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

Utilisation de la syntaxe courte pour les tableaux d'UnicaenAuth

parent 6efa4f5e
Branches
Tags
No related merge requests found
Showing
with 634 additions and 345 deletions
......@@ -31,16 +31,16 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
*/
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
return [
'Zend\Loader\ClassMapAutoloader' => [
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
],
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
],
],
];
}
/**
......@@ -73,43 +73,43 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
if ($options->getCas() && php_sapi_name() !== 'cli') {
/* @var $router \Zend\Mvc\Router\Http\TreeRouteStack */
$router = $services->get('router');
$router->addRoutes(array(
$router->addRoutes([
// remplace les routes existantes (cf. config du module)
'zfcuser' => array(
'zfcuser' => [
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'options' => [
'route' => '/auth',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'index',
),
),
],
],
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'child_routes' => [
'login' => [
'type' => 'Literal',
'options' => array(
'options' => [
'route' => '/connexion',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'authenticate', // zappe l'action 'login'
),
),
),
'logout' => array(
],
],
],
'logout' => [
'type' => 'Literal',
'options' => array(
'options' => [
'route' => '/deconnexion',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'logout',
),
),
),
),
)
));
],
],
],
],
]
]);
}
}
......@@ -120,8 +120,8 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
*/
public function getViewHelperConfig()
{
return array(
'factories' => array(
return [
'factories' => [
'userConnection' => 'UnicaenAuth\View\Helper\UserConnectionFactory',
'userCurrent' => 'UnicaenAuth\View\Helper\UserCurrentFactory',
'userStatus' => 'UnicaenAuth\View\Helper\UserStatusFactory',
......@@ -129,11 +129,11 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
'userInfo' => 'UnicaenAuth\View\Helper\UserInfoFactory',
'userProfileSelect' => 'UnicaenAuth\View\Helper\UserProfileSelectFactory',
'userProfileSelectRadioItem' => 'UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory',
),
'invokables' => array(
],
'invokables' => [
'appConnection' => 'UnicaenAuth\View\Helper\AppConnection',
),
);
],
];
}
/**
......@@ -143,8 +143,8 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
*/
public function getServiceConfig()
{
return array(
'factories' => array(
return [
'factories' => [
// verrue pour forcer le label de l'identifiant qqsoit l'options 'auth_identity_fields'
'zfcuser_login_form' => function($sm) {
$options = $sm->get('zfcuser_module_options');
......@@ -153,7 +153,7 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
$form->get('identity')->setLabel("Username");
return $form;
},
),
);
],
];
}
}
\ No newline at end of file
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return array(
return [
'UnicaenAuth\Service\User' => __DIR__ . '/src/UnicaenAuth/Service/User.php',
'UnicaenAuth\Authentication\Storage\Ldap' => __DIR__ . '/src/UnicaenAuth/Authentication/Storage/Ldap.php',
'UnicaenAuth\Authentication\Storage\Db' => __DIR__ . '/src/UnicaenAuth/Authentication/Storage/Db.php',
......@@ -21,4 +21,4 @@ return array(
'UnicaenAuth\View\Helper\UserConnection' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserConnection.php',
'UnicaenAuth\View\Helper\UserAbstract' => __DIR__ . '/src/UnicaenAuth/View/Helper/UserAbstract.php',
'UnicaenAuth\Module' => __DIR__ . '/Module.php',
);
\ No newline at end of file
];
\ No newline at end of file
<?php
$settings = array(
$settings = [
/**
* Fournisseurs d'identité.
*/
'identity_providers' => array(
'identity_providers' => [
300 => 'UnicaenAuth\Provider\Identity\Basic', // en 1er
200 => 'UnicaenAuth\Provider\Identity\Db', // en 2e
100 => 'UnicaenAuth\Provider\Identity\Ldap', // en 3e
),
);
],
];
$zfcuserSettings = array(
$zfcuserSettings = [
/**
* Enable registration
* Allows users to register through the website.
......@@ -24,7 +24,7 @@ $zfcuserSettings = array(
* Default value: array containing 'email'
* Accepted values: array containing one or more of: email, username
*/
'auth_identity_fields' => array('username', 'email'),
'auth_identity_fields' => ['username', 'email'],
/**
* Login Redirect Route
* Upon successful login the user will be redirected to the entered route
......@@ -59,19 +59,19 @@ $zfcuserSettings = array(
* Default value: array containing 'ZfcUser\Authentication\Adapter\Db' with priority 100
* Accepted values: array containing services that implement 'ZfcUser\Authentication\Adapter\ChainableAdapter'
*/
'auth_adapters' => array(
'auth_adapters' => [
300 => 'UnicaenAuth\Authentication\Adapter\Ldap', // notifié en 1er
200 => 'UnicaenAuth\Authentication\Adapter\Db', // ensuite (si échec d'authentification Ldap)
100 => 'UnicaenAuth\Authentication\Adapter\Cas', // ensuite (si échec d'authentification Db)
),
],
// telling ZfcUser to use our own class
'user_entity_class' => 'UnicaenAuth\Entity\Db\User',
// telling ZfcUserDoctrineORM to skip the entities it defines
'enable_default_entities' => false,
);
];
$bjyauthorize = array(
$bjyauthorize = [
/* this module uses a meta-role that inherits from any roles that should
* be applied to the active user. the identity provider tells us which
* roles the "identity role" should inherit from.
......@@ -85,33 +85,33 @@ $bjyauthorize = array(
* to specify roles in a config file and one to load roles using a
* Zend\Db adapter.
*/
'role_providers' => array(
'role_providers' => [
/**
* 2 rôles doivent systématiquement exister dans les ACL :
* - le rôle par défaut 'guest', c'est le rôle de tout utilisateur non authentifié.
* - le rôle 'user', c'est le rôle de tout utilisateur authentifié.
*/
'UnicaenAuth\Provider\Role\Config' => array(
'guest' => array('name' => "Non authentifié(e)", 'selectable' => false, 'children' => array(
'user' => array('name' => "Authentifié(e)", 'selectable' => false)
)),
),
'UnicaenAuth\Provider\Role\Config' => [
'guest' => ['name' => "Non authentifié(e)", 'selectable' => false, 'children' => [
'user' => ['name' => "Authentifié(e)", 'selectable' => false]
]],
],
/**
* Fournit les rôles issus de la base de données éventuelle de l'appli.
* NB: si le rôle par défaut 'guest' est fourni ici, il ne sera pas ajouté en double dans les ACL.
* NB: si la connexion à la base échoue, ce n'est pas bloquant!
*/
'UnicaenAuth\Provider\Role\DbRole' => array(
'UnicaenAuth\Provider\Role\DbRole' => [
'object_manager' => 'doctrine.entitymanager.orm_default',
'role_entity_class' => 'UnicaenAuth\Entity\Db\Role',
),
],
/**
* Fournit le rôle correspondant à l'identifiant de connexion de l'utilisateur.
* Cela est utile lorsque l'on veut gérer les habilitations d'un utilisateur unique
* sur des ressources.
*/
'UnicaenAuth\Provider\Role\Username' => array(),
),
'UnicaenAuth\Provider\Role\Username' => [],
],
// strategy service name for the strategy listener to be used when permission-related errors are detected
// 'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy',
......@@ -119,72 +119,72 @@ $bjyauthorize = array(
/* Currently, only controller and route guards exist
*/
'guards' => array(
'guards' => [
/* If this guard is specified here (i.e. it is enabled), it will block
* access to all controllers and actions unless they are specified here.
* You may omit the 'action' index to allow access to the entire controller
*/
'BjyAuthorize\Guard\Controller' => array(
array('controller' => 'index', 'action' => 'index', 'roles' => array()),
array('controller' => 'zfcuser', 'roles' => array()),
array('controller' => 'Application\Controller\Index', 'roles' => array()),
'BjyAuthorize\Guard\Controller' => [
['controller' => 'index', 'action' => 'index', 'roles' => []],
['controller' => 'zfcuser', 'roles' => []],
['controller' => 'Application\Controller\Index', 'roles' => []],
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'etab', 'roles' => array()),
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'apropos', 'roles' => array()),
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'contact', 'roles' => array()),
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'plan', 'roles' => array()),
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'mentions-legales', 'roles' => array()),
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'informatique-et-libertes', 'roles' => array()),
array('controller' => 'UnicaenApp\Controller\Application', 'action' => 'refresh-session', 'roles' => array()),
array('controller' => 'UnicaenAuth\Controller\Utilisateur', 'action' => 'selectionner-profil', 'roles' => array()),
),
),
);
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'etab', 'roles' => []],
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'apropos', 'roles' => []],
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'contact', 'roles' => []],
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'plan', 'roles' => []],
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'mentions-legales', 'roles' => []],
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'informatique-et-libertes', 'roles' => []],
['controller' => 'UnicaenApp\Controller\Application', 'action' => 'refresh-session', 'roles' => []],
['controller' => 'UnicaenAuth\Controller\Utilisateur', 'action' => 'selectionner-profil', 'roles' => []],
],
],
];
return array(
return [
'zfcuser' => $zfcuserSettings,
'bjyauthorize' => $bjyauthorize,
'unicaen-auth' => $settings,
'doctrine' => array(
'driver' => array(
'doctrine' => [
'driver' => [
// overriding zfc-user-doctrine-orm's config
'zfcuser_entity' => array(
'zfcuser_entity' => [
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'paths' => array(
'paths' => [
__DIR__ . '/../src/UnicaenAuth/Entity/Db'
)
),
'orm_auth_driver' => array(
]
],
'orm_auth_driver' => [
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(
'paths' => [
__DIR__ . '/../src/UnicaenAuth/Entity/Db'
)
),
'orm_default' => array(
]
],
'orm_default' => [
'class' => 'Doctrine\ORM\Mapping\Driver\DriverChain',
'drivers' => array(
'drivers' => [
'UnicaenAuth\Entity\Db' => 'zfcuser_entity',
'UnicaenAuth\Entity\Db' => 'orm_auth_driver'
)
),
),
),
'service_manager' => array(
'aliases' => array(
]
],
],
],
'service_manager' => [
'aliases' => [
'Zend\Authentication\AuthenticationService' => 'zfcuser_auth_service',
),
'invokables' => array(
],
'invokables' => [
'unicaen-auth_user_service' => 'UnicaenAuth\Service\User',
'UnicaenAuth\Authentication\Storage\Db' => 'UnicaenAuth\Authentication\Storage\Db',
'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap',
'UnicaenAuth\View\RedirectionStrategy' => 'UnicaenAuth\View\RedirectionStrategy',
'authUserContext' => 'UnicaenAuth\Service\UserContext'
),
'abstract_factories' => array(
],
'abstract_factories' => [
'UnicaenAuth\Authentication\Adapter\AbstractFactory',
),
'factories' => array(
],
'factories' => [
'unicaen-auth_module_options' => 'UnicaenAuth\Options\ModuleOptionsFactory',
'zfcuser_auth_service' => 'UnicaenAuth\Authentication\AuthenticationServiceFactory',
'UnicaenAuth\Authentication\Storage\Chain' => 'UnicaenAuth\Authentication\Storage\ChainServiceFactory',
......@@ -195,127 +195,127 @@ return array(
'UnicaenAuth\Provider\Role\Config' => 'UnicaenAuth\Provider\Role\ConfigServiceFactory',
'UnicaenAuth\Provider\Role\DbRole' => 'UnicaenAuth\Provider\Role\DbRoleServiceFactory',
'UnicaenAuth\Provider\Role\Username' => 'UnicaenAuth\Provider\Role\UsernameServiceFactory',
),
'initializers' => array(
],
'initializers' => [
'UnicaenAuth\Service\UserAwareInitializer',
),
),
'controllers' => array(
'invokables' => array(
],
],
'controllers' => [
'invokables' => [
'UnicaenAuth\Controller\Utilisateur' => 'UnicaenAuth\Controller\UtilisateurController',
),
),
'view_manager' => array(
'template_map' => array(
],
],
'view_manager' => [
'template_map' => [
'error/403' => __DIR__ . '/../view/error/403.phtml',
),
'template_path_stack' => array(
],
'template_path_stack' => [
'unicaen-auth' => __DIR__ . '/../view',
),
),
'translator' => array(
'translation_file_patterns' => array(
array(
],
],
'translator' => [
'translation_file_patterns' => [
[
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
),
),
),
'router' => array(
'routes' => array(
'zfcuser' => array(
],
],
],
'router' => [
'routes' => [
'zfcuser' => [
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'options' => [
'route' => '/auth',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'index',
),
),
],
],
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'child_routes' => [
'login' => [
'type' => 'Literal',
'options' => array(
'options' => [
'route' => '/connexion',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'login',
),
),
),
'logout' => array(
],
],
],
'logout' => [
'type' => 'Literal',
'options' => array(
'options' => [
'route' => '/deconnexion',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'logout',
),
),
),
'register' => array(
],
],
],
'register' => [
'type' => 'Literal',
'options' => array(
'options' => [
'route' => '/creation-compte',
'defaults' => array(
'defaults' => [
'controller' => 'zfcuser',
'action' => 'register',
),
),
),
),
),
'utilisateur' => array(
],
],
],
],
],
'utilisateur' => [
'type' => 'Literal',
'options' => array(
'options' => [
'route' => '/utilisateur',
'defaults' => array(
'defaults' => [
'__NAMESPACE__' => 'UnicaenAuth\Controller',
'controller' => 'Utilisateur',
'action' => 'index',
),
),
],
],
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'child_routes' => [
'default' => [
'type' => 'Segment',
'options' => array(
'options' => [
'route' => '/:action[/:id]',
'constraints' => array(
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
),
'defaults' => array(
],
'defaults' => [
'action' => 'index',
),
),
),
),
),
),
),
],
],
],
],
],
],
],
// All navigation-related configuration is collected in the 'navigation' key
'navigation' => array(
'navigation' => [
// The DefaultNavigationFactory we configured uses 'default' as the sitemap key
'default' => array(
'default' => [
// And finally, here is where we define our page hierarchy
'home' => array(
'pages' => array(
'login' => array(
'home' => [
'pages' => [
'login' => [
'label' => _("Connexion"),
'route' => 'zfcuser/login',
'visible' => false,
),
'register' => array(
],
'register' => [
'label' => _("Enregistrement"),
'route' => 'zfcuser/register',
'visible' => false,
),
),
),
),
),
);
\ No newline at end of file
],
],
],
],
],
];
\ No newline at end of file
......@@ -5,7 +5,7 @@
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
$settings = array(
$settings = [
/**
* Flag indiquant si l'utilisateur authenitifié avec succès via l'annuaire LDAP doit
* être enregistré/mis à jour dans la table des utilisateurs de l'appli.
......@@ -16,14 +16,14 @@ $settings = array(
* (i.e. créer un compte dans la table des utilisateurs).
*/
'enable_registration' => false,
);
];
/**
* You do not need to edit below this line
*/
return array(
return [
'unicaen-auth' => $settings,
'zfcuser' => array(
'zfcuser' => [
'enable_registration' => isset($settings['enable_registration']) ? $settings['enable_registration'] : false,
),
);
\ No newline at end of file
],
];
\ No newline at end of file
......@@ -5,13 +5,13 @@
* If you have a ./config/autoload/ directory set up for your project, you can
* drop this config file in it and change the values as you wish.
*/
$settings = array(
$settings = [
/**
* Paramètres de connexion au serveur CAS :
* - pour désactiver l'authentification CAS, le tableau 'cas' doit être vide.
* - pour l'activer, renseigner les paramètres.
*/
'cas' => array(
'cas' => [
// 'connection' => array(
// 'default' => array(
// 'params' => array(
......@@ -23,17 +23,17 @@ $settings = array(
// ),
// ),
// ),
),
],
/**
* Identifiants de connexion LDAP autorisés à faire de l'usurpation d'identité.
* NB: à réserver exclusivement aux tests.
*/
// 'usurpation_allowed_usernames' => array(),
);
];
/**
* You do not need to edit below this line
*/
return array(
return [
'unicaen-auth' => $settings,
);
\ No newline at end of file
];
\ No newline at end of file
......@@ -30,6 +30,38 @@ CREATE TABLE IF NOT EXISTS `user_role_linker` (
CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS categorie_privilege (
id INT(11) NOT NULL AUTO_INCREMENT,
code VARCHAR(150) NOT NULL,
libelle VARCHAR(200) NOT NULL,
ordre INt(11),
PRIMARY KEY (id),
UNIQUE INDEX unique_code (code ASC)
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS privilege (
id INT(11) NOT NULL AUTO_INCREMENT,
categorie_id INT(11) NOT NULL,
code VARCHAR(150) NOT NULL,
libelle VARCHAR(200) NOT NULL,
ordre INT(11),
PRIMARY KEY (id),
UNIQUE INDEX unique_code (code ASC),
CONSTRAINT fk_categorie_id FOREIGN KEY (categorie_id) REFERENCES categorie_privilege (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS role_privilege (
role_id INT(11) NOT NULL,
privilege_id INT(11) NOT NULL,
PRIMARY KEY (role_id,privilege_id),
INDEX idx_role_id (role_id ASC),
INDEX idx_privilege_id (privilege_id ASC),
CONSTRAINT fk_rp_role_id FOREIGN KEY (role_id) REFERENCES user_role (id) ON DELETE CASCADE,
CONSTRAINT fk_rp_privilege_id FOREIGN KEY (privilege_id) REFERENCES privilege (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
INSERT INTO `user_role` (`id`, `role_id`, `is_default`, `parent_id`) VALUES
(1, 'Standard', 1, NULL),
(2, 'Gestionnaire', 0, 1),
......
......@@ -57,7 +57,7 @@ class AbstractFactory implements AbstractFactoryInterface
$eventManager = $serviceLocator->get('event_manager');
$adapter->setEventManager($eventManager);
$userService = $serviceLocator->get('unicaen-auth_user_service'); /* @var $userService \UnicaenAuth\Service\User */
$eventManager->attach('userAuthenticated', array($userService, 'userAuthenticated'), 100);
$eventManager->attach('userAuthenticated', [$userService, 'userAuthenticated'], 100);
}
return $adapter;
......
......@@ -65,7 +65,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
$storage = $this->getStorage()->read();
$e->setIdentity($storage['identity'])
->setCode(AuthenticationResult::SUCCESS)
->setMessages(array('Authentication successful.'));
->setMessages(['Authentication successful.']);
return;
}
......@@ -91,7 +91,7 @@ class Cas extends AbstractAdapter implements ServiceManagerAwareInterface, Event
$storage['identity'] = $e->getIdentity();
$this->getStorage()->write($storage);
$e->setCode(AuthenticationResult::SUCCESS)
->setMessages(array('Authentication successful.'));
->setMessages(['Authentication successful.']);
$this->getEventManager()->trigger('userAuthenticated', $e);
}
......
......@@ -61,7 +61,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
$storage = $this->getStorage()->read();
$e->setIdentity($storage['identity'])
->setCode(AuthenticationResult::SUCCESS)
->setMessages(array('Authentication successful.'));
->setMessages(['Authentication successful.']);
return;
}
......@@ -73,7 +73,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
// Failure!
if (! $success) {
$e->setCode(AuthenticationResult::FAILURE)
->setMessages(array('LDAP bind failed.'));
->setMessages(['LDAP bind failed.']);
$this->setSatisfied(false);
return false;
}
......@@ -84,7 +84,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
$storage['identity'] = $e->getIdentity();
$this->getStorage()->write($storage);
$e->setCode(AuthenticationResult::SUCCESS)
->setMessages(array('Authentication successful.'));
->setMessages(['Authentication successful.']);
$this->getEventManager()->trigger('userAuthenticated', $e);
}
......@@ -163,7 +163,7 @@ class Ldap extends AbstractAdapter implements ServiceManagerAwareInterface, Even
public function getLdapAuthAdapter()
{
if (null === $this->ldapAuthAdapter) {
$options = array();
$options = [];
if (($config = $this->getAppModuleOptions()->getLdap())) {
foreach ($config['connection'] as $name => $connection) {
$options[$name] = $connection['params'];
......
......@@ -146,10 +146,10 @@ class Chain implements StorageInterface, EventManagerAwareInterface
*/
public function setEventManager(EventManagerInterface $eventManager)
{
$eventManager->setIdentifiers(array(
$eventManager->setIdentifiers([
__CLASS__,
get_called_class(),
));
]);
$this->eventManager = $eventManager;
return $this;
}
......
......@@ -21,7 +21,7 @@ class ChainEvent extends Event
/**
* @var array
*/
protected $contents = array();
protected $contents = [];
/**
* Returns the contents of storage
......@@ -56,6 +56,6 @@ class ChainEvent extends Event
*/
public function clearContents()
{
$this->contents = array();
$this->contents = [];
}
}
\ No newline at end of file
......@@ -19,18 +19,18 @@ class ChainServiceFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$storages = array(
$storages = [
200 => 'UnicaenAuth\Authentication\Storage\Ldap',
100 => 'UnicaenAuth\Authentication\Storage\Db',
);
];
$chain = new Chain();
foreach ($storages as $priority => $name) {
$storage = $serviceLocator->get($name);
$chain->getEventManager()->attach('read', array($storage, 'read'), $priority);
$chain->getEventManager()->attach('write', array($storage, 'write'), $priority);
$chain->getEventManager()->attach('clear', array($storage, 'clear'), $priority);
$chain->getEventManager()->attach('read', [$storage, 'read'], $priority);
$chain->getEventManager()->attach('write', [$storage, 'write'], $priority);
$chain->getEventManager()->attach('clear', [$storage, 'clear'], $priority);
}
return $chain;
......
<?php
namespace UnicaenAuth\Entity\Db;
use Zend\Permissions\Acl\Resource\ResourceInterface;
/**
* Privilege
*/
abstract class AbstractPrivilege implements ResourceInterface
{
/**
* @var string
*/
private $code;
/**
* @var string
*/
private $libelle;
/**
*
* @var integer
*/
private $ordre;
/**
* @var integer
*/
private $id;
/**
* @var \UnicaenApp\Entity\Db\CategoriePrivilege
*/
private $categorie;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $role;
/**
* Constructor
*/
public function __construct()
{
$this->role = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Set code
*
* @param string $code
*
* @return Privilege
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
public function getFullCode()
{
return $this->getCategorie()->getCode() . '-' . $this->getCode();
}
/**
* Set libelle
*
* @param string $libelle
*
* @return Privilege
*/
public function setLibelle($libelle)
{
$this->libelle = $libelle;
return $this;
}
/**
* Get libelle
*
* @return string
*/
public function getLibelle()
{
return $this->libelle;
}
/**
*
* @return integer
*/
function getOrdre()
{
return $this->ordre;
}
/**
*
* @param integer $ordre
*
* @return \Application\Entity\Db\Privilege
*/
function setOrdre($ordre)
{
$this->ordre = $ordre;
return $this;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set categorie
*
* @param \Application\Entity\Db\CategoriePrivilege $categorie
*
* @return Privilege
*/
public function setCategorie(\Application\Entity\Db\CategoriePrivilege $categorie = null)
{
$this->categorie = $categorie;
return $this;
}
/**
* Get categorie
*
* @return \Application\Entity\Db\CategoriePrivilege
*/
public function getCategorie()
{
return $this->categorie;
}
/**
* Add role
*
* @param \Application\Entity\Db\Role $role
*
* @return Privilege
*/
public function addRole(\Application\Entity\Db\Role $role)
{
$this->Role[] = $role;
return $this;
}
/**
* Remove role
*
* @param \Application\Entity\Db\Role $role
*/
public function removeRole(\Application\Entity\Db\Role $role)
{
$this->role->removeElement($role);
}
/**
* Get role
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRole()
{
return $this->role;
}
/**
* @deprecated
* @todo à voir si cela sert à quelque chose ou non !!
* @return array
*/
public function getRoleCodes()
{
$result = [];
foreach ($this->role as $role) {
/* @var $role Role */
$result[] = $role->getRoleId();
}
return $result;
}
/**
* @return string
*/
public function __toString()
{
return $this->getLibelle();
}
/**
* @return string
*/
public function getResourceId()
{
return sprintf('privilege/%s', $this->getFullCode());
}
}
......@@ -25,7 +25,7 @@ abstract class AuthenticatedUserSavedAbstractListener implements ListenerAggrega
/**
* @var \Zend\Stdlib\CallbackHandler[]
*/
protected $listeners = array();
protected $listeners = [];
/**
* Renseigne les relations 'intervenant' et 'personnel' avant que l'objet soit persisté.
......@@ -50,7 +50,7 @@ abstract class AuthenticatedUserSavedAbstractListener implements ListenerAggrega
$this->listeners[] = $sharedEvents->attach(
'UnicaenAuth\Service\User',
UserAuthenticatedEvent::PRE_PERSIST,
array($this, 'onUserAuthenticatedPrePersist'),
[$this, 'onUserAuthenticatedPrePersist'],
100);
}
......
......@@ -11,7 +11,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions
/**
* @var array
*/
protected $usurpationAllowedUsernames = array();
protected $usurpationAllowedUsernames = [];
/**
* @var bool
......@@ -21,7 +21,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions
/**
* @var array
*/
protected $cas = array();
protected $cas = [];
/**
* set usernames allowed to make usurpation
......@@ -29,7 +29,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions
* @param array $usurpationAllowedUsernames
* @return ModuleOptions
*/
public function setUsurpationAllowedUsernames(array $usurpationAllowedUsernames = array())
public function setUsurpationAllowedUsernames(array $usurpationAllowedUsernames = [])
{
$this->usurpationAllowedUsernames = $usurpationAllowedUsernames;
return $this;
......@@ -75,7 +75,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions
* @param array $cas
* @return ModuleOptions
*/
public function setCas(array $cas = array())
public function setCas(array $cas = [])
{
$this->cas = $cas;
return $this;
......
......@@ -21,7 +21,7 @@ class ModuleOptionsFactory implements FactoryInterface
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Configuration');
$moduleConfig = isset($config['unicaen-auth']) ? $config['unicaen-auth'] : array();
$moduleConfig = isset($config['unicaen-auth']) ? $config['unicaen-auth'] : [];
$moduleConfig = array_merge($config['zfcuser'], $moduleConfig);
return new ModuleOptions($moduleConfig);
......
......@@ -24,9 +24,9 @@ class Basic extends AuthenticationIdentityProvider implements ChainableProvider
public function getIdentityRoles()
{
if (! $identity = $this->authService->getIdentity()) {
return array($this->getDefaultRole());
return [$this->getDefaultRole()];
}
return array($this->getAuthenticatedRole());
return [$this->getAuthenticatedRole()];
}
}
\ No newline at end of file
......@@ -43,7 +43,7 @@ class Chain implements ProviderInterface, ServiceLocatorAwareInterface, EventMan
{
$selectedIdentityRole = $this->getSelectedIdentityRole();
$allRoles = $this->getAllIdentityRoles();
$roles = $selectedIdentityRole ? array($selectedIdentityRole) : $allRoles;
$roles = $selectedIdentityRole ? [$selectedIdentityRole] : $allRoles;
return $roles;
}
......@@ -69,7 +69,7 @@ class Chain implements ProviderInterface, ServiceLocatorAwareInterface, EventMan
return $this->roles;
}
$this->roles = array();
$this->roles = [];
$e = $this->getEvent();
$e->clearRoles();
......
......@@ -18,7 +18,7 @@ class ChainEvent extends Event
*
* @var array
*/
protected $roles = array();
protected $roles = [];
/**
* Retourne les rôles collectés.
......@@ -52,7 +52,7 @@ class ChainEvent extends Event
*/
public function clearRoles()
{
$this->roles = array();
$this->roles = [];
return $this;
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ class ChainServiceFactory implements FactoryInterface
foreach ($providers as $priority => $name) {
$provider = $serviceLocator->get($name);
$chain->getEventManager()->attach('getIdentityRoles', array($provider, 'injectIdentityRoles'), $priority);
$chain->getEventManager()->attach('getIdentityRoles', [$provider, 'injectIdentityRoles'], $priority);
}
return $chain;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment