示例#1
0
 /**
  * Validate merged layout
  *
  * @param string $cacheId
  * @param string $layout
  * @return $this
  */
 protected function _validateMergedLayout($cacheId, $layout)
 {
     $layoutStr = '<handle id="handle">' . $layout . '</handle>';
     if ($this->_appState->getMode() === \Magento\Framework\App\State::MODE_DEVELOPER) {
         if (!$this->_layoutValidator->isValid($layoutStr, Validator::LAYOUT_SCHEMA_MERGED, false)) {
             $messages = $this->_layoutValidator->getMessages();
             //Add first message to exception
             $message = reset($messages);
             $this->_logger->info('Cache file with merged layout: ' . $cacheId . ': ' . $message);
         }
     }
     return $this;
 }
示例#2
0
 /**
  * Load layout updates by handles
  *
  * @param array|string $handles
  * @throws \Magento\Framework\Exception
  * @return $this
  */
 public function load($handles = array())
 {
     if (is_string($handles)) {
         $handles = array($handles);
     } elseif (!is_array($handles)) {
         throw new \Magento\Framework\Exception('Invalid layout update handle');
     }
     $this->addHandle($handles);
     $cacheId = $this->_getCacheId(md5(implode('|', $this->getHandles())));
     $result = $this->_loadCache($cacheId);
     if ($result) {
         $this->addUpdate($result);
         return $this;
     }
     foreach ($this->getHandles() as $handle) {
         $this->_merge($handle);
     }
     $layout = $this->asString();
     $layoutStr = '<handle id="handle">' . $layout . '</handle>';
     if ($this->_appState->getMode() === \Magento\Framework\App\State::MODE_DEVELOPER) {
         if (!$this->_layoutValidator->isValid($layoutStr, \Magento\Core\Model\Layout\Update\Validator::LAYOUT_SCHEMA_MERGED, false)) {
             $messages = $this->_layoutValidator->getMessages();
             //Add first message to exception
             $message = array_shift($messages);
             $this->_logger->addStreamLog(\Magento\Framework\Logger::LOGGER_SYSTEM);
             $this->_logger->log('Cache file with merged layout: ' . $cacheId . ': ' . $message, \Zend_Log::ERR);
         }
     }
     $this->_saveCache($layout, $cacheId, $this->getHandles());
     return $this;
 }