public function siteMap() { try { $presentationClasses = \helper\FolderHelper::listFilesByType(PAPRIKA_CUSTOM_PATH.'/'.Config::CUSTOM_CODE_PRESENTATION, '.php', true); echo '<ul>'.PHP_EOL; foreach ($presentationClasses as $class) { echo '<li>'.$class.'</li>'; $listAnnotation = \annotation\Annotation::extractAnnotations($class); if (isset($listAnnotation[\annotation\Annotation::CLAZZ])) { foreach ($listAnnotation[\annotation\Annotation::CLAZZ] as $annotation) { if ($annotation[\annotation\Annotation::BEHAVIOR] == \annotation\Annotation::T_ROUTE && $annotation[\annotation\Annotation::VALUES][\annotation\Annotation::O_TYPE] == 'static') { if (isset($annotation[\annotation\Annotation::VALUES][\annotation\Annotation::O_ROLE])) continue; if (isset($annotation[\annotation\Annotation::VALUES][\annotation\Annotation::O_CONTENT_TYPE]) && $annotation[\annotation\Annotation::VALUES][\annotation\Annotation::O_CONTENT_TYPE] == 'json') continue; $link = $annotation[\annotation\Annotation::VALUES][\annotation\Annotation::O_MAPPER]; $basePrefix = preg_replace('/\/sitemap.php$/', '', $_SERVER['SCRIPT_NAME']); echo '<li style="margin-left: 25px; list-style: circle"><a href="'.$basePrefix.$link.'">'.$link.'</a></li>'; } } } } echo '</ul>'.PHP_EOL; } catch (\Exception $e) { p($e); } }
public function findRoute($className, $method, $usesBasePrefix = true, $args = null) { $presentationClasses = \helper\FolderHelper::listFilesByType(PAPRIKA_CUSTOM_PATH.'/'.Config::CUSTOM_CODE_PRESENTATION, '.php', true); foreach ($presentationClasses as $presentationClassName) { $listAnnotation = \annotation\Annotation::extractAnnotations($presentationClassName); if (isset($listAnnotation[\annotation\Annotation::CLAZZ])) { foreach ($listAnnotation[\annotation\Annotation::CLAZZ] as $annotation) { if ($annotation[Annotation::BEHAVIOR] == Annotation::T_ROUTE) { if ($presentationClassName == $className && $annotation[Annotation::VALUES][Annotation::O_METHOD] == $method) { $url = null; if ($usesBasePrefix) { $url = $this->getBasePrefix().$annotation[Annotation::VALUES][Annotation::O_MAPPER]; } else { $url = $annotation[Annotation::VALUES][Annotation::O_MAPPER]; } if (isset($args)) { foreach ($args as $key=>$arg) { $var = '({'.$key.'})'; $url = preg_replace($var, $arg, $url); } } return $url; } } } } } return null; }