userId === null) { throw new InvalidConfigException( __CLASS__ . '::$userId is required'); } } /** * @inheritdoc */ public function run() { $model = $this->make(Assignment::class, [], ['user_id' => $this->userId]); if ($model->load($this->params)) { $this->make(UpdateAuthAssignmentsService::class, [$model])->run(); } return $this->render('/widgets/assignments/form', [ 'model' => $model, 'availableItems' => $this->getAvailableItems() ]); } /** * Returns all available auth items to be attached to the user * * @return array */ protected function getAvailableItems() { return ArrayHelper::map($this->getAuthManager()->getItems(), 'name', function ($item) { return empty($item->description) ? $item->name : $item->name . ' (' . $item->description . ')'; }); } }