diff --git a/.travis.yml b/.travis.yml index 3c7ebff..2f85b1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: php php: - - 5.3 - - 5.4 - 5.5 - 5.6 - hhvm diff --git a/Grid/Factory.php b/Grid/Factory.php index 55cddb1..96669aa 100644 --- a/Grid/Factory.php +++ b/Grid/Factory.php @@ -24,15 +24,17 @@ public function __construct($container) /** * @param string $gridClassName The name of the Grid descendant class that will be instantiated + * @param \Symfony\Component\HttpFoundation\Request $request * * @return \PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract + * */ - public function createGrid($gridClassName) + public function createGrid($gridClassName, \Symfony\Component\HttpFoundation\Request $request) { $gridClass = new \ReflectionClass($gridClassName); /* @var \PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract $grid */ - $grid = $gridClass->newInstance($this->container); + $grid = $gridClass->newInstance($this->container, $request); $grid->setupGrid(); return $grid; diff --git a/Grid/Filter/Operator/Date.php b/Grid/Filter/Operator/Date.php index e100929..861ed1a 100644 --- a/Grid/Filter/Operator/Date.php +++ b/Grid/Filter/Operator/Date.php @@ -2,7 +2,7 @@ namespace PedroTeixeira\Bundle\GridBundle\Grid\Filter\Operator; -use Symfony\Component\Locale\Stub\DateFormat\FullTransformer; +use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer; /** * Date @@ -18,6 +18,7 @@ public function execute($value) $this->container->getParameter('pedro_teixeira_grid.date.date_format'), $this->container->getParameter('locale') ); + $date = new \DateTime(); $transformer->parse($date, $value); diff --git a/Grid/Filter/Operator/DateRange.php b/Grid/Filter/Operator/DateRange.php index 919665d..4c41b01 100644 --- a/Grid/Filter/Operator/DateRange.php +++ b/Grid/Filter/Operator/DateRange.php @@ -2,7 +2,7 @@ namespace PedroTeixeira\Bundle\GridBundle\Grid\Filter\Operator; -use Symfony\Component\Locale\Stub\DateFormat\FullTransformer; +use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer; /** * DateRange diff --git a/Grid/GridAbstract.php b/Grid/GridAbstract.php index bd34757..09cf4af 100644 --- a/Grid/GridAbstract.php +++ b/Grid/GridAbstract.php @@ -8,6 +8,8 @@ use Doctrine\ORM\Tools\Pagination\Paginator; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\HttpFoundation\Request; /** * Grid Abstract @@ -15,7 +17,7 @@ abstract class GridAbstract { /** - * @var \Symfony\Component\DependencyInjection\Container + * @var Container */ protected $container; @@ -25,7 +27,7 @@ abstract class GridAbstract protected $router; /** - * @var \Symfony\Component\HttpFoundation\Request + * @var Request */ protected $request; @@ -80,16 +82,17 @@ abstract class GridAbstract abstract public function setupGrid(); /** - * @param \Symfony\Component\DependencyInjection\Container $container + * @param Container $container + * @param Request $request * * @return \PedroTeixeira\Bundle\GridBundle\Grid\GridAbstract */ - public function __construct(\Symfony\Component\DependencyInjection\Container $container) + public function __construct(Container $container, Request $request) { $this->container = $container; + $this->request = $request; $this->router = $this->container->get('router'); - $this->request = $this->container->get('request'); $this->templating = $this->container->get('templating'); $this->columns = array(); @@ -109,7 +112,7 @@ public function __construct(\Symfony\Component\DependencyInjection\Container $co } /** - * @return \Symfony\Component\DependencyInjection\Container + * @return Container */ public function getContainer() { @@ -369,24 +372,24 @@ public function getData() $rowColumn = $row[$column->getField()]; - // Array scalar + // Array scalar } elseif (array_key_exists(0, $row) && array_key_exists($column->getField(), $row[0])) { $rowColumn = $row[0][$column->getField()]; - // Object + // Object } elseif (method_exists($row, 'get' . ucfirst($column->getField()))) { $method = 'get' . ucfirst($column->getField()); $rowColumn = $row->$method(); - // Object scalar + // Object scalar } elseif (array_key_exists(0, $row) && method_exists($row[0], 'get' . ucfirst($column->getField()))) { $method = 'get' . ucfirst($column->getField()); $rowColumn = $row[0]->$method(); - // Array + // Array } elseif ($column->getTwig()) { $rowColumn = $this->templating->render( diff --git a/Grid/Render/Date.php b/Grid/Render/Date.php index 8cd3251..0178fa4 100644 --- a/Grid/Render/Date.php +++ b/Grid/Render/Date.php @@ -2,7 +2,7 @@ namespace PedroTeixeira\Bundle\GridBundle\Grid\Render; -use Symfony\Component\Locale\Stub\DateFormat\FullTransformer; +use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer; /** * Render Date diff --git a/Grid/Render/DateTime.php b/Grid/Render/DateTime.php index 296132e..7a2faa4 100644 --- a/Grid/Render/DateTime.php +++ b/Grid/Render/DateTime.php @@ -2,7 +2,7 @@ namespace PedroTeixeira\Bundle\GridBundle\Grid\Render; -use Symfony\Component\Locale\Stub\DateFormat\FullTransformer; +use Symfony\Component\Intl\DateFormatter\DateFormat\FullTransformer; /** * Render Date diff --git a/README.md b/README.md index a936819..3ffb85b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# pedro-teixeira/grid-bundle +# pedro-teixeira/grid-bundle (Symfony3 fork) [![Build Status](http://img.shields.io/travis/pedro-teixeira/grid-bundle.svg?style=flat)](https://travis-ci.org/pedro-teixeira/grid-bundle) [![Version](http://img.shields.io/packagist/v/pedro-teixeira/grid-bundle.svg?style=flat)](https://packagist.org/packages/pedro-teixeira/grid-bundle) [![Downloads](http://img.shields.io/packagist/dt/pedro-teixeira/grid-bundle.svg?style=flat)](https://packagist.org/packages/pedro-teixeira/grid-bundle) [![License](http://img.shields.io/packagist/l/pedro-teixeira/grid-bundle.svg?style=flat)](https://packagist.org/packages/pedro-teixeira/grid-bundle) -> Ajax grid for Symfony2 +> Ajax grid for Symfony3 ## Example @@ -158,6 +158,7 @@ namespace PedroTeixeira\Bundle\TestBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; + use Symfony\Component\HttpFoundation\Request; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; @@ -175,14 +176,14 @@ * * @return array */ - public function indexAction() + public function indexAction(Request $request) { /** @var \Doctrine\ORM\EntityRepository $repository */ $repository = $this->getDoctrine()->getRepository('PedroTeixeiraTestBundle:TestEntity'); $queryBuilder = $repository->createQueryBuilder('r'); /** @var \PedroTeixeira\Bundle\TestBundle\Grid\TestGrid $grid */ - $grid = $this->get('pedroteixeira.grid')->createGrid('\PedroTeixeira\Bundle\TestBundle\Grid\TestGrid'); + $grid = $this->get('pedroteixeira.grid')->createGrid('\PedroTeixeira\Bundle\TestBundle\Grid\TestGrid', $request); $grid->setQueryBuilder($queryBuilder); if ($grid->isResponseAnswer()) { diff --git a/Resources/public/js/grid.js b/Resources/public/js/grid.js index c2b0538..697b355 100644 --- a/Resources/public/js/grid.js +++ b/Resources/public/js/grid.js @@ -1,3 +1,5 @@ +var run = false; + !function ($) { /* GRID PUBLIC CLASS DEFINITION @@ -25,6 +27,12 @@ , ajax:function () { + console.log("run: " + run); + if(run) { + return; + } + run = true; + var filters = this.$element.find('form').serializeArray(), tbody = this.$element.find('table').find('tbody.row-result'), emptyTbody = this.$element.find('table').find('tbody.row-empty'), @@ -84,6 +92,7 @@ } tbody.html(html) + run = false; }, error:function (error) { thisClass.gridUnlock() @@ -92,6 +101,7 @@ tbody.html('') alert('Error: ' + error.statusText) + run = false; } }) diff --git a/composer.json b/composer.json index 283843a..bc4afd6 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name" : "pedro-teixeira/grid-bundle", + "name" : "pedro-teixeira/grid-bundle-s3", "type" : "symfony-bundle", - "description" : "Ajax grid for Symfony2", + "description" : "Ajax grid for Symfony3", "keywords" : [ "datagrid", "grid" @@ -17,8 +17,9 @@ ], "require" : { "php" : ">=5.3", - "symfony/framework-bundle" : "~2 | ~3.0", - "doctrine/orm" : "~2.2" + "symfony/framework-bundle" : "~3", + "symfony/intl": "~3", + "doctrine/orm" : "~2.5" }, "require-dev" : { "squizlabs/php_codesniffer" : "~1"