public function clearCollections() { $this->hookedObjectCollections->forAll(function ($key, HookedObjectCollectionEntity $hookedObjectCollectionEntity) { $hookedObjectCollectionEntity->getCollection()->getHookedObjectCollections()->removeElement($hookedObjectCollectionEntity); $hookedObjectCollectionEntity->setCollection(null)->setHookedObject(null); }); $this->hookedObjectCollections->clear(); }
/** * @param array $collection * @param MapInterface $map * @param ObjectFactoryInterface|string $factory * @param null $aggregator * @throws \InvalidArgumentException */ public function processing(array $collection, MapInterface $map, $factory, $aggregator = null) { $this->aggregator = $aggregator; $this->collection = new ArrayCollection($collection); $this->map = $map; // Checking type of factory and then set as internal tool if (is_string($factory)) { $this->factory = $this->container->get($factory); } else { $this->factory = $factory; } if (count($collection) == 0) { throw new \InvalidArgumentException('Collection can\'t be null'); } // Split collection to "new" and "exists" $this->ranking(); // If collection "exists" not empty, then load items form database if (!$this->exists->isEmpty()) { $this->loadExistsObjects(); } // If collection "new" not empty, then create new entities if (!$this->new->isEmpty()) { $this->createNewObjects(); } // Clean internal "common" collection $this->collection->clear(); // Clean aggregator $this->aggregator = null; }
/** * Set items * * @param Iterable $items * * @return Category */ public function setItems($items) { $this->items->clear(); foreach ($items as $item) { $this->addItem($item); } return $this; }
/** * @param ConfigModelValue[] $values * @return $this */ public function setValues($values) { $this->values->clear(); foreach ($values as $value) { $this->addValue($value); } return $this; }
/** * Set parameters. * * @param array $parameters * * @return $this */ public function setParameters($parameters) { if ($this->parameters instanceof ArrayCollection) { $this->parameters->clear(); } else { $this->initializeParameters(); } foreach ($parameters as $parameter => $value) { $this->setParameter(trim($parameter), $value); } return $this; }
public function clear() { if (null === $this->entries) { $this->__load___(); } $this->entries->clear(); }
/** * Restore all flushed entities to their decrypted state * * @param PostFlushEventArgs $eventArgs */ public function postFlush(PostFlushEventArgs $eventArgs) { foreach ($this->flushedEntities as $entity) { $this->decryptEntity($entity); } $this->flushedEntities->clear(); }
/** * Set payload data. * * @param array $data * * @throws \InvalidArgumentException * * @return $this */ public function setPayloadData(array $data) { $this->payload->clear(); foreach ($data as $key => $value) { $this->setPayload($key, $value); } return $this; }
/** * Set tags * * @param Iterable $tags * * @return Item */ public function setTags($tags) { $this->tags->clear(); foreach ($tags as $tag) { $this->addTag($tag); } return $this; }
/** * @param ArrayCollection|array $folders * * @return $this */ public function setSubFolders($folders) { $this->subFolders->clear(); foreach ($folders as $folder) { $this->addSubFolder($folder); } return $this; }
/** * @param \Shopware\Models\Property\Option[] $options * @return Group */ public function setOptions(array $options) { $this->options->clear(); foreach ($options as $option) { $this->addOption($option); } return $this; }
/** * Set addresses. * * This method could not be named setAddresses because of bug CRM-253. * * @param ArrayCollection|AbstractAddress[] $addresses * * @return $this */ public function resetAddresses($addresses) { $this->addresses->clear(); foreach ($addresses as $address) { $this->addAddress($address); } return $this; }
/** * Clear all Products * * @return Sale */ public function clearProducts() { foreach ($this->products as $product) { $this->removeProductWithSale($product); } $this->products->clear(); return $this; }
/** * @param $keywords */ public function setKeywords(array $keywords) { $this->keywords->clear(); foreach ($keywords as $keyword) { if ($keyword instanceof FileKeyword) { $this->keywords->add($keyword); } } }
/** * @param array $types */ public function setTypesAsArray($types) { $this->types->clear(); foreach ($types as $type) { if ($type) { $this->types[] = new TypeEntity($type, $this); } } }
public function buildForm(FormBuilderInterface $builder, array $options) { $categories = $this->loadCategories($options); foreach ($categories as $category) { $this->addCategoryField($builder, $category); } $builder->addEventListener(FormEvents::POST_SET_DATA, function (FormEvent $event) use($categories) { // distribute labels to category fields $form = $event->getForm(); $data = $event->getData(); if (null == $data) { $data = new ArrayCollection(); } $labels = new ArrayCollection(); foreach ($data as $label) { if ($label instanceof Label) { $labels->add($label); } } foreach ($categories as $category) { $field = $form->get($category->getName()); $fieldData = new ArrayCollection(); /** @var Label $label */ foreach ($labels as $label) { if ($label->getCategory()->getId() === $category->getId()) { $fieldData->add($label); } } $field->setData($fieldData); } }); $builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) { // collect labels from category fields /** @var PersistentCollection|array|null $data */ $data = $event->getData(); if (null === $data) { $data = new ArrayCollection(); } if (!$data instanceof ArrayCollection && is_array($data)) { $data = new ArrayCollection($data); } $tmpData = clone $data; $data->clear(); foreach ($tmpData as $fieldData) { if ($fieldData instanceof Label) { // skip existing labels continue; } // add labels from category field foreach ($fieldData as $label) { $data->add($label); } } }); }
/** * @dataProvider getOrderedColumnWidgetsDataProvider */ public function testGetOrderedColumnWidgets($column, $appendGreater, $appendLesser, $layoutPositions, $expectedLayoutPositions) { $this->widgets->clear(); foreach ($layoutPositions as $layoutPosition) { $widget = $this->getMockBuilder('Oro\\Bundle\\DashboardBundle\\Model\\WidgetModel')->disableOriginalConstructor()->getMock(); $widget->expects($this->any())->method('getLayoutPosition')->will($this->returnValue($layoutPosition)); $this->widgets->add($widget); } $actualLayoutPositions = array(); $orderedWidgets = $this->dashboardModel->getOrderedColumnWidgets($column, $appendGreater, $appendLesser); foreach ($orderedWidgets as $widget) { $actualLayoutPositions[] = $widget->getLayoutPosition(); } $this->assertSame($expectedLayoutPositions, $actualLayoutPositions); }
/** * Reorder pic by id * * @param string $picId * @param boolean $up */ private function reorderPicById($picId, $up = true) { $snapshot = array_values($this->pics->toArray()); $this->pics->clear(); $out = array(); foreach ($snapshot as $key => $pic) { if ($pic->getId() === $picId) { $out[$key * 10 + ($up ? -11 : 11)] = $pic; } else { $out[$key * 10] = $pic; } } ksort($out); foreach ($out as $pic) { $this->pics->add($pic); } }
/** * Reorder link by id * * @param string $linkId * @param boolean $up */ private function reorderLinkById($linkId, $up = true) { $snapshot = array_values($this->links->toArray()); $this->links->clear(); $out = array(); foreach ($snapshot as $key => $link) { if ($link->getId() === $linkId) { $out[$key * 10 + ($up ? -11 : 11)] = $link; } else { $out[$key * 10] = $link; } } ksort($out); foreach ($out as $link) { $this->links->add($link); } }
/** * @param BaseFileEntity $parent */ public function copyPermission(BaseFileEntity $parent = NULL) { $parent = $parent ?: $this->parent; if ($parent === NULL) { return; } if (!$this->user) { $this->user = $parent->user; } $this->protected = $parent->protected; $this->read->clear(); $this->write->clear(); foreach ($parent->read as $role) { $this->read->add($role); } foreach ($parent->write as $role) { $this->write->add($role); } }
/** * Function used to add amounts of resources (Orcamentos\Model\ResourceQuote) to the quote * @param array $resourceQuotes * @param Orcamentos\Model\Quote $quote * @return void */ public function addResourceQuotes($resourceQuotes, $quote) { $quoteResourceCollection = $quote->getResourceQuoteCollection(); if (!$quoteResourceCollection) { $quoteResourceCollection = new ArrayCollection(); } $quoteResourceCollection->clear(); if (isset($resourceQuotes)) { foreach ($resourceQuotes as $id => $amount) { $resource = $this->em->getRepository("Orcamentos\\Model\\Resource")->find($id); $quoteResource = new ResourceQuoteModel(); $quoteResource->setResource($resource); $quoteResource->setQuote($quote); $quoteResource->setAmount($amount); $quoteResource->setValue($resource->getCost()); $this->em->persist($quoteResource); $quoteResourceCollection->add($quoteResource); } } }
public function clearItems() { $this->items->clear(); return $this; }
/** * Sorts the given privileges by name in alphabetical order. * The root privilege is moved at the top of the list. * * @param ArrayCollection $privileges */ protected function sortPrivileges(ArrayCollection $privileges) { $data = []; /** @var AclPrivilege $privilege */ foreach ($privileges->getIterator() as $privilege) { $isRoot = false !== strpos($privilege->getIdentity()->getId(), ObjectIdentityFactory::ROOT_IDENTITY_TYPE); $label = !$isRoot ? $this->translator->trans($privilege->getIdentity()->getName()) : null; $data[] = [$privilege, $isRoot, $label]; } uasort($data, function ($a, $b) { if ($a[1]) { return -1; } if ($b[1]) { return 1; } return strcmp($a[2], $b[2]); }); $privileges->clear(); foreach ($data as $item) { $privileges->add($item[0]); } }
/** * Set children calendar events. * * @param Collection|CalendarEvent[] $calendarEvents * * @return CalendarEvent */ public function resetChildEvents($calendarEvents) { $this->childEvents->clear(); foreach ($calendarEvents as $calendarEvent) { $this->addChildEvent($calendarEvent); } return $this; }
/** * @return \TaxiPrize\TaxiBundle\Entity\Employe */ public function clearCars() { foreach ($this->cars as $car) { $car->removeEmploye($this); } $this->cars->clear(); return $this; }
/** * @param User[]|ArrayCollection $users * * @return $this */ public function setUsers($users) { $this->userBadges->clear(); foreach ($users as $user) { $userBagde = new UserBadge(); $userBagde->setBadge($this)->setUser($user); $this->addUserBadge($userBagde); } return $this; }
/** * Removes all tags. */ public function removeTags() { $this->tags->clear(); }
/** * Set email body * * @param EmailBody $emailBody * * @return Email */ public function setEmailBody(EmailBody $emailBody) { if ($this->emailBody->count() > 0) { $this->emailBody->clear(); } $emailBody->setHeader($this); $this->emailBody->add($emailBody); return $this; }
/** * Clear all Sales * * @return Product */ public function clearSales() { $this->sales->clear(); return $this; }
/** * @return \Eccube\Entity\Cart */ public function clearCartItems() { $this->CartItems->clear(); return $this; }