예제 #1
1
 public function indexAction()
 {
     $entity = $this->getEntity();
     if (!$entity) {
         $this->getResponse()->setStatusCode(404);
         return false;
     }
     $type = $this->moduleOptions->getType($entity->getType()->getName());
     if ($type->hasComponent('redirect')) {
         /* @var $redirect RedirectOptions */
         $redirect = $type->getComponent('redirect');
         foreach ($entity->getChildren('link', $redirect->getToType()) as $child) {
             if (!$child->isTrashed() && $child->hasCurrentRevision()) {
                 return $this->redirect()->toRoute('uuid/get', ['uuid' => $child->getId()]);
             }
         }
     }
     $model = new ViewModel(['entity' => $entity]);
     $model->setTemplate('entity/page/default');
     if ($this->params('isXmlHttpRequest', false)) {
         $model->setTemplate('entity/view/default');
     }
     $this->layout('layout/3-col');
     if (!$entity->hasCurrentRevision()) {
         $this->layout('layout/2-col');
         $model->setTemplate('entity/page/pending');
     }
     return $model;
 }
 /**
  * @param EntityInterface $entity
  * @return Form
  */
 protected function getForm(EntityInterface $entity, $id = null)
 {
     // Todo: Unhack
     $type = $entity->getType()->getName();
     $form = $this->moduleOptions->getType($type)->getComponent('repository')->getForm();
     $form = $this->getServiceLocator()->get($form);
     $revision = $this->getRevision($entity, $id);
     if (is_object($revision)) {
         $data = [];
         foreach ($revision->getFields() as $field) {
             $data[$field->getName()] = $field->getValue();
         }
         $form->setData($data);
     }
     $license = $entity->getLicense();
     $agreement = $license->getAgreement() ? $license->getAgreement() : $license->getTitle();
     $form->get('license')->get('agreement')->setLabel($agreement);
     $form->get('changes')->setValue('');
     return $form;
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function provide()
 {
     $notTrashed = new NotTrashedCollectionFilter();
     $hasCurrent = new HasCurrentRevisionCollectionFilter();
     $chain = new FilterChain();
     $chain->attach($notTrashed);
     $chain->attach($hasCurrent);
     $container = [];
     $types = $this->options->getTypes();
     foreach ($types as $type) {
         if ($type->hasComponent('search')) {
             /* @var $component SearchOptions */
             $component = $type->getComponent('search');
             if ($component->getEnabled()) {
                 $name = $type->getName();
                 $entities = $this->entityManager->findEntitiesByTypeName($name, true);
                 $entities = $chain->filter($entities);
                 $this->addEntitiesToContainer($entities, $container);
             }
         }
     }
     return $container;
 }