select: global additional appliers

This commit is contained in:
Yuri Kuznetsov
2024-09-12 11:02:24 +03:00
parent 7390b1674f
commit c0ef13c7f4
5 changed files with 57 additions and 3 deletions
+19
View File
@@ -1025,6 +1025,25 @@
</SchemaInfo>
</value>
</entry>
<entry key="metadata/app/record">
<value>
<SchemaInfo>
<option name="generatedName" value="New Schema" />
<option name="name" value="metadata/app/record" />
<option name="relativePathToSchema" value="schema/metadata/app/record.json" />
<option name="schemaVersion" value="JSON Schema version 7" />
<option name="patterns">
<list>
<Item>
<option name="pattern" value="true" />
<option name="path" value="*/Resources/metadata/app/record.json" />
<option name="mappingKind" value="Pattern" />
</Item>
</list>
</option>
</SchemaInfo>
</value>
</entry>
<entry key="metadata/app/recordId">
<value>
<SchemaInfo>
+6
View File
@@ -400,6 +400,12 @@
],
"url": "./schema/metadata/app/rebuild.json"
},
{
"fileMatch": [
"*/Resources/metadata/app/record.json"
],
"url": "./schema/metadata/app/record.json"
},
{
"fileMatch": [
"*/Resources/metadata/app/recordId.json"
@@ -42,6 +42,9 @@ class ApplierClassNameListProvider
*/
public function get(string $entityType): array
{
return $this->metadata->get(['recordDefs', $entityType, 'selectApplierClassNameList']) ?? [];
return [
...$this->metadata->get("app.record.selectApplierClassNameList", []),
...$this->metadata->get("recordDefs.$entityType.selectApplierClassNameList", []),
];
}
}
@@ -29,6 +29,7 @@
namespace Espo\Core\Select\Applier\Appliers;
use Espo\Core\Binding\ContextualBinder;
use Espo\ORM\Query\SelectBuilder as QueryBuilder;
use Espo\Core\Select\SearchParams;
use Espo\Core\InjectableFactory;
@@ -39,8 +40,11 @@ use Espo\Entities\User;
class Additional
{
public function __construct(private User $user, private InjectableFactory $injectableFactory)
{}
public function __construct(
private User $user,
private InjectableFactory $injectableFactory,
private string $entityType,
) {}
/**
* @param class-string<AdditionalApplier>[] $classNameList
@@ -63,6 +67,9 @@ class Additional
$className,
BindingContainerBuilder::create()
->bindInstance(User::class, $this->user)
->inContext($className, function (ContextualBinder $binder) {
$binder->bindValue('$entityType', $this->entityType);
})
->build()
);
}
+19
View File
@@ -0,0 +1,19 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://www.espocrm.com/schema/metadata/app/record.json",
"title": "app/select",
"description": "Record framework definitions.",
"type": "object",
"properties": {
"selectApplierClassNameList": {
"type": "array",
"items": {
"anyOf": [
{"const": "__APPEND__"},
{"type": "string"}
]
},
"description": "Classes for additional handling of a select query. Should implement Espo\\Core\\Select\\Applier\\AdditionalApplier interface. An entity type is passed to the constructor in `$entityType` parameter. As of v8.5.0."
}
}
}