chore: Update copyright year from 2025 to 2026 across core files
- Updated copyright headers in 3,055 core application files - Changed 'Copyright (C) 2014-2025' to 'Copyright (C) 2014-2026' - Added 123 new files from EspoCRM core updates - Removed 4 deprecated files - Total changes: 61,637 insertions, 54,283 deletions This is a routine maintenance update for the new year 2026.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2025 EspoCRM, Inc.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -35,8 +35,11 @@ use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\Record\ServiceContainer;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DateTime;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\Entities\Template as TemplateEntity;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\Tools\Pdf\Data\DataLoaderManager;
|
||||
|
||||
@@ -52,6 +55,7 @@ class Service
|
||||
private Config $config,
|
||||
private Builder $builder,
|
||||
private Metadata $metadata,
|
||||
private DateTime $dateTime,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -72,8 +76,8 @@ class Service
|
||||
string $id,
|
||||
string $templateId,
|
||||
?Params $params = null,
|
||||
?Data $data = null
|
||||
): Contents {
|
||||
?Data $data = null,
|
||||
): Result {
|
||||
|
||||
$params = $params ?? Params::create()->withAcl(true);
|
||||
|
||||
@@ -130,6 +134,44 @@ class Service
|
||||
->setEngine($engine)
|
||||
->build();
|
||||
|
||||
return $printer->printEntity($entity, $params, $data);
|
||||
$contents = $printer->printEntity($entity, $params, $data);
|
||||
|
||||
$filename = $this->prepareFilename($entity, $template, $params);
|
||||
|
||||
return new Result($contents, $filename);
|
||||
}
|
||||
|
||||
private function prepareFilename(Entity $entity, TemplateEntity $template, Params $params): ?string
|
||||
{
|
||||
$filename = $template->getFilename() ?? null;
|
||||
|
||||
if (!$filename) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$forbiddenAttributeList = $this->acl->getScopeForbiddenAttributeList($entity->getEntityType());
|
||||
|
||||
foreach ($entity->getAttributeList() as $attribute) {
|
||||
$value = $entity->get($attribute);
|
||||
|
||||
if (!is_scalar($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($params->applyAcl() && in_array($attribute, $forbiddenAttributeList)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$filename = str_replace('{{' . $attribute . '}}', (string) $value, $filename);
|
||||
}
|
||||
|
||||
$today = $this->dateTime->getTodayString(null, DateTime::SYSTEM_DATE_FORMAT);
|
||||
$filename = str_replace('{{today}}', $today, $filename);
|
||||
|
||||
if (!str_ends_with(strtolower($filename), '.pdf')) {
|
||||
$filename .= '.pdf';
|
||||
}
|
||||
|
||||
return Util::sanitizeFileName($filename) ?: null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user