N°5655 - Introduce auto-routing mechanism for backoffice pages (Part 1)

This commit is contained in:
Molkobain
2022-11-10 10:44:51 +01:00
parent 8c14d36dfe
commit a553616ea2
9 changed files with 3965 additions and 3665 deletions

View File

@@ -10,20 +10,16 @@ namespace Combodo\iTop\Controller;
* Class AbstractController
*
* Abstract controller to centralize common features of business controllers which are still to be defined.
* Note that this can be extended by "TwigBase" controllers or standalone controllers.
*
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @package Combodo\iTop\Controller
* @since 3.1.0
*/
class AbstractController
abstract class AbstractController implements iController
{
/**
* It works if your JavaScript library sets an X-Requested-With HTTP header.
* It is known to work with common JavaScript frameworks: {@link https://wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript}
*
* @see \Symfony\Component\HttpFoundation\Request::isXmlHttpRequest() Inspired by
*
* @return bool True if the current request is an XmlHttpRequest (eg. an AJAX request)
* @inheritDoc
*/
public function IsHandlingXmlHttpRequest(): bool
{

View File

@@ -11,6 +11,7 @@ use ApplicationException;
use cmdbAbstractObject;
use CMDBObjectSet;
use Combodo\iTop\Application\UI\Base\Layout\PageContent\PageContentFactory;
use Combodo\iTop\Controller\AbstractController;
use Dict;
use iTopWebPage;
use MetaModel;
@@ -27,12 +28,9 @@ use WebPage;
* @since 3.1.0
* @package Combodo\iTop\Controller\Base\Layout
*/
class ObjectController extends \Combodo\iTop\Controller\AbstractController
class ObjectController extends AbstractController
{
public function View()
{
}
public const ROUTE_NAMESPACE = 'object';
/**
* @return \iTopWebPage|\AjaxPage Object edit form in its webpage
@@ -41,15 +39,12 @@ class ObjectController extends \Combodo\iTop\Controller\AbstractController
* @throws \CoreException
* @throws \SecurityException
*/
public function Modify()
public function OperationModify()
{
$bPrintable = utils::ReadParam('printable', '0') === '1';
$sClass = utils::ReadParam('class', '', false, 'class');
$sId = utils::ReadParam('id', '');
$sClass = 'Person';
$sId = 6;
// Check parameters
if (utils::IsNullOrEmptyString($sClass) || utils::IsNullOrEmptyString($sId))
{

View File

@@ -0,0 +1,30 @@
<?php
/*
* @copyright Copyright (C) 2010-2022 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Controller;
/**
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
* @since 3.1.0
* @package Combodo\iTop\Controller
*/
interface iController
{
/**
* @var string|null Meant for overlaoding. Route namespace, what will prefix the "route" parameter to define in which namespoce the operation is to be executed. If left to `null`, the controller will be ignored.
*/
public const ROUTE_NAMESPACE = null;
/**
* It works if your JavaScript library sets an X-Requested-With HTTP header.
* It is known to work with common JavaScript frameworks: {@link https://wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript}
*
* @see \Symfony\Component\HttpFoundation\Request::isXmlHttpRequest() Inspired by
*
* @return bool True if the current request is an XmlHttpRequest (eg. an AJAX request)
*/
public function IsHandlingXmlHttpRequest(): bool;
}