Skip to content
Snippets Groups Projects
Commit 1361f8bb authored by Vadim Justus's avatar Vadim Justus
Browse files

Implement strategy provider logic

parent c3f9816f
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ namespace Firegento\ContentProvisioning\Model\Strategy;
use Firegento\ContentProvisioning\Api\StrategyInterface;
use Firegento\ContentProvisioning\Api\StrategyProviderInterface;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NotFoundException;
class Provider implements StrategyProviderInterface
......@@ -17,9 +18,18 @@ class Provider implements StrategyProviderInterface
/**
* Provider constructor.
* @param StrategyInterface[] $strategies
* @throws InputException
*/
public function __construct(array $strategies)
{
foreach ($strategies as $strategy) {
if (!($strategy instanceof StrategyInterface)) {
throw new InputException(__(
'Strategy must be instance of %interface',
['interface' => StrategyInterface::class]
));
}
}
$this->strategies = $strategies;
}
......@@ -34,7 +44,7 @@ class Provider implements StrategyProviderInterface
$strategy = $this->strategies[$strategyCode] ?? null;
if (!$strategy) {
throw new NotFoundException(__('Strategy %s not found.', $strategyCode));
throw new NotFoundException(__('Strategy %strategy_code not found.', ['strategy_code' => $strategyCode]));
}
return $strategy;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment