Transforms route translation entity

@param FileTranslation|array $translation FileTranslation entity

@return array
978870
public function transform($translation)
    {
        $translation = $this->entityToArray(FileTranslation::class, $translation);
        return [
            'id'          => (int) $translation['id'],
            'langCode'    => $translation['lang_code'],
            'title'       => $translation['title'],
            'description' => $translation['description'],
            'createdAt'   => $translation['created_at'],
            'updatedAt'   => $translation['updated_at'],
        ];
    }
816025
public function transform($route)
    {
        $route = $this->entityToArray(Route::class, $route);
        return [
            'id'        => (int) $route['id'],
            'createdAt' => $route['created_at'],
            'updatedAt' => $route['updated_at']
        ];
    }
36084
public function transformToResourceIdentifier(ResourceTransformation $transformation): ?array
    {
        if ($transformation->object === null || $transformation->resource === null) {
            return null;
        }

        $transformation->resource->initializeTransformation(
            $transformation->request,
            $transformation->object,
            $transformation->exceptionFactory
        );

        $this->transformResourceIdentifier($transformation);

        $transformation->resource->clearTransformation();

        return $transformation->result;
    }
166545
public function setTranslation($translation) {
		if(!$this->setModified('translation', $translation)->isModified()) {
			return $this;
		}
		$this->translation = $translation;
		return $this;
	}
768192
public function loadTranslations($translations)
    {
        if (is_object($translations) && $translations instanceof Translations) {
            $translations = PhpArray::generate($translations, ['includeHeaders' => false]);
        } elseif (is_string($translations) && is_file($translations)) {
            $translations = include $translations;
        } elseif (!is_array($translations)) {
            throw new \InvalidArgumentException(
                'Invalid Translator: only arrays, files or instance of Translations are allowed'
            );
        }

        $this->addTranslations($translations);

        return $this;
    }
1181816
public function getTranslationsForKey($key) {
		$this->getAllTranslationByLanguage();
		$translations = [];
		foreach ($this->messages as $language => $messages) {
			foreach ($messages as $messageKey => $message) {
				if($key == $messageKey) {
					$translations[$language] = $message;
				}
			}
		}
		return $translations;
	}
325199
private function getTranslations($lang) {
    if (!isset($this->translations[$lang])) {
      $messageFile = $this->localeDir."/messages_".$lang.".php";
      if (file_exists($messageFile)) {
        require_once($messageFile);
        // store for later reference
        $this->translations[$lang] = ${"messages_$lang"};
      }
      else {
        $this->translations[$lang] = [];
      }
    }
    return $this->translations[$lang];
  }
1184227
public function removeTranslation(\Lexik\Bundle\TranslationBundle\Model\Translation $translation)
    {
        $this->translations->removeElement($translation);
    }
1005198
protected function replace($translation, $replacement = []) {
        foreach ($replacement as $key => $value) {
            $translation = str_replace(':'.$key, $value, $translation);
        }

        return $translation;
    }
703815
public function filter($translations)
    {
        foreach ($translations as $pluginName => $pluginTranslations) {
            foreach ($pluginTranslations as $key => $translation) {

                if (isset($this->baseTranslations[$pluginName][$key]) &&
                    $this->baseTranslations[$pluginName][$key] != Translate::clean($this->baseTranslations[$pluginName][$key])) {
                    continue; // skip if base translation already contains encoded entities
                }

                // remove encoded entities
                $decoded = Translate::clean($translation);
                if ($translation != $decoded) {
                    $this->filteredData[$pluginName][$key] = $translation;
                    $translations[$pluginName][$key] = $decoded;
                    continue;
                }

            }
        }

        return $translations;
    }
1187020
public function exportTranslations(Translations $translations)
    {
        $name = $this->getTreeNodeDisplayName('text');
        if (is_string($name) && ($name !== '')) {
            $context = method_exists($this, 'getTreeNodeTranslationContext') ? $this->getTreeNodeTranslationContext() : '';
            $translations->insert($context, $name);
        }
        $this->populateDirectChildrenOnly();
        foreach ($this->getChildNodes() as $childnode) {
            $childnode->exportTranslations($translations);
        }
    }
