public function __invoke($input, $deps = null) { if ($deps === null) { return Ariette::handle($this, $input); } $deps[] = $input; $deps[] = $this; return call_user_func_array($this->func, $deps); }
<?php namespace Ariette; Ariette::module('Ariette', [])->component('config', __DIR__ . '/config.php')->component('redirect', __DIR__ . '/redirect.php')->component('injector', __DIR__ . '/injector.php')->lock();
<?php namespace Ariette; Ariette::module('Ariette')->component('injector', function ($input, $inject = null) { static $inject_settings = []; // Middleware mode if (is_array($input)) { return array_merge($input, $inject_settings); } else { if (is_string($input)) { $inject_settings["\${$input}"] = $inject; } } return $inject_settings; });
public function init() { $this->init = true; Ariette::handle($this->component('__init__'), [], 'NOOP'); }
<?php namespace Ariette; Ariette::module('Ariette')->component('redirect', function ($component, $settings) { static $rules = []; // Adding rules if (is_string($component) && is_string($settings)) { $rules[$component] = $settings; } else { if (array_key_exists($component['$path'], $rules)) { $component['$path'] = $rules[$component['$path']]; $c = json_decode(Pt::run($component), true); $c['$short'] = true; return $c; } else { return $component; } } });
<?php namespace Ariette; Ariette::module('Ariette')->component('config', function ($component = null, $settings = null) { static $config_settings = []; // If not being used as middleware if (is_string($component) && $settings !== null) { if (!array_key_exists($component, $config_settings)) { $config_settings[$component] = []; } $config_settings[$component] = array_merge($config_settings[$component], $settings); } else { if ($settings === null && is_string($component)) { if (array_key_exists($component, $config_settings)) { return $config_settings[$component]; } else { return []; } } else { if ($component !== null && isset($settings)) { if (array_key_exists('$path', $component)) { if (array_key_exists($component['$path'], $config_settings)) { $component['$config'] = $config_settings[$component['$path']]; } else { $component['$config'] = []; } } return $component; } }
if (!defined('ARIETTE_REQUIRE_IT')) { switch (ini_get('ARIETTE_REQUIRE_IT')) { case false: case 'require': define('ARIETTE_REQUIRE_IT', true); break; default: define('ARIETTE_REQUIRE_IT', false); } } if (!defined('ARIETTE_REQUIRE_NONE')) { switch (ini_get('ARIETTE_REQUIRE_NONE')) { case false: define('ARIETTE_REQUIRE_NONE', false); break; default: define('ARIETTE_REQUIRE_NONE', true); } } if (!constant('ARIETTE_REQUIRE_NONE')) { require __DIR__ . "/ArietteException.php"; require __DIR__ . "/Component.php"; require __DIR__ . "/Module.php"; require __DIR__ . "/Ariette.php"; if (constant('ARIETTE_REQUIRE_CORE')) { Ariette::module('Ariette', __DIR__ . '/../core/Ariette.php'); } if (constant('ARIETTE_REQUIRE_IT')) { require __DIR__ . '/../it/bootstrap.php'; } }