mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 03:58:45 +02:00
N°8771 - Add Symfony form component to iTop core
- IO debug
This commit is contained in:
41
sources/Forms/Block/IO/Converter/OqlToClassConverter.php
Normal file
41
sources/Forms/Block/IO/Converter/OqlToClassConverter.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Forms\Block\IO\Converter;
|
||||
|
||||
use Combodo\iTop\Forms\Block\IO\Format\ClassIOFormat;
|
||||
use MetaModel;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
|
||||
/**
|
||||
* OQL expression to class converter.
|
||||
*/
|
||||
class OqlToClassConverter extends AbstractConverter
|
||||
{
|
||||
/** @inheritdoc */
|
||||
public function Convert(mixed $oData): ?ClassIOFormat
|
||||
{
|
||||
if($oData === null)
|
||||
return null;
|
||||
|
||||
// Extract OQL information
|
||||
preg_match('/SELECT\s+(\w+)/', $oData, $aMatches);
|
||||
|
||||
// Selected class
|
||||
if(isset($aMatches[1])){
|
||||
$sSelectedClass = $aMatches[1];
|
||||
if(!MetaModel::IsValidClass($sSelectedClass)){
|
||||
throw new IOException('Incorrect OQL select class name ' . $sSelectedClass);
|
||||
}
|
||||
return new ClassIOFormat($aMatches[1]);
|
||||
}
|
||||
else{
|
||||
throw new IOException('Incorrect OQL sentence');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user