$cacheKey = 'expertises';
$cacheClosure = function (ItemInterface $item) {
$item->expiresAfter($this->getCacheDuration());
$list = $this->get("expertise/");
$return = [];
foreach ($list as $s) {
$return[] = (new Expertise())->setId($s->id)->setName($s->name)->setKeyword($s->keyword);
}
usort($return, function (Expertise $a, Expertise $b) {
return $a->getName() <=> $b->getName();
});
if ($locked || !$wouldBlock) {
$logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
self::$lockedFiles[$key] = true;
$value = $callback($item, $save);
if ($save) {
if ($setMetadata) {
$setMetadata($item);
}
}
try {
$value = ($this->callbackWrapper)($callback, $item, $save, $pool, function (CacheItem $item) use ($setMetadata, $startTime, &$metadata) {
$setMetadata($item, $startTime, $metadata);
}, $this->logger ?? null);
$setMetadata($item, $startTime, $metadata);
return $value;
} finally {
unset($this->computing[$key]);
}
}
if ($recompute) {
$save = true;
$item->set($callback($item, $save));
if ($save) {
$pool->save($item);
}
}
return $value;
} finally {
unset($this->computing[$key]);
}
}, $beta, $metadata, $this->logger ?? null);
}
}
*
* @return mixed
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
{
return $this->doGet($this, $key, $callback, $beta, $metadata);
}
/**
* {@inheritdoc}
*/
}
private function getKey($cacheKey, $cacheClosure)
{
$cacheKey .= '-' . $this->localeService->getCurrent();
$result = $this->cache->get($cacheKey, $cacheClosure);
if (!$result || (is_array($result) && 0 == count($result))) {
$this->cache->delete($cacheKey);
}
return $result;
}
return $a->getName() <=> $b->getName();
});
return $return;
};
return $this->getKey($cacheKey, $cacheClosure);
}
private function getCertificationAssociated($id)
{
{
return $this->renderView('liste_certifications/index.html.twig', [
'bodyClass' => 'liste_certifications',
'headerClass' => 'whiteTransparent',
'controller_name' => 'ListeCertificationsController',
'expertises' => $this->emd->getExpertises(),
'sectors' => $this->emd->getSectors(),
'certifications' => $this->emd->getFullDetailledCertifications(),
'routeName' => 'liste_certifications',
]);
}
{
public function index(Security $security, CacheItemPoolInterface $cache, $cacheForPerformance)
{
if ($cacheForPerformance || !$security->isGranted('ROLE_ADMIN')) {
$html = $this->getHtmlContent();
} else {
$html = $cache->get('liste-certifications-' . $this->getLocale()->getCode(), fn() => $this->getHtmlContent());
}
return new Response($html);
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
No log messages
ErrorException
|
---|
ErrorException: Warning: foreach() argument must be of type array|object, null given at src/Service/EmdRestService.php:130 at App\Service\EmdRestService->App\Service\{closure}(object(CacheItem), true) (vendor/symfony/cache/LockRegistry.php:113) at Symfony\Component\Cache\LockRegistry::compute(object(Closure), object(CacheItem), true, object(RedisAdapter), object(Closure), object(Logger)) (vendor/symfony/cache/Traits/ContractsTrait.php:100) at Symfony\Component\Cache\Adapter\AbstractAdapter->Symfony\Component\Cache\Traits\{closure}(object(CacheItem), true) (vendor/symfony/cache-contracts/CacheTrait.php:72) at Symfony\Component\Cache\Adapter\AbstractAdapter->contractsGet(object(RedisAdapter), 'expertises-es-AR', object(Closure), 1.0, array(), object(Logger)) (vendor/symfony/cache/Traits/ContractsTrait.php:107) at Symfony\Component\Cache\Adapter\AbstractAdapter->doGet(object(RedisAdapter), 'expertises-es-AR', object(Closure), 1.0, array()) (vendor/symfony/cache-contracts/CacheTrait.php:35) at Symfony\Component\Cache\Adapter\AbstractAdapter->get('expertises-es-AR', object(Closure)) (src/Service/EmdRestService.php:106) at App\Service\EmdRestService->getKey('expertises-es-AR', object(Closure)) (src/Service/EmdRestService.php:139) at App\Service\EmdRestService->getExpertises() (src/Controller/Web/ListeCertificationsController.php:33) at App\Controller\Web\ListeCertificationsController->getHtmlContent() (src/Controller/Web/ListeCertificationsController.php:19) at App\Controller\Web\ListeCertificationsController->index(object(Security), object(RedisAdapter), true) (vendor/symfony/http-kernel/HttpKernel.php:163) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:75) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:202) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (public/index.php:25) |