/** * Custom logic code here for setting placeholders, etc * @param array $scriptProperties * @return mixed */ public function process(array $scriptProperties = array()) { $placeholders = array(); /* load template */ if (empty($scriptProperties['id'])) { return $this->failure($this->modx->lexicon('template_err_ns')); } $this->template = $this->modx->getObject('modTemplate', $scriptProperties['id']); if ($this->template == null) { return $this->failure($this->modx->lexicon('template_err_nf')); } if (!$this->template->checkPolicy('view')) { return $this->failure($this->modx->lexicon('access_denied')); } /* get properties */ $properties = $this->template->get('properties'); if (!is_array($properties)) { $properties = array(); } $data = array(); foreach ($properties as $property) { $data[] = array($property['name'], $property['desc'], !empty($property['type']) ? $property['type'] : 'textfield', !empty($property['options']) ? $property['options'] : array(), $property['value'], !empty($property['lexicon']) ? $property['lexicon'] : '', false, $property['desc_trans'], !empty($property['area']) ? $property['area'] : '', !empty($property['area_trans']) ? $property['area_trans'] : ''); } $this->templateArray = $this->template->toArray(); $this->templateArray['properties'] = $data; $this->templateArray['content'] = $this->template->getContent(); $this->prepareElement(); /* load template into parser */ $placeholders['template'] = $this->template; /* invoke OnTempFormRender event */ $placeholders['onTempFormRender'] = $this->fireRenderEvent(); return $placeholders; }
/** * @return void */ public function testGetContent() { $this->assertEquals($this->template->get('content'), $this->template->getContent()); }