本文整理汇总了PHP中Doctrine\Common\Collections\Collection::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::get方法的具体用法?PHP Collection::get怎么用?PHP Collection::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Collections\Collection
的用法示例。
在下文中一共展示了Collection::get方法的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);
}
示例2: let
function let(LoaderInterface $loader, Collection $resourcesToThemes, ThemeInterface $theme)
{
$theme->getLogicalName()->willReturn("sylius/sample-theme");
$resourcesToThemes->get(realpath($this->getThemeTranslationResourcePath()))->willReturn($theme);
$resourcesToThemes->get(realpath($this->getVanillaTranslationResourcePath()))->willReturn(null);
$this->beConstructedWith($loader, $resourcesToThemes);
}
示例3: 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);
}
示例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: load
/**
* {@inheritdoc}
*/
public function load($resource, $locale, $domain = 'messages')
{
$messageCatalogue = $this->loader->load($resource, $locale, $domain);
if (null !== ($theme = $this->resourcesToThemes->get(realpath($resource)))) {
$messages = $messageCatalogue->all($domain);
foreach ($messages as $key => $value) {
unset($messages[$key]);
$messages[$key . '|' . $theme->getLogicalName()] = $value;
}
$messageCatalogue->replace($messages, $domain);
}
return $messageCatalogue;
}
示例6: getTranslation
/**
* @param bool $allowCreate
*
* @return TranslationInterface
*/
public function getTranslation($allowCreate = false)
{
$locales = $this->getLocales();
if (empty($locales)) {
throw new LocaleNotFoundException();
}
$translation = null;
foreach ($locales as $locale) {
if (($translation = $this->translations->get($locale)) !== null) {
break;
}
}
if ($translation === null && $allowCreate) {
$translation = $this->getTranslationFactory()->create(['locale' => reset($locales)]);
$this->addTranslation($translation);
}
if ($translation === null && $this->hasFallbackLocale()) {
$translation = $this->translations->get($this->getFallbackLocale());
}
if ($translation === null) {
if ($this->hasFallbackLocale()) {
$locales[] = $this->getFallbackLocale();
}
throw new TranslationNotFoundException();
}
return $translation;
}
示例7: 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);
}
示例8: 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));
}
示例9: allows
/**
* Check if the given permission is allowed.
* Only explicitly allowed permissions will return true.
*
* @param string $permissionName
* @return bool
*/
protected function allows($permissionName)
{
foreach ($this->getMatchingPermissions($permissionName) as $key) {
/** @var Permission $permission */
$permission = $this->permissions->get($key);
if ($permission->isAllowed()) {
return true;
}
}
return false;
}
示例10: resolveDependencies
/**
* @param Package $package
* @param array $packageInfo
*/
private function resolveDependencies(Package $package, array $packageInfo)
{
if (!isset($packageInfo[self::DEPENDENCIES_KEY])) {
return;
}
foreach ($packageInfo[self::DEPENDENCIES_KEY] as $dependencyName => $dependencyInfo) {
$dependencyPackage = $this->packages->get($dependencyName);
if (null !== $dependencyPackage) {
$package->addDependency($dependencyPackage);
}
}
}
示例11: createPackageFormulae
/**
* Creates formulae for the given package.
*
* @param \Sp\BowerBundle\Bower\Package\Package $package
* @param string $packageName
* @param string $extension
*
* @return array<string,array<array>>
*/
protected function createPackageFormulae(Package $package, $packageName, $extension)
{
/** @var PackageResource $packageResource */
$packageResource = $this->packageResources->get($packageName);
$nestDependencies = $this->shouldNestDependencies();
if (null !== $packageResource && null !== $packageResource->shouldNestDependencies()) {
$nestDependencies = $packageResource->shouldNestDependencies();
}
if (null !== ($assets = $this->createSingleFormula($package, $nestDependencies, $extension))) {
return array($assets, $this->resolveFilters($extension, $packageResource), array());
}
return array();
}
示例12: getStep
/**
* Get step by name
*
* @param string $stepName
* @return Step
*/
public function getStep($stepName)
{
return $this->steps->get($stepName);
}
示例13: getCellByCoordinate
/**
* @param string $coordinate
*
* @return Cell|null
*/
public function getCellByCoordinate(string $coordinate)
{
return $this->cells->get($coordinate);
}
示例14: getCelestialBody
public function getCelestialBody($number)
{
return $this->celestialBodies->get($number);
}
示例15: getSetting
/**
* {@inheritdoc}
*/
public function getSetting($key)
{
return $this->settings->get($key);
}