Skip to content

Commit

Permalink
Switch to PSR-4 and move classes accordingly LM-Commons#35
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCat34 committed Feb 10, 2023
1 parent 1bb730b commit c1f1cd2
Show file tree
Hide file tree
Showing 133 changed files with 132 additions and 123 deletions.
117 changes: 4 additions & 113 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,116 +1,7 @@
<?php

declare(strict_types=1);

namespace LmcUser;

use Laminas\Hydrator\ClassMethodsHydrator;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
use Laminas\ModuleManager\Feature\ControllerPluginProviderInterface;
use Laminas\ModuleManager\Feature\ControllerProviderInterface;
use Laminas\ModuleManager\Feature\ServiceProviderInterface;
use Laminas\ModuleManager\Feature\ViewHelperProviderInterface;

/**
* Class Module
* This file is placed here for compatibility with Laminas's ModuleManager.
* It allows usage of this module even without composer.
* The original Module.php is in 'src/' in order to respect PSR-4
*/
class Module implements
ConfigProviderInterface,
ControllerPluginProviderInterface,
ControllerProviderInterface,
ServiceProviderInterface,
ViewHelperProviderInterface
{
public const LMC_USER_SESSION_STORAGE_NAMESPACE = 'LmcUserNamespace';

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ConfigProviderInterface::getConfig()
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ControllerPluginProviderInterface::getControllerPluginConfig()
*/
public function getControllerPluginConfig()
{
return [
'factories' => [
'lmcUserAuthentication' => Factory\Controller\Plugin\LmcUserAuthentication::class,
],
];
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ControllerProviderInterface::getControllerConfig()
*/
public function getControllerConfig()
{
return [
'factories' => [
'lmcuser' => Factory\Controller\UserControllerFactory::class,
],
];
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ViewHelperProviderInterface::getViewHelperConfig()
*/
public function getViewHelperConfig()
{
return [
'factories' => [
'lmcUserDisplayName' => Factory\View\Helper\LmcUserDisplayName::class,
'lmcUserIdentity' => Factory\View\Helper\LmcUserIdentity::class,
'lmcUserLoginWidget' => Factory\View\Helper\LmcUserLoginWidget::class,
],
];
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ServiceProviderInterface::getServiceConfig()
*/
public function getServiceConfig()
{
return [
'aliases' => [
'lmcuser_laminas_db_adapter' => \Laminas\Db\Adapter\Adapter::class,
'lmcuser_register_form_hydrator' => 'lmcuser_user_hydrator',
'lmcuser_base_hydrator' => 'lmcuser_default_hydrator',
],
'invokables' => [
'lmcuser_default_hydrator' => ClassMethodsHydrator::class,
],
'factories' => [
'lmcuser_redirect_callback' => Factory\Controller\RedirectCallbackFactory::class,
'lmcuser_module_options' => Factory\Options\ModuleOptions::class,
Authentication\Adapter\AdapterChain::class => Authentication\Adapter\AdapterChainServiceFactory::class,

// We alias this one because it's LmcUser's instance of
// Laminas\Authentication\AuthenticationService. We don't want to
// hog the FQCN service alias for a Laminas\* class.
'lmcuser_auth_service' => Factory\AuthenticationService::class,

'lmcuser_user_hydrator' => Factory\UserHydrator::class,
'lmcuser_user_mapper' => Factory\Mapper\User::class,

'lmcuser_login_form' => Factory\Form\Login::class,
'lmcuser_register_form' => Factory\Form\Register::class,
'lmcuser_change_password_form' => Factory\Form\ChangePassword::class,
'lmcuser_change_email_form' => Factory\Form\ChangeEmail::class,

Authentication\Adapter\Db::class => Factory\Authentication\Adapter\DbFactory::class,
Authentication\Storage\Db::class => Factory\Authentication\Storage\DbFactory::class,

'lmcuser_user_service' => Factory\Service\UserFactory::class,
],
];
}
}
require_once __DIR__ . '/src/Module.php';
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@
"laminas/laminas-captcha" : "Laminas\\Captcha if you want to use the captcha component"
},
"autoload": {
"psr-0": {
"LmcUser": "src/"
},
"classmap": [
"./Module.php"
]
"psr-4": {
"LmcUser\\": "src/"
}
},
"autoload-dev": {
"psr-0": {
"LmcUserTest": "tests/"
"psr-4": {
"LmcUserTest\\": "tests/"
}
},
"extra": {
"laminas": {
"module": "LmcUser"
}
},
"scripts": {
"check": [
"@cs-check",
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./vendor/autoload.php"
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand All @@ -10,7 +10,7 @@
backupGlobals="false"
>
<testsuite name="LmcUser Test Suite">
<directory>./tests/LmcUserTest</directory>
<directory>./tests</directory>
</testsuite>

<php>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
116 changes: 116 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

declare(strict_types=1);

namespace LmcUser;

use Laminas\Hydrator\ClassMethodsHydrator;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
use Laminas\ModuleManager\Feature\ControllerPluginProviderInterface;
use Laminas\ModuleManager\Feature\ControllerProviderInterface;
use Laminas\ModuleManager\Feature\ServiceProviderInterface;
use Laminas\ModuleManager\Feature\ViewHelperProviderInterface;

/**
* Class Module
*/
class Module implements
ConfigProviderInterface,
ControllerPluginProviderInterface,
ControllerProviderInterface,
ServiceProviderInterface,
ViewHelperProviderInterface
{
public const LMC_USER_SESSION_STORAGE_NAMESPACE = 'LmcUserNamespace';

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ConfigProviderInterface::getConfig()
*/
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ControllerPluginProviderInterface::getControllerPluginConfig()
*/
public function getControllerPluginConfig()
{
return [
'factories' => [
'lmcUserAuthentication' => Factory\Controller\Plugin\LmcUserAuthentication::class,
],
];
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ControllerProviderInterface::getControllerConfig()
*/
public function getControllerConfig()
{
return [
'factories' => [
'lmcuser' => Factory\Controller\UserControllerFactory::class,
],
];
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ViewHelperProviderInterface::getViewHelperConfig()
*/
public function getViewHelperConfig()
{
return [
'factories' => [
'lmcUserDisplayName' => Factory\View\Helper\LmcUserDisplayName::class,
'lmcUserIdentity' => Factory\View\Helper\LmcUserIdentity::class,
'lmcUserLoginWidget' => Factory\View\Helper\LmcUserLoginWidget::class,
],
];
}

/**
* {@inheritDoc}
* @see \Laminas\ModuleManager\Feature\ServiceProviderInterface::getServiceConfig()
*/
public function getServiceConfig()
{
return [
'aliases' => [
'lmcuser_laminas_db_adapter' => \Laminas\Db\Adapter\Adapter::class,
'lmcuser_register_form_hydrator' => 'lmcuser_user_hydrator',
'lmcuser_base_hydrator' => 'lmcuser_default_hydrator',
],
'invokables' => [
'lmcuser_default_hydrator' => ClassMethodsHydrator::class,
],
'factories' => [
'lmcuser_redirect_callback' => Factory\Controller\RedirectCallbackFactory::class,
'lmcuser_module_options' => Factory\Options\ModuleOptions::class,
Authentication\Adapter\AdapterChain::class => Authentication\Adapter\AdapterChainServiceFactory::class,

// We alias this one because it's LmcUser's instance of
// Laminas\Authentication\AuthenticationService. We don't want to
// hog the FQCN service alias for a Laminas\* class.
'lmcuser_auth_service' => Factory\AuthenticationService::class,

'lmcuser_user_hydrator' => Factory\UserHydrator::class,
'lmcuser_user_mapper' => Factory\Mapper\User::class,

'lmcuser_login_form' => Factory\Form\Login::class,
'lmcuser_register_form' => Factory\Form\Register::class,
'lmcuser_change_password_form' => Factory\Form\ChangePassword::class,
'lmcuser_change_email_form' => Factory\Form\ChangeEmail::class,

Authentication\Adapter\Db::class => Factory\Authentication\Adapter\DbFactory::class,
Authentication\Storage\Db::class => Factory\Authentication\Storage\DbFactory::class,

'lmcuser_user_service' => Factory\Service\UserFactory::class,
],
];
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c1f1cd2

Please sign in to comment.