public static function getHooks($classpath, $namespace, $classname = null, $extends = null, $method = null) {

        //
        $hooks = [];

        // Get the filenames.
        $filenames = FileHelper::getFileNames($classpath, ".php");

        // Handle each filenames.
        foreach ($filenames as $filename) {

            // Check the class name.
            if (null !== $classname && 0 === preg_match($classname, $filename)) {
                continue;
            }

            // Import the class.
            try {
                require_once $classpath . "/" . $filename;
            } catch (Error $ex) {
                throw new SyntaxErrorException($classpath . "/" . $filename);
            }

            // Init. the complete class name.
            $completeClassname = $namespace . basename($filename, ".php");

            try {
                $rc = new ReflectionClass($completeClassname);
            } catch (Exception $ex) {
                throw new ClassNotFoundException($completeClassname, $ex);
            }

            // Check the extends.
            if (false === (null === $extends || true === $rc->isSubclassOf($extends))) {
                continue;
            }

            // Initialize the hook.
            $hook = [];

            $hook["classpath"] = $classpath;
            $hook["namespace"] = $namespace;
            $hook["filename"]  = $filename;
            $hook["class"]     = $rc;
            $hook["method"]    = null;

            $hooks[] = $hook;

            // Check the method.
            if (null === $method) {
                continue;
            }

            try {
                $rm = $rc->getMethod($method);

                $hooks[count($hooks) - 1]["method"] = $rm;
            } catch (ReflectionException $ex) {
                throw new MethodNotFoundException($method, $ex);
            }
        }

        // Returns the hooks.
        return $hooks;
    }
public static function getHooks($classpath, $namespace, $classname = null, $extends = null, $method = null) {

        //
        $hooks = [];

        // Get the filenames.
        $filenames = FileHelper::getFileNames($classpath, ".php");

        // Handle each filenames.
        foreach ($filenames as $filename) {

            // Check the class name.
            if (null !== $classname && 0 === preg_match($classname, $filename)) {
                continue;
            }

            // Import the class.
            try {
                require_once $classpath . "/" . $filename;
            } catch (Error $ex) {
                throw new SyntaxErrorException($classpath . "/" . $filename);
            }

            // Init. the complete class name.
            $completeClassname = $namespace . basename($filename, ".php");

            try {
                $rc = new ReflectionClass($completeClassname);
            } catch (Exception $ex) {
                throw new ClassNotFoundException($completeClassname, $ex);
            }

            // Check the extends.
            if (false === (null === $extends || true === $rc->isSubclassOf($extends))) {
                continue;
            }

            // Initialize the hook.
            $hook = [];

            $hook["classpath"] = $classpath;
            $hook["namespace"] = $namespace;
            $hook["filename"]  = $filename;
            $hook["class"]     = $rc;
            $hook["method"]    = null;

            $hooks[] = $hook;

            // Check the method.
            if (null === $method) {
                continue;
            }

            try {
                $rm = $rc->getMethod($method);

                $hooks[count($hooks) - 1]["method"] = $rm;
            } catch (ReflectionException $ex) {
                throw new MethodNotFoundException($method, $ex);
            }
        }

        // Returns the hooks.
        return $hooks;
    }
public static function getHooks ( $ classpath , $ namespace , $ classname = null , $ extends = null , $ method = null ) { // $ hooks = [ ] ; // Get the filenames. $ filenames = FileHelper :: getFileNames ( $ classpath , ".php" ) ; // Handle each filenames. foreach ( $ filenames as $ filename ) { // Check the class name. if ( null !== $ classname && 0 === preg_match ( $ classname , $ filename ) ) { continue ; } // Import the class. try { require_once $ classpath . "/" . $ filename ; } catch ( Error $ ex ) { throw new SyntaxErrorException ( $ classpath . "/" . $ filename ) ; } // Init. the complete class name. $ completeClassname = $ namespace . basename ( $ filename , ".php" ) ; try { $ rc = new ReflectionClass ( $ completeClassname ) ; } catch ( Exception $ ex ) { throw new ClassNotFoundException ( $ completeClassname , $ ex ) ; } // Check the extends. if ( false === ( null === $ extends || true === $ rc -> isSubclassOf ( $ extends ) ) ) { continue ; } // Initialize the hook. $ hook = [ ] ; $ hook [ "classpath" ] = $ classpath ; $ hook [ "namespace" ] = $ namespace ; $ hook [ "filename" ] = $ filename ; $ hook [ "class" ] = $ rc ; $ hook [ "method" ] = null ; $ hooks [ ] = $ hook ; // Check the method. if ( null === $ method ) { continue ; } try { $ rm = $ rc -> getMethod ( $ method ) ; $ hooks [ count ( $ hooks ) - 1 ] [ "method" ] = $ rm ; } catch ( ReflectionException $ ex ) { throw new MethodNotFoundException ( $ method , $ ex ) ; } } // Returns the hooks. return $ hooks ; }
Get the hooks.

@param string $classpath The class path.
@param string $namespace The namespace.
@param string $classname The class name.
@param string $extends The class extend.
@param string $method The class method.
@return array Returns the hooks array.
@throws ClassNotFoundException Throws a hook class not found if the classname is not found.
Get the hooks .