當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayCollection::add方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Collections\ArrayCollection::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayCollection::add方法的具體用法?PHP ArrayCollection::add怎麽用?PHP ArrayCollection::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Collections\ArrayCollection的用法示例。


在下文中一共展示了ArrayCollection::add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addTranslation

 /**
  * {@inheritdoc}
  */
 public function addTranslation(AbstractTranslation $translation)
 {
     if (!$this->translations->contains($translation)) {
         $translation->setForeignKey($this);
         $this->translations->add($translation);
     }
 }
開發者ID:antoineguigan,項目名稱:CustomEntityBundle,代碼行數:10,代碼來源:AbstractTranslatableCustomEntity.php

示例2: add

 /**
  * @param Ignored $ignored
  *
  * @return IgnoredRepository
  */
 public function add(Ignored $ignored)
 {
     if (!$this->ignores->contains($ignored)) {
         $this->ignores->add($ignored);
     }
     return $this;
 }
開發者ID:lfgamers,項目名稱:discord-base-bot,代碼行數:12,代碼來源:IgnoredRepository.php

示例3: addGame

 /**
  * Add game
  *
  * @param EGGame $game
  * @return EGGameGenre
  */
 public function addGame(EGGame $game)
 {
     if (!$this->games->contains($game)) {
         $this->games->add($game);
     }
     return $this;
 }
開發者ID:scottstuff,項目名稱:GCProtractorJS,代碼行數:13,代碼來源:EGGameGenre.php

示例4: createTagCollection

 public function createTagCollection()
 {
     $tags = new ArrayCollection();
     $tags->add(new Tag("foo"));
     $tags->add(new Tag("bar"));
     return $tags;
 }
開發者ID:rsky,項目名稱:symfony,代碼行數:7,代碼來源:CollectionToStringTransformerTest.php

示例5: addItem

 public function addItem($item)
 {
     if (!$item instanceof IItemData) {
         throw new Exceptions\InvalidStateException("Argument item has to be type of MenuNode");
     }
     $this->items->add($item);
 }
開發者ID:fuca,項目名稱:sportsclub,代碼行數:7,代碼來源:PublicMenuControlFactory.php

示例6: addOrderProduct

 public function addOrderProduct($orderProduct)
 {
     $orderProduct->setOrder($this);
     $this->orderProducts->add($orderProduct);
     $this->setUpdatedAt(new \DateTime());
     return $this;
 }
開發者ID:beurkinger,項目名稱:hightech,代碼行數:7,代碼來源:Order.php

示例7: testUpdatePath

 /**
  * 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());
 }
開發者ID:open-orchestra,項目名稱:open-orchestra-cms-bundle,代碼行數:32,代碼來源:UpdateChildNodePathSubscriberTest.php

示例8: add

 /**
  * 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);
 }
開發者ID:jaytaph,項目名稱:otas,代碼行數:12,代碼來源:Inventory.php

示例9: Package

 /**
  * @param Package $package
  * @return $this
  */
 public function Package(Package $package)
 {
     if (!$this->hasPackage($package)) {
         $this->Packages->add($package);
     }
     return $this;
 }
開發者ID:ChrisWesterfield,項目名稱:MJR.ONE-CP,代碼行數:11,代碼來源:Repository.php

示例10: addFiller

 /**
  * @param FillerInterface $filler
  *
  * @return AddNewItem
  */
 public function addFiller(FillerInterface $filler)
 {
     if (!$this->fillers->contains($filler)) {
         $this->fillers->add($filler);
     }
     return $this;
 }
開發者ID:anime-db,項目名稱:catalog-bundle,代碼行數:12,代碼來源:AddNewItem.php

示例11: addError

 /**
  * @param $message
  */
 protected function addError($message)
 {
     if (null === $this->errors) {
         $this->errors = new ArrayCollection();
     }
     $this->errors->add($message);
 }
開發者ID:pmdc,項目名稱:UnifikSystemBundle,代碼行數:10,代碼來源:BaseDeletableListener.php

示例12: addAlert

 /**
  * @inheritdoc
  */
 public function addAlert(AlertInterface $alert)
 {
     if (!$this->alerts->contains($alert)) {
         $this->alerts->add($alert);
         $alert->addChangeType($this);
     }
 }
開發者ID:stopfstedt,項目名稱:ilios,代碼行數:10,代碼來源:AlertChangeType.php

示例13: addUser

 /**
  * @param FolderUser $user
  * @return $this
  */
 public function addUser(FolderUser $user)
 {
     if (!$this->hasUser($user)) {
         $this->Users->add($user);
     }
     return $this;
 }
開發者ID:ChrisWesterfield,項目名稱:MJR.ONE-CP,代碼行數:11,代碼來源:Folder.php

示例14: testConfigureSandboxNotCached

 /**
  * 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();
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:28,代碼來源:EmailRendererTest.php

示例15: addSubnode

 /**
  * 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;
 }
開發者ID:pramoddas,項目名稱:elcodi,代碼行數:14,代碼來源:SubnodesTrait.php


注:本文中的Doctrine\Common\Collections\ArrayCollection::add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。