Пример #1
0
<?php

//autoload
require_once __DIR__ . '/../vendor/autoload.php';
define('APPLICATION_ROOT', __DIR__ . '/..');
ulfberht()->registerModule('module\\application');
ulfberht()->forge(['applicationInitConfig']);
$basePath = __DIR__ . '/../src/public/assets';
$store = ulfberht()->get('module\\application\\service\\store');
$view = ulfberht()->get('module\\application\\service\\view');
$resources = $store->get('resources');
//remove directory
$it = new RecursiveDirectoryIterator($basePath, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file) {
    if ($file->isDir()) {
        rmdir($file->getRealPath());
    } else {
        unlink($file->getRealPath());
    }
}
rmdir($basePath);
//setup new directory structore
mkdir($basePath);
mkdir($basePath . '/js');
mkdir($basePath . '/css');
foreach ($resources as $resourceId => $resource) {
    if ($resource->type === 'js') {
        $code = $view->jscode($resourceId);
        $resourcePath = __DIR__ . '/../src/public/assets/js/' . $resourceId . '.js';
    } else {
Пример #2
0
 /**
  * Gets the service you request.
  * @param  string $className The name of the service you want to retrieve
  * @return mixed The service you requested
  */
 protected function get($className)
 {
     return ulfberht()->get($className);
 }
Пример #3
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
class ClassB
{
}
class ClassC
{
}
class ClassA
{
    public function __construct(ClassB $dep1, ClassC $dep2)
    {
        $this->dep1 = $dep1;
        $this->dep2 = $dep2;
    }
}
var_dump(ulfberht()->factory('ClassA')->factory('ClassB')->factory('ClassC')->get('ClassA'));
Пример #4
0
<?php

//autoload
require_once __DIR__ . '/../../vendor/autoload.php';
ulfberht\debug::enable();
define('APPLICATION_ROOT', __DIR__ . '/../..');
ulfberht()->registerModule('module\\application');
ulfberht()->registerModule('module\\example');
ulfberht()->forge(['applicationInit', 'debugInit', 'applicationMvc']);
Пример #5
0
<?php

use Doctrine\ORM\Tools\Console\ConsoleRunner;
//autoload
require_once __DIR__ . '/vendor/autoload.php';
define('APPLICATION_ROOT', __DIR__);
ulfberht()->registerModule('module\\application');
ulfberht()->forge(['applicationInitConfig', 'applicationInitDoctrine']);
//get doctrine and entityManager
$doctrine = ulfberht()->get('module\\application\\service\\doctrine');
$em = $doctrine->getEntityManager('application');
return ConsoleRunner::createHelperSet($em);
Пример #6
0
 /**
  * [Ulfberht Forging Hook] This method is setup to run as a hook when forging
  * an ulfberht application. The purpose of this hook is to resolve a path to
  * a controller and run that controller's action.
  * @param $router module\application\service\router
  * @param $request module\application\service\request
  * @param $response module\application\service\response
  * @return void
  */
 public function applicationMvc(router $router, request $request, response $response)
 {
     $params = $router->resolve();
     $request->attributes->add($params);
     $controllerActionSetting = explode(':', $params['controller']);
     $controllerClass = $controllerActionSetting[0];
     $controllerAction = isset($controllerActionSetting[1]) ? $controllerActionSetting[1] : false;
     if (!$controllerClass) {
         throw new Exception('Could not find a controller to resolve.');
     }
     if (!$controllerAction) {
         throw new Exception('A controller action was not defined.');
     }
     if (!ulfberht()->exists($controllerClass)) {
         throw new Exception('Could not find controller "' . $controllerClass . '"');
     }
     $controller = ulfberht()->get($controllerClass);
     if ($controllerAction) {
         if (!method_exists($controller, $controllerAction)) {
             throw new Exception('Cound not find action method "' . $controllerAction . '" on controller "' . $controllerClass . '"');
         }
         call_user_func([$controller, $controllerAction]);
     }
     $response->prepare($request);
     $response->send();
 }