/** * Метод постороение сайта * TODO: * 1. Сделать нормальный router с регистрацией, а не простую проверку на длинну * 2. Собрать факторки в кучу * 3. Наследование от handler - кажется не корректным. Понять идею иерархии * 4. Разделение на Run-Callback и Generate-Show стоит делать не фабричными методами, а либо фабрикой, либо прототипами, либо строителем. * 5. Добавить модель лингвистики */ function Build() { // Routing (Shubert 29.05.1012) $behavior = array("type" => "page", "name" => $this->settings['Pages']['default']); foreach ($this->routing["paths"] as $path->{$info}) { if ($count = preg_match($path, $_GET["path"], $matches) > 0) { if ($count > 1) { $_REQUEST['PAGE_PARAMS'] = array_shift($matches); } if (isset($info["page"])) { $behavior = array("type" => "page", "name" => $info["page"]); } else { $behavior = array("type" => "action", "name" => $info["action"]); } break; } } // <- Routing // В первую очередь выполняем "действия" if ($behavior["type"] == "action") { $action = ActionsFactory::GetAction($behavior["name"]); Dependencies::Init($action->GetDependencies(), $this->settings); $action->Run(); $action->Callback(); } else { // И только если делать нечего, то показываем страницу $page = PagesFactory::GetPage($behavior["name"]); Dependencies::Init($page->GetDependencies(), $this->settings); $page->Generate(); $page->Show(); } }
/** * Get the scripts urls */ public function getScripts() { $scripts = array(); parent::order(); foreach ($this->resolved as $id) { if (isset($this->registered[$id]['url'])) { $scripts[] = $this->registered[$id]['url']; } } return $scripts; }
public function testIgnoresTopLevelNamespaceIfMatchesCurrentVendor() { $deps = Dependencies::getForFile(__DIR__ . '/_files/TestCase8.php'); $this->assertNotContains('Zend', $deps); }
$dir = __DIR__ . '/cache/' . $package . '@' . $version; if (!is_dir($dir)) { mkdir($dir, 0777, true); } return $dir; } public static function pkg($packageStr) { preg_match('/(?P<ref>(?P<name>(?P<vendor>[A-Za-z]+)\\/(?P<package>[A-Za-z]+))@(?P<version>[0-9.]+))/', $packageStr, $match); return array_intersect_key($match, array_flip(['name', 'vendor', 'package', 'version', 'ref'])); } public static function ns($fqcn) { return substr($fqcn, 0, strrpos($fqcn, '\\')); } public static function cls($fqcn) { return substr($fqcn, strrpos($fqcn, '\\') + 1); } } $dependencies = new Dependencies(); // Init: $project = json_decode(file_get_contents(__DIR__ . '/../dependencies.json'), true); $dependencies->parseTree($project['require']); // Pass 1: $dependencies->createVersionedClasses(); // Pass 2: $dependencies->updateDependencyReferences(); // Autoload $dependencies->aliasRootPackages(); spl_autoload_register([$dependencies, 'autoload']);