type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-19 11:11:58 +02:00
parent aa51a58da5
commit 4015e2f254
5 changed files with 19 additions and 11 deletions
@@ -63,10 +63,11 @@ class Container
'user',
];
/** @var string[] */
$fileList = scandir('application/Espo/Core/Loaders');
if (file_exists('custom/Espo/Custom/Core/Loaders')) {
$fileList = array_merge($fileList, scandir('custom/Espo/Custom/Core/Loaders'));
$fileList = array_merge($fileList, scandir('custom/Espo/Custom/Core/Loaders') ?: []);
}
foreach ($fileList as $file) {
@@ -35,7 +35,7 @@ use Espo\Services\Stream as StreamService;
use Espo\Core\Notification\AssignmentNotificator;
use Espo\Core\Notification\AssignmentNotificator\Params;
use Espo\Core\Notification\UserEnabledChecker;
use Espo\Core\ServiceFactory;
use Espo\Core\InjectableFactory;
use Espo\Core\AclManager;
use Espo\ORM\EntityManager;
@@ -61,7 +61,7 @@ class Email implements AssignmentNotificator
private $entityManager;
private $serviceFactory;
private $injectableFactory;
private $aclManager;
@@ -71,13 +71,13 @@ class Email implements AssignmentNotificator
User $user,
EntityManager $entityManager,
UserEnabledChecker $userChecker,
ServiceFactory $serviceFactory,
InjectableFactory $injectableFactory,
AclManager $aclManager
) {
$this->user = $user;
$this->entityManager = $entityManager;
$this->userChecker = $userChecker;
$this->serviceFactory = $serviceFactory;
$this->injectableFactory = $injectableFactory;
$this->aclManager = $aclManager;
}
@@ -294,7 +294,7 @@ class Email implements AssignmentNotificator
private function getStreamService(): StreamService
{
if (empty($this->streamService)) {
$this->streamService = $this->serviceFactory->create('Stream');
$this->streamService = $this->injectableFactory->create(StreamService::class);
}
return $this->streamService;
@@ -31,6 +31,8 @@ namespace Espo\Classes\ConsoleCommands;
use Espo\Tools\Import\Service;
use Espo\Core\Utils\File\Manager as FileManager;
use Espo\Core\{
Console\Command,
Console\Command\Params,
@@ -41,11 +43,14 @@ use Throwable;
class Import implements Command
{
private $service;
private Service $service;
public function __construct(Service $service)
private FileManager $fileManager;
public function __construct(Service $service, FileManager $fileManager)
{
$this->service = $service;
$this->fileManager = $fileManager;
}
public function run(Params $params, IO $io) : void
@@ -64,13 +69,13 @@ class Import implements Command
return;
}
if (!file_exists($filePath)) {
if (!$this->fileManager->isFile($filePath)) {
$io->writeLine("File not found.");
return;
}
$contents = file_get_contents($filePath);
$contents = $this->fileManager->getContents($filePath);
try {
$result = $this->service->importContentsWithParamsId($contents, $paramsId);
@@ -47,6 +47,7 @@ use ICal\ICal;
use ICal\Event;
use Throwable;
use stdClass;
/**
* @implements Loader<\Espo\Entities\Email>
@@ -174,7 +175,7 @@ class IcsDataLoader implements Loader
}
}
private function loadCreatedEvent(Entity $entity, EspoEvent $espoEvent, object $eventData): void
private function loadCreatedEvent(Entity $entity, EspoEvent $espoEvent, stdClass $eventData): void
{
$emailSameEvent = $this->entityManager
->getRDBRepository(Email::ENTITY_TYPE)
@@ -104,6 +104,7 @@ class StringDataLoader implements Loader
return;
}
/** @var ?string */
$fromEmailAddressId = $entity->get('fromEmailAddressId');
if (!$fromEmailAddressId) {