add() public method

{@inheritDoc}
public add ( $element )
 /**
  * {@inheritdoc}
  */
 public function addTranslation(AbstractTranslation $translation)
 {
     if (!$this->translations->contains($translation)) {
         $translation->setForeignKey($this);
         $this->translations->add($translation);
     }
 }
 /**
  * @param Ignored $ignored
  *
  * @return IgnoredRepository
  */
 public function add(Ignored $ignored)
 {
     if (!$this->ignores->contains($ignored)) {
         $this->ignores->add($ignored);
     }
     return $this;
 }
 /**
  * Add game
  *
  * @param EGGame $game
  * @return EGGameGenre
  */
 public function addGame(EGGame $game)
 {
     if (!$this->games->contains($game)) {
         $this->games->add($game);
     }
     return $this;
 }
 public function createTagCollection()
 {
     $tags = new ArrayCollection();
     $tags->add(new Tag("foo"));
     $tags->add(new Tag("bar"));
     return $tags;
 }
 public function addItem($item)
 {
     if (!$item instanceof IItemData) {
         throw new Exceptions\InvalidStateException("Argument item has to be type of MenuNode");
     }
     $this->items->add($item);
 }
Example #6
0
 public function addOrderProduct($orderProduct)
 {
     $orderProduct->setOrder($this);
     $this->orderProducts->add($orderProduct);
     $this->setUpdatedAt(new \DateTime());
     return $this;
 }
 /**
  * Test update path
  */
 public function testUpdatePath()
 {
     $siteId = $this->currentSiteManager->getCurrentSiteId();
     $parentNodeId = 'parent';
     $parentPath = 'parentPath';
     $son1NodeId = 'son1NodeId';
     $son2NodeId = 'son2NodeId';
     $parent = Phake::mock('OpenOrchestra\\ModelInterface\\Model\\NodeInterface');
     Phake::when($parent)->getNodeId()->thenReturn($parentNodeId);
     Phake::when($parent)->getPath()->thenReturn($parentPath);
     $son1 = Phake::mock('OpenOrchestra\\ModelInterface\\Model\\NodeInterface');
     Phake::when($son1)->getNodeId()->thenReturn($son1NodeId);
     $son2 = Phake::mock('OpenOrchestra\\ModelInterface\\Model\\NodeInterface');
     Phake::when($son2)->getNodeId()->thenReturn($son2NodeId);
     $son3 = Phake::mock('OpenOrchestra\\ModelInterface\\Model\\NodeInterface');
     Phake::when($son3)->getNodeId()->thenReturn($son2NodeId);
     $sons = new ArrayCollection();
     $sons->add($son1);
     $sons->add($son2);
     $sons->add($son3);
     Phake::when($this->nodeRepository)->findByParent($parentNodeId, $siteId)->thenReturn($sons);
     $event = Phake::mock('OpenOrchestra\\ModelInterface\\Event\\NodeEvent');
     Phake::when($event)->getNode()->thenReturn($parent);
     $this->subscriber->updatePath($event);
     Phake::verify($son1)->setPath($parentPath . '/' . $son1NodeId);
     Phake::verify($son2)->setPath($parentPath . '/' . $son2NodeId);
     Phake::verify($son3)->setPath($parentPath . '/' . $son2NodeId);
     Phake::verify($this->eventDispatcher, Phake::times(2))->dispatch(Phake::anyParameters());
 }
Example #8
0
 /**
  * Adds an object to the inventory
  *
  * @param Object $object
  */
 function add(Object $object)
 {
     if ($this->size > 0 && $this->container->count() >= $this->size) {
         throw new \OverflowException("Too many items in inventory");
     }
     $this->container->add($object);
 }
 /**
  * @param Package $package
  * @return $this
  */
 public function Package(Package $package)
 {
     if (!$this->hasPackage($package)) {
         $this->Packages->add($package);
     }
     return $this;
 }
Example #10
0
 /**
  * @param FillerInterface $filler
  *
  * @return AddNewItem
  */
 public function addFiller(FillerInterface $filler)
 {
     if (!$this->fillers->contains($filler)) {
         $this->fillers->add($filler);
     }
     return $this;
 }
 /**
  * @param $message
  */
 protected function addError($message)
 {
     if (null === $this->errors) {
         $this->errors = new ArrayCollection();
     }
     $this->errors->add($message);
 }
