Esempio n. 1
0
 /**
  * Set the properties on the Element
  * @return mixed
  */
 public function setElementProperties()
 {
     $properties = null;
     $propertyData = $this->getProperty('propdata', null);
     if ($propertyData != null && is_string($propertyData)) {
         $propertyData = $this->modx->fromJSON($propertyData);
     }
     if (is_array($propertyData)) {
         $this->object->setProperties($propertyData);
     }
     return $propertyData;
 }
 /**
  * {@inheritDoc}
  * @return mixed
  */
 public function process()
 {
     if (!$this->object) {
         $this->element->setProperties($this->getData());
         $this->element->save();
     } else {
         /* Run the beforeSave method and allow stoppage */
         $canSave = $this->beforeSave();
         if ($canSave !== true) {
             return $this->failure($canSave);
         }
         $this->object->setProperties($this->getProperty('data'));
         if ($this->saveObject() == false) {
             return $this->failure($this->modx->lexicon($this->objectType . '_err_save'));
         }
     }
     $this->logManagerAction();
     return $this->success();
 }
Esempio n. 3
0
 /**
  * Hook before save, returning false will abandon save
  * 
  * @param \modElement $modElement
  * @return boolean
  */
 public function onBeforeSave(\modElement &$modElement)
 {
     $modElement->set('type', $this->getType());
     $modElement->set('caption', $this->getCaption());
     $modElement->set('source', $this->getSource());
     $modElement->set('locked', intval($this->_locked));
     $modElement->set('rank', intval($this->_rank));
     $modElement->set('display', $this->_display);
     $modElement->set('display_params', $this->_display_params);
     $modElement->set('default_text', $this->_default_text);
     $modElement->set('elements', $this->_elements);
     $modElement->set('input_properties', $this->_input_properties);
     $modElement->set('output_properties', $this->_output_properties);
     $modElement->setProperties($this->_properties, true);
     return true;
 }