当前位置: 首页>>代码示例>>PHP>>正文


PHP Collection::containsKey方法代码示例

本文整理汇总了PHP中Doctrine\Common\Collections\Collection::containsKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::containsKey方法的具体用法?PHP Collection::containsKey怎么用?PHP Collection::containsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\Common\Collections\Collection的用法示例。


在下文中一共展示了Collection::containsKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getEntityAttribute

 /**
  * Get related entity attribute
  *
  * @return Attribute
  * @throws UnknownAttributeException
  */
 public function getEntityAttribute()
 {
     if (!$this->attributes->containsKey($this->entityAttributeName)) {
         throw new UnknownAttributeException('There is no entity attribute');
     }
     return $this->attributes->get($this->entityAttributeName);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:13,代码来源:AttributeManager.php

示例2: getCalculator

 private function getCalculator(ShippingMethodInterface $shippingMethod) : ShippingCalculatorInterface
 {
     $calculator = $shippingMethod->getCalculator();
     if (false === $this->calculators->containsKey($calculator)) {
         throw new CalculatorNotFoundException($calculator);
     }
     return $this->calculators->get($calculator);
 }
开发者ID:WellCommerce,项目名称:ShippingBundle,代码行数:8,代码来源:ShippingMethodProvider.php

示例3: removeProduct

 /**
  * Remove a product from the basket.
  *
  * @param Product $product
  * @param int     $nb
  *
  * @return $this
  */
 public function removeProduct(Product $product, $nb = 1)
 {
     if ($this->products->containsKey($product->getId())) {
         $this->decreaseNbProduct($product, $nb);
         $nbLeft = $this->getNbProduct($product);
         if (0 >= $nbLeft) {
             $this->products->remove($product->getId());
         }
     }
     return $this;
 }
开发者ID:Neirda24,项目名称:currency,代码行数:19,代码来源:Basket.php

示例4: addTranslation

 /**
  * @param TranslationInterface $translation
  */
 public function addTranslation(TranslationInterface $translation)
 {
     if (!$this->translations->containsKey($translation->getLocale())) {
         $this->translations->set($translation->getLocale(), $translation);
         $translation->setTranslatable($this);
     }
 }
开发者ID:php-lug,项目名称:lug,代码行数:10,代码来源:TranslatableTrait.php

示例5: getType

 public function getType(string $type) : TypeInterface
 {
     if (false === $this->types->containsKey($type)) {
         throw new TypeNotFoundException($type, $this->types->getKeys());
     }
     return $this->types->get($type);
 }
开发者ID:WellCommerce,项目名称:SearchBundle,代码行数:7,代码来源:SearchManager.php

示例6:

 function it_doest_not_contain_keys_with_type_other_than_specified(Collection $internal)
 {
     $internal->containsKey(Argument::any())->shouldNotBeCalled();
     $internal->offsetExists(Argument::any())->shouldNotBeCalled();
     $this->containsKey('4')->shouldBe(false);
     $this->offsetExists('4')->shouldBe(false);
 }
开发者ID:Rybbow,项目名称:x-blog,代码行数:7,代码来源:IndexedTypedCollectionSpec.php

示例7: 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));
 }
开发者ID:svobodni,项目名称:web,代码行数:12,代码来源:CollectionContainer.php

示例8: reorderChildren

 /**
  * {@inheritdoc}
  */
 public function reorderChildren($order)
 {
     if (count($order) != $this->count()) {
         throw new \InvalidArgumentException('Cannot reorder children, order does not contain all children.');
     }
     $newChildren = array();
     foreach ($order as $name) {
         if (!$this->children->containsKey($name)) {
             throw new \InvalidArgumentException('Cannot find children named ' . $name);
         }
         $child = $this->getChild($name);
         $newChildren[$name] = $child;
     }
     $this->setChildren($newChildren);
     return $this;
 }
开发者ID:superdesk,项目名称:web-publisher,代码行数:19,代码来源:MenuItem.php

示例9: hasModifier

 public function hasModifier(string $name) : bool
 {
     return $this->modifiers->containsKey($name);
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:4,代码来源:Order.php

示例10: hasCelestialBody

 public function hasCelestialBody($number)
 {
     return $this->celestialBodies->containsKey($number);
 }
开发者ID:iw-reload,项目名称:iw,代码行数:4,代码来源:System.php

示例11: containsKey

 /**
  * {@inheritdoc}
  */
 public function containsKey($key)
 {
     $this->initialize();
     return $this->coll->containsKey($key);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:8,代码来源:PersistentCollection.php

示例12: hasGalaxy

 public function hasGalaxy($number)
 {
     return $this->galaxies->containsKey($number);
 }
开发者ID:iw-reload,项目名称:iw,代码行数:4,代码来源:Universe.php

示例13: testContainsKey

 public function testContainsKey()
 {
     $this->_coll[5] = 'five';
     $this->assertTrue($this->_coll->containsKey(5));
 }
开发者ID:GMBN,项目名称:ZF2---DoctrineModule---ManyToOne-,代码行数:5,代码来源:CollectionTest.php

示例14: add

 /**
  * 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);
     }
 }
开发者ID:digbang,项目名称:security,代码行数:13,代码来源:LazyPermissionsTrait.php

示例15: testContainsKey

 /**
  * @dataProvider provideCollection
  */
 public function testContainsKey(Collection $coll, array $elements)
 {
     $keys = array_keys($elements);
     $this->assertTrue($coll->containsKey(current($keys)));
     $this->assertTrue($coll->containsKey(end($keys)));
     $this->assertFalse($coll->containsKey('this-will-surely-not-exist'));
 }
开发者ID:malarzm,项目名称:collections,代码行数:10,代码来源:BaseTest.php


注:本文中的Doctrine\Common\Collections\Collection::containsKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。