Get last modified records from the content log.

@param string $contenttypeslug
@param int    $contentid

@return \Bolt\Response\TemplateResponse
175817
private function getLastmodifiedByContentLog($contenttypeslug, $contentid)
    {
        // Get the proper ContentType.
        $contenttype = $this->getContentType($contenttypeslug);

        // get the changelog for the requested ContentType.
        $options = ['limit' => 5, 'order' => 'date', 'direction' => 'DESC'];

        if ((int) $contentid == 0) {
            $isFiltered = false;
        } else {
            $isFiltered = true;
            $options['contentid'] = (int) $contentid;
        }

        /** @var Repository\LogChangeRepository $repo */
        $repo = $this->storage()->getRepository(Entity\LogChange::class);
        $changelog = $repo->getChangeLogByContentType($contenttype['slug'], $options);

        $context = [
            'changelog'   => $changelog,
            'contenttype' => $contenttype,
            'contentid'   => $contentid,
            'filtered'    => $isFiltered,
        ];

        return $this->render('@bolt/components/panel-lastmodified.twig', ['context' => $context]);
    }
211835
public function mapContentById($contentId)
    {
        $contentInfo = $this->contentHandler->loadContentInfo($contentId);

        return $this->mapContent(
            $this->contentHandler->load($contentId, $contentInfo->currentVersionNo)
        );
    }
135334
private function loadContentType(int $contentTypeId, array $languageCodes): ContentType
    {
        return $this->repository->getContentTypeService()->loadContentType($contentTypeId, $languageCodes);
    }
1167838
public function getContentTypeGrouping($contenttypeslug)
    {
        $grouping = false;
        $taxonomy = $this->getContentTypeTaxonomy($contenttypeslug);
        foreach ($taxonomy as $tax) {
            if ($tax['behaves_like'] === 'grouping') {
                $grouping = $tax['slug'];
                break;
            }
        }

        return $grouping;
    }
431440
protected function getContentTypeUserPermissions($contentTypeSlug, $user = null)
    {
        if ($user === null) {
            return $this->app['permissions']->getContentTypePermissions();
        }

        return $this->app['permissions']->getContentTypeUserPermissions($contentTypeSlug, $user);
    }
1165706
private function getLastmodifiedSimple($contenttypeslug)
    {
        // Get the proper ContentType.
        $contenttype = $this->getContentType($contenttypeslug);

        // Get the 'latest' from the requested ContentType.
        $latest = $this->getContent($contenttype['slug'], ['limit' => 5, 'order' => '-datechanged', 'hydrate' => false]);

        $context = [
            'latest'      => $latest,
            'contenttype' => $contenttype,
        ];

        return $this->render('@bolt/components/panel-lastmodified.twig', ['context' => $context]);
    }
653602
public function setContentType(ContentType $contentType)
    {
        $this->contentTypeName = $contentType->getName();
        $this->contentTypeId = null;

        return parent::setContentType($contentType);
    }
778415
private function getContentIdentifier($contentId)
    {
        $contentType = $this->contentTypeService->loadContentType(
            $this->contentService
                ->loadContent($contentId)
                ->contentInfo
                ->contentTypeId
        );

        return $contentType->identifier;
    }
974693
public function getRecord($recordId, $contentTypeName = null, DataDimensions $dataDimensions = null)
    {

        if ($contentTypeName == null)
        {
            $contentTypeName = $this->getCurrentContentTypeName();
        }

        $records = $this->getAllRecords($contentTypeName, $dataDimensions);

        if (array_key_exists($recordId, $records))
        {
            return $records[$recordId];
        }

        KVMLogger::instance('anycontent-connection')
                 ->info('Record ' . $recordId . ' not found for content type ' . $this->getCurrentContentTypeName());

        return false;

    }
