. */ namespace App\Services\LogSystem; use App\Entity\Attachments\AttachmentContainingDBElement; use App\Entity\Base\AbstractDBElement; use App\Entity\Base\AbstractStructuralDBElement; use App\Entity\Parameters\AbstractParameter; use App\Entity\Parts\Part; class HistoryHelper { public function __construct() { } /** * Returns an array containing all elements that are associated with the argument. * The returned array contains the given element. * * @psalm-return array */ public function getAssociatedElements(AbstractDBElement $element): array { $array = [$element]; if ($element instanceof AttachmentContainingDBElement) { $array = array_merge($array, $element->getAttachments()->toArray()); } if ($element instanceof Part) { $array = array_merge( $array, $element->getPartLots()->toArray(), $element->getOrderdetails()->toArray() ); foreach ($element->getOrderdetails() as $orderdetail) { $array = array_merge($array, $orderdetail->getPricedetails()->toArray()); } } if ($element instanceof Part || $element instanceof AbstractStructuralDBElement) { $array = array_merge($array, $element->getParameters()->toArray()); } return $array; } }