mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
ref
This commit is contained in:
@@ -29,6 +29,11 @@
|
||||
|
||||
namespace Espo\Core\Templates\Repositories;
|
||||
|
||||
class Base extends \Espo\Core\Repositories\Database
|
||||
{
|
||||
}
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\Repositories\Database;
|
||||
|
||||
/**
|
||||
* @extends Database<Entity>
|
||||
*/
|
||||
class Base extends Database
|
||||
{}
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
|
||||
namespace Espo\Core\Templates\Repositories;
|
||||
|
||||
class BasePlus extends \Espo\Core\Repositories\Database
|
||||
{
|
||||
}
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\Repositories\Database;
|
||||
|
||||
/**
|
||||
* @extends Database<Entity>
|
||||
*/
|
||||
class BasePlus extends Database
|
||||
{}
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
|
||||
namespace Espo\Core\Templates\Repositories;
|
||||
|
||||
class Company extends \Espo\Core\Repositories\Database
|
||||
{
|
||||
}
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\Repositories\Database;
|
||||
|
||||
/**
|
||||
* @extends Database<Entity>
|
||||
*/
|
||||
class Company extends Database
|
||||
{}
|
||||
|
||||
@@ -29,5 +29,11 @@
|
||||
|
||||
namespace Espo\Core\Templates\Repositories;
|
||||
|
||||
class Person extends \Espo\Core\Repositories\Database
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\Repositories\Database;
|
||||
|
||||
/**
|
||||
* @extends Database<Entity>
|
||||
*/
|
||||
class Person extends Database
|
||||
{}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Core\WebSocket;
|
||||
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Ratchet\Wamp\Topic;
|
||||
use Ratchet\Wamp\WampServerInterface;
|
||||
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
@@ -39,47 +40,25 @@ use RuntimeException;
|
||||
|
||||
class Pusher implements WampServerInterface
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
/** @var string[] */
|
||||
private $categoryList;
|
||||
|
||||
/**
|
||||
* @var array<string,array<string,mixed>>
|
||||
*/
|
||||
/** @var array<string, array<string, mixed>> */
|
||||
protected $categoriesData;
|
||||
|
||||
protected bool $isDebugMode = false;
|
||||
|
||||
/**
|
||||
* @var array<string,string>
|
||||
*/
|
||||
/** @var array<string, string> */
|
||||
protected $connectionIdUserIdMap = [];
|
||||
|
||||
/**
|
||||
* @var array<string,string[]>
|
||||
*/
|
||||
/** @var array<string, string[]> */
|
||||
protected $userIdConnectionIdListMap = [];
|
||||
|
||||
/**
|
||||
* @var array<string,string[]>
|
||||
*/
|
||||
/** @var array<string, string[]> */
|
||||
protected $connectionIdTopicIdListMap = [];
|
||||
|
||||
/**
|
||||
* @var array<string,ConnectionInterface>
|
||||
*/
|
||||
/** @var array<string, ConnectionInterface> */
|
||||
protected $connections = [];
|
||||
|
||||
/**
|
||||
* @var array<string,\Ratchet\Wamp\Topic<object>>
|
||||
*/
|
||||
/** @var array<string, Topic<object>> */
|
||||
protected $topicHash = [];
|
||||
|
||||
private string $phpExecutablePath;
|
||||
|
||||
/**
|
||||
* @param array<string,array<string,mixed>> $categoriesData
|
||||
* @param array<string, array<string, mixed>> $categoriesData
|
||||
*/
|
||||
public function __construct(
|
||||
array $categoriesData = [],
|
||||
@@ -106,7 +85,7 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Ratchet\Wamp\Topic<object> $topic
|
||||
* @param Topic<object> $topic
|
||||
* @return void
|
||||
*/
|
||||
public function onSubscribe(ConnectionInterface $connection, $topic)
|
||||
@@ -165,7 +144,7 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Ratchet\Wamp\Topic<object> $topic
|
||||
* @param Topic<object> $topic
|
||||
* @return void
|
||||
*/
|
||||
public function onUnSubscribe(ConnectionInterface $connection, $topic)
|
||||
@@ -208,7 +187,7 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getCategoryData(string $topicId): array
|
||||
{
|
||||
@@ -230,7 +209,7 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getParamsFromTopicId(string $topicId): array
|
||||
{
|
||||
@@ -256,7 +235,7 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Ratchet\Wamp\Topic<object> $topic
|
||||
* @param Topic<object> $topic
|
||||
*/
|
||||
protected function getAccessCheckCommandForTopic(ConnectionInterface $connection, $topic): ?string
|
||||
{
|
||||
@@ -291,7 +270,7 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Ratchet\Wamp\Topic<object> $topic
|
||||
* @param Topic<object> $topic
|
||||
* @return string
|
||||
*/
|
||||
protected function getTopicCategory($topic)
|
||||
@@ -486,8 +465,8 @@ class Pusher implements WampServerInterface
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param \Ratchet\Wamp\Topic<object> $topic
|
||||
* @param array<string,mixed> $params
|
||||
* @param Topic<object> $topic
|
||||
* @param array<string, mixed> $params
|
||||
* @return void
|
||||
*/
|
||||
public function onCall(ConnectionInterface $connection, $id, $topic, array $params)
|
||||
@@ -502,10 +481,10 @@ class Pusher implements WampServerInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Ratchet\Wamp\Topic<object> $topic
|
||||
* @param Topic<object> $topic
|
||||
* @param string $event
|
||||
* @param array<mixed,mixed> $exclude
|
||||
* @param array<mixed,mixed> $eligible
|
||||
* @param array<mixed, mixed> $exclude
|
||||
* @param array<mixed, mixed> $eligible
|
||||
* @return void
|
||||
*/
|
||||
public function onPublish(ConnectionInterface $connection, $topic, $event, array $exclude, array $eligible)
|
||||
|
||||
@@ -41,18 +41,13 @@ use RuntimeException;
|
||||
*/
|
||||
class SenderFactory implements Factory
|
||||
{
|
||||
private $injectableFactory;
|
||||
private $config;
|
||||
private $metadata;
|
||||
|
||||
private const DEFAULT_MESSAGER = 'ZeroMQ';
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory, Config $config, Metadata $metadata)
|
||||
{
|
||||
$this->injectableFactory = $injectableFactory;
|
||||
$this->config = $config;
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
public function __construct(
|
||||
private InjectableFactory $injectableFactory,
|
||||
private Config $config,
|
||||
private Metadata $metadata
|
||||
) {}
|
||||
|
||||
public function create(): Sender
|
||||
{
|
||||
|
||||
@@ -46,39 +46,30 @@ use Ratchet\Wamp\WampServer;
|
||||
*/
|
||||
class ServerStarter
|
||||
{
|
||||
private $subscriber;
|
||||
|
||||
private $categoriesData;
|
||||
|
||||
private $phpExecutablePath;
|
||||
|
||||
/** @var array<string, array<string, mixed>> */
|
||||
private array $categoriesData;
|
||||
private ?string $phpExecutablePath;
|
||||
private bool $isDebugMode;
|
||||
|
||||
private bool $useSecureServer;
|
||||
private string $port;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $port;
|
||||
|
||||
private $config;
|
||||
|
||||
public function __construct(Subscriber $subscriber, Config $config, Metadata $metadata)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
$this->config = $config;
|
||||
|
||||
public function __construct(
|
||||
private Subscriber $subscriber,
|
||||
private Config $config,
|
||||
Metadata $metadata
|
||||
) {
|
||||
$this->categoriesData = $metadata->get(['app', 'webSocket', 'categories'], []);
|
||||
|
||||
$this->phpExecutablePath = $config->get('phpExecutablePath');
|
||||
$this->isDebugMode = (bool) $config->get('webSocketDebugMode');
|
||||
$this->useSecureServer = (bool) $config->get('webSocketUseSecureServer');
|
||||
|
||||
$this->port = $this->config->get('webSocketPort');
|
||||
$port = $this->config->get('webSocketPort');
|
||||
|
||||
if (!$this->port) {
|
||||
$this->port = $this->useSecureServer ? '8443' : '8080';
|
||||
if (!$port) {
|
||||
$port = $this->useSecureServer ? '8443' : '8080';
|
||||
}
|
||||
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +104,7 @@ class ServerStarter
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function getSslParams(): array
|
||||
{
|
||||
|
||||
@@ -37,15 +37,10 @@ use Throwable;
|
||||
|
||||
class Submission
|
||||
{
|
||||
private $sender;
|
||||
|
||||
private $log;
|
||||
|
||||
public function __construct(Sender $sender, Log $log)
|
||||
{
|
||||
$this->sender = $sender;
|
||||
$this->log = $log;
|
||||
}
|
||||
public function __construct(
|
||||
private Sender $sender,
|
||||
private Log $log
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Submit to a web-socket server.
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Binding\Factory;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,14 +36,10 @@ use ZMQ;
|
||||
|
||||
class ZeroMQSender implements Sender
|
||||
{
|
||||
private $config;
|
||||
|
||||
private const DSN = 'tcp://localhost:5555';
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
public function __construct(private Config $config)
|
||||
{}
|
||||
|
||||
public function send(string $message): void
|
||||
{
|
||||
|
||||
@@ -40,14 +40,10 @@ use ZMQ;
|
||||
|
||||
class ZeroMQSubscriber implements Subscriber
|
||||
{
|
||||
private $config;
|
||||
|
||||
private const DSN = 'tcp://127.0.0.1:5555';
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
public function __construct(private Config $config)
|
||||
{}
|
||||
|
||||
public function subscribe(Pusher $pusher, LoopInterface $loop): void
|
||||
{
|
||||
|
||||
@@ -29,19 +29,15 @@
|
||||
|
||||
namespace Espo\Core\Webhook;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\Config,
|
||||
Utils\DataCache,
|
||||
Utils\FieldUtil,
|
||||
ORM\EntityManager,
|
||||
ORM\Entity,
|
||||
Utils\Log,
|
||||
};
|
||||
use Espo\Core\ORM\Entity;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DataCache;
|
||||
use Espo\Core\Utils\FieldUtil;
|
||||
use Espo\Core\Utils\Log;
|
||||
|
||||
use Espo\Entities\{
|
||||
WebhookEventQueueItem,
|
||||
Webhook,
|
||||
};
|
||||
use Espo\Entities\Webhook;
|
||||
use Espo\Entities\WebhookEventQueueItem;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
@@ -52,38 +48,23 @@ class Manager
|
||||
{
|
||||
private string $cacheKey = 'webhooks';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected $skipAttributeList = ['isFollowed', 'modifiedAt', 'modifiedBy'];
|
||||
/** @var string[] */
|
||||
protected $skipAttributeList = [
|
||||
'isFollowed',
|
||||
'modifiedAt',
|
||||
'modifiedBy'
|
||||
];
|
||||
|
||||
/**
|
||||
* @var ?array<string,bool>
|
||||
*/
|
||||
/** @var ?array<string, bool> */
|
||||
private $data = null;
|
||||
|
||||
private Config $config;
|
||||
|
||||
private DataCache $dataCache;
|
||||
|
||||
private EntityManager $entityManager;
|
||||
|
||||
private FieldUtil $fieldUtil;
|
||||
|
||||
private Log $log;
|
||||
|
||||
public function __construct(
|
||||
Config $config,
|
||||
DataCache $dataCache,
|
||||
EntityManager $entityManager,
|
||||
FieldUtil $fieldUtil,
|
||||
Log $log
|
||||
private Config $config,
|
||||
private DataCache $dataCache,
|
||||
private EntityManager $entityManager,
|
||||
private FieldUtil $fieldUtil,
|
||||
private Log $log
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->dataCache = $dataCache;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->fieldUtil = $fieldUtil;
|
||||
$this->log = $log;
|
||||
|
||||
$this->loadData();
|
||||
}
|
||||
@@ -91,7 +72,7 @@ class Manager
|
||||
private function loadData(): void
|
||||
{
|
||||
if ($this->config->get('useCache') && $this->dataCache->has($this->cacheKey)) {
|
||||
/** @var array<string,bool> $data */
|
||||
/** @var array<string, bool> $data */
|
||||
$data = $this->dataCache->get($this->cacheKey);
|
||||
|
||||
$this->data = $data;
|
||||
@@ -116,7 +97,7 @@ class Manager
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,bool>
|
||||
* @return array<string, bool>
|
||||
*/
|
||||
private function buildData(): array
|
||||
{
|
||||
|
||||
@@ -29,24 +29,18 @@
|
||||
|
||||
namespace Espo\Core\Webhook;
|
||||
|
||||
use Espo\Entities\{
|
||||
Webhook,
|
||||
WebhookQueueItem,
|
||||
WebhookEventQueueItem,
|
||||
User,
|
||||
};
|
||||
use Espo\Entities\User;
|
||||
use Espo\Entities\Webhook;
|
||||
use Espo\Entities\WebhookEventQueueItem;
|
||||
use Espo\Entities\WebhookQueueItem;
|
||||
|
||||
use Espo\Core\{
|
||||
AclManager,
|
||||
Utils\Config,
|
||||
Utils\DateTime as DateTimeUtil,
|
||||
Utils\Log,
|
||||
};
|
||||
use Espo\Core\AclManager;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
use Espo\Core\Utils\Log;
|
||||
|
||||
use Espo\ORM\{
|
||||
EntityManager,
|
||||
Query\Part\Condition as Cond,
|
||||
};
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\ORM\Query\Part\Condition as Cond;
|
||||
|
||||
use Exception;
|
||||
use DateTime;
|
||||
@@ -59,38 +53,18 @@ use stdClass;
|
||||
class Queue
|
||||
{
|
||||
private const EVENT_PORTION_SIZE = 20;
|
||||
|
||||
private const PORTION_SIZE = 20;
|
||||
|
||||
private const BATCH_SIZE = 50;
|
||||
|
||||
private const MAX_ATTEMPT_NUMBER = 4;
|
||||
|
||||
private const FAIL_ATTEMPT_PERIOD = '10 minutes';
|
||||
|
||||
private $sender;
|
||||
|
||||
private $config;
|
||||
|
||||
private $entityManager;
|
||||
|
||||
private $aclManager;
|
||||
|
||||
private $log;
|
||||
|
||||
public function __construct(
|
||||
Sender $sender,
|
||||
Config $config,
|
||||
EntityManager $entityManager,
|
||||
AclManager $aclManager,
|
||||
Log $log
|
||||
) {
|
||||
$this->sender = $sender;
|
||||
$this->config = $config;
|
||||
$this->entityManager = $entityManager;
|
||||
$this->aclManager = $aclManager;
|
||||
$this->log = $log;
|
||||
}
|
||||
private Sender $sender,
|
||||
private Config $config,
|
||||
private EntityManager $entityManager,
|
||||
private AclManager $aclManager,
|
||||
private Log $log
|
||||
) {}
|
||||
|
||||
public function process(): void
|
||||
{
|
||||
|
||||
@@ -30,11 +30,9 @@
|
||||
namespace Espo\Core\Webhook;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Entities\Webhook;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Entities\Webhook;
|
||||
|
||||
/**
|
||||
* Sends a portion.
|
||||
@@ -42,18 +40,13 @@ use Espo\Core\Utils\Json;
|
||||
class Sender
|
||||
{
|
||||
private const CONNECT_TIMEOUT = 5;
|
||||
|
||||
private const TIMEOUT = 10;
|
||||
|
||||
private Config $config;
|
||||
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
public function __construct(private Config $config)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @param array<int,mixed> $dataList
|
||||
* @param array<int, mixed> $dataList
|
||||
* @throws Error
|
||||
*/
|
||||
public function send(Webhook $webhook, array $dataList): int
|
||||
|
||||
Reference in New Issue
Block a user