Commit 6356dbd8 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Modufucations pour passer à ZF3.

parent c3f28ea5
......@@ -14,9 +14,27 @@ use UnicaenAuth\Service\ShibServiceFactory;
use UnicaenAuth\Service\UserContextFactory;
use UnicaenAuth\Service\UserFactory;
use UnicaenAuth\Service\UserMapperFactory;
use UnicaenAuth\View\Helper\LdapConnectViewHelper;
use UnicaenAuth\View\Helper\LdapConnectViewHelperFactory;
use UnicaenAuth\View\Helper\LocalConnectViewHelper;
use UnicaenAuth\View\Helper\LocalConnectViewHelperFactory;
use UnicaenAuth\View\Helper\ShibConnectViewHelper;
use UnicaenAuth\View\Helper\ShibConnectViewHelperFactory;
use UnicaenAuth\View\Helper\UserConnection;
use UnicaenAuth\View\Helper\UserConnectionFactory;
use UnicaenAuth\View\Helper\UserCurrent;
use UnicaenAuth\View\Helper\UserCurrentFactory;
use UnicaenAuth\View\Helper\UserInfo;
use UnicaenAuth\View\Helper\UserInfoFactory;
use UnicaenAuth\View\Helper\UserProfile;
use UnicaenAuth\View\Helper\UserProfileFactory;
use UnicaenAuth\View\Helper\UserProfileSelect;
use UnicaenAuth\View\Helper\UserProfileSelectFactory;
use UnicaenAuth\View\Helper\UserProfileSelectRadioItem;
use UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory;
use UnicaenAuth\View\Helper\UserStatus;
use UnicaenAuth\View\Helper\UserStatusFactory;
use UnicaenAuth\View\Helper\UserUsurpationHelper;
use UnicaenAuth\View\Helper\UserUsurpationHelperFactory;
use Zend\Authentication\AuthenticationService;
use Zend\ServiceManager\Proxy\LazyServiceFactory;
......@@ -422,10 +440,17 @@ return [
],
],
],
//
//( ! ) Warning: Declaration of
// Application\Service\UserContextServiceAwareTrait::setUserContextService(Application\Service\UserContextService $userContextService)
// should be compatible with
// UnicaenAuth\Controller\UtilisateurController::setUserContextService(UnicaenAuth\Service\UserContext $userContextService)
// in /var/www/sygal/module/Application/src/Application/Controller/UtilisateurController.php on line 34
'service_manager' => [
'aliases' => [
'Zend\Authentication\AuthenticationService' => 'zfcuser_auth_service',
'UnicaenAuth\Privilege\PrivilegeProvider' => 'UnicaenAuth\Service\Privilege',
'\UnicaenAuth\Guard\PrivilegeController' => 'UnicaenAuth\Guard\PrivilegeController',
'unicaen-auth_user_service' => 'UnicaenAuth\Service\User', // pour la compatibilité
'authUserContext' => 'UnicaenAuth\Service\UserContext', // pour la compatibilité
......@@ -502,18 +527,31 @@ return [
],
'view_helpers' => [
'factories' => [
'userConnection' => 'UnicaenAuth\View\Helper\UserConnectionFactory',
'userCurrent' => 'UnicaenAuth\View\Helper\UserCurrentFactory',
'userStatus' => 'UnicaenAuth\View\Helper\UserStatusFactory',
'userProfile' => 'UnicaenAuth\View\Helper\UserProfileFactory',
'userInfo' => 'UnicaenAuth\View\Helper\UserInfoFactory',
'userProfileSelect' => 'UnicaenAuth\View\Helper\UserProfileSelectFactory',
'userProfileSelectRadioItem' => 'UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory',
'userUsurpation' => UserUsurpationHelperFactory::class,
'localConnect' => LocalConnectViewHelperFactory::class,
'ldapConnect' => LdapConnectViewHelperFactory::class,
'shibConnect' => ShibConnectViewHelperFactory::class,
'aliases' => [
'userConnection' => UserConnection::class,
'userCurrent' => UserCurrent::class,
'userStatus' => UserStatus::class,
'userProfile' => UserProfile::class,
'userInfo' => UserInfo::class,
'userProfileSelect' => UserProfileSelect::class,
'userProfileSelectRadioItem' => UserProfileSelectRadioItem::class,
'userUsurpation' => UserUsurpationHelper::class,
'localConnect' => LocalConnectViewHelper::class,
'ldapConnect' => LdapConnectViewHelper::class,
'shibConnect' => ShibConnectViewHelper::class,
],
'factories' => [
UserConnection::class => UserConnectionFactory::class,
UserCurrent::class => UserCurrentFactory::class,
UserStatus::class => UserStatusFactory::class,
UserProfile::class => UserProfileFactory::class,
UserInfo::class => UserInfoFactory::class,
UserProfileSelect::class => UserProfileSelectFactory::class,
UserProfileSelectRadioItem::class => UserProfileSelectRadioItemFactory::class,
UserUsurpationHelper::class => UserUsurpationHelperFactory::class,
LocalConnectViewHelper::class => LocalConnectViewHelperFactory::class,
LdapConnectViewHelper::class => LdapConnectViewHelperFactory::class,
ShibConnectViewHelper::class => ShibConnectViewHelperFactory::class,
],
'invokables' => [
'appConnection' => 'UnicaenAuth\View\Helper\AppConnection',
......
......@@ -9,6 +9,7 @@ use UnicaenAuth\Entity\Ldap\People;
use UnicaenAuth\Entity\Shibboleth\ShibUser;
use UnicaenAuth\Options\ModuleOptions;
use UnicaenAuth\Service\ShibService;
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;
use UnicaenAuth\Service\UserContext;
use Zend\Authentication\AuthenticationService;
use Zend\Http\Request;
......@@ -21,6 +22,8 @@ use ZfcUser\Mapper\User as UserMapper;
*/
class UtilisateurController extends AbstractActionController
{
use UserContextServiceAwareTrait;
/**
* @var LdapPeopleMapper
*/
......@@ -54,11 +57,6 @@ class UtilisateurController extends AbstractActionController
*/
private $shibService;
/**
* @var UserContext
*/
private $userContextService;
/**
* @param UserMapper $userMapper
*/
......@@ -93,10 +91,11 @@ class UtilisateurController extends AbstractActionController
/**
* @param UserContext $userContextService
* @deprecated Utiliser UserContextServiceAwareTrait::setServiceUserContext() à la place, svp.
*/
public function setUserContextService(UserContext $userContextService)
{
$this->userContextService = $userContextService;
$this->serviceUserContext = $userContextService;
}
/**
......@@ -119,11 +118,11 @@ class UtilisateurController extends AbstractActionController
$role = $request->getPost('role');
if ($role) {
$this->getAuthUserContextService()->setSelectedIdentityRole($role);
$this->serviceUserContext->setSelectedIdentityRole($role);
}
if ($addFlashMessage) {
$selectedRole = $this->getAuthUserContextService()->getSelectedIdentityRoleToString();
$selectedRole = $this->serviceUserContext->getSelectedIdentityRoleToString();
$message = sprintf("Vous endossez à présent le profil utilisateur <strong>%s</strong>.", $selectedRole);
$this->flashMessenger()->setNamespace('UnicaenAuth/success')->addMessage($message);
}
......@@ -233,10 +232,11 @@ class UtilisateurController extends AbstractActionController
/**
* @return UserContext
* @deprecated Utiliser $this->serviceUserContext directement, svp.
*/
protected function getAuthUserContextService()
{
return $this->userContextService;
return $this->serviceUserContext;
}
/**
......
......@@ -38,7 +38,7 @@ class UtilisateurControllerFactory
$controller = new UtilisateurController();
$controller->setLdapPeopleMapper($ldapPeopleMapper);
$controller->setUserContextService($userContextService);
$controller->setServiceUserContext($userContextService);
$controller->setOptions($options);
$controller->setShibService($shibService);
$controller->setAuthenticationService($authenticationService);
......
......@@ -27,11 +27,13 @@ class PrivilegeController extends Controller
public function processConfig()
{
$this->rules = $this->privilegesToRoles($this->config);
$this->rules = $this->privilegesToRoles();
}
protected function privilegesToRoles(array $rules)
protected function privilegesToRoles()
{
$rules = $this->config;
$pr = $this->getPrivilegeProvider()->getPrivilegesRoles();
foreach ($rules as $index => $rule) {
......
......@@ -55,9 +55,9 @@ class UserProfile extends UserAbstract
$html = "<strong>$title :</strong>" . PHP_EOL;
if ($this->userProfileSelectable) {
$html .= $this->getView()->userProfileSelect(false);
$html .= $this->view->userProfileSelect(false);
} else {
$html .= $this->getView()->htmlList($roles);
$html .= $this->view->htmlList($roles);
}
return $html;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment