@@ -16,9 +16,9 @@ |
||
| 16 | 16 | $configuration = new Configuration(); |
| 17 | 17 | $config = $this->processConfiguration($configuration, $configs); |
| 18 | 18 | |
| 19 | - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 19 | + $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 20 | 20 | $loader->load('services.xml'); |
| 21 | - $ymlLoader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
|
| 21 | + $ymlLoader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
| 22 | 22 | $ymlLoader->load('data_grid.yml'); |
| 23 | 23 | |
| 24 | 24 | $container->getDefinition('data_grid.configuration') |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | ]; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function generateGrid(Environment $environment, DataGrid $grid, array $attributes = []){ |
|
| 33 | + public function generateGrid(Environment $environment, DataGrid $grid, array $attributes = []) { |
|
| 34 | 34 | $template = $grid->getTemplate(); |
| 35 | - if (!$template->hasBlock('grid_table', [])){ |
|
| 35 | + if (!$template->hasBlock('grid_table', [])) { |
|
| 36 | 36 | $template = $environment->loadTemplate(self::DEFAULT_TEMPLATE); |
| 37 | 37 | $grid->setTemplate($template); |
| 38 | 38 | } |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $this->container = $container; |
| 28 | 28 | foreach ($config as $key => $value) { |
| 29 | - $setter = 'set' . ucfirst($key); |
|
| 29 | + $setter = 'set'.ucfirst($key); |
|
| 30 | 30 | if (method_exists($this, $setter)) { |
| 31 | 31 | $this->$setter($value); |
| 32 | 32 | } |
@@ -14,25 +14,25 @@ |
||
| 14 | 14 | |
| 15 | 15 | protected $paginationOptions; |
| 16 | 16 | |
| 17 | - public function __construct(array $config){ |
|
| 18 | - foreach ($config as $key => $value){ |
|
| 17 | + public function __construct(array $config) { |
|
| 18 | + foreach ($config as $key => $value) { |
|
| 19 | 19 | $setter = 'set'.ucfirst($key); |
| 20 | - if (method_exists($this, $setter)){ |
|
| 20 | + if (method_exists($this, $setter)) { |
|
| 21 | 21 | $this->$setter($value); |
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - protected function setTemplate(string $template){ |
|
| 26 | + protected function setTemplate(string $template) { |
|
| 27 | 27 | $this->template = $template; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - protected function setNoDataMessage(string $message){ |
|
| 30 | + protected function setNoDataMessage(string $message) { |
|
| 31 | 31 | $this->noDataMessage = $message; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - protected function setPagination(array $options){ |
|
| 35 | - if (!empty($options)){ |
|
| 34 | + protected function setPagination(array $options) { |
|
| 35 | + if (!empty($options)) { |
|
| 36 | 36 | $this->pagination = true; |
| 37 | 37 | $this->paginationOptions = $options; |
| 38 | 38 | } else { |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | public function addDateFilter(string $attribute, string $comparison = 'equal'): DataGridFiltersBuilderInterface |
| 76 | 76 | { |
| 77 | 77 | if (array_key_exists($attribute, $this->params)) { |
| 78 | - $comparisonFunc = lcfirst($comparison) . 'Date'; |
|
| 78 | + $comparisonFunc = lcfirst($comparison).'Date'; |
|
| 79 | 79 | if (method_exists($this, $comparisonFunc)) { |
| 80 | 80 | $this->$comparisonFunc($attribute); |
| 81 | 81 | } else { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | public function addColumn(string $columnClass, array $config = []): DataGridBuilderInterface |
| 45 | 45 | { |
| 46 | 46 | if (!is_subclass_of($columnClass, AbstractColumn::class)) { |
| 47 | - throw new InvalidArgumentException('Expected subclass of' . AbstractColumn::class); |
|
| 47 | + throw new InvalidArgumentException('Expected subclass of'.AbstractColumn::class); |
|
| 48 | 48 | } |
| 49 | 49 | $this->columns[] = new $columnClass($this->container, array_merge(['template' => $this->options['template']], $config)); |
| 50 | 50 | return $this; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | public function setTemplate(string $path) : DataGridBuilderInterface |
| 67 | 67 | { |
| 68 | 68 | $this->options['template'] = $path; |
| 69 | - foreach ($this->columns as $column){ |
|
| 69 | + foreach ($this->columns as $column) { |
|
| 70 | 70 | $column->setTemplate($path); |
| 71 | 71 | } |
| 72 | 72 | return $this; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | public function enablePagination($options = []) : DataGridBuilderInterface |
| 85 | 85 | { |
| 86 | - if (is_array($options) && !empty($options)){ |
|
| 86 | + if (is_array($options) && !empty($options)) { |
|
| 87 | 87 | $this->options['pagination'] = true; |
| 88 | 88 | $this->options['paginationOptions'] = $options; |
| 89 | 89 | } else { |
@@ -51,9 +51,9 @@ |
||
| 51 | 51 | { |
| 52 | 52 | $manager = $this->container['doctrine']->getRepository($this->entityClass); |
| 53 | 53 | $queryResult = $manager->createQueryBuilder('dgq') |
| 54 | - ->select(['dgq.id', 'dgq.' . $this->label])->orderBy('dgq.id')->getQuery()->getArrayResult(); |
|
| 54 | + ->select(['dgq.id', 'dgq.'.$this->label])->orderBy('dgq.id')->getQuery()->getArrayResult(); |
|
| 55 | 55 | $choices = []; |
| 56 | - array_walk($queryResult, function ($val) use (&$choices) { |
|
| 56 | + array_walk($queryResult, function($val) use (&$choices) { |
|
| 57 | 57 | $choices[$val['id']] = $val[$this->label]; |
| 58 | 58 | }); |
| 59 | 59 | return [ |
@@ -90,13 +90,13 @@ |
||
| 90 | 90 | |
| 91 | 91 | protected function getEntityAttribute($entity, $attribute) |
| 92 | 92 | { |
| 93 | - $attribute = preg_replace_callback('/_([A-z]?)/', function ($matches) { |
|
| 93 | + $attribute = preg_replace_callback('/_([A-z]?)/', function($matches) { |
|
| 94 | 94 | return isset($matches[1]) ? strtoupper($matches[1]) : ''; |
| 95 | 95 | }, $attribute); |
| 96 | - $getter = 'get' . ucfirst($attribute); |
|
| 96 | + $getter = 'get'.ucfirst($attribute); |
|
| 97 | 97 | if (method_exists($entity, $getter)) { |
| 98 | 98 | return $entity->$getter(); |
| 99 | 99 | } |
| 100 | - throw new Exception('Unknown property ' . $attribute . ' in ' . get_class($entity)); |
|
| 100 | + throw new Exception('Unknown property '.$attribute.' in '.get_class($entity)); |
|
| 101 | 101 | } |
| 102 | 102 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function getCellContent($entity) |
| 41 | 41 | { |
| 42 | - return preg_replace_callback('/\{(\w+)\}/', function ($matches) use ($entity) { |
|
| 42 | + return preg_replace_callback('/\{(\w+)\}/', function($matches) use ($entity) { |
|
| 43 | 43 | if ($this->isButtonVisible($matches[1])) { |
| 44 | 44 | if (array_key_exists($matches[1], $this->buttons) && is_callable($this->buttons[$matches[1]])) { |
| 45 | 45 | return call_user_func_array($this->buttons[$matches[1]], [ |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | if ($this->urlGenerator != null && is_callable($this->urlGenerator)) { |
| 73 | 73 | return call_user_func_array($this->urlGenerator, [$entity, $action, $this->container['router']]); |
| 74 | 74 | } elseif (method_exists($entity, 'getId')) { |
| 75 | - return $this->container['router']->generate($this->pathPrefix . $action, ['id' => $entity->getId()]); |
|
| 75 | + return $this->container['router']->generate($this->pathPrefix.$action, ['id' => $entity->getId()]); |
|
| 76 | 76 | } else { |
| 77 | - throw new Exception('Could not generate url for action: ' . $action); |
|
| 77 | + throw new Exception('Could not generate url for action: '.$action); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | |