/** * tests Module->getRelationsAsJson() */ public function testGetRelationsAsJson() { $relation = $this->setupRelation(); $this->module->addRelation($relation); $expected = '{"0_1":"parent"}'; $this->assertEquals($expected, $this->module->getRelationsAsJson()); $relation = $this->setupRelation(); $entities = $relation->getEntities(); $entities[0]->setIndex(2); $entities[1]->setIndex(3); $this->module->addRelation($relation); $expected = '{"0_1":"parent","2_3":"parent"}'; $this->assertEquals($expected, $this->module->getRelationsAsJson()); }
/** * get form fields * * @return array */ public function getFields() { $entities = [$this->moduleInstance->getEntityCode() => __('MODULE'), $this->settingsInstance->getEntityCode() => __('SETTINGS'), $this->entityInstance->getEntityCode() => __('ENTITY'), $this->attributeInstance->getEntityCode() => __('ATTRIBUTE')]; $data = []; foreach ($entities as $entityCode => $entityLabel) { $data[] = ['__colspan' => $entityLabel]; $config = $this->formConfig->getConfig('form/' . $entityCode, true, []); foreach ($config['fieldset'] as $fieldset) { $data[] = ['__colspan' => $fieldset['label']]; foreach ($fieldset['field'] as $field) { if ($field['type'] != 'hidden') { $data[] = ['field' => $field['label'], 'type' => $field['type'], 'description' => isset($field['tooltip']) ? $field['tooltip'] : '']; } } } } return $data; }
/** * @param bool $namespaceOnly * @return string */ public function getBaseWritePath($namespaceOnly = false) { return $this->module->getSettings()->getXmlRootPath() . '/' . $this->module->getNamespace() . '/' . (!$namespaceOnly ? $this->module->getModuleName() . '/' : ''); }