Skip to content

Commit

Permalink
Get only invokable and factory names
Browse files Browse the repository at this point in the history
refs #1355
  • Loading branch information
jimsafley committed Dec 10, 2018
1 parent 2721c96 commit 6d9a872
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions application/src/ServiceManager/AbstractPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ abstract class AbstractPluginManager extends ZendAbstractPluginManager
{
use EventManagerAwareTrait;

protected $registeredNames = [];

/**
* Sorted array of service names. Names specified here are sorted
* accordingly in the getRegisteredNames output. Names not specified
Expand All @@ -27,6 +29,18 @@ public function __construct($configOrContainerInterface = null, array $v3config
$this->sortedNames = $v3config['sorted_names'];
}
}

public function configure(array $config)
{
parent::configure($config);
if (isset($config['factories']) && is_array($config['factories'])) {
$this->registeredNames = array_merge($this->registeredNames, array_keys($config['factories']));
}
if (isset($config['invokables']) && is_array($config['invokables'])) {
$this->registeredNames = array_merge($this->registeredNames, array_keys($config['invokables']));
}
}

/**
* Get registered names.
*
Expand All @@ -38,14 +52,7 @@ public function __construct($configOrContainerInterface = null, array $v3config
*/
public function getRegisteredNames()
{
$aliases = $this->aliases;
$registeredNames = array_keys($aliases);
foreach ($this->factories as $key => $value) {
if (!in_array($key, $aliases)) {
$registeredNames[] = $key;
}
}
$registeredNames = array_merge($this->sortedNames, array_diff($registeredNames, $this->sortedNames));
$registeredNames = array_merge($this->sortedNames, array_diff($this->registeredNames, $this->sortedNames));
$args = $this->getEventManager()->prepareArgs([
'registered_names' => $registeredNames,
]);
Expand Down

0 comments on commit 6d9a872

Please sign in to comment.