예제 #1
0
 function __construct()
 {
     $dsn = ApplicationRegistry::getDSN();
     if (is_null($dsn)) {
         throw new AppException('DSN не задан');
     }
     self::$DB = new \PDO($dsn);
     self::$DB->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
 }
예제 #2
0
 function handleRequest()
 {
     $request = new Request();
     $app_c = \woo\base\ApplicationRegistry::appController();
     while ($cmd = $app_c->getCommand($request)) {
         $cmd->execute($request);
     }
     $this->invokeView($app_c->getView($request));
 }
예제 #3
0
 private function getOptions()
 {
     $this->ensure(file_exists($this->config), "Could not find options file");
     $options = SimpleXml_load_file($this->config);
     print get_class($options);
     $dsn = (string) $options->dsn;
     $this->ensure($dsn, "No DSN found");
     \woo\base\ApplicationRegistry::setDSN($dsn);
     // set other values
 }
예제 #4
0
 function handleRequest()
 {
     $request = new Request();
     $app_c = \woo\base\ApplicationRegistry::appController();
     while ($cmd = $app_c->getCommand($request)) {
         $cmd->execute($request);
     }
     \woo\domain\ObjectWatcher::instance()->performOperations();
     $this->invokeView($app_c->getView($request));
 }
예제 #5
0
파일: Mapper.php 프로젝트: jabouzi/projet
 function __construct()
 {
     if (!isset(self::$PDO)) {
         $dsn = \woo\base\ApplicationRegistry::getDSN();
         if (is_null($dsn)) {
             throw new \woo\base\AppException("No DSN");
         }
         self::$PDO = new \PDO($dsn);
         self::$PDO->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     }
 }
예제 #6
0
 function __construct()
 {
     if (!isset(self::$PDO)) {
         $dsn = ApplicationRegistry::getDSN();
         if (is_null($dsn)) {
             throw new AppException('DSN не определен');
         }
         self::$PDO = new \PDO($dsn);
         self::$PDO->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     }
 }
예제 #7
0
 function handleRequest()
 {
     $request = new Request();
     $app_c = ApplicationRegistry::appController();
     while ($cmd = $app_c->getCommand($request)) {
         print 'Выполняется ' . get_class($cmd) . '\\n';
         $cmd->execute($request);
     }
     $this->invokeView($app_c->getView());
     //        $cmd_r = new CommandResolver();
     //        $cmd = $cmd_r->getCommand($request);
     //        $cmd->execute($request);
 }
예제 #8
0
 private function getOptions()
 {
     $this->ensure(file_exists($this->config), 'Файл конфигурации не найден');
     $options = simplexml_load_file($this->config);
     print get_class($options);
     $dsn = (string) $options->dsn;
     $this->ensure($options instanceof \SimpleXMLElement, 'Файл конфигурации запорчен');
     $this->ensure($dsn, 'DSN не найден');
     ApplicationRegistry::setDSN($dsn);
     $map = new ControllerMap();
     foreach ($options->control->view as $default_view) {
         $stat_str = trim($default_view['status']);
         $status = Command::statues($stat_str);
         $map->addView('default', $status, (string) $default_view);
     }
     // анализ остальных кодов
     ApplicationRegistry::setControllerMap($map);
 }
예제 #9
0
 private function getOptions()
 {
     $this->ensure(file_exists($this->config), "Could not find options file");
     $options = @SimpleXml_load_file($this->config);
     //        $this->ensure( $options instanceof SimpleXMLElement,
     //                            "Could not resolve options file" );
     $dsn = (string) $options->dsn;
     $this->ensure($dsn, "No DSN found");
     \woo\base\ApplicationRegistry::setDSN($dsn);
     $map = new ControllerMap();
     foreach ($options->control->view as $default_view) {
         $stat_str = trim($default_view['status']);
         $status = \woo\command\Command::statuses($stat_str);
         $map->addView('default', $status, (string) $default_view);
     }
     foreach ($options->control->command as $command_view) {
         $command = trim((string) $command_view['name']);
         if ($command_view->classalias) {
             $classroot = trim((string) $command_view->classalias['name']);
             $map->addClassroot($command, $classroot);
         }
         if ($command_view->view) {
             $view = trim((string) $command_view->view);
             $forward = trim((string) $command_view->forward);
             $map->addView($command, 0, $view);
             if ($forward) {
                 $map->addForward($command, 0, $forward);
             }
             foreach ($command_view->status as $command_view_status) {
                 $view = trim((string) $command_view_status->view);
                 $forward = trim((string) $command_view_status->forward);
                 $stat_str = trim($command_view_status['value']);
                 $status = \woo\command\Command::statuses($stat_str);
                 if ($view) {
                     $map->addView($command, $status, $view);
                 }
                 if ($forward) {
                     $map->addForward($command, $status, $forward);
                 }
             }
         }
     }
     \woo\base\ApplicationRegistry::setControllerMap($map);
 }
예제 #10
0
<?php

require_once "listing12.05.php";
// Registry
// test file app registry
if (!isset($argv[1])) {
    // run script without argument to monitor
    while (1) {
        sleep(5);
        $thing = \woo\base\ApplicationRegistry::getDSN();
        \woo\base\RequestRegistry::instance();
        \woo\base\SessionRegistry::instance();
        \woo\base\MemApplicationRegistry::instance();
        print "dsn is {$thing}\n";
    }
} else {
    // run script with argument in separate window to change value.. see the result in monitor process
    print "setting dsn {$argv[1]}\n";
    \woo\base\ApplicationRegistry::setDSN($argv[1]);
}