Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
->in(__DIR__ . '/src/Services/CRM/Quote/')
->in(__DIR__ . '/src/Services/CRM/Lead/')
->in(__DIR__ . '/src/Services/CRM/Currency/')
->in(__DIR__ . '/src/Services/CRM/Type/')
->in(__DIR__ . '/src/Services/CRM/Userfieldconfig/')
->in(__DIR__ . '/src/Services/Catalog/')
->in(__DIR__ . '/src/Services/CRM/Requisites/')
->in(__DIR__ . '/src/Services/CRM/Status/')
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## Unreleased

### Added

- Added service `Services\CRM\Userfieldconfig` with support methods,
see [userfieldconfig.* methods](https://apidocs.bitrix24.com/api-reference/crm/universal/userfieldconfig/index.html) ([#605](https://github.com/bitrix24/b24phpsdk/issues/605)):
- `add` adds a new custom field for a CRM smart-process type, the new invoice or the sign document entity, with batch calls support
- `update` updates the settings of an existing custom field, with batch calls support
- `get` returns the settings of a custom field by its identifier
- `list` returns a list of custom field settings matching the filter
- `delete` deletes a custom field, with batch calls support
- `getTypes` returns the set of custom field types available for the specified module
- Added support for events
see [userfieldconfig events](https://apidocs.bitrix24.com/api-reference/crm/universal/userfieldconfig/events/index.html) ([#605](https://github.com/bitrix24/b24phpsdk/issues/605)):
- `onCrmTypeUserFieldAdd`
- `onCrmTypeUserFieldUpdate`
- `onCrmTypeUserFieldDelete`
- `onCrmTypeUserFieldSetEnumValues`

## 1.11.0 - 2026.08.31

### Added
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ test-integration-sale-property-relation:
.PHONY: test-integration-scope-crm
test-integration-scope-crm:
docker-compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_scope_crm

.PHONY: test-integration-crm-type
test-integration-crm-type:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_crm_type

.PHONY: test-integration-crm-userfieldconfig
test-integration-crm-userfieldconfig:
docker compose run --rm php-cli vendor/bin/phpunit --testsuite integration_tests_crm_userfieldconfig

.PHONY: integration_tests_scope_crm_address
integration_tests_scope_crm_address:
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ parameters:
- tests/Integration/Services/CRM/Quote/Service/QuoteProductRowsTest.php
- tests/Integration/Services/CRM/Lead/Service/LeadUserfieldTest.php
- tests/Integration/Services/CRM/Currency
- tests/Integration/Services/CRM/Type
- tests/Integration/Services/CRM/Userfieldconfig
- tests/Integration/Services/CRM/Requisites
- tests/Integration/Services/Task
- tests/Integration/Services/Sale
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
<testsuite name="integration_tests_scope_crm_currency">
<directory>./tests/Integration/Services/CRM/Currency/</directory>
</testsuite>
<testsuite name="integration_tests_crm_type">
<directory>./tests/Integration/Services/CRM/Type/</directory>
</testsuite>
<testsuite name="integration_tests_crm_userfieldconfig">
<directory>./tests/Integration/Services/CRM/Userfieldconfig/</directory>
</testsuite>
<testsuite name="integration_tests_deal_recurring">
<file>./tests/Integration/Services/CRM/Deal/Service/DealRecurringTest.php</file>
</testsuite>
Expand Down
4 changes: 4 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
__DIR__ . '/tests/Integration/Services/CRM/Quote/Service',
__DIR__ . '/src/Services/CRM/Currency',
__DIR__ . '/tests/Integration/Services/CRM/Currency',
__DIR__ . '/src/Services/CRM/Type',
__DIR__ . '/tests/Integration/Services/CRM/Type',
__DIR__ . '/src/Services/CRM/Userfieldconfig',
__DIR__ . '/tests/Integration/Services/CRM/Userfieldconfig',
__DIR__ . '/src/Services/CRM/Requisites',
__DIR__ . '/tests/Integration/Services/CRM/Requisites',
__DIR__ . '/src/Services/CRM/Timeline',
Expand Down
17 changes: 17 additions & 0 deletions src/Services/CRM/CRMServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,4 +719,21 @@ public function type(): Type\Service\Type

return $this->serviceCache[__METHOD__];
}

public function userfieldConfig(): Userfieldconfig\Service\Userfieldconfig
{
if (!isset($this->serviceCache[__METHOD__])) {
$batch = new Userfieldconfig\Batch(
$this->core,
$this->log
);
$this->serviceCache[__METHOD__] = new Userfieldconfig\Service\Userfieldconfig(
new Userfieldconfig\Service\Batch($batch, $this->log),
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}
}
57 changes: 57 additions & 0 deletions src/Services/CRM/Type/Events/CrmTypeEventsFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events;

use Bitrix24\SDK\Core\Contracts\Events\EventInterface;
use Bitrix24\SDK\Core\Contracts\Events\EventsFabricInterface;
use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException;
use Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldAdd\OnCrmTypeUserFieldAdd;
use Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldDelete\OnCrmTypeUserFieldDelete;
use Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldSetEnumValues\OnCrmTypeUserFieldSetEnumValues;
use Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldUpdate\OnCrmTypeUserFieldUpdate;
use Symfony\Component\HttpFoundation\Request;

readonly class CrmTypeEventsFactory implements EventsFabricInterface
{
public function isSupport(string $eventCode): bool
{
return in_array(strtoupper($eventCode), [
OnCrmTypeUserFieldAdd::CODE,
OnCrmTypeUserFieldUpdate::CODE,
OnCrmTypeUserFieldDelete::CODE,
OnCrmTypeUserFieldSetEnumValues::CODE,
], true);
}

/**
* @throws InvalidArgumentException
*/
public function create(Request $eventRequest): EventInterface
{
$eventPayload = $eventRequest->request->all();
if (!array_key_exists('event', $eventPayload)) {
throw new InvalidArgumentException('«event» key not found in event payload');
}

return match ($eventPayload['event']) {
OnCrmTypeUserFieldAdd::CODE => new OnCrmTypeUserFieldAdd($eventRequest),
OnCrmTypeUserFieldUpdate::CODE => new OnCrmTypeUserFieldUpdate($eventRequest),
OnCrmTypeUserFieldDelete::CODE => new OnCrmTypeUserFieldDelete($eventRequest),
OnCrmTypeUserFieldSetEnumValues::CODE => new OnCrmTypeUserFieldSetEnumValues($eventRequest),
default => throw new InvalidArgumentException(
sprintf('Unexpected event code «%s»', $eventPayload['event'])
),
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldAdd;

use Bitrix24\SDK\Application\Requests\Events\AbstractEventRequest;

class OnCrmTypeUserFieldAdd extends AbstractEventRequest
{
public const CODE = 'ONCRMTYPEUSERFIELDADD';

public function getPayload(): OnCrmTypeUserFieldAddPayload
{
return new OnCrmTypeUserFieldAddPayload($this->eventPayload['data']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldAdd;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* @property-read positive-int $id
* @property-read non-empty-string $entityId
* @property-read non-empty-string $fieldName
*/
class OnCrmTypeUserFieldAddPayload extends AbstractItem
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldDelete;

use Bitrix24\SDK\Application\Requests\Events\AbstractEventRequest;

class OnCrmTypeUserFieldDelete extends AbstractEventRequest
{
public const CODE = 'ONCRMTYPEUSERFIELDDELETE';

public function getPayload(): OnCrmTypeUserFieldDeletePayload
{
return new OnCrmTypeUserFieldDeletePayload($this->eventPayload['data']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldDelete;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* @property-read positive-int $id
* @property-read non-empty-string $entityId
* @property-read non-empty-string $fieldName
*/
class OnCrmTypeUserFieldDeletePayload extends AbstractItem
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldSetEnumValues;

use Bitrix24\SDK\Application\Requests\Events\AbstractEventRequest;

class OnCrmTypeUserFieldSetEnumValues extends AbstractEventRequest
{
public const CODE = 'ONCRMTYPEUSERFIELDSETENUMVALUES';

public function getPayload(): OnCrmTypeUserFieldSetEnumValuesPayload
{
return new OnCrmTypeUserFieldSetEnumValuesPayload($this->eventPayload['data']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldSetEnumValues;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* @property-read positive-int $id
* @property-read non-empty-string $entityId
* @property-read non-empty-string $fieldName
*/
class OnCrmTypeUserFieldSetEnumValuesPayload extends AbstractItem
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldUpdate;

use Bitrix24\SDK\Application\Requests\Events\AbstractEventRequest;

class OnCrmTypeUserFieldUpdate extends AbstractEventRequest
{
public const CODE = 'ONCRMTYPEUSERFIELDUPDATE';

public function getPayload(): OnCrmTypeUserFieldUpdatePayload
{
return new OnCrmTypeUserFieldUpdatePayload($this->eventPayload['data']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* This file is part of the bitrix24-php-sdk package.
*
* © Dmitriy Ignatenko <algonexys@gmail.com>
*
* For the full copyright and license information, please view the MIT-LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Type\Events\OnCrmTypeUserFieldUpdate;

use Bitrix24\SDK\Core\Result\AbstractItem;

/**
* @property-read positive-int $id
* @property-read non-empty-string $entityId
* @property-read non-empty-string $fieldName
*/
class OnCrmTypeUserFieldUpdatePayload extends AbstractItem
{
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Type/Result/AddedTypeItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ public function getId(): int
{
return (int)$this->getCoreResponse()->getResponseData()->getResult()['type']['id'];
}
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Type/Result/DeletedItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public function isSuccess(): bool
{
return true;
}
}
}
2 changes: 1 addition & 1 deletion src/Services/CRM/Type/Result/UpdatedTypeItemResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public function isSuccess(): bool
{
return true;
}
}
}
Loading
Loading