Sulu\Component\Content\Extension\AbstractExtension::setLanguageCode PHP Method

setLanguageCode() public method

public setLanguageCode ( $languageCode, $languageNamespace, $namespace )
    public function setLanguageCode($languageCode, $languageNamespace, $namespace)
    {
        // build namespace
        $namespaces = [];
        if (!empty($namespace)) {
            $namespaces[] = $namespace;
        }
        if (!empty($this->additionalPrefix)) {
            $namespaces[] = $this->additionalPrefix;
        }
        $this->translatedProperties = new MultipleTranslatedProperties($this->properties, $languageNamespace, implode('-', $namespaces));
        $this->translatedProperties->setLanguage($languageCode);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function setLanguageCode($languageCode, $languageNamespace, $namespace)
 {
     // lazy load excerpt structure to avoid redeclaration of classes
     // should be done before parent::setLanguageCode because it uses the $thi<->properties
     // which will be set in initExcerptStructure
     if ($this->excerptStructure === null) {
         $this->initProperties();
     }
     $this->languageCode = $languageCode;
     parent::setLanguageCode($languageCode, $languageNamespace, $namespace);
     $this->languageNamespace = $languageNamespace;
 }