[Settings] Removed from main repo

This commit is contained in:
Jan Goralski 2016-11-09 15:34:18 +01:00
parent e83bc0f4b8
commit f84b37e482
No known key found for this signature in database
GPG key ID: 48749B194497003F
100 changed files with 75 additions and 3008 deletions

View file

@ -89,7 +89,8 @@
"phpspec/phpspec": "^3.1",
"phpunit/phpunit": "^5.6",
"se/selenium-server-standalone": "^2.52",
"stripe/stripe-php": "^4.0"
"stripe/stripe-php": "^4.0",
"sylius/settings-bundle": "^1.0@alpha"
},
"replace": {
"sylius/addressing": "self.version",
@ -124,7 +125,6 @@
"sylius/registry": "self.version",
"sylius/resource": "self.version",
"sylius/resource-bundle": "self.version",
"sylius/settings-bundle": "self.version",
"sylius/shipping": "self.version",
"sylius/shipping-bundle": "self.version",
"sylius/shop-bundle": "self.version",

76
composer.lock generated
View file

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "aa73250ff88cffb1f06ae63daba588c9",
"content-hash": "d82e6d84b5c052b595799cd7e5529cd2",
"hash": "ab1aa9c8ac3581ab7ac156502f3fb28c",
"content-hash": "f1ee98b6f3925f7c9cab064b609be8af",
"packages": [
{
"name": "behat/transliterator",
@ -8512,11 +8512,79 @@
"stripe"
],
"time": "2016-10-21 18:25:10"
},
{
"name": "sylius/settings-bundle",
"version": "v1.0.0-alpha.1",
"source": {
"type": "git",
"url": "https://github.com/Sylius/SyliusSettingsBundle.git",
"reference": "f05b86cfb7b0fa5f1f418f71e4e06f8c5b4ef231"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Sylius/SyliusSettingsBundle/zipball/f05b86cfb7b0fa5f1f418f71e4e06f8c5b4ef231",
"reference": "f05b86cfb7b0fa5f1f418f71e4e06f8c5b4ef231",
"shasum": ""
},
"require": {
"php": "^5.6|^7.0",
"sylius/registry": "^1.0",
"sylius/resource-bundle": "^1.0",
"symfony/framework-bundle": "^2.8"
},
"require-dev": {
"phpspec/phpspec": "^3.1",
"symfony/form": "^2.8",
"symfony/validator": "^2.8"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Sylius\\Bundle\\SettingsBundle\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Sylius project",
"homepage": "http://sylius.org"
},
{
"name": "Community contributions",
"homepage": "http://github.com/Sylius/Sylius/contributors"
},
{
"name": "Paweł Jędrzejewski",
"homepage": "http://pjedrzejewski.com"
}
],
"description": "Settings system for Symfony2 applications, editable via web user interface.",
"homepage": "http://sylius.org",
"keywords": [
"Settings",
"config",
"configuration",
"ecommerce",
"shop",
"webshop"
],
"time": "2016-10-17 15:23:39"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"minimum-stability": "dev",
"stability-flags": {
"sylius/settings-bundle": 15
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {

View file

@ -52,7 +52,6 @@ suites:
PromotionBundle: { namespace: Sylius\Bundle\PromotionBundle, psr4_prefix: Sylius\Bundle\PromotionBundle, spec_path: src/Sylius/Bundle/PromotionBundle, src_path: src/Sylius/Bundle/PromotionBundle }
ResourceBundle: { namespace: Sylius\Bundle\ResourceBundle, psr4_prefix: Sylius\Bundle\ResourceBundle, spec_path: src/Sylius/Bundle/ResourceBundle, src_path: src/Sylius/Bundle/ResourceBundle }
ReviewBundle: { namespace: Sylius\Bundle\ReviewBundle, psr4_prefix: Sylius\Bundle\ReviewBundle, spec_path: src/Sylius/Bundle/ReviewBundle, src_path: src/Sylius/Bundle/ReviewBundle }
SettingsBundle: { namespace: Sylius\Bundle\SettingsBundle, psr4_prefix: Sylius\Bundle\SettingsBundle, spec_path: src/Sylius/Bundle/SettingsBundle, src_path: src/Sylius/Bundle/SettingsBundle }
ShippingBundle: { namespace: Sylius\Bundle\ShippingBundle, psr4_prefix: Sylius\Bundle\ShippingBundle, spec_path: src/Sylius/Bundle/ShippingBundle, src_path: src/Sylius/Bundle/ShippingBundle }
ShopBundle: { namespace: Sylius\Bundle\ShopBundle, psr4_prefix: Sylius\Bundle\ShopBundle, spec_path: src/Sylius/Bundle/ShopBundle, src_path: src/Sylius/Bundle/ShopBundle }
TaxationBundle: { namespace: Sylius\Bundle\TaxationBundle, psr4_prefix: Sylius\Bundle\TaxationBundle, spec_path: src/Sylius/Bundle/TaxationBundle, src_path: src/Sylius/Bundle/TaxationBundle }

View file

@ -1,5 +0,0 @@
vendor/
bin/
composer.phar
composer.lock

View file

@ -1,11 +0,0 @@
CHANGELOG
=========
### v0.10.0
* Twig extension was renamed from `SyliusSettingsExtension` into `SettingsExtension`,
also the service name was changed from `sylius.settings.twig` to `sylius.twig.extension.settings`.
### v0.9.0
* Release before the components extraction.

View file

@ -1,149 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Controller;
use FOS\RestBundle\Controller\FOSRestController;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactoryInterface;
use Sylius\Bundle\SettingsBundle\Manager\SettingsManagerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Translation\TranslatorInterface;
use Symfony\Component\Validator\Exception\ValidatorException;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class SettingsController extends FOSRestController
{
/**
* @param Request $request
*
* @return Response
*/
public function showAction(Request $request)
{
$schemaAlias = $request->attributes->get('schema');
$this->isGrantedOr403($schemaAlias);
$settings = $this->getSettingsManager()->load($schemaAlias);
$view = $this
->view()
->setData($settings)
;
return $this->handleView($view);
}
/**
* @param Request $request
*
* @return Response
*/
public function updateAction(Request $request)
{
$schemaAlias = $request->attributes->get('schema');
$this->isGrantedOr403($schemaAlias);
$settingsManager = $this->getSettingsManager();
$settings = $settingsManager->load($schemaAlias);
$isApiRequest = $this->isApiRequest($request);
$form = $this
->getSettingsFormFactory()
->create($schemaAlias, $settings, $isApiRequest ? ['csrf_protection' => false] : [])
;
if ($form->handleRequest($request)->isValid()) {
$messageType = 'success';
try {
$settingsManager->save($settings);
$message = $this->getTranslator()->trans('sylius.settings.update', [], 'flashes');
} catch (ValidatorException $exception) {
$message = $this->getTranslator()->trans($exception->getMessage(), [], 'validators');
$messageType = 'error';
}
if ($isApiRequest) {
return $this->handleView($this->view(null, Response::HTTP_NO_CONTENT));
}
$request->getSession()->getBag('flashes')->add($messageType, $message);
if ($request->headers->has('referer')) {
return $this->redirect($request->headers->get('referer'));
}
}
return $this->render($request->attributes->get('template', 'SyliusSettingsBundle:Settings:update.html.twig'), [
'settings' => $settings,
'form' => $form->createView(),
]);
}
/**
* @return SettingsManagerInterface
*/
protected function getSettingsManager()
{
return $this->get('sylius.settings_manager');
}
/**
* @return SettingsFormFactoryInterface
*/
protected function getSettingsFormFactory()
{
return $this->get('sylius.form_factory.settings');
}
/**
* @return TranslatorInterface
*/
protected function getTranslator()
{
return $this->get('translator');
}
/**
* Check that user can change given schema.
*
* @param string $schemaAlias
*
* @return bool
*/
protected function isGrantedOr403($schemaAlias)
{
if (!$this->container->has('sylius.authorization_checker')) {
return true;
}
if (!$this->get('sylius.authorization_checker')->isGranted(sprintf('sylius.settings.%s', $schemaAlias))) {
throw new AccessDeniedException();
}
}
/**
* @param Request $request
*
* @return bool
*/
private function isApiRequest(Request $request)
{
return 'html' !== $request->getRequestFormat();
}
}

View file

@ -1,48 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
final class RegisterResolversPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('sylius.registry.settings_resolver')) {
return;
}
$resolverRegistry = $container->getDefinition('sylius.registry.settings_resolver');
foreach ($container->findTaggedServiceIds('sylius.settings_resolver') as $id => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['schema'])) {
throw new \InvalidArgumentException(
sprintf('Service "%s" must define the "schema" attribute on "sylius.settings_resolver" tags.', $id)
);
}
$schemaAlias = $attributes['schema'];
$resolverRegistry->addMethodCall('register', [$schemaAlias, new Reference($id)]);
}
}
}
}

