public function create($parentId, $caption) { $tagCategory = new Type($this->getDataSource()); $tagCategory->setValue('parent_id', $parentId); $tagCategory->setValue('caption', $caption); $tagCategory->insert(); $rootCategory = new Type($this->getDataSource()); $rootCategory->loadBy('qname', 'default'); $tagCategory->buildTree($rootCategory->getId(), true); return $tagCategory->getValues(); }
<?php use PMD\Capital\Configuration\DataSource; use PMD\Capital\Module\Tag\Model\Tag; use PMD\Capital\Model\ObjectType; use PMD\Capital\Module\Tag\Model\Type; use PMD\Capital\Module\Tag\Model\Association; use PMD\Capital\Module\Tag\Model\AssociationType; $tagDataSource = DataSource::get('new'); $tagTypeTree = new Type($tagDataSource); $tagTypeTree->loadBy('qname', 'company'); $attributes = $tagTypeTree->getInheritableAttributes(); print_r($attributes); /* $parents=$tagTypeTree->getParents(); foreach ($parents as $parent) { print_r($parent->loadAttributes()); } */
echo "Create Content tag type\n"; $query = "\n INSERT INTO " . Type::getTableName() . " (\n parent_id,\n qname,\n caption,\n datecreation\n ) VALUES (\n " . $rootTypeNode->getId() . ",\n 'content',\n 'Contenu',\n NOW()\n )\n"; $tagDataSource->query($query); $tagTypeContent = new Type($tagDataSource); $tagTypeContent->loadBy('qname', 'content'); $tagTypeContent->setValue('data', '{ "attributes": { "image": { "caption": "Image", "mandatory": false, "type": "image", "default": null, "enable": true } }, "rules": [] }'); $tagTypeContent->update(); $tree = new Type(); $tree->setSource($tagDataSource); $tree->buildTree(); echo "Create root tag \n"; $contentTagType = new Type($tagDataSource); $contentTagType->loadBy('qname', 'default'); $tag = new Tag(); $tag->setSource($tagDataSource); $tag->setValue('type_id', $contentTagType->getId()); $tag->setCaption('Tags'); $tag->insert(); $tagDataSource->commit(); $tag->buildTree();
"type": "text", "default": null, "enable": true, "scopes":["system"] }, "cofisemId": { "caption" : "Cofisem ID", "mandatory": false, "type": "integer", "default": null, "enable": true, "scopes":["system"] } }, "rules": [] }' . "'\n )\n"; $tagDataSource->query($query); echo "Create ISIN tag type\n"; $entrepriseTagType = new Type($tagDataSource); $entrepriseTagType->loadBy('qname', 'company'); $query = "\n INSERT INTO " . Type::getTableName() . " (\n parent_id,\n qname,\n caption,\n datecreation\n ) VALUES (\n " . $contentTagId . ",\n 'isin',\n 'Code ISIN',\n NOW()\n )\n"; $tagDataSource->query($query); echo "Create Person tag type\n"; $query = "\n INSERT INTO " . Type::getTableName() . " (\n parent_id,\n qname,\n caption,\n datecreation\n ) VALUES (\n " . $contentTagId . ",\n 'person',\n 'Personnalité',\n NOW()\n )\n"; $tagDataSource->query($query); echo "Reconstruction de l'arbre des type des tag\n"; $tree = new Type(); $tree->setSource($tagDataSource); $tree->reset(); $tree->buildTree(); $tagDataSource->commit();