mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
Prepare property service for form block dashboard
This commit is contained in:
@@ -76,6 +76,24 @@ class PropertyTypeCompiler
|
||||
return file_get_contents($sPath);
|
||||
}
|
||||
|
||||
public function ListPropertyTypesByType(string $sType)
|
||||
{
|
||||
$sPath = utils::GetAbsoluteModulePath('core')."property_types/$sType";
|
||||
if (!is_dir($sPath)) {
|
||||
throw new PropertyTypeCompilerException("Properties types folder $sType not present");
|
||||
}
|
||||
|
||||
$aFiles = scandir($sPath);
|
||||
$aPropertyTypes = [];
|
||||
foreach ($aFiles as $sFile) {
|
||||
if (is_file("$sPath/$sFile") && pathinfo($sFile, PATHINFO_EXTENSION) === 'xml') {
|
||||
$aPropertyTypes[] = basename($sFile, ".xml");
|
||||
}
|
||||
}
|
||||
|
||||
return $aPropertyTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile XML property tree into PHP to create the configuration form
|
||||
*
|
||||
@@ -108,4 +126,6 @@ class PropertyTypeCompiler
|
||||
|
||||
return $this->CompileFormFromXML($sXMLContent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use Combodo\iTop\Forms\Block\Base\FormBlock;
|
||||
use Combodo\iTop\Forms\Block\FormBlockException;
|
||||
use Combodo\iTop\Forms\Block\FormBlockService;
|
||||
use Combodo\iTop\PropertyType\Compiler\PropertyTypeCompiler;
|
||||
use Combodo\iTop\PropertyType\Compiler\PropertyTypeCompilerException;
|
||||
use Combodo\iTop\Service\Cache\DataModelDependantCache;
|
||||
use utils;
|
||||
|
||||
@@ -40,10 +41,10 @@ class PropertyTypeService
|
||||
* @param string $sId name of the form to retrieve
|
||||
* @param string $sType
|
||||
*
|
||||
* @return \Combodo\iTop\Forms\Block\Base\FormBlock
|
||||
* @throws \Combodo\iTop\Forms\Block\FormBlockException
|
||||
* @throws \Combodo\iTop\PropertyType\Compiler\PropertyTypeCompilerException
|
||||
* @throws \Combodo\iTop\PropertyType\PropertyTypeException
|
||||
* @return FormBlock
|
||||
* @throws FormBlockException
|
||||
* @throws PropertyTypeCompilerException
|
||||
* @throws PropertyTypeException
|
||||
* @throws \DOMFormatException
|
||||
*/
|
||||
public function GetFormBlockById(string $sId, string $sType): FormBlock
|
||||
@@ -62,11 +63,24 @@ class PropertyTypeService
|
||||
return new $sFormBlockClass($sFilteredId);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all property types for a given type.
|
||||
*
|
||||
* @param string $sType
|
||||
*
|
||||
* @return array
|
||||
* @throws PropertyTypeCompilerException
|
||||
*/
|
||||
public function ListPropertyTypesByType(string $sType): array
|
||||
{
|
||||
return PropertyTypeCompiler::GetInstance()->ListPropertyTypesByType($sType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sId
|
||||
*
|
||||
* @return string
|
||||
* @throws \Combodo\iTop\Forms\Block\FormBlockException
|
||||
* @throws FormBlockException
|
||||
*/
|
||||
private function SanitizeId(string $sId): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user