本文整理汇总了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');