本文整理匯總了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);
}
}
示例2: add
/**
* @param Ignored $ignored
*
* @return IgnoredRepository
*/
public function add(Ignored $ignored)
{
if (!$this->ignores->contains($ignored)) {
$this->ignores->add($ignored);
}
return $this;
}
示例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;
}
示例4: createTagCollection
public function createTagCollection()
{
$tags = new ArrayCollection();
$tags->add(new Tag("foo"));
$tags->add(new Tag("bar"));
return $tags;
}
示例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);
}
示例6: addOrderProduct
public function addOrderProduct($orderProduct)
{
$orderProduct->setOrder($this);
$this->orderProducts->add($orderProduct);
$this->setUpdatedAt(new \DateTime());
return $this;
}
示例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);
}
示例9: Package
/**
* @param Package $package
* @return $this
*/
public function Package(Package $package)
{
if (!$this->hasPackage($package)) {
$this->Packages->add($package);
}
return $this;
}
示例10: addFiller
/**
* @param FillerInterface $filler
*
* @return AddNewItem
*/
public function addFiller(FillerInterface $filler)
{
if (!$this->fillers->contains($filler)) {
$this->fillers->add($filler);
}
return $this;
}
示例11: addError
/**
* @param $message
*/
protected function addError($message)
{
if (null === $this->errors) {
$this->errors = new ArrayCollection();
}
$this->errors->add($message);
}
示例12: addAlert
/**
* @inheritdoc
*/
public function addAlert(AlertInterface $alert)
{
if (!$this->alerts->contains($alert)) {
$this->alerts->add($alert);
$alert->addChangeType($this);
}
}
示例13: addUser
/**
* @param FolderUser $user
* @return $this
*/
public function addUser(FolderUser $user)
{
if (!$this->hasUser($user)) {
$this->Users->add($user);
}
return $this;
}
示例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();
}
示例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;
}