コード例 #1
0
 /**
  * @param array         $insertedEntities
  * @param EntityManager $entityManager
  * @return bool
  */
 public function processInsertEntities($insertedEntities, EntityManager $entityManager)
 {
     if (!empty($insertedEntities)) {
         foreach ($insertedEntities as $entity) {
             $activityList = $this->chainProvider->getActivityListEntitiesByActivityEntity($entity);
             if ($activityList) {
                 $entityManager->persist($activityList);
             }
         }
         return true;
     }
     return false;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function executeAction($context)
 {
     $email = $this->contextAccessor->getValue($context, $this->activityEntity);
     $targetEntity = $this->contextAccessor->getValue($context, $this->targetEntity);
     $activityList = $this->chainProvider->getActivityListEntitiesByActivityEntity($email);
     if ($activityList) {
         $this->entityManager->persist($activityList);
     }
     $result = $this->activityManager->addAssociation($email, $targetEntity);
     if ($this->attribute !== null) {
         $this->contextAccessor->setValue($context, $this->attribute, $result);
     }
 }
コード例 #3
0
 /**
  * @param ObjectManager             $manager
  * @param ActivityListChainProvider $provider
  * @param array                     $entities
  * @param string                    $ownerField
  * @param string                    $organizationField
  */
 protected function saveActivityLists(ObjectManager $manager, ActivityListChainProvider $provider, $entities, $ownerField = '', $organizationField = '')
 {
     $accessor = PropertyAccess::createPropertyAccessor();
     foreach ($entities as $entity) {
         if ($ownerField && $organizationField) {
             $owner = $accessor->getValue($entity, $ownerField);
             if ($owner instanceof User) {
                 $this->setSecurityContext($owner, $accessor->getValue($entity, $organizationField));
             }
         }
         $activityListEntity = $provider->getActivityListEntitiesByActivityEntity($entity);
         if ($activityListEntity) {
             $manager->persist($activityListEntity);
         }
     }
     $manager->flush();
     $manager->clear();
 }