Bonjour,

ayant récemment effectué un projet avec Symfony, je voulais m'intéresser un petit peu plus aux fonctionnalités offertes.

Particulièrement la ré-utilisation de bundle.


Dans mon cas, je voulais pouvoir utiliser un éditeur de texte comme l'on en trouve sur n'importe quel forum.

J'ai donc trouvé le lien suivant

Lien du bundle

J'ai suivi les instructions, ou du moins je pense les avoir suivi

J'ai donc un fichier de formulaire ultra simple et non lié à aucune entité pour les besoins de ce test

NewsType.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
 
namespace WOS\WayOfShogunBundle\Form;
 
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
 
use KMS\KMSFroalaEditorBundle\Form\Type\FroalaEditorType;
 
class NewsType extends AbstractType
{
    /**
     * {@inheritdoc}
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add( "content", FroalaEditorType::class )
                ->add('publier',      SubmitType::class);
    }
}

Sauf que lorsque j'essaie de charger ma page, j'obtiens ce message d'erreur qui semble me dire qu'il y a un problème dans le nom du namespace..mais je vois vraiment pas...

The autoloader expected class "KMS\KMSFroalaEditorBundle\Form\Type\FroalaEditorType" to be defined in file "C:\wamp\www\Kingdom\vendor\composer/../../src\KMS\KMSFroalaEditorBundle\Form\Type\FroalaEditorType.php". The file was found but the class was not in it, the class name or namespace probably has a typo.
500 Internal Server Error - RuntimeException

Le fichier en question est donc celui contenu dans le bundle que j'ai récupéré

FroalaEditorType.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<?php
 
	namespace KMS\FroalaEditorBundle\Form\Type;
 
	use KMS\FroalaEditorBundle\DependencyInjection\Configuration;
	use KMS\FroalaEditorBundle\Service\OptionManager;
	use KMS\FroalaEditorBundle\Service\PluginProvider;
	use KMS\FroalaEditorBundle\Utility\UConfiguration;
	use Symfony\Component\DependencyInjection\ContainerInterface;
	use Symfony\Component\Form\AbstractType;
	use Symfony\Component\Form\Extension\Core\Type\TextareaType;
	use Symfony\Component\Form\FormBuilderInterface;
	use Symfony\Component\Form\FormInterface;
	use Symfony\Component\Form\FormView;
	use Symfony\Component\HttpKernel\Kernel;
	use Symfony\Component\OptionsResolver\OptionsResolver;
 
	/**
	 * Froala editor form type.
	 * Class FroalaEditorType
	 * @package KMS\FroalaEditorBundle\Form\Type
	 */
	class FroalaEditorType extends AbstractType
	{
 
		// -------------------------------------------------------------//
		// --------------------------- MEMBERS -------------------------//
		// -------------------------------------------------------------//
 
		/**
		 * @var \Symfony\Component\DependencyInjection\ContainerInterface
		 */
		private $m_container;
 
		/**
		 * @var \KMS\FroalaEditorBundle\Service\OptionManager
		 */
		private $m_optionManager;
 
		/**
		 * @var \KMS\FroalaEditorBundle\Service\PluginProvider
		 */
		private $m_pluginProvider;
 
		/**
		 * @var int
		 */
		private $m_version;
 
		// -------------------------------------------------------------//
		// -------------------------- CONSTRUCTOR ----------------------//
		// -------------------------------------------------------------//
 
		/**
		 * FroalaEditorType constructor.
		 * @param \Symfony\Component\HttpKernel\Kernel                      $p_kernel
		 * @param \Symfony\Component\DependencyInjection\ContainerInterface $p_container
		 * @param \KMS\FroalaEditorBundle\Service\OptionManager             $p_optionManager
		 * @param \KMS\FroalaEditorBundle\Service\PluginProvider            $p_pluginProvider
		 */
		public function __construct( Kernel $p_kernel, ContainerInterface $p_container, OptionManager $p_optionManager, PluginProvider $p_pluginProvider )
		{
			// ------------------------- DECLARE ---------------------------//
 
			$this->m_container      = $p_container;
			$this->m_optionManager  = $p_optionManager;
			$this->m_pluginProvider = $p_pluginProvider;
			$this->m_version        = $p_kernel::MAJOR_VERSION;
		}
 
