Example #1
0
 /**
  * Build references (subject, directComplement, indirectComplement)
  * of timeline action
  */
 public function build()
 {
     foreach ($this->action->getActionComponents() as $actionComponent) {
         if (!$actionComponent->isText()) {
             $this->buildComponent($actionComponent);
         }
     }
 }
 /**
  * @param  ActionInterface $action    action
  * @param  string          $type      type
  * @param  mixed           $component component
  * @throws \Exception
  */
 public function addComponent($action, $type, $component)
 {
     if (!$component instanceof ComponentInterface && !is_scalar($component)) {
         $component = $this->findOrCreateComponent($component);
         if (null === $component) {
             throw new \Exception(sprintf('Impossible to create component from %s.', $type));
         }
     }
     $action->addComponent($type, $component, $this->actionComponentClass);
 }
 /**
  * @param ComponentInterface $component
  *
  * @return AdminInterface
  */
 protected function getAdmin(ComponentInterface $component, ActionInterface $action = null)
 {
     if ($action && ($adminComponent = $action->getComponent('admin_code'))) {
         return $this->pool->getAdminByAdminCode($adminComponent);
     }
     try {
         return $this->pool->getAdminByClass($component->getModel());
     } catch (\RuntimeException $e) {
     }
     return false;
 }
 /**
  * {@inheritdoc}
  */
 public function supports(ActionInterface $action)
 {
     return in_array($action->getVerb(), $this->supportedVerbs);
 }
 /**
  * {@inheritdoc}
  */
 public function createAndPersist(ActionInterface $action, ComponentInterface $subject, $context = 'GLOBAL', $type = TimelineInterface::TYPE_TIMELINE)
 {
     $redisKey = $this->getRedisKey($subject, $context, $type);
     $this->persistedDatas[] = array('zAdd', $redisKey, $action->getSpreadTime(), $action->getId());
     // we want to deploy on a subject action list to enable ->getSubjectActions feature..
     if ('timeline' === $type) {
         $redisKey = $this->getSubjectRedisKey($action->getSubject());
         $this->persistedDatas[] = array('zAdd', $redisKey, $action->getSpreadTime(), $action->getId());
     }
 }
 /**
  * {@inheritdoc}
  */
 public function updateAction(ActionInterface $action)
 {
     $action->setId($this->getNextId());
     $this->client->hset($this->getActionKey(), $action->getId(), serialize($action));
     $this->deployActionDependOnDelivery($action);
 }
Example #7
0
 /**
  * @param ActionInterface $action action
  *
  * @return EntryCollection
  */
 public function processSpreads(ActionInterface $action)
 {
     if ($this->onSubject) {
         $this->entryCollection->add(new Entry($action->getSubject()), 'GLOBAL');
     }
     foreach ($this->spreads as $spread) {
         if ($spread->supports($action)) {
             $spread->process($action, $this->entryCollection);
         }
     }
     return $this->getEntryCollection();
 }