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

Commit 656001c

Browse files
committed
Documented and simplified logic of populateFactoryPluginManagers
- Created a ternary from the original if/else, making the logic more compact. - Added the method docblock.
1 parent d26c4b4 commit 656001c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/InputFilterPluginManager.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,22 @@ public function populateFactory($first, $second)
9595
}
9696
}
9797

98+
/**
99+
* Populate the filter and validator managers for the default filter/validator chains.
100+
*
101+
* @param Factory $factory
102+
* @return void
103+
*/
98104
public function populateFactoryPluginManagers(Factory $factory)
99105
{
100-
if (property_exists($this, 'creationContext')) {
101-
// v3
102-
$container = $this->creationContext;
103-
} else {
104-
// v2
105-
$container = $this->serviceLocator;
106-
}
106+
$container = property_exists($this, 'creationContext')
107+
? $this->creationContext // v3
108+
: $this->serviceLocator; // v2
107109

108110
if ($container && $container->has('FilterManager')) {
109111
$factory->getDefaultFilterChain()->setPluginManager($container->get('FilterManager'));
110112
}
113+
111114
if ($container && $container->has('ValidatorManager')) {
112115
$factory->getDefaultValidatorChain()->setPluginManager($container->get('ValidatorManager'));
113116
}

0 commit comments

Comments
 (0)