event select defs
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"selectAttributesDependancyMap": {
|
||||
"duration": [
|
||||
"dateStart",
|
||||
"dateEnd"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -477,6 +477,8 @@ class EntityManager
|
||||
}
|
||||
$this->getMetadata()->set('clientDefs', $name, $clientDefsData);
|
||||
|
||||
$this->processMetadataCreateSelectDefs($templatePath, $name, $type);
|
||||
|
||||
$this->getBaseLanguage()->set('Global', 'scopeNames', $name, $labelSingular);
|
||||
$this->getBaseLanguage()->set('Global', 'scopeNamesPlural', $name, $labelPlural);
|
||||
|
||||
@@ -493,6 +495,21 @@ class EntityManager
|
||||
return true;
|
||||
}
|
||||
|
||||
private function processMetadataCreateSelectDefs(string $templatePath, string $name, string $type): void
|
||||
{
|
||||
$path = $templatePath . "/Metadata/{$type}/selectDefs.json";
|
||||
|
||||
if (!$this->getFileManager()->isFile($path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contents = $this->getFileManager()->getContents($path);
|
||||
|
||||
$data = Json::decode($contents, true);
|
||||
|
||||
$this->getMetadata()->set('selectDefs', $name, $data);
|
||||
}
|
||||
|
||||
public function update($name, $data)
|
||||
{
|
||||
if (!$this->getMetadata()->get('scopes.' . $name)) {
|
||||
|
||||
@@ -27,13 +27,20 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
use Espo\Core\Container;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Json;
|
||||
|
||||
class AfterUpgrade
|
||||
{
|
||||
public function run($container)
|
||||
public function run(Container $container): void
|
||||
{
|
||||
$entityManager = $container->get('entityManager');
|
||||
|
||||
$this->updateTemplates($entityManager);
|
||||
|
||||
$this->updateEventMetadata($container->get('metadata'), $container->get('fileManager'));
|
||||
}
|
||||
|
||||
protected function updateTemplates($entityManager)
|
||||
@@ -56,4 +63,34 @@ class AfterUpgrade
|
||||
$entityManager->saveEntity($template);
|
||||
}
|
||||
}
|
||||
|
||||
private function updateEventMetadata(Metadata $metadata, FileManager $fileManager): void
|
||||
{
|
||||
$defs = $metadata->get(['scopes']);
|
||||
|
||||
$toSave = false;
|
||||
|
||||
$path = "application/Espo/Core/Templates/Metadata/Event/selectDefs.json";
|
||||
|
||||
$contents = $fileManager->getContents($path);
|
||||
|
||||
$data = Json::decode($contents, true);
|
||||
|
||||
foreach ($defs as $entityType => $item) {
|
||||
$isCustom = $item['isCustom'] ?? false;
|
||||
$type = $item['type'] ?? false;
|
||||
|
||||
if (!$isCustom || $type !== 'Event') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$toSave = true;
|
||||
|
||||
$metadata->set('selectDefs', $entityType, $data);
|
||||
}
|
||||
|
||||
if ($toSave) {
|
||||
$metadata->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user