예제 #1
0
 /**
  * Render the activity
  *
  * @param ActivityStream $stream
  *
  * @return mixed
  */
 public function renderFilter(ActivityStream $stream)
 {
     $em = $this->objectManager->getRepository($stream->getObjectType());
     $entity = $em->find($stream->getObjectId());
     $bundleName = self::getBundleName($stream->getObjectType());
     return $this->twig->render($bundleName . ":Dashboard:" . $stream->getVerb() . ".html.twig", array('entity' => $entity, 'stream' => $stream));
 }
예제 #2
0
 /**
  * Create a new activity
  *
  * @param EventArgs $eventArgs
  * @param string    $verb
  * @param object    $entity
  *
  * @return ActivityStream
  */
 public function createActivity(EventArgs $eventArgs, $verb, $entity)
 {
     $em = $eventArgs->getEntityManager();
     $entityClass = \Doctrine\Common\Util\ClassUtils::getClass($entity);
     $classMetaData = $em->getClassMetadata($entityClass);
     if (!$classMetaData->reflClass->implementsInterface('Jumph\\Bundle\\DashboardBundle\\Entity\\ActivityInterface')) {
         return '';
     }
     $activityStreamMeta = $em->getClassMetadata("JumphDashboardBundle:ActivityStream");
     $uow = $em->getUnitOfWork();
     $activityStream = new ActivityStream();
     $activityStream->setVerb($verb);
     $activityStream->setObjectType($entityClass);
     $activityStream->setUser($this->user);
     if ($verb === 'create') {
         $this->pendingInserts[spl_object_hash($entity)] = $activityStream;
     } else {
         $activityStream->setObjectId($entity->getId());
     }
     $em->persist($activityStream);
     $uow->computeChangeSet($activityStreamMeta, $activityStream);
     return $activityStream;
 }