mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°8772 - add &debug in request
This commit is contained in:
@@ -9,6 +9,8 @@ namespace Combodo\iTop\Application\TwigBase\Controller;
|
||||
|
||||
abstract class AbstractProfilerExtension implements iProfilerExtension
|
||||
{
|
||||
protected bool $bDebugForced;
|
||||
|
||||
public function Init()
|
||||
{
|
||||
}
|
||||
@@ -35,4 +37,9 @@ abstract class AbstractProfilerExtension implements iProfilerExtension
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function SetDebugForced(bool $bDebugForced): void
|
||||
{
|
||||
$this->bDebugForced = $bDebugForced;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ abstract class Controller extends AbstractController
|
||||
private ?string $sContentType = null;
|
||||
private ?string $sPageType = null;
|
||||
private bool $bDebugAllowed = true;
|
||||
protected bool $bDebugForced;
|
||||
|
||||
/**
|
||||
* Controller constructor.
|
||||
@@ -181,6 +182,7 @@ abstract class Controller extends AbstractController
|
||||
|
||||
// PHP Request object representation from PHP request globals
|
||||
$this->oRequest = Request::createFromGlobals();
|
||||
$this->bDebugForced = $this->oRequest->query->has('debug');
|
||||
|
||||
// Initialize the CSRF token manager
|
||||
$this->oCsrfTokenManager = new CsrfTokenManager();
|
||||
@@ -1021,13 +1023,14 @@ abstract class Controller extends AbstractController
|
||||
if (!in_array($sPageType, [self::ENUM_PAGE_TYPE_HTML, self::ENUM_PAGE_TYPE_AJAX, self::ENUM_PAGE_TYPE_TURBO_FORM_AJAX])) {
|
||||
return;
|
||||
}
|
||||
if (!$this->bDebugAllowed) {
|
||||
if (!$this->bDebugAllowed && !$this->bDebugForced) {
|
||||
return;
|
||||
}
|
||||
$aProfilesInfo = [];
|
||||
foreach (InterfaceDiscovery::GetInstance()->FindItopClasses(iProfilerExtension::class) as $sExtension) {
|
||||
/** @var \Combodo\iTop\Application\TwigBase\Controller\iProfilerExtension $oExtensionInstance */
|
||||
$oExtensionInstance = $sExtension::GetInstance();
|
||||
$oExtensionInstance->SetDebugForced($this->bDebugForced);
|
||||
if ($oExtensionInstance->IsEnabled()) {
|
||||
$sDebugTemplate = $oExtensionInstance->GetDebugTemplate();
|
||||
$aDebugParams = $oExtensionInstance->GetDebugParams($aParams);
|
||||
@@ -1084,7 +1087,9 @@ abstract class Controller extends AbstractController
|
||||
}
|
||||
|
||||
if ($this->sPageType === self::ENUM_PAGE_TYPE_TURBO_FORM_AJAX) {
|
||||
$this->AddToPage($this->oTwig->render('application/forms/itop_error_update.html.twig', ['sControllerError' => $sErrorMsg]));
|
||||
if (utils::IsNotNullOrEmptyString($sErrorMsg)) {
|
||||
$this->AddToPage($this->oTwig->render('application/forms/itop_error_update.html.twig', ['sControllerError' => $sErrorMsg]));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,5 @@ interface iProfilerExtension
|
||||
public function GetLinkedScripts(): null|array;
|
||||
public function GetLinkedStylesheets(): null|array;
|
||||
public function GetSaas(): null|array;
|
||||
public function SetDebugForced(bool $bDebugForced): void;
|
||||
}
|
||||
|
||||
@@ -58,11 +58,11 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm
|
||||
* @throws \Combodo\iTop\Forms\Block\FormBlockException
|
||||
*/
|
||||
public static function MakeForDashletConfiguration(string $sDashletId, string $sId = null): TurboForm
|
||||
public static function MakeForDashletConfiguration(string $sDashletId, array $aData = [], string $sId = null): TurboForm
|
||||
{
|
||||
$oBlockForm = FormBlockService::GetInstance()->GetFormBlockById($sDashletId);
|
||||
$oController = new FormsController();
|
||||
$oBuilder = $oController->GetFormBuilder($oBlockForm);
|
||||
$oBuilder = $oController->GetFormBuilder($oBlockForm, $aData);
|
||||
$oForm = $oBuilder->getForm();
|
||||
|
||||
$oTurboForm = new TurboForm($oForm->createView(), $sId);
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Combodo\iTop\Forms\Compiler;
|
||||
|
||||
use Combodo\iTop\Application\TwigBase\Controller\Controller;
|
||||
use Combodo\iTop\Forms\Block\FormBlockService;
|
||||
use Combodo\iTop\Forms\FormType\FormTypeHelper;
|
||||
use Combodo\iTop\ItopSdkFormDemonstrator\Helper\ItopSdkFormDemonstratorLog;
|
||||
use Exception;
|
||||
use IssueLog;
|
||||
@@ -49,16 +48,16 @@ class FormsController extends Controller
|
||||
return;
|
||||
}
|
||||
|
||||
$this->DisplayPage([
|
||||
'form' => $oForm->createView(),
|
||||
'sAction' => utils::GetAbsoluteUrlAppRoot().'pages/UI.php?route=forms.dashlet_configuration&dashlet_code='.urlencode($sDashletId),
|
||||
], 'itop_form');
|
||||
// $this->DisplayPage([
|
||||
// 'form' => $oForm->createView(),
|
||||
// 'sAction' => utils::GetAbsoluteUrlAppRoot().'pages/UI.php?route=forms.dashlet_configuration&dashlet_code='.urlencode($sDashletId),
|
||||
// ], 'itop_form');
|
||||
|
||||
} catch (Exception $e) {
|
||||
ItopSdkFormDemonstratorLog::Exception($e->getMessage(), $e);
|
||||
$this->DisplayPage([
|
||||
'sError' => $e->getMessage(),
|
||||
], 'itop_error');
|
||||
'sControllerError' => $e->getMessage(),
|
||||
], 'itop_error_update', Controller::ENUM_PAGE_TYPE_TURBO_FORM_AJAX);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user