Permalink
Browse files

Removed parameters from services and added configuration options with…

… defaults from old parameters.
  • Loading branch information...
1 parent bf76eb9 commit ec3a95328434ecead7419475797344364746c003 Jarvis Stubblefield committed Sep 24, 2012
View
@@ -1,6 +1,10 @@
CHANGELOG
=========
+### 2012-09-24
+
+* changed service parameters into options that come through the configuration with the old values as the new defaults.
+
### [BC BREAK] 2012-07-21
* change impersonating definition, now the url is defined as a configuration, you don't need to create
@@ -54,12 +54,30 @@ public function getConfigTreeBuilder()
->thenInvalid('The manager type %s is not supported. Please choose one of '.json_encode($supportedManagerTypes))
->end()
->end()
+ ->arrayNode('admin')
+ ->children()
+ ->scalarNode('group')->end()
+ ->scalarNode('user')->end()
+ ->end()
+ ->end()
->arrayNode('class')
->children()
->scalarNode('group')->end()
->scalarNode('user')->end()
->end()
->end()
+ ->arrayNode('controller')
+ ->children()
+ ->scalarNode('group')->end()
+ ->scalarNode('user')->end()
+ ->end()
+ ->end()
+ ->arrayNode('translation_domain')
+ ->children()
+ ->scalarNode('group')->end()
+ ->scalarNode('user')->end()
+ ->end()
+ ->end()
// Original code from the FOS User Bundle
->arrayNode('profile')
@@ -51,8 +51,12 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->addDefaults($config);
$this->registerDoctrineMapping($config);
+ $this->configureAdminClass($config, $container);
$this->configureClass($config, $container);
+ $this->configureTranslationDomain($config, $container);
+ $this->configureController($config, $container);
+
// add custom form widgets
$container->setParameter('twig.form.resources', array_merge(
$container->getParameter('twig.form.resources'),
@@ -111,6 +115,15 @@ public function addDefaults(array $config)
$defaultConfig['class']['user'] = sprintf('Application\\Sonata\\UserBundle\\%s\\User', $modelType);
$defaultConfig['class']['group'] = sprintf('Application\\Sonata\\UserBundle\\%s\\Group', $modelType);
+ $defaultConfig['admin']['user'] = sprintf('Sonata\\UserBundle\\Admin\\%s\\UserAdmin', $modelType);
+ $defaultConfig['admin']['group'] = sprintf('Sonata\\UserBundle\\Admin\\%s\\GroupAdmin', $modelType);
+
+ $defaultConfig['controller']['user'] = 'SonataAdminBundle:CRUD';
+ $defaultConfig['controller']['group'] = 'SonataAdminBundle:CRUD';
+
+ $defaultConfig['translation_domain']['user'] = 'SonataUserBundle';
+ $defaultConfig['translation_domain']['group'] = 'SonataUserBundle';
+
return array_merge($defaultConfig, $config);
}
@@ -133,6 +146,42 @@ public function configureClass($config, ContainerBuilder $container)
}
/**
+ * @param array $config
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ *
+ * @return void
+ */
+ public function configureAdminClass($config, ContainerBuilder $container)
+ {
+ $container->setParameter('sonata.user.admin.user.class', $config['admin']['user']);
+ $container->setParameter('sonata.user.admin.group.class', $config['admin']['group']);
+ }
+
+ /**
+ * @param array $config
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ *
+ * @return void
+ */
+ public function configureTranslationDomain($config, ContainerBuilder $container)
+ {
+ $container->setParameter('sonata.user.admin.user.translation_domain', $config['translation_domain']['user']);
+ $container->setParameter('sonata.user.admin.group.translation_domain', $config['translation_domain']['group']);
+ }
+
+ /**
+ * @param array $config
+ * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
+ *
+ * @return void
+ */
+ public function configureController($config, ContainerBuilder $container)
+ {
+ $container->setParameter('sonata.user.admin.user.controller', $config['controller']['user']);
+ $container->setParameter('sonata.user.admin.group.controller', $config['controller']['group']);
+ }
+
+ /**
* @param array $config
*/
public function registerDoctrineMapping(array $config)
@@ -4,16 +4,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
- <!-- USER -->
- <parameter key="sonata.user.admin.user.class">Sonata\UserBundle\Admin\Document\UserAdmin</parameter>
- <parameter key="sonata.user.admin.user.controller">SonataAdminBundle:CRUD</parameter>
- <parameter key="sonata.user.admin.user.translation_domain">SonataUserBundle</parameter>
-
- <!-- GROUP -->
- <parameter key="sonata.user.admin.group.class">Sonata\UserBundle\Admin\Document\GroupAdmin</parameter>
- <parameter key="sonata.user.admin.group.controller">SonataAdminBundle:CRUD</parameter>
- <parameter key="sonata.user.admin.group.translation_domain">%sonata.user.admin.user.translation_domain%</parameter>
-
<parameter key="sonata.user.admin.groupname">sonata_user</parameter>
</parameters>
@@ -4,16 +4,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
- <!-- USER -->
- <parameter key="sonata.user.admin.user.class">Sonata\UserBundle\Admin\Entity\UserAdmin</parameter>
- <parameter key="sonata.user.admin.user.controller">SonataAdminBundle:CRUD</parameter>
- <parameter key="sonata.user.admin.user.translation_domain">SonataUserBundle</parameter>
-
- <!-- GROUP -->
- <parameter key="sonata.user.admin.group.class">Sonata\UserBundle\Admin\Entity\GroupAdmin</parameter>
- <parameter key="sonata.user.admin.group.controller">SonataAdminBundle:CRUD</parameter>
- <parameter key="sonata.user.admin.group.translation_domain">%sonata.user.admin.user.translation_domain%</parameter>
-
<parameter key="sonata.user.admin.groupname">sonata_user</parameter>
</parameters>
@@ -23,10 +23,22 @@ Full configuration options:
sonata_user:
security_acl: false
impersonating_route: homepage # or any route you want to use
- class:
+ class: # Entity Classes
user: Application\Sonata\UserBundle\Entity\User
group: Application\Sonata\UserBundle\Entity\Group
+ admin: # Admin Classes
+ user: Sonata\UserBundle\Admin\Entity\UserAdmin
+ group: Sonata\UserBundle\Admin\Entity\GroupAdmin
+
+ controller:
+ user: SonataAdminBundle:CRUD
+ group: SonataAdminBundle:CRUD
+
+ translation_domain:
+ user: SonataUserBundle
+ group: SonataUserBundle
+
profile: # Profile Form (firstname, lastname, etc ...)
form:
type: sonata_user_profile

0 comments on commit ec3a953

Please sign in to comment.