本文整理汇总了PHP中Zend\Form\Form::setDefaultTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::setDefaultTranslator方法的具体用法?PHP Form::setDefaultTranslator怎么用?PHP Form::setDefaultTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Form
的用法示例。
在下文中一共展示了Form::setDefaultTranslator方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTranslatorRetrievesGlobalDefaultWhenAvailable
public function testGetTranslatorRetrievesGlobalDefaultWhenAvailable()
{
$this->assertNull($this->element->getTranslator());
$translator = new Translator('ArrayAdapter', array('foo' => 'bar'));
Form::setDefaultTranslator($translator);
$received = $this->element->getTranslator();
$this->assertSame($translator->getAdapter(), $received);
}
示例2: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
Registry::_unsetInstance();
Form::setDefaultTranslator(null);
$this->element = new SubmitElement('foo');
}
示例3: testValidatorsDefaultTranslatorDoesntOverrideFormsDefaultTranslator
/**
* @group ZF-9275
*/
public function testValidatorsDefaultTranslatorDoesntOverrideFormsDefaultTranslator()
{
$formTranslations = array('alphaInvalid' => 'Form message');
$formTranslate = new Translator('ArrayAdapter', $formTranslations);
Form::setDefaultTranslator($formTranslate);
$validatorTranslations = array('alphaInvalid' => 'Validator message');
$validatorTranslate = new Translator('ArrayAdapter', $validatorTranslations);
AbstractValidator::setDefaultTranslator($validatorTranslate);
// the default validate translator should beat the registry one
$this->element->addValidator('Alpha');
$this->assertFalse($this->element->isValid(123));
$messages = $this->element->getMessages();
$this->assertEquals('Form message', $messages['alphaInvalid']);
}
示例4: testLocalTranslatorPreferredOverDefaultGlobalTranslator
public function testLocalTranslatorPreferredOverDefaultGlobalTranslator()
{
$this->assertNull($this->form->getTranslator());
$translatorDefault = new Translator('ArrayAdapter', array('foo' => 'bar'));
Form::setDefaultTranslator($translatorDefault);
$received = $this->form->getTranslator();
$this->assertSame($translatorDefault->getAdapter(), $received);
$translator = new Translator('ArrayAdapter', array('foo' => 'bar'));
$this->form->setTranslator($translator);
$received = $this->form->getTranslator();
$this->assertNotSame($translatorDefault->getAdapter(), $received);
$this->assertSame($translator->getAdapter(), $received);
}
示例5: setUp
public function setUp()
{
Form::setDefaultTranslator(null);
$this->form = new SubForm();
}