N°6043 - Booking: Add prerequisites in iTop core - CRUD extensibility (#520)

This commit is contained in:
bdalsass
2023-07-04 16:22:53 +02:00
committed by GitHub
parent 40dc3deabb
commit 9d38b4d1d6
28 changed files with 1665 additions and 123 deletions

View File

@@ -6,6 +6,7 @@
namespace Combodo\iTop\Service\Base;
use cmdbAbstractObject;
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
use DBObject;
use DBObjectSearch;
@@ -299,4 +300,40 @@ class ObjectRepository
return ObjectRepository::ComputeOthersData($oObject, $sObjectClass, $aObjectData, $aComplementAttributeSpec, $sObjectImageAttCode);
}
/**
* DeleteFromOql.
*
* @param string $sOql OQL expression
*
* @return bool
*/
static public function DeleteFromOql(string $sOql): bool
{
try {
// Create db search
$oDbObjectSearch = DBSearch::FromOQL($sOql);
// Create db set from db search
$oDbObjectSet = new DBObjectSet($oDbObjectSearch);
// Delete objects
while ($oObject = $oDbObjectSet->Fetch()) {
$oObject->DBDelete();
}
// return operation success
return true;
}
catch (Exception $e) {
ExceptionLog::LogException($e);
return false;
}
}
}