Example #1
0
 /**
  * Save control values data
  *
  * @param array $controlsData
  * @return $this
  */
 public function saveData(array $controlsData)
 {
     $configDom = $this->_viewConfig->getDomConfigCopy()->getDom();
     $varData = $this->_prepareVarData($controlsData, $this->_controlList);
     /** @var $varsNode \DOMElement */
     foreach ($configDom->childNodes->item(0)->childNodes as $varsNode) {
         $moduleName = $varsNode->getAttribute('module');
         if (!isset($varData[$moduleName])) {
             continue;
         }
         /** @var $varNode \DOMElement */
         foreach ($varsNode->getElementsByTagName('var') as $varNode) {
             $varName = $varNode->getAttribute('name');
             if (isset($varData[$moduleName][$varName])) {
                 list($controlName, $controlValue) = $varData[$moduleName][$varName];
                 $varNode->nodeValue = $controlValue;
                 $this->_controlList[$controlName]['value'] = $controlValue;
             }
         }
     }
     $this->_saveViewConfiguration($configDom);
     $this->_eventDispatcher->dispatch('save_view_configuration', array('configuration' => $this, 'theme' => $this->_theme));
     return $this;
 }