/** * Custom logic code here for setting placeholders, etc * @param array $scriptProperties * @return mixed */ public function process(array $scriptProperties = array()) { $placeholders = array(); /* load tv */ if (empty($scriptProperties['id'])) { return $this->failure($this->modx->lexicon('tv_err_ns')); } $this->tv = $this->modx->getObject('modTemplateVar', $scriptProperties['id']); if ($this->tv == null) { return $this->failure($this->modx->lexicon('tv_err_nf')); } if (!$this->tv->checkPolicy('view')) { return $this->failure($this->modx->lexicon('access_denied')); } /* get properties */ $properties = $this->tv->get('properties'); if (!is_array($properties)) { $properties = array(); } $data = array(); foreach ($properties as $property) { $data[] = array($property['name'], $property['desc'], $property['type'], $property['options'], $property['value'], $property['lexicon'], false, $property['desc_trans']); } $this->tvArray = $this->tv->toArray(); $this->tvArray['properties'] = $data; $this->tvArray['default_text'] = $this->tv->getContent(); $this->tvArray['sources'] = $this->getElementSources(); $this->prepareElement(); /* load tv into parser */ $placeholders['tv'] = $this->tv; /* invoke OnTVFormRender event */ $placeholders['onTVFormRender'] = $this->fireRenderEvent(); return $placeholders; }
/** * @return void */ public function testGetContent() { $this->assertEquals($this->tv->get('default_text'), $this->tv->getContent()); }