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);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public function getLabel(ManagedRepositoryInterface $repository)
 {
     return sprintf('Add new %s', $repository->queryMetadata('getEntityHumanName'));
 }
Exemplo n.º 4
0
 /**
  * @return string
  */
 public function getLabel()
 {
     return sprintf('List %s', $this->repository->queryMetadata('getEntityHumanName', ['plural' => true]));
 }
Exemplo n.º 5
0
 /**
  * @param ManagedRepositoryInterface $repository
  * @return bool
  */
 public function isRepositoryEligible(ManagedRepositoryInterface $repository)
 {
     $crud = $repository->queryMetadata('getEntityCrud');
     return !empty($crud->read);
 }
Exemplo n.º 6
0
 /**
  * @return array
  */
 public function getColumns()
 {
     return $this->repository->queryMetadata('getVisiblePropertyLabels', ['important' => true]);
 }
Exemplo n.º 7
0
 public function isRepositoryEligible(ManagedRepositoryInterface $repository)
 {
     $crud = $repository->queryMetadata('getEntityCrud');
     $property = $this->isCreate() ? 'create' : 'update';
     return !empty($crud->{$property});
 }