873175
public function preRemove(PageTranslationInterface $translation)
    {
        /** @var \Ekyna\Bundle\CmsBundle\Model\PageInterface $translatable */
        $translatable = $translation->getTranslatable();
        if (null !== $parentPage = $translatable->getParent()) {
            $from = $translation->getPath();
            $locale = $translation->getLocale();
            // TODO use url generator or i18n routing prefix strategy
            $localePrefix = $locale != 'fr' ? '/' . $locale : '';

            // Redirect to this parent page.
            $to = $parentPage->translate($locale)->getPath();
            if (0 < strlen($from) && 0 < strlen($to) && $from != $to) {
                $this->redirections[] = array(
                    'from' => $localePrefix . $from,
                    'to'   => $localePrefix . $to,
                );
            }
        }
    }
986031
public function filter($translations)
    {
        $cleanedTranslations = array();

        foreach ($translations as $pluginName => $pluginTranslations) {

            foreach ($pluginTranslations as $key => $translation) {

                if (isset($this->baseTranslations[$pluginName][$key])) {
                    $baseTranslation = $this->baseTranslations[$pluginName][$key];
                } else {
                    // english string was deleted, do not error
                    continue;
                }

                // ensure that translated strings have the same number of %s as the english source strings
                $baseCount = $this->_getParametersCountToReplace($baseTranslation);
                $translationCount = $this->_getParametersCountToReplace($translation);

                if ($baseCount != $translationCount) {

                    $this->filteredData[$pluginName][$key] = $translation;
                    continue;
                }

                $cleanedTranslations[$pluginName][$key] = $translation;
            }
        }

        return $cleanedTranslations;
    }
533798
public function translate($uri)
    {
        foreach ($this->translationMap as $from => $to) {
            $uri = preg_replace($from, $to, $uri);
        }

        // translate references to local files within the json-schema package
        $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);

        return $uri;
    }
1038248
public function routeDetails($translate = false) {
        $fetchList = [
            'routeDest' => 'destination',
            'routeMask' => 'mask',
            'routeTos' => 'TOS',
            'routeNextHop' => 'nextHop',
            'routeIfIndex' => 'ifIndex',
            'routeType' => 'type',
            'routeProto' => 'protocol',
            'routeAge' => 'age',
            'routeInfo' => 'info',
            'routeNextHopAS' => 'nextHopAS',
            'routeMetric1' => 'metric1',
            'routeMetric2' => 'metric2',
            'routeMetric3' => 'metric3',
            'routeMetric4' => 'metric4',
            'routeMetric5' => 'metric5',
            'routeStatus' => 'status'
        ];
        $canTranslate = [ 'routeType', 'routeProto', 'routeStatus'];
        $details = [];

        foreach ($fetchList as $fn => $idx) {
            if (in_array($fn, $canTranslate))
                $values = $this->$fn($translate);
            else
                $values = $this->$fn();
            foreach ($values as $ip => $value)
                $details[$ip][$idx] = $value;
        }
        return $details;
    }
796215
private function normalizePropertyTranslations(array $translations)
    {
        $maxLength = 0;

        foreach ($translations as $property => $translation) {
            $length = strlen($property);

            if ($length > $maxLength) {
                $maxLength = $length;
            }
        }
        foreach ($translations as $property => $translation) {
            $translations[$property] = str_repeat(' ', $maxLength - strlen($property)).$translation;
        }

        ksort($translations);

        return $translations;
    }
150272
private function translationToString(Translation $translation)
    {
        $values = $translation->values;
        if ($translation instanceof Translation\Plural) {
            if (current($values) === 1) {
                return $translation->singular;
            } else {
                return $translation->plural;
            }
        } else {
            return $translation->message;
        }
    }