public function __construct(ManagedRepositoryInterface $repository, UrlGeneratorInterface $urlGenerator, ControllerNodeInterface $currentControllerNode = null, $routeName = 'cms') { $rootNode = $repository->queryMetadata('getRootCmsNode'); parent::__construct($rootNode, $routeName, $urlGenerator); $this->repository = $repository; $this->currentControllerNode = $currentControllerNode; $diff = $currentControllerNode === null ? [] : [$currentControllerNode->getActionName() => null]; foreach (array_diff(['index', 'add'], array_keys($diff)) as $action) { if (!$this->hasChild($action) && $repository->queryMetadata('hasCmsNode', compact('action'))) { $node = $repository->queryMetadata('getCmsNode', compact('action')); $listNode = $this->createListNode($node); $this->wrapChild($listNode, $action, $node->getActionLabel(), false); } } $this->childNodes = array_diff_key($this->childNodes, $diff); }
protected function getFormData(ManagedRepositoryInterface $repository, Request $request) { if (!($id = $request->get('id'))) { throw new HttpException(404, 'No ID was specified.'); } if (!($entity = $repository->find($id))) { $humanName = $repository->queryMetadata('getEntityHumanName'); $message = sprintf('No %s exists with ID %d.', $humanName, $id); throw new HttpException(404, $message); } $formData = new \stdClass(); $formData->entity = $entity; return $formData; }
public function getLabel(ManagedRepositoryInterface $repository) { return sprintf('Add new %s', $repository->queryMetadata('getEntityHumanName')); }
/** * @return string */ public function getLabel() { return sprintf('List %s', $this->repository->queryMetadata('getEntityHumanName', ['plural' => true])); }
/** * @param ManagedRepositoryInterface $repository * @return bool */ public function isRepositoryEligible(ManagedRepositoryInterface $repository) { $crud = $repository->queryMetadata('getEntityCrud'); return !empty($crud->read); }
/** * @return array */ public function getColumns() { return $this->repository->queryMetadata('getVisiblePropertyLabels', ['important' => true]); }
public function isRepositoryEligible(ManagedRepositoryInterface $repository) { $crud = $repository->queryMetadata('getEntityCrud'); $property = $this->isCreate() ? 'create' : 'update'; return !empty($crud->{$property}); }