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


PHP MetadataInterface::getName方法代码示例

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


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

示例1: 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);
     }
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:35,代码来源:DoctrinePHPCRDriver.php

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

示例3: updateAction

 /**
  * @param Request $request
  *
  * @return Response
  */
 public function updateAction(Request $request)
 {
     $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
     $this->isGrantedOr403($configuration, ResourceActions::UPDATE);
     $resource = $this->findOr404($configuration);
     $form = $this->resourceFormFactory->create($configuration, $resource);
     if (in_array($request->getMethod(), array('POST', 'PUT', 'PATCH')) && $form->submit($request, !$request->isMethod('PATCH'))->isValid()) {
         $resource = $form->getData();
         $event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource);
         if ($event->isStopped() && !$configuration->isHtmlRequest()) {
             throw new HttpException($event->getErrorCode(), $event->getMessage());
         }
         if ($event->isStopped()) {
             $this->flashHelper->addFlashFromEvent($configuration, $event);
             return $this->redirectHandler->redirectToResource($configuration, $resource);
         }
         $this->manager->flush();
         $this->eventDispatcher->dispatchPostEvent(ResourceActions::UPDATE, $configuration, $resource);
         if (!$configuration->isHtmlRequest()) {
             return $this->viewHandler->handle($configuration, View::create($resource, 204));
         }
         $this->flashHelper->addSuccessFlash($configuration, ResourceActions::UPDATE, $resource);
         return $this->redirectHandler->redirectToResource($configuration, $resource);
     }
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create($form, 400));
     }
     $view = View::create()->setData(array('metadata' => $this->metadata, 'resource' => $resource, $this->metadata->getName() => $resource, 'form' => $form->createView()))->setTemplate($configuration->getTemplate(ResourceActions::UPDATE));
     return $this->viewHandler->handle($configuration, $view);
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:35,代码来源:ResourceController.php

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

示例5: updateAction

 /**
  * @param Request $request
  *
  * @return Response
  */
 public function updateAction(Request $request)
 {
     $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
     $this->isGrantedOr403($configuration, ResourceActions::UPDATE);
     $resource = $this->findOr404($configuration);
     $form = $this->resourceFormFactory->create($configuration, $resource);
     if (in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'], true) && $form->handleRequest($request)->isValid()) {
         $resource = $form->getData();
         $event = $this->eventDispatcher->dispatchPreEvent(ResourceActions::UPDATE, $configuration, $resource);
         if ($event->isStopped() && !$configuration->isHtmlRequest()) {
             throw new HttpException($event->getErrorCode(), $event->getMessage());
         }
         if ($event->isStopped()) {
             $this->flashHelper->addFlashFromEvent($configuration, $event);
             return $this->redirectHandler->redirectToResource($configuration, $resource);
         }
         if ($configuration->hasStateMachine()) {
             $this->stateMachine->apply($configuration, $resource);
         }
         $this->manager->flush();
         $this->eventDispatcher->dispatchPostEvent(ResourceActions::UPDATE, $configuration, $resource);
         if (!$configuration->isHtmlRequest()) {
             return $this->viewHandler->handle($configuration, View::create(null, Response::HTTP_NO_CONTENT));
         }
         $this->flashHelper->addSuccessFlash($configuration, ResourceActions::UPDATE, $resource);
         return $this->redirectHandler->redirectToResource($configuration, $resource);
     }
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create($form, Response::HTTP_BAD_REQUEST));
     }
     $view = View::create()->setData(['configuration' => $configuration, 'metadata' => $this->metadata, 'resource' => $resource, $this->metadata->getName() => $resource, 'form' => $form->createView()])->setTemplate($configuration->getTemplate(ResourceActions::UPDATE . '.html'));
     return $this->viewHandler->handle($configuration, $view);
 }
开发者ID:sylius,项目名称:sylius,代码行数:38,代码来源:ResourceController.php

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

