Skip to content

Commit

Permalink
ref
Browse files Browse the repository at this point in the history
  • Loading branch information
yurikuzn committed Nov 28, 2023
1 parent e97c736 commit fa77fa0
Show file tree
Hide file tree
Showing 64 changed files with 1,842 additions and 1,787 deletions.
1 change: 1 addition & 0 deletions .idea/real-estate.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
">=7.4.0"
],
"php": [
">=7.4"
">=8.0"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/************************************************************************
* This file is part of Real Estate extension for EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* Real Estate extension 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.
*
* Real Estate extension 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\Modules\RealEstate\Classes\Record\Hooks\RealEstateProperty;

use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Record\Hook\UpdateHook;
use Espo\Core\Record\UpdateParams;
use Espo\Core\Select\SearchParams;
use Espo\Modules\RealEstate\Entities\RealEstateProperty;
use Espo\Modules\RealEstate\Entities\RealEstateRequest;
use Espo\Modules\RealEstate\Tools\Property\Service;
use Espo\ORM\Entity;
use Espo\ORM\EntityManager;

/**
* @noinspection PhpUnused
* @implements UpdateHook<RealEstateProperty>
*/
class BeforeUpdate implements UpdateHook
{
public function __construct(
private Service $service,
private EntityManager $entityManager
) {}

/**
* @param RealEstateProperty $entity
* @throws BadRequest
* @throws Forbidden
*/
public function process(Entity $entity, UpdateParams $params): void
{
$matchingRequestCount = null;

if ($entity->isActual()) {
$query = $this->service->getMatchingRequestsQuery($entity, SearchParams::create());

$matchingRequestCount = $this->entityManager
->getRDBRepository(RealEstateRequest::ENTITY_TYPE)
->clone($query)
->count();
}

$entity->set('matchingRequestCount', $matchingRequestCount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/************************************************************************
* This file is part of Real Estate extension for EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* Real Estate extension 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.
*
* Real Estate extension 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\Modules\RealEstate\Classes\Record\Hooks\RealEstateRequest;

use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Record\Hook\UpdateHook;
use Espo\Core\Record\UpdateParams;
use Espo\Core\Select\SearchParams;
use Espo\Modules\RealEstate\Entities\RealEstateProperty;
use Espo\Modules\RealEstate\Entities\RealEstateRequest;
use Espo\Modules\RealEstate\Tools\Request\Service;
use Espo\ORM\Entity;
use Espo\ORM\EntityManager;

/**
* @noinspection PhpUnused
* @implements UpdateHook<RealEstateRequest>
*/
class BeforeUpdate implements UpdateHook
{
public function __construct(
private Service $service,
private EntityManager $entityManager
) {}

/**
* @param RealEstateRequest $entity
* @throws BadRequest
* @throws Forbidden
*/
public function process(Entity $entity, UpdateParams $params): void
{
$matchingRequestCount = null;

if ($entity->isActual()) {
$query = $this->service->getMatchingPropertiesQuery($entity, SearchParams::create());

$matchingRequestCount = $this->entityManager
->getRDBRepository(RealEstateProperty::ENTITY_TYPE)
->clone($query)
->count();
}

$entity->set('matchingRequestCount', $matchingRequestCount);
}
}
34 changes: 0 additions & 34 deletions src/files/custom/Espo/Modules/RealEstate/Controllers/Contact.php

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@
use Espo\Core\DataManager;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\ServiceFactory;
use Espo\Entities\User;
use Espo\Modules\RealEstate\Tools\Matches\ConfigurationService;

class RealEstateMatchingConfiguration
{
/**
* @throws Forbidden
*/
public function __construct(
private ServiceFactory $serviceFactory,
private ConfigurationService $service,
private User $user,
private DataManager $dataManager
) {
Expand All @@ -64,7 +64,7 @@ public function putActionUpdate(Request $request): bool

$data = $request->getParsedBody();

$this->serviceFactory->create('RealEstateMatchingConfiguration')->setMatchingParameters($data);
$this->service->setMatchingParameters($data);

$this->dataManager->rebuild();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
use Espo\Core\Api\Request;
use Espo\Core\Controllers\Record;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
use Espo\Modules\RealEstate\Tools\Property\Service;

class RealEstateProperty extends Record
{
/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function postActionSetNotInterested(Request $request): bool
{
Expand All @@ -46,13 +51,17 @@ public function postActionSetNotInterested(Request $request): bool
throw new BadRequest();
}

$this->getRecordService()->setNotInterested($data->propertyId, $data->requestId);
$this->injectableFactory
->create(Service::class)
->setNotInterested($data->propertyId, $data->requestId);;

return true;
}

/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function postActionUnsetNotInterested(Request $request): bool
{
Expand All @@ -62,7 +71,9 @@ public function postActionUnsetNotInterested(Request $request): bool
throw new BadRequest();
}

$this->getRecordService()->unsetNotInterested($data->propertyId, $data->requestId);
$this->injectableFactory
->create(Service::class)
->unsetNotInterested($data->propertyId, $data->requestId);;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
use Espo\Core\Api\Request;
use Espo\Core\Controllers\Record;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
use Espo\Modules\RealEstate\Tools\Request\Service;

class RealEstateRequest extends Record
{
/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function postActionSetNotInterested(Request $request): bool
{
Expand All @@ -46,13 +51,17 @@ public function postActionSetNotInterested(Request $request): bool
throw new BadRequest();
}

$this->getRecordService()->setNotInterested($data->requestId, $data->propertyId);
$this->injectableFactory
->create(Service::class)
->setNotInterested($data->requestId, $data->propertyId);

return true;
}

/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function postActionUnsetNotInterested(Request $request): bool
{
Expand All @@ -62,7 +71,9 @@ public function postActionUnsetNotInterested(Request $request): bool
throw new BadRequest();
}

$this->getRecordService()->unsetNotInterested($data->requestId, $data->propertyId);
$this->injectableFactory
->create(Service::class)
->unsetNotInterested($data->requestId, $data->propertyId);

return true;
}
Expand Down
36 changes: 0 additions & 36 deletions src/files/custom/Espo/Modules/RealEstate/Entities/Contact.php

This file was deleted.

Loading

0 comments on commit fa77fa0

Please sign in to comment.