Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Drop zend-loader and autoloader provider support
Browse files Browse the repository at this point in the history
  • Loading branch information
Xerkus authored and michalbundyra committed Oct 19, 2019
1 parent cc4bc94 commit da565de
Show file tree
Hide file tree
Showing 17 changed files with 8 additions and 668 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@
"require-dev": {
"zendframework/zend-console": "^2.6",
"zendframework/zend-di": "^2.6",
"zendframework/zend-loader": "^2.5",
"zendframework/zend-mvc": "^3.0 || ^2.7",
"zendframework/zend-servicemanager": "^3.0.3 || ^2.7.5",
"phpunit/phpunit": "^7.5.16",
"zendframework/zend-coding-standard": "~1.0.0"
},
"suggest": {
"zendframework/zend-console": "Zend\\Console component",
"zendframework/zend-loader": "Zend\\Loader component if you are not using Composer autoloading for your modules",
"zendframework/zend-mvc": "Zend\\Mvc component",
"zendframework/zend-servicemanager": "Zend\\ServiceManager component"
},
Expand All @@ -43,8 +41,10 @@
},
"autoload-dev": {
"files": [
"test/autoload.php",
"test/TestAsset/ModuleAsClass.php"
"test/autoload.php"
],
"classmap": [
"test/TestAsset/"
],
"psr-4": {
"ListenerTestModule\\": "test/TestAsset/ListenerTestModule/",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 0 additions & 22 deletions src/Feature/AutoloaderProviderInterface.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/Listener/AutoloaderListener.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/Listener/DefaultListenerAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,8 @@ public function attach(EventManagerInterface $events, $priority = 1)
$configListener = $this->getConfigListener();
$locatorRegistrationListener = new LocatorRegistrationListener($options);

// High priority, we assume module autoloading (for FooNamespace\Module
// classes) should be available before anything else.
// Register it only if use_zend_loader config is true, however.
if ($options->useZendLoader()) {
$moduleLoaderListener = new ModuleLoaderListener($options);
$moduleLoaderListener->attach($events);
$this->listeners[] = $moduleLoaderListener;
}
$this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE_RESOLVE, new ModuleResolverListener);

if ($options->useZendLoader()) {
// High priority, because most other loadModule listeners will assume
// the module's classes are available via autoloading
// Register it only if use_zend_loader config is true, however.
$this->listeners[] = $events->attach(
ModuleEvent::EVENT_LOAD_MODULE,
new AutoloaderListener($options),
9000
);
}

if ($options->getCheckDependencies()) {
$this->listeners[] = $events->attach(
ModuleEvent::EVENT_LOAD_MODULE,
Expand Down
73 changes: 0 additions & 73 deletions src/Listener/ListenerOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
*/
class ListenerOptions extends AbstractOptions
{
/**
* @var array
*/
protected $modulePaths = [];

/**
* @var array
*/
Expand Down Expand Up @@ -66,47 +61,6 @@ class ListenerOptions extends AbstractOptions
*/
protected $moduleMapCacheKey;

/**
* @var bool
*/
protected $useZendLoader = true;

/**
* Get an array of paths where modules reside
*
* @return array
*/
public function getModulePaths()
{
return $this->modulePaths;
}

/**
* Set an array of paths where modules reside
*
* @param array|Traversable $modulePaths
* @throws Exception\InvalidArgumentException
* @return ListenerOptions Provides fluent interface
*/
public function setModulePaths($modulePaths)
{
if (! is_array($modulePaths) && ! $modulePaths instanceof Traversable) {
throw new Exception\InvalidArgumentException(
sprintf(
'Argument passed to %s::%s() must be an array, '
. 'implement the Traversable interface, or be an '
. 'instance of Zend\Config\Config. %s given.',
__CLASS__,
__METHOD__,
gettype($modulePaths)
)
);
}

$this->modulePaths = $modulePaths;
return $this;
}

/**
* Get the glob patterns to load additional config files
*
Expand Down Expand Up @@ -382,33 +336,6 @@ public function setCheckDependencies($checkDependencies)
return $this;
}

/**
* Whether or not to use zend-loader to autoload modules.
*
* @return bool
*/
public function useZendLoader()
{
return $this->useZendLoader;
}

/**
* Set a flag indicating if the module manager should use zend-loader
*
* Setting this option to false will disable ModuleAutoloader, requiring
* other means of autoloading to be used (e.g., Composer).
*
* If disabled, the AutoloaderProvider feature will be disabled as well
*
* @param bool $flag
* @return ListenerOptions
*/
public function setUseZendLoader($flag)
{
$this->useZendLoader = (bool) $flag;
return $this;
}

/**
* Normalize a path for insertion in the stack
*
Expand Down
125 changes: 0 additions & 125 deletions src/Listener/ModuleLoaderListener.php

This file was deleted.

16 changes: 1 addition & 15 deletions test/Listener/AbstractListenerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,11 @@

namespace ZendTest\ModuleManager\Listener;

use PHPUnit\Framework\TestCase;
use Zend\Loader\ModuleAutoloader;
use ZendTest\ModuleManager\ResetAutoloadFunctionsTrait;
use PHPUnit\Framework\TestCase as TestCase;

/**
* Common test methods for all AbstractListener children.
*/
class AbstractListenerTestCase extends TestCase
{
use ResetAutoloadFunctionsTrait;

/**
* @before
*/
protected function registerTestAssetsOnModuleAutoloader()
{
$autoloader = new ModuleAutoloader([
dirname(__DIR__) . '/TestAsset',
]);
$autoloader->register();
}
}
Loading

0 comments on commit da565de

Please sign in to comment.