/** * Helper to get instance of AutoloadBuilder with cli options applied * * @throws \RuntimeException * @return \TheSeer\Autoload\AutoloadBuilder|\TheSeer\Autoload\StaticBuilder */ public function getBuilder(ClassFinder $finder) { $isStatic = $this->config->isStaticMode(); $isPhar = $this->config->isPharMode(); $isCompat = $this->config->isCompatMode(); $noLower = !$this->config->isLowercaseMode(); $isOnce = $this->config->isOnceMode(); $tplType = $noLower ? 'cs' : 'ci'; if ($isStatic === TRUE) { $builder = new StaticBuilder($finder->getMerged()); $builder->setDependencies($finder->getDependencies()); $builder->setPharMode($isPhar); $builder->setRequireOnce($isOnce); } else { $builder = new AutoloadBuilder($finder->getMerged()); } $builder->setCompat($isCompat); $basedir = $this->config->getBaseDirectory(); if (!$basedir || !is_dir($basedir)) { throw new \RuntimeException("Given basedir '{$basedir}' does not exist or is not a directory"); } $builder->setBaseDir($basedir); $template = $this->config->getTemplate(); if ($template !== NULL) { if (!file_exists($template)) { $alternative = __DIR__ . '/templates/' . $tplType . '/' . $template; if (file_exists($alternative)) { $template = $alternative; } } $builder->setTemplateFile($template); } else { // determine auto template to use $tplFile = 'default.php.tpl'; if ($isCompat) { $tplFile = 'php52.php.tpl'; } if ($isPhar) { if ($isStatic) { $tplFile = 'staticphar.php.tpl'; } else { $tplFile = 'phar.php.tpl'; } } elseif ($isStatic) { $tplFile = 'static.php.tpl'; $tplType = '.'; } $builder->setTemplateFile(__DIR__ . '/templates/' . $tplType . '/' . $tplFile); } $format = $this->config->getDateFormat(); if ($format) { $builder->setDateTimeFormat($format); } $builder->setIndent($this->config->getIndent()); $builder->setLineBreak($this->config->getLinebreak()); foreach ($this->config->getVariables() as $name => $value) { $builder->setVariable($name, $value); } return $builder; }
function __construct($config) { $registry = new registry(); new Autoloader($registry); $registry->configFile = $this->getConfig($config); $configData = new Config($registry); $registry->siteUrl = $configData->getSitepath(); $registry->appDir = $configData->getAppPath(); $registry->appNamespace = $configData->getAppNamespace(); $registry->menu = $configData->getMenuData(); $registry->defaultController = $configData->getDefaultController(); $registry->template = $configData->getTemplate(); $registry->dispatcher = new Dispatcher($registry); $registry->view = new View($registry); $registry->dispatcher->load(); }