Files
Alexandre Gain b138056e43 style: fix indentation, alignment, and docblock annotations
- Correct getChoices() docblock to reflect translated label => enum
  backing value order instead of value => label
- Re-indent Smart Links menu config to match actual array nesting
- Align assignment operators in RefreshStatsCommand
- Add missing newline at end of RefreshStatsCommand.php
2026-11-21 11:23:33 +01:00

64 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace MauticPlugin\MT3SMarketingProgramBundle\Model;
use Mautic\CoreBundle\Model\FormModel;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\Audience;
use MauticPlugin\MT3SMarketingProgramBundle\Entity\AudienceRepository;
use MauticPlugin\MT3SMarketingProgramBundle\Form\Type\AudienceType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
/**
* Available as mautic.mt3smarketingprogram.model.audience, or getModel('mt3smarketingprogram.audience').
*
* Audiences are a global directory (Programs > Audiences), independent of plans; plans link to
* them from their Audiences tab through ProgramAudience (which carries the audience's priority in
* that program).
*/
class AudienceModel extends FormModel
{
public function getRepository(): AudienceRepository
{
$repository = $this->em->getRepository(Audience::class);
\assert($repository instanceof AudienceRepository);
return $repository;
}
public function getPermissionBase(): string
{
return 'mt3smarketingprogram:audiences';
}
public function getEntity($id = null): ?Audience
{
if (null === $id) {
return new Audience();
}
$audience = parent::getEntity($id);
return $audience instanceof Audience ? $audience : null;
}
/**
* @param array<string, mixed> $options
*/
public function createForm($entity, FormFactoryInterface $formFactory, $action = null, $options = []): FormInterface
{
if (!$entity instanceof Audience) {
throw new MethodNotAllowedHttpException(['Audience']);
}
if (!empty($action)) {
$options['action'] = $action;
}
return $formFactory->create(AudienceType::class, $entity, $options);
}
}