本文整理汇总了PHP中Service::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::set方法的具体用法?PHP Service::set怎么用?PHP Service::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
*/
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: createServices
/**
* 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: addService
/**
* @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: function
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'));