mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 18:18:46 +02:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
@@ -12,34 +13,34 @@ use utils;
|
||||
|
||||
class SelectObjectValidator extends AbstractValidator
|
||||
{
|
||||
public const VALIDATOR_NAME = 'select_object_validator';
|
||||
public const VALIDATOR_NAME = 'select_object_validator';
|
||||
|
||||
/** @var \DBSearch $oSearch */
|
||||
private $oSearch;
|
||||
/** @var \DBSearch $oSearch */
|
||||
private $oSearch;
|
||||
|
||||
public function __construct(DBSearch $oSearch)
|
||||
{
|
||||
parent::__construct();
|
||||
public function __construct(DBSearch $oSearch)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->oSearch = $oSearch;
|
||||
}
|
||||
$this->oSearch = $oSearch;
|
||||
}
|
||||
|
||||
public function Validate($value): array
|
||||
{
|
||||
if (utils::IsNullOrEmptyString($value)) {
|
||||
return [];
|
||||
}
|
||||
if (($value === 0) || ($value === '0')) {
|
||||
return [];
|
||||
}
|
||||
public function Validate($value): array
|
||||
{
|
||||
if (utils::IsNullOrEmptyString($value)) {
|
||||
return [];
|
||||
}
|
||||
if (($value === 0) || ($value === '0')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$oSetForExistingCurrentValue = FieldHelper::GetObjectsSetFromSearchAndCurrentValueId($this->oSearch, $value);
|
||||
$iObjectsCount = $oSetForExistingCurrentValue->CountWithLimit(1);
|
||||
$oSetForExistingCurrentValue = FieldHelper::GetObjectsSetFromSearchAndCurrentValueId($this->oSearch, $value);
|
||||
$iObjectsCount = $oSetForExistingCurrentValue->CountWithLimit(1);
|
||||
|
||||
if ($iObjectsCount === 0) {
|
||||
return ["Value $value does not match the corresponding filter set"];
|
||||
}
|
||||
if ($iObjectsCount === 0) {
|
||||
return ["Value $value does not match the corresponding filter set"];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user