Ejemplo n.º 1
0
 /**
  * Kernel request listener callback.
  *
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $contenttypes = $this->config->get('contenttypes', []);
     foreach ($contenttypes as $contenttype) {
         $contenttype = $this->em->getContentType($contenttype['slug']);
         // Check if we need to 'publish' any 'timed' records, or 'depublish' any expired records.
         $this->em->publishTimedRecords($contenttype);
         $this->em->depublishExpiredRecords($contenttype);
     }
 }
Ejemplo n.º 2
0
 /**
  * Fetch a listing of ContentType records.
  *
  * @param string         $contentTypeSlug
  * @param ListingOptions $options
  */
 public function action($contentTypeSlug, ListingOptions $options)
 {
     // Order has to be set carefully. Either set it explicitly when the user
     // sorts, or fall back to what's defined in the contenttype. Except for
     // a ContentType that has a "grouping taxonomy", as that should override
     // it. That exception state is handled by the query OrderHandler.
     $contenttype = $this->em->getContentType($contentTypeSlug);
     $contentParameters = ['paging' => true, 'hydrate' => true, 'order' => $options->getOrder() ?: $contenttype['sort'], 'page' => $options->getPage(), 'filter' => $options->getFilter()];
     // Set the amount of items to show per page
     if (!empty($contenttype['recordsperpage'])) {
         $contentParameters['limit'] = $contenttype['recordsperpage'];
     } else {
         $contentParameters['limit'] = $this->config->get('general/recordsperpage');
     }
     // Filter on taxonomies
     if ($options->getTaxonomies() !== null) {
         foreach ($options->getTaxonomies() as $taxonomy => $value) {
             $contentParameters[$taxonomy] = $value;
         }
     }
     return $this->getContent($contentTypeSlug, $contentParameters, $options);
 }