Exemple #1
0
 /**
  * Fill view data from config
  *
  * @param string $viewId
  * @return ViewInterface
  * @throws \InvalidArgumentException
  */
 public function load($viewId)
 {
     $view = $this->config->getView($viewId);
     if (empty($view) || empty($view['view_id']) || $view['view_id'] != $viewId) {
         throw new \InvalidArgumentException("{$viewId} view does not exist.");
     }
     $this->setId($viewId);
     $this->setData($view);
     return $this;
 }
 /**
  * Load data
  *
  * @param bool $printQuery
  * @param bool $logQuery
  * @return \Magento\Framework\Mview\View\CollectionInterface
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function loadData($printQuery = false, $logQuery = false)
 {
     if (!$this->isLoaded()) {
         $states = $this->statesFactory->create();
         foreach (array_keys($this->config->getViews()) as $viewId) {
             /** @var \Magento\Framework\Mview\ViewInterface $view */
             $view = $this->getNewEmptyItem();
             $view->load($viewId);
             foreach ($states->getItems() as $state) {
                 /** @var \Magento\Framework\Mview\View\StateInterface $state */
                 if ($state->getViewId() == $viewId) {
                     $view->setState($state);
                     break;
                 }
             }
             $this->_addItem($view);
         }
         $this->_setIsLoaded(true);
     }
     return $this;
 }
 protected function loadView()
 {
     $viewId = 'view_test';
     $this->configMock->expects(
         $this->once()
     )->method(
         'getView'
     )->with(
         $viewId
     )->will(
         $this->returnValue($this->getViewData())
     );
     $this->model->load($viewId);
 }