예제 #1
0
 /**
  * Before saving the object, add the created or updated times
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
예제 #2
0
파일: Slider.php 프로젝트: OlgaBurtyka/m2
 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     /* if (!$this->isValidPostLink_url($object)) {
                 throw new \Magento\Framework\Exception\LocalizedException(
                     __('The post URL key contains capital letters or disallowed symbols.')
                 );
             }
     
             if ($this->isNumericPostLink_url($object)) {
                 throw new \Magento\Framework\Exception\LocalizedException(
                     __('The post URL key cannot be made of only numbers.')
                 );
             }*/
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }
예제 #3
0
 /**
  * Process post data before saving
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     //        if (!$this->isValidPostUrlKey($object)) {
     //            throw new \Magento\Framework\Exception\LocalizedException(
     //            __('The post URL key contains capital letters or disallowed symbols.')
     //            );
     //        }
     //
     //        if ($this->isNumericPostUrlKey($object)) {
     //            throw new \Magento\Framework\Exception\LocalizedException(
     //            __('The post URL key cannot be made of only numbers.')
     //            );
     //        }
     //        $object->setData('photo_url', 'fefefefewfergrtgtrh');
     //        throw new \Magento\Framework\Exception\LocalizedException(
     //        __('Alert!! '.$object->getData('photo_url'))
     //        );
     if ($object->isObjectNew() && !$object->hasCreationTime()) {
         $object->setCreationTime($this->_date->gmtDate());
     }
     $object->setUpdateTime($this->_date->gmtDate());
     return parent::_beforeSave($object);
 }