示例#1
0
 public function executeSlug($request)
 {
     $this->checkList($request);
     //check that the entity has the given name
     $name = LsSlug::convertSlugToName($request->getParameter('slug'));
     if ($this->list->name != $name) {
         $this->forward404();
     }
     $this->forward('list', $request->getParameter('target', 'view'));
 }
示例#2
0
 static function getBySlug($slug, $extension = null, $useAliases = false)
 {
     $name = LsSlug::convertSlugToName($slug);
     if ($extension) {
         $q = self::getByExtensionQuery($extension);
     } else {
         $q = LsDoctrineQuery::create()->from('Entity e');
     }
     $q->andWhere('e.name = ?', $name);
     if (!($entities = $q->execute())) {
         $q = LsDoctrineQuery::create()->from('Entity e')->leftJoin('e.Alias a')->where('a.name = ?', $name);
         $entities = $q->execute();
     }
     return $entities;
 }
示例#3
0
 public function executeOrg($request)
 {
     if ($id = $request->getParameter('id')) {
         //id given, we check that the id exists
         $this->checkEntity($request);
         $this->forward404Unless($this->entity['primary_ext'] == 'Org');
         //check that the entity has the given name
         $name = LsSlug::convertSlugToName($request->getParameter('slug'));
         //if the name isn't primary, we redirect to the url with the primary name
         if ($this->entity->rawGet('name') != $name) {
             $params = $request->getParameterHolder()->getAll();
             if ($params['target'] == 'view') {
                 $params['target'] = null;
             }
             $url = EntityTable::generateRoute($this->entity, $params['target'], $params);
             $this->redirect($url);
         }
     } else {
         $entities = EntityTable::getBySlug($request->getParameter('slug'), 'Org', $useAliases = true);
         switch ($q->count()) {
             case 0:
                 $this->forward404();
                 break;
             case 1:
                 $this->entity = $entities[0];
                 $request->setParameter('id', $this->entity->id);
                 break;
             default:
                 $request->setParameter('extension', 'Org');
                 $this->forward('entity', 'disambiguation');
                 break;
         }
     }
     $this->forward('entity', $request->getParameter('target', 'view'));
 }