示例7: getPermission

 /**
  * @param string $name
  *
  * @return string
  *
  * @throws \LogicException
  */
 public function getPermission($name)
 {
     if (!$this->hasPermission()) {
         throw new \LogicException('Current action does not require any authorization.');
     }
     if (!$this->parameters->has('permission')) {
         return sprintf('%s.%s.%s', $this->metadata->getApplicationName(), $this->metadata->getName(), $name);
     }
     return $this->parameters->get('permission');
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:17,代码来源:RequestConfiguration.php

示例8: getPermission

 /**
  * @param string $name
  *
  * @return string
  *
  * @throws \LogicException
  */
 public function getPermission($name)
 {
     $permission = $this->parameters->get('permission');
     if (null === $permission) {
         throw new \LogicException('Current action does not require any authorization.');
     }
     if (true === $permission) {
         return sprintf('%s.%s.%s', $this->metadata->getApplicationName(), $this->metadata->getName(), $name);
     }
     return $permission;
 }
开发者ID:sylius,项目名称:sylius,代码行数:18,代码来源:RequestConfiguration.php

示例9:

 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

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

示例11: updateStateAction

 /**
  * @param Request $request
  * @param string $transition
  * @param string $graph
  *
  * @return RedirectResponse
  */
 public function updateStateAction(Request $request, $transition, $graph)
 {
     $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
     $resource = $this->findOr404($configuration);
     $stateMachine = $this->get('sm.factory')->get($resource, $graph);
     if (!$stateMachine->can($transition)) {
         throw new NotFoundHttpException(sprintf('The requested transition %s cannot be applied on the given %s with graph %s.', $transition, $this->metadata->getName(), $graph));
     }
     $stateMachine->apply($transition);
     $this->manager->flush();
     if (!$configuration->isHtmlRequest()) {
         return $this->viewHandler->handle($configuration, View::create($resource, 204));
     }
     $this->flashHelper->addSuccessFlash($configuration, ResourceActions::UPDATE, $resource);
     return $this->redirectHandler->redirectToReferer($configuration);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:23,代码来源:ResourceController.php

示例12:

 function it_has_a_name(MetadataInterface $metadata)
 {
     $metadata->getName()->willReturn('product');
     $metadata->getApplicationName()->willReturn('sylius');
     $this->getName()->shouldReturn('sylius_product_from_identifier');
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:6,代码来源:ResourceFromIdentifierTypeSpec.php

示例13: HttpException

 function it_does_not_delete_a_resource_and_throws_http_exception_for_non_html_requests_stopped_via_event(MetadataInterface $metadata, RequestConfigurationFactoryInterface $requestConfigurationFactory, RequestConfiguration $configuration, AuthorizationCheckerInterface $authorizationChecker, RepositoryInterface $repository, SingleResourceProviderInterface $singleResourceProvider, ResourceInterface $resource, FlashHelperInterface $flashHelper, EventDispatcherInterface $eventDispatcher, ResourceControllerEvent $event, Request $request)
 {
     $metadata->getApplicationName()->willReturn('sylius');
     $metadata->getName()->willReturn('product');
     $requestConfigurationFactory->create($metadata, $request)->willReturn($configuration);
     $configuration->hasPermission()->willReturn(true);
     $configuration->getPermission(ResourceActions::DELETE)->willReturn('sylius.product.delete');
     $authorizationChecker->isGranted($configuration, 'sylius.product.delete')->willReturn(true);
     $singleResourceProvider->get($configuration, $repository)->willReturn($resource);
     $configuration->isHtmlRequest()->willReturn(false);
     $eventDispatcher->dispatchPreEvent(ResourceActions::DELETE, $configuration, $resource)->willReturn($event);
     $event->isStopped()->willReturn(true);
     $event->getMessage()->willReturn('Cannot delete this product.');
     $event->getErrorCode()->willReturn(500);
     $repository->remove($resource)->shouldNotBeCalled();
     $eventDispatcher->dispatchPostEvent(Argument::any())->shouldNotBeCalled();
     $flashHelper->addSuccessFlash(Argument::any())->shouldNotBeCalled();
     $flashHelper->addFlashFromEvent(Argument::any())->shouldNotBeCalled();
     $this->shouldThrow(new HttpException(500, 'Cannot delete this product.'))->during('deleteAction', array($request));
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:20,代码来源:ResourceControllerSpec.php

示例14: getBlockPrefix

 /**
  * {@inheritdoc}
  */
 public function getBlockPrefix()
 {
     return sprintf('%s_%s_choice', $this->metadata->getApplicationName(), $this->metadata->getName());
 }
开发者ID:sylius,项目名称:sylius,代码行数:7,代码来源:ResourceChoiceType.php

示例15: debugResource

 /**
  * @param MetadataInterface $metadata
  * @param OutputInterface $output
  */
 private function debugResource(MetadataInterface $metadata, OutputInterface $output)
 {
     $table = new Table($output);
     $information = ['name' => $metadata->getName(), 'application' => $metadata->getApplicationName(), 'driver' => $metadata->getDriver()];
     $parameters = $this->flattenParameters($metadata->getParameters());
     foreach ($parameters as $key => $value) {
         $information[$key] = $value;
     }
     foreach ($information as $key => $value) {
         $table->addRow([$key, $value]);
     }
     $table->render();
 }
开发者ID:loic425,项目名称:Sylius,代码行数:17,代码来源:DebugResourceCommand.php


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