當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MetadataInterface::getServiceId方法代碼示例

本文整理匯總了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);
 }
開發者ID:lingoda,項目名稱:Sylius,代碼行數:30,代碼來源:DoctrineORMDriver.php

示例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);
 }
開發者ID:starspire,項目名稱:eventmanager,代碼行數:11,代碼來源:DoctrineORMDriver.php

示例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);
 }
開發者ID:bendavies,項目名稱:Sylius,代碼行數:13,代碼來源:DoctrinePHPCRDriver.php

示例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);
 }
開發者ID:NeverResponse,項目名稱:Sylius,代碼行數:17,代碼來源:DoctrineORMDriver.php

示例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);
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:23,代碼來源:DoctrinePHPCRDriver.php

示例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);
 }
開發者ID:sylius,項目名稱:sylius,代碼行數:18,代碼來源:AbstractDriver.php

示例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);
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:45,代碼來源:ResourceLoader.php

示例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);
 }
開發者ID:Silwereth,項目名稱:Sylius,代碼行數:21,代碼來源:AbstractDriver.php

示例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);
 }
開發者ID:vikey89,項目名稱:Sylius,代碼行數:26,代碼來源:ResourceLoader.php

示例10: addManager

 /**
  * {@inheritdoc}
  */
 protected function addManager(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $container->setAlias($metadata->getServiceId('manager'), new Alias($this->getManagerServiceId($metadata)));
 }
開發者ID:malukenho,項目名稱:Sylius,代碼行數:7,代碼來源:AbstractDoctrineDriver.php


注:本文中的Sylius\Component\Resource\Metadata\MetadataInterface::getServiceId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。