Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored
AssignSwitches
for Hubs and Servers (#76)
* Refactored `AssignSwitches` for Hubs and Servers * minor
- Loading branch information
Showing
18 changed files
with
421 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace hipanel\modules\server\forms; | ||
|
||
use hipanel\base\ModelTrait; | ||
use hipanel\modules\server\models\AssignSwitchInterface; | ||
use hipanel\modules\server\models\Hub; | ||
|
||
class AssignSwitchesForm extends Hub implements AssignSwitchInterface | ||
{ | ||
use ModelTrait; | ||
|
||
public $switchVariants = ['net', 'kvm', 'pdu', 'rack', 'console']; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function tableName() | ||
{ | ||
return 'hub'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function rules() | ||
{ | ||
return array_merge(parent::rules(), $this->defaultSwitchRules(), $this->generateUniqueValidators()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace hipanel\modules\server\models; | ||
|
||
interface AssignSwitchInterface | ||
{ | ||
public function getBindings(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
/** | ||
* Finance module for HiPanel | ||
* | ||
* @link https://github.com/hiqdev/hipanel-module-finance | ||
* @package hipanel-module-finance | ||
* @license BSD-3-Clause | ||
* @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace hipanel\modules\server\models\query; | ||
|
||
use hiqdev\hiart\ActiveQuery; | ||
use Yii; | ||
|
||
class HubQuery extends ActiveQuery | ||
{ | ||
public function withBindings(): self | ||
{ | ||
if (Yii::$app->user->can('hub.read')) { | ||
$this->joinWith('bindings'); | ||
$this->andWhere(['with_bindings' => true]); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.