本文整理汇总了PHP中Doctrine\Common\Collections\Collection::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::set方法的具体用法?PHP Collection::set怎么用?PHP Collection::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addProduct
/**
* Add a product to the basket.
*
* @param Product $product
* @param int $nb
*
* @return $this
*/
public function addProduct(Product $product, $nb = 1)
{
if (!$this->products->containsKey($product->getId())) {
$this->products->set($product->getId(), $product);
}
$this->increaseNbProduct($product, $nb);
return $this;
}
示例2: addTemplateLayout
/**
* Set templateLayout
* @param TemplateLayout $templateLayout
*/
public function addTemplateLayout(TemplateLayout $templateLayout)
{
if ($this->lock('templateLayouts')) {
$media = $templateLayout->getMedia();
$this->templateLayouts->set($media, $templateLayout);
$templateLayout->setTemplate($this);
$this->unlock('templateLayouts');
}
}
示例3: map
/**
* {@inheritdoc}
*/
public function map(array $packagesInfo, ConfigurationInterface $config)
{
$this->config = $config;
$packagesInfo = $this->orderPackages($packagesInfo);
foreach ($packagesInfo[self::DEPENDENCIES_KEY] as $packageName => $packageInfo) {
$package = $this->createPackage($packageName, $packageInfo);
$this->packages->set($packageName, $package);
}
return $this->packages;
}
示例4: addProduct
/**
* @param Product $product
* @param Quantity $quantity
* @return Cart
*/
public function addProduct(Product $product, Quantity $quantity) : Cart
{
$key = $product->getId()->getValue();
/** @var LineItem $lineItem */
$lineItem = $this->lineItems->get($key);
if ($lineItem === null) {
$lineItem = new LineItem($product, $quantity);
} else {
$lineItem = new LineItem($product, $lineItem->getQuantity()->add($quantity));
}
$this->lineItems->set($key, $lineItem);
return $this;
}
示例5: addSystem
/**
* @param \common\entities\System $system
* @param bool $sync
*/
public function addSystem(System $system, $sync = true)
{
$this->systems->set($system->getNumber(), $system);
if ($sync) {
$system->setGalaxy($this, false);
}
}
示例6: addCelestialBody
/**
* @param \common\entities\System $celestialBody
* @param bool $sync
*/
public function addCelestialBody(CelestialBody $celestialBody, $sync = true)
{
$this->celestialBodies->set($celestialBody->getNumber(), $celestialBody);
if ($sync) {
$celestialBody->setSystem($this, false);
}
}
示例7: addGalaxy
/**
* @param \common\entities\Galaxy $galaxy
* @param bool $sync
*/
public function addGalaxy(Galaxy $galaxy, $sync = true)
{
$this->galaxies->set($galaxy->getNumber(), $galaxy);
if ($sync) {
$galaxy->setUniverse($this, false);
}
}
示例8: addTranslation
/**
* @param TranslationInterface $translation
*/
public function addTranslation(TranslationInterface $translation)
{
if (!$this->translations->containsKey($translation->getLocale())) {
$this->translations->set($translation->getLocale(), $translation);
$translation->setTranslatable($this);
}
}
示例9: createNewContainer
/**
* @param int $index
* @return \Kdyby\Doctrine\Forms\EntityContainer
*/
private function createNewContainer($index)
{
if (!$this->collection->containsKey($index)) {
$this->collection->set($index, $this->createNewEntity());
}
$class = $this->containerClass;
return new $class($this->collection->get($index));
}
示例10: set
/**
* {@inheritdoc}
*/
public function set($key, $value)
{
$this->coll->set($key, $value);
// Handle orphanRemoval
if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) {
$this->uow->unscheduleOrphanRemoval($value);
}
$this->changed();
}
示例11: doSet
/**
* Actual logic for setting an element in the collection.
*
* @param mixed $offset
* @param mixed $value
* @param bool $arrayAccess
* @return bool
*/
private function doSet($offset, $value, $arrayAccess)
{
$arrayAccess ? $this->coll->offsetSet($offset, $value) : $this->coll->set($offset, $value);
// Handle orphanRemoval
if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) {
$this->uow->unscheduleOrphanRemoval($value);
}
$this->changed();
}
示例12: set
/**
* Sets an element in the collection at the specified key/index.
*
* @param string|integer $key The key/index of the element to set.
* @param mixed $value The element to set.
*
* @return void
*/
function set($key, $value)
{
$this->checkType($value);
$this->initialize();
$className = $this->entityTerms->getClassName();
$eTerm = new $className();
/** @var $eTerm EntityTermRepositoryInterface */
$eTerm->setTerm($value);
$this->collection->set($key, $eTerm);
}
示例13: partition
/**
* {@inheritDoc}
*/
public function partition(Closure $p)
{
$array = $this->toArray();
$this->collection->clear();
foreach ($array as $key => $element) {
$this->collection->set($key, $element);
}
$partitions = $this->collection->partition($p);
return [new static($partitions[0]), new static($partitions[1])];
}
示例14: fixCollectionField
/**
* @param Collection $collection
* @param $level
*/
protected function fixCollectionField($collection, $level)
{
foreach ($collection as $key => $value) {
if ($this->isEntityDetached($value)) {
$value = $this->reloadEntity($value);
$collection->set($key, $value);
} else {
$this->fixEntityAssociationFields($value, $level - 1);
}
}
}
示例15: addChild
/**
* {@inheritdoc}
*/
public function addChild($child, array $options = array())
{
if (!$this->hasChild($child)) {
$child->setParent($this);
$this->children->set($child->getName(), $child);
}
return $child;
}