View file

@ -1,47 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class RegisterSchemasPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('sylius.registry.settings_schema')) {
return;
}
$schemaRegistry = $container->getDefinition('sylius.registry.settings_schema');
$taggedServicesIds = $container->findTaggedServiceIds('sylius.settings_schema');
foreach ($taggedServicesIds as $id => $tags) {
foreach ($tags as $attributes) {
if (!isset($attributes['alias'])) {
throw new \InvalidArgumentException(
sprintf('Service "%s" must define the "alias" attribute on "sylius.settings_schema" tags.', $id)
);
}
$schemaRegistry->addMethodCall('register', [$attributes['alias'], new Reference($id)]);
}
}
}
}

View file

@ -1,79 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\DependencyInjection;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Bundle\SettingsBundle\Model\Settings;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
use Sylius\Component\Resource\Factory\Factory;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_settings');
$rootNode
->addDefaultsIfNotSet()
->children()
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
->end()
;
$this->addClassesSection($rootNode);
return $treeBuilder;
}
/**
* @param ArrayNodeDefinition $node
*/
private function addClassesSection(ArrayNodeDefinition $node)
{
$node
->children()
->arrayNode('resources')
->addDefaultsIfNotSet()
->children()
->arrayNode('settings')
->addDefaultsIfNotSet()
->children()
->variableNode('options')->end()
->arrayNode('classes')
->addDefaultsIfNotSet()
->children()
->scalarNode('model')->defaultValue(Settings::class)->cannotBeEmpty()->end()
->scalarNode('interface')->defaultValue(SettingsInterface::class)->cannotBeEmpty()->end()
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
->scalarNode('repository')->cannotBeEmpty()->end()
->scalarNode('factory')->defaultValue(Factory::class)->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end()
;
}
}

View file

@ -1,36 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\DependencyInjection;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SyliusSettingsExtension extends AbstractResourceExtension
{
/**
* {@inheritdoc}
*/
public function load(array $config, ContainerBuilder $container)
{
$config = $this->processConfiguration($this->getConfiguration($config, $container), $config);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$this->registerResources('sylius', $config['driver'], $config['resources'], $container);
$loader->load('services.xml');
}
}

View file

@ -1,144 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Doctrine\EventListener;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Event\OnFlushEventArgs;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilder;
use Sylius\Bundle\SettingsBundle\Transformer\ParameterTransformerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
final class ParameterTransformerListener
{
/**
* @var ContainerInterface
*/
private $container;
/**
* @var array
*/
private $parametersMap = [];
/**
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
// Circular reference detected for service "doctrine.dbal.default_connection", path: "doctrine.dbal.default_connection".
$this->container = $container;
}
/**
* @param LifecycleEventArgs $event
*/
public function postLoad(LifecycleEventArgs $event)
{
$settings = $event->getObject();
if ($settings instanceof SettingsInterface) {
$this->reverseTransform($settings);
}
}
/**
* @param OnFlushEventArgs $event
*/
public function onFlush(OnFlushEventArgs $event)
{
$entityManager = $event->getEntityManager();
$unitOfWork = $entityManager->getUnitOfWork();
foreach ($unitOfWork->getScheduledEntityInsertions() as $entity) {
if ($entity instanceof SettingsInterface) {
$this->transform($entity, $entityManager);
}
}
foreach ($unitOfWork->getScheduledEntityUpdates() as $entity) {
if ($entity instanceof SettingsInterface) {
$this->transform($entity, $entityManager);
}
}
}
public function postFlush()
{
// revert settings parameters to what they were before flushing
foreach ($this->parametersMap as $map) {
$map['entity']->setParameters($map['parameters']);
}
// reset parameters map
$this->parametersMap = [];
}
/**
* @param SettingsInterface $settings
* @param EntityManager $entityManager
*/
protected function transform(SettingsInterface $settings, EntityManager $entityManager)
{
// store old parameters, so we can revert to it after flush
$this->parametersMap[] = [
'entity' => $settings,
'parameters' => $settings->getParameters(),
];
$transformers = $this->getTransformers($settings);
foreach ($settings->getParameters() as $name => $value) {
if (isset($transformers[$name])) {
$settings->set($name, $transformers[$name]->transform($value));
}
}
$classMetadata = $entityManager->getClassMetadata(get_class($settings));
$entityManager->getUnitOfWork()->recomputeSingleEntityChangeSet($classMetadata, $settings);
}
/**
* @param SettingsInterface $settings
*/
protected function reverseTransform(SettingsInterface $settings)
{
$transformers = $this->getTransformers($settings);
foreach ($settings->getParameters() as $name => $value) {
if (isset($transformers[$name])) {
$settings->set($name, $transformers[$name]->reverseTransform($value));
}
}
}
/**
* @param SettingsInterface $settings
*
* @return ParameterTransformerInterface[]
*/
protected function getTransformers(SettingsInterface $settings)
{
$registry = $this->container->get('sylius.registry.settings_schema');
/** @var SchemaInterface $schema */
$schema = $registry->get($settings->getSchemaAlias());
$settingsBuilder = new SettingsBuilder();
$schema->buildSettings($settingsBuilder);
return $settingsBuilder->getTransformers();
}
}

View file

@ -1,55 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Event;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
* @author Aram Alipoor <aram.alipoor@gmail.com>
* @author Steffen Brem <steffenbrem@gmail.com>
*/
class SettingsEvent extends Event
{
const PRE_SAVE = 'sylius.settings.pre_save';
const POST_SAVE = 'sylius.settings.post_save';
/**
* @var SettingsInterface
*/
private $settings;
/**
* @param SettingsInterface $settings
*/
public function __construct(SettingsInterface $settings)
{
$this->settings = $settings;
}
/**
* @return SettingsInterface
*/
public function getSettings()
{
return $this->settings;
}
/**
* @param SettingsInterface $settings
*/
public function setSettings($settings)
{
$this->settings = $settings;
}
}

View file

@ -1,30 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Exception;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
final class ParameterNotFoundException extends \InvalidArgumentException
{
/**
* @param string $parameter
* @param int $code
* @param \Exception|null $previousException
*/
public function __construct($parameter, $code = 0, \Exception $previousException = null)
{
$message = sprintf('Parameter with name "%s" does not exist.', $parameter);
parent::__construct($message, $code, $previousException);
}
}

View file

@ -1,59 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Form\Factory;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Symfony\Component\Form\FormFactoryInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SettingsFormFactory implements SettingsFormFactoryInterface
{
/**
* @var ServiceRegistryInterface
*/
private $schemaRegistry;
/**
* @var FormFactoryInterface
*/
private $formFactory;
/**
* @param ServiceRegistryInterface $schemaRegistry
* @param FormFactoryInterface $formFactory
*/
public function __construct(ServiceRegistryInterface $schemaRegistry, FormFactoryInterface $formFactory)
{
$this->schemaRegistry = $schemaRegistry;
$this->formFactory = $formFactory;
}
/**
* {@inheritdoc}
*/
public function create($schemaAlias, $data = null, array $options = [])
{
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($schemaAlias);
$builder = $this->formFactory->createBuilder('form', $data, array_merge_recursive(
['data_class' => null], $options
));
$schema->buildForm($builder);
return $builder->getForm();
}
}

View file

@ -1,29 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Form\Factory;
use Symfony\Component\Form\FormInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface SettingsFormFactoryInterface
{
/**
* @param string $schemaAlias
* @param mixed|null $data
* @param array $options
*
* @return FormInterface
*/
public function create($schemaAlias, $data = null, array $options = []);
}

View file

