mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-30 14:08:46 +02:00
N°8772 - Form dependencies manager implementation
- Form SDK implementation - Basic Forms - Dynamics Forms - Basic Blocks + Data Model Block - Form Compilation - Turbo integration
This commit is contained in:
44
sources/Forms/IO/Converter/OqlToClassConverter.php
Normal file
44
sources/Forms/IO/Converter/OqlToClassConverter.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Forms\IO\Converter;
|
||||
|
||||
use Combodo\iTop\Service\DependencyInjection\DIException;
|
||||
use Combodo\iTop\Service\DependencyInjection\DIService;
|
||||
use Combodo\iTop\Forms\IO\Format\ClassIOFormat;
|
||||
use Combodo\iTop\Forms\IO\FormBlockIOException;
|
||||
use Exception;
|
||||
use ModelReflection;
|
||||
|
||||
/**
|
||||
* Extract the selected class from an OQL query.
|
||||
*
|
||||
* @package Combodo\iTop\Forms\IO\Converter
|
||||
* @since 3.3.0
|
||||
*/
|
||||
class OqlToClassConverter extends AbstractConverter
|
||||
{
|
||||
/** @inheritdoc
|
||||
* @throws DIException
|
||||
* @throws FormBlockIOException
|
||||
*/
|
||||
public function Convert(mixed $oData): ?ClassIOFormat
|
||||
{
|
||||
if ($oData === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var ModelReflection $oModelReflection */
|
||||
$oModelReflection = DIService::GetInstance()->GetService('ModelReflection');
|
||||
try {
|
||||
$oQuery = $oModelReflection->GetQuery($oData);
|
||||
} catch (Exception $e) {
|
||||
throw new FormBlockIOException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
return new ClassIOFormat($oQuery->GetClass());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user