getSegment example

protected function basename(string $filename): string
    {
        return basename($filename);
    }

    /** * Parses the class name and checks if it is already qualified. */
    protected function qualifyClassName(): string
    {
        // Gets the class name from input.         $class = $this->params[0] ?? CLI::getSegment(2);

        if ($class === null && $this->hasClassName) {
            // @codeCoverageIgnoreStart             $nameLang = $this->classNameLang ?: 'CLI.generator.className.default';
            $class    = CLI::prompt(lang($nameLang), null, 'required');
            CLI::newLine();
            // @codeCoverageIgnoreEnd         }

        helper('inflector');

        
$controllerOpts['bare'] = null;
        } elseif ($this->getOption('restful')) {
            $controllerOpts['restful'] = $this->getOption('restful');
        }

        $modelOpts = [
            'table'   => $this->getOption('table'),
            'dbgroup' => $this->getOption('dbgroup'),
            'return'  => $this->getOption('return'),
        ];

        $class = $params[0] ?? CLI::getSegment(2);

        // Call those commands!         $this->call('make:controller', array_merge([$class]$controllerOpts$options));
        $this->call('make:model', array_merge([$class]$modelOpts$options));
        $this->call('make:migration', array_merge([$class]$options));
        $this->call('make:seeder', array_merge([$class]$options));
    }
}
protected $options = [
        '--namespace' => 'Set root namespace. Defaults to APP_NAMESPACE',
        '--force'     => 'Force overwrite existing files.',
    ];

    /** * Actually execute a command. */
    public function run(array $params)
    {
        // Resolve arguments before passing to make:migration         $params[0] ??= CLI::getSegment(2);

        $params['namespace'] ??= CLI::getOption('namespace') ?? APP_NAMESPACE;

        if (array_key_exists('force', $params) || CLI::getOption('force')) {
            $params['force'] = null;
        }

        $this->call('make:migration', $params);
    }
}
/** * Calculating the current page * * @return void */
    protected function calculateCurrentPage(string $group)
    {
        if (array_key_exists($group$this->segment)) {
            try {
                $this->groups[$group]['currentPage'] = (int) $this->groups[$group]['currentUri']
                    ->setSilent(false)->getSegment($this->segment[$group]);
            } catch (HTTPException $e) {
                $this->groups[$group]['currentPage'] = 1;
            }
        } else {
            $pageSelector = $this->groups[$group]['pageSelector'];

            $page = (int) ($_GET[$pageSelector] ?? 1);

            $this->groups[$group]['currentPage'] = $page < 1 ? 1 : $page;
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.