当前位置: 首页>>代码示例>>PHP>>正文


PHP Metadata\MetadataInterface类代码示例

本文整理汇总了PHP中Sylius\Component\Resource\Metadata\MetadataInterface的典型用法代码示例。如果您正苦于以下问题:PHP MetadataInterface类的具体用法?PHP MetadataInterface怎么用?PHP MetadataInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MetadataInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function it_defines_resource_options(OptionsResolver $resolver, MetadataInterface $metadata)
 {
     $metadata->getDriver()->willReturn(SyliusResourceBundle::DRIVER_DOCTRINE_ORM);
     $resolver->setDefaults(['class' => null])->shouldBeCalled()->willReturn($resolver);
     $resolver->setNormalizer('class', Argument::type('callable'))->shouldBeCalled()->willReturn($resolver);
     $this->configureOptions($resolver);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:7,代码来源:ResourceChoiceTypeSpec.php

示例2: build

 /**
  * {@inheritdoc}
  */
 public function build(MetadataInterface $metadata, FormBuilderInterface $formBuilder, array $options)
 {
     $classMetadata = $this->entityManager->getClassMetadata($metadata->getClass('model'));
     if (1 < count($classMetadata->identifier)) {
         throw new \RuntimeException('The default form factory does not support entity classes with multiple primary keys.');
     }
     $fields = (array) $classMetadata->fieldNames;
     if (!$classMetadata->isIdentifierNatural()) {
         $fields = array_diff($fields, $classMetadata->identifier);
     }
     foreach ($fields as $fieldName) {
         $options = [];
         if (in_array($fieldName, ['createdAt', 'updatedAt', 'deletedAt'])) {
             continue;
         }
         if (Type::DATETIME === $classMetadata->getTypeOfField($fieldName)) {
             $options = ['widget' => 'single_text'];
         }
         $formBuilder->add($fieldName, null, $options);
     }
     foreach ($classMetadata->getAssociationMappings() as $fieldName => $associationMapping) {
         if (ClassMetadataInfo::ONE_TO_MANY !== $associationMapping['type']) {
             $formBuilder->add($fieldName, null, ['property' => 'id']);
         }
     }
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:29,代码来源:DefaultFormBuilder.php

示例3: 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;
 }
开发者ID:malukenho,项目名称:Sylius,代码行数:13,代码来源:AbstractDoctrineDriver.php

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

示例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');
     }
     $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

示例6:

 function it_returns_specific_metadata_by_model_class(MetadataInterface $metadata1, MetadataInterface $metadata2)
 {
     $metadata1->getAlias()->willReturn('app.product');
     $metadata1->getClass('model')->willReturn('App\\Model\\Product');
     $metadata2->getAlias()->willReturn('app.order');
     $metadata2->getClass('model')->willReturn('App\\Model\\Order');
     $this->add($metadata1);
     $this->add($metadata2);
     $this->getByClass('App\\Model\\Order')->shouldReturn($metadata2);
 }
开发者ID:Silwereth,项目名称:Sylius,代码行数:10,代码来源:RegistrySpec.php

示例7: ResourceGridView

 function it_uses_data_provider_to_create_a_view_with_data_and_definition(DataProviderInterface $dataProvider, ParametersParserInterface $parametersParser, Grid $grid, Parameters $parameters, MetadataInterface $resourceMetadata, Request $request, RequestConfiguration $requestConfiguration)
 {
     $expectedResourceGridView = new ResourceGridView(['foo', 'bar'], $grid->getWrappedObject(), $parameters->getWrappedObject(), $resourceMetadata->getWrappedObject(), $requestConfiguration->getWrappedObject());
     $requestConfiguration->getRequest()->willReturn($request);
     $parametersParser->parseRequestValues(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => ['$customerId']]], $request)->willReturn(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => [5]]]);
     $grid->getDriverConfiguration()->willReturn(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => ['$customerId']]]);
     $grid->setDriverConfiguration(['repository' => ['method' => 'createByCustomerQueryBuilder', 'arguments' => [5]]])->shouldBeCalled();
     $dataProvider->getData($grid, $parameters)->willReturn(['foo', 'bar']);
     $this->create($grid, $parameters, $resourceMetadata, $requestConfiguration)->shouldBeSameResourceGridViewAs($expectedResourceGridView);
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:ResourceGridViewFactorySpec.php

