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 }
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); }
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); }
<?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]); }
array_unshift($values, $s_id); $ret['spaces'][] = $values; } return $ret; } function bookEvent($space_id, $name, $time, $duration) { $values = array($space_id, $time, $time + $duration); $stmt = $this->doStatement(self::$check_slot, $values, false); if ($result = $stmt->fetch()) { throw new \woo\base\AppException("double booked! try again"); } $this->doStatement(self::$add_event, array($name, $space_id, $time, $duration)); } } $halfhour = 60 * 30; $hour = 60 * 60; $day = 24 * $hour; //$mode="mysql"; $mode = "sqlite"; if ($mode == 'mysql') { $dsn = "mysql:dbname=test"; } else { $dsn = "sqlite://tmp/data/woo.db"; } \woo\base\ApplicationRegistry::setDSN($dsn); $mgr = new VenueManager(); $ret = $mgr->addVenue("The Eyeball Inn", array('The Room Upstairs', 'Main Bar')); $space_id = $ret['spaces'][0][0]; $mgr->bookEvent($space_id, "Running like the rain", time() + $day, $hour - 5); $mgr->bookEvent($space_id, "Running like the trees", time() + ($day - $hour), 60 * 60);