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


PHP MetadataInterface::hasClass方法代碼示例

本文整理匯總了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::hasClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP MetadataInterface::hasClass方法的具體用法?PHP MetadataInterface::hasClass怎麽用?PHP MetadataInterface::hasClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sylius\Component\Resource\Metadata\MetadataInterface的用法示例。


在下文中一共展示了MetadataInterface::hasClass方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

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

示例2: addRepository

 /**
  * {@inheritdoc}
  */
 protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $reflection = new \ReflectionClass($metadata->getClass('model'));
     $translatableInterface = TranslatableInterface::class;
     $translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
     $repositoryClassParameterName = sprintf('%s.repository.%s.class', $metadata->getApplicationName(), $metadata->getName());
     $repositoryClass = $translatable ? TranslatableResourceRepository::class : EntityRepository::class;
     if ($container->hasParameter($repositoryClassParameterName)) {
         $repositoryClass = $container->getParameter($repositoryClassParameterName);
     }
     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')) {
         $translatableRepositoryInterface = TranslatableResourceRepositoryInterface::class;
         $translationConfig = $metadata->getParameter('translation');
         if (interface_exists($translatableRepositoryInterface) && $repositoryReflection->implementsInterface($translatableRepositoryInterface)) {
             if (isset($translationConfig['fields'])) {
                 $definition->addMethodCall('setTranslatableFields', [$translationConfig['fields']]);
             }
         }
     }
     $container->setDefinition($metadata->getServiceId('repository'), $definition);
 }
開發者ID:starspire,項目名稱:eventmanager,代碼行數:31,代碼來源:DoctrineORMDriver.php

示例3: 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

示例4: 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

示例5: addRepository

 /**
  * {@inheritdoc}
  */
 protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $modelClass = $metadata->getClass('model');
     $repositoryClass = in_array(TranslatableInterface::class, class_implements($modelClass)) ? TranslatableRepository::class : new Parameter('sylius.mongodb.odm.repository.class');
     if ($metadata->hasClass('repository')) {
         $repositoryClass = $metadata->getClass('repository');
     }
     $unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
     $unitOfWorkDefinition->setFactory([new Reference($this->getManagerServiceId($metadata)), 'getUnitOfWork'])->setPublic(false);
     $definition = new Definition($repositoryClass);
     $definition->setArguments([new Reference($metadata->getServiceId('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($metadata)]);
     $container->setDefinition($metadata->getServiceId('repository'), $definition);
 }
開發者ID:loic425,項目名稱:Sylius,代碼行數:16,代碼來源:DoctrineODMDriver.php

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

示例7: 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

示例8: addRepository

 /**
  * {@inheritdoc}
  */
 protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $modelClass = $metadata->getClass('model');
     $reflection = new \ReflectionClass($modelClass);
     $translatableInterface = 'Sylius\\Component\\Translation\\Model\\TranslatableInterface';
     $translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
     $repositoryClass = $translatable ? 'Sylius\\Bundle\\TranslationBundle\\Doctrine\\ODM\\MongoDB\\TranslatableResourceRepository' : new Parameter('sylius.mongodb_odm.repository.class');
     if ($metadata->hasClass('repository')) {
         $repositoryClass = $metadata->getClass('repository');
     }
     $unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
     $unitOfWorkDefinition->setFactory(array(new Reference($this->getManagerServiceId($metadata)), 'getUnitOfWork'))->setPublic(false);
     $definition = new Definition($repositoryClass);
     $definition->setArguments(array(new Reference($metadata->getServiceId('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($modelClass)));
     return $definition;
 }
開發者ID:lingoda,項目名稱:Sylius,代碼行數:19,代碼來源:DoctrineODMDriver.php

示例9: addRepository

 /**
  * {@inheritdoc}
  */
 protected function addRepository(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $modelClass = $metadata->getClass('model');
     $reflection = new \ReflectionClass($modelClass);
     $translatableInterface = TranslatableInterface::class;
     $translatable = interface_exists($translatableInterface) && $reflection->implementsInterface($translatableInterface);
     $repositoryClass = $translatable ? TranslatableResourceRepository::class : new Parameter('sylius.mongodb_odm.repository.class');
     if ($metadata->hasClass('repository')) {
         $repositoryClass = $metadata->getClass('repository');
     }
     $repositoryReflection = new \ReflectionClass($repositoryClass);
     $unitOfWorkDefinition = new Definition('Doctrine\\ODM\\MongoDB\\UnitOfWork');
     $unitOfWorkDefinition->setFactory([new Reference($this->getManagerServiceId($metadata)), 'getUnitOfWork'])->setPublic(false);
     $definition = new Definition($repositoryClass);
     $definition->setArguments([new Reference($metadata->getServiceId('manager')), $unitOfWorkDefinition, $this->getClassMetadataDefinition($metadata)]);
     $definition->setLazy(!$repositoryReflection->isFinal());
     $container->setDefinition($metadata->getServiceId('repository'), $definition);
 }
開發者ID:starspire,項目名稱:eventmanager,代碼行數:21,代碼來源:DoctrineODMDriver.php

示例10: 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


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