Beispiel #1
0
 public function testActivityOwner()
 {
     $user = new User();
     $user->setFirstName('First Name');
     $organization = new Organization();
     $organization->setName('Organization One');
     $activityOwner = new ActivityOwner();
     $activityOwner->setUser($user);
     $activityOwner->setOrganization($organization);
     $activityList = new ActivityList();
     $activityList->addActivityOwner($activityOwner);
     $this->assertCount(1, $activityList->getActivityOwners());
     $firstOwner = $activityList->getActivityOwners()->first();
     $this->assertEquals('First Name', $firstOwner->getUser()->getFirstName());
     $this->assertEquals('Organization One', $firstOwner->getOrganization()->getName());
 }
 /**
  * @param ActivityListProviderInterface $provider
  * @param object $entity
  * @param ActivityList $activityList
  */
 protected function fillOwners(ActivityListProviderInterface $provider, $entity, ActivityList $activityList)
 {
     $oldActivityOwners = $activityList->getActivityOwners();
     $newActivityOwners = $provider->getActivityOwners($entity, $activityList);
     $newActivityOwners = new ArrayCollection($newActivityOwners);
     foreach ($oldActivityOwners as $oldOwner) {
         if (!$oldOwner->isOwnerInCollection($newActivityOwners)) {
             $activityList->removeActivityOwner($oldOwner);
         }
     }
     if ($newActivityOwners) {
         foreach ($newActivityOwners as $newOwner) {
             if (!$newOwner->isOwnerInCollection($oldActivityOwners)) {
                 $activityList->addActivityOwner($newOwner);
             }
         }
     }
 }