<?php namespace PMVC\PlugIn\url; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\url'; \PMVC\l(__DIR__ . '/src/UrlObject.php'); \PMVC\initPlugIn(['getenv' => null]); class url extends \PMVC\PlugIn { /** * Keep value to check now use http or https * @var string */ private $protocol = null; /** * Set env */ public function setEnv(array $arr, $overwrite = true) { $env = \PMVC\plug('getenv'); foreach ($arr as $key) { if ($overwrite || !isset($this[$key])) { $this[$key] = $env->get($key); } } } /** * Get Url */ function getUrl($url) {
<?php namespace PMVC\PlugIn\view_config_helper; // \PMVC\l(__DIR__.'/xxx.php'); ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\view_config_helper'; \PMVC\initPlugIn(['controller' => null]); class view_config_helper extends \PMVC\PlugIn { public function init() { \PMVC\callPlugin('dispatcher', 'attach', [$this, \PMVC\Event\B4_PROCESS_VIEW]); } public function onB4ProcessView() { $dot = \PMVC\plug('dotenv'); $view = \PMVC\plug('view'); $dotView = '.env.view'; if ($dot->fileExists($dotView)) { $configs = $dot->getUnderscoreToArray($dotView); } else { $configs = []; } $globalView = \PMVC\getOption('VIEW'); if ($globalView) { $configs = array_replace_recursive($configs, $globalView); \PMVC\option('set', 'VIEW', null); } $i18n = \PMVC\getOption('I18N', []); $configs = array_replace_recursive($configs, ['I18N' => $i18n]); \PMVC\option('set', 'I18N', null);
<?php namespace PMVC\PlugIn\app_action_router; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\app_action_router'; \PMVC\initPlugIn(array('url' => null, 'http' => null)); class app_action_router extends \PMVC\PlugIn\http\http implements \PMVC\RouterInterface { public function onMapRequest() { $uri = \PMVC\plug('url')->getPath(); if (empty($uri)) { return; } $uris = explode('/', $uri); $controller = \PMVC\plug('controller'); $request = $controller->getRequest(); for ($i = 0, $j = count($uris); $i < $j - 1; $i++) { $request[$i] = urldecode($uris[$i + 1]); } if (!empty($request[0])) { $controller->setApp($request[0]); } if (!empty($request[1])) { $controller->setAppAction($request[1]); } } public function init() { \PMVC\callPlugin('dispatcher', 'attach', array($this, \PMVC\Event\MAP_REQUEST)); }