本文整理汇总了PHP中Doctrine\Common\Collections\Collection::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::add方法的具体用法?PHP Collection::add怎么用?PHP Collection::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPost
/**
* Adds a post top the User's authored Posts.
*
* Post Author needs to be updated manually.
*
* @param Post $addPost
* @return User
*/
public function addPost(Post $addPost)
{
if (!$this->getAuthoredPosts()->contains($addPost)) {
$this->authoredPosts->add($addPost);
}
return $this;
}
示例2: addOption
/**
* Add a given option
*
* @param OptionInterface $option
* @return $this
*/
public function addOption(OptionInterface $option)
{
if (!$this->hasOption($option)) {
$this->options->add($option);
}
return $this;
}
示例3: addOutpost
public function addOutpost(Outpost $outpost, $sync = true)
{
$this->outposts->add($outpost);
if ($sync) {
$outpost->setOwner($this, false);
}
}
示例4: 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;
}
示例5: addThirdParty
/**
* @param ThirdParty $thirdParty
*
* @return bool
*/
public function addThirdParty(ThirdParty $thirdParty)
{
if ($this->thirdPartyCredentials->contains($thirdParty)) {
return false;
}
return $this->thirdPartyCredentials->add($thirdParty);
}
示例6: addCheckpoint
/**
* @param \AntiMattr\ShipmentTracking\Model\Tracking\CheckpointInterface
*/
public function addCheckpoint(CheckpointInterface $checkpoint)
{
$this->checkpoints->add($checkpoint);
if ($this !== $checkpoint->getTracking()) {
$checkpoint->setTracking($this);
}
}
示例7: addTagging
/**
* {@inheritdoc}
*/
public function addTagging(TaggingInterface $tagging)
{
if (!$this->hasTagging($tagging)) {
$tagging->setTag($this);
$this->taggings->add($tagging);
}
}
示例8: addEmpresa
/**
* @param Empresa $empresa
*/
public function addEmpresa($empresa)
{
if (!$this->empresas->contains($empresa)) {
$empresa->setDirector($this);
$this->empresas->add($empresa);
}
}
示例9: addParent
/**
* @param Role $parent
*/
public function addParent(Role $parent)
{
if ($this->parents->contains($parent)) {
throw new LogicException(sprintf("Parent role '%s' already assigned.", $parent->getId()));
}
$this->parents->add($parent);
}
示例10: addTag
/**
* {@inheritdoc}
*/
public function addTag(TagInterface $tag)
{
if ($this->tags->contains($tag)) {
return;
}
$this->tags->add($tag);
}
示例11: addArchivo
/**
* @param Archivo $archivo
*/
public function addArchivo($archivo)
{
if (!$this->archivos->contains($archivo)) {
$archivo->setDocumentable($this);
$this->archivos->add($archivo);
}
}
示例12: addOption
/**
* @param AntiMattr\Common\Product\OptionInterface
*/
public function addOption(OptionInterface $option)
{
$this->options->add($option);
if ($this !== $option->getVariation()) {
$option->setVariation($this);
}
}
示例13: testFirstAndLast
public function testFirstAndLast()
{
$this->_coll->add('one');
$this->_coll->add('two');
$this->assertEquals($this->_coll->first(), 'one');
$this->assertEquals($this->_coll->last(), 'two');
}
示例14: addTerm
/**
* {@inheritdoc}
*/
public function addTerm(TermInterface $term)
{
if (!$this->hasOption($term)) {
$this->terms->add($term);
}
return $this;
}
示例15: addArticleSubmissionFile
/**
* Add submissionFiles
*
* @param ArticleSubmissionFile $articleSubmissionFile
* @return $this
*/
public function addArticleSubmissionFile(ArticleSubmissionFile $articleSubmissionFile)
{
if (!$this->articleSubmissionFiles->contains($articleSubmissionFile)) {
$this->articleSubmissionFiles->add($articleSubmissionFile);
}
return $this;
}