Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RssManager.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Rss\Model;
7 
10 
18 {
22  protected $providers;
23 
28  public function __construct(
29  \Magento\Framework\ObjectManagerInterface $objectManager,
30  array $dataProviders = []
31  ) {
32  $this->objectManager = $objectManager;
33  $this->providers = $dataProviders;
34  }
35 
43  public function getProvider($type)
44  {
45  if (!isset($this->providers[$type])) {
46  throw new \InvalidArgumentException('Unknown provider with type: ' . $type);
47  }
48 
49  $provider = $this->providers[$type];
50 
51  if (is_string($provider)) {
52  $provider = $this->objectManager->get($provider);
53  }
54 
55  if (!$provider instanceof DataProviderInterface) {
56  throw new \InvalidArgumentException('Provider should implement DataProviderInterface');
57  }
58 
59  $this->providers[$type] = $provider;
60 
61  return $this->providers[$type];
62  }
63 
67  public function getProviders()
68  {
69  $result = [];
70  foreach (array_keys($this->providers) as $type) {
71  $result[] = $this->getProvider($type);
72  }
73  return $result;
74  }
75 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, array $dataProviders=[])
Definition: RssManager.php:28
$type
Definition: item.phtml:13