@ -1,136 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Manager;
use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Bundle\SettingsBundle\Event\SettingsEvent;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
use Sylius\Bundle\SettingsBundle\Resolver\SettingsResolverInterface;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilder;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
* @author Steffen Brem <steffenbrem@gmail.com>
*/
final class SettingsManager implements SettingsManagerInterface
{
/**
* @var ServiceRegistryInterface
*/
private $schemaRegistry;
/**
* @var ServiceRegistryInterface
*/
private $resolverRegistry;
/**
* @var ObjectManager
*/
private $manager;
/**
* @var FactoryInterface
*/
private $settingsFactory;
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
/**
* @param ServiceRegistryInterface $schemaRegistry
* @param ServiceRegistryInterface $resolverRegistry
* @param ObjectManager $manager
* @param FactoryInterface $settingsFactory
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(
ServiceRegistryInterface $schemaRegistry,
ServiceRegistryInterface $resolverRegistry,
ObjectManager $manager,
FactoryInterface $settingsFactory,
EventDispatcherInterface $eventDispatcher
) {
$this->schemaRegistry = $schemaRegistry;
$this->resolverRegistry = $resolverRegistry;
$this->manager = $manager;
$this->settingsFactory = $settingsFactory;
$this->eventDispatcher = $eventDispatcher;
}
/**
* {@inheritdoc}
*/
public function load($schemaAlias, $namespace = null, $ignoreUnknown = true)
{
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($schemaAlias);
/** @var SettingsResolverInterface $resolver */
$resolver = $this->resolverRegistry->get($schemaAlias);
$settings = $resolver->resolve($schemaAlias, $namespace);
if (!$settings) {
$settings = $this->settingsFactory->createNew();
$settings->setSchemaAlias($schemaAlias);
}
// We need to get a plain parameters array since we use the options resolver on it
$parameters = $settings->getParameters();
$settingsBuilder = new SettingsBuilder();
$schema->buildSettings($settingsBuilder);
// Remove unknown settings' parameters (e.g. From a previous version of the settings schema)
if ($ignoreUnknown) {
foreach ($parameters as $name => $value) {
if (!$settingsBuilder->isDefined($name)) {
unset($parameters[$name]);
}
}
}
$parameters = $settingsBuilder->resolve($parameters);
$settings->setParameters($parameters);
return $settings;
}
/**
* {@inheritdoc}
*/
public function save(SettingsInterface $settings)
{
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($settings->getSchemaAlias());
$settingsBuilder = new SettingsBuilder();
$schema->buildSettings($settingsBuilder);
$parameters = $settingsBuilder->resolve($settings->getParameters());
$settings->setParameters($parameters);
$this->eventDispatcher->dispatch(SettingsEvent::PRE_SAVE, new SettingsEvent($settings));
$this->manager->persist($settings);
$this->manager->flush();
$this->eventDispatcher->dispatch(SettingsEvent::POST_SAVE, new SettingsEvent($settings));
}
}

View file

@ -1,33 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Manager;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface SettingsManagerInterface
{
/**
* @param string $schemaAlias
* @param string|null $namespace
*
* @return SettingsInterface
*/
public function load($schemaAlias, $namespace = null);
/**
* @param SettingsInterface $settings
*/
public function save(SettingsInterface $settings);
}

View file

@ -1,184 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Model;
use Sylius\Bundle\SettingsBundle\Exception\ParameterNotFoundException;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
class Settings implements SettingsInterface
{
/**
* @var mixed
*/
protected $id;
/**
* @var string
*/
protected $schemaAlias;
/**
* @var string
*/
protected $namespace;
/**
* @var array
*/
protected $parameters = [];
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getSchemaAlias()
{
return $this->schemaAlias;
}
/**
* {@inheritdoc}
*/
public function setSchemaAlias($schemaAlias)
{
if (null !== $this->schemaAlias) {
throw new \LogicException('The schema alias of the settings model is immutable, instantiate a new object in order to use another schema.');
}
$this->schemaAlias = $schemaAlias;
}
/**
* {@inheritdoc}
*/
public function getNamespace()
{
return $this->namespace;
}
/**
* {@inheritdoc}
*/
public function setNamespace($namespace)
{
if (null !== $this->namespace) {
throw new \LogicException('The namespace of the settings model is immutable, instantiate a new object in order to use another namespace.');
}
$this->namespace = $namespace;
}
/**
* {@inheritdoc}
*/
public function getParameters()
{
return $this->parameters;
}
/**
* {@inheritdoc}
*/
public function setParameters(array $parameters)
{
$this->parameters = $parameters;
}
/**
* {@inheritdoc}
*/
public function offsetExists($offset)
{
return $this->has($offset);
}
/**
* {@inheritdoc}
*/
public function offsetGet($offset)
{
return $this->get($offset);
}
/**
* {@inheritdoc}
*/
public function offsetSet($offset, $value)
{
$this->set($offset, $value);
}
/**
* {@inheritdoc}
*/
public function offsetUnset($offset)
{
$this->remove($offset);
}
/**
* {@inheritdoc}
*/
public function count()
{
return count($this->parameters);
}
/**
* {@inheritdoc}
*/
public function get($name)
{
if (!$this->has($name)) {
throw new ParameterNotFoundException($name);
}
return $this->parameters[$name];
}
/**
* {@inheritdoc}
*/
public function has($name)
{
return array_key_exists($name, $this->parameters);
}
/**
* {@inheritdoc}
*/
public function set($name, $value)
{
$this->parameters[$name] = $value;
}
/**
* {@inheritdoc}
*/
public function remove($name)
{
if (!$this->has($name)) {
throw new ParameterNotFoundException($name);
}
unset($this->parameters[$name]);
}
}

View file

@ -1,80 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Model;
use Sylius\Bundle\SettingsBundle\Exception\ParameterNotFoundException;
use Sylius\Component\Resource\Model\ResourceInterface;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
interface SettingsInterface extends ResourceInterface, \ArrayAccess, \Countable
{
/**
* @return string
*/
public function getSchemaAlias();
/**
* @param string $schemaAlias
*/
public function setSchemaAlias($schemaAlias);
/**
* @return string
*/
public function getNamespace();
/**
* @param string $namespace
*/
public function setNamespace($namespace);
/**
* @return array
*/
public function getParameters();
/**
* @param array $parameters
*/
public function setParameters(array $parameters);
/**
* @param string $name
*
* @return string
*
* @throws ParameterNotFoundException
*/
public function get($name);
/**
* @param string $name
*
* @return bool
*/
public function has($name);
/**
* @param string $name
* @param mixed $value
*/
public function set($name, $value);
/**
* @param string $name
*
* @throws ParameterNotFoundException
*/
public function remove($name);
}

View file

