lazy: true
class Kernel extends BaseKernel
{
/**
* @var string
*/
private $templateDirSuffix;
public function __construct(string $environment, bool $debug, string $templateDirSuffix = '')
{
parent::__construct($environment, $debug);
$this->templateDirSuffix = $templateDirSuffix;
}
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
// ...
$container->setParameter('template_dir_suffix', $this->templateDirSuffix);
}
/**
* @inheritDoc
*/
public function getCacheDir()
{
return $this->getProjectDir().'/var/cache'. $this->templateDirSuffix .'/'.$this->environment;
}
}
# twig.yaml
twig:
default_path: '%kernel.project_dir%/templates%template_dir_suffix%'
# console.php
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], $_SERVER['APP_TEMPLATE_SUFFIX'] ?? '');
# index.php
$_SERVER['APP_TEMPLATE_SUFFIX'] = $_SERVER['APP_TEMPLATE_SUFFIX'] ?? (preg_match("/m.example.com/i", $_SERVER['SERVER_NAME'] ?? '') ? '_mobile' : '')
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], $_SERVER['APP_TEMPLATE_SUFFIX'] ?? '');
APP_TEMPLATE_SUFFIX=_mobile bin/console c:c
if (isset($forms['freeTrial'])) {
, добавьте для каждого поля, ну либо упростите до public function mapDataToForms($forms, &$viewData)
{
if (!$viewData instanceof PaymentCreateDTO) {
return;
}
$fields = [
'stripeProductId',
'stripePlanId',
'stripeToken',
'stripeSource',
'stripeCoupon',
'stripeSourceName',
'freeTrial',
];
/** @var FormInterface[] $forms */
$forms = iterator_to_array($forms);
foreach ($fields as $field) {
if (!isset($forms[$field])) {
continue;
}
$forms[$field]->setData($viewData->$field);
}
}
$form->handleRequest($request);
$form->submit($data);
distinct: false
?