mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
- Form SDK implementation - Basic Forms - Dynamics Forms - Basic Blocks + Data Model Block - Form Compilation - Turbo integration
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?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());
|
|
}
|
|
}
|