Beispiel #1
0
 public function push($message, $type = Log::TYPE_MESSAGE)
 {
     if (is_array($message)) {
         $message_value = array_pop($message);
         $message_key = $message;
     } else {
         $message_value = $message;
         $message_key = null;
     }
     $this->storage->set($message_key, $message_value);
     return $this;
 }
Beispiel #2
0
 /**
  * @return Storage
  */
 protected function getStorage()
 {
     if (null === $this->storage) {
         $this->storage = Storage::getInstance($this->settings->storage);
     }
     return $this->storage;
 }
Beispiel #3
0
 /**
  * @param Settings|null $dsn
  * @throws Exception
  * @throws \Yaoi\Service\Exception
  */
 public function __construct(Settings $dsn = null)
 {
     $this->settings = $dsn ? $dsn : Storage::createSettings();
     if (empty($dsn->proxyClient)) {
         throw new Exception('proxyClient required in dsn', Exception::PROXY_REQUIRED);
     }
     $this->storage = Storage::getInstance($this->settings->proxyClient);
 }
Beispiel #4
0
    public function render()
    {
        $isDev = Auth::getInstance('dev')->isProvidedDemandOnWrong();
        ?>
<html>
<head>
    <title><?php 
        echo $this->title;
        ?>
</title>
    <link rel="stylesheet" type="text/css" href="/css/style.css" />
    <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
    <link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" />
    <script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script>
    <script src="/js/tag-filter.js"></script>

</head>
<body>
<div class="list">
    <?php 
        echo $this->list;
        ?>
</div>

<div class="filters">
    <?php 
        echo $this->filters;
        ?>
</div>

<div class="main">
    <?php 
        echo $this->main;
        ?>
</div>

<?php 
        if ($isDev) {
            ?>
<div class="dev-debug">
    <a href="/dev?logout">Logout debug mode</a>
    <?php 
            $debugStorage = Storage::getInstance('debug_log');
            $debugStorage->set('_SERVER', $_SERVER);
            CollapsiblePrintR::create($debugStorage->exportArray())->render();
            ?>
</div><?php 
        }
        ?>

</body>
</html>
<?php 
    }
Beispiel #5
0
<?php

namespace PHPerf;

use Yaoi\Database;
use Yaoi\Http\Auth;
use Yaoi\Http\Auth\Settings;
use Yaoi\Log;
use Yaoi\Storage;
date_default_timezone_set('Europe/Moscow');
header("Content-Type: text/html; charset=utf8");
error_reporting(E_ALL);
ini_set('display_errors', 'on');
umask('0002');
Auth::register(function () {
    $dsn = new Settings();
    $dsn->title = 'Developers Only Area';
    $dsn->salt = '<random-string>';
    $dsn->users = array('<login>' => '<password-hash>');
    return $dsn;
}, 'dev');
Storage::register(new Storage\PhpVar(), 'debug_log');
Log::register('storage:///?storage=debug_log', 'debug_log');
Database::register(function () {
    $database = new Database('mysqli://root@localhost/phperf_result');
    $database->log(Log::getInstance('debug_log'));
    return $database;
});
Beispiel #6
0
date_default_timezone_set('Asia/Bangkok');
//Storage::getInstance('mock')->deleteAll();
Client::register(function () {
    $settings = new Settings();
    $settings->username = '******';
    $settings->password = '******';
    return $settings;
});
Http\Client::register(function () {
    $client = new Http\Client();
    $client->mock(new Mock(Storage::getInstance('mock')));
    return $client;
});
Storage::register(function () {
    $settings = new Storage\Settings();
    $settings->driverClassName = Storage\Driver\SerializedFile::className();
    $settings->path = __DIR__ . '/resources/mock4.serialized';
    return $settings;
}, 'mock');
Database::register('mysqli://root:@localhost/wakabot?timezone=Asia/Jakarta');
/*
Database::register(function(){
    $settings = new Database\Settings();
    $settings->driverClassName = Database\Driver\Sqlite::className();
    $settings->path = __DIR__ . '/resources/db.sqlite';
    return $settings;
}, 'sqlite');
*/
Migration\Manager::register(function () {
    $settings = new Migration\Settings();
    $settings->storage = new Storage('serialized-file:///' . __DIR__ . '/resources/migration.serialized');
    $settings->run = function () {
Beispiel #7
0
 /**
  * @return static
  */
 public function branch()
 {
     $key = func_get_args();
     if (!$key) {
         return $this;
     }
     if (null === $this->branches) {
         $this->branches = new PhpVar();
     }
     if (!($mock = $this->branches->get($key))) {
         $mock = new static($this->storage);
         $mock->mode = $this->mode;
         $mock->isEmptyBranch = true;
         $mock->branchKey = array_merge($this->branchKey, $key);
         $this->branches->set($key, $mock);
     }
     return $mock;
 }
Beispiel #8
0
 static function cache($identifier = Service::PRIMARY)
 {
     return Storage::getInstance($identifier);
 }
Beispiel #9
0
 public function __construct()
 {
     $settings = self::createSettings();
     $settings->driverClassName = Driver\PhpVar::className();
     parent::__construct($settings);
 }