Bolt\Controller\Backend\Records::related PHP Метод

    public function related(Request $request, $contenttypeslug, $id)
    {
        // Make sure the user is allowed to see this page, based on 'allowed contenttypes' for Editors.
        if (!$this->isAllowed('contenttype:' . $contenttypeslug)) {
            $this->flashes()->error(Trans::__('general.phrase.access-denied-privilege-edit-record'));
            return $this->redirectToRoute('dashboard');
        }
        // Get content record, and the contenttype config from $contenttypeslug
        $content = $this->getContent($contenttypeslug, ['id' => $id]);
        $contenttype = $this->getContentType($contenttypeslug);
        // Get relations
        $showContentType = null;
        $relations = null;
        if (isset($contenttype['relations'])) {
            $relations = $contenttype['relations'];
            // Which related contenttype is to be shown?
            // If non is selected or selection does not exist, take the first one
            $showSlug = $request->get('show') ? $request->get('show') : null;
            if (!isset($relations[$showSlug])) {
                reset($relations);
                $showSlug = key($relations);
            }
            foreach (array_keys($relations) as $relatedslug) {
                $relatedtype = $this->getContentType($relatedslug);
                if ($relatedtype['slug'] == $showSlug) {
                    $showContentType = $relatedtype;
                }
                $relations[$relatedslug] = ['name' => Trans::__($relatedtype['name']), 'active' => $relatedtype['slug'] === $showSlug];
            }
        }
        $context = ['id' => $id, 'name' => Trans::__($contenttype['singular_name']), 'title' => $content['title'], 'contenttype' => $contenttype, 'relations' => $relations, 'show_contenttype' => $showContentType, 'related_content' => is_null($relations) ? null : $content->related($showContentType['slug']), 'permissions' => $this->getContentTypeUserPermissions($contenttypeslug, $this->users()->getCurrentUser())];
        return $this->render('@bolt/relatedto/relatedto.twig', $context);
    }