public function testAlias()
 {
     $container = new \League\Container\Container();
     $container->add('config', ['directions' => ['default' => []]]);
     $container->addServiceProvider('Laasti\\Directions\\Providers\\LeagueDirectionsProvider');
     $this->assertInstanceOf('Laasti\\Directions\\Router', $container->get('directions.routers.default'));
     $this->assertInstanceOf('Laasti\\Directions\\Router', $container->get('Laasti\\Directions\\RouterInterface'));
 }
 /**
  * Построение join-ов
  * 
  * @todo добавить типы связей 
  * has_many - один к многим (пост и коммеентарии)
  * belongs_to - многие к многим (пользователь имет множество оплат одного заказа)
  * has_one - один к одному
  */
 protected function setRelations(ISpecificationCriteria $Specification)
 {
     $joins = [];
     foreach ($this->mapping_fields as $field => $cfg) {
         if (isset($cfg['relation'])) {
             $reltype = isset($cfg['reltype']) ? $cfg['reltype'] : 'belongs_to';
             $this->relations[$field] = ['mapper' => $mapper = $this->DI->get($cfg['relation']), 'reltype' => $reltype];
             $table = $mapper->getEntityTable();
             $relation_key = isset($cfg['on']) ? $cfg['on'] : $mapper->key;
             $joins[$table] = ['alias' => $field, 'type' => $reltype != 'has_many' ? 'INNER' : 'LEFT OUTER', 'on' => "`{$this->table}`.{$cfg['field']} = `{$field}`.{$relation_key}"];
         }
     }
     if ($this->use_joins === true) {
         $Specification->setJoins($joins);
     }
 }
<?php

$container = new League\Container\Container();
$container->singleton('A');
//trigger all autoloaders
$b = $container->get('B');
unset($b);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $a = $container->get('B');
}
$t2 = microtime(true);
$results = ['time' => $t2 - $t1, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);
<?php

$container = new League\Container\Container();
$container->singleton('A');
//trigger all autoloaders
$a = $container->get('A');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $a = $container->get('A');
}
$t2 = microtime(true);
$results = ['time' => $t2 - $t1, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);
<?php

//Trigger all autoloaders
$container = new League\Container\Container();
$a = $container->get('J');
unset($a);
$t1 = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $a = $container->get('J');
}
$t2 = microtime(true);
$results = ['time' => $t2 - $t1, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);
Beispiel #6
0
/**
 * Set DI container
 */
$jets_container = new League\Container\Container();
/**
 * Register theme config
 */
$jets_container->share('config', function () {
    $path = __DIR__ . '/config/config.yaml';
    return new \Jets\Config($path);
});
/**
 * Register assets enqueuer
 */
$jets_container->share('enqueuer', function () use($jets_container) {
    $config = $jets_container->get('config');
    return new \Jets\Enqueuer($config);
});
/**
 * Register menus manager
 */
$jets_container->share('menus', function () use($jets_container) {
    $config = $jets_container->get('config');
    return new \Jets\Menu_Helper($config);
});
/**
 * Register sidebars manager
 */
$jets_container->share('sidebars', function () use($jets_container) {
    $config = $jets_container->get('config');
    return new \Jets\Sidebar_Helper($config);
<?php

$container = new League\Container\Container();
for ($i = 0; $i < $argv[1]; $i++) {
    $j = $container->get('J');
}
$results = ['time' => 0, 'files' => count(get_included_files()), 'memory' => memory_get_peak_usage() / 1024 / 1024];
echo json_encode($results);