Passed
Branch master (2b2aec)
by Oleg
05:41 queued 02:36
created
Entity/UploadFile.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      * @ORM\PrePersist()
120 120
      * @ORM\PreUpdate()
121 121
      */
122
-    public function prePersistUpdate(){
123
-        if(!$this->status){
122
+    public function prePersistUpdate() {
123
+        if (!$this->status) {
124 124
             $this->status = self::STATUS_LOAD;
125 125
         }
126 126
         $this->ts = new \DateTime();
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      * @param $encode
131 131
      * @return UploadFile
132 132
      */
133
-    public function setEncode($encode){
133
+    public function setEncode($encode) {
134 134
         $this->encode = $encode;
135 135
 
136 136
         return $this;
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     /**
140 140
      * @return string
141 141
      */
142
-    public function getEncode(){
142
+    public function getEncode() {
143 143
         return $this->encode;
144 144
     }
145 145
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      * @param $message
148 148
      * @return UploadFile
149 149
      */
150
-    public function setMessage($message){
150
+    public function setMessage($message) {
151 151
         $this->message = $message;
152 152
 
153 153
         return $this;
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     /**
157 157
      * @return string
158 158
      */
159
-    public function getMessage(){
159
+    public function getMessage() {
160 160
         return $this->message;
161 161
     }
162 162
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @param $status
165 165
      * @return UploadFile
166 166
      */
167
-    public function setStatus($status){
167
+    public function setStatus($status) {
168 168
         $this->status = $status;
169 169
 
170 170
         return $this;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
     /**
174 174
      * @return string
175 175
      */
176
-    public function getStatus(){
176
+    public function getStatus() {
177 177
         return $this->status;
178 178
     }
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
      * @param $loaderClass
182 182
      * @return $this
183 183
      */
184
-    public function setLoaderClass($loaderClass){
184
+    public function setLoaderClass($loaderClass) {
185 185
         $this->loaderClass = $loaderClass;
186 186
 
187 187
         return $this;
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
     /**
191 191
      * @return string
192 192
      */
193
-    public function getLoaderClass(){
193
+    public function getLoaderClass() {
194 194
         return $this->loaderClass;
195 195
     }
196 196
 
197
-    public function move($uploadDir){
197
+    public function move($uploadDir) {
198 198
         $file = $this->getFile();
199 199
         $fileName = md5(uniqid() . time()) . '.' . $file->guessExtension();
200 200
         $file->move($uploadDir, $fileName);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      * @param $message
206 206
      * @return $this
207 207
      */
208
-    public function setStatusError($message){
208
+    public function setStatusError($message) {
209 209
         $this->setStatus(self::STATUS_ERROR);
210 210
         $this->setMessage($message);
211 211
         return $this;
Please login to merge, or discard this patch.
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.