		// -------------------------------------------------------------//
		// --------------------------- METHODS -------------------------//
		// -------------------------------------------------------------//
 
		// -------------------------------------------------------------//
		// --------------------------- OVERRIDE ------------------------//
		// -------------------------------------------------------------//
 
		/**
		 * @param \Symfony\Component\Form\FormBuilderInterface $p_builder
		 * @param array                                        $p_options
		 */
		public function buildForm( FormBuilderInterface $p_builder, array $p_options )
		{
			// ------------------------- DECLARE ---------------------------//
 
			foreach( $p_options as $key => $option )
			{
				$p_builder->setAttribute( $key, $option );
			}
		}
 
		/**
		 * @param \Symfony\Component\Form\FormView      $p_view
		 * @param \Symfony\Component\Form\FormInterface $p_form
		 * @param array                                 $p_options
		 */
		public function buildView( FormView $p_view, FormInterface $p_form, array $p_options )
		{
			$arrKey            = UConfiguration::getArrOption();
			$arrKeyCustom      = UConfiguration::getArrOptionCustom();
			$arrOption         = array();
			$arrPluginEnabled  = isset( $p_options [ "pluginsEnabled" ] ) ? $p_options [ "pluginsEnabled" ] : array();
			$arrPluginDisabled = isset( $p_options [ "pluginsDisabled" ] ) ? $p_options [ "pluginsDisabled" ] : array();
			// ------------------------- DECLARE ---------------------------//
 
			// Prepare options.
			$this->m_optionManager->prepareOptions( $p_options );
 
			// Separate Froala options from custom, to iterate properly in twig widget.
			foreach( $p_options as $key => $option )
			{
				if( in_array( $key, $arrKey ) )
				{
					$arrOption[ $key ] = $option;
				}
				else
				{
					if( in_array( $key, $arrKeyCustom ) )
					{
						$p_view->vars [ $key ] = $option;
					}
				}
			}
 
			// Options.
			$p_view->vars [ "arrOption" ] = $arrOption;
 
			// Plugins.
			$arrPlugin = $this->m_pluginProvider->obtainArrPluginToInclude( $arrPluginEnabled, //
																			$arrPluginDisabled );
 
			$p_view->vars [ "arrOption" ][ "pluginsEnabled" ] =
				$this->m_pluginProvider->obtainArrPluginCamelized( $arrPlugin );
			$p_view->vars [ "arrPluginJS" ]                   =
				$this->m_pluginProvider->obtainArrPluginJS( $arrPlugin );
			$p_view->vars [ "arrPluginCSS" ]                  =
				$this->m_pluginProvider->obtainArrPluginCSS( $arrPlugin );
		}
 
		/**
		 * @param \Symfony\Component\OptionsResolver\OptionsResolver $p_resolver
		 */
		public function configureOptions( OptionsResolver $p_resolver )
		{
			$arrDefault = array();
			$arrDefined = array();
			// ------------------------- DECLARE ---------------------------//
 
			foreach( UConfiguration::getArrOptionAll() as $option )
			{
 
				// If defined in config file, set default value to form, else set option as available.
				if( $this->m_container->hasParameter( Configuration::$NODE_ROOT . '.' . $option ) )
				{
					$arrDefault[ $option ] =
						$this->m_container->getParameter( Configuration::$NODE_ROOT . '.' . $option );
				}
				else
				{
					$arrDefined[] = $option;
				}
			}
 
			$p_resolver->setDefined( $arrDefined );
			$p_resolver->setDefaults( $arrDefault );
		}
 
		/**
		 * @return string
		 */
		public function getParent()
		{
			// ------------------------- DECLARE ---------------------------//
 
			if( $this->m_version == 3 )
			{
				return "Symfony\Component\Form\Extension\Core\Type\TextareaType";
			}
 
			return "textarea";
		}
 
		/**
		 * @return string
		 */
		public function getName()
		{
			//------------------------- DECLARE ---------------------------//
 
			return "froala";
		}
 
		/**
		 * @return string
		 */
		public function getBlockPrefix()
		{
			//------------------------- DECLARE ---------------------------//
 
			return "froala";
		}
 
	}
Merci pour votre aide !