本文整理汇总了PHP中Sonata\AdminBundle\Admin\AdminInterface::setLabelTranslatorStrategy方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminInterface::setLabelTranslatorStrategy方法的具体用法?PHP AdminInterface::setLabelTranslatorStrategy怎么用?PHP AdminInterface::setLabelTranslatorStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\AdminBundle\Admin\AdminInterface
的用法示例。
在下文中一共展示了AdminInterface::setLabelTranslatorStrategy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWithFieldsCascadeTranslationDomain
public function testWithFieldsCascadeTranslationDomain()
{
$this->admin->setModelManager($this->modelManager);
$this->modelManager->expects($this->once())->method('getNewFieldDescriptionInstance')->with('class', 'foo', array('translation_domain' => 'Foobar', 'type' => 'bar'))->will($this->returnValue($this->fieldDescription));
$this->contractor->expects($this->once())->method('getDefaultOptions')->will($this->returnValue(array()));
$this->admin->setLabelTranslatorStrategy($this->labelTranslatorStrategy);
$this->formMapper->with('foobar', array('translation_domain' => 'Foobar'))->add('foo', 'bar')->end();
$this->assertSame(array('default' => array('collapsed' => false, 'class' => false, 'description' => false, 'translation_domain' => 'Foobar', 'name' => 'default', 'auto_created' => true, 'groups' => array('foobar'), 'tab' => true)), $this->admin->getFormTabs());
$this->assertSame(array('foobar' => array('collapsed' => false, 'class' => false, 'description' => false, 'translation_domain' => 'Foobar', 'name' => 'foobar', 'fields' => array('foo' => 'foo'))), $this->admin->getFormGroups());
}
示例2: setUp
public function setUp()
{
$this->contractor = $this->getMock('Sonata\\AdminBundle\\Builder\\FormContractorInterface');
$formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
$eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$formBuilder = new FormBuilder('test', 'stdClass', $eventDispatcher, $formFactory);
$this->admin = new CleanAdmin('code', 'class', 'controller');
$this->modelManager = $this->getMock('Sonata\\AdminBundle\\Model\\ModelManagerInterface');
// php 5.3 BC
$fieldDescription = $this->getFieldDescriptionMock();
$this->modelManager->expects($this->any())->method('getNewFieldDescriptionInstance')->will($this->returnCallback(function ($class, $name, array $options = array()) use($fieldDescription) {
$fieldDescriptionClone = clone $fieldDescription;
$fieldDescriptionClone->setName($name);
$fieldDescriptionClone->setOptions($options);
return $fieldDescriptionClone;
}));
$this->admin->setModelManager($this->modelManager);
$labelTranslatorStrategy = $this->getMock('Sonata\\AdminBundle\\Translator\\LabelTranslatorStrategyInterface');
$this->admin->setLabelTranslatorStrategy($labelTranslatorStrategy);
$this->formMapper = new FormMapper($this->contractor, $formBuilder, $this->admin);
}