protected function createComponentPost() : Nette\Application\UI\Multiplier { return new Nette\Application\UI\Multiplier(function ($id) : Ytnuk\Blog\Post\Control { $entity = $this->postRepository->getById($id); if ($entity instanceof Ytnuk\Blog\Post\Entity) { return $this->postControl->create($entity); } return NULL; }); }
public function setValues($values, $erase = FALSE) : Ytnuk\Orm\Form\Container { $container = parent::setValues($values, $erase); $link = $this->entity->link; $link->module = 'Blog:Post'; if (!$link->parameters->get()->getBy(['key' => $key = current($this->repository->getEntityMetadata()->getPrimaryKey())])) { $linkParameter = new Ytnuk\Link\Parameter\Entity(); $linkParameter->key = $key; $linkParameter->value = $this->entity->getPersistedId() ?: $this->repository->persist($this->entity)->getPersistedId(); $link->parameters->add($linkParameter); } return $container; }
public function actionEdit(int $id) { if (!($this->entity = $this->repository->getById($id))) { $this->error(); } }
public function getterPosts() : Nextras\Orm\Collection\ICollection { return $this->postRepository->findBy(['this->categoryNodes->category' => $this->id]); }