1277933
public function getContentType($contenttypeslug)
    {
        // Return false if empty, can't find it.
        if (empty($contenttypeslug)) {
            return false;
        }

        $contenttype = $this->app['config']->get('contenttypes/' . $contenttypeslug);

        // See if we've either given the correct contenttype, or try to find it by name or singular_name.
        if (!$contenttype) {
            // Also check for the slugified version of the content type
            $slugifiedContentType = $this->app['slugify']->slugify($contenttypeslug);
            $contenttype = $this->app['config']->get('contenttypes/' . $slugifiedContentType);

            if (!$contenttype) {
                foreach ($this->app['config']->get('contenttypes') as $key => $ct) {
                    if (
                        (isset($ct['slug']) &&
                            (($contenttypeslug === $ct['slug']) || ($slugifiedContentType === $ct['slug']))
                        ) ||
                        (isset($ct['singular_slug']) &&
                            (($contenttypeslug === $ct['singular_slug']) || ($slugifiedContentType === $ct['singular_slug']))
                        ) ||
                        $slugifiedContentType === $this->app['slugify']->slugify($ct['name']) ||
                        $slugifiedContentType === $this->app['slugify']->slugify($ct['singular_name'])
                    ) {
                        $contenttype = $ct;
                        $contenttype['key'] = $key;
                        break;
                    }
                }
            }
        }

        if (!empty($contenttype)) {
            return $contenttype;
        } else {
            return false;
        }
    }
677867
private function checkEditAccess($contenttypeslug, $id)
    {
        // Is the record new or existing
        $new = empty($id) ?: false;

        /*
         * Check the user is allowed to create/edit this record, based on:
         *     contenttype-all:
         *     contenttype-default:
         *     contenttypes:
         *         edit: []
         *         create: []
         */
        $perm = $new ? "contenttype:$contenttypeslug:create" : "contenttype:$contenttypeslug:edit:$id";
        if (!$this->isAllowed($perm)) {
            $action = $new ? 'create' : 'edit';
            $this->flashes()->error(Trans::__("You do not have the right privileges to $action that record."));

            return $this->redirectToRoute('dashboard');
        }

        return false;
    }
738360
public function getContentTypeDefinition($contentTypeName = null)
    {

        if ($contentTypeName == null) {
            $contentTypeName = $this->getCurrentContentTypeName();
        }

        return $this->readConnection->getContentTypeDefinition($contentTypeName);
    }
591419
public function record(Request $request, $contenttypeslug, $slug = '')
    {
        $contenttype = $this->getContentType($contenttypeslug);

        // If the ContentType is 'viewless', don't show the record page.
        if (isset($contenttype['viewless']) && $contenttype['viewless'] === true) {
            $this->abort(Response::HTTP_NOT_FOUND, "Page $contenttypeslug/$slug not found.");

            return null;
        }

        // Perhaps we don't have a slug. Let's see if we can pick up the 'id', instead.
        if (empty($slug)) {
            $slug = $request->get('id');
        }

        $slug = $this->app['slugify']->slugify($slug);

        // First, try to get it by slug.
        $content = $this->getContent($contenttype['slug'], ['slug' => $slug, 'returnsingle' => true, 'log_not_found' => !is_numeric($slug)]);

        if (is_numeric($slug) && !$content) {
            // And otherwise try getting it by ID
            $content = $this->getContent($contenttype['slug'], ['id' => $slug, 'returnsingle' => true]);
        }

        // No content, no page!
        if (!$content) {
            $this->abort(Response::HTTP_NOT_FOUND, "Page $contenttypeslug/$slug not found.");

            return null;
        }

        // Then, select which template to use, based on our 'cascading templates rules'
        $template = $this->templateChooser()->record($content);

        // Setting the editlink
        $this->app['editlink'] = $this->generateUrl('editcontent', ['contenttypeslug' => $contenttype['slug'], 'id' => $content->id]);
        $this->app['edittitle'] = $content->getTitle();

        // Make sure we can also access it as {{ page.title }} for pages, etc. We set these in the global scope,
        // So that they're also available in menu's and templates rendered by extensions.
        $globals = [
            'record'                      => $content,
            $contenttype['singular_slug'] => $content,
        ];

        return $this->render($template, [], $globals);
    }
933993
public function loadContentTypeFieldDefinitionList($contentTypeId)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId, Language::ALL);

        return new Values\FieldDefinitionList(
            $contentType,
            $contentType->getFieldDefinitions()
        );
    }
97273
private function loadVersionInfo($contentId): VersionInfo
    {
        return $this->repository->sudo(
            static function (Repository $repository) use ($contentId): VersionInfo {
                return $repository->getContentService()->loadVersionInfoById($contentId);
            }
        );
    }
371741
public function deleteContentTypeDraft($contentTypeId)
    {
        $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
        $this->contentTypeService->deleteContentType($contentTypeDraft);

        return new Values\NoContent();
    }
1223519
public function loadContentType($contentTypeId)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId, Language::ALL);

        return new Values\RestContentType(
            $contentType,
            $contentType->getFieldDefinitions()
        );
    }