Просмотр исходного кода

[DoctrineBundle] Fixing issue with doctrine:generate:entity command when no --fields are specified

Jonathan H. Wage 15 лет назад
Родитель
Сommit
e33894a80c

+ 16 - 13
src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntityDoctrineCommand.php

@@ -87,19 +87,22 @@ EOT
 
         // Map the specified fields
         $fields = $input->getOption('fields');
-        $e = explode(' ', $fields);
-        foreach ($e as $value) {
-            $e = explode(':', $value);
-            $name = $e[0];
-            $type = isset($e[1]) ? $e[1] : 'string';
-            preg_match_all('/(.*)\((.*)\)/', $type, $matches);
-            $type = isset($matches[1][0]) ? $matches[1][0] : 'string';
-            $length = isset($matches[2][0]) ? $matches[2][0] : null;
-            $class->mapField(array(
-                'fieldName' => $name,
-                'type' => $type,
-                'length' => $length
-            ));
+        if ($fields)
+        {
+          $e = explode(' ', $fields);
+          foreach ($e as $value) {
+              $e = explode(':', $value);
+              $name = $e[0];
+              $type = isset($e[1]) ? $e[1] : 'string';
+              preg_match_all('/(.*)\((.*)\)/', $type, $matches);
+              $type = isset($matches[1][0]) ? $matches[1][0] : 'string';
+              $length = isset($matches[2][0]) ? $matches[2][0] : null;
+              $class->mapField(array(
+                  'fieldName' => $name,
+                  'type' => $type,
+                  'length' => $length
+              ));
+          }
         }
 
         // Setup a new exporter for the mapping type specified