mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 15:22:17 +02:00
🎨 refactor & fix typo
This commit is contained in:
@@ -5108,8 +5108,8 @@ abstract class DBObject implements iDisplay
|
|||||||
protected function GetReferencingObjectsForDeletion($bAllowAllData = false)
|
protected function GetReferencingObjectsForDeletion($bAllowAllData = false)
|
||||||
{
|
{
|
||||||
$aDependentObjects = [];
|
$aDependentObjects = [];
|
||||||
$aRererencingMe = MetaModel::EnumReferencingClasses(get_class($this));
|
$aReferencingMe = MetaModel::EnumReferencingClasses(get_class($this));
|
||||||
foreach ($aRererencingMe as $sRemoteClass => $aExtKeys) {
|
foreach ($aReferencingMe as $sRemoteClass => $aExtKeys) {
|
||||||
/** @var \AttributeExternalKey $oExtKeyAttDef */
|
/** @var \AttributeExternalKey $oExtKeyAttDef */
|
||||||
foreach ($aExtKeys as $sExtKeyAttCode => $oExtKeyAttDef) {
|
foreach ($aExtKeys as $sExtKeyAttCode => $oExtKeyAttDef) {
|
||||||
// skip if external key doesn't require the deletion cascading
|
// skip if external key doesn't require the deletion cascading
|
||||||
|
|||||||
@@ -32,10 +32,12 @@ class DeletionPlanService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $aClasses
|
* @param array|null $aClasses
|
||||||
*
|
*
|
||||||
* @return array<\Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanSummaryEntity>
|
* @return array<\Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanSummaryEntity>
|
||||||
* @throws \CoreException
|
* @throws \CoreException
|
||||||
|
* @throws \CoreUnexpectedValue
|
||||||
|
* @throws \MySQLException
|
||||||
*/
|
*/
|
||||||
public function GetDeletionPlanSummary(?array $aClasses): array
|
public function GetDeletionPlanSummary(?array $aClasses): array
|
||||||
{
|
{
|
||||||
@@ -44,13 +46,7 @@ class DeletionPlanService
|
|||||||
return $aSummary;
|
return $aSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oDeletionPlan = new DeletionPlan();
|
$oDeletionPlan = $this->GetDeletionPlan($aClasses);
|
||||||
foreach ($aClasses as $sClass) {
|
|
||||||
$aObjects = $this->GetAllObjects($sClass);
|
|
||||||
foreach ($aObjects as $oObject) {
|
|
||||||
$oObject->CheckToDelete($oDeletionPlan);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($oDeletionPlan->ListUpdates() as $sClass => $aUpdates) {
|
foreach ($oDeletionPlan->ListUpdates() as $sClass => $aUpdates) {
|
||||||
$oDeletionPlanSummaryEntity = new DeletionPlanSummaryEntity($sClass);
|
$oDeletionPlanSummaryEntity = new DeletionPlanSummaryEntity($sClass);
|
||||||
@@ -100,32 +96,8 @@ class DeletionPlanService
|
|||||||
*/
|
*/
|
||||||
public function ExecuteDeletionPlan(array $aClasses): array
|
public function ExecuteDeletionPlan(array $aClasses): array
|
||||||
{
|
{
|
||||||
$oDeletionPlan = new DeletionPlan();
|
$oDeletionPlan = $this->GetDeletionPlan($aClasses);
|
||||||
foreach ($aClasses as $sClass) {
|
|
||||||
$aObjects = $this->GetAllObjects($sClass);
|
|
||||||
foreach ($aObjects as $oObject) {
|
|
||||||
$oObject->CheckToDelete($oDeletionPlan);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->DoDelete($oDeletionPlan);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DeletionPlan $oDeletionPlan
|
|
||||||
*
|
|
||||||
* @return array<\Combodo\iTop\DataFeatureRemoval\Entity\DeletionPlanSummaryEntity>
|
|
||||||
* @throws \Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalException
|
|
||||||
* @throws \CoreCannotSaveObjectException
|
|
||||||
* @throws \CoreException
|
|
||||||
* @throws \CoreUnexpectedValue
|
|
||||||
* @throws \MySQLException
|
|
||||||
* @throws \MySQLHasGoneAwayException
|
|
||||||
* @throws \OQLException
|
|
||||||
*/
|
|
||||||
private function DoDelete(DeletionPlan $oDeletionPlan): array
|
|
||||||
{
|
|
||||||
if (count($oDeletionPlan->GetIssues()) > 0) {
|
if (count($oDeletionPlan->GetIssues()) > 0) {
|
||||||
throw new DataFeatureRemovalException("Deletion Plan cannot be executed due to issues");
|
throw new DataFeatureRemovalException("Deletion Plan cannot be executed due to issues");
|
||||||
}
|
}
|
||||||
@@ -173,4 +145,25 @@ class DeletionPlanService
|
|||||||
|
|
||||||
return $aSummary;
|
return $aSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $aClasses
|
||||||
|
*
|
||||||
|
* @return \DeletionPlan
|
||||||
|
* @throws \CoreException
|
||||||
|
* @throws \CoreUnexpectedValue
|
||||||
|
* @throws \MySQLException
|
||||||
|
*/
|
||||||
|
public function GetDeletionPlan(array $aClasses): DeletionPlan
|
||||||
|
{
|
||||||
|
$oDeletionPlan = new DeletionPlan();
|
||||||
|
foreach ($aClasses as $sClass) {
|
||||||
|
$aObjects = $this->GetAllObjects($sClass);
|
||||||
|
foreach ($aObjects as $oObject) {
|
||||||
|
$oObject->CheckToDelete($oDeletionPlan);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $oDeletionPlan;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user