Пример #1
0
 /**
  * @param Entity $entity
  * @param $id
  *
  * @return \Kalnoy\Cruddy\Contracts\Field
  */
 protected function resolveField(Entity $entity, $id)
 {
     $field = $entity->getFields()->get($id);
     if ($field === null) {
         throw new \RuntimeException("The field [{$entity->getId()}.{$id}] is not found.");
     }
     return $field;
 }
Пример #2
0
 /**
  * @param string $action
  * @param Entity $entity
  *
  * @return bool
  */
 public function isPermitted($action, Entity $entity)
 {
     $key = "{$entity->getId()}.{$action}";
     return ($user = $this->sentry->getUser()) && $user->hasAccess($key);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     return ['multiple' => $this->isMultiple(), 'reference' => $this->reference->getId()] + parent::toArray();
 }