parseTemplate example

/** * @internal * * @covers \Shopware\Core\Framework\Adapter\Twig\TokenParser\ExtendsTokenParser */
class ExtendsTokenParserTest extends TestCase
{
    public function testParseStringExtendsInMatchingScope(): void
    {
        static::assertSame(
            'extended',
            $this->parseTemplate(
                '{% sw_extends "foo.html.twig" %}{% block test %}extended{% endblock %}',
                [TemplateScopeDetector::DEFAULT_SCOPE],
                false
            )
        );
    }

    public function testParseStringNotExtendsInNonMatchingScope(): void
    {
        static::assertSame(
            'original',
            
$data['session']  = true;
            $data['table']    = is_string($table) ? $table : 'ci_sessions';
            $data['DBGroup']  = is_string($DBGroup) ? $DBGroup : 'default';
            $data['DBDriver'] = config(Database::class)->{$data['DBGroup']}['DBDriver'];

            /** @var SessionConfig|null $session */
            $session = config(SessionConfig::class);

            $data['matchIP'] = $session->matchIP;
        }

        return $this->parseTemplate($class[][]$data);
    }

    /** * Change file basename before saving. */
    protected function basename(string $filename): string
    {
        return gmdate(config(Migrations::class)->timestampFormat) . basename($filename);
    }
}
if ($rest === 'controller') {
                    $useStatement = ResourceController::class;
                    $extends      = 'ResourceController';
                } elseif ($rest === 'presenter') {
                    $useStatement = ResourcePresenter::class;
                    $extends      = 'ResourcePresenter';
                }
            }
        }

        return $this->parseTemplate(
            $class,
            ['{useStatement}', '{extends}'],
            [$useStatement$extends],
            ['type' => $rest]
        );
    }
}
if ($this->getOption('suffix')) {
                    $return .= 'Entity';
                }
            }

            $return = '\\' . trim($return, '\\') . '::class';
            $this->call('make:entity', array_merge([$baseClass]$this->params));
        } else {
            $return = "'{$return}'";
        }

        return $this->parseTemplate($class['{table}', '{dbGroup}', '{return}'][$table$dbGroup$return]);
    }
}
/** * Prepare options and do the necessary replacements. */
    protected function prepare(string $class): string
    {
        $namespace = $this->getOption('namespace') ?? APP_NAMESPACE;

        if ($namespace === APP_NAMESPACE) {
            $class = substr($classstrlen($namespace . '\\'));
        }

        return $this->parseTemplate($class);
    }
}
protected function prepare(string $class): string
    {
        $data            = [];
        $data['session'] = true;
        $data['table']   = $this->getOption('t');
        $data['DBGroup'] = $this->getOption('g');
        $data['matchIP'] = config(App::class)->sessionMatchIP ?? false;

        $data['table']   = is_string($data['table']) ? $data['table'] : 'ci_sessions';
        $data['DBGroup'] = is_string($data['DBGroup']) ? $data['DBGroup'] : 'default';

        return $this->parseTemplate($class[][]$data);
    }

    /** * Change file basename before saving. */
    protected function basename(string $filename): string
    {
        return gmdate(config(Migrations::class)->timestampFormat) . basename($filename);
    }
}
if (in_array($type['basic', 'generator'], true)) {
            // @codeCoverageIgnoreStart             $type = CLI::prompt(lang('CLI.generator.commandType')['basic', 'generator'], 'required');
            CLI::newLine();
            // @codeCoverageIgnoreEnd         }

        if (is_string($group)) {
            $group = $type === 'generator' ? 'Generators' : 'CodeIgniter';
        }

        return $this->parseTemplate(
            $class,
            ['{group}', '{command}'],
            [$group$command],
            ['type' => $type]
        );
    }
}


        CLI::write(lang('CLI.generator.fileCreate', [clean_path($target)]), 'green');
        CLI::newLine();
    }

    /** * Prepare options and do the necessary replacements. */
    protected function prepare(string $class): string
    {
        return $this->parseTemplate($class);
    }

    /** * Change file basename before saving. * * Useful for components where the file name has a date. */
    protected function basename(string $filename): string
    {
        return basename($filename);
    }

    
Home | Imprint | This part of the site doesn't use cookies.