refactor(plugin): rename Plan to Program and add audience/UTM routes
Rename the Plan bundle to Program across config, routes, menus, and controllers (Plan -> Initiative), bump version to 0.16.0, and introduce new audience and UTM taxonomy routes and permissions to support the expanded Programs feature set.
This commit is contained in:
1 parent
8268fad886
commit
71ff11390b
121 files changed
+5011
-2874
No files matched your search
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\ProgramBundle\Model;
|
||||
|
||||
use Mautic\CoreBundle\Model\FormModel;
|
||||
use MauticPlugin\ProgramBundle\Entity\Audience;
|
||||
use MauticPlugin\ProgramBundle\Entity\AudienceRepository;
|
||||
use MauticPlugin\ProgramBundle\Form\Type\AudienceType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
|
||||
|
||||
/**
|
||||
* Available as mautic.program.model.audience, or getModel('program.audience').
|
||||
*
|
||||
* Audiences are a global directory (Programs > Audiences), independent of plans; plans link to
|
||||
* them from their Audiences tab through InitiativeAudience (which carries the audience's priority in
|
||||
* that initiative).
|
||||
*/
|
||||
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 'program: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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user