/** * handlerのマップ名を呼び出しているURLを生成する * 引数を与える事も可能 * @param string $name マップ名 * @return string */ public function map_url($name) { $args = func_get_args(); array_shift($args); if (strpos($name, '::') === false) { $entry = $this->current_entry; } else { list($entry, $name) = explode('::', $name, 2); } if (!isset($this->url_pattern[$entry]) && is_file($f = $this->current_entry_dir . '/' . $entry . '.php')) { foreach (\org\rhaco\Flow::get_maps($f) as $m) { $this->url_pattern[$entry][$m['name'] . '#' . $m['num']] = $m; } } $n = $name . '#' . sizeof($args); if (isset($this->url_pattern[$entry][$n])) { return vsprintf($this->url_pattern[$entry][$n]['pattern'], $args); } }
/** * エントリのURL群 * @param string $dir * @return array */ public static function get_urls($dir = null) { if (empty($dir)) { $dir = getcwd(); } $urls = array(); foreach (new \RecursiveDirectoryIterator($dir, \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::UNIX_PATHS) as $f) { if (substr($f->getFilename(), -4) == '.php' && !preg_match('/\\/[\\._]/', $f->getPathname())) { $entry_name = substr($f->getFilename(), 0, -4); $src = file_get_contents($f->getPathname()); if (strpos($src, 'Flow') !== false) { $entry_name = substr($f->getFilename(), 0, -4); foreach (\org\rhaco\Flow::get_maps($f->getPathname()) as $p => $m) { $urls[$entry_name . '::' . $m['name']] = $m['pattern']; } } } } return $urls; }