Skip to content

Commit

Permalink
Merge branch 'master' of github.com:APY/APYDataGridBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcyr committed Feb 20, 2022
2 parents fbdc271 + f396420 commit ca9c91d
Show file tree
Hide file tree
Showing 29 changed files with 268 additions and 221 deletions.
22 changes: 8 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
language: php

php:
- 5.6
- 7.0
- 7.2
- 7.3

matrix:
include:
- php: 5.6
- php: 7.2
env: |
SYMFONY_VERSION=2.7.*
- php: 5.6
env: |
SYMFONY_VERSION=2.8.*
- php: 7.1
SYMFONY_VERSION=^3.0
- php: 7.2
env: |
SYMFONY_VERSION=^4.0
before_install:
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- |
if [ "${SYMFONY_VERSION}" != "" ]; then
packages="form dependency-injection config http-foundation http-kernel options-resolver security serializer"
packages="form dependency-injection config http-foundation http-kernel options-resolver security-guard serializer"
devpackages="framework-bundle browser-kit templating expression-language"
for package in $packages
do
Expand All @@ -31,10 +29,6 @@ before_install:
done
fi;
before_script:
- echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

install:
- travis_retry composer self-update
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update ${COMPOSER_FLAGS} --no-interaction
Expand All @@ -46,4 +40,4 @@ script:
- php vendor/bin/phpunit -c phpunit.xml.dist

after_success:
- php vendor/bin/coveralls
- php vendor/bin/php-coveralls
6 changes: 3 additions & 3 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('apy_data_grid');
$treeBuilder = new TreeBuilder('apy_data_grid');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand All @@ -32,7 +32,7 @@ public function getConfigTreeBuilder()
->prototype('scalar')->end()
->end()
->booleanNode('persistence')->defaultFalse()->end()
->scalarNode('theme')->defaultValue('APYDataGridBundle::blocks.html.twig')->end()
->scalarNode('theme')->defaultValue('@APYDataGrid/blocks.html.twig')->end()
->scalarNode('no_data_message')->defaultValue('No data')->end()
->scalarNode('no_result_message')->defaultValue('No result')->end()
->scalarNode('actions_columns_size')->defaultValue(-1)->end()
Expand Down
2 changes: 1 addition & 1 deletion Grid/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public function getFilters($source)
{
$filters = [];

if (isset($this->data) && $this->hasOperator($this->data['operator'])) {
if (isset($this->data['operator']) && $this->hasOperator($this->data['operator'])) {
if ($this instanceof ArrayColumn && in_array($this->data['operator'], [self::OPERATOR_EQ, self::OPERATOR_NEQ])) {
$filters[] = new Filter($this->data['operator'], $this->data['from']);
} else {
Expand Down
4 changes: 2 additions & 2 deletions Grid/Export/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

abstract class Export implements ExportInterface, ContainerAwareInterface
{
const DEFAULT_TEMPLATE = 'APYDataGridBundle::blocks.html.twig';
const DEFAULT_TEMPLATE = '@APYDataGrid/blocks.html.twig';

protected $title;

Expand Down Expand Up @@ -459,7 +459,7 @@ protected function getTemplatesFromString($theme)
$templates = [];

$template = $this->twig->loadTemplate($theme);
while ($template instanceof \Twig_Template) {
while ($template instanceof TemplateWrapper) {
$templates[] = $template;
$template = $template->getParent([]);
}
Expand Down
14 changes: 8 additions & 6 deletions Grid/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Twig\TemplateWrapper;

class Grid implements GridInterface
{
Expand Down Expand Up @@ -359,8 +360,10 @@ public function initialize()
$this->setPersistence($config->isPersisted());

// Route parameters
$routeParameters = $config->getRouteParameters();
if (!empty($routeParameters)) {
$routeParameters = [];
$parameters = $config->getRouteParameters();
if (!empty($parameters)) {
$routeParameters = $parameters;
foreach ($routeParameters as $parameter => $value) {
$this->setRouteParameter($parameter, $value);
}
Expand Down Expand Up @@ -1135,7 +1138,7 @@ protected function set($key, $data)

protected function saveSession()
{
if (!empty($this->sessionData)) {
if (!empty($this->sessionData) && !empty($this->hash)) {
$this->session->set($this->hash, $this->sessionData);
}
}
Expand Down Expand Up @@ -1395,12 +1398,11 @@ public function getRowActions()
public function setTemplate($template)
{
if ($template !== null) {
if ($template instanceof \Twig_Template) {
if ($template instanceof TemplateWrapper) {
$template = '__SELF__' . $template->getTemplateName();
} elseif (!is_string($template)) {
throw new \Exception(self::TWIG_TEMPLATE_LOAD_EX_MSG);
}

$this->set(self::REQUEST_QUERY_TEMPLATE, $template);
$this->saveSession();
}
Expand Down Expand Up @@ -2147,7 +2149,7 @@ public function getGridResponse($param1 = null, $param2 = null, Response $respon
if ($view === null) {
return $parameters;
} else {
return $this->container->get('templating')->renderResponse($view, $parameters, $response);
return new Response($this->container->get('twig')->render($view, $parameters, $response));
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion Grid/GridManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,15 @@ public function getGridManagerResponse($param1 = null, $param2 = null, Response
return $parameters;
}

return $this->container->get('templating')->renderResponse($view, $parameters, $response);
$content = $this->container->get('twig')->render($view, $parameters);

if (null === $response) {
$response = new Response();
}

$response->setContent($content);

return $response;
}
}

Expand Down
44 changes: 20 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
Datagrid for Symfony inspired by Zfdatagrid and Magento Grid.
This bundle was initiated by Stanislav Turza (Sorien).

[![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)
[![Stories in Ready](https://badge.waffle.io/APY/APYDataGridBundle.svg?label=ready&title=Ready)](http://waffle.io/APY/APYDataGridBundle)
[![Gitter](https://badges.gitter.im/APY/APYDataGridBundle.svg)](https://gitter.im/APY/APYDataGridBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
# APYDataGrid Bundle

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)
This **Symfony Bundle** allows you to create wonderful grid based on data or entities of your projet.

## Features
[![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)

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

## Documentation
## Installation, documentation

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

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

Simple example with the external filter box in english:

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

Same example in french:

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

Data used in these screenshots (this is a phpMyAdmin screenshot):

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

## Simple grid with an ORM source
## Example of a simple grid with an ORM source

```php
<?php
Expand Down Expand Up @@ -118,3 +108,9 @@ class MyEntity

And clear your cache.

## Bundle history

Datagrid for Symfony inspired by Zfdatagrid and Magento Grid.
This bundle was initiated by Stanislav Turza (Sorien).

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)
3 changes: 3 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<argument>%apy_data_grid.actions_columns_title%</argument>
</call>
</service>

<service id="%grid.class%" alias="grid" public="true">
</service>

<service id="grid.manager" class="%grid.manager.class%">
<argument type="service" id="service_container" />
Expand Down
Loading

0 comments on commit ca9c91d

Please sign in to comment.