Ejemplo n.º 1
0
 public function init()
 {
     if (!empty($this['parent'])) {
         $this['parent'] = sys_get_temp_dir();
     }
     $this->temp =& \PMVC\getOption('TemporaryFiles');
 }
Ejemplo n.º 2
0
 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])]);
     }
 }
Ejemplo n.º 3
0
 public function init()
 {
     $guid = new BigIntGuid();
     $this->setDefaultAlias($guid);
     $this['GUID_DB'] = \PMVC\getOption('GUID_DB');
     $this['private_db'] = 'guid_private_db';
 }
Ejemplo n.º 4
0
 public function onSetConfig__run_form_($subject)
 {
     $subject->detach($this);
     $method = \PMVC\value(\PMVC\getOption(_RUN_FORM), ['_method']);
     if (!empty($method)) {
         $this['method'] = $method;
     }
 }
Ejemplo n.º 5
0
 function testDumpAtFinish()
 {
     \PMVC\option('set', 'v', 0);
     $debugStore = \PMVC\plug($this->_plug);
     \PMVC\d('fake');
     $debugStore->onFinish();
     $this->assertEquals(1, \PMVC\getOption('v'));
 }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
 public function unsetCli(&$json)
 {
     $cliWhiteList = [_ROUTER, _VIEW_ENGINE, _RUN_APPS];
     foreach ($cliWhiteList as $key) {
         if (\PMVC\getOption($key)) {
             unset($json[$key]);
         }
     }
 }
Ejemplo n.º 8
0
 public function init()
 {
     if (!isset($this['app'])) {
         $this['app'] = \PMVC\getOption('ALGOLIA_APP');
     }
     if (!isset($this['key'])) {
         $this['key'] = \PMVC\getOption('ALGOLIA_KEY');
     }
 }
Ejemplo n.º 9
0
 function getNewCookieName()
 {
     if (!isset($this['user'])) {
         $this['user'] = \PMVC\getOption('USER');
     }
     $date = date('Ymd');
     $cookie_file = '/tmp/cookie_' . $this['user'] . '_' . $date;
     return $cookie_file;
 }
Ejemplo n.º 10
0
 /**
  * @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]);
 }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
 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);
 }
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
 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'));
 }
Ejemplo n.º 15
0
 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;
 }
Ejemplo n.º 16
0
 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);
 }
Ejemplo n.º 18
0
 public function getAllApps()
 {
     $parent = \PMVC\getOption();
 }
Ejemplo n.º 19
0
 function stop($bool = null)
 {
     if (is_null($bool)) {
         return \PMVC\getOption(\PMVC\PAUSE);
     } else {
         return \PMVC\option('set', \PMVC\PAUSE, $bool);
     }
 }
Ejemplo n.º 20
0
<?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);