poc form SDK (extends to form)

This commit is contained in:
Benjamin Dalsass
2023-09-01 14:32:42 +02:00
parent 20ae64706a
commit 664aa3949d
9 changed files with 155 additions and 68 deletions

View File

@@ -9,6 +9,7 @@ use DBObject;
use DBObjectSet;
use MetaModel;
use ormLinkSet;
use Symfony\Component\Stopwatch\Stopwatch;
class ObjectService
{
@@ -18,16 +19,20 @@ class ObjectService
/** @var string database name */
private string $sDbName;
/** @var \Symfony\Component\Stopwatch\Stopwatch */
private Stopwatch $oStopWatch;
/**
* Constructor.
*
* @param $sDbHost
* @param $sDbName
*/
public function __construct($sDbHost, $sDbName)
public function __construct($sDbHost, $sDbName, Stopwatch $oStopWatch)
{
$this->sDbHost = $sDbHost;
$this->sDbName = $sDbName;
$this->oStopWatch = $oStopWatch;
}
/**
@@ -61,6 +66,8 @@ class ObjectService
*/
public function ToChoices(DBObjectSet $oObjectsSet) : array
{
$this->oStopWatch->start('ToChoices');
$aChoices = [];
// Retrieve friendly name complementary specification
@@ -75,11 +82,13 @@ class ObjectService
$oObjectsSet->OptimizeColumnLoad([$oObjectsSet->GetClassAlias() => $aDefaultFieldsToLoad]);
$i = 0;
while ($i < 30 && $oObj = $oObjectsSet->Fetch()) {
while ($i < 10 && $oObj = $oObjectsSet->Fetch()) {
$aChoices[$oObj->GetName()] = $oObj->GetKey();
$i++;
}
$this->oStopWatch->stop('ToChoices');
return $aChoices;
}
@@ -143,4 +152,13 @@ class ObjectService
}
}
}
public function listConcreteChildClasses(string $sObjectClass)
{
$aChildClasses = MetaModel::EnumChildClasses($sObjectClass);
return array_filter($aChildClasses, function ($sChildClass){
return !MetaModel::IsAbstract($sChildClass);
});
}
}