Skip to content
Snippets Groups Projects
Commit bf786c02 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Mise en place d'un cache pour récupérer les affectations

parent 75aae7fe
No related branches found
No related tags found
1 merge request!35B8.1
......@@ -128,6 +128,9 @@ return [
/* Configuration LDAP */
'ldap' => [
/* Actif (si non, alors seuls les comptes locaux seront autorisés à se connecter à OSE) */
'actif' => true,
/* IP ou nom DNS de la machine hébergeant le serveur LDAP */
'host' => 'ldap.unicaen.fr',
......
......@@ -80,7 +80,6 @@ class AppConfig
if ('development' == $env) {
$modules[] = 'ZendDeveloperTools';
$configGlobPaths[] = 'config/autoload/{,*.}{global,local}.php.dev';
}
if (self::inConsole() || 'development' == $env){
......
......@@ -19,7 +19,7 @@ return [
'orm_default' => [
'metadata_cache' => 'array',
// 'query_cache' => 'array',
'result_cache' => 'array',
'result_cache' => 'filesystem',
'hydration_cache' => 'array',
'generate_proxies' => AppConfig::get('bdd', 'generateProxies'),
'proxy_dir' => 'data/cache/DoctrineProxy',
......
......@@ -31,7 +31,7 @@ return [
'connection' => [
'default' => [
'params' => [
'host' => AppConfig::get('ldap', 'host'),
'host' => AppConfig::get('ldap', 'actif', true) ? AppConfig::get('ldap', 'host') : null,
'username' => AppConfig::get('ldap', 'username'),
'password' => AppConfig::get('ldap', 'password'),
'baseDn' => AppConfig::get('ldap', 'baseDn'),
......
......@@ -41,7 +41,7 @@ $settings = [
/**
* Possibilité ou non de s'authentifier à l'aide d'un compte local.
*/
'enabled' => false,
'enabled' => !AppConfig::get('ldap', 'actif', true),
],
/**
......@@ -51,7 +51,7 @@ $settings = [
/**
* Possibilité ou non de s'authentifier via l'annuaire LDAP ET en local!!.
*/
'enabled' => true,
'enabled' => AppConfig::get('ldap', 'actif', true),
],
/**
......
......@@ -153,7 +153,7 @@ return array(
'doctrine.mapping_collector.orm_default' => false,
//'bjy_authorize_role_collector' => false,
//'request' => false,
'memory' => false,
//'memory' => false,
)
)
)
......
......@@ -50,6 +50,9 @@ $config = [
'apc' => [
'namespace' => 'OSE__' . __NAMESPACE__,
],
'filesystem' => [
'directory' => getcwd().'/data/cache/Doctrine',
],
],
],
'zfcuser' => [
......
......@@ -6,6 +6,7 @@ use Application\Cache\Traits\CacheContainerTrait;
use Application\Entity\Db\Affectation;
use Application\Entity\Db\Role;
use Application\Form\Droits\Traits\AffectationFormAwareTrait;
use Application\Provider\Role\RoleProvider;
use Application\Service\PrivilegeService;
use Application\Service\Traits\AffectationServiceAwareTrait;
use Application\Service\Traits\ContextServiceAwareTrait;
......@@ -15,6 +16,7 @@ use Application\Service\Traits\StatutIntervenantServiceAwareTrait;
use Application\Service\Traits\StructureServiceAwareTrait;
use Application\Form\Droits\Traits\RoleFormAwareTrait;
use Application\Service\Traits\UtilisateurServiceAwareTrait;
use Application\Traits\DoctrineCacheAwareTrait;
use UnicaenAuth\Service\Traits\PrivilegeServiceAwareTrait;
use Application\Entity\Db\StatutIntervenant;
use UnicaenAuth\Entity\Db\Privilege;
......@@ -38,6 +40,7 @@ class DroitsController extends AbstractController
use AffectationFormAwareTrait;
use ContextServiceAwareTrait;
use CacheContainerTrait;
use DoctrineCacheAwareTrait;
......@@ -282,6 +285,7 @@ class DroitsController extends AbstractController
}
}
}
$this->getCacheFilesystem()->delete(RoleProvider::class.'/affectations');
return compact('form', 'title', 'errors');
}
......@@ -297,6 +301,7 @@ class DroitsController extends AbstractController
$form = $this->makeFormSupprimer(function()use($affectation){
$this->getServiceAffectation()->delete($affectation);
});
$this->getCacheFilesystem()->delete(RoleProvider::class.'/affectations');
return compact('affectation', 'title', 'form');
}
......
......@@ -109,7 +109,7 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface
// chargement des rôles métiers
$query = $this->getEntityManager()->createQuery(
'SELECT DISTINCT
'SELECT
r, a, s, p
FROM
Application\Entity\Db\Role r
......@@ -119,6 +119,9 @@ class RoleProvider implements ProviderInterface, EntityManagerAwareInterface
WHERE
r.histoDestruction IS NULL'
)->setParameter('utilisateur', $utilisateur);
$query->useResultCache(true);
$query->setResultCacheId(__CLASS__.'/affectations');
$result = $query->getResult();
$rolesPrivileges = $this->getRolesPrivileges();
......
<?php
namespace Application\Traits;
use Doctrine\Common\Cache\FilesystemCache;
trait DoctrineCacheAwareTrait
{
/**
* Retourne le cache de système de fichiers de Doctrine
*
* @return FilesystemCache
*/
public function getCacheFilesystem(): FilesystemCache
{
return \Application::$container->get('doctrine.cache.filesystem');
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment