tag settings
This commit is contained in:
@ -25,7 +25,7 @@ class EntityRelation
|
||||
$activeModules = $moduleService->getActiveModules();
|
||||
foreach ($activeModules as $module) {
|
||||
if (isset($module['type']) and $module['type'] === "entity") {
|
||||
$list[$module['slug']] = $module['name'];
|
||||
$list[$module['slug']] = $module['slug'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ class EntityRelation
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getEntitiesRelations(): array|bool
|
||||
public static function getEntitiesRelations(): array|bool
|
||||
{
|
||||
$entity_relations = OptionService::getItem("entity_relations");
|
||||
if ($entity_relations) {
|
||||
@ -61,8 +61,13 @@ class EntityRelation
|
||||
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]);
|
||||
$propertyKey = array_search($property, $entity_relations[$entity]);
|
||||
if ($entity_relations[$entity][$propertyKey] === $property) {
|
||||
unset($entity_relations[$entity][$propertyKey]);
|
||||
$entity_relations[$entity] = array_values($entity_relations[$entity]);
|
||||
if (empty($entity_relations[$entity])) {
|
||||
unset($entity_relations[$entity]);
|
||||
}
|
||||
$entity_relations_info->value = json_encode($entity_relations, JSON_UNESCAPED_UNICODE);
|
||||
$entity_relations_info->save();
|
||||
return true;
|
||||
@ -129,7 +134,7 @@ class EntityRelation
|
||||
if (isset($entity_relations[$entity])) {
|
||||
$entity_relations[$entity][] = $property;
|
||||
} else {
|
||||
$entity_relations[$entity] = $property;
|
||||
$entity_relations[$entity][] = $property;
|
||||
}
|
||||
$entity_relations_info->value = json_encode($entity_relations, JSON_UNESCAPED_UNICODE);
|
||||
$entity_relations_info->save();
|
||||
@ -231,4 +236,17 @@ class EntityRelation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getEntityByProperty(string $data): array
|
||||
{
|
||||
$entityRelations = self::getEntitiesRelations();
|
||||
$entities = [];
|
||||
foreach ($entityRelations as $entity => $property) {
|
||||
if (in_array($data, $property)) {
|
||||
$entities[] = $entity;
|
||||
}
|
||||
}
|
||||
|
||||
return $entities;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user