protected function getLocale($document) { $locale = null; if (!$document->hasLocale()) { $parent = $document->getParent(); if ($parent) { $locale = $this->getLocale($parent); } } else { $locale = $document->getLocale(); } return $locale; }