本文整理匯總了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();
}