function testApp() { \PMVC\initPlugin(['controller' => null, 'dispatcher' => null, 'error' => null, 'debug' => null, 'dotenv' => ['.env.sample'], 'app_action_router' => null]); $controller = \PMVC\plug('controller', [_RUN_APPS => 'apps', 'NODE' => 'vendor/bin/node', _TEMPLATE_DIR => 'vendor/pmvc-theme/hello_react']); if ($controller->plugApp()) { ob_start(); $controller->process(); $output = ob_get_contents(); ob_end_clean(); } $this->assertContains('data-reactid', $output); }
<?php namespace PMVC\PlugIn\algolia; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\algolia'; \PMVC\initPlugin(['guid' => null]); \PMVC\l(__DIR__ . '/src/BaseAlgolia.php'); /** * @parameters string app * @parameters string key */ class algolia extends \IdOfThings\GetDb { public function init() { if (!isset($this['app'])) { $this['app'] = \PMVC\getOption('ALGOLIA_APP'); } if (!isset($this['key'])) { $this['key'] = \PMVC\getOption('ALGOLIA_KEY'); } } public function getBaseDb() { return __NAMESPACE__ . '\\BaseAlgolia'; } public function getNameSpace() { return __NAMESPACE__; } public function getBaseUrl()
<?php namespace PMVC\PlugIn\http; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\http'; \PMVC\initPlugin(['controller' => null]); class http extends \PMVC\PlugIn implements \PMVC\RouterInterface { public function init() { $controller = \PMVC\plug('controller'); if (empty($controller)) { return !trigger_error('Need initial controller first', E_USER_WARNING); } $request = $controller->getRequest(); $method = $this->getMethod(); $request->setMethod($method); if ('GET' === $method) { $inputs =& $_GET; } else { $isJsonInput = 'application/json' === getenv('CONTENT_TYPE'); if ($isJsonInput || 'PUT' === $method) { $input = file_get_contents("php://input"); if ($isJsonInput) { $inputs = (array) \PMVC\fromJson($input); } else { parse_str($input, $inputs); } } else { $inputs =& $_POST; }
<?php namespace PMVC\PlugIn\yo_swagger; use PMVC\PlugIn\swagger; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\yo_swagger'; \PMVC\initPlugin(array('swagger' => null)); class yo_swagger extends swagger\swagger { public function init() { $this->swagger = \PMVC\plug('swagger')->get(); } public function fromYo($yo) { $routes = $yo->getRoutes(); return $this->getSpec($routes); } public function fromMapping($mappings) { $actions = $mappings->addByKey(\PMVC\ACTION_MAPPINGS); $routes = []; $c = \PMVC\plug('controller'); foreach ($actions as $key => $action) { $routes[] = ['uri' => $key, 'action' => $c->getActionCall($mappings->findMapping($key)), 'method' => 'get']; } return $this->getSpec($routes); } public function getSpec($routes) { $annotation = \PMVC\plug('annotation');
<?php namespace PMVC\PlugIn\minions; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\minions'; \PMVC\initPlugin(array('curl' => null)); class minions extends \PMVC\PlugIn\curl\curl { private $queue = array(); const options = 'options'; const callback = 'callback'; const hosts = 'hosts'; const curl = 'curl'; const delay = 'delay'; function process($more = null) { $curls = $this->getCurls(); if (!empty($curls) && \PMVC\isArray($curls)) { foreach ($curls as $curl) { $this->queue[] = array(self::options => $curl->set(), self::callback => $curl->getCallback()); $curl->clean(); } $this->clean(); } $curlPlug = \PMVC\plug(self::curl); while (count($this->queue)) { if (empty($this[self::hosts]) || !is_array($this[self::hosts])) { break; } foreach ($this[self::hosts] as $host) { $pop = array_pop($this->queue);
<?php namespace PMVC\PlugIn\getenv; use PMVC\PlugIn\get\GetInterface; ${_INIT_CONFIG}[_CLASS] = __NAMESPACE__ . '\\getenv'; \PMVC\initPlugin(['get' => null]); /** * @parameters bool isDev */ class getenv extends \PMVC\PlugIn implements GetInterface { public function get($k) { if ($this['isDev'] && \PMVC\value($_REQUEST, ['--' . $k])) { return $_REQUEST['--' . $k]; } elseif (isset($this[$k])) { if (is_callable($this[$k])) { $isCache = false; $v = $this[$k]($isCache, $k, $this); if ($isCache) { $this[$k] = $v; } return $v; } else { return $this[$k]; } } else { return \PMVC\value($_SERVER, [$k]); } }