示例8:

 function it_adds_custom_message(SessionInterface $session, TranslatorBagInterface $translator, MessageCatalogueInterface $messageCatalogue, FlashBagInterface $flashBag, MetadataInterface $metadata, RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $metadata->getApplicationName()->willReturn('app');
     $metadata->getHumanizedName()->willReturn('book');
     $requestConfiguration->getMetadata()->willReturn($metadata);
     $requestConfiguration->getFlashMessage('send')->willReturn('app.book.send');
     $translator->getCatalogue('en')->willReturn($messageCatalogue);
     $messageCatalogue->has('app.book.send', 'flashes')->willReturn(true);
     $session->getBag('flashes')->willReturn($flashBag);
     $flashBag->add('success', 'app.book.send')->shouldBeCalled();
     $this->addSuccessFlash($requestConfiguration, 'send', $resource);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:12,代码来源:FlashHelperSpec.php

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

示例10:

 function it_uses_default_translation_if_message_is_not_translated(SessionInterface $session, FlashBagInterface $flashBag, TranslatorInterface $translator, MetadataInterface $metadata, RequestConfiguration $requestConfiguration, ResourceInterface $resource)
 {
     $metadata->getApplicationName()->willReturn('sylius');
     $metadata->getName()->willReturn('product');
     $metadata->getHumanizedName()->willReturn('product');
     $requestConfiguration->getMetadata()->willReturn($metadata);
     $requestConfiguration->isHtmlRequest()->willReturn(true);
     $session->getBag('flashes')->willReturn($flashBag);
     $requestConfiguration->getFlashMessage(ResourceActions::CREATE)->willReturn('sylius.product.create');
     $translator->trans('sylius.product.create', ['%resource%' => 'Product'], 'flashes')->willReturn('sylius.product.create');
     $translator->trans('sylius.resource.create', ['%resource%' => 'Product'], 'flashes')->willReturn('Product has been successfully created.');
     $flashBag->add('success', 'Product has been successfully created.')->shouldBeCalled();
     $this->addSuccessFlash($requestConfiguration, ResourceActions::CREATE, $resource);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:14,代码来源:FlashHelperSpec.php

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

示例12: get

 /**
  * @param MetadataInterface $metadata
  *
  * @return DriverInterface
  *
  * @throws UnknownDriverException
  */
 public static function get(MetadataInterface $metadata)
 {
     $type = $metadata->getDriver();
     if (isset(self::$drivers[$type])) {
         return self::$drivers[$type];
     }
     switch ($type) {
         case SyliusResourceBundle::DRIVER_DOCTRINE_ORM:
             return self::$drivers[$type] = new DoctrineORMDriver();
         case SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM:
             return self::$drivers[$type] = new DoctrineODMDriver();
         case SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM:
             return self::$drivers[$type] = new DoctrinePHPCRDriver();
     }
     throw new UnknownDriverException($type);
 }
开发者ID:bendavies,项目名称:Sylius,代码行数:23,代码来源:DriverProvider.php

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

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

示例15: build

 /**
  * {@inheritdoc}
  */
 public function build(MetadataInterface $metadata, FormBuilderInterface $formBuilder, array $options)
 {
     $classMetadata = $this->documentManager->getClassMetadata($metadata->getClass('model'));
     // the field mappings should only contain standard value mappings
     foreach ($classMetadata->fieldMappings as $fieldName) {
         if ($fieldName === $classMetadata->uuidFieldName) {
             continue;
         }
         if ($fieldName === $classMetadata->nodename) {
             continue;
         }
         $options = [];
         $mapping = $classMetadata->mappings[$fieldName];
         if ($mapping['nullable'] === false) {
             $options['required'] = true;
         }
         $formBuilder->add($fieldName, null, $options);
     }
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:22,代码来源:DefaultFormBuilder.php


注:本文中的Sylius\Component\Resource\Metadata\MetadataInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。