clear() public method

{@inheritDoc}
public clear ( )
 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #5
0
 /**
  * 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();
 }
Example #8
0
 /**
  * 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;
 }
Example #9
0
 /**
  * Set tags
  *
  * @param Iterable $tags
  *
  * @return Item
  */
 public function setTags($tags)
 {
     $this->tags->clear();
     foreach ($tags as $tag) {
         $this->addTag($tag);
     }
     return $this;
 }
Example #10
0
 /**
  * @param ArrayCollection|array $folders
  *
  * @return $this
  */
 public function setSubFolders($folders)
 {
     $this->subFolders->clear();
     foreach ($folders as $folder) {
         $this->addSubFolder($folder);
     }
     return $this;
 }
Example #11
0
 /**
  * @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;
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 /**
  * Clear all Products
  *
  * @return Sale
  */
 public function clearProducts()
 {
     foreach ($this->products as $product) {
         $this->removeProductWithSale($product);
     }
     $this->products->clear();
     return $this;
 }
Example #14
0
 /**
  * @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);
             }
         }
     });
 }
Example #17
0
 /**
  * @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);
 }
Example #18
0
 /**
  * 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);
     }
 }
Example #20
0
 /**
  * @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);
     }
 }
Example #21
0
 /**
  * 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);
         }
     }
 }
Example #22
0
 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]);
     }
 }
Example #24
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;
 }
Example #25
0
 /**
  * @return \TaxiPrize\TaxiBundle\Entity\Employe
  */
 public function clearCars()
 {
     foreach ($this->cars as $car) {
         $car->removeEmploye($this);
     }
     $this->cars->clear();
     return $this;
 }
Example #26
0
 /**
  * @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;
 }
Example #27
0
 /**
  * Removes all tags.
  */
 public function removeTags()
 {
     $this->tags->clear();
 }
Example #28
0
 /**
  * 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;
 }
Example #29
0
 /**
  * Clear all Sales
  *
  * @return Product
  */
 public function clearSales()
 {
     $this->sales->clear();
     return $this;
 }
Example #30
0
 /**
  * @return \Eccube\Entity\Cart
  */
 public function clearCartItems()
 {
     $this->CartItems->clear();
     return $this;
 }