From 395d9ef67b457fb4c11275d20d87b9fd63792818 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 19:16:47 +0100 Subject: [PATCH 1/2] Define Person as Customisable class (Custom Field) --- DependencyInjection/ChillPersonExtension.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/ChillPersonExtension.php b/DependencyInjection/ChillPersonExtension.php index 231773bdc..d6bfeb309 100644 --- a/DependencyInjection/ChillPersonExtension.php +++ b/DependencyInjection/ChillPersonExtension.php @@ -29,8 +29,24 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); } + + private function declarePersonAsCustomizable (ContainerBuilder $container) + { + $bundles = $container->getParameter('kernel.bundles'); + if (!isset($bundles['ChillCustomFieldsBundle'])) { + throw new MissingBundleException('ChillCustomFieldsBundle'); + } + + $container->prependExtensionConfig('chill_custom_fields', + array('customizables_entities' => + array( + array('class' => 'Chill\PersonBundle\Entity\Person', 'name' => 'PersonEntity') + ) + ) + ); + } - public function prepend(ContainerBuilder $container) + public function prepend(ContainerBuilder $container) { $bundles = $container->getParameter('kernel.bundles'); //add ChillMain to assetic-enabled bundles @@ -42,5 +58,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac $asseticConfig['bundles'][] = 'ChillPersonBundle'; $container->prependExtensionConfig('assetic', array('bundles' => array('ChillPersonBundle'))); + + $this-> declarePersonAsCustomizable($container); } } From 1fbfff90116cabc0464d2c305a037f6788c04b51 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 7 Nov 2014 22:48:46 +0100 Subject: [PATCH 2/2] Adding MissingBundleException Class --- DependencyInjection/ChillPersonExtension.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DependencyInjection/ChillPersonExtension.php b/DependencyInjection/ChillPersonExtension.php index d6bfeb309..848db5342 100644 --- a/DependencyInjection/ChillPersonExtension.php +++ b/DependencyInjection/ChillPersonExtension.php @@ -7,6 +7,7 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; +use Chill\MainBundle\DependencyInjection\MissingBundleException; /** * This is the class that loads and manages your bundle configuration