mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
🎨 CS Fixer
This commit is contained in:
@@ -698,7 +698,7 @@ abstract class LogAPI
|
||||
static::Error($sMessage, $sChannel, $aContext);
|
||||
}
|
||||
|
||||
public static function Error($sMessage, $sChannel = null, $aContext = array())
|
||||
public static function Error($sMessage, $sChannel = null, $aContext = [])
|
||||
{
|
||||
static::Log(self::LEVEL_ERROR, $sMessage, $sChannel, $aContext);
|
||||
}
|
||||
|
||||
@@ -143,17 +143,13 @@ class ModelReflectionRuntime extends ModelReflection
|
||||
$aScope[] = trim($sScopeClass);
|
||||
}
|
||||
}
|
||||
$aAttributes = array();
|
||||
foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef)
|
||||
{
|
||||
$aAttributes = [];
|
||||
foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
|
||||
$oReflection = new ReflectionClass($oAttDef);
|
||||
$sAttributeClass = $oReflection->getShortName();
|
||||
if ($aScope != null)
|
||||
{
|
||||
foreach ($aScope as $sScopeClass)
|
||||
{
|
||||
if (($sAttributeClass == $sScopeClass) || is_subclass_of($sAttributeClass, $sScopeClass))
|
||||
{
|
||||
if ($aScope != null) {
|
||||
foreach ($aScope as $sScopeClass) {
|
||||
if (($sAttributeClass == $sScopeClass) || is_subclass_of($sAttributeClass, $sScopeClass)) {
|
||||
$aAttributes[$sAttCode] = $sAttributeClass;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,15 @@
|
||||
*/
|
||||
|
||||
// Input
|
||||
Dict::Add('EN US', 'English', 'English', [
|
||||
Dict::Add(
|
||||
'EN US',
|
||||
'English',
|
||||
'English',
|
||||
[
|
||||
'UI:Component:Input:ChangeNotAllowed' => 'This change is not allowed',
|
||||
'UI:Component:Input:Password:DoesNotMatch' => 'Passwords do not match',
|
||||
'UI:Component:Input:Set:MinimumItems' => 'Minimum %1$s item(s) required',
|
||||
|
||||
'UI:Component:Input:Select:Select_item' => 'Select an item...',
|
||||
]
|
||||
);
|
||||
);
|
||||
|
||||
@@ -10,11 +10,15 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Dict::Add('FR FR', 'French', 'Français', [
|
||||
Dict::Add(
|
||||
'FR FR',
|
||||
'French',
|
||||
'Français',
|
||||
[
|
||||
'UI:Component:Input:ChangeNotAllowed' => 'Cette modification n\'est pas autorisée',
|
||||
'UI:Component:Input:Password:DoesNotMatch' => 'Les mots de passe ne correspondent pas',
|
||||
'UI:Component:Input:Set:MinimumItems' => 'Minimum %1$s élément(s) requis',
|
||||
|
||||
'UI:Component:Input:Select:Select_item' => 'Sélectionnez un élément...',
|
||||
]
|
||||
);
|
||||
);
|
||||
|
||||
@@ -55,14 +55,14 @@ use ZipArchive;
|
||||
|
||||
abstract class Controller extends AbstractController
|
||||
{
|
||||
const ENUM_PAGE_TYPE_HTML = 'html';
|
||||
const ENUM_PAGE_TYPE_BASIC_HTML = 'basic_html';
|
||||
const ENUM_PAGE_TYPE_AJAX = 'ajax';
|
||||
const ENUM_PAGE_TYPE_TURBO_FORM_AJAX = 'turbo_ajax';
|
||||
const ENUM_PAGE_TYPE_SETUP = 'setup';
|
||||
public const ENUM_PAGE_TYPE_HTML = 'html';
|
||||
public const ENUM_PAGE_TYPE_BASIC_HTML = 'basic_html';
|
||||
public const ENUM_PAGE_TYPE_AJAX = 'ajax';
|
||||
public const ENUM_PAGE_TYPE_TURBO_FORM_AJAX = 'turbo_ajax';
|
||||
public const ENUM_PAGE_TYPE_SETUP = 'setup';
|
||||
|
||||
const TWIG_ERROR = 'error';
|
||||
const TWIG_WARNING = 'warning';
|
||||
public const TWIG_ERROR = 'error';
|
||||
public const TWIG_WARNING = 'warning';
|
||||
|
||||
/** @var \Twig\Environment */
|
||||
private $oTwig;
|
||||
@@ -265,8 +265,7 @@ abstract class Controller extends AbstractController
|
||||
}
|
||||
|
||||
$this->DisplayBadRequest();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
$oP = new ErrorPage(Dict::S('UI:PageTitle:FatalError'));
|
||||
$oP->add("<h1>".Dict::S('UI:FatalErrorMessage')."</h1>\n");
|
||||
@@ -298,8 +297,7 @@ abstract class Controller extends AbstractController
|
||||
}
|
||||
|
||||
$this->DisplayPageNotFound();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
$aResponse = ['sError' => $e->getMessage()];
|
||||
echo json_encode($aResponse);
|
||||
@@ -653,7 +651,7 @@ abstract class Controller extends AbstractController
|
||||
$this->SendFileContent($sArchiveFileFullPath, $sDownloadArchiveName.'.zip', true, true);
|
||||
}
|
||||
|
||||
final protected function SendFileContent($sFilePath, $sDownloadArchiveName = null, $bFileTransfer = true, $bRemoveFile = false, $aHeaders = array()): void
|
||||
final protected function SendFileContent($sFilePath, $sDownloadArchiveName = null, $bFileTransfer = true, $bRemoveFile = false, $aHeaders = []): void
|
||||
{
|
||||
$sFileMimeType = utils::GetFileMimeType($sFilePath);
|
||||
header('Content-Type: '.$sFileMimeType);
|
||||
@@ -844,8 +842,7 @@ abstract class Controller extends AbstractController
|
||||
$aErrors[self::TWIG_ERROR][] = $e->getMessage();
|
||||
|
||||
return '';
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$sExceptionMessage = $e->getMessage();
|
||||
if (str_contains($sExceptionMessage, 'at line')) {
|
||||
IssueLog::Error($sExceptionMessage);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -66,4 +67,4 @@ class TurboForm extends UIContentBlock
|
||||
{
|
||||
return $this->oFormView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -16,7 +17,7 @@ use Symfony\Component\Form\FormView;
|
||||
* @since 3.3.0
|
||||
* @package UIBlockAPI
|
||||
*/
|
||||
class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
/** @inheritDoc */
|
||||
public const TWIG_TAG_NAME = 'UITurboForm';
|
||||
@@ -33,4 +34,4 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
return new TurboForm($oFormView, $sId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -24,4 +25,4 @@ class TurboUpdate extends UIContentBlock
|
||||
{
|
||||
return $this->sTarget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -15,7 +16,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
* @since 3.3.0
|
||||
* @package UIBlockAPI
|
||||
*/
|
||||
class TurboUpdateUIBlockFactory extends AbstractUIBlockFactory
|
||||
class TurboUpdateUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
/** @inheritDoc */
|
||||
public const TWIG_TAG_NAME = 'UITurboUpdate';
|
||||
@@ -34,4 +35,4 @@ class TurboUpdateUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
return new TurboUpdate($sTarget, $sId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -424,4 +425,4 @@ abstract class AbstractFormBlock implements IFormBlock
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -43,7 +44,7 @@ abstract class AbstractTypeFormBlock extends AbstractFormBlock
|
||||
public function IsVisible(string $sEventType = null): bool
|
||||
{
|
||||
$oInput = $this->GetInput(self::INPUT_VISIBLE);
|
||||
if(!$oInput->IsBound()){
|
||||
if (!$oInput->IsBound()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,8 +88,8 @@ abstract class AbstractTypeFormBlock extends AbstractFormBlock
|
||||
{
|
||||
parent::UpdateOptions($oOptionsRegister);
|
||||
|
||||
if($this->GetInput(self::INPUT_ENABLE)->IsBound()){
|
||||
if ($this->GetInput(self::INPUT_ENABLE)->IsBound()) {
|
||||
$oOptionsRegister->SetOption('disabled', !$this->GetInputValue(self::INPUT_ENABLE));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -41,4 +42,4 @@ class CheckboxFormBlock extends AbstractTypeFormBlock
|
||||
parent::RegisterIO($oIORegister);
|
||||
$oIORegister->AddOutput(self::OUTPUT_CHECKED, BooleanIOFormat::class, new StringToBooleanConverter());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -33,4 +34,4 @@ class ChoiceFormBlock extends AbstractTypeFormBlock
|
||||
parent::RegisterIO($oIORegister);
|
||||
$oIORegister->AddOutput(self::OUTPUT_LABEL, RawFormat::class, new ChoiceValueToLabelConverter($this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -23,10 +24,10 @@ class ChoiceFromInputsBlock extends ChoiceFormBlock
|
||||
$aChoices = [];
|
||||
/** @var FormInput $oInput */
|
||||
foreach ($this->GetInputs() as $oInput) {
|
||||
if($oInput->HasValue()){
|
||||
if ($oInput->HasValue()) {
|
||||
$aChoices[strval($oInput->GetValue())] = $oInput->GetName();
|
||||
}
|
||||
}
|
||||
$oOptionsRegister->SetOption('choices', $aChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -55,7 +56,7 @@ class CollectionBlock extends AbstractTypeFormBlock
|
||||
$oOptionsRegister->SetOption('prototype', true);
|
||||
$oOptionsRegister->SetOption('allow_add', true);
|
||||
$oOptionsRegister->SetOption('prototype_options', [
|
||||
'label' => false
|
||||
'label' => false,
|
||||
]);
|
||||
|
||||
// not type options
|
||||
@@ -76,4 +77,4 @@ class CollectionBlock extends AbstractTypeFormBlock
|
||||
$oOptionsRegister->SetOption('entry_options', $this->oPrototypeBlock->GetOptions());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -28,4 +29,4 @@ class DateFormBlock extends AbstractTypeFormBlock
|
||||
parent::RegisterOptions($oOptionsRegister);
|
||||
$oOptionsRegister->SetOption('widget', 'single_text');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -28,4 +29,4 @@ class DateTimeFormBlock extends AbstractTypeFormBlock
|
||||
parent::RegisterOptions($oOptionsRegister);
|
||||
$oOptionsRegister->SetOption('widget', 'single_text');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -42,8 +43,7 @@ class FormBlock extends AbstractTypeFormBlock
|
||||
try {
|
||||
// Build the form
|
||||
$this->BuildForm();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new FormBlockException('Unable to construct form', 0, $e);
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ class FormBlock extends AbstractTypeFormBlock
|
||||
* @throws ReflectionException
|
||||
* @throws FormBlockException
|
||||
*/
|
||||
public function Add(string $sName, string $sBlockClass,array $aOptions = []): AbstractFormBlock
|
||||
public function Add(string $sName, string $sBlockClass, array $aOptions = []): AbstractFormBlock
|
||||
{
|
||||
$this->VerifyBlockName($sName);
|
||||
$this->VerifyBlockClassName($sBlockClass);
|
||||
@@ -94,7 +94,7 @@ class FormBlock extends AbstractTypeFormBlock
|
||||
*/
|
||||
private function VerifyBlockName(string $sBlockName): void
|
||||
{
|
||||
if(!ctype_alnum(str_replace(array('-', '_'), '', $sBlockName))) {
|
||||
if (!ctype_alnum(str_replace(['-', '_'], '', $sBlockName))) {
|
||||
throw new FormBlockException("Block name '$sBlockName' is not valid. Only alphanumeric characters, hyphens and underscores are allowed.");
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class FormBlock extends AbstractTypeFormBlock
|
||||
private function VerifyBlockClassName(string $sBlockClass): void
|
||||
{
|
||||
$oRef = new ReflectionClass($sBlockClass);
|
||||
if($oRef->isSubclassOf(AbstractFormBlock::class) === false){
|
||||
if ($oRef->isSubclassOf(AbstractFormBlock::class) === false) {
|
||||
throw new FormBlockException("The block type '$sBlockClass' is not a subclass of AbstractFormBlock.");
|
||||
}
|
||||
}
|
||||
@@ -162,4 +162,4 @@ class FormBlock extends AbstractTypeFormBlock
|
||||
{
|
||||
return $this->oDependencyMap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -21,4 +22,4 @@ class IntegerFormBlock extends AbstractTypeFormBlock
|
||||
return IntegerType::class;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -21,4 +22,4 @@ class TextAreaFormBlock extends AbstractTypeFormBlock
|
||||
return TextareaType::class;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -21,5 +22,4 @@ class TextFormBlock extends AbstractTypeFormBlock
|
||||
return TextType::class;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -49,7 +50,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
|
||||
$oClass = $this->GetInputValue(self::INPUT_CLASS_NAME);
|
||||
|
||||
if($oClass === null){
|
||||
if ($oClass === null) {
|
||||
$oOptionsRegister->SetOption('choices', []);
|
||||
return;
|
||||
}
|
||||
@@ -57,7 +58,7 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
$aAttributeCodes = MetaModel::GetAttributesList($oClass);
|
||||
|
||||
$aAttributes = [];
|
||||
foreach ($aAttributeCodes as $sAttributeCode){
|
||||
foreach ($aAttributeCodes as $sAttributeCode) {
|
||||
$oAttribute = MetaModel::GetAttributeDef(strval($oClass), $sAttributeCode);
|
||||
$aAttributes[$oAttribute->GetLabel()] = $sAttributeCode;
|
||||
}
|
||||
@@ -65,4 +66,4 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
$oOptionsRegister->SetOption('choices', $aAttributes);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -63,10 +64,9 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
|
||||
$aValues = $oAttDef->GetAllowedValues();
|
||||
|
||||
$oOptionsRegister->SetOption('choices', array_flip($aValues ?? []));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new FormBlockException('Update option failed for '.json_encode($this->GetName()), 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -43,5 +44,4 @@ class OqlFormBlock extends TextAreaFormBlock
|
||||
$oIORegister->AddOutput(self::OUTPUT_SELECTED_CLASS, ClassIOFormat::class, new OqlToClassConverter());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -22,8 +23,8 @@ class ExpressionFormBlock extends AbstractFormBlock
|
||||
public const EXPRESSION_PATTERN = "/:(?<input>\w+)/";
|
||||
|
||||
// Outputs
|
||||
const OUTPUT_RESULT = "result";
|
||||
const OUTPUT_RESULT_INVERT = "result_invert";
|
||||
public const OUTPUT_RESULT = "result";
|
||||
public const OUTPUT_RESULT_INVERT = "result_invert";
|
||||
|
||||
/** @inheritdoc */
|
||||
protected function RegisterIO(IORegister $oIORegister): void
|
||||
@@ -54,7 +55,7 @@ class ExpressionFormBlock extends AbstractFormBlock
|
||||
public function ComputeExpression(string $sEventType): void
|
||||
{
|
||||
$sExpression = '';
|
||||
try{
|
||||
try {
|
||||
$sExpression = $this->GetOption('expression');
|
||||
|
||||
$oExpression = Expression::FromOQL($sExpression);
|
||||
@@ -69,10 +70,9 @@ class ExpressionFormBlock extends AbstractFormBlock
|
||||
$this->GetOutput(self::OUTPUT_RESULT)->SetValue($sEventType, new BooleanIOFormat($bResult));
|
||||
$this->GetOutput(self::OUTPUT_RESULT_INVERT)->SetValue($sEventType, new BooleanIOFormat(!$bResult));
|
||||
$this->GetOutput(self::OUTPUT_VALUE)->SetValue($sEventType, new RawFormat($result));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
throw new FormBlockException('Compute expression '.json_encode($sExpression).' block issue', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -10,5 +11,4 @@ use Combodo\iTop\Forms\FormsException;
|
||||
|
||||
class FormBlockException extends FormsException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -140,8 +141,7 @@ class DependencyHandler
|
||||
// Compute the block outputs with the data
|
||||
try {
|
||||
$oFormBlock->ComputeOutputs($sEventType, $oForm->getData());
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$oForm->addError(new FormError($e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -235,4 +235,4 @@ class DependencyHandler
|
||||
'value' => $oValue,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -59,15 +60,15 @@ class DependencyMap
|
||||
foreach ($oDependentBlock->GetBoundInputsBindings() as $oBinding) {
|
||||
|
||||
// OUT > IN
|
||||
if($oBinding->oSourceIO instanceof FormOutput
|
||||
&& $oBinding->oDestinationIO instanceof FormInput){
|
||||
if ($oBinding->oSourceIO instanceof FormOutput
|
||||
&& $oBinding->oDestinationIO instanceof FormInput) {
|
||||
$this->AddBindingToMap($this->aBindingsOutputToInput, $oBinding);
|
||||
$this->AddToBlockImpactedBy($oBinding->oSourceIO->GetOwnerBlock()->GetName(), $oDependentBlock);
|
||||
}
|
||||
|
||||
// IN > IN
|
||||
if($oBinding->oSourceIO instanceof FormInput
|
||||
&& $oBinding->oDestinationIO instanceof FormInput){
|
||||
if ($oBinding->oSourceIO instanceof FormInput
|
||||
&& $oBinding->oDestinationIO instanceof FormInput) {
|
||||
$this->AddBindingToMap($this->aBindingsInputToInput, $oBinding);
|
||||
}
|
||||
|
||||
@@ -77,8 +78,8 @@ class DependencyMap
|
||||
foreach ($oDependentBlock->GetBoundOutputBindings() as $oBinding) {
|
||||
|
||||
// OUT > OUT
|
||||
if($oBinding->oSourceIO instanceof FormOutput
|
||||
&& $oBinding->oDestinationIO instanceof FormOutput){
|
||||
if ($oBinding->oSourceIO instanceof FormOutput
|
||||
&& $oBinding->oDestinationIO instanceof FormOutput) {
|
||||
$this->AddBindingToMap($this->aBindingsOutputToOutputs, $oBinding);
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ class DependencyMap
|
||||
private function AddToBlockImpactedBy(string $sDependsOnName, AbstractFormBlock $oImpactedBlock): void
|
||||
{
|
||||
// Initialize array for this dependence
|
||||
if(!array_key_exists($sDependsOnName, $this->aBlocksImpactedBy)){
|
||||
if (!array_key_exists($sDependsOnName, $this->aBlocksImpactedBy)) {
|
||||
$this->aBlocksImpactedBy[$sDependsOnName] = [];
|
||||
}
|
||||
|
||||
@@ -131,9 +132,9 @@ class DependencyMap
|
||||
$this->aBlocksImpactedBy[$sDependsOnName][$oImpactedBlock->GetName()] = $oImpactedBlock;
|
||||
|
||||
// TODO
|
||||
if($oImpactedBlock instanceof ExpressionFormBlock){
|
||||
foreach($oImpactedBlock->GetOutputs() as $oOutput){
|
||||
foreach($oOutput->GetBindings() as $oBinding){
|
||||
if ($oImpactedBlock instanceof ExpressionFormBlock) {
|
||||
foreach ($oImpactedBlock->GetOutputs() as $oOutput) {
|
||||
foreach ($oOutput->GetBindings() as $oBinding) {
|
||||
$this->AddToBlockImpactedBy($sDependsOnName, $oBinding->oDestinationIO->GetOwnerBlock());
|
||||
}
|
||||
}
|
||||
@@ -148,10 +149,10 @@ class DependencyMap
|
||||
$aResult = [];
|
||||
|
||||
// Iterate throw binding OUT > IN
|
||||
foreach(array_keys($this->aBindingsOutputToInput) as $sOutputBlockName) {
|
||||
foreach (array_keys($this->aBindingsOutputToInput) as $sOutputBlockName) {
|
||||
|
||||
// Exclude block containing dependencies
|
||||
if(!array_key_exists($sOutputBlockName, $this->aBlocksWithDependencies)){
|
||||
if (!array_key_exists($sOutputBlockName, $this->aBlocksWithDependencies)) {
|
||||
$aResult[] = $sOutputBlockName;
|
||||
}
|
||||
}
|
||||
@@ -170,13 +171,13 @@ class DependencyMap
|
||||
*/
|
||||
public function GetBlocksImpactedBy(string $sBlockName, callable $oFilter = null): ?array
|
||||
{
|
||||
if(!array_key_exists($sBlockName, $this->aBlocksImpactedBy)){
|
||||
if (!array_key_exists($sBlockName, $this->aBlocksImpactedBy)) {
|
||||
return null;
|
||||
}
|
||||
$aBlocks = $this->aBlocksImpactedBy[$sBlockName];
|
||||
|
||||
// Filtering
|
||||
if($oFilter !== null){
|
||||
if ($oFilter !== null) {
|
||||
$aBlocks = array_filter($aBlocks, $oFilter);
|
||||
}
|
||||
|
||||
@@ -234,4 +235,4 @@ class DependencyMap
|
||||
{
|
||||
return $this->aBindings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -525,4 +526,4 @@ class FormBuilder implements FormBuilderInterface, IteratorAggregate
|
||||
{
|
||||
return $this->builder->getIsEmptyCallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -10,5 +11,4 @@ use Combodo\iTop\Forms\FormsException;
|
||||
|
||||
class FormBuilderException extends FormsException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ class FormHelper
|
||||
{
|
||||
if ($event instanceof PostSetDataEvent) {
|
||||
return FormEvents::POST_SET_DATA;
|
||||
} else if ($event instanceof PostSubmitEvent) {
|
||||
} elseif ($event instanceof PostSubmitEvent) {
|
||||
return FormEvents::POST_SUBMIT;
|
||||
} else if ($event instanceof PreSubmitEvent) {
|
||||
} elseif ($event instanceof PreSubmitEvent) {
|
||||
return FormEvents::PRE_SUBMIT;
|
||||
}
|
||||
|
||||
@@ -48,4 +48,4 @@ class FormHelper
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -20,7 +21,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
*/
|
||||
class FormTypeExtension extends AbstractTypeExtension
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
public static function getExtendedTypes(): iterable
|
||||
{
|
||||
@@ -58,4 +58,4 @@ class FormTypeExtension extends AbstractTypeExtension
|
||||
$view->vars['trigger_form_submit_on_modify'] = $oFormBlock->ImpactDependentsBlocks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -19,4 +20,4 @@ class ResolvedFormType extends SymfonyResolvedFormType implements ResolvedFormTy
|
||||
|
||||
return new FormBuilder($builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -19,4 +20,4 @@ class ResolvedFormTypeFactory implements ResolvedFormTypeFactoryInterface
|
||||
{
|
||||
return new ResolvedFormType($type, $typeExtensions, $parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -55,7 +56,7 @@ class ChoiceFormType extends AbstractType
|
||||
});
|
||||
|
||||
// on pre submit (prior)
|
||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $oEvent) use ($options){
|
||||
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (PreSubmitEvent $oEvent) use ($options) {
|
||||
|
||||
// reset value if not in available choices
|
||||
if (!empty($oEvent->getData()) && !$this->CheckValue($oEvent->getData(), $options)) {
|
||||
@@ -119,5 +120,4 @@ class ChoiceFormType extends AbstractType
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -41,4 +42,4 @@ class CollectionFormType extends AbstractType
|
||||
$view->vars['button_label'] = $options['button_label'];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -16,7 +17,7 @@ use Symfony\Component\Form\FormView;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class FormType extends AbstractType
|
||||
class FormType extends AbstractType
|
||||
{
|
||||
/** @inheritdoc */
|
||||
public function getParent(): string
|
||||
@@ -33,23 +34,22 @@ class FormType extends AbstractType
|
||||
$oBlock = $options['form_block'];
|
||||
|
||||
$aData = [];
|
||||
foreach($oBlock->GetChildren() as $oChild) {
|
||||
foreach ($oBlock->GetChildren() as $oChild) {
|
||||
if (!$oChild instanceof AbstractTypeFormBlock) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($oChild->IsAdded()){
|
||||
if ($oChild->IsAdded()) {
|
||||
$aData[] = [
|
||||
'name' => $oChild->GetName(),
|
||||
'added' => $oChild->IsAdded(),
|
||||
'id' => FormTypeHelper::GetFormId($form) . '_' . $oChild->GetName()
|
||||
'id' => FormTypeHelper::GetFormId($form).'_'.$oChild->GetName(),
|
||||
];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$aData[] = [
|
||||
'name' => $oChild->GetName(),
|
||||
'added' => $oChild->IsAdded(),
|
||||
'id' => FormTypeHelper::GetFormId($form) . '_' . $oChild->GetName()
|
||||
'id' => FormTypeHelper::GetFormId($form).'_'.$oChild->GetName(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -57,4 +57,4 @@ class FormType extends AbstractType
|
||||
$view->vars['blocks'] = $aData;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -29,7 +30,7 @@ class OqlFormType extends AbstractType
|
||||
'placeholder' => 'SELECT Contact',
|
||||
]);
|
||||
|
||||
$resolver->setDefault('outputs', array(
|
||||
$resolver->setDefault('outputs', [
|
||||
'selected_class' => function ($oData) {
|
||||
if ($oData === null) {
|
||||
return null;
|
||||
@@ -39,7 +40,7 @@ class OqlFormType extends AbstractType
|
||||
|
||||
return $aMatches[1] ?? null;
|
||||
},
|
||||
));
|
||||
]);
|
||||
|
||||
$resolver->setDefined('with_ai_button');
|
||||
}
|
||||
@@ -51,4 +52,4 @@ class OqlFormType extends AbstractType
|
||||
|
||||
$view->vars['with_ai_button'] = $options['with_ai_button'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -14,7 +15,6 @@ use Symfony\Component\Form\FormInterface;
|
||||
*/
|
||||
class FormTypeHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* @param FormInterface $oForm
|
||||
*
|
||||
@@ -61,10 +61,9 @@ class FormTypeHelper
|
||||
$aImpacted = $oMap->GetBlocksImpactedBy($oBlockTurboTrigger->GetName());
|
||||
foreach ($aImpacted as $oImpactedBlock) {
|
||||
$sName = $sParentName.'_'.$oImpactedBlock->GetName();
|
||||
if($oParent->has($oImpactedBlock->GetName())){
|
||||
if ($oParent->has($oImpactedBlock->GetName())) {
|
||||
$aBlocksToRedraw[$sName] = $oParent->get($oImpactedBlock->GetName())->createView();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$aBlocksToRedraw[$sName] = null;
|
||||
}
|
||||
|
||||
@@ -90,5 +89,4 @@ class FormTypeHelper
|
||||
return $oForm;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -43,4 +44,4 @@ final class Forms
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -17,4 +18,4 @@ class FormsException extends Exception
|
||||
parent::__construct($sMessage, $iCode, $oPrevious);
|
||||
IssueLog::Exception(get_class($this).' occurs: '.$sMessage, $this, null, $aContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,4 @@ namespace Combodo\iTop\Forms;
|
||||
|
||||
interface IFormBlock
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -278,4 +279,4 @@ class AbstractFormIO
|
||||
return $this->aBindingsToInputs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -19,4 +20,4 @@ abstract class AbstractConverter
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function Convert(mixed $oData): mixed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -24,7 +25,7 @@ class ChoiceValueToLabelConverter extends AbstractConverter
|
||||
/** @inheritdoc */
|
||||
public function Convert(mixed $oData): ?RawFormat
|
||||
{
|
||||
if(is_null($oData) || is_array($oData)){
|
||||
if (is_null($oData) || is_array($oData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -32,4 +33,4 @@ class ChoiceValueToLabelConverter extends AbstractConverter
|
||||
|
||||
return new RawFormat($aOptions[$oData]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -39,6 +40,5 @@ class OqlToClassConverter extends AbstractConverter
|
||||
throw new FormBlockIOException('Incorrect OQL sentence '.json_encode($oData));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -22,4 +23,4 @@ class StringToAttributeConverter extends AbstractConverter
|
||||
|
||||
return new AttributeIOFormat($oData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -16,6 +17,6 @@ class StringToBooleanConverter extends AbstractConverter
|
||||
/** @inheritdoc */
|
||||
public function Convert(mixed $oData): ?BooleanIOFormat
|
||||
{
|
||||
return new BooleanIOFormat($oData );
|
||||
return new BooleanIOFormat($oData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -37,4 +38,4 @@ class FormBinding
|
||||
$this->oDestinationIO->SetValues($this->oSourceIO->GetValues());
|
||||
$this->oDestinationIO->GetOwnerBlock()->BindingReceivedEvent($this->oDestinationIO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -10,5 +11,4 @@ use Combodo\iTop\Forms\FormsException;
|
||||
|
||||
class FormBlockIOException extends FormsException
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -57,4 +58,4 @@ class FormInput extends AbstractFormIO
|
||||
$oBinding->PropagateValues();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -80,7 +81,6 @@ class FormOutput extends AbstractFormIO
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind to output.
|
||||
*
|
||||
@@ -138,4 +138,4 @@ class FormOutput extends AbstractFormIO
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ class AttributeIOFormat implements JsonSerializable
|
||||
{
|
||||
return $this->sAttributeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ class BooleanIOFormat implements JsonSerializable
|
||||
{
|
||||
return $this->bValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,4 +23,4 @@ class ClassIOFormat implements JsonSerializable
|
||||
{
|
||||
return $this->sClassName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ class NumberIOFormat
|
||||
{
|
||||
return $this->oValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ class RawFormat
|
||||
{
|
||||
return strval($this->sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -313,4 +314,4 @@ class IORegister
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,4 +7,4 @@ class Option
|
||||
public function __construct(public string $sName, public mixed $oValue, public bool $bIsTypeOption = true)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -28,10 +29,9 @@ class OptionsRegister
|
||||
{
|
||||
$this->VerifyOptionName($sOptionName);
|
||||
|
||||
if(isset($this->aOptions[$sOptionName])){
|
||||
if (isset($this->aOptions[$sOptionName])) {
|
||||
$this->aOptions[$sOptionName]->oValue = $mDefaultValue;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->aOptions[$sOptionName] = new Option($sOptionName, $mDefaultValue, $bTypeOption);
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class OptionsRegister
|
||||
*/
|
||||
private function VerifyOptionName(string $sOptionName): void
|
||||
{
|
||||
if(!ctype_alnum(str_replace(array('-', '_'), '', $sOptionName))) {
|
||||
if (!ctype_alnum(str_replace(['-', '_'], '', $sOptionName))) {
|
||||
throw new RegisterException("Option name '$sOptionName' is not valid. Only alphanumeric characters, hyphens and underscores are allowed.");
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class OptionsRegister
|
||||
public function SetOptionArrayValue(string $sOptionName, string $sArrayKey, mixed $mDefaultValue = null): void
|
||||
{
|
||||
// Initialization of the option as an array if not set
|
||||
if(!isset($this->aOptions[$sOptionName])){
|
||||
if (!isset($this->aOptions[$sOptionName])) {
|
||||
$this->SetOption($sOptionName, []);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class OptionsRegister
|
||||
public function GetOptions(): array
|
||||
{
|
||||
$aOptions = array_filter($this->aOptions, fn ($oElement) => $oElement->bIsTypeOption);
|
||||
return array_map( fn ($oElement) => $oElement->oValue, $aOptions);
|
||||
return array_map(fn ($oElement) => $oElement->oValue, $aOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,4 +102,4 @@ class OptionsRegister
|
||||
{
|
||||
return array_key_exists($sOption, $this->aOptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -15,4 +16,4 @@ class RegisterException extends Exception
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\sources\Forms;
|
||||
|
||||
use Combodo\iTop\Forms\Block\AbstractFormBlock;
|
||||
@@ -42,7 +44,7 @@ abstract class AbstractFormsTest extends ItopDataTestCase
|
||||
$oBlock->AddInput($aIO['name'], $aIO['data_type']);
|
||||
} else {
|
||||
if (isset($aIO['converter_class'])) {
|
||||
$oBlock->AddOutput($aIO['name'], $aIO['data_type'], new $aIO['converter_class']);
|
||||
$oBlock->AddOutput($aIO['name'], $aIO['data_type'], new $aIO['converter_class']());
|
||||
} else {
|
||||
$oBlock->AddOutput($aIO['name'], $aIO['data_type']);
|
||||
}
|
||||
@@ -51,4 +53,4 @@ abstract class AbstractFormsTest extends ItopDataTestCase
|
||||
|
||||
return $oBlock;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -26,7 +27,6 @@ use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
*/
|
||||
class BlockTest extends ItopDataTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Block get form type must return a class derived from Symfony form AbstractType.
|
||||
*
|
||||
@@ -36,8 +36,8 @@ class BlockTest extends ItopDataTestCase
|
||||
{
|
||||
$aFormBlocks = InterfaceDiscovery::GetInstance()->FindItopClasses(iFormBlock::class);
|
||||
foreach ($aFormBlocks as $sFormBlock) {
|
||||
$oChoiceBlock = new($sFormBlock)($sFormBlock);
|
||||
if($oChoiceBlock instanceof AbstractTypeFormBlock){
|
||||
$oChoiceBlock = new ($sFormBlock)($sFormBlock);
|
||||
if ($oChoiceBlock instanceof AbstractTypeFormBlock) {
|
||||
$oClass = new \ReflectionClass($oChoiceBlock->GetFormType());
|
||||
$this->assertTrue($oClass->isSubclassOf(AbstractType::class));
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class BlockTest extends ItopDataTestCase
|
||||
{
|
||||
$aFormBlocks = InterfaceDiscovery::GetInstance()->FindItopClasses(iFormBlock::class);
|
||||
foreach ($aFormBlocks as $sFormBlock) {
|
||||
$oChoiceBlock = new($sFormBlock)($sFormBlock);
|
||||
$oChoiceBlock = new ($sFormBlock)($sFormBlock);
|
||||
$this->assertTrue($oChoiceBlock->GetOption('form_block') === $oChoiceBlock);
|
||||
}
|
||||
}
|
||||
@@ -110,4 +110,4 @@ class BlockTest extends ItopDataTestCase
|
||||
$this->expectException(OutOfBoundsException::class);
|
||||
$oForm->get('birthdate');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Forms;
|
||||
|
||||
use Combodo\iTop\Forms\Block\Base\CheckboxFormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\ChoiceFormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\Forms\Block\Base\TextFormBlock;
|
||||
use Combodo\iTop\Forms\Block\FormBlockException;
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use ReflectionException;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
|
||||
class BlockIO extends ItopDataTestCase
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -10,6 +11,4 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
|
||||
class Builder extends ItopDataTestCase
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -12,7 +13,6 @@ use Symfony\Component\Form\FormEvents;
|
||||
|
||||
class AbstractFormIOTest extends AbstractFormsTest
|
||||
{
|
||||
|
||||
public function testFormIoHasNoDataAtCreation()
|
||||
{
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -149,4 +150,4 @@ class FormBindingTest extends AbstractFormsTest
|
||||
$this->assertEquals('The Value', $oOutputIO1->GetValue(FormEvents::PRE_SET_DATA));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
@@ -50,4 +51,4 @@ class OptionsRegisterTest extends ItopDataTestCase
|
||||
$this->assertTrue($this->oOptionsRegister->HasOption('option'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user