示例#1
0
文件: Edit.php 项目: aiesh/magento2
 /**
  * Checks themes for changes by time
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $sourceTheme
  * @param \Magento\Framework\View\Design\ThemeInterface $targetTheme
  * @return bool
  */
 protected function _hasThemeChanged(\Magento\Framework\View\Design\ThemeInterface $sourceTheme, \Magento\Framework\View\Design\ThemeInterface $targetTheme)
 {
     $sourceChange = $this->_changeFactory->create();
     $sourceChange->loadByThemeId($sourceTheme->getId());
     $targetChange = $this->_changeFactory->create();
     $targetChange->loadByThemeId($targetTheme->getId());
     return $sourceChange->getChangeTime() !== $targetChange->getChangeTime();
 }
 /**
  * Copy additional information about theme change time
  *
  * @param \Magento\Theme\Model\CopyService $subject
  * @param callable $proceed
  * @param \Magento\Framework\View\Design\ThemeInterface $source
  * @param \Magento\Framework\View\Design\ThemeInterface $target
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundCopy(\Magento\Theme\Model\CopyService $subject, \Closure $proceed, \Magento\Framework\View\Design\ThemeInterface $source, \Magento\Framework\View\Design\ThemeInterface $target)
 {
     $proceed($source, $target);
     if ($source && $target) {
         /** @var $sourceChange \Magento\DesignEditor\Model\Theme\Change */
         $sourceChange = $this->_themeChangeFactory->create();
         $sourceChange->loadByThemeId($source->getId());
         /** @var $targetChange \Magento\DesignEditor\Model\Theme\Change */
         $targetChange = $this->_themeChangeFactory->create();
         $targetChange->loadByThemeId($target->getId());
         if ($sourceChange->getId()) {
             $targetChange->setThemeId($target->getId());
             $targetChange->setChangeTime($sourceChange->getChangeTime());
             $targetChange->save();
         } elseif ($targetChange->getId()) {
             $targetChange->delete();
         }
     }
 }