73 lines
1.9 KiB
PHP
73 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\BusProNet\Model;
|
|
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
|
|
/**
|
|
* Represents a CRM selection group with included services mapping.
|
|
*
|
|
* This class handles CRM selection group data including identification,
|
|
* labeling, and selections. It provides methods to filter mutable selections
|
|
* and determine visibility, along with a static mapping for included services.
|
|
*/
|
|
class CrmSelectionGroup
|
|
{
|
|
/**
|
|
* Maps BusPro IDs of CRM selection groups representing
|
|
* included services.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
public static array $includedServicesMapping = [
|
|
7 => 'Skipass',
|
|
8 => 'Sonstige',
|
|
71 => 'Verpflegung',
|
|
74 => 'Unterkünfte',
|
|
85 => 'Übernachtung',
|
|
86 => 'Programm',
|
|
88 => 'Personal',
|
|
90 => 'Transport',
|
|
];
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?int $id = null;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?string $label = null;
|
|
|
|
#[Groups(['api:single'])]
|
|
public ?array $selections = null;
|
|
|
|
/**
|
|
* Retrieves only the mutable selections from the group.
|
|
*
|
|
* Filters the selections array to return only items that are marked
|
|
* as mutable for user interface management.
|
|
*
|
|
* @return array<CrmSelection> The mutable selections array
|
|
*/
|
|
public function getMutableSelections(): array
|
|
{
|
|
return array_filter($this->selections, function (CrmSelection $selection) {
|
|
return $selection->mutable;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Determines if the selection group should be visible.
|
|
*
|
|
* A group is considered visible if it contains at least one
|
|
* mutable selection for user interaction.
|
|
*
|
|
* @return bool True if the group has mutable selections, false otherwise
|
|
*/
|
|
#[Groups(['api:single'])]
|
|
public function isVisible(): bool
|
|
{
|
|
return 0 < count($this->getMutableSelections());
|
|
}
|
|
}
|