Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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');
     }
 }
Exemplo n.º 3
0
 /**
  * {@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;
 }
Exemplo n.º 4
0
 /**
  * @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;
 }
Exemplo n.º 5
0
 /**
  * @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);
     }
 }
Exemplo n.º 6
0
 /**
  * @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);
     }
 }
Exemplo n.º 7
0
 /**
  * @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);
     }
 }
Exemplo n.º 8
0
 /**
  * @param TranslationInterface $translation
  */
 public function addTranslation(TranslationInterface $translation)
 {
     if (!$this->translations->containsKey($translation->getLocale())) {
         $this->translations->set($translation->getLocale(), $translation);
         $translation->setTranslatable($this);
     }
 }
Exemplo n.º 9
0
 /**
  * @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));
 }
 /**
  * {@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();
 }
 /**
  * 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();
 }
Exemplo n.º 12
0
 /**
  * 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);
 }
Exemplo n.º 13
0
 /**
  * {@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])];
 }
Exemplo n.º 14
0
 /**
  * @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);
         }
     }
 }
Exemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function addChild($child, array $options = array())
 {
     if (!$this->hasChild($child)) {
         $child->setParent($this);
         $this->children->set($child->getName(), $child);
     }
     return $child;
 }
 /**
  * @param SiteAliasInterface $alias
  */
 public function addAlias(SiteAliasInterface $alias)
 {
     $this->aliases->set(uniqid(SiteInterface::PREFIX_SITE_ALIAS), $alias);
 }
Exemplo n.º 17
0
 /**
  * @param string $resource
  */
 private function mapResourceToTheme($resource)
 {
     $this->resourcesToThemes->set($resource, $this->themeRepository->findByPath($resource));
 }
 public function addCell(Cell $cell) : self
 {
     $this->cells->set($cell->getCoordinate(), $cell);
     $cell->setBattlefield($this);
     return $this;
 }
Exemplo n.º 19
0
 function it_accepts_only_elements_of_specified_type_for_set_method(Collection $internal)
 {
     $this->shouldThrow(new InvalidTypeException(4, 'string'))->during('set', [1, 4]);
     $internal->set(Argument::cetera())->shouldNotHaveBeenCalled();
 }
Exemplo n.º 20
0
 public function addModifier(OrderModifierInterface $modifier)
 {
     $this->modifiers->set($modifier->getName(), $modifier);
 }
Exemplo n.º 21
0
 protected function isRevised(EntityInterface $entity, Collection $collection)
 {
     if ($entity->isUnrevised() && !$collection->contains($entity)) {
         $normalized = $this->normalizer->normalize($entity->getHead());
         $collection->set(-$normalized->getMetadata()->getCreationDate()->getTimestamp(), $normalized);
     }
 }
Exemplo n.º 22
0
 /**
  * @param LocalizationTag $tag
  */
 public function addTag(LocalizationTag $tag)
 {
     $tag->setLocalization($this);
     $this->tags->set($tag->getName(), $tag);
 }
Exemplo n.º 23
0
 /**
  * Adds a permission to the merged permissions Collection.
  * Override logic is handled from outside to enable strict or standard permissions.
  *
  * @param Permission $permission
  * @param bool       $override
  */
 protected function add(Permission $permission, $override = true)
 {
     if ($override || !$this->permissions->containsKey($permission->getName())) {
         $this->permissions->set($permission->getName(), $permission);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     $this->initialize();
     $this->coll->set($key, $value);
     $this->changed();
 }
Exemplo n.º 25
0
Arquivo: Role.php Projeto: sulu/sulu
 /**
  * Add setting.
  *
  * @param RoleSettingInterface $setting
  *
  * @return Role
  */
 public function addSetting(RoleSettingInterface $setting)
 {
     $this->settings->set($setting->getKey(), $setting);
     return $this;
 }
Exemplo n.º 26
0
 /**
  * Adds an element to collection preserving uniqueness of fields
  * @param Collection $collection
  * @param Entity $newItem
  * @param string $uniqueField
  * @return boolean true if added, false if already the same instance has been added
  * @throws \RuntimeException if element with the same unique field values exists
  */
 protected function addUnique(Collection $collection, Entity $newItem, $uniqueField = null)
 {
     if ($collection->contains($newItem)) {
         return false;
     }
     if (is_null($uniqueField)) {
         $collection->add($newItem);
     } else {
         $indexBy = $newItem->getProperty($uniqueField);
         if ($collection->offsetExists($indexBy)) {
             throw new \RuntimeException("Cannot add value '{$newItem}' to '{$this}': element by {$uniqueField}={$indexBy} already exists in the collection");
         }
         $collection->set($indexBy, $newItem);
     }
     return true;
 }
 /**
  * {@inheritDoc}
  */
 public function set($key, $value)
 {
     $this->initialize();
     $this->collection->set($key, $value);
 }
Exemplo n.º 28
0
 /**
  * When the collection is a Map this is like put(key,value)/add(key,value).
  * When the collection is a List this is like add(position,value).
  * 
  * @param integer $key
  * @param mixed $value
  * @override
  */
 public function set($key, $value)
 {
     parent::set($key, $value);
     if (!$this->_hydrationFlag) {
         $this->_changed();
     }
 }
Exemplo n.º 29
0
 public function testCanVerifyExistingKeysWithNullValues()
 {
     $this->_coll->set('key', null);
     $this->assertTrue($this->_coll->containsKey('key'));
 }
Exemplo n.º 30
0
 /**
  * @param PackageResource $packageResource
  *
  * @return $this
  */
 public function addPackageResource(PackageResource $packageResource)
 {
     $this->packageResources->set($packageResource->getName(), $packageResource);
     return $this;
 }