From 1361f8bbc98874414087911a33e4b87617740cea Mon Sep 17 00:00:00 2001
From: Vadim Justus <v.justus@techdivision.com>
Date: Sat, 1 Jun 2019 12:41:30 +0200
Subject: [PATCH] Implement strategy provider logic

---
 Model/Strategy/Provider.php | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Model/Strategy/Provider.php b/Model/Strategy/Provider.php
index 372e96f..25698df 100644
--- a/Model/Strategy/Provider.php
+++ b/Model/Strategy/Provider.php
@@ -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;
-- 
GitLab