Publication\Model\Publication::findCachedBySlug PHP Метод

findCachedBySlug() публичный статический Метод

public static findCachedBySlug ( $slug )
    public static function findCachedBySlug($slug)
    {
        $publication = self::findFirst(["slug = '{$slug}'", 'cache' => ['key' => self::cacheSlugKey($slug), 'lifetime' => 60]]);
        return $publication;
    }

Usage Example

Пример #1
0
 public function publicationAction()
 {
     $slug = $this->dispatcher->getParam('slug', 'string');
     $type = $this->dispatcher->getParam('type', 'string');
     $publication = Publication::findCachedBySlug($slug);
     if (!$publication) {
         throw new Exception("Publication '{$slug}.html' not found");
     }
     if ($publication->getTypeSlug() != $type) {
         throw new Exception("Publication type <> {$type}");
     }
     $this->helper->title()->append($publication->getMeta_title());
     $this->helper->meta()->set('description', $publication->getMeta_description());
     $this->helper->meta()->set('keywords', $publication->getMeta_keywords());
     $this->view->publication = $publication;
     $this->helper->menu->setActive($type);
 }