Skip to content
Snippets Groups Projects
module.config.php 8.72 KiB
Newer Older
<?php
/**
 * Copyright (C) 2019 Leipzig University Library
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * @author  Sebastian Kehr <kehr@ub.uni-leipzig.de>
 * @license http://opensource.org/licenses/gpl-2.0.php GNU GPLv2
 */

use fid\Controller\UserController;
use fid\Controller\UserControllerFactory;
use fid\Helper\RegistrationFormLabel;
use fid\Helper\TranslatorDelegator;
use fid\Listener\ErrorListener;
use fid\Listener\ErrorListenerFactory;
use fid\Listener\LocaleListener;
use fid\Service\Client;
use fid\Service\ClientFactory;
use fid\VuFind\Auth\Authenticator;
use fid\VuFind\Auth\AuthenticatorFactory;
use fid\VuFind\Auth\ILSAuthenticator;
use fid\VuFind\Auth\ILSAuthenticatorFactory;
use fid\VuFind\Db\Row\User;
use fid\VuFind\Db\Row\UserDelegatorFactory;
use fid\VuFind\ILS\Fid;
use fid\VuFind\ILS\FidFactory;
use VuFind\Auth\ILSAuthenticator as BaseILSAuthenticator;
use VuFind\Db\Row\User as BaseUser;
use VuFind\Db\Row\UserFactory;
use Zend\Mvc\I18n\Translator;
use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger;
use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers'     => [
        'factories' => [
            UserController::class => UserControllerFactory::class,
        ]
    ],
    'listeners'       => [
        ErrorListener::class,
        LocaleListener::class,
    ],
    'view_helpers'    => [
        'invokables' => [
            'formLabel' => RegistrationFormLabel::class,
        ],
    ],
    // TODO: add alias to vufind core
    'controller_plugins' => [
        'aliases' => [
            'flashmessenger' => FlashMessenger::class,
        ]
    ],
    'service_manager' => [
        'aliases'    => [
            BaseILSAuthenticator::class => ILSAuthenticator::class,
            'MvcTranslator'             => Translator::class,
        ],
        'delegators' => [
            ILSAuthenticator::class => [
                ILSAuthenticatorFactory::class,
            ],
            Translator::class       => [
                TranslatorDelegator::class,
            ],
        ],
        'factories'  => [
            Client::class           => ClientFactory::class,
            ErrorListener::class    => ErrorListenerFactory::  class,
            ILSAuthenticator::class => ILSAuthenticatorFactory::class,
            LocaleListener::class   => InvokableFactory::class,
        ],
    ],
    'vufind'          => [
        'plugin_managers' => [
            'auth'       => [
                'aliases'   => [
                    'fid' => Authenticator::class,
                ],
                'factories' => [
                    Authenticator::class => AuthenticatorFactory::class,
                ],
            ],
            'db_row'     => [
                'aliases'    => [
                    BaseUser::class => User::class,
                ],
                'delegators' => [
                    User::class => [
                        UserDelegatorFactory::class,
                    ],
                ],
                'factories'  => [
                    User::class => UserFactory::class,
                ],
            ],
            'ils_driver' => [
                'aliases'   => [
                    'fid' => Fid::class,
                ],
                'factories' => [
                    Fid::class => FidFactory::class,
                ],
            ],
        ],
    ],
    'router'          => [
        'routes' => [
            'fid'                => [
                'type'          => 'literal',
                'may_terminate' => false,
                'options'       => [
                    'route' => '/fid',
                ],
                'child_routes'  => [
                    'user' => [
                        'may_terminate' => false,
                        'type'          => 'literal',
                        'options'       => [
                            'route' => '/user',
                        ],
                        'child_routes'  => [
                            'init'     => [
                                'may_terminate' => true,
                                'type'          => 'literal',
                                'options'       => [
                                    'route'    => '/init',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'init',
                                    ],
                                ],
                            ],
                            'create'   => [
                                'type'    => 'literal',
                                'options' => [
                                    'route'    => '/create',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'create',
                                    ],
                                ],
                            ],
                            'update'   => [
                                'type'    => 'literal',
                                'options' => [
                                    'route'    => '/update',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'update',
                                    ],
                                ],
                            ],
                            'policy'   => [
                                'type'    => 'literal',
                                'options' => [
                                    'route'    => '/policy',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'policy',
                                    ],
                                ],
                            ],
                            'terms'    => [
                                'type'    => 'literal',
                                'options' => [
                                    'route'    => '/terms',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'terms',
                                    ],
                                ],
                            ],
                            'reset-password' => [
                                'type'    => 'literal',
                                'options' => [
                                    'route'    => '/reset-password',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'resetPassword',
                                    ],
                                ],
                            ],
                            'change-password' => [
                                'type'    => 'literal',
                                'options' => [
                                    'route'    => '/change-password',
                                    'defaults' => [
                                        'controller' => UserController::class,
                                        'action'     => 'changePassword',
                                    ],
                                ],
                            ]
                        ],
                    ],
                ],
            ],
            'myresearch-account' => [
                'options' => [
                    'defaults' => [
                        'controller' => UserController::class,
                        'action'     => 'init',
                    ],
                ],
            ],
            'myresearch-recover' => [
                'options' => [
                    'defaults' => [
                        'controller' => UserController::class,
                        'action'     => 'resetPassword',
                    ]
                ]
            ]