public function init() { if (!empty($this['parent'])) { $this['parent'] = sys_get_temp_dir(); } $this->temp =& \PMVC\getOption('TemporaryFiles'); }
function init() { $this->setDefaultAlias(new CacheHeaderHelper()); if (!empty($this[0]) || strlen($this[0])) { \PMVC\callPlugin(\PMVC\getOption(_ROUTER), 'processHeader', [call_user_func_array([$this, 'getCacheHeader'], $this[0])]); } }
public function init() { $guid = new BigIntGuid(); $this->setDefaultAlias($guid); $this['GUID_DB'] = \PMVC\getOption('GUID_DB'); $this['private_db'] = 'guid_private_db'; }
public function onSetConfig__run_form_($subject) { $subject->detach($this); $method = \PMVC\value(\PMVC\getOption(_RUN_FORM), ['_method']); if (!empty($method)) { $this['method'] = $method; } }
function testDumpAtFinish() { \PMVC\option('set', 'v', 0); $debugStore = \PMVC\plug($this->_plug); \PMVC\d('fake'); $debugStore->onFinish(); $this->assertEquals(1, \PMVC\getOption('v')); }
public function process() { if (\PMVC\getOption(Event\FINISH) || !\PMVC\exists('dispatcher', 'plugin')) { return $this->onFinish(); } else { // only need trigger when process \PMVC\plug('dispatcher')->attachAfter($this, Event\FINISH); } }
public function unsetCli(&$json) { $cliWhiteList = [_ROUTER, _VIEW_ENGINE, _RUN_APPS]; foreach ($cliWhiteList as $key) { if (\PMVC\getOption($key)) { unset($json[$key]); } } }
public function init() { if (!isset($this['app'])) { $this['app'] = \PMVC\getOption('ALGOLIA_APP'); } if (!isset($this['key'])) { $this['key'] = \PMVC\getOption('ALGOLIA_KEY'); } }
function getNewCookieName() { if (!isset($this['user'])) { $this['user'] = \PMVC\getOption('USER'); } $date = date('Ymd'); $cookie_file = '/tmp/cookie_' . $this['user'] . '_' . $date; return $cookie_file; }
/** * @expectedException PHPUnit_Framework_Error */ function testError() { $errStr = 'error'; $err = PMVC\plug($this->_plug); $err->setErrorReporting('all'); trigger_error($errStr); $Errors =& PMVC\getOption(PMVC\ERRORS); $this->assertEquals($errStr, $Errors[PMVC\APP_LAST_ERROR]); }
public function process() { if (\PMVC\getOption(Event\FINISH) || !\PMVC\exists('dispatcher', 'plugin')) { // run directly if miss event return $this->onFinish(); } else { // only run by finish event \PMVC\plug('dispatcher')->attachAfter($this, Event\FINISH); } }
function testDump() { \PMVC\plug('debug_fake', [_CLASS => __NAMESPACE__ . '\\debug_fake']); $d = \PMVC\plug('debug', ['output' => 'debug_fake']); $d->setLevelType('hihi'); \PMVC\plug($this->_plug); \PMVC\dev(function () { return 'req'; }, 'hihi'); $actual = \PMVC\getOption('test'); $expected = ['req', 'hihi']; $this->assertEquals($expected, $actual); }
public function block() { header('WWW-Authenticate: Basic realm="' . $this->getTip() . '"'); header('HTTP/1.0 401 Unauthorized'); if (!is_null($this['callBack'])) { return call_user_func_array($this['callBack'], array()); } $view = \PMVC\plug('view'); $view->setThemeFolder(\PMVC\getOption(_TEMPLATE_DIR)); $view->setThemePath('forbidden'); $view->process(); exit; }
public function testDefaultForm() { $test_str = 'Hello World!'; $b = new PMVC\MappingBuilder(); $b->addAction('index', [_FUNCTION => function () use($test_str) { return $test_str; }, _FORM => 'myForm']); $option = [_DEFAULT_FORM => 'FakeDefaultForm']; $mvc = \PMVC\plug('controller'); \PMVC\set($mvc, $option); $result = $mvc->process($b); $this->assertEquals($test_str, $result[0]); $this->assertEquals('aaa', \PMVC\getOption('fakeDefaultForm')); }
public function get($k) { $option =& \PMVC\getOption($k); if (!is_null($option)) { return $option; } else { if (is_array($this['order'])) { foreach ($this['order'] as $get) { $plug = \PMVC\plug($get); if ($plug && $plug->has($k)) { return $plug->get($k); } } } } return $option; }
public function d() { http_response_code(\PMVC\getOption('httpResponseCode', 500)); $a = func_get_args(); if ($this->isException($a[0]) || 1 === count($a) && is_string($a[0])) { $tmp = $a[0]; } else { ob_start(); call_user_func_array('var_dump', $a); $tmp = ob_get_contents(); ob_end_clean(); } if (!$this->run) { $this->run = true; $this->dump($tmp); $this->run = false; } }
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); $view->set($configs); }
public function getAllApps() { $parent = \PMVC\getOption(); }
function stop($bool = null) { if (is_null($bool)) { return \PMVC\getOption(\PMVC\PAUSE); } else { return \PMVC\option('set', \PMVC\PAUSE, $bool); } }
<?php include_once './vendor/autoload.php'; \PMVC\Load::plug(['dotenv' => ['./.env']]); \PMVC\addPlugInFolders(['../']); $algo = \PMVC\plug('algolia'); $park = $algo->getdb('parking'); $result = $park->search('"' . \PMVC\getOption('QUERY') . '"', ['minProximity' => 1, 'minWordSizefor1Typo' => 1, 'advancedSyntax' => true, 'attributes' => 'doc.name,doc.info', 'attributesToHighlight' => 'doc.name', 'restrictSearchableAttributes' => 'doc.name', 'disableTypoToleranceOnAttributes' => 'doc.name', 'queryType' => 'prefixNone', 'distinct' => true, 'typoTolerance' => 'false', 'removeStopWords' => false]); var_dump($result);