diff --git a/Controller/BackendController.php b/Controller/BackendController.php index e4e0974..65cef86 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -171,14 +171,15 @@ final class BackendController extends Controller $tree[$ref][$component->getId()]['obj'] = $component; $parent = $component->parent->getId(); - if (!($component instanceof Position) // parent could be in different department then ignore - || (!($component->parent instanceof NullPosition) && $component->parent->department->getId() === $component->department->getId()) + if ($parent !== 0 + && (!($component instanceof Position) // parent could be in different department then ignore + || $component->parent->department->getId() === $component->department->getId() + ) ) { if (!isset($tree[$ref][$parent])) { $tree[$ref][$parent] = ['obj' => null, 'children' => [], 'index' => 0]; } - // For some stupid reason the next line is too complicated for phpstan and the error it creates is insane/wrong! /** @phpstan-ignore-next-line */ $tree[$ref][$parent]['children'][] = &$tree[$ref][$component->getId()]; } diff --git a/Models/Unit.php b/Models/Unit.php index c0a98bf..bde2faa 100755 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -54,10 +54,10 @@ class Unit implements \JsonSerializable /** * Parent * - * @var null|Unit + * @var Unit * @since 1.0.0 */ - public ?self $parent = null; + public self $parent; /** * Description. diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index d46fd31..b5d36a8 100755 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -257,6 +257,25 @@ $CONFIG = [ 'root' => '/', 'https' => false, ], + 'app' => [ + 'path' => __DIR__, + 'default' => [ + 'app' => 'Backend', + 'id' => 'backend', + 'lang' => 'en', + 'theme' => 'Backend', + 'org' => 1, + ], + 'domains' => [ + '127.0.0.1' => [ + 'app' => 'Backend', + 'id' => 'backend', + 'lang' => 'en', + 'theme' => 'Backend', + 'org' => 1, + ], + ], + ], 'socket' => [ 'master' => [ 'host' => '127.0.0.1',