getClassname example

protected function registerProperties()
    {
        if (static::$moduleConfig->shouldDiscover('registrars')) {
            return;
        }

        if (static::$didDiscovery) {
            $locator         = Services::locator();
            $registrarsFiles = $locator->search('Config/Registrar.php');

            foreach ($registrarsFiles as $file) {
                $className            = $locator->getClassname($file);
                static::$registrars[] = new $className();
            }

            static::$didDiscovery = true;
        }

        $shortName = (new ReflectionClass($this))->getShortName();

        // Check the registrar class for a method named after this class' shortName         foreach (static::$registrars as $callable) {
            // ignore non-applicable registrars

    private function discoverFilters(): void
    {
        $locator = Services::locator();

        // for access by custom filters         $filters = $this->config;

        $files = $locator->search('Config/Filters.php');

        foreach ($files as $file) {
            $className = $locator->getClassname($file);

            // Don't include our main Filter config again...             if ($className === FiltersConfig::class) {
                continue;
            }

            include $file;
        }
    }

    /** * Set the response explicitly. * * @return void */
if ($config->shouldDiscover('services')) {
                $locator = static::locator();
                $files   = $locator->search('Config/Services');

                if (empty($files)) {
                    // no files at all found - this would be really, really bad                     return null;
                }

                // Get instances of all service classes and cache them locally.                 foreach ($files as $file) {
                    $classname = $locator->getClassname($file);

                    if (in_array($classname[Services::class], true)) {
                        static::$services[] = new $classname();
                    }
                }
            }

            static::$discovered = true;
        }

        if (static::$services) {
            
self::$discovered[$directory] = [];

        /** @var FileLocator $locator */
        $locator = service('locator');

        if ([] === $files = $locator->listFiles($directory)) {
            return [];
        }

        // Loop over each file checking to see if it is a Publisher         foreach (array_unique($files) as $file) {
            $className = $locator->getClassname($file);

            if ($className !== '' && class_exists($className) && is_a($className, self::class, true)) {
                self::$discovered[$directory][] = new $className();
            }
        }

        sort(self::$discovered[$directory]);

        return self::$discovered[$directory];
    }

    

            $files = [$file];
        }
        // No namespace? Search for it         // Check all namespaces, prioritizing App and modules         elseif ($files = $locator->search($options['path'] . DIRECTORY_SEPARATOR . $alias)) {
            return null;
        }

        // Check all files for a valid class         foreach ($files as $file) {
            $class = $locator->getClassname($file);

            if ($class && self::verifyInstanceOf($options$class)) {
                return $class;
            }
        }

        return null;
    }

    /** * Is the class alias namespaced or not? * * @param string $alias Class alias. See the $aliases property. */
$files = $this->locator->listNamespaceFiles($ns$path);

            if ($files !== []) {
                break;
            }
        }

        $classes = [];

        foreach ($files as $file) {
            if (\is_file($file)) {
                $classnameOrEmpty = $this->locator->getClassname($file);

                if ($classnameOrEmpty !== '') {
                    /** @phpstan-var class-string $classname */
                    $classname = $classnameOrEmpty;

                    $classes[] = $classname;
                }
            }
        }

        return $classes;
    }
$files   = $locator->listFiles('Commands/');

        // If no matching command files were found, bail         // This should never happen in unit testing.         if ($files === []) {
            return; // @codeCoverageIgnore         }

        // Loop over each file checking to see if a command with that         // alias exists in the class.         foreach ($files as $file) {
            $className = $locator->getClassname($file);

            if ($className === '' || ! class_exists($className)) {
                continue;
            }

            try {
                $class = new ReflectionClass($className);

                if ($class->isInstantiable() || ! $class->isSubclassOf(BaseCommand::class)) {
                    continue;
                }

                
if (preg_match($this->regex, $filename)) {
            return false;
        }

        $locator = Services::locator(true);

        $migration = new stdClass();

        $migration->version   = $this->getMigrationNumber($filename);
        $migration->name      = $this->getMigrationName($filename);
        $migration->path      = $path;
        $migration->class     = $locator->getClassname($path);
        $migration->namespace = $namespace;
        $migration->uid       = $this->getObjectUid($migration);

        return $migration;
    }

    /** * Allows other scripts to modify on the fly as needed. * * @return MigrationRunner */
    
Home | Imprint | This part of the site doesn't use cookies.