本文整理汇总了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::getApplicationName方法的典型用法代码示例。如果您正苦于以下问题:PHP MetadataInterface::getApplicationName方法的具体用法?PHP MetadataInterface::getApplicationName怎么用?PHP MetadataInterface::getApplicationName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Metadata\MetadataInterface
的用法示例。
在下文中一共展示了MetadataInterface::getApplicationName方法的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);
}
}
示例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'));
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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');
}
示例6: 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;
}
示例7:
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);
}
示例8: 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);
}
示例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);
}
示例10:
function it_has_a_name(MetadataInterface $metadata)
{
$metadata->getName()->willReturn('product');
$metadata->getApplicationName()->willReturn('sylius');
$this->getName()->shouldReturn('sylius_product_from_identifier');
}
示例11: 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));
}
示例12: getBlockPrefix
/**
* {@inheritdoc}
*/
public function getBlockPrefix()
{
return sprintf('%s_%s_choice', $this->metadata->getApplicationName(), $this->metadata->getName());
}
示例13: 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();
}
示例14:
function it_generates_permission_name(MetadataInterface $metadata, Parameters $parameters)
{
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');
$parameters->has('permission')->willReturn(false);
$this->getPermission('index')->shouldReturn('sylius.product.index');
}
示例15: getName
/**
* {@inheritdoc}
*/
public function getName()
{
return sprintf('%s_%s', $this->metadata->getApplicationName(), $this->metadata->getName());
}