public static function buildContainer($rootPath) { $container = new self(); $container->addCompilerPass(new RouterTagCompilerPass()); $container->setProxyInstantiator(new RuntimeInstantiator()); $container->setParameter('app_root', $rootPath); $loader = new YamlFileLoader($container, new FileLocator($rootPath . '/config')); $loader->load('services.yml'); $container->compile(); return $container; }
/** * Parses a template file and declares view variables in this scope for the * template to have access to them. Loads localized templates based on the current * active locale. * @param string The name of the template to load * @param array an associative array of values to assign in the template * @param string The file extension of the template to be loaded * @return string The parsed html. */ public static function parse($path, $variables = array(), $extension = '.php', $allowDebug = true) { $tpl = new self(); $tpl->injectVariables($variables); $tpl->setViewName($path); $tpl->setConfig("file_extention", $extension); if (!(bool) $tpl->getConfig("allow_debug")) { $tpl->setConfig("allow_debug", false); } else { $tpl->setConfig("allow_debug", $allowDebug); } return $tpl->compile(); }
/** * Compiles the node. * * @param Context $context The context * @param array|null $arguments Array of arguments * @param bool|null $important Important flag * * @return Node * * @throws CompilerException */ public function compile(Context $context, $arguments = null, $important = null) { $name = $this->name; if (strpos($name, '@@') === 0) { $v = new self(substr($name, 1), $this->index, $this->currentFileInfo); $name = '@' . $v->compile($context)->value; } if ($this->evaluating) { throw new CompilerException(sprintf('Recursive variable definition for %s', $name), $this->index, $this->currentFileInfo); } $this->evaluating = true; $variable = null; // variables from the API take precedence if ($context->customVariables && ($v = $context->customVariables->variable($name))) { $variable = $v->value->compile($context); } else { // search for the variable foreach ($context->frames as $frame) { /* @var $frame RulesetNode */ if ($v = $frame->variable($name)) { /* @var $v RuleNode */ if ($v->important) { $importantScope =& $context->importantScope[count($context->importantScope) - 1]; $importantScope['important'] = $v->important; } $variable = $v->value->compile($context); break; } } } if ($variable) { $this->evaluating = false; return $variable; } else { throw new CompilerException(sprintf('variable %s is undefined', $name), $this->index, $this->currentFileInfo); } }
/** * Calculates and returns the height of rows, added by the page break callback. * @return int */ private function _getPageBreakCallbackHeight() { if ($this->pageBreakCallbackHeight !== null) { return $this->pageBreakCallbackHeight; } $table = $this->getTable(); if (!($callback = $table->getPageBreakCallback())) { return $this->pageBreakCallbackHeight = 0; } $table->setRows(array()); $callback($table); $numberOfNewRows = count($table->getRows()); $this->pageBreakCallbackHeight = 0; if ($numberOfNewRows > 0) { $converter = new self($table, $this->cacheDir); $converter->compile(); // merge row heights foreach ($converter->_getRowHeights() as $height) { $this->pageBreakCallbackHeight += $height; } } return $this->pageBreakCallbackHeight; }
/** * Listens to the routing.load_configuration event. Finds & compiles LESS files to CSS * * @param sfEvent $event an sfEvent instance */ public static function findAndCompile(sfEvent $event) { // Start compilation timer for debug info $timer = sfTimerManager::getTimer('Less compilation'); // Create new helper object & compile LESS stylesheets with it $lessHelper = new self(); foreach (self::findLessFiles() as $lessFile) { $lessHelper->compile($lessFile); } // Stop timer $timer->addTime(); }
/** * static version which does new, compile and output all in one go. * * See outputObject($t) for more details. * * @version 01/12/14 * @access public * @param object object to output as $t * @param filename of template * @return string - result */ public static function &staticQuickTemplate($file, &$t) { $template = new self(); $template->compile($file); $template->outputObject($t); }