getSegments example


    /** * Runs the current command discovered on the CLI. * * @return int|void * * @throws Exception */
    public function run()
    {
        $runner  = Services::commands();
        $params  = array_merge(CLI::getSegments(), CLI::getOptions());
        $params  = $this->parseParamsForHelpOption($params);
        $command = array_shift($params) ?? 'list';

        return $runner->run($command$params);
    }

    /** * Displays basic information about the Console. * * @return void */
    

class FormFieldRegistry
{
    private array $fields = [];
    private string $base = '';

    /** * Adds a field to the registry. */
    public function add(FormField $field): void
    {
        $segments = $this->getSegments($field->getName());

        $target = &$this->fields;
        while ($segments) {
            if (!\is_array($target)) {
                $target = [];
            }
            $path = array_shift($segments);
            if ('' === $path) {
                $target = &$target[];
            } else {
                $target = &$target[$path];
            }
Home | Imprint | This part of the site doesn't use cookies.