本文整理汇总了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::getParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP MetadataInterface::getParameter方法的具体用法?PHP MetadataInterface::getParameter怎么用?PHP MetadataInterface::getParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Metadata\MetadataInterface
的用法示例。
在下文中一共展示了MetadataInterface::getParameter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getObjectManagerName
/**
* @param MetadataInterface $metadata
*
* @return string
*/
protected function getObjectManagerName(MetadataInterface $metadata)
{
$objectManagerName = 'default';
if ($metadata->hasParameter('options') && isset($metadata->getParameter('options')['object_manager'])) {
$objectManagerName = $metadata->getParameter('options')['object_manager'];
}
return $objectManagerName;
}
示例2: addResourceListeners
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function addResourceListeners(ContainerBuilder $container, MetadataInterface $metadata)
{
$defaultOptions = ['parent_path_default' => null, 'parent_path_autocreate' => false, 'parent_path_force' => false, 'name_filter' => true, 'name_resolver' => true];
$metadataOptions = $metadata->hasParameter('options') ? $metadata->getParameter('options') : [];
if ($diff = array_diff(array_keys($metadataOptions), array_keys($defaultOptions))) {
throw new InvalidArgumentException(sprintf('Unknown PHPCR-ODM configuration options: "%s"', implode('", "', $diff)));
}
$options = array_merge($defaultOptions, $metadataOptions);
$createEventName = sprintf('%s.%s.pre_%s', $metadata->getApplicationName(), $metadata->getName(), 'create');
$updateEventName = sprintf('%s.%s.pre_%s', $metadata->getApplicationName(), $metadata->getName(), 'update');
if ($options['parent_path_default']) {
$defaultPath = new Definition(DefaultParentListener::class);
$defaultPath->setArguments([new Reference($metadata->getServiceId('manager')), $options['parent_path_default'], $options['parent_path_autocreate'], $options['parent_path_force']]);
$defaultPath->addTag('kernel.event_listener', ['event' => $createEventName, 'method' => 'onPreCreate']);
$container->setDefinition(sprintf('%s.resource.%s.doctrine.odm.phpcr.event_listener.default_path', $metadata->getApplicationName(), $metadata->getName()), $defaultPath);
}
if ($options['name_filter']) {
$nameFilter = new Definition(NameFilterListener::class);
$nameFilter->setArguments([new Reference($metadata->getServiceId('manager'))]);
$nameFilter->addTag('kernel.event_listener', ['event' => $createEventName, 'method' => 'onEvent']);
$nameFilter->addTag('kernel.event_listener', ['event' => $updateEventName, 'method' => 'onEvent']);
$container->setDefinition(sprintf('%s.resource.%s.doctrine.odm.phpcr.event_listener.name_filter', $metadata->getApplicationName(), $metadata->getName()), $nameFilter);
}
if ($options['name_resolver']) {
$nameResolver = new Definition(NameResolverListener::class);
$nameResolver->setArguments([new Reference($metadata->getServiceId('manager'))]);
$nameResolver->addTag('kernel.event_listener', ['event' => $createEventName, 'method' => 'onEvent']);
$nameResolver->addTag('kernel.event_listener', ['event' => $updateEventName, 'method' => 'onEvent']);
$container->setDefinition(sprintf('%s.resource.%s.doctrine.odm.phpcr.event_listener.name_resolver', $metadata->getApplicationName(), $metadata->getName()), $nameResolver);
}
}
示例3: setClassesParameters
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function setClassesParameters(ContainerBuilder $container, MetadataInterface $metadata)
{
if ($metadata->hasClass('model')) {
$container->setParameter(sprintf('%s.model.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('model'));
}
if ($metadata->hasClass('controller')) {
$container->setParameter(sprintf('%s.controller.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('controller'));
}
if ($metadata->hasClass('factory')) {
$container->setParameter(sprintf('%s.factory.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('factory'));
}
if ($metadata->hasClass('repository')) {
$container->setParameter(sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName()), $metadata->getClass('repository'));
}
if (!$metadata->hasParameter('validation_groups')) {
return;
}
$validationGroups = $metadata->getParameter('validation_groups');
foreach ($validationGroups as $formName => $groups) {
$suffix = 'default' === $formName ? '' : sprintf('_%s', $formName);
$container->setParameter(sprintf('%s.validation_groups.%s%s', $metadata->getApplicationName(), $metadata->getName(), $suffix), array_merge(['Default'], $groups));
}
}