예제 #1
0
 /**
  * 
  */
 public function __construct()
 {
     $config = new Config();
     $config->loadConfig('config.yml');
     Service::set('config', $config);
     $request = new Request();
     Service::set('request', $request);
     $session = new Session();
     Service::set('session', $session);
     $routes = (include '../config/routes.php');
     $router = new Router($routes);
     Service::set('router', $router);
     Service::set('pdo', new \PDO($config->getVal('mysql/type') . ':host=' . $config->getVal('mysql/host') . ';dbname=' . $config->getVal('mysql/db'), $config->getVal('mysql/username'), $config->getVal('mysql/pass'), array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')));
     $log = new Log(URL . '/logs/log.txt');
     Service::set('log', $log);
     Service::set('user', new User());
 }
예제 #2
0
 /**
  * Create services
  *
  * @throws Exception\DatabaseException
  */
 private function createServices()
 {
     Service::set('request', new Request());
     Service::set('db', DBConnection::getInstance(Service::get('config')->get('pdo')));
     Database::setConnection(Service::get('db'));
     Service::set('session', new Session());
     Service::set('security', new Security(Service::get('config')->get('security.login_route'), Service::get('config')->get('security.user_class')));
     Service::set('router', new Router(Service::get('config')->get('routes')));
     Service::set('render', new Render(Service::get('config')->get('main_layout')));
 }
예제 #3
0
 /**
  * @brief Function addService
  *      adiciona um novo serviço no banco de dados.
  * @param id_adm do usuario logado
  * @return mensagem indicador de erro ou sucesso
  */
 public function addService($id_adm)
 {
     $moreService = new Service();
     return $moreService->set($id_adm);
 }
예제 #4
0
    return new Kodazzi\Console\Commands\DatabaseCommand();
});
Service::factory('command.model', function () {
    return new Kodazzi\Console\Commands\ModelCommand();
});
Service::factory('command.form', function () {
    return new Kodazzi\Console\Commands\FormsCommand();
});
Service::factory('command.bundle', function () {
    return new Kodazzi\Console\Commands\BundleCommand();
});
Service::factory('command.routes', function () {
    return new Kodazzi\Console\Commands\RoutesCommand();
});
Service::set('shell', function () {
    return new Kodazzi\Console\Shell();
});
Service::factory('new.request', function () {
    return new Symfony\Component\HttpFoundation\Request();
});
// Captura la peticion
Service::instance('kernel.request', Symfony\Component\HttpFoundation\Request::createFromGlobals());
// Agrega al contenedor la instancia de Request y loader.
Service::instance('kernel.loader', $loader);
// Suscribe los escuchas
$dispatcher = Service::get('event');
$dispatcher->addSubscriber(Service::get('listener.router'));
$dispatcher->addSubscriber(Service::get('listener.firewall'));
$dispatcher->addSubscriber(Service::get('listener.controller'));
$dispatcher->addSubscriber(Service::get('listener.locale'));
$dispatcher->addSubscriber(Service::get('listener.response'));