Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataProviderFactory.php
Go to the documentation of this file.
1 <?php
8 
13 
19 {
25  private $objectManager;
26 
30  public function __construct(ObjectManagerInterface $objectManager)
31  {
32  $this->objectManager = $objectManager;
33  }
34 
55  public function create(DataProviderInterface $dataProvider, QueryContainer $query = null)
56  {
57  $result = $dataProvider;
58  if ($dataProvider instanceof QueryAwareInterface) {
59  if (null === $query) {
60  throw new \LogicException(
61  'Instance of ' . QueryAwareInterface::class . ' must be configured with a search query,'
62  . ' but the query is empty'
63  );
64  }
65 
66  $className = get_class($dataProvider);
67  $result = $this->objectManager->create($className, ['queryContainer' => $query]);
68  }
69 
70  return $result;
71  }
72 }
$objectManager
Definition: bootstrap.php:17
create(DataProviderInterface $dataProvider, QueryContainer $query=null)
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31