Merge branch 'master' of https://github.com/espocrm/espocrm
This commit is contained in:
@@ -84,7 +84,6 @@ class Authentication
|
||||
protected $auth2FAFactory;
|
||||
|
||||
public function __construct(
|
||||
bool $allowAnyAccess = false,
|
||||
ApplicationUser $applicationUser,
|
||||
ApplicationState $applicationState,
|
||||
Config $config,
|
||||
@@ -92,7 +91,8 @@ class Authentication
|
||||
EntityManagerProxy $entityManagerProxy,
|
||||
LoginFactory $authLoginFactory,
|
||||
TwoFAFactory $auth2FAFactory,
|
||||
AuthTokenManager $authTokenManager
|
||||
AuthTokenManager $authTokenManager,
|
||||
bool $allowAnyAccess = false
|
||||
) {
|
||||
$this->allowAnyAccess = $allowAnyAccess;
|
||||
|
||||
|
||||
@@ -74,17 +74,19 @@ class BindingContainer
|
||||
return $this->data->getContext($className, $key);
|
||||
}
|
||||
|
||||
$dependencyClass = null;
|
||||
$dependencyClassName = null;
|
||||
|
||||
if ($param->getType()) {
|
||||
$dependencyClass = $param->getClass();
|
||||
$type = $param->getType();
|
||||
|
||||
if ($type && !$type->isBuiltin()) {
|
||||
$dependencyClassName = $type->getName();
|
||||
}
|
||||
|
||||
$key = null;
|
||||
$keyWithParamName = null;
|
||||
|
||||
if ($dependencyClass) {
|
||||
$key = $dependencyClass->getName();
|
||||
if ($dependencyClassName) {
|
||||
$key = $dependencyClassName;
|
||||
|
||||
if ($key) {
|
||||
$keyWithParamName = $key . ' $' . $param->getName();
|
||||
|
||||
@@ -125,18 +125,23 @@ class ControllerManager
|
||||
|
||||
$params = $method->getParameters();
|
||||
|
||||
if (count($params) > 0) {
|
||||
$firstParamClass = $params[0]->getClass();
|
||||
if (count($params) === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
$firstParamClass
|
||||
&&
|
||||
(
|
||||
$firstParamClass->getName() === Request::class || $firstParamClass->isSubclassOf(Request::class)
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
$type = $params[0]->getType();
|
||||
|
||||
if (!$type || $type->isBuiltin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$firstParamClass = new ReflectionClass($type->getName());
|
||||
|
||||
if (
|
||||
$firstParamClass->getName() === Request::class ||
|
||||
$firstParamClass->isSubclassOf(Request::class)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -43,6 +43,8 @@ use Espo\Core\{
|
||||
Record\Collection as RecordCollection,
|
||||
};
|
||||
|
||||
use StdClass;
|
||||
|
||||
class Record extends Base
|
||||
{
|
||||
const MAX_SIZE_LIMIT = 200;
|
||||
@@ -441,9 +443,15 @@ class Record extends Base
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if (empty($data->targetId) || empty($data->sourceIds) || !is_array($data->sourceIds) || !($data->attributes instanceof \StdClass)) {
|
||||
if (
|
||||
empty($data->targetId) ||
|
||||
empty($data->sourceIds) ||
|
||||
!is_array($data->sourceIds) ||
|
||||
!($data->attributes instanceof StdClass)
|
||||
) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$targetId = $data->targetId;
|
||||
$sourceIds = $data->sourceIds;
|
||||
$attributes = $data->attributes;
|
||||
|
||||
@@ -155,7 +155,7 @@ class Client
|
||||
return $this->execute($url, $params, $httpMethod, $httpHeaders);
|
||||
}
|
||||
|
||||
private function execute($url, $params = null, $httpMethod, array $httpHeaders = [])
|
||||
private function execute($url, $params, $httpMethod, array $httpHeaders = [])
|
||||
{
|
||||
$curlOptions = array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
|
||||
@@ -1349,7 +1349,7 @@ class Activities implements
|
||||
return Select::fromRaw($selectParams);
|
||||
}
|
||||
|
||||
protected function getActivitiesSelectParams(Entity $entity, $scope, array $statusList = [], $isHistory)
|
||||
protected function getActivitiesSelectParams(Entity $entity, $scope, array $statusList, $isHistory)
|
||||
{
|
||||
$selectManager = $this->getSelectManagerFactory()->create($scope);
|
||||
|
||||
|
||||
@@ -57,21 +57,30 @@ class Campaign extends \Espo\Services\Record implements
|
||||
{
|
||||
parent::loadAdditionalFields($entity);
|
||||
|
||||
$sentCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Sent',
|
||||
'isTest' => false
|
||||
])->count();
|
||||
$sentCount = $this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Sent',
|
||||
'isTest' => false
|
||||
])
|
||||
->count();
|
||||
|
||||
if (!$sentCount) {
|
||||
$sentCount = null;
|
||||
}
|
||||
|
||||
$entity->set('sentCount', $sentCount);
|
||||
|
||||
$openedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Opened',
|
||||
'isTest' => false
|
||||
])->count();
|
||||
$openedCount = $this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Opened',
|
||||
'isTest' => false
|
||||
])
|
||||
->count();
|
||||
|
||||
$entity->set('openedCount', $openedCount);
|
||||
|
||||
$openedPercentage = null;
|
||||
@@ -80,23 +89,27 @@ class Campaign extends \Espo\Services\Record implements
|
||||
}
|
||||
$entity->set('openedPercentage', $openedPercentage);
|
||||
|
||||
$clickedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Clicked',
|
||||
'isTest' => false,
|
||||
'id=s' => [
|
||||
'entityType' => 'CampaignLogRecord',
|
||||
'selectParams' => [
|
||||
'select' => ['MIN:id'],
|
||||
'whereClause' => [
|
||||
'action' => 'Clicked',
|
||||
'isTest' => false,
|
||||
'campaignId' => $entity->id,
|
||||
$clickedCount = $this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Clicked',
|
||||
'isTest' => false,
|
||||
'id=s' => [
|
||||
'entityType' => 'CampaignLogRecord',
|
||||
'selectParams' => [
|
||||
'select' => ['MIN:id'],
|
||||
'whereClause' => [
|
||||
'action' => 'Clicked',
|
||||
'isTest' => false,
|
||||
'campaignId' => $entity->id,
|
||||
],
|
||||
'groupBy' => ['queueItemId'],
|
||||
],
|
||||
'groupBy' => ['queueItemId'],
|
||||
],
|
||||
],
|
||||
])->count();
|
||||
])
|
||||
->count();
|
||||
|
||||
$entity->set('clickedCount', $clickedCount);
|
||||
|
||||
$clickedPercentage = null;
|
||||
@@ -105,47 +118,71 @@ class Campaign extends \Espo\Services\Record implements
|
||||
}
|
||||
$entity->set('clickedPercentage', $clickedPercentage);
|
||||
|
||||
$optedInCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Opted In',
|
||||
'isTest' => false
|
||||
])->count();
|
||||
if (!$optedInCount) $optedInCount = null;
|
||||
$optedInCount = $this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Opted In',
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
|
||||
if (!$optedInCount) {
|
||||
$optedInCount = null;
|
||||
}
|
||||
|
||||
$entity->set('optedInCount', $optedInCount);
|
||||
|
||||
$optedOutCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Opted Out',
|
||||
'isTest' => false
|
||||
])->count();
|
||||
$optedOutCount = $this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Opted Out',
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
|
||||
$entity->set('optedOutCount', $optedOutCount);
|
||||
|
||||
$optedOutPercentage = null;
|
||||
|
||||
if ($sentCount > 0) {
|
||||
$optedOutPercentage = round($optedOutCount / $sentCount * 100, 2, \PHP_ROUND_HALF_EVEN);
|
||||
}
|
||||
|
||||
$entity->set('optedOutPercentage', $optedOutPercentage);
|
||||
|
||||
$bouncedCount = $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Bounced',
|
||||
'isTest' => false
|
||||
])->count();
|
||||
$bouncedCount = $this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
'action' => 'Bounced',
|
||||
'isTest' => false,
|
||||
])
|
||||
->count();
|
||||
|
||||
$entity->set('bouncedCount', $bouncedCount);
|
||||
|
||||
$bouncedPercentage = null;
|
||||
|
||||
if ($sentCount && $sentCount > 0) {
|
||||
$bouncedPercentage = round($bouncedCount / $sentCount * 100, 2, \PHP_ROUND_HALF_EVEN);
|
||||
}
|
||||
|
||||
$entity->set('bouncedPercentage', $bouncedPercentage);
|
||||
|
||||
if ($this->getAcl()->check('Lead')) {
|
||||
$leadCreatedCount = $this->getEntityManager()->getRepository('Lead')->where([
|
||||
'campaignId' => $entity->id
|
||||
])->count();
|
||||
$leadCreatedCount = $this->getEntityManager()
|
||||
->getRepository('Lead')
|
||||
->where([
|
||||
'campaignId' => $entity->id,
|
||||
])
|
||||
->count();
|
||||
|
||||
if (!$leadCreatedCount) {
|
||||
$leadCreatedCount = null;
|
||||
}
|
||||
|
||||
$entity->set('leadCreatedCount', $leadCreatedCount);
|
||||
}
|
||||
|
||||
@@ -157,24 +194,28 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'select' => ['SUM:amountConverted'],
|
||||
'whereClause' => [
|
||||
'stage' => 'Closed Won',
|
||||
'campaignId' => $entity->id
|
||||
'campaignId' => $entity->id,
|
||||
],
|
||||
'groupBy' => ['opportunity.campaignId']
|
||||
'groupBy' => ['opportunity.campaignId'],
|
||||
];
|
||||
|
||||
$sql = $this->getEntityManager()->getQueryComposer()->compose(Select::fromRaw($params));
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
$sth = $pdo->prepare($sql);
|
||||
|
||||
$sth->execute();
|
||||
|
||||
$revenue = null;
|
||||
|
||||
if ($row = $sth->fetch(\PDO::FETCH_ASSOC)) {
|
||||
$revenue = floatval($row['SUM:amountConverted']);
|
||||
|
||||
if (!$revenue) {
|
||||
$revenue = null;
|
||||
}
|
||||
}
|
||||
|
||||
$entity->set('revenue', $revenue);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +232,7 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'parentId' => $target->id,
|
||||
'parentType' => $target->getEntityType(),
|
||||
'action' => 'Lead Created',
|
||||
'isTest' => $isTest
|
||||
'isTest' => $isTest,
|
||||
]);
|
||||
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
@@ -199,9 +240,9 @@ class Campaign extends \Espo\Services\Record implements
|
||||
|
||||
public function logSent(
|
||||
string $campaignId,
|
||||
?string $queueItemId = null,
|
||||
?string $queueItemId,
|
||||
Entity $target,
|
||||
Entity $emailOrEmailTemplate = null,
|
||||
Entity $emailOrEmailTemplate,
|
||||
$emailAddress,
|
||||
$actionDate = null,
|
||||
$isTest = false
|
||||
@@ -218,7 +259,7 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'action' => 'Sent',
|
||||
'stringData' => $emailAddress,
|
||||
'queueItemId' => $queueItemId,
|
||||
'isTest' => $isTest
|
||||
'isTest' => $isTest,
|
||||
]);
|
||||
|
||||
if ($emailOrEmailTemplate) {
|
||||
@@ -230,19 +271,35 @@ class Campaign extends \Espo\Services\Record implements
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
}
|
||||
|
||||
public function logBounced($campaignId, $queueItemId = null, Entity $target, $emailAddress, $isHard = false, $actionDate = null, $isTest = false)
|
||||
{
|
||||
if ($queueItemId && $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Bounced',
|
||||
'isTest' => $isTest
|
||||
])->findOne()) {
|
||||
public function logBounced(
|
||||
$campaignId,
|
||||
$queueItemId,
|
||||
Entity $target,
|
||||
$emailAddress,
|
||||
$isHard = false,
|
||||
$actionDate = null,
|
||||
$isTest = false
|
||||
) {
|
||||
if (
|
||||
$queueItemId &&
|
||||
$this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Bounced',
|
||||
'isTest' => $isTest,
|
||||
])
|
||||
->findOne()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($actionDate)) {
|
||||
$actionDate = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$logRecord = $this->getEntityManager()->getEntity('CampaignLogRecord');
|
||||
|
||||
$logRecord->set([
|
||||
'campaignId' => $campaignId,
|
||||
'actionDate' => $actionDate,
|
||||
@@ -251,8 +308,9 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'action' => 'Bounced',
|
||||
'stringData' => $emailAddress,
|
||||
'queueItemId' => $queueItemId,
|
||||
'isTest' => $isTest
|
||||
'isTest' => $isTest,
|
||||
]);
|
||||
|
||||
if ($isHard) {
|
||||
$logRecord->set('stringAdditionalData', 'Hard');
|
||||
} else {
|
||||
@@ -261,21 +319,38 @@ class Campaign extends \Espo\Services\Record implements
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
}
|
||||
|
||||
public function logOptedIn($campaignId, $queueItemId = null, Entity $target, $emailAddress = null, $actionDate = null, $isTest = false)
|
||||
{
|
||||
if ($queueItemId && $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opted In',
|
||||
'isTest' => $isTest
|
||||
])->findOne()) return;
|
||||
public function logOptedIn(
|
||||
$campaignId,
|
||||
$queueItemId,
|
||||
Entity $target,
|
||||
$emailAddress = null,
|
||||
$actionDate = null,
|
||||
$isTest = false
|
||||
) {
|
||||
if (
|
||||
$queueItemId &&
|
||||
$this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opted In',
|
||||
'isTest' => $isTest,
|
||||
])
|
||||
->findOne()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($actionDate)) {
|
||||
$actionDate = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
if (!$emailAddress) {
|
||||
$emailAddress = $target->get('emailAddress');
|
||||
}
|
||||
|
||||
$logRecord = $this->getEntityManager()->getEntity('CampaignLogRecord');
|
||||
|
||||
$logRecord->set([
|
||||
'campaignId' => $campaignId,
|
||||
'actionDate' => $actionDate,
|
||||
@@ -284,23 +359,38 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'action' => 'Opted In',
|
||||
'stringData' => $emailAddress,
|
||||
'queueItemId' => $queueItemId,
|
||||
'isTest' => $isTest
|
||||
'isTest' => $isTest,
|
||||
]);
|
||||
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
}
|
||||
|
||||
public function logOptedOut($campaignId, $queueItemId = null, Entity $target, $emailAddress = null, $actionDate = null, $isTest = false)
|
||||
{
|
||||
if ($queueItemId && $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array(
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opted Out',
|
||||
'isTest' => $isTest
|
||||
))->findOne()) {
|
||||
public function logOptedOut(
|
||||
$campaignId,
|
||||
$queueItemId,
|
||||
Entity $target,
|
||||
$emailAddress = null,
|
||||
$actionDate = null,
|
||||
$isTest = false
|
||||
) {
|
||||
if (
|
||||
$queueItemId &&
|
||||
$this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opted Out',
|
||||
'isTest' => $isTest,
|
||||
])
|
||||
->findOne()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($actionDate)) {
|
||||
$actionDate = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$logRecord = $this->getEntityManager()->getEntity('CampaignLogRecord');
|
||||
$logRecord->set(array(
|
||||
'campaignId' => $campaignId,
|
||||
@@ -315,22 +405,31 @@ class Campaign extends \Espo\Services\Record implements
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
}
|
||||
|
||||
public function logOpened($campaignId, $queueItemId = null, Entity $target, $actionDate = null, $isTest = false)
|
||||
public function logOpened($campaignId, $queueItemId, Entity $target, $actionDate = null, $isTest = false)
|
||||
{
|
||||
if (empty($actionDate)) {
|
||||
$actionDate = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
if ($queueItemId && $this->getEntityManager()->getRepository('CampaignLogRecord')->where(array(
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opened',
|
||||
'isTest' => $isTest
|
||||
))->findOne()) {
|
||||
if (
|
||||
$queueItemId &&
|
||||
$this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Opened',
|
||||
'isTest' => $isTest,
|
||||
])
|
||||
->findOne()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$queueItem = $this->getEntityManager()->getEntity('EmailQueueItem', $queueItemId);
|
||||
|
||||
if ($queueItem) {
|
||||
$massEmail = $this->getEntityManager()->getEntity('MassEmail', $queueItem->get('massEmailId'));
|
||||
|
||||
if ($massEmail && $massEmail->id) {
|
||||
$logRecord = $this->getEntityManager()->getEntity('CampaignLogRecord');
|
||||
$logRecord->set([
|
||||
@@ -342,28 +441,42 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'objectId' => $massEmail->get('emailTemplateId'),
|
||||
'objectType' => 'EmailTemplate',
|
||||
'queueItemId' => $queueItemId,
|
||||
'isTest' => $isTest
|
||||
'isTest' => $isTest,
|
||||
]);
|
||||
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function logClicked($campaignId, $queueItemId = null, Entity $target, Entity $trackingUrl, $actionDate = null, $isTest = false)
|
||||
{
|
||||
public function logClicked(
|
||||
$campaignId,
|
||||
$queueItemId,
|
||||
Entity $target,
|
||||
Entity $trackingUrl,
|
||||
$actionDate = null,
|
||||
$isTest = false
|
||||
) {
|
||||
if ($this->getConfig()->get('massEmailOpenTracking')) {
|
||||
$this->logOpened($campaignId, $queueItemId, $target);
|
||||
}
|
||||
|
||||
if ($queueItemId && $this->getEntityManager()->getRepository('CampaignLogRecord')->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Clicked',
|
||||
'objectId' => $trackingUrl->id,
|
||||
'objectType' => $trackingUrl->getEntityType(),
|
||||
'isTest' => $isTest
|
||||
])->findOne()) {
|
||||
if (
|
||||
$queueItemId &&
|
||||
$this->getEntityManager()
|
||||
->getRepository('CampaignLogRecord')
|
||||
->where([
|
||||
'queueItemId' => $queueItemId,
|
||||
'action' => 'Clicked',
|
||||
'objectId' => $trackingUrl->id,
|
||||
'objectType' => $trackingUrl->getEntityType(),
|
||||
'isTest' => $isTest,
|
||||
])
|
||||
->findOne()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($actionDate)) {
|
||||
$actionDate = date('Y-m-d H:i:s');
|
||||
}
|
||||
@@ -378,7 +491,7 @@ class Campaign extends \Espo\Services\Record implements
|
||||
'objectId' => $trackingUrl->id,
|
||||
'objectType' => $trackingUrl->getEntityType(),
|
||||
'queueItemId' => $queueItemId,
|
||||
'isTest' => $isTest
|
||||
'isTest' => $isTest,
|
||||
]);
|
||||
$this->getEntityManager()->saveEntity($logRecord);
|
||||
}
|
||||
|
||||
@@ -1085,7 +1085,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
}
|
||||
|
||||
protected function convertComplexExpression(
|
||||
?Entity $entity = null, string $attribute, bool $distinct = false, array &$params
|
||||
?Entity $entity = null, string $attribute, bool $distinct, array &$params
|
||||
) : string {
|
||||
$function = null;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
}
|
||||
|
||||
protected function getFunctionArgumentPart(
|
||||
Entity $entity, string $attribute, bool $distinct = false, array &$params
|
||||
Entity $entity, string $attribute, bool $distinct, array &$params
|
||||
) : string {
|
||||
$argument = $attribute;
|
||||
|
||||
@@ -1767,7 +1767,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getBelongsToJoinsPart(Entity $entity, ?array $select = null, array $skipList = [], array $params) : string
|
||||
protected function getBelongsToJoinsPart(Entity $entity, ?array $select, array $skipList, array $params) : string
|
||||
{
|
||||
$joinsArr = [];
|
||||
|
||||
@@ -1939,7 +1939,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
}
|
||||
|
||||
protected function getAggregationSelectPart(
|
||||
Entity $entity, string $aggregation, string $aggregationBy, bool $distinct = false, array $params
|
||||
Entity $entity, string $aggregation, string $aggregationBy, bool $distinct, array $params
|
||||
) : ?string {
|
||||
if (!isset($entity->getAttributes()[$aggregationBy])) {
|
||||
return null;
|
||||
@@ -2510,7 +2510,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
}
|
||||
|
||||
protected function getJoinsTypePart(
|
||||
Entity $entity, array $joins, bool $isLeft = false, $joinConditions = [], array $params
|
||||
Entity $entity, array $joins, bool $isLeft, $joinConditions, array $params
|
||||
) : string {
|
||||
$joinSqlList = [];
|
||||
|
||||
@@ -2556,7 +2556,7 @@ abstract class BaseQueryComposer implements QueryComposer
|
||||
return implode(' ', $joinSqlList);
|
||||
}
|
||||
|
||||
protected function buildJoinConditionStatement(Entity $entity, $alias = null, $left, $right, array $params)
|
||||
protected function buildJoinConditionStatement(Entity $entity, $alias, $left, $right, array $params)
|
||||
{
|
||||
$sql = '';
|
||||
|
||||
|
||||
@@ -442,7 +442,17 @@ class EmailAccount extends Record implements
|
||||
$flags = $message->getFlags();
|
||||
}
|
||||
|
||||
$email = $this->importMessage($importer, $emailAccount, $message, $teamIdList, null, [$userId], $filterCollection, $fetchOnlyHeader, $folderData);
|
||||
$email = $this->importMessage(
|
||||
$importer,
|
||||
$emailAccount,
|
||||
$message,
|
||||
$teamIdList,
|
||||
null,
|
||||
[$userId],
|
||||
$filterCollection,
|
||||
$fetchOnlyHeader,
|
||||
$folderData
|
||||
);
|
||||
|
||||
if ($emailAccount->get('keepFetchedEmailsUnread')) {
|
||||
if (is_array($flags) && empty($flags[Storage::FLAG_SEEN])) {
|
||||
@@ -529,8 +539,8 @@ class EmailAccount extends Record implements
|
||||
$emailAccount,
|
||||
$message,
|
||||
$teamIdList,
|
||||
$userId = null,
|
||||
$userIdList = [],
|
||||
$userId,
|
||||
$userIdList,
|
||||
$filterCollection,
|
||||
$fetchOnlyHeader,
|
||||
$folderData = null
|
||||
|
||||
@@ -364,8 +364,15 @@ class InboundEmail extends RecordService implements
|
||||
}
|
||||
|
||||
$email = $this->importMessage(
|
||||
$importer, $emailAccount, $message, $teamIdList, $userId, $userIdList,
|
||||
$filterCollection, $fetchOnlyHeader, null
|
||||
$importer,
|
||||
$emailAccount,
|
||||
$message,
|
||||
$teamIdList,
|
||||
$userId,
|
||||
$userIdList,
|
||||
$filterCollection,
|
||||
$fetchOnlyHeader,
|
||||
null
|
||||
);
|
||||
|
||||
if ($emailAccount->get('keepFetchedEmailsUnread')) {
|
||||
@@ -481,8 +488,15 @@ class InboundEmail extends RecordService implements
|
||||
}
|
||||
|
||||
protected function importMessage(
|
||||
$importer, $emailAccount, $message, $teamIdList, $userId = null, $userIdList = [],
|
||||
$filterCollection, $fetchOnlyHeader, $folderData = null
|
||||
$importer,
|
||||
$emailAccount,
|
||||
$message,
|
||||
$teamIdList,
|
||||
$userId,
|
||||
$userIdList,
|
||||
$filterCollection,
|
||||
$fetchOnlyHeader,
|
||||
$folderData = null
|
||||
) {
|
||||
$email = null;
|
||||
|
||||
|
||||
@@ -2205,7 +2205,7 @@ class Record implements Crud,
|
||||
}
|
||||
}
|
||||
|
||||
public function merge($id, array $sourceIdList = [], $attributes)
|
||||
public function merge(string $id, array $sourceIdList, StdClass $attributes)
|
||||
{
|
||||
if (empty($id)) {
|
||||
throw new Error("No ID passed.");
|
||||
|
||||
Generated
+3
-3
@@ -1527,9 +1527,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
|
||||
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz",
|
||||
"integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==",
|
||||
"dev": true
|
||||
},
|
||||
"interpret": {
|
||||
|
||||
@@ -39,7 +39,7 @@ use Espo\Core\{
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionParameter;
|
||||
use ReflectionType;
|
||||
use ReflectionNamedType;
|
||||
|
||||
class BindingContainerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
@@ -75,17 +75,32 @@ class BindingContainerTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$class = null;
|
||||
|
||||
$type = $this->getMockBuilder(ReflectionNamedType::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
if ($className) {
|
||||
$class = $this->createClassMock($className);
|
||||
|
||||
$type = $this->getMockBuilder(ReflectionType::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
$param
|
||||
$type
|
||||
->expects($this->any())
|
||||
->method('getType')
|
||||
->willReturn($type);
|
||||
->method('isBuiltin')
|
||||
->willReturn(false);
|
||||
|
||||
$type
|
||||
->expects($this->any())
|
||||
->method('getName')
|
||||
->willReturn($className);
|
||||
}
|
||||
|
||||
$type
|
||||
->expects($this->any())
|
||||
->method('isBuiltin')
|
||||
->willReturn(true);
|
||||
|
||||
$param
|
||||
->expects($this->any())
|
||||
->method('getType')
|
||||
->willReturn($type);
|
||||
|
||||
$param
|
||||
->expects($this->any())
|
||||
->method('getName')
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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 tests\unit\Espo\Core;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\ClassFinder,
|
||||
InjectableFactory,
|
||||
ControllerManager,
|
||||
Api\RequestWrapper,
|
||||
Api\ResponseWrapper,
|
||||
};
|
||||
|
||||
use tests\unit\testClasses\Controllers\TestController;
|
||||
|
||||
class ControllerManagerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->classFinder = $this->getMockBuilder(ClassFinder::class)->disableOriginalConstructor()->getMock();
|
||||
$this->injectableFactory = $this->getMockBuilder(InjectableFactory::class)->disableOriginalConstructor()->getMock();
|
||||
$this->request = $this->getMockBuilder(RequestWrapper::class)->disableOriginalConstructor()->getMock();
|
||||
$this->response = $this->getMockBuilder(ResponseWrapper::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->controllerManager = new ControllerManager($this->injectableFactory, $this->classFinder);
|
||||
}
|
||||
|
||||
public function testAction1()
|
||||
{
|
||||
$controller = $this->getMockBuilder(TestController::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->classFinder
|
||||
->expects($this->once())
|
||||
->method('find')
|
||||
->with('Controllers', 'Test')
|
||||
->willReturn(TestController::class);
|
||||
|
||||
$this->request
|
||||
->expects($this->once())
|
||||
->method('getMethod')
|
||||
->willReturn('POST');
|
||||
|
||||
$this->injectableFactory
|
||||
->expects($this->once())
|
||||
->method('createWith')
|
||||
->with(TestController::class, ['name' => 'Test'])
|
||||
->willReturn($controller);
|
||||
|
||||
$controller
|
||||
->expects($this->once())
|
||||
->method('postActionHello')
|
||||
->with($this->request, $this->response);
|
||||
|
||||
$this->controllerManager->process('Test', 'hello', $this->request, $this->response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy 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 tests\unit\testClasses\Controllers;
|
||||
|
||||
use Espo\Core\{
|
||||
Api\Request,
|
||||
Api\Response,
|
||||
};
|
||||
|
||||
class TestController
|
||||
{
|
||||
public function postActionHello(Request $request, Response $response)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user