<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php');
\Bitrix\Main\Loader::includeModule('iblock');
$iblockId = 5;
$elementId = 7;
$cacheDir = 'profile';
$cacheTime = 86400;
$cacheId = md5(serialize([$iblockId, $elementId, $cacheDir]));
$cache = Bitrix\Main\Data\Cache::createInstance();
if ($cache->initCache($cacheTime, $cacheId, $cacheDir)) {
$element = $cache->getVars();
} elseif ($cache->startDataCache()) {
$iblock = \Bitrix\Iblock\Iblock::wakeUp($iblockId);
$element = $iblock->getEntityDataClass()::getByPrimary($elementId)->fetch();
$cache->endDataCache($element);
}
\CMain::finalActions();
public function index(PostRepository $posts): Response
{
$authorPosts = $posts->findBy(['author' => $this->getUser()], ['publishedAt' => 'DESC']);