Initial commit: CloudOps infrastructure platform
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\LeadBundle\Twig\Extension;
|
||||
|
||||
use Mautic\LeadBundle\Exception\UnknownDncReasonException;
|
||||
use Mautic\LeadBundle\Twig\Helper\DncReasonHelper;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class DncReasonExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(
|
||||
protected DncReasonHelper $helper,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Twig_Extension::getFunctions()
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('dncReasonToText', [$this, 'toText']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert DNC reason ID to text.
|
||||
*
|
||||
* @throws UnknownDncReasonException
|
||||
*/
|
||||
public function toText(int $reasonId): string
|
||||
{
|
||||
return $this->helper->toText($reasonId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\LeadBundle\Twig\Extension;
|
||||
|
||||
use Mautic\LeadBundle\Helper\FormFieldHelper;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
final class FormFieldExtension extends AbstractExtension
|
||||
{
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('leadFieldCountryChoices', [FormFieldHelper::class, 'getCountryChoices']),
|
||||
new TwigFunction('leadFieldRegionChoices', [FormFieldHelper::class, 'getRegionChoices']),
|
||||
new TwigFunction('leadFieldTimezonesChoices', [FormFieldHelper::class, 'getTimezonesChoices']),
|
||||
new TwigFunction('leadFieldLocaleChoices', [$this, 'getLeadFieldLocaleChoices']),
|
||||
new TwigFunction('leadFormFieldParseListForChoices', [FormFieldHelper::class, 'parseListForChoices']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get locale choices with proper key=>value.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getLeadFieldLocaleChoices(): array
|
||||
{
|
||||
return array_flip(FormFieldHelper::getLocaleChoices());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\LeadBundle\Twig\Extension;
|
||||
|
||||
use Mautic\LeadBundle\Entity\Lead;
|
||||
use Mautic\LeadBundle\Twig\Helper\AvatarHelper;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
class LeadExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(
|
||||
protected AvatarHelper $avatarHelper,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Twig_Extension::getFunctions()
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new TwigFunction('leadGetAvatar', [$this, 'getAvatar']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AvatarHelper::getAvatar
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAvatar(Lead $lead)
|
||||
{
|
||||
return $this->avatarHelper->getAvatar($lead);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user