Browse Source

avoid long lines (#4303)

Oskar Stark 8 years ago
parent
commit
8403e875a5

+ 37 - 16
Admin/AbstractAdmin.php

@@ -2050,7 +2050,9 @@ EOT;
             E_USER_DEPRECATED
         );
         if ($this->breadcrumbsBuilder === null) {
-            $this->breadcrumbsBuilder = new BreadcrumbsBuilder($this->getConfigurationPool()->getContainer()->getParameter('sonata.admin.configuration.breadcrumbs'));
+            $this->breadcrumbsBuilder = new BreadcrumbsBuilder(
+                $this->getConfigurationPool()->getContainer()->getParameter('sonata.admin.configuration.breadcrumbs')
+            );
         }
 
         return $this->breadcrumbsBuilder;
@@ -2519,7 +2521,10 @@ EOT;
     {
         // TODO: Remove it when bumping requirements to SF 2.5+
         if (!$validator instanceof ValidatorInterface && !$validator instanceof LegacyValidatorInterface) {
-            throw new \InvalidArgumentException('Argument 1 must be an instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface');
+            throw new \InvalidArgumentException(
+                'Argument 1 must be an instance of Symfony\Component\Validator\Validator\ValidatorInterface'
+                .' or Symfony\Component\Validator\ValidatorInterface'
+            );
         }
 
         $this->validator = $validator;
@@ -2779,7 +2784,11 @@ EOT;
         $access = $this->getAccess();
 
         if (!array_key_exists($action, $access)) {
-            throw new \InvalidArgumentException(sprintf('Action "%s" could not be found in access mapping. Please make sure your action is defined into your admin class accessMapping property.', $action));
+            throw new \InvalidArgumentException(sprintf(
+                'Action "%s" could not be found in access mapping.'
+                .' Please make sure your action is defined into your admin class accessMapping property.',
+                $action
+            ));
         }
 
         if (!is_array($access[$action])) {
@@ -3132,12 +3141,16 @@ EOT;
         $mapper = new ListMapper($this->getListBuilder(), $this->list, $this);
 
         if (count($this->getBatchActions()) > 0) {
-            $fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance($this->getClass(), 'batch', array(
-                'label' => 'batch',
-                'code' => '_batch',
-                'sortable' => false,
-                'virtual_field' => true,
-            ));
+            $fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance(
+                $this->getClass(),
+                'batch',
+                array(
+                    'label' => 'batch',
+                    'code' => '_batch',
+                    'sortable' => false,
+                    'virtual_field' => true,
+                )
+            );
 
             $fieldDescription->setAdmin($this);
             $fieldDescription->setTemplate($this->getTemplate('batch'));
@@ -3152,12 +3165,16 @@ EOT;
         }
 
         if ($this->hasRequest() && $this->getRequest()->isXmlHttpRequest()) {
-            $fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance($this->getClass(), 'select', array(
-                'label' => false,
-                'code' => '_select',
-                'sortable' => false,
-                'virtual_field' => false,
-            ));
+            $fieldDescription = $this->getModelManager()->getNewFieldDescriptionInstance(
+                $this->getClass(),
+                'select',
+                array(
+                    'label' => false,
+                    'code' => '_select',
+                    'sortable' => false,
+                    'virtual_field' => false,
+                )
+            );
 
             $fieldDescription->setAdmin($this);
             $fieldDescription->setTemplate($this->getTemplate('select'));
@@ -3211,7 +3228,11 @@ EOT;
             return $this->subClasses[$name];
         }
 
-        throw new \RuntimeException(sprintf('Unable to find the subclass `%s` for admin `%s`', $name, get_class($this)));
+        throw new \RuntimeException(sprintf(
+            'Unable to find the subclass `%s` for admin `%s`',
+            $name,
+            get_class($this)
+        ));
     }
 
     /**

+ 8 - 3
Admin/AdminHelper.php

@@ -210,7 +210,9 @@ class AdminHelper
                 $method = sprintf('add%s', Inflector::classify(Inflector::singularize($mapping['fieldName'])));
 
                 if (!method_exists($object, $method)) {
-                    throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, ClassUtils::getClass($object)));
+                    throw new \RuntimeException(
+                        sprintf('Please add a method %s in the %s class!', $method, ClassUtils::getClass($object))
+                    );
                 }
             }
         }
@@ -248,7 +250,8 @@ class AdminHelper
     /**
      * Get access path to element which works with PropertyAccessor.
      *
-     * @param string $elementId expects string in format used in form id field. (uniqueIdentifier_model_sub_model or uniqueIdentifier_model_1_sub_model etc.)
+     * @param string $elementId expects string in format used in form id field.
+     *                          (uniqueIdentifier_model_sub_model or uniqueIdentifier_model_1_sub_model etc.)
      * @param mixed  $entity
      *
      * @return string
@@ -277,7 +280,9 @@ class AdminHelper
         }
 
         if (!empty($currentPath)) {
-            throw new \Exception(sprintf('Could not get element id from %s Failing part: %s', $elementId, $currentPath));
+            throw new \Exception(
+                sprintf('Could not get element id from %s Failing part: %s', $elementId, $currentPath)
+            );
         }
 
         return $totalPath;

+ 5 - 1
Admin/Pool.php

@@ -192,7 +192,11 @@ class Pool
         }
 
         if (count($this->adminClasses[$class]) > 1) {
-            throw new \RuntimeException(sprintf('Unable to find a valid admin for the class: %s, there are too many registered: %s', $class, implode(',', $this->adminClasses[$class])));
+            throw new \RuntimeException(sprintf(
+                'Unable to find a valid admin for the class: %s, there are too many registered: %s',
+                $class,
+                implode(',', $this->adminClasses[$class])
+            ));
         }
 
         return $this->getInstance($this->adminClasses[$class][0]);

+ 7 - 1
Command/GenerateAdminCommand.php

@@ -292,7 +292,13 @@ class GenerateAdminCommand extends ContainerAwareCommand
 
         // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
         if ($questionHelper instanceof DialogHelper) {
-            return $questionHelper->askAndValidate($output, $questionHelper->getQuestion($questionText, $default), $validator, false, $default);
+            return $questionHelper->askAndValidate(
+                $output,
+                $questionHelper->getQuestion($questionText, $default),
+                $validator,
+                false,
+                $default
+            );
         }
 
         $question = new Question($questionHelper->getQuestion($questionText, $default), $default);

+ 26 - 6
Controller/HelperController.php

@@ -59,7 +59,11 @@ class HelperController
     public function __construct(\Twig_Environment $twig, Pool $pool, AdminHelper $helper, $validator)
     {
         if (!($validator instanceof ValidatorInterface) && !($validator instanceof LegacyValidatorInterface)) {
-            throw new \InvalidArgumentException('Argument 4 is an instance of '.get_class($validator).', expecting an instance of \Symfony\Component\Validator\Validator\ValidatorInterface or \Symfony\Component\Validator\ValidatorInterface');
+            throw new \InvalidArgumentException(
+                'Argument 4 is an instance of '.get_class($validator).', expecting an instance of'
+                .' \Symfony\Component\Validator\Validator\ValidatorInterface or'
+                .' \Symfony\Component\Validator\ValidatorInterface'
+            );
         }
 
         $this->twig = $twig;
@@ -136,7 +140,9 @@ class HelperController
         if ($objectId) {
             $subject = $admin->getModelManager()->find($admin->getClass(), $objectId);
             if (!$subject) {
-                throw new NotFoundHttpException(sprintf('Unable to find the object id: %s, class: %s', $objectId, $admin->getClass()));
+                throw new NotFoundHttpException(
+                    sprintf('Unable to find the object id: %s, class: %s', $objectId, $admin->getClass())
+                );
             }
         } else {
             $subject = $admin->getNewInstance();
@@ -257,7 +263,10 @@ class HelperController
         }
 
         if (!$fieldDescription->getOption('editable')) {
-            return new JsonResponse(array('status' => 'KO', 'message' => 'The field cannot be edit, editable option must be set to true'));
+            return new JsonResponse(array(
+                'status' => 'KO',
+                'message' => 'The field cannot be edit, editable option must be set to true',
+            ));
         }
 
         $propertyPath = new PropertyPath($field);
@@ -348,7 +357,9 @@ class HelperController
             $formAutocomplete = $admin->getForm()->get($fieldDescription->getName());
 
             if ($formAutocomplete->getConfig()->getAttribute('disabled')) {
-                throw new AccessDeniedException('Autocomplete list can`t be retrieved because the form element is disabled or read_only.');
+                throw new AccessDeniedException(
+                    'Autocomplete list can`t be retrieved because the form element is disabled or read_only.'
+                );
             }
 
             $property = $formAutocomplete->getConfig()->getAttribute('property');
@@ -386,7 +397,11 @@ class HelperController
                 // multiple properties
                 foreach ($property as $prop) {
                     if (!$datagrid->hasFilter($prop)) {
-                        throw new \RuntimeException(sprintf('To retrieve autocomplete items, you should add filter "%s" to "%s" in configureDatagridFilters() method.', $prop, get_class($targetAdmin)));
+                        throw new \RuntimeException(sprintf(
+                            'To retrieve autocomplete items,'
+                            .' you should add filter "%s" to "%s" in configureDatagridFilters() method.',
+                            $prop, get_class($targetAdmin)
+                        ));
                     }
 
                     $filter = $datagrid->getFilter($prop);
@@ -396,7 +411,12 @@ class HelperController
                 }
             } else {
                 if (!$datagrid->hasFilter($property)) {
-                    throw new \RuntimeException(sprintf('To retrieve autocomplete items, you should add filter "%s" to "%s" in configureDatagridFilters() method.', $property, get_class($targetAdmin)));
+                    throw new \RuntimeException(sprintf(
+                        'To retrieve autocomplete items,'
+                        .' you should add filter "%s" to "%s" in configureDatagridFilters() method.',
+                        $property,
+                        get_class($targetAdmin)
+                    ));
                 }
 
                 $datagrid->setValue($property, null, $searchText);

+ 4 - 1
Datagrid/DatagridMapper.php

@@ -79,7 +79,10 @@ class DatagridMapper extends BaseMapper
                 array_merge($filterOptions, $fieldDescriptionOptions)
             );
         } else {
-            throw new \RuntimeException('Unknown field name in datagrid mapper. Field name should be either of FieldDescriptionInterface interface or string.');
+            throw new \RuntimeException(
+                'Unknown field name in datagrid mapper.'
+                .' Field name should be either of FieldDescriptionInterface interface or string.'
+            );
         }
 
         // add the field with the DatagridBuilder