/**
  * {@inheritdoc}
  */
 public function load(ThemeInterface $theme, $namespace = null)
 {
     $schemaAlias = sprintf('theme_%s', $theme->getName());
     if (!$this->schemaRegistry->has($schemaAlias)) {
         $schema = $this->themeSettingsSchemaProvider->getSchema($theme);
         $this->schemaRegistry->register($schemaAlias, $schema);
     }
     return $this->decoratedSettingsManager->load($schemaAlias, $namespace);
 }
 /**
  * Load settings parameter for given namespace and name.
  *
  * @param string $name
  *
  * @return mixed
  *
  * @throws \InvalidArgumentException
  */
 protected function getSettingsParameter($name)
 {
     if (false === strpos($name, '.')) {
         throw new \InvalidArgumentException(sprintf('Parameter must be in format "namespace.name", "%s" given.', $name));
     }
     list($namespace, $name) = explode('.', $name);
     $settings = $this->settingsManager->load($namespace);
     return $settings->get($name);
 }
Exemple #3
0
 /**
  * Checks if settings parameter for given schema alias and name exists.
  *
  * @param string $name
  *
  * @return bool
  */
 public function hasSettingsParameter($name)
 {
     if (false === strpos($name, '.')) {
         throw new \InvalidArgumentException(sprintf('Parameter must be in format "schemaAlias.name", "%s" given.', $name));
     }
     list($schemaAlias, $name) = explode('.', $name);
     $settings = $this->settingsManager->load($schemaAlias);
     return (bool) $settings->get($name);
 }
 /**
  * {@inheritdoc}
  */
 public function isGranted($permissionCode)
 {
     if (null === $this->settings) {
         $this->settings = $this->settingsManager->load('sylius_security');
     }
     if (false === $this->settings->get('enabled')) {
         return true;
     }
     return $this->authorizationChecker->isGranted($permissionCode);
 }
 function it_registers_theme_schema_alias_if_not_exists_during_loading_settings(SettingsManagerInterface $decoratedSettingsManager, ServiceRegistryInterface $schemaRegistry, ThemeSettingsSchemaProviderInterface $themeSettingsSchemaProvider, ThemeInterface $theme, SettingsInterface $settings, SchemaInterface $schema)
 {
     $theme->getName()->willReturn('theme/name');
     $schemaRegistry->has('theme_theme/name')->willReturn(false);
     $themeSettingsSchemaProvider->getSchema($theme)->willReturn($schema);
     $schemaRegistry->register('theme_theme/name', $schema)->shouldBeCalled();
     $decoratedSettingsManager->load('theme_theme/name', null)->willReturn($settings);
     $this->load($theme)->shouldReturn($settings);
 }
 function let(StorageInterface $storage, CustomerContextInterface $customerContext, SettingsManagerInterface $settingsManager, ObjectManager $customerManager, SettingsInterface $settings, ChannelContextInterface $channelContext)
 {
     $settingsManager->load('sylius_general')->willReturn($settings);
     $settings->get('currency')->willReturn('EUR');
     $this->beConstructedWith($storage, $customerContext, $settingsManager, $customerManager, $channelContext);
 }
 function it_should_return_settings_parameter_by_namespace_and_name(SettingsManagerInterface $settingsManager, SettingsInterface $settings)
 {
     $settingsManager->load('sylius_shipping')->shouldBeCalled()->willReturn($settings);
     $settings->get('price')->shouldBeCalled()->willReturn(19.99);
     $this->getSettingsParameter('sylius_shipping.price')->shouldReturn(19.99);
 }
Exemple #8
0
 /**
  * @Given default tax zone is :zone
  */
 public function defaultTaxZoneIs(ZoneInterface $zone)
 {
     $settings = $this->settingsManager->load('sylius_taxation');
     $settings->set('default_tax_zone', $zone);
     $this->settingsManager->save($settings);
 }
 /**
  * {@inheritdoc}
  */
 public function getSettings($schemaAlias)
 {
     return $this->settingsManager->load($schemaAlias);
 }
 /**
  * {@inheritdoc}
  */
 public function setSettings(SettingsManagerInterface $manager, $alias)
 {
     $this->settings = $manager->load($alias);
 }
Exemple #11
0
 function it_returns_settings_by_namespace(SettingsManagerInterface $settingsManager, SettingsInterface $settings)
 {
     $settingsManager->load('sylius_taxation')->willReturn($settings);
     $this->getSettings('sylius_taxation')->shouldReturn($settings);
 }
Exemple #12
0
 public function __construct(SettingsManagerInterface $settings, $version = self::LATEST_API_VERSION)
 {
     $mailchimp = $settings->load('mailchimp');
     parent::__construct($mailchimp->get('api_key'), $version);
     $this->getEventDispatcher()->addSubscriber(new ConnectionErrorListener());
 }
Exemple #13
0
 /**
  * {@inheritdoc}
  */
 public function getDefaultCurrencyCode()
 {
     return $this->settingsManager->load('sylius_general')->get('currency');
 }