public function addArticle(Article $article) { if (!$this->articles->contains($article)) { $article->setFeed($this); $this->articles->add($article); } }
/** * {@inheritdoc} * * @throws UnexpectedValueException */ public function set($key, $value) { if (!$this->acceptsType($value)) { throw $this->doUnexpectedValueError($value); } parent::set($key, $value); }
/** * @param ContactList $contactList * * @return void */ public function add($contactList) { if (!$this->exists(function ($key, ContactList $element) use($contactList) { return $contactList->getId() == $element->getId(); })) { parent::add($contactList); } }
/** * @return array all elements as an array */ public function toArray() { /** * Array keys chnges during live cycle of queue. Using array_values() to * make sure that array will be indexed starting 0. */ return array_values(parent::toArray()); }
/** * @return ResourceCollection */ protected function createPlain() { $entities = $this->entities->toArray() ?: []; $metadata = $this->mineMetadata($entities); // El método map() sólo puede generar colecciones del mismo tipo. $resources = array_map([$this, 'createResource'], $entities); return new ResourceCollection($resources, $metadata); }
/** * @param Segment $segment * * @return void */ public function add($segment) { if (!$this->exists(function ($key, Segment $element) use($segment) { return $segment->getId() == $element->getId(); })) { parent::add($segment); } }
/** * @param int $index * @return Model */ public function offsetGet($index) { $model = parent::offsetGet($index); if (!is_object($model)) { $model_class = $this->model_class; $model = $model_class::find($model); self::offsetSet($index, $model); } return $model; }
/** * @return float consumption per 100km */ public function getAverageConsumption() { $count = $this->refuels->count(); if (!$count) { return; } $sum = 0; $this->refuels->map(function (Refuel $refuel) use(&$sum) { $sum += $refuel->getConsumption(); }); return $sum / $count; }
public function removeRole($role) { $role = $this->roles->filter(function (Role $r) use($role) { if ($role instanceof Role) { return $r->getRole() === $role->getRole(); } else { return $r->getRole() === strtoupper($role); } })->first(); if ($role) { $this->roles->removeElement($role); } return $this; }
/** * Remove produits * * @param \Ecommerce\EcommerceBundle\Entity\Fournisseur $produits */ public function removeProduit(\Ecommerce\EcommerceBundle\Entity\Fournisseur $produits) { $this->produits->removeElement($produits); }
/** * Remove project * * @param \Backend\AdminBundle\Entity\Project $project */ public function removeProject(\Backend\AdminBundle\Entity\Project $project) { $this->projects->removeElement($project); }
/** * Finalize the block; mark it closed for modification * * @param int $lineNumber * @param InlineParser $inlineParser * @param ReferenceMap $refMap */ public function finalize($lineNumber, CommonMark_InlineParser $inlineParser, CommonMark_Reference_ReferenceMap $refMap) { if (!$this->open) { return; } $this->open = false; if ($lineNumber > $this->startLine) { $this->endLine = $lineNumber - 1; } else { $this->endLine = $lineNumber; } switch ($this->getType()) { case self::TYPE_PARAGRAPH: $this->stringContent = preg_replace('/^ */m', '', implode("\n", $this->strings->toArray())); // Try parsing the beginning as link reference definitions: while ($this->stringContent[0] === '[' && ($pos = $inlineParser->parseReference($this->stringContent, $refMap))) { $this->stringContent = substr($this->stringContent, $pos); if ($this->isStringContentBlank()) { //RegexHelper::getInstance()->isBlank($this->stringContent)) { $this->type = self::TYPE_REFERENCE_DEF; break; } } break; case self::TYPE_ATX_HEADER: case self::TYPE_SETEXT_HEADER: case self::TYPE_HTML_BLOCK: $this->stringContent = implode("\n", $this->strings->toArray()); break; case self::TYPE_INDENTED_CODE: $reversed = array_reverse($this->strings->toArray(), true); foreach ($reversed as $index => $line) { if ($line == '' || $line === "\n" || preg_match('/^(\\n *)$/', $line)) { unset($reversed[$index]); } else { break; } } $fixed = array_reverse($reversed); $tmp = implode("\n", $fixed); if (substr($tmp, -1) !== "\n") { $tmp .= "\n"; } $this->stringContent = $tmp; break; case self::TYPE_FENCED_CODE: // first line becomes info string $this->setExtra('info', CommonMark_Util_RegexHelper::unescape(trim($this->strings->first()))); if ($this->strings->count() == 1) { $this->stringContent = ''; } else { $this->stringContent = implode("\n", $this->strings->slice(1)) . "\n"; } break; case self::TYPE_LIST: $this->setExtra('tight', true); // tight by default $numItems = $this->children->count(); $i = 0; while ($i < $numItems) { /** @var BlockElement $item */ $item = $this->children->get($i); // check for non-final list item ending with blank line: $lastItem = $i == $numItems - 1; if ($item->endsWithBlankLine() && !$lastItem) { $this->setExtra('tight', false); break; } // Recurse into children of list item, to see if there are // spaces between any of them: $numSubItems = $item->getChildren()->count(); $j = 0; while ($j < $numSubItems) { $subItem = $item->getChildren()->get($j); $lastSubItem = $j == $numSubItems - 1; if ($subItem->endsWithBlankLine() && !($lastItem && $lastSubItem)) { $this->setExtra('tight', false); break; } $j++; } $i++; } break; default: break; } }
private static function WrapContenidoList($contenidos) { //Collection<PeliculaLogica> contenidoslogica = new ArrayList<PeliculaLogica>(); $contenidoslogica = new ArrayCollection(); // Iterator<Contenido> it = $contenidos.iterator(); $it = $contenidos->getIterator(); while ($it . hasNext()) { //PeliculaLogica pl = new PeliculaLogica(it.next()); $peliculaLogica = new PeliculaLogica($it->next()); $contenidoslogica->add($peliculaLogica); } return $contenidoslogica; }
/** * Remove failure * * @param Loginfailure $failure */ public function removeFailure(Loginfailure $failure) { $this->failures->removeElement($failure); }
/** * @deprecicate * * @param $attributeValue * @param $attributeName * @param $object * @param $resource * @param $attributeMetatdata * @param $type */ public function normalizeDataArrayCollection($attributeValue, $attributeName, $object, $resource, $attributeMetatdata, $type) { if (is_array($attributeValue)) { $values = new ArrayCollection(); foreach ($attributeValue as $obj) { $values->add($this->denormalizeRelation($resource, $attributeMetatdata, $type->getClass(), $obj)); } $this->setValue($object, $attributeName, $values); throw new \InvalidArgumentException('Invalid json message received'); } }
/** {@inheritDoc} */ public function toArray() { $this->initialize(); return $this->collection->toArray(); }
/** * Remove files * * @param \AppBundle\Entity\FileQuestion $files */ public function removeFile(\AppBundle\Entity\FileQuestion $files) { $this->files->removeElement($files); }
/** * Remove childTask * * @param \Est\AppBundle\Entity\Task $childTask */ public function removeChildTask(\Est\AppBundle\Entity\Task $childTask) { $this->childTasks->removeElement($childTask); }
/** * Remove product * * @param \AppBundle\Entity\Product $product */ public function removeProduct(\AppBundle\Entity\Product $product) { $this->products->removeElement($product); }
/** * Remove role * * @param \Bigfish\Bundle\UserBundle\Entity\Role $role */ public function removeRole(\Bigfish\Bundle\UserBundle\Entity\Role $role) { $this->role->removeElement($role); }
/** * Remove cita * * @param \AppBundle\Entity\Cita $cita */ public function removeCita(\AppBundle\Entity\Cita $cita) { $this->citas->removeElement($cita); }
/** * Remove instagramComment * * @param \Headoo\MediaSocialApiBundle\Entity\InstagramComment $instagramComment */ public function removeInstagramComment(\Headoo\MediaSocialApiBundle\Entity\InstagramComment $instagramComment) { $this->instagramComment->removeElement($instagramComment); }
/** * @param mixed $offset * * @return CustomFieldChoice|null */ public function offsetGet($offset) { return parent::offsetGet($offset); }
/** * Remove charges * * @param \Flyers\PlanITBundle\Entity\Charge $charges */ public function removeCharge(\Flyers\PlanITBundle\Entity\Charge $charges) { $this->charges->removeElement($charges); }
public function test_filter_map() { $arc = new ArrayCollection(array('aap', 'aap', 'noot', 'mies')); $filtered = $arc->filter(function ($i) { return $i != 'aap'; }); $this->assertInstanceOf('\\SAML2\\Utilities\\ArrayCollection', $filtered); $this->assertEquals($filtered->get(0), null); $this->assertEquals($filtered->get(1), null); $this->assertEquals($filtered->get(2), 'noot'); $this->assertEquals($filtered->get(3), 'mies'); $mapped = $arc->map(function ($i) { return ucfirst($i); }); $this->assertInstanceOf('\\SAML2\\Utilities\\ArrayCollection', $mapped); $this->assertEquals($mapped->get(0), 'Aap'); $this->assertEquals($mapped->get(1), 'Aap'); $this->assertEquals($mapped->get(2), 'Noot'); $this->assertEquals($mapped->get(3), 'Mies'); // ensure original is not changed $this->assertEquals($arc->get(0), 'aap'); $this->assertEquals($arc->get(1), 'aap'); $this->assertEquals($arc->get(2), 'noot'); $this->assertEquals($arc->get(3), 'mies'); }
/** * Remove reviews * * @param \UserBundle\Entity\Review $reviews */ public function removeReview(\ReviewsBundle\Entity\Review $reviews) { $this->reviews->removeElement($reviews); }
/** * Remove car * * @param \AppBundle\Entity\Car $cars */ public function removeCar(\AppBundle\Entity\Car $car) { $this->cars->removeElement($car); }
public function removeRuleGroup(RuleGroup $ruleGroup) { return $this->ruleGroups->removeElement($ruleGroup); }
/** * Remove tweetPlace * * @param \Headoo\MediaSocialApiBundle\Entity\TweetPlace $tweetPlace */ public function removeTweetPlace(\Headoo\MediaSocialApiBundle\Entity\TweetPlace $tweetPlace) { $this->tweetPlace->removeElement($tweetPlace); }
/** * Remove employees * * @param \Flyers\PlanITBundle\Entity\Employee $employees */ public function removeEmployee(\Flyers\PlanITBundle\Entity\Employee $employees) { $this->employees->removeElement($employees); }