コード例 #1
0
 /**
  * @param string        $permalink
  * @param PermalinkInterface $permalinkGenerator
  *
  * @return WorkInterface
  */
 public function findOneByPermalink($permalink, PermalinkInterface $permalinkGenerator)
 {
     $repository = $this->getRepository();
     $query = $repository->createQueryBuilder('p');
     $urlParameters = $permalinkGenerator->getParameters($permalink);
     $parameters = array();
     if (isset($urlParameters['slug'])) {
         $query->andWhere('p.slug = :slug');
         $parameters['slug'] = $urlParameters['slug'];
     }
     if (isset($urlParameters['collection'])) {
         $pcqp = $this->getPublicationCollectionQueryParts($urlParameters['collection']);
         $parameters = array_merge($parameters, $pcqp['params']);
         $query->leftJoin('p.collection', 'c')->andWhere($pcqp['query']);
     }
     if (count($parameters) == 0) {
         return null;
     }
     $query->setParameters($parameters);
     $results = $query->getQuery()->getResult();
     if (count($results) > 0) {
         return $results[0];
     }
     return null;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
 {
     if (!$childAdmin && !in_array($action, array('edit'))) {
         return;
     }
     $admin = $this->isChild() ? $this->getParent() : $this;
     $id = $admin->getRequest()->get('id');
     $menu->addChild($this->trans('sidemenu.link_edit_work'), array('uri' => $admin->generateUrl('edit', array('id' => $id))));
     if ($this->hasSubject() && $this->getSubject()->getId() !== null) {
         $menu->addChild($this->trans('sidemenu.link_view_work'), array('uri' => $admin->getRouteGenerator()->generate('nz_portfolio_view', array('permalink' => $this->permalinkGenerator->generate($this->getSubject())))));
     }
 }
コード例 #3
0
 /**
  * @param \Nz\PortfolioBundle\Model\WorkInterface
  *
  * @return string|Exception
  */
 public function generatePermalink(WorkInterface $work)
 {
     return $this->permalinkGenerator->generate($work);
 }