本文整理匯總了PHP中eZContentObjectStateGroup::translationByLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentObjectStateGroup::translationByLocale方法的具體用法?PHP eZContentObjectStateGroup::translationByLocale怎麽用?PHP eZContentObjectStateGroup::translationByLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentObjectStateGroup
的用法示例。
在下文中一共展示了eZContentObjectStateGroup::translationByLocale方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testCreateWithvalidIdentifier
/**
* @dataProvider providerCreateWithValidIdentifier
*/
public function testCreateWithvalidIdentifier($identifier)
{
$row = array('identifier' => $identifier);
$stateGroup = new eZContentObjectStateGroup($row);
$trans = $stateGroup->translationByLocale('eng-GB');
$trans->setAttribute('name', $identifier);
$messages = array();
$this->assertTrue($stateGroup->isValid($messages), "Valid state group identifier '{$identifier}' was refused, " . var_export($messages, true));
}
示例2: array
$localeIDToUse = false;
// this script inserts English names, so preferably use an English locale
$preferredLocales = array('eng-GB', 'eng-US');
foreach ($preferredLocales as $preferredLocale) {
if (in_array($preferredLocale, $locales)) {
$localeToUse = $preferredLocale;
break;
}
}
// when none of the preferred locales are in use, then use the top priority language
if ($localeToUse === false) {
$prioritizedLanguage = eZContentLanguage::topPriorityLanguage();
$localeToUse = $prioritizedLanguage->attribute('locale');
}
$lockGroup = new eZContentObjectStateGroup(array('identifier' => 'ez_lock'));
$trans = $lockGroup->translationByLocale($localeToUse);
$trans->setAttribute('name', 'Lock');
$trans->setAttribute('description', 'Lock group');
$messages = array();
if ($lockGroup->isValid($messages)) {
$cli->output('storing state group ez_lock');
$lockGroup->store();
} else {
eZDebug::writeDebug($messages);
$db->rollback();
$script->shutdown(2);
}
$notLockedState = $lockGroup->newState('not_locked');
$trans = $notLockedState->translationByLocale($localeToUse);
$trans->setAttribute('name', 'Not locked');
$trans->setAttribute('description', 'Not locked state');