$response = $this->response; echo $response->body; $response->_finalized_body = true; } private function finalize_cookies() { $response = $this->response; foreach ($response->cookies as $c) { setcookie($c['name'], $c['value'], $c['expire'], $c['path'], $c['domain'], $c['secure'], $c['httponly']); } $response->_finalized_cookies = true; } public static function path_to() { // app_root should already be suffixed with / $home = DF_Web_Environment::singleton()->app_root; if (!preg_match('#/$#', $home)) { $home .= "/"; } $args = func_get_args(); if ($args) { $home .= join('/', $args); if (is_dir($home)) { $home .= '/'; } } return $home; } } DF_Web::$LOGGER = DF_Web_Logger::logger('DF_Web'); require_once 'DF/Util/Arrays.php';
public function get_path() { return $this->path; } public function get_method() { $name = $this->name; $method = "handle_{$name}"; return $method; } public function get_code_ref() { $ctrl = $this->controller_name . ""; $method = $this->get_method(); $ref = array($ctrl, $method); return $ref; } public function __toString() { $ctrl = $this->controller_name; $method = $this->get_method(); $path_match = $this->get_path_match(); $name = $this->name; $path = $this->path; $args = $this->args; $str = "{$ctrl}::{$method} Pathmatch: {$path_match}, Name: {$name}, Path: {$path}, Args: {$args}"; return $str; } } DF_Web_Routing_Action::$LOGGER = DF_Web_Logger::logger('DF_Web_Routing_Action');
} public function find_actions_by_path($path) { if (!$path instanceof DF_Web_Path) { throw new DF_Error_InvalidArgumentException("path", $path, "DF_Web_Path"); } $ret = array(); if ($best = $this->find_path_actions_by_path($path)) { $actions = $best->get_actions(); $ret = self::build_path_action($path, $actions); } elseif ($best = $this->find_chained_actions_by_path($path)) { $actions = $best->get_actions(); $ret = self::build_chain($path, $actions); } else { #throw new Exception("No actions found by path: $path"); } return $ret; } public function find_actions_by_url($url) { $url = DF_Web_URL::fromString($url); $path = $url->get_path(); #$path = new DF_Web_Path($url); $actions = $this->find_actions_by_path($path); return $actions; } } require_once 'DF/Error/InvalidArgumentException.php'; require_once 'DF/Web/Routing/ActionChain.php'; DF_Web_Routing::$LOGGER = DF_Web_Logger::logger('DF_Web_Routing');
require_once 'DF/Error.php'; require_once 'DF/Error/InvalidArgumentException.php'; class DF_Web_Utils_Arguments { public static $LOGGER = NULL; public static function flatten_arguments_list($arguments) { if (!is_array($arguments)) { throw new DF_Error_InvalidArgumentException('arguments', $arguments, 'array'); } $str = array(); foreach ($arguments as $arg) { if (NULL === $arg) { $str[] = "NULL"; } elseif (gettype($arg) == 'object') { $str[] = get_class($arg); } elseif (gettype($arg) == 'string') { $str[] = '"' . $arg . '"'; } elseif (gettype($arg) == 'array') { $str[] = 'Array'; } else { $type = gettype($arg); self::$LOGGER->warn("Building argument list. Unknown type: {$type} - value: {$arg}"); $str[] = '"' . $arg . '"'; } } return join(', ', $str); } } DF_Web_Utils_Arguments::$LOGGER = DF_Web_Logger::logger('DF_Web_Utils_Arguments');
*/ protected function has_config_chained($config) { if ($config->has('chained')) { return true; } return false; } public function is_chained_root() { return $this->is_chained_root; } public function is_endpoint() { if ($this->get_args()) { return true; } return false; } public function __toString() { $parent = parent::__toString(); $chained = $this->chained; $captures = $this->captures; $root_chained = $this->is_chained_root ? "Root chained" : "Chained"; $str = "{$parent}, {$root_chained}: {$chained}, Captures: {$captures}"; return $str; } } DF_Web_Routing_Action_Chained::$LOGGER = DF_Web_Logger::logger('DF_Web_Routing_Action_Chained');
<?php require_once 'DF/Web/View/Smarty.php'; class DF_Web_View_Smarty_Doclet extends DF_Web_View_Smarty { public static $LOGGER = NULL; protected $config = array('debugging' => false, 'debugging_ctrl' => 'NONE', 'caching' => 0, 'error' => 'error.tpl'); } DF_Web_View_Smarty::$LOGGER = DF_Web_Logger::logger('DF_Web_View_Smarty');
# TODO configurable and detect changes by timestamp $compiled_file = File::buildPath(array($app_root, "cache", "{$basename}-compiled.php")); if (file_exists($compiled_file)) { global $config; require_once "{$compiled_file}"; return $config; } $file = File::buildPath(array($app_root, "{$basename}.yaml")); $fileenv = File::buildPath(array($app_root, "{$basename}-{$environment}.yaml")); $config = array(); if (file_exists($file)) { if ($env->debug) { self::$LOGGER->debug("Loading configuration file: {$file}"); } $loader = new DF_Web_Config_Loader($file); $config = array_merge($config, $loader->getConfig()); } if (file_exists($fileenv)) { if ($env->debug) { self::$LOGGER->log("Loading configuration file: {$fileenv}"); } $loader = DF_Web_Config_Loader($fileenv); $config = array_merge($config, $loader->getConfig()); } $struct = "<?php\n \$config = " . var_export($config, 1) . ";"; file_put_contents($compiled_file, $struct); return $config; } } DF_Web_Config::$LOGGER = DF_Web_Logger::logger('DF_Web_Config'); require_once 'DF/Util/Arrays.php';
} if ($this === $action) { return true; } if (get_class($action) !== get_class($this)) { return false; } if ($this->get_controller() != $action->get_controller()) { return false; } if ($this->get_method() != $action->get_method()) { return false; } if ($this->get_arguments() != $action->get_arguments()) { return false; } return true; } public function toString() { $args = ""; if ($this->arguments) { $args = join(', ', $this->arguments); } $ctrl = $this->controller; $method = $this->method; return "{$ctrl}->{$method}({$args})"; } } DF_Web_Action_REST::$LOGGER = DF_Web_Logger::logger('DF_Web_Action_REST');