lib/controllers/ObjectController.php
public function actionView()
    {
        if (empty($_GET['id']) || !($object = $this->params['object'] = Registry::getObject($_GET['id'], false)) || !($typeItem = $this->params['typeItem'] = $object->objectTypeItem)) {
            throw new HttpException(404, "Unknown object.");
        }
        if (!$object->can('read')) {
            throw new HttpException(403, "Unable to access object.");
        }
        $action = isset($_GET['subaction']) ? $_GET['subaction'] : 'view';
        Yii::$app->request->object = $object;
        $object->loadChildParentIds();
        $type = $this->params['type'] = $object->objectType;
        $viewEvent = new ObjectViewEvent(['object' => $object, 'action' => $action]);
        $type->trigger(TypeModule::EVENT_VIEW_OBJECT, $viewEvent);
        //Yii::$app->collectors['widgets']->lazy = true;

        if ($viewEvent->handled) {
            if ($viewEvent->accessed) {
                ObjectFamiliarity::accessed($object);
            }

            return;
        }

        if (empty($_GET['h']) or !($relatedObject = $this->params['relatedObject'] = Registry::getObject($_GET['h'], false)) or !($relatedTypeItem = $this->params['relatedTypeItem'] = $relatedObject->objectTypeItem)) {
            $relatedObject = null;
        } elseif (!$object->can('read')) {
            $relatedObject = null;
        }

        if (!$type->hasDashboard) {
            $relatedObjectOptions = [];
            $relatedObjects = $object->queryRelations(false)->all();
            foreach ($relatedObjects as $relation) {
                if ($relation->child_object_id === $object->primaryKey) {
                    $relatedTest = Registry::getObject($relation->parent_object_id, false);
                } else {
                    $relatedTest = Registry::getObject($relation->child_object_id, false);
                }
                if (!$relatedTest || !$relatedTest->objectType->hasDashboard || !$relatedTest->can('read')) {
                    continue;
                }
                $relatedObjectOptions[$relatedTest->primaryKey] = ['descriptor' => $relatedTest->descriptor, 'url' => $relatedTest->getUrl('view', ['h' => $object->primaryKey], false)];
            }
            if (isset($relatedObject) && isset($relatedObjectOptions[$relatedObject->primaryKey])) {
                $this->redirect($relatedObjectOptions[$relatedObject->primaryKey]['url']);

                return;
            } elseif (sizeof($relatedObjectOptions) === 1) {
                $relatedObject = array_pop($relatedObjectOptions);
                $this->redirect($relatedObject['url']);

                return;
            } else {
                $this->params['options'] = $relatedObjectOptions;
                Yii::$app->response->view = 'viewOptions';

                return;
            }
            throw new HttpException(400, "Bad request");
        }
        $this->params['highlight'] = $relatedObject;

        ObjectFamiliarity::accessed($object);
        Yii::$app->response->view = 'view';

        $sections = $this->params['sections'] = $typeItem->getSections($object);
        $this->params['active'] = $this->params['default'] = null;
        foreach ($sections as $section) {
            if ($section->priority > 0) {
                $this->params['active'] = $this->params['default'] = $section->systemId;
                break;
            }
        }
        if (!empty($_GET['section'])) {
            $this->params['active'] = $_GET['section'];
        }
    }
public function actionView()
    {
        if (empty($_GET['id']) || !($object = $this->params['object'] = Registry::getObject($_GET['id'], false)) || !($typeItem = $this->params['typeItem'] = $object->objectTypeItem)) {
            throw new HttpException(404, "Unknown object.");
        }
        if (!$object->can('read')) {
            throw new HttpException(403, "Unable to access object.");
        }
        $action = isset($_GET['subaction']) ? $_GET['subaction'] : 'view';
        Yii::$app->request->object = $object;
        $object->loadChildParentIds();
        $type = $this->params['type'] = $object->objectType;
        $viewEvent = new ObjectViewEvent(['object' => $object, 'action' => $action]);
        $type->trigger(TypeModule::EVENT_VIEW_OBJECT, $viewEvent);
        //Yii::$app->collectors['widgets']->lazy = true;

        if ($viewEvent->handled) {
            if ($viewEvent->accessed) {
                ObjectFamiliarity::accessed($object);
            }

            return;
        }

        if (empty($_GET['h']) or !($relatedObject = $this->params['relatedObject'] = Registry::getObject($_GET['h'], false)) or !($relatedTypeItem = $this->params['relatedTypeItem'] = $relatedObject->objectTypeItem)) {
            $relatedObject = null;
        } elseif (!$object->can('read')) {
            $relatedObject = null;
        }

        if (!$type->hasDashboard) {
            $relatedObjectOptions = [];
            $relatedObjects = $object->queryRelations(false)->all();
            foreach ($relatedObjects as $relation) {
                if ($relation->child_object_id === $object->primaryKey) {
                    $relatedTest = Registry::getObject($relation->parent_object_id, false);
                } else {
                    $relatedTest = Registry::getObject($relation->child_object_id, false);
                }
                if (!$relatedTest || !$relatedTest->objectType->hasDashboard || !$relatedTest->can('read')) {
                    continue;
                }
                $relatedObjectOptions[$relatedTest->primaryKey] = ['descriptor' => $relatedTest->descriptor, 'url' => $relatedTest->getUrl('view', ['h' => $object->primaryKey], false)];
            }
            if (isset($relatedObject) && isset($relatedObjectOptions[$relatedObject->primaryKey])) {
                $this->redirect($relatedObjectOptions[$relatedObject->primaryKey]['url']);

                return;
            } elseif (sizeof($relatedObjectOptions) === 1) {
                $relatedObject = array_pop($relatedObjectOptions);
                $this->redirect($relatedObject['url']);

                return;
            } else {
                $this->params['options'] = $relatedObjectOptions;
                Yii::$app->response->view = 'viewOptions';

                return;
            }
            throw new HttpException(400, "Bad request");
        }
        $this->params['highlight'] = $relatedObject;

        ObjectFamiliarity::accessed($object);
        Yii::$app->response->view = 'view';

        $sections = $this->params['sections'] = $typeItem->getSections($object);
        $this->params['active'] = $this->params['default'] = null;
        foreach ($sections as $section) {
            if ($section->priority > 0) {
                $this->params['active'] = $this->params['default'] = $section->systemId;
                break;
            }
        }
        if (!empty($_GET['section'])) {
            $this->params['active'] = $_GET['section'];
        }
    }
[[@doctodo method_description:actionView]].

@throws HttpException [[@doctodo exception_description:HttpException]]
@return [[@doctodo return_type:actionView]] [[@doctodo return_description:actionView]]