Example #12
0
 /**
  * @inheritdoc
  */
 public function addAlert(AlertInterface $alert)
 {
     if (!$this->alerts->contains($alert)) {
         $this->alerts->add($alert);
         $alert->addChangeType($this);
     }
 }
Example #13
0
 /**
  * @param FolderUser $user
  * @return $this
  */
 public function addUser(FolderUser $user)
 {
     if (!$this->hasUser($user)) {
         $this->Users->add($user);
     }
     return $this;
 }
 /**
  * configureSanbox method with not cached scenario
  */
 public function testConfigureSandboxNotCached()
 {
     $entityClass = 'Oro\\Bundle\\UserBundle\\Entity\\User';
     $configIdMock = $this->getMockForAbstractClass('Oro\\Bundle\\EntityConfigBundle\\Config\\Id\\ConfigIdInterface');
     $configIdMock->expects($this->once())->method('getClassName')->will($this->returnValue($entityClass));
     $configuredData = array($entityClass => array('getsomecode'));
     $this->cache->expects($this->once())->method('fetch')->with($this->cacheKey)->will($this->returnValue(false));
     $this->cache->expects($this->once())->method('save')->with($this->cacheKey, serialize($configuredData));
     $configurableEntities = array($configIdMock);
     $this->configProvider->expects($this->once())->method('getIds')->will($this->returnValue($configurableEntities));
     $fieldsCollection = new ArrayCollection();
     $this->configProvider->expects($this->once())->method('filter')->will($this->returnCallback(function ($callback) use($fieldsCollection) {
         return $fieldsCollection->filter($callback);
     }));
     $field1Id = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\Id\\FieldConfigId')->disableOriginalConstructor()->getMock();
     $field1Id->expects($this->once())->method('getFieldName')->will($this->returnValue('someCode'));
     $field1 = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $field2 = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMockForAbstractClass();
     $field1->expects($this->once())->method('is')->with('available_in_template')->will($this->returnValue(true));
     $field1->expects($this->once())->method('getId')->will($this->returnValue($field1Id));
     $field2->expects($this->once())->method('is')->with('available_in_template')->will($this->returnValue(false));
     $fieldsCollection->add($field1);
     $fieldsCollection->add($field2);
     $this->getRendererInstance();
 }
Example #15
0
 /**
  * Add subnode.
  *
  * @param \Elcodi\Component\Menu\Entity\Menu\Interfaces\NodeInterface $node Node
  *
  * @return $this Self object
  */
 public function addSubnode(\Elcodi\Component\Menu\Entity\Menu\Interfaces\NodeInterface $node)
 {
     if ($node !== $this) {
         $this->subnodes->add($node);
     }
     return $this;
 }
 /**
  * @param OwnerTreeProviderInterface $provider
  */
 public function addProvider(OwnerTreeProviderInterface $provider)
 {
     if ($this->providers->contains($provider)) {
         return;
     }
     $this->providers->add($provider);
 }
 public function testBindCollection()
 {
     $request = new Request();
     $collection = new ArrayCollection();
     $item1 = new Inventory();
     $item1->setProductId('770011');
     $item1->setQuantity('5');
     $item1->setThreshold('3');
     $item1->setUpdatedAt($this->newDateTime('2001-12-31T12:00:00'));
     $item2 = new Inventory();
     $item2->setProductId('770077');
     $item2->setQuantity('10');
     $item2->setThreshold('7');
     $item2->setUpdatedAt($this->newDateTime('2001-12-31T12:00:00'));
     $item3 = new Inventory();
     $item3->setProductId('990099');
     $item3->setQuantity('10');
     $item3->setThreshold('5');
     $item3->setUpdatedAt($this->newDateTime('2001-12-31T12:00:00'));
     $collection->add($item1);
     $collection->add($item2);
     $collection->add($item3);
     $this->requestHandler->bindCollection($request, $collection);
     $content = $request->getContent();
     $this->assertXmlStringEqualsXmlString(self::$xml, $content);
 }
 /**
  * @param string $class
  * @return SupportedClassPool
  */
 public function addClass(string $class) : self
 {
     if (!$this->classes->contains($class)) {
         $this->classes->add($class);
     }
     return $this;
 }
 /**
  * @param RoleInterface $role
  *
  * @return $this
  */
 public function addRole(RoleInterface $role)
 {
     if (false === $this->hasRole($role)) {
         $this->roles->add($role);
     }
     return $this;
 }
 /**
  * @param Entity $activity
  *
  * @return $this
  */
 public function addActivity(Entity $activity)
 {
     if (!$this->hasActivity($activity)) {
         $this->activities->add($activity);
     }
     return $this;
 }
 public function __construct()
 {
     $this->history = new ArrayCollection();
     $this->addPostCommandHandler(function (ChainableCommandInterface $cmd) {
         $this->history->add($cmd);
     });
 }
