/** * Check for imports in the document and process them. * Converts imported xml into ACL and passes back to this builder. * * This is recursive so the end result is that we do a depth first leaf node * construction of the ACL * * @param string $basePath Path to directory of parent file */ protected function processImports($basePath) { $xpath = new \DOMXPath($this->xml); $xpath->registerNamespace('acl', self::NS); $importNodes = $xpath->query('//acl:acl/acl:imports/acl:import'); if ($importNodes->length == 0) { return; } foreach ($importNodes as $iNode) { $importName = $iNode->nodeValue; if (dirname($importName) == '.') { //assume it is in same directory as the parent file $importName = "{$basePath}/{$importName}"; } elseif (strstr($importName, '..') == 0) { //it is relative to parent file directory $file = basename($importName); $dir = realpath($basePath . '/' . dirname($importName)); $importName = "{$dir}/{$file}"; } $builder = new self(new StringType($importName), $this->acl); if ($builder->build()) { $result = $builder->getResult(); $this->acl = $result['acl']; } } }
/** * Standard factory method to instantiate a populated object. * * @param BaseDataObject $object The object being rendered * @param $urlType The type of URL connection * @param array $attributes HTML tag attributes * @return mixed */ public static function factory(RendererInterface $renderer, BaseDataObject $object, $urlType, array $attributes = array()) { $htmlRenderer = new self(); $htmlRenderer->setRenderer($renderer); $htmlRenderer->setObject($object); $htmlRenderer->setUrlType($urlType); $htmlRenderer->setAttributes($attributes); return $htmlRenderer->build(); }
public static function render($position) { $self = new self(); $items = $self->build($position); $render = ''; foreach ($items as $item) { $render .= $item->render(); } return $render; }
public static function buildSchema($schema, $dsn = null, $user = null, $pass = null, $adapter = null) { $builder = new self(); $builder->setSchema($schema); return $builder->build($dsn, $user, $pass, $adapter); }
/** * Build a source Less file to a Css destination file * * @param string $source The Less source filename * @param string $dest The destination CSS file * @param bool $force If set to true, will build whereas the cache status * @param array $variables Less variables to set before compiling the Less file */ public static function compile($source, $dest, $force = false, $variables = array()) { if (!is_file($dest)) { $force = true; } $less = new self($source); $less->build($dest, $force, $variables); }
/** * Build a container configured for the dev environment. * * @return Container */ public static function buildDevContainer() { $builder = new self(); return $builder->build(); }
/** * Load a language file * * @param string $plugin The plugin to load * @param string $language The language to get the translations in * @param string $force If set to true, force to reload the translations */ private static function load($plugin, $language = LANGUAGE, $force = false) { if (!isset(self::$keys[$plugin][$language]) || $force || $language !== self::$usedLanguage) { App::logger()->debug('Reload keys for plugin ' . $plugin . ' and for language ' . $language); self::$keys[$plugin][$language] = array(); $instance = new self($plugin, self::DEFAULT_LANGUAGE); $instance->build(); self::$keys[$plugin][$language] = App::cache()->includeCache($instance->cacheFile); if ($language !== self::DEFAULT_LANGUAGE) { $instance = new self($plugin, $language); $instance->build(); $translations = App::cache()->includeCache($instance->cacheFile); if (!is_array($translations)) { $translations = array(); } self::$keys[$plugin][$language] = array_merge(self::$keys[$plugin][$language], $translations); } self::$usedLanguage = $language; } }
private function importItem(SiteDocIndexItem $rootIndex, SimpleXMLElement $node) { switch ($node->getName()) { case "doc": $item = new SiteDocIndexXmlItem($this->absolutizeXmlPath((string) $node['xml']), $this->getHtmlUri($this->absolutizeLocation(isset($node['location']) ? (string) $node['location'] : (string) $node['xml'])), $rootIndex, isset($node['site-part']) ? new SitePart((string) $node['site-part']) : null); break; case "ref": $item = new SiteDocIndexRefItem((string) $node['name'], $this->absolutizeLocation((string) $node['link']), $rootIndex, isset($node['site-part']) ? new SitePart($node['site-part']) : null); break; case "include": $worker = new self($this->absolutizeXmlPath((string) $node['xml']), $this->absolutizeLocation((string) $node['prefix']), $rootIndex); $worker->xmlRoot = $this->xmlRoot; $worker->build(); return; default: Assert::isUnreachable('unknown item %s', $node->getName()); } $this->traverse($item, $node); }
/** * create a new builder and build it. * @param string $rssVersion * @param string $encoding * @return \Hyancat\Larss\RssBuilder */ public static function create($rssVersion = '2.0', $encoding = 'UTF-8') { $builder = new self($rssVersion, $encoding); return $builder->build(); }