/**
  * Get aggregator
  */
 public function get($identifier = NULL)
 {
     $aggregator = parent::get($identifier);
     if (is_array($aggregator)) {
         // filter public entities
         return array('channels' => array_values(array_filter($aggregator['entities'], function ($agg) {
             return $agg instanceof Model\Aggregator;
         })));
     } else {
         if ($aggregator instanceof Model\Aggregator) {
             return $aggregator;
         } else {
             throw new \Exception('Entity is not a group: \'' . $identifier . '\'');
         }
     }
 }
 /**
  * Get channel
  */
 public function get($identifier = NULL)
 {
     $channel = parent::get($identifier);
     if (is_array($channel)) {
         // filter public entities
         return array('channels' => array_values(array_filter($channel['entities'], function ($ch) {
             return $ch instanceof Model\Channel;
         })));
     } else {
         if ($channel instanceof Model\Channel) {
             return $channel;
         } else {
             throw new \Exception('Entity is not a channel: \'' . $identifier . '\'');
         }
     }
 }
 /**
  * Delete Aggregator or remove entity from aggregator
  */
 public function delete($identifier)
 {
     if (!isset($identifier)) {
         return;
     }
     $aggregator = NULL;
     if ($uuids = self::makeArray($this->request->query->get('uuid'))) {
         // remove entity from aggregator
         $aggregator = $this->get($identifier);
         $ec = new EntityController($this->request, $this->em);
         foreach ($uuids as $uuid) {
             $aggregator->removeChild($ec->get($uuid));
         }
         $this->em->flush();
     } else {
         // remove aggregator
         parent::delete($identifier);
     }
     return $aggregator;
 }
Пример #4
0
 public function run($operation, array $identifiers = array())
 {
     $ec = new EntityController($this->view, $this->em);
     $entity = $ec->get($identifiers[0]);
     return $this->{$operation}($entity);
 }
 /**
  * Delete Aggregator or remove entity from aggregator
  */
 public function delete($identifier)
 {
     if (isset($identifier) && ($uuid = $this->view->request->getParameter('uuid'))) {
         // remove entity from aggregator
         $aggregator = $this->get($identifier);
         if ($uuid) {
             $ec = new EntityController($this->view, $this->em);
             $aggregator->removeChild($ec->get($uuid));
             $this->em->flush();
         } else {
             throw new \Exception('You have to specifiy a UUID to remove');
         }
     } else {
         // remove aggregator
         parent::delete($identifier);
     }
     return $aggregator;
 }
 protected static function getChannelByUUID($uuid)
 {
     $ec = new Controller\EntityController(null, self::$em);
     return $ec->get($uuid);
 }