/** * Prepare execute hook. * * @throws \UnexpectedValueException * @return void */ protected function prepareExecute() { parent::prepareExecute(); $this->user = $this->container->get('user'); $this->lang = $this->container->get('language'); $this->model = $this->getModel($this->viewItem); $this->table = $this->model->getTable($this->viewItem, $this->prefix . 'Table'); // Determine model if (!$this->model instanceof CrudModel) { throw new \UnexpectedValueException(sprintf('%s model need extend to CrudModel', $this->name)); } // Determine the name of the primary key for the data. if (empty($this->key)) { $this->key = $this->table->getKeyName(); } // To avoid data collisions the urlVar may be different from the primary key. if (empty($this->urlVar)) { $this->urlVar = $this->key; } }