コード例 #1
0
ファイル: TopicModel.php プロジェクト: asika32764/natika
 /**
  * getItem
  *
  * @param int $pk
  *
  * @return  Data
  */
 public function getItem($pk = null)
 {
     $item = parent::getItem($pk);
     if ($item->notNull()) {
         $mapper = new CategoryMapper();
         $item->category = $mapper->findOne($item->category_id);
     }
     return $item;
 }
コード例 #2
0
ファイル: AdminModel.php プロジェクト: ventoviro/phoenix
 /**
  * save
  *
  * @param DataInterface $data
  *
  * @return  boolean
  */
 public function save(DataInterface $data)
 {
     $result = parent::save($data);
     // Reorder
     if ($result && $this->get('order.position') == static::ORDER_POSITION_FIRST) {
         $pk = $data->{$this->getKeyName()};
         $this->reorder(array($pk => 0));
         $this->state->set('order.position', null);
     }
     return $result;
 }
コード例 #3
0
 /**
  * prepareExecute
  *
  * @return  void
  *
  * @throws \LogicException
  * @throws \DomainException
  */
 protected function prepareExecute()
 {
     parent::prepareExecute();
     $this->model = $this->getModel();
     $this->dataObject = $this->getDataObject();
     $this->task = $this->input->get('task');
     // Determine model
     if (!$this->model instanceof CrudRepositoryInterface) {
         throw new \DomainException(sprintf('%s model should be instance of %s, class: %s', $this->model->getName(), CrudRepositoryInterface::class, get_class($this->model)));
     }
     // Determine the name of the primary key for the data.
     if (empty($this->keyName)) {
         $this->keyName = $this->model->getKeyName(false) ?: 'id';
     }
     $this->checkAccess($this->dataObject);
 }