本文整理汇总了PHP中Collection::removeElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::removeElement方法的具体用法?PHP Collection::removeElement怎么用?PHP Collection::removeElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::removeElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeActivityPrototype
/**
* {@inheritdoc}
*/
public function removeActivityPrototype(ActivityPrototypeInterface $activityPrototype)
{
if ($this->hasActivityPrototype($activityPrototype)) {
$this->activityPrototypes->removeElement($activityPrototype);
}
return $this;
}
示例2: reverseTransform
/**
* @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;
}
示例3: removePromotion
/**
* {@inheritdoc}
*/
public function removePromotion(PromotionInterface $promotion)
{
if ($this->hasPromotion($promotion)) {
$this->promotions->removeElement($promotion);
}
return $this;
}
示例4: removeActivity
/**
* {@inheritdoc}
*/
public function removeActivity(ActivityInterface $activity)
{
if ($this->hasActivity($activity)) {
$this->activities->removeElement($activity);
$activity->setRegimen(null);
}
}
示例5: removeElement
/**
* {@inheritdoc}
*/
public function removeElement($element) : bool
{
$return = parent::removeElement($element);
if ($return) {
$this->removeFromHistory($element);
}
return $return;
}
示例6: removeChild
/**
* {@inheritdoc}
*/
public function removeChild(PermissionInterface $permission)
{
if ($this->hasChild($permission)) {
$permission->setParent(null);
$this->children->removeElement($permission);
}
return $this;
}
示例7: removeElement
/**
* {@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;
}
示例8: hydrate
/**
* 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;
}
示例9: removeProjectUser
/**
* Remove projectUser
*
* @param \CentraleLille\CustomFosUserBundle\Entity\ProjectUser $projectUser
*/
public function removeProjectUser(\CentraleLille\CustomFosUserBundle\Entity\ProjectUser $projectUser)
{
$this->projectUsers->removeElement($projectUser);
}
示例10: removeFavoriteBundle
/**
* Remove favorite Bundle
*
* @param Bundle $favoriteBundle
*/
public function removeFavoriteBundle(Bundle $favoriteBundle)
{
$this->favoriteBundles->removeElement($favoriteBundle);
}
示例11: removeExam
/**
*
* @param Exam $exam
* @return ExamContent
*/
function removeExam($exam)
{
$this->exams->removeElement($exam);
$exam->setContent(null);
return $this;
}
示例12: removeElement
/**
* {@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;
}
示例13: removeChild
/**
*
* @param Subject $child
* @return Subject
*/
function removeChild($child)
{
$this->children->removeElement($child);
return $this;
}
示例14: removeUser
/**
* 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;
}
示例15: removeResponse
/**
*
* @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;
}