src/Database/Migration/Manager.php
public function getSeeds()
    {
        if (null === $this->seeds) {
            $phpFiles = $this->getSeedFiles();

            // filter the files to only get the ones that match our naming scheme
            $fileNames = [];
            /** @var AbstractSeed[] $seeds */
            $seeds = [];

            foreach ($phpFiles as $filePath) {
                if (Util::isValidSeedFileName(basename($filePath))) {
                    $config = $this->getConfig();
                    $namespace = $config->getSeedNamespaceByPath(dirname($filePath));

                    // convert the filename to a class name
                    $class = (null === $namespace ? '' : $namespace . '\\') . pathinfo($filePath, PATHINFO_FILENAME);
                    $fileNames[$class] = basename($filePath);

                    // load the seed file
                    /** @noinspection PhpIncludeInspection */
                    require_once $filePath;
                    if (!class_exists($class)) {
                        throw new \InvalidArgumentException(sprintf(
                            'Could not find class "%s" in file "%s"',
                            $class,
                            $filePath
                        ));
                    }

                    // instantiate it
                    $seed = new $class($this->getCommand());

                    if (!($seed instanceof AbstractSeed)) {
                        throw new \InvalidArgumentException(sprintf(
                            'The class "%s" in file "%s" must extend \Hail\Database\Migration\Seed\AbstractSeed',
                            $class,
                            $filePath
                        ));
                    }

                    $seeds[$class] = $seed;
                }
            }

            ksort($seeds);
            $this->setSeeds($seeds);
        }

        $this->seeds = $this->orderSeedsByDependencies($this->seeds);

        return $this->seeds;
    }
public function getSeeds()
    {
        if (null === $this->seeds) {
            $phpFiles = $this->getSeedFiles();

            // filter the files to only get the ones that match our naming scheme
            $fileNames = [];
            /** @var AbstractSeed[] $seeds */
            $seeds = [];

            foreach ($phpFiles as $filePath) {
                if (Util::isValidSeedFileName(basename($filePath))) {
                    $config = $this->getConfig();
                    $namespace = $config->getSeedNamespaceByPath(dirname($filePath));

                    // convert the filename to a class name
                    $class = (null === $namespace ? '' : $namespace . '\\') . pathinfo($filePath, PATHINFO_FILENAME);
                    $fileNames[$class] = basename($filePath);

                    // load the seed file
                    /** @noinspection PhpIncludeInspection */
                    require_once $filePath;
                    if (!class_exists($class)) {
                        throw new \InvalidArgumentException(sprintf(
                            'Could not find class "%s" in file "%s"',
                            $class,
                            $filePath
                        ));
                    }

                    // instantiate it
                    $seed = new $class($this->getCommand());

                    if (!($seed instanceof AbstractSeed)) {
                        throw new \InvalidArgumentException(sprintf(
                            'The class "%s" in file "%s" must extend \Hail\Database\Migration\Seed\AbstractSeed',
                            $class,
                            $filePath
                        ));
                    }

                    $seeds[$class] = $seed;
                }
            }

            ksort($seeds);
            $this->setSeeds($seeds);
        }

        $this->seeds = $this->orderSeedsByDependencies($this->seeds);

        return $this->seeds;
    }
public function getSeeds ( ) { if ( null === $ this -> seeds ) { $ phpFiles = $ this -> getSeedFiles ( ) ; // filter the files to only get the ones that match our naming scheme $ fileNames = [ ] ; /** @var AbstractSeed[] $seeds */ $ seeds = [ ] ; foreach ( $ phpFiles as $ filePath ) { if ( Util :: isValidSeedFileName ( basename ( $ filePath ) ) ) { $ config = $ this -> getConfig ( ) ; $ namespace = $ config -> getSeedNamespaceByPath ( dirname ( $ filePath ) ) ; // convert the filename to a class name $ class = ( null === $ namespace ? '' : $ namespace . '\\' ) . pathinfo ( $ filePath , PATHINFO_FILENAME ) ; $ fileNames [ $ class ] = basename ( $ filePath ) ; // load the seed file /** @noinspection PhpIncludeInspection */ require_once $ filePath ; if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Could not find class "%s" in file "%s"' , $ class , $ filePath ) ) ; } // instantiate it $ seed = new $ class ( $ this -> getCommand ( ) ) ; if ( ! ( $ seed instanceof AbstractSeed ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The class "%s" in file "%s" must extend \Hail\Database\Migration\Seed\AbstractSeed' , $ class , $ filePath ) ) ; } $ seeds [ $ class ] = $ seed ; } } ksort ( $ seeds ) ; $ this -> setSeeds ( $ seeds ) ; } $ this -> seeds = $ this -> orderSeedsByDependencies ( $ this -> seeds ) ; return $ this -> seeds ; }
Gets an array of database seeders.

@throws \InvalidArgumentException
@return AbstractSeed[]
Gets an array of database seeders .