本文整理匯總了PHP中Doctrine\Common\Collections\Collection::offsetExists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::offsetExists方法的具體用法?PHP Collection::offsetExists怎麽用?PHP Collection::offsetExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::offsetExists方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
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);
}
示例2: offsetExists
/**
* {@inheritDoc}
*/
public function offsetExists($offset)
{
$this->initialize();
return $this->collection->offsetExists($offset);
}
示例3: addUnique
/**
* 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;
}
示例4: offsetExists
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return $this->inner->offsetExists($offset);
}
示例5: hasLayout
/**
* Whether the layout exists
* @param string $media
* @return boolean
*/
public function hasLayout($media = TemplateLayout::MEDIA_SCREEN)
{
$has = $this->templateLayouts->offsetExists($media);
return $has;
}
示例6: appendProperData
/**
* Fills the data with the proper characteristic type.
*
* @param \Doctrine\Common\Collections\Collection $data
* @param \Ekyna\Component\Characteristics\Schema\Definition $definition
* @throws \InvalidArgumentException
*/
private function appendProperData(Collection $data, Definition $definition)
{
$identifier = $definition->getIdentifier();
if ($data->offsetExists($identifier)) {
return;
}
$characteristic = $this->manager->createCharacteristicFromDefinition($definition);
$data->set($identifier, $characteristic);
}