Example #22
0
 public function addPost(Post $post)
 {
     if (!$this->posts->contains($post)) {
         $this->posts->add($post);
     }
     return $this;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     if (!$this->isEnabled()) {
         return;
     }
     $shippingMethods = new ArrayCollection();
     $shippingMethods->add($this->getReference('shipping_method_fedex'));
     $shippingMethods->add($this->getReference('shipping_method_ups'));
     $cod = new PaymentMethod();
     $cod->setEnabled(1);
     $cod->setHierarchy(0);
     $cod->setProcessor('cod');
     $cod->translate('en')->setName('Cash on delivery');
     $cod->setShippingMethods($shippingMethods);
     $cod->setDefaultOrderStatus($this->getReference('default_order_status'));
     $cod->mergeNewTranslations();
     $manager->persist($cod);
     $bankTransfer = new PaymentMethod();
     $bankTransfer->setEnabled(1);
     $bankTransfer->setHierarchy(0);
     $bankTransfer->setProcessor('bank_transfer');
     $bankTransfer->translate('en')->setName('Bank transfer');
     $bankTransfer->setShippingMethods($shippingMethods);
     $bankTransfer->setDefaultOrderStatus($this->getReference('default_order_status'));
     $bankTransfer->mergeNewTranslations();
     $manager->persist($bankTransfer);
     $manager->flush();
     $this->setReference('payment_method_cod', $cod);
     $this->setReference('payment_method_bank_transfer', $bankTransfer);
 }
 /**
  * @param Movie $m
  */
 public function addMovie(Movie $m)
 {
     if (!$this->movies->contains($m)) {
         $this->movies->add($m);
         $m->addDirector($this);
     }
 }
Example #25
0
 /**
  * @inheritdoc
  */
 public function addCompetency(CompetencyInterface $competency)
 {
     if (!$this->competencies->contains($competency)) {
         $this->competencies->add($competency);
         $competency->addAamcPcrs($this);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function mapFormsToData($forms, &$data)
 {
     if (null === $data) {
         return;
     }
     if (!is_array($data) && !is_object($data)) {
         throw new UnexpectedTypeException($data, 'object, array or empty');
     }
     $newData = new ArrayCollection();
     foreach ($forms as $translationsFieldsForm) {
         $translationsFieldsConfig = $translationsFieldsForm->getConfig();
         $locale = $translationsFieldsConfig->getName();
         $translationClass = $translationsFieldsConfig->getOption('translation_class');
         foreach ($translationsFieldsForm->getData() as $field => $content) {
             $existingTranslation = $data ? $data->filter(function ($object) use($locale, $field) {
                 return $object && $object->getLocale() === $locale && $object->getField() === $field;
             })->first() : null;
             if ($existingTranslation) {
                 $existingTranslation->setContent($content);
                 $newData->add($existingTranslation);
             } else {
                 $translation = new $translationClass();
                 $translation->setLocale($locale);
                 $translation->setField($field);
                 $translation->setContent($content);
                 $newData->add($translation);
             }
         }
     }
     $data = $newData;
 }
 /**
  * @param ObserverInterface $observer
  */
 public function registerObserver(ObserverInterface $observer)
 {
     if (is_null($this->observers)) {
         $this->observers = new ArrayCollection();
     }
     $this->observers->add($observer);
 }
Example #28
0
 /**
  * @param UserInterface $user
  */
 public function addUser(UserInterface $user)
 {
     if (!$this->users->contains($user)) {
         $this->users->add($user);
         $user->addRole($this);
     }
 }
 /**
  * If the event isn't already in the list, add it
  * 
  * @param CalendarEventInterface $event
  * @return CalendarEvent $this
  */
 public function addEvent(CalendarEventInterface $event)
 {
     if (!$this->events->contains($event)) {
         $this->events->add($event);
     }
     return $this;
 }
Example #30
0
 /**
  * @param Main $main
  * @return $this
  */
 public function addCustomer(Main $main)
 {
     if (!$this->hasCustomer($main)) {
         $this->Customers->add($main);
     }
     return $this;
 }