protected function __construct() { foreach (require_once moojon_paths::get_routes_path() as $route) { if (is_subclass_of($route, 'moojon_base_route')) { $this->data[$route->get_pattern()] = $route; } else { throw new moojon_exception("Only moojon_base_route derived objects may be included in {$routes_path} (" . get_class($route) . ' found)'); } } }
public static function add_route($route) { $routes_path = moojon_paths::get_routes_path(); $read_file_handle = fopen($routes_path, 'r'); $routes = ''; while ($line = fgets($read_file_handle)) { $routes .= "{$line}"; if (preg_match("/return\\s+array\\s*\\(/", $line)) { $routes .= "\t{$route}\n"; } } fclose($read_file_handle); $write_file_handle = fopen($routes_path, 'w'); fwrite($write_file_handle, $routes); fclose($write_file_handle); echo "Adding route ({$route})\n"; }