Spaces:
No application file
No application file
File size: 1,408 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<?php
declare(strict_types=1);
namespace Mautic\MarketplaceBundle\Security\Permissions;
use Mautic\CoreBundle\Helper\CoreParametersHelper;
use Mautic\CoreBundle\Security\Permissions\AbstractPermissions;
use Mautic\MarketplaceBundle\Service\Config;
use Symfony\Component\Form\FormBuilderInterface;
class MarketplacePermissions extends AbstractPermissions
{
public const BASE = 'marketplace';
public const PACKAGES = 'packages';
public const CAN_VIEW_PACKAGES = self::BASE.':'.self::PACKAGES.':view';
public const CAN_INSTALL_PACKAGES = self::BASE.':'.self::PACKAGES.':create';
public const CAN_REMOVE_PACKAGES = self::BASE.':'.self::PACKAGES.':remove';
public function __construct(
CoreParametersHelper $coreParametersHelper,
private Config $config
) {
parent::__construct($coreParametersHelper->all());
}
public function definePermissions(): void
{
$this->addStandardPermissions(self::PACKAGES, false);
}
public function isEnabled(): bool
{
return $this->config->marketplaceIsEnabled();
}
public function getName(): string
{
return self::BASE;
}
public function buildForm(FormBuilderInterface &$builder, array $options, array $data): void
{
$this->addStandardFormFields(self::BASE, self::PACKAGES, $builder, $data, false);
}
}
|