本文整理汇总了PHP中Doctrine\ODM\PHPCR\DocumentManager::isDocumentTranslatable方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::isDocumentTranslatable方法的具体用法?PHP DocumentManager::isDocumentTranslatable怎么用?PHP DocumentManager::isDocumentTranslatable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ODM\PHPCR\DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::isDocumentTranslatable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateLocale
/**
* Update the locale of a route if $id starts with the prefix and has a
* valid locale right after.
*
* @param Route $doc The route object
* @param string $id The id (in move case, this is not the current
* id of $route).
* @param DocumentManager $dm The document manager to get locales from if
* the setAvailableTranslations option is
* enabled.
* @param boolean $force Whether to update the locale even if the
* route already has a locale.
*/
protected function updateLocale(Route $doc, $id, DocumentManager $dm, $force = false)
{
$matches = array();
// only update if the prefix matches, to allow for more than one
// listener and more than one route root.
if (!preg_match('#(' . implode('|', $this->getPrefixes()) . ')/([^/]+)(/|$)#', $id, $matches)) {
return;
}
if (in_array($locale = $matches[2], $this->locales)) {
if ($force || !$doc->getDefault('_locale')) {
$doc->setDefault('_locale', $locale);
}
if ($force || !$doc->getRequirement('_locale')) {
$doc->setRequirement('_locale', $locale);
}
} else {
if ($this->addLocalePattern) {
$doc->setOption('add_locale_pattern', true);
}
if ($this->updateAvailableTranslations && $dm->isDocumentTranslatable($doc) && !$doc->getRequirement('_locale')) {
$locales = $dm->getLocalesFor($doc, true);
$doc->setRequirement('_locale', implode('|', $locales));
}
}
}