Passed
Branch master (2b2aec)
by Oleg
05:41 queued 02:36
created
Command/SonataImportCommand.php 1 patch
Spacing   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Symfony\Component\Form\FormBuilderInterface;
19 19
 use Symfony\Component\HttpFoundation\File\File;
20 20
 
21
-class SonataImportCommand extends ContainerAwareCommand{
21
+class SonataImportCommand extends ContainerAwareCommand {
22 22
 
23 23
     /** @var EntityManager $this->em  */
24 24
     protected $em;
@@ -46,16 +46,15 @@  discard block
 block discarded – undo
46 46
         $uploadFile = $this->em->getRepository('DoctrsSonataImportBundle:UploadFile')->find($uploadFileId);
47 47
         $fileLoaders = $this->getContainer()->getParameter('doctrs_sonata_import.class_loaders');
48 48
         $fileLoader = isset($fileLoaders[$fileLoaderId], $fileLoaders[$fileLoaderId]['class']) ?
49
-            $fileLoaders[$fileLoaderId]['class'] :
50
-            null;
49
+            $fileLoaders[$fileLoaderId]['class'] : null;
51 50
 
52
-        if(!class_exists($fileLoader)){
51
+        if (!class_exists($fileLoader)) {
53 52
             $uploadFile->setStatusError('class_loader not found');
54 53
             $this->em->flush($uploadFile);
55 54
             return;
56 55
         }
57 56
         $fileLoader = new $fileLoader();
58
-        if(!$fileLoader instanceof FileLoaderInterface){
57
+        if (!$fileLoader instanceof FileLoaderInterface) {
59 58
             $uploadFile->setStatusError('class_loader must be instanceof "FileLoaderInterface"');
60 59
             $this->em->flush($uploadFile);
61 60
             return;
@@ -124,7 +123,7 @@  discard block
 block discarded – undo
124 123
                     }
125 124
 
126 125
                 }
127
-                if(!count($errors)) {
126
+                if (!count($errors)) {
128 127
                     $validator = $this->getContainer()->get('validator');
129 128
                     $errors = $validator->validate($entity);
130 129
                 }
@@ -151,7 +150,7 @@  discard block
 block discarded – undo
151 150
             }
152 151
             $uploadFile->setStatus(UploadFile::STATUS_SUCCESS);
153 152
             $this->em->flush($uploadFile);
154
-        } catch(\Exception $e){
153
+        } catch (\Exception $e) {
155 154
             /**
156 155
              * Данный хак нужен в случае бросания ORMException
157 156
              * В случае бросания ORMException entity manager останавливается
@@ -175,7 +174,7 @@  discard block
 block discarded – undo
175 174
         return $method . str_replace(' ', '', ucfirst(join('', explode('_', $name))));
176 175
     }
177 176
 
178
-    protected function setValue($value, FormBuilderInterface $fieldDescription, AbstractAdmin $admin){
177
+    protected function setValue($value, FormBuilderInterface $fieldDescription, AbstractAdmin $admin) {
179 178
 
180 179
         $mappings = $this->getContainer()->getParameter('doctrs_sonata_import.mappings');
181 180
 
@@ -187,9 +186,9 @@  discard block
 block discarded – undo
187 186
          * Проверяем кастомные типы форм на наличие в конфиге.
188 187
          * В случае совпадения, получаем значение из класса, указанного в конфиге
189 188
          */
190
-        foreach($mappings as $item){
191
-            if($item['name'] === $type){
192
-                if($this->getContainer()->has($item['class']) && $this->getContainer()->get($item['class']) instanceof ImportInterface){
189
+        foreach ($mappings as $item) {
190
+            if ($item['name'] === $type) {
191
+                if ($this->getContainer()->has($item['class']) && $this->getContainer()->get($item['class']) instanceof ImportInterface) {
193 192
                     /** @var ImportInterface $class */
194 193
                     $class = $this->getContainer()->get($item['class']);
195 194
                     return $class->getFormatValue($value);
@@ -216,7 +215,7 @@  discard block
 block discarded – undo
216 215
                 $fieldDescription->getOption('class')
217 216
             )
218 217
         ) {
219
-            if(!$value){
218
+            if (!$value) {
220 219
                 return null;
221 220
             }
222 221
             /** @var \Doctrine\ORM\Mapping\ClassMetadata $metaData */
@@ -242,7 +241,7 @@  discard block
 block discarded – undo
242 241
              * Если значение число, то пытаемся найти его по ID.
243 242
              * Если значение не число, то ищем его по полю name
244 243
              */
245
-            if(is_numeric($value)){
244
+            if (is_numeric($value)) {
246 245
                 $value = $repo->find($value);
247 246
             } else {
248 247
                 try {
Please login to merge, or discard this patch.
Admin/AdminImportTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 use Sonata\AdminBundle\Route\RouteCollection;
8 8
 use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
9 9
 
10
-trait AdminImportTrait{
10
+trait AdminImportTrait {
11 11
 
12 12
 
13 13
     protected function configureRoutes(RouteCollection $collection)
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     public function getDashboardActions()
28 28
     {
29
-        if(!$this instanceof AbstractAdmin){
29
+        if (!$this instanceof AbstractAdmin) {
30 30
             throw new InvalidArgumentException(sprintf('Class "%s" must by instanceof "Sonata\AdminBundle\Admin\AbstractAdmin"',
31 31
                 get_class($this)
32 32
             ));
Please login to merge, or discard this patch.