Skip to content

Commit a6bd37d

Browse files
author
Hüseyin Mert
authored
Merge pull request #877 from APY/symfony3
Symfony 2.8|^3.0 Support
2 parents 2f4e029 + 2017028 commit a6bd37d

23 files changed

+678
-227
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: php
22

33
php:
4-
- 5.5
54
- 5.6
65
- 7.0
76

Grid/Column/Column.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
use APY\DataGridBundle\Grid\Filter;
1616
use Doctrine\Common\Version as DoctrineVersion;
17-
use Symfony\Component\Security\Core\SecurityContextInterface;
17+
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1818

1919
abstract class Column
2020
{
@@ -80,7 +80,7 @@ abstract class Column
8080
protected $params;
8181
protected $isSorted = false;
8282
protected $orderUrl;
83-
protected $securityContext;
83+
protected $authorizationChecker;
8484
protected $data;
8585
protected $operatorsVisible;
8686
protected $operators;
@@ -293,8 +293,8 @@ public function isVisible($isExported = false)
293293
{
294294
$visible = $isExported && $this->export !== null ? $this->export : $this->visible;
295295

296-
if ($visible && $this->securityContext !== null && $this->getRole() != null) {
297-
return $this->securityContext->isGranted($this->getRole());
296+
if ($visible && $this->authorizationChecker !== null && $this->getRole() != null) {
297+
return $this->authorizationChecker->isGranted($this->getRole());
298298
}
299299

300300
return $visible;
@@ -804,13 +804,13 @@ public function hasDQLFunction(&$matches = null)
804804
/**
805805
* Internal function.
806806
*
807-
* @param $securityContext
807+
* @param $authorizationChecker
808808
*
809809
* @return $this
810810
*/
811-
public function setSecurityContext(SecurityContextInterface $securityContext)
811+
public function setAuthorizationChecker(AuthorizationCheckerInterface $authorizationChecker)
812812
{
813-
$this->securityContext = $securityContext;
813+
$this->authorizationChecker = $authorizationChecker;
814814

815815
return $this;
816816
}

Grid/Columns.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414

1515
use APY\DataGridBundle\Grid\Column\Column;
1616
use APY\DataGridBundle\Grid\Helper\ColumnsIterator;
17-
use Symfony\Component\Security\Core\SecurityContextInterface;
17+
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
1818

1919
class Columns implements \IteratorAggregate, \Countable
2020
{
2121
protected $columns = [];
2222
protected $extensions = [];
2323

2424
/**
25-
* @var \Symfony\Component\Security\Core\SecurityContextInterface
25+
* @var AuthorizationCheckerInterface
2626
*/
27-
protected $securityContext;
27+
protected $authorizationChecker;
2828

29-
public function __construct(SecurityContextInterface $securityContext)
29+
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
3030
{
31-
$this->securityContext = $securityContext;
31+
$this->authorizationChecker = $authorizationChecker;
3232
}
3333

3434
public function getIterator($showOnlySourceColumns = false)
@@ -46,7 +46,7 @@ public function getIterator($showOnlySourceColumns = false)
4646
*/
4747
public function addColumn(Column $column, $position = 0)
4848
{
49-
$column->setSecurityContext($this->securityContext);
49+
$column->setAuthorizationChecker($this->authorizationChecker);
5050

5151
if ($position == 0) {
5252
$this->columns[] = $column;

Grid/Export/Export.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ protected function getGridCell($column, $row)
384384
protected function hasBlock($name)
385385
{
386386
foreach ($this->getTemplates() as $template) {
387-
if ($template->hasBlock($name)) {
387+
if ($template->hasBlock($name, [])) {
388388
return true;
389389
}
390390
}
@@ -403,7 +403,7 @@ protected function hasBlock($name)
403403
protected function renderBlock($name, $parameters)
404404
{
405405
foreach ($this->getTemplates() as $template) {
406-
if ($template->hasBlock($name)) {
406+
if ($template->hasBlock($name, [])) {
407407
return $template->renderBlock($name, array_merge($parameters, $this->params));
408408
}
409409
}

Grid/Grid.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Grid implements GridInterface
6060
protected $request;
6161

6262
/**
63-
* @var \Symfony\Component\Security\Core\SecurityContext
63+
* @var \Symfony\Component\Security\Core\Authorization\AuthorizationChecker
6464
*/
6565
protected $securityContext;
6666

@@ -307,9 +307,9 @@ public function __construct($container, $id = '', GridConfigInterface $config =
307307
$this->config = $config;
308308

309309
$this->router = $container->get('router');
310-
$this->request = $container->get('request');
310+
$this->request = $container->get('request_stack')->getCurrentRequest();
311311
$this->session = $this->request->getSession();
312-
$this->securityContext = $container->get('security.context');
312+
$this->securityContext = $container->get('security.authorization_checker');
313313

314314
$this->id = $id;
315315

@@ -343,6 +343,11 @@ public function initialize()
343343
$this->setRouteParameter($parameter, $value);
344344
}
345345
}
346+
347+
// Route
348+
if (null != $config->getRoute()) {
349+
$this->setRouteUrl($this->router->generate($config->getRoute(), $routeParameters));
350+
}
346351

347352
// Route
348353
if (null != $config->getRoute()) {
@@ -632,7 +637,7 @@ protected function processMassActions($actionId)
632637
$action->getParameters()
633638
);
634639

635-
$subRequest = $this->container->get('request')->duplicate([], null, $path);
640+
$subRequest = $this->request->duplicate([], null, $path);
636641

637642
$this->massActionResponse = $this->container->get('http_kernel')->handle($subRequest, \Symfony\Component\HttpKernel\HttpKernelInterface::SUB_REQUEST);
638643
} else {

Resources/config/services.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</call>
2121
</service>
2222

23-
<service id="grid" class="%grid.class%" scope="prototype">
23+
<service id="grid" class="%grid.class%" shared="false">
2424
<argument type="service" id="service_container" />
2525
<call method="setLimits">
2626
<argument>%apy_data_grid.limits%</argument>
@@ -50,12 +50,13 @@
5050
<argument type="service" id="annotation_reader" />
5151
</service>
5252

53-
<service id="grid.mapping.manager" class="APY\DataGridBundle\Grid\Mapping\Metadata\Manager" scope="prototype">
53+
<service id="grid.mapping.manager" class="APY\DataGridBundle\Grid\Mapping\Metadata\Manager" shared="false">
5454
<argument type="service" id="form.factory"/>
5555
<call method="addDriver">
5656
<argument type="service" id="grid.metadata.driver.annotation" />
5757
<argument>1</argument>
5858
</call>
5959
</service>
6060
</services>
61+
6162
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Columns Configuration with Annotations
2+
3+
## Annotations
4+
5+
* [Source Annotation](annotations/source_annotation.md)
6+
* [Column Annotation for a property](annotations/column_annotation_property.md)
7+
* [Column Annotation for a class](annotations/column_annotation_class.md)
8+
* [ORM Association Mapping](annotations/association_mapping.md)
9+
* [DQL Functions](annotations/dql_function.md)
10+
11+
## Column Types References
12+
13+
* [Text Column](types/text_column.md)
14+
* [Number Column](types/number_column.md)
15+
* [Decimal](types/number_column.md)
16+
* [Currency](types/number_column.md)
17+
* [Percent](types/number_column.md)
18+
* [Duration](types/number_column.md)
19+
* [Scientific](types/number_column.md)
20+
* [Spell Out](types/number_column.md)
21+
* [Boolean Column](types/boolean_column.md)
22+
* [DateTime Column](types/datetime_column.md)
23+
* [Date Column](types/date_column.md)
24+
* [_Time_](types/time_column.md)
25+
* [Array Column](types/array_column.md)
26+
* [Blank Column](types/blank_column.md)
27+
* [Rank Column](types/rank_column.md)
28+
* [Join Column](types/join_column.md)
29+
* [Create your column](types/create_column.md)
30+
31+
## Filters
32+
33+
* [Input Filter](filters/input_filter.md)
34+
* [Select Filter](filters/select_filter.md)
35+
* [Create a filter](filters/create_filter.md)

Resources/doc/configuration.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# APYDataGrid Configuration Reference
2+
3+
All available configuration options are listed below with their default values.
4+
5+
```yaml
6+
apy_data_grid:
7+
limits: [20, 50, 100]
8+
persistence: false
9+
theme: 'APYDataGridBundle::blocks.html.twig'
10+
no_data_message: "No data"
11+
no_result_message: "No result"
12+
actions_columns_size: -1
13+
actions_columns_title: "Actions"
14+
actions_columns_separator: "<br />"
15+
pagerfanta:
16+
enable: false
17+
view_class: "Pagerfanta\View\DefaultView"
18+
options: ["prev_message" => "«", "next_message" => "»"]
19+
```

Resources/doc/export/index.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Export
2+
3+
APYDataGrid bundle provides different ways for export your datas. This bundle proposes native exports such as a CSV or a JSON export and library-dependent exports such as Excel and PDF exports but everything is made that it is really easy to create your own export.
4+
5+
> Note: An export don't export mass action and row actions columns.
6+
7+
## Native Exports
8+
9+
* [CSV Export](native_exports/CSV_export.md)
10+
* [DSV Export](native_exports/DSV_export.md)
11+
* [Excel Export](native_exports/Excel_export.md)
12+
* [JSON Export](native_exports/JSON_export.md)
13+
* [SCVS Export](native_exports/SCVS_export.md)
14+
* [TSV Export](native_exports/TSV_export.md)
15+
* [XML Export](native_exports/XML_export.md)
16+
17+
## External Library Exports
18+
19+
### With PHPExcel
20+
21+
Add the following package to your composer.json file:
22+
23+
```bash
24+
$ composer require phpoffice/phpexcel "dev-master"
25+
```
26+
27+
* [PHPExcel Excel 2007 Export](library-dependent_exports/PHPExcel/PHPExcel_excel2007_export.md)
28+
* [PHPExcel Excel 2003 Export](library-dependent_exports/PHPExcel/PHPExcel_excel2003_export.md)
29+
* [PHPExcel Excel 5 (97-2003) Export](library-dependent_exports/PHPExcel/PHPExcel_excel5_export.md)
30+
* [PHPExcel Simple HTML Export](library-dependent_exports/PHPExcel/PHPExcel_HTML_export.md)
31+
* [PHPExcel simple PDF export](library-dependent_exports/PHPExcel/PHPExcel_PDF_export.md)
32+
33+
## Cook Book
34+
35+
* [How to create your custom export](create_export.md)

Resources/doc/export/library-dependent_exports/PHPExcel/PHPExcel_installation.md

-16
This file was deleted.

Resources/doc/features.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# APYDataGrid Bundle Features
2+
3+
- Supports Entity (ORM), Document (ODM) and Vector (Array) sources
4+
- Sortable and Filterable with operators (Comparison operators, range, starts/ends with, (not) contains, is (not) defined, regex)
5+
- Auto-typing columns (Text, Number, Boolean, Array, DateTime, Date, ...)
6+
- Locale support for DateTime, Date and Number columns (Decimal, Currency, Percent, Duration, Scientific, Spell out)
7+
- Input, Select, checkbox and radio button filters filled with the data of the grid or an array of values
8+
- Export (CSV, Excel, _PDF_, XML, JSON, HTML, ...)
9+
- Mass actions
10+
- Row actions
11+
- Supports mapped fields with Entity source
12+
- Securing the columns, actions and export with security roles
13+
- Annotations and PHP configuration
14+
- External filters box
15+
- Ajax loading
16+
- Pagination (You can also use Pagerfanta)
17+
- Column width and column align
18+
- Prefix translated titles
19+
- Grid manager for multi-grid on the same page
20+
- Groups configuration for ORM and ODM sources
21+
- Easy templates overriding (twig)
22+
- Custom columns and filters creation
23+
24+
## Screenshot
25+
26+
Full example with this [CSS style file](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/grid_configuration/working_example.css):
27+
28+
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_full.png?raw=true)
29+
30+
Simple example with the external filter box in english:
31+
32+
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_en.png?raw=true)
33+
34+
Same example in french:
35+
36+
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_fr.png?raw=true)
37+
38+
Data used in these screenshots (this is a phpMyAdmin screenshot):
39+
40+
![test](https://github.com/APY/APYDataGridBundle/blob/master/Resources/doc/images/screenshot_database.png?raw=true)

0 commit comments

Comments
 (0)