@@ -30,7 +30,7 @@ class UploadCollectionSubscriber implements EventSubscriberInterface
3030 /**
3131 * @var boolean Primary Key field
3232 */
33- protected $ primary_key ;
33+ protected $ primaryKey ;
3434
3535 /**
3636 * @var boolean Is file nameable
@@ -40,7 +40,7 @@ class UploadCollectionSubscriber implements EventSubscriberInterface
4040 /**
4141 * @var string Nameable field name
4242 */
43- protected $ nameable_field ;
43+ protected $ nameableField ;
4444
4545 /**
4646 * Used to revert changes if form is not valid.
@@ -61,17 +61,17 @@ class UploadCollectionSubscriber implements EventSubscriberInterface
6161 /**
6262 * @var array Submitted primary keys
6363 */
64- protected $ submitted_pk ;
64+ protected $ submittedPk ;
6565
6666 /**
6767 * @var boolean
6868 */
69- protected $ allow_add ;
69+ protected $ allowAdd ;
7070
7171 /**
7272 * @var boolean
7373 */
74- protected $ allow_delete ;
74+ protected $ allowDelete ;
7575
7676 /**
7777 * @var FileStorageInterface
@@ -88,14 +88,14 @@ public function __construct($propertyName, array $options, FileStorageInterface
8888 {
8989 $ this ->propertyName = $ propertyName ;
9090 $ this ->dataClass = $ options ['options ' ]['data_class ' ];
91- $ this ->primary_key = $ options ['primary_key ' ];
91+ $ this ->primaryKey = $ options ['primary_key ' ];
9292 $ this ->nameable = $ options ['nameable ' ];
93- $ this ->nameable_field = $ options ['nameable_field ' ];
93+ $ this ->nameableField = $ options ['nameable_field ' ];
9494 $ this ->uploads = array ();
9595 $ this ->editable = array ();
96- $ this ->submitted_pk = array ();
97- $ this ->allow_add = $ options ['allow_add ' ];
98- $ this ->allow_delete = $ options ['allow_delete ' ];
96+ $ this ->submittedPk = array ();
97+ $ this ->allowAdd = $ options ['allow_add ' ];
98+ $ this ->allowDelete = $ options ['allow_delete ' ];
9999 $ this ->storage = $ storage ;
100100 }
101101
@@ -110,7 +110,6 @@ public static function getSubscribedEvents()
110110
111111 public function preSubmit (FormEvent $ event )
112112 {
113- $ form = $ event ->getForm ();
114113 $ data = $ event ->getData ();
115114
116115 $ data = $ data ?: array ();
@@ -142,8 +141,8 @@ public function preSubmit(FormEvent $event)
142141
143142 // save submitted primary keys for onSubmit event
144143 foreach ($ data as $ file ) {
145- if (is_array ($ file ) && array_key_exists ($ this ->primary_key , $ file )) {
146- $ this ->submitted_pk [] = $ file [$ this ->primary_key ];
144+ if (is_array ($ file ) && array_key_exists ($ this ->primaryKey , $ file )) {
145+ $ this ->submittedPk [] = $ file [$ this ->primaryKey ];
147146 }
148147 }
149148
@@ -159,17 +158,17 @@ public function onSubmit(FormEvent $event)
159158 $ getter = 'get ' .ucfirst ($ this ->propertyName );
160159 $ this ->originalFiles = $ data ->$ getter ();
161160
162- if ($ this ->allow_delete ) {
161+ if ($ this ->allowDelete ) {
163162 // remove files not present in submitted pk
164- $ pkGetter = 'get ' .ucfirst ($ this ->primary_key );
163+ $ pkGetter = 'get ' .ucfirst ($ this ->primaryKey );
165164 foreach ($ data ->$ getter () as $ file ) {
166- if (!in_array ($ file ->$ pkGetter (), $ this ->submitted_pk )) {
165+ if (!in_array ($ file ->$ pkGetter (), $ this ->submittedPk )) {
167166 $ data ->$ getter ()->removeElement ($ file );
168167 }
169168 }
170169 }
171170
172- if ($ this ->allow_add ) {
171+ if ($ this ->allowAdd ) {
173172 // create file entites for each file
174173 foreach ($ this ->uploads as $ upload ) {
175174 if (!is_object ($ upload ) && !is_null ($ this ->storage )) {
@@ -196,8 +195,8 @@ public function onSubmit(FormEvent $event)
196195 }
197196
198197 // if nameable field specified - set normalized name
199- if ($ this ->nameable && $ this ->nameable_field ) {
200- $ setNameable = 'set ' .ucfirst ($ this ->nameable_field );
198+ if ($ this ->nameable && $ this ->nameableField ) {
199+ $ setNameable = 'set ' .ucfirst ($ this ->nameableField );
201200
202201 // this value is unsafe
203202 $ name = $ upload ->getClientOriginalName ();
@@ -235,70 +234,70 @@ public function postSubmit(FormEvent $event)
235234 private function normalizeUtf8String ($ s )
236235 {
237236 // save original string
238- $ original_string = $ s ;
237+ $ originalString = $ s ;
239238
240239 // Normalizer-class missing!
241240 if (!class_exists ('\Normalizer ' )) {
242241 // remove all non-whitelisted characters
243- return preg_replace ( '@[^a-zA-Z0-9._\-\s ]@u ' , "" , $ original_string );
242+ return preg_replace ( '@[^a-zA-Z0-9._\-\s ]@u ' , '' , $ originalString );
244243 }
245244
246245 $ normalizer = new \Normalizer ();
247246
248247 // maps German (umlauts) and other European characters onto two characters before just removing diacritics
249- $ s = preg_replace ('@\x{00c4}@u ' , " AE " , $ s ); // umlaut Ä => AE
250- $ s = preg_replace ('@\x{00d6}@u ' , " OE " , $ s ); // umlaut Ö => OE
251- $ s = preg_replace ('@\x{00dc}@u ' , " UE " , $ s ); // umlaut Ü => UE
252- $ s = preg_replace ('@\x{00e4}@u ' , " ae " , $ s ); // umlaut ä => ae
253- $ s = preg_replace ('@\x{00f6}@u ' , " oe " , $ s ); // umlaut ö => oe
254- $ s = preg_replace ('@\x{00fc}@u ' , " ue " , $ s ); // umlaut ü => ue
255- $ s = preg_replace ('@\x{00f1}@u ' , " ny " , $ s ); // ñ => ny
256- $ s = preg_replace ('@\x{00ff}@u ' , " yu " , $ s ); // ÿ => yu
248+ $ s = preg_replace ('@\x{00c4}@u ' , ' AE ' , $ s ); // umlaut Ä => AE
249+ $ s = preg_replace ('@\x{00d6}@u ' , ' OE ' , $ s ); // umlaut Ö => OE
250+ $ s = preg_replace ('@\x{00dc}@u ' , ' UE ' , $ s ); // umlaut Ü => UE
251+ $ s = preg_replace ('@\x{00e4}@u ' , ' ae ' , $ s ); // umlaut ä => ae
252+ $ s = preg_replace ('@\x{00f6}@u ' , ' oe ' , $ s ); // umlaut ö => oe
253+ $ s = preg_replace ('@\x{00fc}@u ' , ' ue ' , $ s ); // umlaut ü => ue
254+ $ s = preg_replace ('@\x{00f1}@u ' , ' ny ' , $ s ); // ñ => ny
255+ $ s = preg_replace ('@\x{00ff}@u ' , ' yu ' , $ s ); // ÿ => yu
257256
258257 // maps special characters (characters with diacritics) on their base-character followed by the diacritical mark
259258 // exmaple: Ú => U´, á => a`
260259 $ s = $ normalizer ->normalize ($ s , $ normalizer ::FORM_D );
261260
262261 $ s = preg_replace ('@\pM@u ' , "" , $ s ); // removes diacritics
263262
264- $ s = preg_replace ('@\x{00df}@u ' , " ss " , $ s ); // maps German ß onto ss
265- $ s = preg_replace ('@\x{00c6}@u ' , " AE " , $ s ); // Æ => AE
266- $ s = preg_replace ('@\x{00e6}@u ' , " ae " , $ s ); // æ => ae
267- $ s = preg_replace ('@\x{0132}@u ' , " IJ " , $ s ); // ? => IJ
268- $ s = preg_replace ('@\x{0133}@u ' , " ij " , $ s ); // ? => ij
269- $ s = preg_replace ('@\x{0152}@u ' , " OE " , $ s ); // Œ => OE
270- $ s = preg_replace ('@\x{0153}@u ' , " oe " , $ s ); // œ => oe
271-
272- $ s = preg_replace ('@\x{00d0}@u ' , " D " , $ s ); // Ð => D
273- $ s = preg_replace ('@\x{0110}@u ' , " D " , $ s ); // Ð => D
274- $ s = preg_replace ('@\x{00f0}@u ' , " d " , $ s ); // ð => d
275- $ s = preg_replace ('@\x{0111}@u ' , " d " , $ s ); // d => d
276- $ s = preg_replace ('@\x{0126}@u ' , " H " , $ s ); // H => H
277- $ s = preg_replace ('@\x{0127}@u ' , " h " , $ s ); // h => h
278- $ s = preg_replace ('@\x{0131}@u ' , " i " , $ s ); // i => i
279- $ s = preg_replace ('@\x{0138}@u ' , " k " , $ s ); // ? => k
280- $ s = preg_replace ('@\x{013f}@u ' , " L " , $ s ); // ? => L
281- $ s = preg_replace ('@\x{0141}@u ' , " L " , $ s ); // L => L
282- $ s = preg_replace ('@\x{0140}@u ' , " l " , $ s ); // ? => l
283- $ s = preg_replace ('@\x{0142}@u ' , " l " , $ s ); // l => l
284- $ s = preg_replace ('@\x{014a}@u ' , " N " , $ s ); // ? => N
285- $ s = preg_replace ('@\x{0149}@u ' , " n " , $ s ); // ? => n
286- $ s = preg_replace ('@\x{014b}@u ' , " n " , $ s ); // ? => n
287- $ s = preg_replace ('@\x{00d8}@u ' , " O " , $ s ); // Ø => O
288- $ s = preg_replace ('@\x{00f8}@u ' , " o " , $ s ); // ø => o
289- $ s = preg_replace ('@\x{017f}@u ' , " s " , $ s ); // ? => s
290- $ s = preg_replace ('@\x{00de}@u ' , " T " , $ s ); // Þ => T
291- $ s = preg_replace ('@\x{0166}@u ' , " T " , $ s ); // T => T
292- $ s = preg_replace ('@\x{00fe}@u ' , " t " , $ s ); // þ => t
293- $ s = preg_replace ('@\x{0167}@u ' , " t " , $ s ); // t => t
263+ $ s = preg_replace ('@\x{00df}@u ' , ' ss ' , $ s ); // maps German ß onto ss
264+ $ s = preg_replace ('@\x{00c6}@u ' , ' AE ' , $ s ); // Æ => AE
265+ $ s = preg_replace ('@\x{00e6}@u ' , ' ae ' , $ s ); // æ => ae
266+ $ s = preg_replace ('@\x{0132}@u ' , ' IJ ' , $ s ); // ? => IJ
267+ $ s = preg_replace ('@\x{0133}@u ' , ' ij ' , $ s ); // ? => ij
268+ $ s = preg_replace ('@\x{0152}@u ' , ' OE ' , $ s ); // Œ => OE
269+ $ s = preg_replace ('@\x{0153}@u ' , ' oe ' , $ s ); // œ => oe
270+
271+ $ s = preg_replace ('@\x{00d0}@u ' , ' D ' , $ s ); // Ð => D
272+ $ s = preg_replace ('@\x{0110}@u ' , ' D ' , $ s ); // Ð => D
273+ $ s = preg_replace ('@\x{00f0}@u ' , ' d ' , $ s ); // ð => d
274+ $ s = preg_replace ('@\x{0111}@u ' , ' d ' , $ s ); // d => d
275+ $ s = preg_replace ('@\x{0126}@u ' , ' H ' , $ s ); // H => H
276+ $ s = preg_replace ('@\x{0127}@u ' , ' h ' , $ s ); // h => h
277+ $ s = preg_replace ('@\x{0131}@u ' , ' i ' , $ s ); // i => i
278+ $ s = preg_replace ('@\x{0138}@u ' , ' k ' , $ s ); // ? => k
279+ $ s = preg_replace ('@\x{013f}@u ' , ' L ' , $ s ); // ? => L
280+ $ s = preg_replace ('@\x{0141}@u ' , ' L ' , $ s ); // L => L
281+ $ s = preg_replace ('@\x{0140}@u ' , ' l ' , $ s ); // ? => l
282+ $ s = preg_replace ('@\x{0142}@u ' , ' l ' , $ s ); // l => l
283+ $ s = preg_replace ('@\x{014a}@u ' , ' N ' , $ s ); // ? => N
284+ $ s = preg_replace ('@\x{0149}@u ' , ' n ' , $ s ); // ? => n
285+ $ s = preg_replace ('@\x{014b}@u ' , ' n ' , $ s ); // ? => n
286+ $ s = preg_replace ('@\x{00d8}@u ' , ' O ' , $ s ); // Ø => O
287+ $ s = preg_replace ('@\x{00f8}@u ' , ' o ' , $ s ); // ø => o
288+ $ s = preg_replace ('@\x{017f}@u ' , ' s ' , $ s ); // ? => s
289+ $ s = preg_replace ('@\x{00de}@u ' , ' T ' , $ s ); // Þ => T
290+ $ s = preg_replace ('@\x{0166}@u ' , ' T ' , $ s ); // T => T
291+ $ s = preg_replace ('@\x{00fe}@u ' , ' t ' , $ s ); // þ => t
292+ $ s = preg_replace ('@\x{0167}@u ' , ' t ' , $ s ); // t => t
294293
295294 // remove all non-ASCii characters
296- $ s = preg_replace ('@[^\0-\x80]@u ' , "" , $ s );
295+ $ s = preg_replace ('@[^\0-\x80]@u ' , '' , $ s );
297296
298297 // possible errors in UTF8-regular-expressions
299298 if (empty ($ s )) {
300299 // remove all non-whitelisted characters
301- return preg_replace ('@[^a-zA-Z0-9._\-\s ]@u ' , "" , $ original_string );
300+ return preg_replace ('@[^a-zA-Z0-9._\-\s ]@u ' , '' , $ originalString );
302301 }
303302
304303 // return normalized string
0 commit comments