本文整理匯總了PHP中Sylius\Component\Resource\Metadata\MetadataInterface::getHumanizedName方法的典型用法代碼示例。如果您正苦於以下問題:PHP MetadataInterface::getHumanizedName方法的具體用法?PHP MetadataInterface::getHumanizedName怎麽用?PHP MetadataInterface::getHumanizedName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sylius\Component\Resource\Metadata\MetadataInterface
的用法示例。
在下文中一共展示了MetadataInterface::getHumanizedName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
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);
}
示例2:
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);
}
示例3: translateMessage
/**
* @param string $flashMessage
* @param MetadataInterface $metadata
*
* @return string
*/
private function translateMessage($flashMessage, MetadataInterface $metadata)
{
return $this->translator->trans($flashMessage, ['%resource%' => ucfirst($metadata->getHumanizedName())], 'flashes');
}
示例4: getPermissionRole
protected function getPermissionRole($type, MetadataInterface $metadata)
{
return strtoupper(sprintf('ROLE_%s_%s_%s', $metadata->getApplicationName(), $metadata->getHumanizedName(), $type));
}
示例5: getUnderscoreName
protected function getUnderscoreName()
{
$name = $this->metadata->getHumanizedName();
$name = str_replace(' ', '_', $name);
return $name;
}