/** * Used to set values on the resource record sent to the template for derivative classes * * @return void */ public function prepareResource() { $settings = $this->resource->getProperties('gridclasskey'); if (is_array($settings) && !empty($settings)) { foreach ($settings as $k => $v) { $this->resourceArray['gridclasskey-property-' . $k] = $v; } } elseif ($this->parent) { $parentSettings = $this->parent->getProperties('gridclasskey'); if (is_array($parentSettings) && isset($parentSettings['child-properties'])) { $settings = json_decode($parentSettings['child-properties'], 1); $this->resourceArray['properties'] = $settings; if (isset($settings['gridclasskey']) && !empty($settings['gridclasskey'])) { foreach ($settings['gridclasskey'] as $k => $v) { $this->resourceArray['gridclasskey-property-' . $k] = $v; } } } } }
public function beforeSave() { $this->object->set('class_key', 'GridContainer'); $this->object->set('hide_children_in_tree', true); $this->object->set('cacheable', true); $this->object->set('isfolder', true); $properties = $this->getProperties(); $settings = $this->object->getProperties('gridclasskey'); foreach ($properties as $k => $v) { if (substr($k, 0, 22) == 'gridclasskey-property-') { $key = substr($k, 22); if ($v === 'false') { $v = 0; } elseif ($v === 'true') { $v = 1; } if ($key === 'fields') { $v = json_decode($v, TRUE); } $settings[$key] = $v; } } $this->object->setProperties($settings, 'gridclasskey'); return parent::beforeSave(); }