Compare commits
3 Commits
ee9d93f137
...
860ea1a82d
Author | SHA1 | Date | |
---|---|---|---|
860ea1a82d | |||
65b332811f | |||
b465020111 |
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace app\modules\tag;
|
namespace app\modules\tag;
|
||||||
|
|
||||||
use itguild\forms\builders\TextInputBuilder;
|
|
||||||
use itguild\forms\Form;
|
|
||||||
use kernel\Module;
|
use kernel\Module;
|
||||||
use kernel\modules\menu\service\MenuService;
|
use kernel\modules\menu\service\MenuService;
|
||||||
use kernel\services\MigrationService;
|
use kernel\services\MigrationService;
|
||||||
@ -37,11 +35,4 @@ class TagModule extends Module
|
|||||||
{
|
{
|
||||||
$this->menuService->removeItemBySlug("tag");
|
$this->menuService->removeItemBySlug("tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formInputs(): void
|
|
||||||
{
|
|
||||||
$input = TextInputBuilder::build("tags", ['class' => 'form-control', 'placeholder' => "Теги"]);
|
|
||||||
$input->setLabel("Теги");
|
|
||||||
$input->create()->render();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,7 +3,6 @@
|
|||||||
"version": "0.2",
|
"version": "0.2",
|
||||||
"author": "ITGuild",
|
"author": "ITGuild",
|
||||||
"slug": "tag",
|
"slug": "tag",
|
||||||
"type": "additional_property",
|
|
||||||
"description": "Tags module",
|
"description": "Tags module",
|
||||||
"app_module_path": "{APP}/modules/{slug}",
|
"app_module_path": "{APP}/modules/{slug}",
|
||||||
"module_class": "app\\modules\\tag\\TagModule",
|
"module_class": "app\\modules\\tag\\TagModule",
|
||||||
|
@ -53,9 +53,22 @@ class EntityRelation
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeFromEntityRelations(string $entity, string $property)
|
public function removeFromEntityRelations(string $entity, string $property): bool
|
||||||
{
|
{
|
||||||
|
$entity_relations_info = Option::where("key", "entity_relations")->first();
|
||||||
|
if ($entity_relations_info) {
|
||||||
|
$entity_relations = json_decode($entity_relations_info->value, true);
|
||||||
|
if ($entity_relations[$entity]) {
|
||||||
|
if ($entity_relations[$entity][$property]) {
|
||||||
|
unset($entity_relations[$entity][$property]);
|
||||||
|
$entity_relations_info->value = json_encode($entity_relations, JSON_UNESCAPED_UNICODE);
|
||||||
|
$entity_relations_info->save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntityRelationsBySlug(string $slug)
|
public function getEntityRelationsBySlug(string $slug)
|
||||||
@ -70,14 +83,15 @@ class EntityRelation
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addEntityRelation(array $data): bool
|
public function addEntityRelation(string $entity, string $property): bool
|
||||||
{
|
{
|
||||||
$entity_relations_info = Option::where("key", "entity_relations")->first();
|
$entity_relations_info = Option::where("key", "entity_relations")->first();
|
||||||
|
|
||||||
if ($entity_relations_info) {
|
if ($entity_relations_info) {
|
||||||
$entity_relations = json_decode($entity_relations_info->value, true);
|
$entity_relations = json_decode($entity_relations_info->value, true);
|
||||||
foreach ($data as $entity => $relation) {
|
if (isset($entity_relations[$entity])) {
|
||||||
$entity_relations[$entity] = $relation;
|
$entity_relations[$entity][] = $property;
|
||||||
|
} else {
|
||||||
|
$entity_relations[$entity] = $property;
|
||||||
}
|
}
|
||||||
$entity_relations_info->value = json_encode($entity_relations, JSON_UNESCAPED_UNICODE);
|
$entity_relations_info->value = json_encode($entity_relations, JSON_UNESCAPED_UNICODE);
|
||||||
$entity_relations_info->save();
|
$entity_relations_info->save();
|
||||||
|
@ -32,7 +32,6 @@ $info_to_table['data'] = $modules_info;
|
|||||||
|
|
||||||
$table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
$table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
|
||||||
|
|
||||||
|
|
||||||
$table->addAction(function ($row, $url) use ($moduleService) {
|
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||||
$slug = $row['slug'];
|
$slug = $row['slug'];
|
||||||
if ($moduleService->isActive($slug)) {
|
if ($moduleService->isActive($slug)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user