| Code Coverage | ||||||||||
| Classes and Traits | Functions and Methods | Lines | ||||||||
| Total |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 4 | CRAP |  | 0.00% | 0 / 18 | 
| ItemDrop |  | 0.00% | 0 / 1 |  | 0.00% | 0 / 4 | 30 |  | 0.00% | 0 / 18 | 
| getSortableModel |  | 0.00% | 0 / 1 | 6 |  | 0.00% | 0 / 6 | |||
| save |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 4 | |||
| rules |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 5 | |||
| formName |  | 0.00% | 0 / 1 | 2 |  | 0.00% | 0 / 3 | |||
| <?php | |
| /** | |
| * @link https://www.humhub.org/ | |
| * @copyright Copyright (c) 2018 HumHub GmbH & Co. KG | |
| * @license https://www.humhub.com/licences | |
| * | |
| */ | |
| /** | |
| * Created by PhpStorm. | |
| * User: davidborn | |
| */ | |
| namespace humhub\modules\tasks\models\forms; | |
| use humhub\modules\tasks\models\Sortable; | |
| use humhub\modules\tasks\models\Task; | |
| use yii\base\Model; | |
| class ItemDrop extends Model | |
| { | |
| /** | |
| * @var Sortable | |
| */ | |
| public $model; | |
| /** | |
| * @var integer | |
| */ | |
| public $modelId; | |
| /** | |
| * @var Task | |
| */ | |
| public $modelClass; | |
| /** | |
| * @var integer | |
| */ | |
| public $index; | |
| /** | |
| * @var integer | |
| */ | |
| public $itemId; | |
| public function getSortableModel() | |
| { | |
| if(!$this->model) { | |
| $this->model = call_user_func("$this->modelClass::findOne", ['id' => $this->modelId]); | |
| } | |
| return $this->model; | |
| } | |
| public function save() | |
| { | |
| $this->getSortableModel()->moveItemIndex($this->itemId, $this->index); | |
| return true; | |
| } | |
| public function rules() | |
| { | |
| return [ | |
| [['modelId', 'itemId', 'index'], 'integer'] | |
| ]; | |
| } | |
| public function formName() | |
| { | |
| return 'ItemDrop'; | |
| } | |
| } |