/**
  * {@inheritdoc}
  */
 public function removeActivityPrototype(ActivityPrototypeInterface $activityPrototype)
 {
     if ($this->hasActivityPrototype($activityPrototype)) {
         $this->activityPrototypes->removeElement($activityPrototype);
     }
     return $this;
 }
 /**
  * @param array $ids
  * @param Collection $collection
  */
 public function reverseTransform($ids, $collection)
 {
     if (count($ids) == 0) {
         // don't check for collection count, a straight clear doesnt initialize the collection
         $collection->clear();
         return $collection;
     }
     $em = $this->getOption('em');
     $metadata = $em->getClassMetadata($this->getOption('className'));
     $reflField = $metadata->getReflectionProperty($metadata->identifier[0]);
     foreach ($collection as $object) {
         $key = array_search($reflField->getValue($object), $ids);
         if (false === $key) {
             $collection->removeElement($object);
         } else {
             unset($ids[$key]);
         }
     }
     // @todo: This can be greatly optimized into a single SELECT .. WHERE id IN () query.
     foreach ($ids as $id) {
         $entity = $em->find($this->getOption('className'), $id);
         if (!$entity) {
             throw new TransformationFailedException("Selected entity of type '" . $this->getOption('className') . "' by id '" . $id . "' which is not present in the database.");
         }
         $collection->add($entity);
     }
     return $collection;
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function removePromotion(PromotionInterface $promotion)
 {
     if ($this->hasPromotion($promotion)) {
         $this->promotions->removeElement($promotion);
     }
     return $this;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function removeActivity(ActivityInterface $activity)
 {
     if ($this->hasActivity($activity)) {
         $this->activities->removeElement($activity);
         $activity->setRegimen(null);
     }
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function removeElement($element) : bool
 {
     $return = parent::removeElement($element);
     if ($return) {
         $this->removeFromHistory($element);
     }
     return $return;
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 public function removeChild(PermissionInterface $permission)
 {
     if ($this->hasChild($permission)) {
         $permission->setParent(null);
         $this->children->removeElement($permission);
     }
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function removeElement($element)
 {
     $this->initialize();
     $removed = $this->coll->removeElement($element);
     if ($removed) {
         $this->changed();
         if ($this->mapping !== null && isset($this->mapping['embedded'])) {
             $this->uow->scheduleOrphanRemoval($element);
         }
     }
     return $removed;
 }
 /**
  * Adds or removes a social profile from the collection.
  *
  * @param array $data
  * @param Collection $object
  * @see \Zend\Hydrator\HydratorInterface::hydrate()
  * @return \Auth\Entity\SocialProfiles\ProfileInterface
  */
 public function hydrate(array $data, $object)
 {
     foreach ($data as $name => $value) {
         if (!isset($this->profileClassMap[$name])) {
             continue;
         }
         if (empty($value)) {
             // We need to check, if collection has a profile and
             // remove it.
             foreach ($object as $p) {
                 if ($p instanceof $this->profileClassMap[$name]) {
                     $object->removeElement($p);
                     continue 2;
                 }
             }
             // No profile found, so do nothing.
             continue;
         }
         if (is_string($value)) {
             $value = \Zend\Json\Json::decode($value, \Zend\Json\Json::TYPE_ARRAY);
         }
         /* If there is already a profile of this type, we do not need to
          * add it, but update the data only.
          */
         foreach ($object as $p) {
             if ($p instanceof $this->profileClassMap[$name]) {
                 // Already a profile in the collection, just update and continue main loop.
                 $p->setData($value);
                 continue 2;
             }
         }
         // We need to add a new profile to the collection.
         $class = $this->profileClassMap[$name];
         $profile = new $class();
         $profile->setData($value);
         $object->add($profile);
     }
     return $object;
 }
Example #9
0
 /**
  * Remove projectUser
  *
  * @param \CentraleLille\CustomFosUserBundle\Entity\ProjectUser $projectUser
  */
 public function removeProjectUser(\CentraleLille\CustomFosUserBundle\Entity\ProjectUser $projectUser)
 {
     $this->projectUsers->removeElement($projectUser);
 }
Example #10
0
 /**
  * Remove favorite Bundle
  *
  * @param Bundle $favoriteBundle
  */
 public function removeFavoriteBundle(Bundle $favoriteBundle)
 {
     $this->favoriteBundles->removeElement($favoriteBundle);
 }
Example #11
0
 /**
  * 
  * @param Exam $exam
  * @return ExamContent
  */
 function removeExam($exam)
 {
     $this->exams->removeElement($exam);
     $exam->setContent(null);
     return $this;
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function removeElement($element)
 {
     // TODO: Assuming the identity of entities in a collection is always based
     //       on their primary key (there is no equals/hashCode in PHP),
     //       if the collection is not initialized, we could issue a straight
     //       SQL DELETE/UPDATE on the association (table) without initializing
     //       the collection.
     /*if ( ! $this->_initialized) {
           $this->_em->getUnitOfWork()->getCollectionPersister($this->_association)
               ->deleteRows($this, $element);
       }*/
     $this->_initialize();
     $result = $this->_coll->removeElement($element);
     $this->_changed();
     return $result;
 }
Example #13
0
 /**
  * 
  * @param Subject $child
  * @return Subject
  */
 function removeChild($child)
 {
     $this->children->removeElement($child);
     return $this;
 }
Example #14
0
 /**
  * Remove User entity from collection (one to many).
  *
  * @param \Entity\User $user
  * @return \Entity\Country
  */
 public function removeUser(User $user)
 {
     $this->users->removeElement($user);
     return $this;
 }
 /**
  *
  * @param \Amisure\P4SApiBundle\Entity\EvaluationModelItemResponse $item        	
  * @return \Amisure\P4SApiBundle\Entity\EvaluationModelItem
  */
 public function removeResponse(\Amisure\P4SApiBundle\Entity\EvaluationModelItemResponse $response)
 {
     $this->responses->removeElement($response);
     return $this;
 }
Example #16
0
 /**
  * @param SubscriberInterface $subscriber
  * @return Newsletter
  */
 public function removeSubscriber(SubscriberInterface $subscriber)
 {
     $subscriber->removeNewsletter($this);
     $this->subscribers->removeElement($subscriber);
     return $this;
 }
Example #17
0
 public function removeResponse(EvaluationItemResponse $response)
 {
     $this->responses->removeElement($response);
     return $this;
 }
Example #18
0
 /**
  * Remove permission
  *
  * @param Permission $permission
  */
 public function removePermission(Permission $permission)
 {
     $this->permissions->removeElement($permission);
 }
 /**
  *
  * @param \Amisure\P4SApiBundle\Entity\EvaluationItem $item        	
  * @return \Amisure\P4SApiBundle\Entity\EvaluationModelCategory
  */
 public function removeItem(EvaluationModelItem $item)
 {
     $this->items->removeElement($item);
     return $this;
 }
 public function removeOrganization(OrganizationUser $organization)
 {
     $this->organizations->removeElement($organization);
     return $this;
 }
Example #21
0
 /**
  * Remove projects
  *
  * @param Project $project
  */
 public function removeProject(Project $project)
 {
     $this->projects->removeElement($project);
 }
 public function removeCategory(EvaluationModelCategory $category)
 {
     $this->categories->removeElement($category);
     return $this;
 }