clear cache if user changed roles

This commit is contained in:
yuri
2015-09-17 11:00:21 +03:00
parent b940adc341
commit 957fda9e8e
+18
View File
@@ -49,6 +49,11 @@ class User extends Record
return $this->getContainer()->get('language');
}
protected function getFileManager()
{
return $this->getContainer()->get('fileManager');
}
protected function getContainer()
{
return $this->injections['container'];
@@ -353,5 +358,18 @@ class User extends Record
}
return parent::deleteEntity($id);
}
public function afterUpdate(Entity $entity, array $data)
{
parent::afterUpdate($entity, $data);
if (array_key_exists('rolesIds', $data) || array_key_exists('teamsIds', $data)) {
$this->clearRoleCache($entity->id);
}
}
protected function clearRoleCache($id)
{
$this->getFileManager()->removeFile('data/cache/application/acl/' . $id . '.php');
}
}