mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
type fixes
This commit is contained in:
@@ -32,6 +32,7 @@ namespace Espo\Core;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Container\Loader;
|
||||
use Espo\Core\Container\Container as ContainerInterface;
|
||||
use Espo\Core\Container\Configuration;
|
||||
use Espo\Core\Binding\BindingContainer;
|
||||
|
||||
use ReflectionClass;
|
||||
@@ -45,18 +46,33 @@ use ReflectionNamedType;
|
||||
*/
|
||||
class Container implements ContainerInterface
|
||||
{
|
||||
/**
|
||||
* @var array<string,object>
|
||||
*/
|
||||
private $data = [];
|
||||
|
||||
/**
|
||||
* @var array<string,ReflectionClass<object>>
|
||||
*/
|
||||
private $classCache = [];
|
||||
|
||||
/**
|
||||
* @var array<string,class-string<Loader>>
|
||||
*/
|
||||
private $loaderClassNames;
|
||||
|
||||
private $configuration = null;
|
||||
private ?Configuration $configuration = null;
|
||||
|
||||
private $bindingContainer;
|
||||
private ?BindingContainer $bindingContainer = null;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
/**
|
||||
* @param class-string<Configuration> $configurationClassName
|
||||
* @param array<string,class-string<Loader>> $loaderClassNames
|
||||
* @param array<string,object> $services
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct(
|
||||
string $configurationClassName,
|
||||
array $loaderClassNames = [],
|
||||
@@ -172,6 +188,10 @@ class Container implements ContainerInterface
|
||||
$this->classCache[$name] = new ReflectionClass($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Loader> $loaderClassName
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
private function initClassByLoader(string $name, string $loaderClassName): void
|
||||
{
|
||||
$loaderClass = new ReflectionClass($loaderClassName);
|
||||
@@ -196,6 +216,7 @@ class Container implements ContainerInterface
|
||||
/**
|
||||
* Get a class of a service.
|
||||
*
|
||||
* @return ReflectionClass<object>
|
||||
* @throws RuntimeException If not gettable.
|
||||
*/
|
||||
public function getClass(string $name): ReflectionClass
|
||||
@@ -245,6 +266,9 @@ class Container implements ContainerInterface
|
||||
return $this->injectableFactory->create($loaderClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string<Loader>
|
||||
*/
|
||||
private function getLoaderClassName(string $name): ?string
|
||||
{
|
||||
return $this->loaderClassNames[$name] ?? $this->configuration->getLoaderClassName($name);
|
||||
|
||||
50
application/Espo/Core/Container/Configuration.php
Normal file
50
application/Espo/Core/Container/Configuration.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Container;
|
||||
|
||||
interface Configuration
|
||||
{
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
public function getLoaderClassName(string $name): ?string;
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
public function getServiceClassName(string $name): ?string;
|
||||
|
||||
/**
|
||||
* @return ?string[]
|
||||
*/
|
||||
public function getServiceDependencyList(string $name): ?array;
|
||||
|
||||
public function isSettable(string $name): bool;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ use Espo\Core\Utils\Metadata;
|
||||
use ReflectionClass;
|
||||
use Exception;
|
||||
|
||||
class ContainerConfiguration
|
||||
class ContainerConfiguration implements Configuration
|
||||
{
|
||||
/**
|
||||
* Log must be loaded before anything.
|
||||
|
||||
@@ -47,7 +47,10 @@ class Acl extends BaseAcl
|
||||
*/
|
||||
public function checkReadOnlyAccount(string $scope): bool
|
||||
{
|
||||
return $this->aclManager->checkReadOnlyAccount($this->user, $scope);
|
||||
/** @var AclManager */
|
||||
$aclManager = $this->aclManager;
|
||||
|
||||
return $aclManager->checkReadOnlyAccount($this->user, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +58,10 @@ class Acl extends BaseAcl
|
||||
*/
|
||||
public function checkReadOnlyContact(string $scope): bool
|
||||
{
|
||||
return $this->aclManager->checkReadOnlyContact($this->user, $scope);
|
||||
/** @var AclManager */
|
||||
$aclManager = $this->aclManager;
|
||||
|
||||
return $aclManager->checkReadOnlyContact($this->user, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +69,10 @@ class Acl extends BaseAcl
|
||||
*/
|
||||
public function checkOwnershipAccount(Entity $entity): bool
|
||||
{
|
||||
return $this->aclManager->checkOwnershipAccount($this->user, $entity);
|
||||
/** @var AclManager */
|
||||
$aclManager = $this->aclManager;
|
||||
|
||||
return $aclManager->checkOwnershipAccount($this->user, $entity);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +80,10 @@ class Acl extends BaseAcl
|
||||
*/
|
||||
public function checkOwnershipContact(Entity $entity): bool
|
||||
{
|
||||
return $this->aclManager->checkOwnershipContact($this->user, $entity);
|
||||
/** @var AclManager */
|
||||
$aclManager = $this->aclManager;
|
||||
|
||||
return $aclManager->checkOwnershipContact($this->user, $entity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ class AclManager extends InternalAclManager
|
||||
*/
|
||||
protected $userAclClassName = Acl::class;
|
||||
|
||||
private ?InternalAclManager $internalAclManager = null;
|
||||
private InternalAclManager $internalAclManager;
|
||||
|
||||
private ?Portal $portal = null;
|
||||
|
||||
|
||||
@@ -91,7 +91,10 @@ class Application extends BaseApplication
|
||||
throw new Forbidden("Portal {$portalId} is not active.");
|
||||
}
|
||||
|
||||
$this->container->setPortal($portal);
|
||||
/** @var PortalContainer */
|
||||
$container = $this->container;
|
||||
|
||||
$container->setPortal($portal);
|
||||
}
|
||||
|
||||
protected function initPreloads(): void
|
||||
|
||||
Reference in New Issue
Block a user