本文整理匯總了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::getServiceId方法的典型用法代碼示例。如果您正苦於以下問題:PHP MetadataInterface::getServiceId方法的具體用法?PHP MetadataInterface::getServiceId怎麽用?PHP MetadataInterface::getServiceId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Component\Resource\Metadata\MetadataInterface
的用法示例。
在下文中一共展示了MetadataInterface::getServiceId方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$reflection = new \ReflectionClass($metadata->getClass('model'));
$translatableInterface = 'Sylius\\Component\\Translation\\Model\\TranslatableInterface';
$translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
$repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
$repositoryClass = $translatable ? 'Sylius\\Bundle\\TranslationBundle\\Doctrine\\ORM\\TranslatableResourceRepository' : 'Sylius\\Bundle\\ResourceBundle\\Doctrine\\ORM\\EntityRepository';
if ($container->hasParameter($repositoryClassParameterName)) {
$repositoryClass = $container->getParameter($repositoryClassParameterName);
}
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$definition = new Definition($repositoryClass);
$definition->setArguments(array(new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)));
if ($metadata->hasParameter('translation')) {
$repositoryReflection = new \ReflectionClass($repositoryClass);
$translatableRepositoryInterface = 'Sylius\\Component\\Translation\\Repository\\TranslatableResourceRepositoryInterface';
$translationConfig = $metadata->getParameter('translation');
if (interface_exists($translatableRepositoryInterface) && $repositoryReflection->implementsInterface($translatableRepositoryInterface)) {
if (isset($translationConfig['fields'])) {
$definition->addMethodCall('setTranslatableFields', array($translationConfig['fields']));
}
}
}
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例2: addDefaultForm
/**
* {@inheritdoc}
*/
protected function addDefaultForm(ContainerBuilder $container, MetadataInterface $metadata)
{
$defaultFormBuilderDefinition = new Definition(DefaultFormBuilder::class);
$defaultFormBuilderDefinition->setArguments([new Reference($metadata->getServiceId('manager'))]);
$definition = new Definition(DefaultResourceType::class);
$definition->setArguments([$this->getMetdataDefinition($metadata), $defaultFormBuilderDefinition])->addTag('form.type', ['alias' => sprintf('%s_%s', $metadata->getApplicationName(), $metadata->getName())]);
$container->setDefinition(sprintf('%s.form.type.%s', $metadata->getApplicationName(), $metadata->getName()), $definition);
}
示例3: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$repositoryClass = new Parameter('sylius.phpcr_odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$definition = new Definition($repositoryClass);
$definition->setArguments(array(new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)));
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例4: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
$repositoryClass = EntityRepository::class;
if ($container->hasParameter($repositoryClassParameterName)) {
$repositoryClass = $container->getParameter($repositoryClassParameterName);
}
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)]);
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例5: addRepository
/**
* {@inheritdoc}
*/
protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
{
$repositoryClass = new Parameter('sylius.phpcr_odm.repository.class');
if ($metadata->hasClass('repository')) {
$repositoryClass = $metadata->getClass('repository');
}
$repositoryReflection = new \ReflectionClass($repositoryClass);
$definition = new Definition($repositoryClass);
$definition->setArguments([new Reference($metadata->getServiceId('manager')), $this->getClassMetadataDefinition($metadata)]);
$definition->setLazy(!$repositoryReflection->isFinal());
if ($metadata->hasParameter('translation')) {
$translationConfig = $metadata->getParameter('translation');
if (in_array(TranslatableRepositoryInterface::class, class_implements($repositoryClass))) {
if (isset($translationConfig['fields'])) {
$definition->addMethodCall('setTranslatableFields', [$translationConfig['fields']]);
}
}
}
$container->setDefinition($metadata->getServiceId('repository'), $definition);
}
示例6: addFactory
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function addFactory(ContainerBuilder $container, MetadataInterface $metadata)
{
$factoryClass = $metadata->getClass('factory');
$modelClass = $metadata->getClass('model');
$definition = new Definition($factoryClass);
$definitionArgs = [$modelClass];
if (in_array(TranslatableFactoryInterface::class, class_implements($factoryClass))) {
$decoratedDefinition = new Definition(Factory::class);
$decoratedDefinition->setArguments($definitionArgs);
$definitionArgs = [$decoratedDefinition, new Reference('sylius.translation_locale_provider')];
}
$definition->setArguments($definitionArgs);
$container->setDefinition($metadata->getServiceId('factory'), $definition);
}
示例7: createRoute
/**
* @param MetadataInterface $metadata
* @param array $configuration
* @param string $path
* @param string $actionName
* @param array $methods
*
* @return Route
*/
private function createRoute(MetadataInterface $metadata, array $configuration, $path, $actionName, array $methods, $isApi = false)
{
$defaults = ['_controller' => $metadata->getServiceId('controller') . sprintf(':%sAction', $actionName)];
if ($isApi && 'index' === $actionName) {
$defaults['_sylius']['serialization_groups'] = ['Default'];
}
if ($isApi && in_array($actionName, ['show', 'create', 'update'], true)) {
$defaults['_sylius']['serialization_groups'] = ['Default', 'Detailed'];
}
if (isset($configuration['grid']) && 'index' === $actionName) {
$defaults['_sylius']['grid'] = $configuration['grid'];
}
if (isset($configuration['form']) && in_array($actionName, ['create', 'update'], true)) {
$defaults['_sylius']['form'] = $configuration['form'];
}
if (isset($configuration['section'])) {
$defaults['_sylius']['section'] = $configuration['section'];
}
if (isset($configuration['templates']) && in_array($actionName, ['show', 'index', 'create', 'update'], true)) {
$defaults['_sylius']['template'] = sprintf('%s:%s.html.twig', $configuration['templates'], $actionName);
}
if (isset($configuration['redirect']) && in_array($actionName, ['create', 'update'], true)) {
$defaults['_sylius']['redirect'] = $this->getRouteName($metadata, $configuration, $configuration['redirect']);
}
if (isset($configuration['permission'])) {
$defaults['_sylius']['permission'] = $configuration['permission'];
}
if (isset($configuration['vars']['all'])) {
$defaults['_sylius']['vars'] = $configuration['vars']['all'];
}
if (isset($configuration['vars'][$actionName])) {
$vars = isset($configuration['vars']['all']) ? $configuration['vars']['all'] : [];
$defaults['_sylius']['vars'] = array_merge($vars, $configuration['vars'][$actionName]);
}
return $this->routeFactory->createRoute($path, $defaults, [], [], '', [], $methods);
}
示例8: addFactory
/**
* @param ContainerBuilder $container
* @param MetadataInterface $metadata
*/
protected function addFactory(ContainerBuilder $container, MetadataInterface $metadata)
{
$translatableFactoryInterface = TranslatableFactoryInterface::class;
$factoryClass = $metadata->getClass('factory');
$modelClass = $metadata->getClass('model');
$reflection = new \ReflectionClass($factoryClass);
$definition = new Definition($factoryClass);
if (interface_exists($translatableFactoryInterface) && $reflection->implementsInterface($translatableFactoryInterface)) {
$decoratedDefinition = new Definition(Factory::class);
$decoratedDefinition->setArguments(array($modelClass));
$definition->setArguments(array($decoratedDefinition, new Reference('sylius.translation.locale_provider')));
$container->setDefinition($metadata->getServiceId('factory'), $definition);
return;
}
$definition->setArguments(array($modelClass));
$container->setDefinition($metadata->getServiceId('factory'), $definition);
}
示例9: createRoute
/**
* @param MetadataInterface $metadata
* @param array $configuration
* @param string $path
* @param string $actionName
* @param array $methods
*
* @return Route
*/
private function createRoute(MetadataInterface $metadata, array $configuration, $path, $actionName, array $methods)
{
$defaults = ['_controller' => $metadata->getServiceId('controller') . sprintf(':%sAction', $actionName)];
if (isset($configuration['form']) && in_array($actionName, ['create', 'update'])) {
$defaults['_sylius']['form'] = $configuration['form'];
}
if (isset($configuration['section'])) {
$defaults['_sylius']['section'] = $configuration['section'];
}
if (isset($configuration['templates']) && in_array($actionName, ['show', 'index', 'create', 'update'])) {
$defaults['_sylius']['template'] = sprintf('%s:%s.html.twig', $configuration['templates'], $actionName);
}
if (isset($configuration['redirect']) && in_array($actionName, ['create', 'update'])) {
$defaults['_sylius']['redirect'] = $this->getRouteName($metadata, $configuration, $configuration['redirect']);
}
return $this->routeFactory->createRoute($path, $defaults, [], [], '', [], $methods);
}
示例10: addManager
/**
* {@inheritdoc}
*/
protected function addManager(ContainerBuilder $container, MetadataInterface $metadata)
{
$container->setAlias($metadata->getServiceId('manager'), new Alias($this->getManagerServiceId($metadata)));
}