function static_class_init($class_name) { if (class_exists($class_name) && method_exists($class_name, STATIC_CLASS_INIT_METHOD)) { $ref = new ReflectionMethod($class_name, STATIC_CLASS_INIT_METHOD); if ($ref->isStatic()) { Injector::run($ref); } } }
<?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")); });
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!"); } } }