@ -1,47 +0,0 @@
SyliusSettingsBundle [![Build status...](https://secure.travis-ci.org/Sylius/SyliusSettingsBundle.png?branch=master)](http://travis-ci.org/Sylius/SyliusSettingsBundle)
====================
Settings system with web editing interface for [**Symfony2**](http://symfony.com) applications.
Sylius
------
![Sylius](http://sylius.org/assets/img/logo.png)
Sylius is an Open Source eCommerce solution built from decoupled components with powerful API and the highest quality code. [Read more on sylius.org](http://sylius.org).
Documentation
-------------
Documentation is available on [**docs.sylius.org**](http://docs.sylius.org/en/latest/bundles/SyliusSettingsBundle/index.html).
Contributing
------------
[This page](http://docs.sylius.org/en/latest/contributing/index.html) contains all the information about contributing to Sylius.
Follow Sylius' Development
--------------------------
If you want to keep up with the updates and latest features, follow us on the following channels:
* [Official Blog](https://sylius.org/blog)
* [Sylius on Twitter](https://twitter.com/Sylius)
* [Sylius on Facebook](https://facebook.com/SyliusEcommerce)
Bug tracking
------------
Sylius uses [GitHub issues](https://github.com/Sylius/Sylius/issues).
If you have found bug, please create an issue.
MIT License
-----------
License can be found [here](https://github.com/Sylius/Sylius/blob/master/LICENSE).
Authors
-------
The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
See the list of [contributors](https://github.com/Sylius/SyliusSettingsBundle/contributors).

View file

@ -1,56 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Resolver;
use Doctrine\ORM\NonUniqueResultException;
use Sylius\Component\Resource\Repository\RepositoryInterface;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
final class DefaultSettingsResolver implements SettingsResolverInterface
{
/**
* @var RepositoryInterface
*/
private $settingsRepository;
/**
* @param RepositoryInterface $settingsRepository
*/
public function __construct(RepositoryInterface $settingsRepository)
{
$this->settingsRepository = $settingsRepository;
}
/**
* {@inheritdoc}
*/
public function resolve($schemaAlias, $namespace = null)
{
try {
$criteria = ['schemaAlias' => $schemaAlias];
if (null !== $namespace) {
$criteria['namespace'] = $namespace;
}
return $this->settingsRepository->findOneBy($criteria);
} catch (NonUniqueResultException $exception) {
throw new \LogicException(
sprintf('Multiple schemas found for "%s". You should probably define a custom settings resolver for this schema.', $schemaAlias),
0,
$exception
);
}
}
}

View file

@ -1,86 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Resolver;
use Sylius\Component\Registry\ServiceRegistryInterface;
/**
* Cannot be final, because it is proxied
*
* @author Steffen Brem <steffenbrem@gmail.com>
*/
class ResolverServiceRegistry implements ServiceRegistryInterface
{
/**
* @var ServiceRegistryInterface
*/
private $decoratedRegistry;
/**
* @var SettingsResolverInterface
*/
private $defaultResolver;
/**
* @param ServiceRegistryInterface $decoratedRegistry
* @param SettingsResolverInterface $defaultResolver
*/
public function __construct(ServiceRegistryInterface $decoratedRegistry, SettingsResolverInterface $defaultResolver)
{
$this->decoratedRegistry = $decoratedRegistry;
$this->defaultResolver = $defaultResolver;
}
/**
* {@inheritdoc}
*/
public function all()
{
return $this->decoratedRegistry->all();
}
/**
* {@inheritdoc}
*/
public function register($type, $service)
{
$this->decoratedRegistry->register($type, $service);
}
/**
* {@inheritdoc}
*/
public function unregister($type)
{
$this->decoratedRegistry->unregister($type);
}
/**
* {@inheritdoc}
*/
public function has($type)
{
return $this->decoratedRegistry->has($type);
}
/**
* {@inheritdoc}
*/
public function get($type)
{
if (!$this->decoratedRegistry->has($type)) {
return $this->defaultResolver;
}
return $this->decoratedRegistry->get($type);
}
}

View file

@ -1,32 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Resolver;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
/**
* A settings resolver is always bound to only one schema alias. You can change the way how that schema will resolve by
* implementing this interface. You could for example implement a resolver that uses a query parameter on the
* current request.
*
* @author Steffen Brem <steffenbrem@gmail.com>
*/
interface SettingsResolverInterface
{
/**
* @param string $schemaAlias
* @param string|null $namespace
*
* @return SettingsInterface
*/
public function resolve($schemaAlias, $namespace = null);
}

View file

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping">
<mapped-superclass name="Sylius\Bundle\SettingsBundle\Model\Settings" table="sylius_settings">
<unique-constraints>
<unique-constraint columns="schema_alias,namespace"/>
</unique-constraints>
<id name="id" column="id" type="integer">
<generator strategy="AUTO"/>
</id>
<field name="schemaAlias" column="schema_alias" type="string" nullable="false"/>
<field name="namespace" type="string" nullable="true"/>
<field name="parameters" type="json_array"/>
</mapped-superclass>
</doctrine-mapping>

View file

@ -1,71 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of the Sylius package.
(c) Paweł Jędrzejewski
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
-->
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sylius.controller.settings" class="Sylius\Bundle\SettingsBundle\Controller\SettingsController">
<call method="setContainer">
<argument type="service" id="service_container" />
</call>
</service>
<service id="sylius.form_factory.settings" class="Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory">
<argument type="service" id="sylius.registry.settings_schema" />
<argument type="service" id="form.factory" />
</service>
<service id="sylius.settings_manager" class="Sylius\Bundle\SettingsBundle\Manager\SettingsManager">
<argument type="service" id="sylius.registry.settings_schema" />
<argument type="service" id="sylius.registry.settings_resolver" />
<argument type="service" id="sylius.manager.settings" />
<argument type="service" id="sylius.factory.settings" />
<argument type="service" id="event_dispatcher" />
</service>
<service id="sylius.registry.settings_schema" class="Sylius\Component\Registry\ServiceRegistry" lazy="true">
<argument>Sylius\Bundle\SettingsBundle\Schema\SchemaInterface</argument>
<argument>Settings schema</argument>
</service>
<service id="sylius.registry.settings_resolver" class="Sylius\Bundle\SettingsBundle\Resolver\ResolverServiceRegistry" lazy="true">
<argument type="service">
<service class="Sylius\Component\Registry\ServiceRegistry">
<argument>Sylius\Bundle\SettingsBundle\Resolver\SettingsResolverInterface</argument>
<argument>Settings resolver</argument>
</service>
</argument>
<argument type="service" id="sylius.settings_resolver.default"/>
</service>
<service id="sylius.settings_resolver.default" class="Sylius\Bundle\SettingsBundle\Resolver\DefaultSettingsResolver">
<argument type="service" id="sylius.repository.settings" />
</service>
<service id="sylius.doctrine.settings_parameter_transformer_listener" class="Sylius\Bundle\SettingsBundle\Doctrine\EventListener\ParameterTransformerListener">
<argument type="service" id="service_container"/>
<tag name="doctrine.event_listener" event="onFlush"/>
<tag name="doctrine.event_listener" event="postFlush"/>
<tag name="doctrine.event_listener" event="postLoad"/>
</service>
<service id="sylius.templating.helper.settings" class="Sylius\Bundle\SettingsBundle\Templating\Helper\SettingsHelper">
<argument type="service" id="sylius.settings_manager" />
<tag name="templating.helper" alias="sylius_settings" />
</service>
<service id="sylius.twig.extension.settings" class="Sylius\Bundle\SettingsBundle\Twig\SettingsExtension" public="false">
<argument type="service" id="sylius.templating.helper.settings" />
<tag name="twig.extension" />
</service>
</services>
</container>

View file

@ -1,19 +0,0 @@
Copyright (c) 2011-2016 Paweł Jędrzejewski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Налады паспяхова абноўлены.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Nastavení byla úspěšně aktualizována.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Indstillingerne er blevet opdateret.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Die Einstellungen wurden erfolgreich aktualisiert.

View file

@ -1,3 +0,0 @@
sylius:
settings:
update: Settings have been successfully updated.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: La configuración se ha actualizado correctamente.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: تنظیمات با موفقیت به روز شد.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Les paramètres ont bien été mis à jour.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Postavke su uspješno ažurirane.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: A beállítások sikeresen frissítve.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Le impostazioni sono state aggiornate con successo.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: 設定を保存しました。

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Nustatymai sėkmingai atnaujinti.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: De instellingen zijn succesvol bijgewerkt.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Innstillingene er oppdatert.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Ustawienia zostały pomyślnie zaktualizowane.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: As configurações foram atualizadas com êxito.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: As configurações foram atualizadas com sucesso.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Setările au fost actualizate cu succes.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Настройки были успешно обновлены.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Nastavenia boli úspešne aktualizované.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Nastavitve so bile uspešno posodobljene.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Parametrat u përditësuan me sukses.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: การตั้งค่าได้ถูกปรับปรุงเรียบร้อยแล้ว

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Ayarlar başarıyla güncellendi.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: Налаштування були успішно оновлені.

View file

@ -1,6 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
settings:
update: 配置更新成功。

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Прастора імёнаў параметра не можа быць даўжэй за 255 сімвалаў|Імя параметра не можа быць даўжэй за 255 сімвалаў.
min_length: Прастора імёнаў параметра не можа быць карацей за 2 сімвалы|Імя параметра не можа быць карацей за 2 сімвалы.
not_blank: Калі ласка, выберыце прастору імёнаў для гэтага параметра.
name:
max_length: Імя параметра не можа быць даўжэй за 255 сімвалаў|Імя параметра не можа быць даўжэй за 255 сімвалаў.
min_length: Імя параметра не можа быць карацей за 2 сімвалы|Імя параметра не можа быць карацей за 2 сімвалы.
not_blank: Калі ласка, увядзіце імя для гэтага параметра.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Obor názvů parametru nesmí být delší než 255 znaků|Obor názvů parametru nesmí být delší než 255 znaků.
min_length: Obor názvů parametrů musí mít alespoň 2 znaky|Obor názvů parametru musí mít alespoň 2 znaky.
not_blank: Zvolte prosím obor názvů pro tento parametr.
name:
max_length: Název parametru nesmí být delší než 255 znaků|Název parametru nesmí být delší než 255 znaků.
min_length: Název parametru musí mít alespoň 2 znaky|Název parametru musí mít alespoň 2 znaky.
not_blank: Zadejte prosím název pro tento parametr.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Parametername darf nicht länger als 255 Zeichen sein .|Parametername darf nicht länger als 255 Zeichen sein.
min_length: Parameter Namensraum muss mindestens 2 Zeichen lang sein.|Parameter Namensraum muss mindestens 2 Zeichen lang sein.
not_blank: Bitte einen Namensraum für diesen Parameter auswählen.
name:
max_length: Parameter Name darf nicht länger als 255 Zeichen lang sein.|Parameter Name darf nicht länger als 255 Zeichen lang sein.
min_length: Parameter Name muss mindestens 2 Zeichen lang sein.|Parameter Name muss mindestens 2 Zeichen lang sein.
not_blank: Bitte einen Namen für den Parameter eingeben.

View file

@ -1,10 +0,0 @@
sylius:
parameter:
namespace:
max_length: Parameter namespace must not be longer than 255 characters|Parameter namespace must not be longer than 255 characters.
min_length: Parameter namespace must be at least 2 characters long|Parameter namespace must be at least 2 characters long.
not_blank: Please select a namespace for this parameter.
name:
max_length: Parameter name must not be longer than 255 characters|Parameter name must not be longer than 255 characters.
min_length: Parameter name must be at least 2 characters long|Parameter name must be at least 2 characters long.
not_blank: Please enter a name for this parameter.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: El parámetro de espacio de nombre no debe tener más de 255 caracteres de largo|El parámetro de espacio de nombre no debe tener más de 255 caracteres de largo.
min_length: El parámetro de espacio debe ser al menos 2 caracteres de largo|El parámetro de espacio debe ser al menos 2 caracteres de largo.
not_blank: Por favor, seleccione un espacio de nombre para este parámetro.
name:
max_length: El parámetro de espacio no debe tener más de 255 caracteres de largo|El parámetro de espacio no debe tener más de 255 caracteres de largo.
min_length: El nombre del parámetro debe ser al menos 2 caracteres de largo|El nombre del parámetro debe ser al menos 2 caracteres de largo.
not_blank: Por favor, introduzca un nombre para este parámetro.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: فضای نام پارامتر نباید بیش از 255 حرف باشد| فضای نام پارامتر نباید بیش از 255 حرف باشد.
min_length: فضای نام پارامتر باید بیش از 2 حرف باشد| فضای نام پارامتر باید بیش از 2 حرف باشد.
not_blank: لطفا یک فضای نام برای این پارامتر انتخاب کنید.
name:
max_length: پارامتر نباید بیش از 255 حرف باشد| پارامتر نباید بیش از 255 حرف باشد.
min_length: پارامتر باید حداقل 2 حرف داشته باشد| پارامتر باید حداقل به اندازه 2 حرف طولانی باشد.
not_blank: لطفا برای این پارامتر نامی را انتخاب کنید.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: L'espace de nom du paramètre ne doit pas contenir plus de 255 caractères.|L'espace de nom du paramètre ne doit pas contenir plus de 255 caractères.
min_length: Le paramètre espace de noms doit contenir au moins 2 caractères|Le paramètre espace de noms doit comporter au moins 2 caractères.
not_blank: Veuillez choisir un espace de nom pour ce paramètre.
name:
max_length: Le nom du paramètre ne peux pas contenir plus de 255 caractères|Le nom du paramètre ne peux pas contenir plus de 255 caractères.
min_length: Le nom du paramètre doit contenir au moins 2 caractères|Le nom du paramètre doit contenir au moins 2 caractères.
not_blank: Veuillez entrer un nom pour ce paramètre.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Naziv imenskog prostora parametra ne smije biti duži od 255 znakova.|Naziv imenskog prostora parametra ne smije biti duži od 255 znakova.
min_length: Naziv imenskog prostora parametra mora biti duži od 2 znaka|Naziv imenskog prostora parametra mora biti duži od 2 znaka.
not_blank: Molim odaberite imenski prostor za ovaj parametar.
name:
max_length: Naziv parametra ne smije biti duži od 255 znakova|Naziv parametra ne smije biti duži od 255 znakova.
min_length: Naziv parametra mora biti najmanje 2 znaka dug|Naziv parametra mora biti najmanje 2 znaka dug.
not_blank: Molim unesite naziv ovog parametra.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: A paraméter névtere nem lehet hosszabb, mint 255 karakter| A paraméter névtere nem lehet hosszabb 255 karakternél.
min_length: A paraméter névterének legalább 2 karakter hosszúnak kell lennie| A paraméter névterének legalább 2 karakter hosszúnak kell lennie.
not_blank: Kérjük válasszon egy névterületet ennek a paraméternek.
name:
max_length: A paraméter neve nem lehet hosszabb, mint 255 karakter| A paraméter neve nem lehet hosszabb 255 karakternél.
min_length: A paraméter névének legalább 2 karakter hosszúnak kell lennie| A paraméter névének legalább 2 karakter hosszúnak kell lennie.
not_blank: Kérjük, írja be a paraméter nevét.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Il namespace di un parametro non può essere più lungo di 255 caratteri.
min_length: Il namespace di un parametro deve avere una lunghezza di almeno 2 caratteri.
not_blank: Per favore seleziona un namespace per questo parametro.
name:
max_length: La lunghezza del nome di un parametro non può superare i 255 caratteri.
min_length: La lunghezza del nome di un parametro deve essere di almeno 2 caratteri.
not_blank: Per favore inserisci un nome per questo parametro.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Parametro vardų sritis negali būti ilgesnė negu 255 simboliai|Parametro vardų sritis negali būti ilgesnė negu 255 simboliai.
min_length: Parametro vardų sritis turi būti mažiausiai 2 simbolių ilgio|Parametro vardų sritis turi būti mažiausiai 2 simbolių ilgio.
not_blank: Pasirinkite šio parametro vardų sritį.
name:
max_length: Parametro pavadinimas negali būti ilgesnis negu 255 simboliai|Parametro pavadinimas negali būti ilgesnis negu 255 simboliai.
min_length: Parametro pavadinimas turi būti mažiausiai 2 simbolių ilgio|Parametro pavadinimas turi būti mažiausiai 2 simbolių ilgio.
not_blank: Įveskite šio parametro pavadinimą.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: De parameter namespace mag niet langer zijn dan 255 karakters|De parameter namespace mag niet langer zijn dan 255 tekens.
min_length: De parameter namespace moet ten minste 2 tekens lang zijn.|De parameter namespace moet ten minste 2 tekens lang zijn.
not_blank: Selecteer een namespace voor deze parameter.
name:
max_length: Parameternaam mag niet langer zijn dan 255 tekens|Parameternaam mag niet langer zijn dan 255 tekens.
min_length: Parameternaam moet ten minste 2 tekens lang zijn|Parameternaam moet ten minste 2 tekens lang zijn.
not_blank: Voer een naam in voor deze parameter.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Datafeltet må ikke være lengre enn 255 tegn.|Datafeltet må ikke være lengre enn 255 tegn.
min_length: Datafeltet må inneholde minst 2 tegn.|Datafeltet må inneholde minst 2 tegn.
not_blank: Vennligst velg et navn for denne parameteren.
name:
max_length: Datafeltet må ikke være lengre enn 255 tegn.|Datafeltet må ikke være lengre enn 255 tegn.
min_length: Datafeltet må inneholde minst 2 tegn.|Datafeltet må inneholde minst 2 tegn.
not_blank: Skriv inn et navn for denne parameteren.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Nazwa przestrzeni nazw parametru może składać się z maksymalnie 255 znaków.|Nazwa przestrzeni nazw parametru może składać się z maksymalnie 255 znaków.
min_length: Nazwa przestrzeni nazw parametru musi składać się z przynajmniej 2 znaków.|Nazwa przestrzeni nazw parametru musi składać się z przynajmniej 2 znaków.
not_blank: Należy wybrać przestrzeń nazw dla tego parametru.
name:
max_length: Nazwa parametru może składać się z maksymalnie 255 znaków.|Nazwa parametru może składać się z maksymalnie 255 znaków.
min_length: Nazwa parametru musi składać się z przynajmniej 2 znaków.|Nazwa parametru musi składać się z przynajmniej 2 znaków.
not_blank: Należy wprowadzić nazwę parametru.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: O namespace não deve ter mais que 255 caracteres |O namespace não deve ter mais que 255 caracteres.
min_length: O namespace deve ter pelo menos 2 caracteres |O namespace deve ter pelo menos 2 caracteres.
not_blank: Seleccione um namespace para este parâmetro.
name:
max_length: O nome do parâmetro não deve ter mais que 255 caracteres|O nome do parâmetro não deve ter mais que 255 caracteres.
min_length: O nome do parâmetro deve ter pelo menos 2 caracteres|O nome do parâmetro deve ter pelo menos 2 caracteres.
not_blank: Por favor introduza um nome para este parâmetro.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Espaço para nome do parâmetro não deve ser maior que 255 caracteres|Espaço para nome do parâmetro não deve ser maior que 255 caracteres.
min_length: Espaço para nome do parâmetro deve ser pelo menos 2 caracteres|Parâmetro namespace deve ter pelo menos 2 caracteres.
not_blank: Por favor selecione um namespace para este parâmetro.
name:
max_length: Nome do parâmetro não deve ter mais de 255 caracteres|Nome do parâmetro não deve ser maior que 255 caracteres.
min_length: Nome do parâmetro deve ser pelo menos 2 caracteres|Nome do parâmetro deve ser de pelo menos 2 caracteres de comprimento.
not_blank: Por favor, digite um nome para este parâmetro.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Namespace-ul nu poate depăși 255 caractere|Namespace-ul nu poate depăși 255 de caractere.
min_length: Namespace-ul trebuie să conţină cel puţin 2 caractere|Namespace-ul trebuie să conţină cel puţin 2 caractere.
not_blank: Vă rugăm să alegeți un namespace pentru parametru.
name:
max_length: Numele parametrului nu poate depăși 255 de caractere|Numele parametrului nu poate depăși 255 de caractere.
min_length: Numele parametrului trebuie să conţină cel puţin 2 caractere.|Numele parametrului trebuie să conţină cel puţin 2 caractere.
not_blank: Vă rugăm să completați numele parametrului.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Длина имени пространства имен должна быть не менее 255 символов|Длина имени пространства имен должна быть не менее 255 символов.
min_length: Длина имени пространства имен должна быть не менее 2 символов|Длина имени пространства имен долэна быть не менее 2символов.
not_blank: Пожалуйста, выберите пространство имен для параметра.
name:
max_length: Длина имени параметра должна быть не менее 255 символов|Длина имени параметра должна быть не менее 255 символов.
min_length: Длина имени параметра должна быть не менее 2 символов|Длина имени параметра должна быть не менее 2 символов.
not_blank: Пожалуйста, введите имя параметра.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Názov odboru nesmie byť dlhší ako 255 znakov | Názov odboru nesmie byť dlhší ako 255 znakov.
min_length: Názov odboru musí mať minimálne 2 znaky | Názov odboru musí mať minimálne 2 znaky.
not_blank: Vyberte odbor názvov pre tento parameter.
name:
max_length: Názov parametra nesmie byť dlhší ako 255 znakov | Názov parametra nesmie byť dlhší ako 255 znakov.
min_length: Názov parametra musí mať minimálne 2 znaky | Názov parametra musí mať minimálne 2 znaky.
not_blank: Zadajte názov pre tento parameter.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Imenski prostor parametra ne sme biti daljši od 255 znakov|Imenski prostor parametra ne sme biti daljši od 255 znakov.
min_length: Imenski prostor parametra mora biti dolg vsaj 2 znaka|Imenski prostor parametra mora biti dolg vsaj 2 znaka.
not_blank: Prosimo, izberite imenski prostor za ta parameter.
name:
max_length: Ime parametra ne sme biti daljše od 255 znakov|Ime parametra ne sme biti daljše od 255 znakov.
min_length: Ime parametra mora biti dolgo vsaj 2 znaka|Ime parametra mora dolgo vsaj 2 znaka.
not_blank: Prosimo, vnesite ime za ta parameter.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Namespace i një parametri nuk duhet të përmbajë më shumë se 255 karaktere.
min_length: Namespace i një karakteri duhet të përmbajë të paktën 2 karaktere.
not_blank: Zgjidh një namespace për këtë parametër.
name:
max_length: Emri i një parametri nuk duhet të përmbajë më shumë se 255 karaktere.
min_length: Emri i një parametri duhet të përmbajë të paktën 2 karaktere.
not_blank: Fut një emër për këtë parametër.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Namespace พารามิเตอร์ต้องมีความยาวไม่เกิน 255 ตัวอักษร
min_length: Namespace พารามิเตอร์ต้องมีความยาวไม่น้อยกว่า 2 ตัวอักษร
not_blank: กรุณาเลือก namespace สำหรับพารามิเตอร์นี้
name:
max_length: Namespace พารามิเตอร์ต้องมีความยาวไม่เกิน 255 ตัวอักษร
min_length: Namespace พารามิเตอร์ต้องมีความยาวไม่น้อยกว่า 2 ตัวอักษร
not_blank: กรุณาใส่ชื่อสำหรับพารามิเตอร์นี้

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Parametre isim alanı 255 karakterden daha uzun olamaz|Parametre isim alanı 255 karakterden daha uzun olamaz.
min_length: Parametre isim alanı en az 2 karakter uzunluğunda olmalıdır| Parametre isim alanı en az 2 karakter uzunluğunda olmalıdır.
not_blank: Lütfen bu parametre için bir isim alanı seçiniz.
name:
max_length: Parametre adı 255 karakterden daha uzun olamaz|Parametre adı 255 karakterden daha uzun olamaz.
min_length: Parametre adı en az 2 karakter uzunluğunda olmalıdır| Parametre adı en az 2 karakter uzunluğunda olmalıdır.
not_blank: Bu parametre için lütfen bir isim giriniz.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: Простір імен параметру має бути не довшим за 255 символів|Простір імен параметру має бути не довшим за 255 символів.
min_length: Простір імен параметру має бути щонайменше 2 символи|Простір імен параметру має бути щонайменше 2 символи.
not_blank: Будь ласка, виберіть простір імен для цього параметра.
name:
max_length: Назва параметру має бути не довшою за 255 символів|Назва параметру має бути не довшою за 255 символів.
min_length: Назва параметру має бути щонайменше 2 символи|Назва параметру має бути щонайменше 2 символи.
not_blank: Будь ласка, введіть назву для цього параметру.

View file

@ -1,13 +0,0 @@
# This file is part of the Sylius package.
# (c) Paweł Jędrzejewski
sylius:
parameter:
namespace:
max_length: 参数命名空间不能超过 255字符|参数的命名空间不能超过 255 个字符。
min_length: 参数命名空间必须至少 2 个字符|参数命名空间必须至少 2 个字符。
not_blank: 请为此参数选择一个命名空间。
name:
max_length: 参数名称不能超过 255字符|参数的命名空间不能超过 255 个字符。
min_length: 参数命名空间必须至少 2 个字符|参数命名空间必须至少 2 个字符。
not_blank: 请输入此参数的名称。

View file

@ -1,66 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Schema;
use Symfony\Component\Form\FormBuilderInterface;
/**
* @todo Remove and replace with anonymous classes after bump to PHP 7
*
* @author Kamil Kokot <kamil.kokot@lakion.com>
*/
final class CallbackSchema implements SchemaInterface
{
/**
* @var callable
*/
private $buildSettings;
/**
* @var callable
*/
private $buildForm;
/**
* @see SchemaInterface
*
* @param callable $buildSettings Receives the same arguments as SchemaInterface::buildSettings method
* @param callable $buildForm Receives the same arguments as SchemaInterface::buildForm method
*/
public function __construct(callable $buildSettings, callable $buildForm)
{
$this->buildSettings = $buildSettings;
$this->buildForm = $buildForm;
}
/**
* {@inheritdoc}
*/
public function buildSettings(SettingsBuilderInterface $builder)
{
// Workaround for PHP 5
$buildSettings = $this->buildSettings;
$buildSettings($builder);
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder)
{
// Workaround for PHP 5
$buildForm = $this->buildForm;
$buildForm($builder);
}
}

View file

@ -1,30 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Schema;
use Symfony\Component\Form\FormBuilderInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface SchemaInterface
{
/**
* @param SettingsBuilderInterface $builder
*/
public function buildSettings(SettingsBuilderInterface $builder);
/**
* @param FormBuilderInterface $builder
*/
public function buildForm(FormBuilderInterface $builder);
}

View file

@ -1,42 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Schema;
use Sylius\Bundle\SettingsBundle\Transformer\ParameterTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class SettingsBuilder extends OptionsResolver implements SettingsBuilderInterface
{
/**
* @var ParameterTransformerInterface[]
*/
protected $transformers = [];
/**
* {@inheritdoc}
*/
public function getTransformers()
{
return $this->transformers;
}
/**
* {@inheritdoc}
*/
public function setTransformer($parameterName, ParameterTransformerInterface $transformer)
{
$this->transformers[$parameterName] = $transformer;
}
}

View file

@ -1,32 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Schema;
use Sylius\Bundle\SettingsBundle\Transformer\ParameterTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface SettingsBuilderInterface extends OptionsResolverInterface
{
/**
* @return ParameterTransformerInterface[]
*/
public function getTransformers();
/**
* @param string $parameterName
* @param ParameterTransformerInterface $transformer
*/
public function setTransformer($parameterName, ParameterTransformerInterface $transformer);
}

View file

@ -1,53 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle;
use Sylius\Bundle\ResourceBundle\AbstractResourceBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
use Sylius\Bundle\SettingsBundle\DependencyInjection\Compiler\RegisterResolversPass;
use Sylius\Bundle\SettingsBundle\DependencyInjection\Compiler\RegisterSchemasPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
class SyliusSettingsBundle extends AbstractResourceBundle
{
/**
* {@inheritdoc}
*/
public function getSupportedDrivers()
{
return [
SyliusResourceBundle::DRIVER_DOCTRINE_ORM,
];
}
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new RegisterSchemasPass());
$container->addCompilerPass(new RegisterResolversPass());
}
/**
* {@inheritdoc}
*/
protected function getModelNamespace()
{
return 'Sylius\Bundle\SettingsBundle\Model';
}
}

View file

@ -1,47 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Templating\Helper;
use Sylius\Bundle\SettingsBundle\Manager\SettingsManagerInterface;
use Symfony\Component\Templating\Helper\Helper;
final class SettingsHelper extends Helper implements SettingsHelperInterface
{
/**
* @var SettingsManagerInterface
*/
private $settingsManager;
/**
* @param SettingsManagerInterface $settingsManager
*/
public function __construct(SettingsManagerInterface $settingsManager)
{
$this->settingsManager = $settingsManager;
}
/**
* {@inheritdoc}
*/
public function getSettings($schemaAlias)
{
return $this->settingsManager->load($schemaAlias);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_settings';
}
}

View file

@ -1,27 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Templating\Helper;
use Symfony\Component\Templating\Helper\HelperInterface;
/**
* @author Kamil Kokot <kamil.kokot@lakion.com>
*/
interface SettingsHelperInterface extends HelperInterface
{
/**
* @param string $schemaAlias
*
* @return array
*/
public function getSettings($schemaAlias);
}

View file

@ -1,32 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Transformer;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
interface ParameterTransformerInterface
{
/**
* @param mixed $value
*
* @return mixed
*/
public function transform($value);
/**
* @param mixed $value
*
* @return mixed
*/
public function reverseTransform($value);
}

View file

@ -1,71 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Transformer;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\PropertyAccess\PropertyAccess;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class ResourceToIdentifierTransformer implements ParameterTransformerInterface
{
/**
* @var RepositoryInterface
*/
private $repository;
/**
* @var string
*/
private $identifier;
/**
* @param RepositoryInterface $repository
* @param string $identifier
*/
public function __construct(RepositoryInterface $repository, $identifier = 'id')
{
$this->repository = $repository;
$this->identifier = $identifier;
}
/**
* {@inheritdoc}
*/
public function transform($value)
{
if (!is_object($value)) {
return null;
}
$accessor = PropertyAccess::createPropertyAccessor();
return $accessor->getValue($value, $this->identifier);
}
/**
* {@inheritdoc}
*/
public function reverseTransform($value)
{
if (empty($value)) {
return null;
}
if ('id' === $this->identifier) {
return $this->repository->find($value);
}
return $this->repository->findOneBy([$this->identifier => $value]);
}
}

View file

@ -1,51 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\Twig;
use Sylius\Bundle\SettingsBundle\Templating\Helper\SettingsHelperInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SettingsExtension extends \Twig_Extension
{
/**
* @var SettingsHelperInterface
*/
private $helper;
/**
* @param SettingsHelperInterface $helper
*/
public function __construct(SettingsHelperInterface $helper)
{
$this->helper = $helper;
}
/**
* {@inheritdoc}
*/
public function getFunctions()
{
return [
new \Twig_SimpleFunction('sylius_settings', [$this->helper, 'getSettings']),
];
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sylius_settings';
}
}

View file

@ -1,56 +0,0 @@
{
"name": "sylius/settings-bundle",
"type": "symfony-bundle",
"description": "Settings system for Symfony2 applications, editable via web user interface.",
"keywords": ["config", "configuration", "settings", "shop", "webshop", "ecommerce"],
"homepage": "http://sylius.org",
"license": "MIT",
"authors": [
{
"name": "Paweł Jędrzejewski",
"homepage": "http://pjedrzejewski.com"
},
{
"name": "Sylius project",
"homepage": "http://sylius.org"
},
{
"name": "Community contributions",
"homepage": "http://github.com/Sylius/Sylius/contributors"
}
],
"require": {
"php": "^5.6|^7.0",
"sylius/registry": "^1.0",
"sylius/resource-bundle": "^1.0",
"symfony/framework-bundle": "^2.8"
},
"require-dev": {
"phpspec/phpspec": "^3.1",
"symfony/form": "^2.8",
"symfony/validator": "^2.8"
},
"config": {
"bin-dir": "bin"
},
"autoload": {
"psr-4": { "Sylius\\Bundle\\SettingsBundle\\": "" }
},
"autoload-dev": {
"psr-4": { "Sylius\\Bundle\\SettingsBundle\\spec\\": "spec/" }
},
"minimum-stability": "dev",
"prefer-stable": true,
"repositories": [
{
"type": "path",
"url": "../../*/*"
}
],
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
}
}

View file

@ -1,5 +0,0 @@
suites:
main:
namespace: Sylius\Bundle\SettingsBundle
psr4_prefix: Sylius\Bundle\SettingsBundle
src_path: .

View file

@ -1,39 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Bundle\SettingsBundle\spec\Fixture;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
class ParameterFixture
{
/**
* @var string
*/
protected $name;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
}

View file

@ -1,59 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Form\Factory;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactory;
use Sylius\Bundle\SettingsBundle\Form\Factory\SettingsFormFactoryInterface;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SettingsFormFactorySpec extends ObjectBehavior
{
function let(
ServiceRegistryInterface $schemaRegistry,
FormFactoryInterface $formFactory
) {
$this->beConstructedWith($schemaRegistry, $formFactory);
}
function it_is_initializable()
{
$this->shouldHaveType(SettingsFormFactory::class);
}
function it_implements_settings_form_factory_interface()
{
$this->shouldImplement(SettingsFormFactoryInterface::class);
}
function it_should_create_a_form_for_given_schema_namespace(
FormInterface $form,
FormBuilder $formBuilder,
FormFactoryInterface $formFactory,
SchemaInterface $schema,
ServiceRegistryInterface $schemaRegistry
) {
$schemaRegistry->get('sylius_general')->willReturn($schema);
$formFactory->createBuilder('form', null, ['data_class' => null])->willReturn($formBuilder);
$schema->buildForm($formBuilder)->shouldBeCalled()->willReturn($formBuilder);
$formBuilder->getForm()->willReturn($form);
$this->create('sylius_general')->shouldReturn($form);
}
}

View file

@ -1,52 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Manager;
use Doctrine\Common\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\Manager\SettingsManager;
use Sylius\Bundle\SettingsBundle\Manager\SettingsManagerInterface;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SettingsManagerSpec extends ObjectBehavior
{
function let(
ServiceRegistryInterface $schemaRegistry,
ServiceRegistryInterface $resolverRegistry,
ObjectManager $manager,
FactoryInterface $settingsFactory,
EventDispatcherInterface $eventDispatcher
) {
$this->beConstructedWith(
$schemaRegistry,
$resolverRegistry,
$manager,
$settingsFactory,
$eventDispatcher
);
}
function it_is_initializable()
{
$this->shouldHaveType(SettingsManager::class);
}
function it_should_be_a_settings_manager()
{
$this->shouldImplement(SettingsManagerInterface::class);
}
}

View file

@ -1,121 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Model;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\Exception\ParameterNotFoundException;
use Sylius\Bundle\SettingsBundle\Model\Settings;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
/**
* @author Steffen Brem <steffenbrem@gmail.com>
*/
final class SettingsSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType(Settings::class);
}
function it_implements_settings_interface()
{
$this->shouldImplement(SettingsInterface::class);
}
function it_implements_array_access_interface()
{
$this->shouldImplement(\ArrayAccess::class);
}
function it_implements_countable_interface()
{
$this->shouldImplement(\Countable::class);
}
function its_schema_alias_is_null_by_default()
{
$this->getSchemaAlias()->shouldReturn(null);
}
function its_schema_should_be_immutable_after_it_is_set()
{
$this->setSchemaAlias('theme');
$this->getSchemaAlias()->shouldReturn('theme');
$this
->shouldThrow(new \LogicException('The schema alias of the settings model is immutable, instantiate a new object in order to use another schema.'))
->during('setSchemaAlias', ['i_dont_like_to_be_changed'])
;
}
function its_namespace_is_null_by_default()
{
$this->getNamespace()->shouldReturn(null);
}
function its_namespace_should_be_immutable_after_it_is_set()
{
$this->setNamespace('banana');
$this->getNamespace()->shouldReturn('banana');
$this
->shouldThrow(new \LogicException('The namespace of the settings model is immutable, instantiate a new object in order to use another namespace.'))
->during('setNamespace', ['i_dont_like_to_be_changed'])
;
}
function its_parameters_has_empty_array_by_default()
{
$this->getParameters()->shouldReturn([]);
}
function it_can_set_a_parameter()
{
$this->set('key', 'value');
$this->getParameters()->shouldReturn(['key' => 'value']);
}
function it_throws_parameter_not_found_exception_when_getting_non_existing_parameter()
{
$this->shouldThrow(ParameterNotFoundException::class)->during('get', ['non_existing']);
}
function it_can_get_a_parameter()
{
$this->set('key', 'value');
$this->get('key')->shouldReturn('value');
}
function it_can_check_if_it_has_parameter()
{
$this->has('key')->shouldReturn(false);
$this->set('key', 'value');
$this->has('key')->shouldReturn(true);
}
function it_throws_parameter_not_found_exception_when_removing_non_existing_parameter()
{
$this->shouldThrow(ParameterNotFoundException::class)->during('remove', ['non_existing']);
}
function it_can_remove_a_parameter()
{
$this->set('key', 'value');
$this->remove('key');
$this->has('key')->shouldReturn(false);
}
function it_can_count_its_parameters()
{
$this->count()->shouldReturn(0);
$this->set('key', 'value');
$this->count()->shouldReturn(1);
}
}

View file

@ -1,62 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Schema;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Bundle\SettingsBundle\Schema\CallbackSchema;
use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Symfony\Component\Form\FormBuilderInterface;
/**
* @author Kamil Kokot <kamil.kokot@lakion.com>
*/
final class CallbackSchemaSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(function (){}, function (){});
}
function it_is_initializable()
{
$this->shouldHaveType(CallbackSchema::class);
}
function it_implements_schema_interface()
{
$this->shouldImplement(SchemaInterface::class);
}
function it_uses_callback_to_build_settings(SettingsBuilderInterface $settingsBuilder)
{
$this->beConstructedWith(function (SettingsBuilderInterface $settingsBuilder) {
$settingsBuilder->setDefaults(['foo' => 'bar']);
}, function (){});
$settingsBuilder->setDefaults(['foo' => 'bar'])->shouldBeCalled();
$this->buildSettings($settingsBuilder);
}
function it_uses_callback_to_build_form(FormBuilderInterface $formBuilder)
{
$this->beConstructedWith(function (){}, function (FormBuilderInterface $formBuilder) {
$formBuilder->add('bono', 'u2');
});
$formBuilder->add('bono', 'u2')->shouldBeCalled();
$this->buildForm($formBuilder);
}
}

View file

@ -1,51 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Schema;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilder;
use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface;
use Sylius\Bundle\SettingsBundle\Transformer\ParameterTransformerInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SettingsBuilderSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType(SettingsBuilder::class);
}
function it_implements_settings_builder_interface()
{
$this->shouldImplement(SettingsBuilderInterface::class);
}
function it_is_a_options_resolver()
{
$this->shouldHaveType(OptionsResolver::class);
}
function it_initializes_transformers_array_by_default()
{
$this->getTransformers()->shouldReturn([]);
}
function it_sets_transformer_for_parameter_by_name(ParameterTransformerInterface $transformer)
{
$this->setTransformer('test', $transformer);
$this->getTransformers()->shouldReturn(['test' => $transformer]);
}
}

View file

@ -1,49 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Templating\Helper;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\Manager\SettingsManagerInterface;
use Sylius\Bundle\SettingsBundle\Model\SettingsInterface;
use Sylius\Bundle\SettingsBundle\Templating\Helper\SettingsHelper;
use Sylius\Bundle\SettingsBundle\Templating\Helper\SettingsHelperInterface;
use Symfony\Component\Templating\Helper\Helper;
final class SettingsHelperSpec extends ObjectBehavior
{
function let(SettingsManagerInterface $settingsManager)
{
$this->beConstructedWith($settingsManager);
}
function it_is_initializable()
{
$this->shouldHaveType(SettingsHelper::class);
}
function it_implements_settings_helper_interface()
{
$this->shouldImplement(SettingsHelperInterface::class);
}
function it_is_a_twig_helper()
{
$this->shouldHaveType(Helper::class);
}
function it_returns_settings_by_namespace(SettingsManagerInterface $settingsManager, SettingsInterface $settings)
{
$settingsManager->load('sylius_taxation')->willReturn($settings);
$this->getSettings('sylius_taxation')->shouldReturn($settings);
}
}

View file

@ -1,72 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Transformer;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\spec\Fixture\ParameterFixture;
use Sylius\Bundle\SettingsBundle\Transformer\ParameterTransformerInterface;
use Sylius\Bundle\SettingsBundle\Transformer\ResourceToIdentifierTransformer;
use Sylius\Component\Resource\Repository\RepositoryInterface;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class ResourceToIdentifierTransformerSpec extends ObjectBehavior
{
function let(RepositoryInterface $repository)
{
$this->beConstructedWith($repository, 'name');
}
function it_is_initializable()
{
$this->shouldHaveType(ResourceToIdentifierTransformer::class);
}
function it_implements_parameter_transformer_interface()
{
$this->shouldImplement(ParameterTransformerInterface::class);
}
function it_returns_null_when_null_transformed()
{
$this->transform(null)->shouldReturn(null);
}
function it_transforms_object_into_its_identifier(ParameterFixture $object)
{
$object->getName()->willReturn('name');
$this->transform($object)->shouldReturn('name');
}
function it_returns_null_when_null_reverse_transformed()
{
$this->reverseTransform(null)->shouldReturn(null);
}
function it_finds_object_when_identifier_reverse_transformed(
ParameterFixture $object,
RepositoryInterface $repository
) {
$repository->findOneBy(['name' => 'foo'])->shouldBeCalled()->willReturn($object);
$this->reverseTransform('foo')->shouldReturn($object);
}
function it_returns_null_when_object_was_not_found_on_reverse_transform($repository)
{
$repository->findOneBy(['name' => 'baz'])->shouldBeCalled()->willReturn(null);
$this->reverseTransform('baz')->shouldReturn(null);
}
}

View file

@ -1,37 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace spec\Sylius\Bundle\SettingsBundle\Twig;
use PhpSpec\ObjectBehavior;
use Sylius\Bundle\SettingsBundle\Templating\Helper\SettingsHelperInterface;
use Sylius\Bundle\SettingsBundle\Twig\SettingsExtension;
/**
* @author Paweł Jędrzejewski <pawel@sylius.org>
*/
final class SettingsExtensionSpec extends ObjectBehavior
{
function let(SettingsHelperInterface $helper)
{
$this->beConstructedWith($helper);
}
function it_is_initializable()
{
$this->shouldHaveType(SettingsExtension::class);
}
function it_should_be_a_twig_extension()
{
$this->shouldHaveType(\Twig_Extension::class);
}
}

View file

@ -27,6 +27,7 @@
},
"require-dev": {
"sylius/settings-bundle": "^1.0",
"sylius/registry": "^1.0",
"matthiasnoback/symfony-config-test": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.0",