/**
  * {@inheritdoc}
  */
 public function readEntry($path, $locale, array $indices, $fallback = true)
 {
     $data = $this->reader->read($path, $locale);
     $entry = RecursiveArrayAccess::get($data, $indices);
     $multivalued = is_array($entry) || $entry instanceof \Traversable;
     if (!($fallback && (null === $entry || $multivalued))) {
         return $entry;
     }
     if (null !== ($fallbackLocale = $this->getFallbackLocale($locale))) {
         $parentEntry = $this->readEntry($path, $fallbackLocale, $indices, true);
         if ($entry || $parentEntry) {
             $multivalued = $multivalued || is_array($parentEntry) || $parentEntry instanceof \Traversable;
             if ($multivalued) {
                 if ($entry instanceof \Traversable) {
                     $entry = iterator_to_array($entry);
                 }
                 if ($parentEntry instanceof \Traversable) {
                     $parentEntry = iterator_to_array($parentEntry);
                 }
                 $entry = array_merge($parentEntry ?: array(), $entry ?: array());
             } else {
                 $entry = null === $entry ? $parentEntry : $entry;
             }
         }
     }
     return $entry;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getLocales($path)
 {
     return $this->reader->getLocales($path);
 }