예제 #1
0
 /**
  * @throws TestCaseException
  */
 public static function execute()
 {
     BootstrapManager::listener(function (StartupEvent $startupEvent) {
         $startupEvent->getContext()->create(static::class)->run();
     });
     BootstrapManager::bootstrap();
 }
예제 #2
0
<?php

namespace Edde\Ext\Neon;

use Edde\Api\EventBus\IEventBus;
use Edde\Api\Resource\IResourceHandlerManager;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\BootEvent;
use Edde\Runtime\Context\Event\FactoryEvent;
BootstrapManager::listener(function (BootEvent $bootEvent) {
    $context = $bootEvent->getContext();
    $context->create(IEventBus::class)->listener(function (FactoryEvent $factoryEvent) {
        switch ($factoryEvent->getName()) {
            case IResourceHandlerManager::class:
                $factoryEvent->getInstance()->registerResourceHandler(new NeonResourceHandler());
                break;
        }
    });
});
예제 #3
0
 * Edde is self-hosted; it is proof-of-concept or it can be used as tutorial. Many experimental features
 * are implemented here.
 */
use Edde\Api\Application\IApplication;
use Edde\Ext\Neon\NeonFile;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\ConfigurationEvent;
use Edde\Runtime\Bootstrap\Event\SetupEvent;
use Edde\Runtime\Bootstrap\Event\StartupEvent;
use Tracy\Debugger;
require_once __DIR__ . '/../lib/tracy.phar';
require_once __DIR__ . '/../../src/loader.php';
BootstrapManager::bootstrap(function (ConfigurationEvent $configurationEvent) {
    $configurationEvent->getConfiguration()->addResource(new NeonFile(__DIR__ . '/../config/config.neon'))->addResource(new NeonFile(__DIR__ . '/../config/config.local.neon'), false);
}, function (SetupEvent $setupEvent) {
    $configuration = $setupEvent->getConfiguration();
    if ($configuration->isDevelMode()) {
        Debugger::enable(Debugger::DEVELOPMENT, $configuration->getDir('log'));
        Debugger::$strictMode = true;
        Debugger::$maxDepth = 12;
        Debugger::$maxLen = 8196;
    }
}, function (StartupEvent $startupEvent) {
    /**
     * optional - create (by default Edde's implementation) IApplication and run it; it holds whole life-cycle
     */
    $startupEvent->getContext()->create(IApplication::class)->run();
});
/**
 * and thats all; look around, there is many things to explore :)
 */
예제 #4
0
namespace Edde\Runtime\Context;

use Edde\Api\Context\IContext;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\BootEvent;
use Edde\Runtime\Bootstrap\Event\SetupEvent;
use Edde\Runtime\Context\Factory\FactoryFactory;
use Edde\Runtime\Context\Factory\ReflectionFactory;
use Edde\Runtime\Context\Factory\SingletonFactory;
BootstrapManager::listener(function (BootEvent $bootEvent) {
    $context = $bootEvent->getContext();
    $context->register(new SingletonFactory($context, IContext::class));
}, function (SetupEvent $setupEvent) {
    $configuration = $setupEvent->getConfiguration();
    foreach ($configuration->query('[]php') as $k => $v) {
        ini_set($k, $v);
    }
    $context = $setupEvent->getContext();
    foreach ($configuration->query('[]' . Context::class . '/register') as $name => $class) {
        $context->register(new ReflectionFactory($class, $name));
    }
    foreach ($configuration->query('[]' . Context::class . '/factory') as $name => $factory) {
        if (strpos($factory, '@') !== false) {
            list($class, $method) = explode('::', ltrim($factory, '@'));
            $factory = function () use($context, $class, $method) {
                return $context->invoke($class, $method);
            };
        }
        $context->register(new FactoryFactory($factory, $name));
    }
});
예제 #5
0
<?php

namespace test;

use Edde\Ext\Neon\NeonFile;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\ConfigurationEvent;
require_once __DIR__ . '/../Tester/bootstrap.php';
require_once __DIR__ . '/../../src/loader.php';
require_once __DIR__ . '/common/AbstractTestCase.php';
BootstrapManager::listener(function (ConfigurationEvent $configurationEvent) {
    $configurationEvent->getConfiguration()->addResource(new NeonFile(__DIR__ . '/../config.neon'));
});
예제 #6
0
<?php

namespace Edde\Ext\Config;

use Edde\Api\Config\ICompiler;
use Edde\Api\Config\ICompilerExtension;
use Edde\Api\EventBus\IEventBus;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\BootEvent;
use Edde\Runtime\Context\Event\FactoryEvent;
use Edde\Runtime\Context\Factory\ReflectionFactory;
BootstrapManager::listener(function (BootEvent $bootEvent) {
    $context = $bootEvent->getContext();
    $context->register(new ReflectionFactory(CompilerExtension::class, ICompilerExtension::class));
    $context->create(IEventBus::class)->listener(function (FactoryEvent $factoryEvent) use($context) {
        switch ($factoryEvent->getName()) {
            case ICompiler::class:
                $factoryEvent->getInstance()->addCompilerExtension($context->create(ICompilerExtension::class));
                break;
        }
    });
});
예제 #7
0
<?php

namespace Edde\Runtime\Config;

use Edde\Api\Config\ICompiler;
use Edde\Runtime\Bootstrap\BootstrapManager;
use Edde\Runtime\Bootstrap\Event\BootEvent;
use Edde\Runtime\Context\Factory\ReflectionFactory;
BootstrapManager::listener(function (BootEvent $bootEvent) {
    $context = $bootEvent->getContext();
    $context->register(new ReflectionFactory(Compiler::class, ICompiler::class));
});