_translate instanceof TranslateObject)) { if (!array_key_exists('translate', $this->_options)) { throw new \RuntimeException("The 'translate' key in the configuration array must be set."); } $this->_translate = new TranslateObject(); if (!array_key_exists('adapter', $this->_options['translate']) || !array_key_exists('translations', $this->_options['translate']) ) { throw new \RuntimeException("The 'adapter' and 'translations' keys need to be set when configuring the translate object."); } $adapterClass = $this->_options['translate']['adapter']; if (!class_exists($adapterClass)) { throw new \RuntimeException( sprintf("Class %s doesn't exist", $adapterClass)); } /** @var \Cube\Translate\Adapter\AbstractAdapter $adapter */ $adapter = new $adapterClass(); foreach ($this->_options['translate']['translations'] as $translation) { $adapter->addTranslation($translation); } $this->_translate->setAdapter($adapter); } return $this->_translate; } }