Beispiel #1
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;
 }