/** * @covers Opt_Class::setup */ public function testSetupRegistersTranslationInterface() { $this->_tpl->sourceDir = 'php://memory'; $this->_tpl->compileDir = 'php://memory'; Opl_Registry::register('opl_translate', null); Opl_Registry::register('opl_translate', $obj = $this->getMock('Opl_Translation_Interface')); $this->_tpl->setup(); $this->assertSame($obj, $this->_tpl->getTranslationInterface()); }
/** * Compiles a language variable. * @param string $group The group name * @param string $id The message ID name * @param int $weight The token weight * @return SplFixedArray */ public function _compileLanguageVar($group, $id, $weight) { if ($this->_tpl->getTranslationInterface() == null) { throw new Opt_NotSupported_Exception('language variable call', 'no translation interface installed'); } $array = new SplFixedArray(4); $array[0] = '$this->_tf->_(\'' . $group . '\',\'' . $id . '\')'; $array[1] = $weight; $array[2] = 'Scalar'; $array[3] = 0; return $array; }
/** * Executes, and optionally compiles the template represented by the view. * Returns true, if the template was found and successfully executed. * * @param Opt_Output_Interface $output The output interface. * @param Boolean $exception Should the exceptions be thrown if the template does not exist? * @return Boolean */ public function _parse(Opt_Output_Interface $output, $exception = true) { if ($this->_tpl->debugConsole) { $time = microtime(true); } $cached = false; if ($this->_cache !== null) { $result = $this->_cache->templateCacheStart($this); if ($result !== false) { // For dynamic cache... if (is_string($result)) { include $result; } return true; } $cached = true; } $this->_tf = $this->_tpl->getTranslationInterface(); if ($this->_tpl->compileMode != Opt_Class::CM_PERFORMANCE) { list($compileName, $compileTime) = $this->_preprocess($exception); if ($compileName === null) { return false; } } else { $compileName = $this->_convert($this->_template); $compileTime = null; if (!$exception && !file_exists($compileName)) { return false; } } $old = error_reporting($this->_tpl->errorReporting); require $this->_tpl->compileDir . $compileName; error_reporting($old); // The counter stops, if the time counting has been enabled for the debug console purposes if ($this->_cache !== null) { $this->_cache->templateCacheStop($this); } if (isset($time)) { Opt_Support::addView($this->_template, $output->getName(), $this->_processingTime = microtime(true) - $time, $cached); } return true; }