Skip to content

Add IM placement codes and fluent option builders (#437)#438

Merged
mesilov merged 6 commits intov3-devfrom
feature/437-add-im-placement-codes
Apr 18, 2026
Merged

Add IM placement codes and fluent option builders (#437)#438
mesilov merged 6 commits intov3-devfrom
feature/437-add-im-placement-codes

Conversation

@mesilov
Copy link
Copy Markdown
Collaborator

@mesilov mesilov commented Apr 17, 2026

Q A
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #437
License MIT

Summary

Adds first-class support for Bitrix24 IM widget placements under the new
Bitrix24\SDK\Services\IM\Placements namespace:

  • PlacementLocationCodes — public constants for the four IM placement codes:
    IM_TEXTAREA, IM_SIDEBAR, IM_CONTEXT_MENU, and the deprecated-since-im 25.1600.0
    IM_SMILES_SELECTOR.
  • PlacementOptionsInterface with build(): array — contract for any object
    that produces the OPTIONS payload for placement.bind.
  • AbstractPlacementOptions — shared fluent base providing context(), role(),
    and extranet() setters, backed by the string-backed enums ChatContext, Role,
    and ExtranetAvailability. Multi-value context() joins with ; per API contract.
  • TextareaPlacementOptions — required iconName, plus color(), width(), height().
  • SidebarPlacementOptions — required iconName, plus color().
  • ContextMenuPlacementOptions — only the shared base setters.
  • PlacementColor — string-backed enum covering all 17 documented colors.

The Placement::bind() service method now accepts PlacementOptionsInterface|array
for its $options argument. Passing a builder normalizes to build() internally;
existing array callers remain fully compatible — this is a pure type widening,
not a breaking change.

Usage

use Bitrix24\SDK\Services\IM\Placements\ChatContext;
use Bitrix24\SDK\Services\IM\Placements\ExtranetAvailability;
use Bitrix24\SDK\Services\IM\Placements\PlacementColor;
use Bitrix24\SDK\Services\IM\Placements\PlacementLocationCodes;
use Bitrix24\SDK\Services\IM\Placements\Role;
use Bitrix24\SDK\Services\IM\Placements\TextareaPlacementOptions;

$options = (new TextareaPlacementOptions('fa-bug'))
    ->context(ChatContext::User, ChatContext::Chat)
    ->role(Role::User)
    ->color(PlacementColor::Aqua)
    ->width(420)
    ->height(320)
    ->extranet(ExtranetAvailability::Denied);

$serviceBuilder
    ->getPlacementScope()
    ->placement()
    ->bind(
        PlacementLocationCodes::IM_TEXTAREA,
        'https://example.com/widget',
        ['ru' => 'Мой виджет', 'en' => 'My widget'],
        $options,
    );

Quality gate

  • make lint-cs-fixer — green
  • make lint-rector — green
  • make lint-phpstan — green
  • make lint-deptrac — green (no new violations)
  • make test-unit — 766 tests, 1957 assertions pass

Notes

  • All new code lives inside Services layer; depends only on Core transitively — no new
    architectural boundary crossings.
  • PlacementLocationCodes intentionally remains a plain class with public const (not an
    enum) so that the deprecated IM_SMILES_SELECTOR constant can carry a @deprecated
    PHPDoc without the friction of enum-case deprecation.
  • Unit tests cover each concrete option class: minimal payload, full payload, and fluent
    chaining returns $this.

Closes #437

mesilov and others added 2 commits April 18, 2026 01:42
…422)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mesilov mesilov self-assigned this Apr 17, 2026
@mesilov mesilov added this to the 3.2.0 milestone Apr 17, 2026
@mesilov mesilov changed the title Add IM placement codes class for placement.bind support Add IM placement codes and fluent option builders (#437) Apr 17, 2026
@mesilov mesilov linked an issue Apr 18, 2026 that may be closed by this pull request
8 tasks
@mesilov mesilov added the enhancement in SDK New feature or request in SDK label Apr 18, 2026
@mesilov mesilov merged commit aceb107 into v3-dev Apr 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement in SDK New feature or request in SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add IM placement codes to PlacementLocationCode

1 participant