Tengo un Bundle externo que renderiza vistas básicas y hay la necesidad de mejorarlas. Existe una manera de reutilizar los controladores cambiando unicamente la vista sin tener que literalmente copiarlos y pegarlos? algo así como un extend, quiero reutilizar la lógica y las variables cambiando solamente la vista.
Tengo estos dos controladores
<!-- language: lang-php --> <?php
# Metodo de Controlador dentro de un Bundle externo en /vendor/{vendor-name}/front-core-bundle/src/FrontCoreBundle/Controller/NameController.php
public function homeAction()
{
$vamsUtilsPurchase = $this->get('front_core.vams.utils.purchase');
$vamsSDK = $this->get('front_core.vams_sdk');
$notificator = $this->get('front_core.notificator.flash');
$translator = $this->get('front_core.translator');
$unitsSummary = $vamsSDK->getUsersModule()->getUserUnitsSummary($vamsUtilsPurchase->unitsType());
$coupons = null;
try {
$coupons = $vamsSDK->getPurchasesModule()->getMyCoupons(1, 5, 0);
} catch (\Throwable $t) {
$notificator->error(
$translator->trans('vams.error_' . $t->getCode(), [], self::DEFAULT_TRANSLATION_ERROR)
);
}
try {
$purchasesResult = $vamsSDK->getPurchasesModule()->getMyPurchases(1, 4, 'withtracking');
} catch (\Throwable $t) {
$notificator->error(
$translator->trans('vams.error_' . $t->getCode(), [], self::DEFAULT_TRANSLATION_ERROR)
);
} catch (\Exception $e) {
throw $e;
}
$this->breadcrumb->appendItem('dashboard');
return $this->render(
'@FrontCore/template/private/home.html.twig',
[
'summary' => $unitsSummary,
'purchases' => $purchasesResult['purchases'],
'coupons' => $coupons['coupons'],
'user' => $vamsSDK->getUsersModule()->me()->getFields(),
'check_voucher_form' => $this->createForm(CheckVoucherType::class)->createView(),
]
);
}
quiero usar el anterior de una manera similar a esta:
<!-- language: lang-php --> <?php
# Metodo de Controlador propio
public function homeAction(){
return $this->render('otravista.html.twig',
[
'summary' => $unitsSummary,
'purchases' => $purchasesResult['purchases'],
'coupons' => $coupons['coupons'],
'user' => $vamsSDK->getUsersModule()->me()->getFields(),
'check_voucher_form' => $this->createForm(CheckVoucherType::class)->createView(),
]);
}