Skip to content

Commit ca9c91d

Browse files
author
tomcyr
committed
Merge branch 'master' of github.com:APY/APYDataGridBundle
2 parents fbdc271 + f396420 commit ca9c91d

29 files changed

+268
-221
lines changed

.travis.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
4+
- 7.2
5+
- 7.3
66

77
matrix:
88
include:
9-
- php: 5.6
9+
- php: 7.2
1010
env: |
11-
SYMFONY_VERSION=2.7.*
12-
- php: 5.6
13-
env: |
14-
SYMFONY_VERSION=2.8.*
15-
- php: 7.1
11+
SYMFONY_VERSION=^3.0
12+
- php: 7.2
1613
env: |
1714
SYMFONY_VERSION=^4.0
1815
1916
before_install:
17+
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
2018
- |
2119
if [ "${SYMFONY_VERSION}" != "" ]; then
22-
packages="form dependency-injection config http-foundation http-kernel options-resolver security serializer"
20+
packages="form dependency-injection config http-foundation http-kernel options-resolver security-guard serializer"
2321
devpackages="framework-bundle browser-kit templating expression-language"
2422
for package in $packages
2523
do
@@ -31,10 +29,6 @@ before_install:
3129
done
3230
fi;
3331
34-
35-
before_script:
36-
- echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
37-
3832
install:
3933
- travis_retry composer self-update
4034
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update ${COMPOSER_FLAGS} --no-interaction
@@ -46,4 +40,4 @@ script:
4640
- php vendor/bin/phpunit -c phpunit.xml.dist
4741

4842
after_success:
49-
- php vendor/bin/coveralls
43+
- php vendor/bin/php-coveralls

DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
1717
*/
1818
public function getConfigTreeBuilder()
1919
{
20-
$treeBuilder = new TreeBuilder();
21-
$rootNode = $treeBuilder->root('apy_data_grid');
20+
$treeBuilder = new TreeBuilder('apy_data_grid');
21+
$rootNode = $treeBuilder->getRootNode();
2222

2323
$rootNode
2424
->children()
@@ -32,7 +32,7 @@ public function getConfigTreeBuilder()
3232
->prototype('scalar')->end()
3333
->end()
3434
->booleanNode('persistence')->defaultFalse()->end()
35-
->scalarNode('theme')->defaultValue('APYDataGridBundle::blocks.html.twig')->end()
35+
->scalarNode('theme')->defaultValue('@APYDataGrid/blocks.html.twig')->end()
3636
->scalarNode('no_data_message')->defaultValue('No data')->end()
3737
->scalarNode('no_result_message')->defaultValue('No result')->end()
3838
->scalarNode('actions_columns_size')->defaultValue(-1)->end()

Grid/Column/Column.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ public function getFilters($source)
687687
{
688688
$filters = [];
689689

690-
if (isset($this->data) && $this->hasOperator($this->data['operator'])) {
690+
if (isset($this->data['operator']) && $this->hasOperator($this->data['operator'])) {
691691
if ($this instanceof ArrayColumn && in_array($this->data['operator'], [self::OPERATOR_EQ, self::OPERATOR_NEQ])) {
692692
$filters[] = new Filter($this->data['operator'], $this->data['from']);
693693
} else {

Grid/Export/Export.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
abstract class Export implements ExportInterface, ContainerAwareInterface
2121
{
22-
const DEFAULT_TEMPLATE = 'APYDataGridBundle::blocks.html.twig';
22+
const DEFAULT_TEMPLATE = '@APYDataGrid/blocks.html.twig';
2323

2424
protected $title;
2525

@@ -459,7 +459,7 @@ protected function getTemplatesFromString($theme)
459459
$templates = [];
460460

461461
$template = $this->twig->loadTemplate($theme);
462-
while ($template instanceof \Twig_Template) {
462+
while ($template instanceof TemplateWrapper) {
463463
$templates[] = $template;
464464
$template = $template->getParent([]);
465465
}

Grid/Grid.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Symfony\Component\HttpFoundation\RedirectResponse;
2727
use Symfony\Component\HttpFoundation\Request;
2828
use Symfony\Component\HttpFoundation\Response;
29+
use Twig\TemplateWrapper;
2930

3031
class Grid implements GridInterface
3132
{
@@ -359,8 +360,10 @@ public function initialize()
359360
$this->setPersistence($config->isPersisted());
360361

361362
// Route parameters
362-
$routeParameters = $config->getRouteParameters();
363-
if (!empty($routeParameters)) {
363+
$routeParameters = [];
364+
$parameters = $config->getRouteParameters();
365+
if (!empty($parameters)) {
366+
$routeParameters = $parameters;
364367
foreach ($routeParameters as $parameter => $value) {
365368
$this->setRouteParameter($parameter, $value);
366369
}
@@ -1135,7 +1138,7 @@ protected function set($key, $data)
11351138

11361139
protected function saveSession()
11371140
{
1138-
if (!empty($this->sessionData)) {
1141+
if (!empty($this->sessionData) && !empty($this->hash)) {
11391142
$this->session->set($this->hash, $this->sessionData);
11401143
}
11411144
}
@@ -1395,12 +1398,11 @@ public function getRowActions()
13951398
public function setTemplate($template)
13961399
{
13971400
if ($template !== null) {
1398-
if ($template instanceof \Twig_Template) {
1401+
if ($template instanceof TemplateWrapper) {
13991402
$template = '__SELF__' . $template->getTemplateName();
14001403
} elseif (!is_string($template)) {
14011404
throw new \Exception(self::TWIG_TEMPLATE_LOAD_EX_MSG);
14021405
}
1403-
14041406
$this->set(self::REQUEST_QUERY_TEMPLATE, $template);
14051407
$this->saveSession();
14061408
}
@@ -2147,7 +2149,7 @@ public function getGridResponse($param1 = null, $param2 = null, Response $respon
21472149
if ($view === null) {
21482150
return $parameters;
21492151
} else {
2150-
return $this->container->get('templating')->renderResponse($view, $parameters, $response);
2152+
return new Response($this->container->get('twig')->render($view, $parameters, $response));
21512153
}
21522154
}
21532155
}

Grid/GridManager.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,15 @@ public function getGridManagerResponse($param1 = null, $param2 = null, Response
193193
return $parameters;
194194
}
195195

196-
return $this->container->get('templating')->renderResponse($view, $parameters, $response);
196+
$content = $this->container->get('twig')->render($view, $parameters);
197+
198+
if (null === $response) {
199+
$response = new Response();
200+
}
201+
202+
$response->setContent($content);
203+
204+
return $response;
197205
}
198206
}
199207

README.md

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
1-
Datagrid for Symfony inspired by Zfdatagrid and Magento Grid.
2-
This bundle was initiated by Stanislav Turza (Sorien).
31

4-
[![Build Status](https://secure.travis-ci.org/APY/APYDataGridBundle.png?branch=master)](http://travis-ci.org/APY/APYDataGridBundle)
5-
[![Coverage Status](https://coveralls.io/repos/github/APY/APYDataGridBundle/badge.svg?branch=test-improvement)](https://coveralls.io/github/APY/APYDataGridBundle?branch=test-improvement)
6-
[![Stories in Ready](https://badge.waffle.io/APY/APYDataGridBundle.svg?label=ready&title=Ready)](http://waffle.io/APY/APYDataGridBundle)
7-
[![Gitter](https://badges.gitter.im/APY/APYDataGridBundle.svg)](https://gitter.im/APY/APYDataGridBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
2+
# APYDataGrid Bundle
83

9-
See [CHANGELOG](https://github.com/APY/APYDataGridBundle/blob/master/CHANGELOG.md) and [UPGRADE 2.0](https://github.com/APY/APYDataGridBundle/blob/master/UPGRADE-2.0.md)
4+
This **Symfony Bundle** allows you to create wonderful grid based on data or entities of your projet.
105

11-
## Features
6+
[![Build Status](https://secure.travis-ci.org/APY/APYDataGridBundle.png?branch=master)](http://travis-ci.org/APY/APYDataGridBundle) [![Coverage Status](https://coveralls.io/repos/github/APY/APYDataGridBundle/badge.svg?branch=test-improvement)](https://coveralls.io/github/APY/APYDataGridBundle?branch=test-improvement)
127

13-
- Supports Entity (ORM), Document (ODM) and Vector (Array) sources
14-
- Sortable and Filterable with operators (Comparison operators, range, starts/ends with, (not) contains, is (not) defined, regex)
8+
## Features
9+
This bundle allow you to create listing with many features that you can expect :
10+
- Various data sources : supports **Entity** (ORM), **Document** (ODM) and **Vector** (Array) sources
11+
- Data manipulation : **Sortable** and **Filterable** with many operators
1512
- Auto-typing columns (Text, Number, Boolean, Array, DateTime, Date, ...)
16-
- Locale support for DateTime, Date and Number columns (Decimal, Currency, Percent, Duration, Scientific, Spell out)
13+
- Locale support for columns and data (DateTime, Date and Number columns)
1714
- Input, Select, checkbox and radio button filters filled with the data of the grid or an array of values
1815
- Export (CSV, Excel, _PDF_, XML, JSON, HTML, ...)
19-
- Mass actions
20-
- Row actions
16+
- Mass actions, Row actions
2117
- Supports mapped fields with Entity source
2218
- Securing the columns, actions and export with security roles
2319
- Annotations and PHP configuration
2420
- External filters box
2521
- Ajax loading
2622
- Pagination (You can also use Pagerfanta)
27-
- Column width and column align
28-
- Prefix translated titles
2923
- Grid manager for multi-grid on the same page
3024
- Groups configuration for ORM and ODM sources
31-
- Easy templates overriding (twig)
25+
- Easy templates overriding (Twig)
3226
- Custom columns and filters creation
33-
- ...
27+
- *and many more*
3428

35-
## Documentation
29+
## Installation, documentation
3630

3731
See the [summary](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/summary.md).
3832

@@ -44,17 +38,13 @@ Full example with this [CSS style file](https://github.com/APY/APYDataGridBundle
4438

4539
Simple example with the external filter box in english:
4640

47-
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_en.png?raw=true)
41+
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_en.png)
4842

4943
Same example in french:
5044

5145
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_fr.png?raw=true)
5246

53-
Data used in these screenshots (this is a phpMyAdmin screenshot):
54-
55-
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_database.png?raw=true)
56-
57-
## Simple grid with an ORM source
47+
## Example of a simple grid with an ORM source
5848

5949
```php
6050
<?php
@@ -118,3 +108,9 @@ class MyEntity
118108

119109
And clear your cache.
120110

111+
## Bundle history
112+
113+
Datagrid for Symfony inspired by Zfdatagrid and Magento Grid.
114+
This bundle was initiated by Stanislav Turza (Sorien).
115+
116+
See [CHANGELOG](https://github.com/APY/APYDataGridBundle/blob/master/CHANGELOG.md) and [UPGRADE 2.0](https://github.com/APY/APYDataGridBundle/blob/master/UPGRADE-2.0.md)

Resources/config/services.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
<argument>%apy_data_grid.actions_columns_title%</argument>
4242
</call>
4343
</service>
44+
45+
<service id="%grid.class%" alias="grid" public="true">
46+
</service>
4447

4548
<service id="grid.manager" class="%grid.manager.class%">
4649
<argument type="service" id="service_container" />

0 commit comments

Comments
 (0)