當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。