mirror of
https://github.com/ToxicCrack/PrintABrick.git
synced 2025-05-16 04:10:09 -07:00
Update ModelLoader.php
Added iteration counter for parent models
This commit is contained in:
parent
4d0cc7cebc
commit
0255e0b71d
@ -215,8 +215,12 @@ class ModelLoader extends BaseLoader
|
||||
*
|
||||
* @return Model|null|false
|
||||
*/
|
||||
public function loadModel($file)
|
||||
public function loadModel($file, $iteration=0)
|
||||
{
|
||||
if($iteration >= 20) {
|
||||
$this->logger->error("Too many submodels. Skipping", [$file]);
|
||||
return false;
|
||||
}
|
||||
/** @var ModelRepository $modelRepository */
|
||||
$modelRepository = $this->em->getRepository(Model::class);
|
||||
|
||||
@ -238,7 +242,7 @@ class ModelLoader extends BaseLoader
|
||||
if ($this->isModelIncluded($modelArray)) {
|
||||
// Recursively load model parent (if any) and add model id as alias of parent
|
||||
if (($parentId = $this->getParentId($modelArray)) && ($parentModelFile = $this->findSubmodelFile($parentId)) !== null) {
|
||||
if ($parentModel = $this->loadModel($parentModelFile)) {
|
||||
if ($parentModel = $this->loadModel($parentModelFile, $iteration+1)) {
|
||||
// Remove old model if ~moved to
|
||||
if ($this->rewrite && ($old = $modelRepository->find($modelArray['id'])) != null) {
|
||||
$modelRepository->delete($old);
|
||||
|
Loading…
x
Reference in New Issue
Block a user