<?php /** * Created by PhpStorm. * User: Roman * Date: 28.07.2015 * Time: 9:30 */ use app\core\cache\TempFileProvider; use app\core\etc\Settings; use app\core\injector\Injector; use app\libs\WaveformGenerator; Injector::run(function (Settings $settings) { WaveformGenerator::setCommand($settings->get("tools", "ffmpeg_cmd")); TempFileProvider::setTempPath($settings->get("fs", "temp")); });
function resource($class_name) { return Injector::getInstance()->injectByClassName($class_name); }
public function run() { $handler = $this->find()->getOrThrow(PageNotFoundException::class); RouteArgs::getInstance()->setMapData($handler["args"]); if (is_string($handler["action"])) { if (!class_exists($handler["action"])) { throw new PageNotFoundException(); } $instance = new $handler["action"](); if (!$instance instanceof RouteHandler) { throw new WrongRouteHandlerException(); } $method = "do" . ucfirst(strtolower($_SERVER["REQUEST_METHOD"])); if (!method_exists($instance, $method)) { throw new NotImplementedException(); } Injector::run(array($instance, $method)); } else { if (is_callable($handler["action"])) { Injector::run($handler["action"]); } else { throw new ApplicationException("Invalid action handler!"); } } }