diff --git a/.travis.yml b/.travis.yml index a8d8436..4e18a3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,8 @@ matrix: env: DB=PGSQL PHPUNIT_TEST=1 - php: 7.1 env: DB=MYSQL PHPUNIT_COVERAGE_TEST=1 + - php: 7.2 + env: DB=MYSQL PHPUNIT_TEST=1 before_script: - phpenv rehash @@ -25,7 +27,7 @@ before_script: script: - if [[ $PHPUNIT_TEST ]]; then vendor/bin/phpunit tests/; fi - if [[ $PHPUNIT_COVERAGE_TEST ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=coverage.xml; fi - - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs --standard=vendor/silverstripe/framework/phpcs.xml.dist src/ tests/ ; fi + - if [[ $PHPCS_TEST ]]; then vendor/bin/phpcs src/ tests/ *.php; fi after_success: - if [[ $PHPUNIT_COVERAGE_TEST ]]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..1b984f8 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,9 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + + + + + diff --git a/src/GridFieldConfigurablePaginator.php b/src/GridFieldConfigurablePaginator.php index f3af8d5..3655ae9 100644 --- a/src/GridFieldConfigurablePaginator.php +++ b/src/GridFieldConfigurablePaginator.php @@ -5,8 +5,8 @@ namespace Symbiote\GridFieldExtensions; use Exception; use SilverStripe\Core\Config\Configurable; use SilverStripe\Forms\GridField\GridField; -use SilverStripe\Forms\GridField\GridFieldPaginator; use SilverStripe\Forms\GridField\GridField_FormAction; +use SilverStripe\Forms\GridField\GridFieldPaginator; use SilverStripe\Forms\GridField\GridState_Data; use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\Limitable; @@ -269,7 +269,7 @@ class GridFieldConfigurablePaginator extends GridFieldPaginator * {@inheritDoc} * * @param GridField $gridField - * @return ArrayList|null + * @return ArrayData|null */ public function getTemplateParameters(GridField $gridField) { @@ -281,7 +281,7 @@ class GridFieldConfigurablePaginator extends GridFieldPaginator // Figure out which page and record range we're on if (!$arguments['total-rows']) { - return; + return null; } // Define a list of the FormActions that should be generated for pager controls (see getPagerActions()) @@ -289,13 +289,15 @@ class GridFieldConfigurablePaginator extends GridFieldPaginator 'first' => array( 'title' => 'First', 'args' => array('first-shown' => 1), - 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left ss-gridfield-firstpage', + 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-left ' + . 'ss-gridfield-firstpage', 'disable-previous' => ($this->getCurrentPage() == 1) ), 'prev' => array( 'title' => 'Previous', 'args' => array('first-shown' => $arguments['first-shown'] - $this->getItemsPerPage()), - 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-left ss-gridfield-previouspage', + 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-left ' + . 'ss-gridfield-previouspage', 'disable-previous' => ($this->getCurrentPage() == 1) ), 'next' => array( @@ -307,7 +309,8 @@ class GridFieldConfigurablePaginator extends GridFieldPaginator 'last' => array( 'title' => 'Last', 'args' => array('first-shown' => ($this->getTotalPages() - 1) * $this->getItemsPerPage() + 1), - 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right ss-gridfield-lastpage', + 'extra-class' => 'btn btn-secondary btn--hide-text btn-sm font-icon-angle-double-right ' + . 'ss-gridfield-lastpage', 'disable-next' => ($this->getCurrentPage() == $arguments['total-pages']) ), 'pagesize' => array( diff --git a/src/GridFieldOrderableRows.php b/src/GridFieldOrderableRows.php index 91cb6d3..8e52a33 100755 --- a/src/GridFieldOrderableRows.php +++ b/src/GridFieldOrderableRows.php @@ -11,17 +11,17 @@ use SilverStripe\Forms\GridField\GridField_DataManipulator; use SilverStripe\Forms\GridField\GridField_HTMLProvider; use SilverStripe\Forms\GridField\GridField_SaveHandler; use SilverStripe\Forms\GridField\GridField_URLHandler; +use SilverStripe\Forms\GridField\GridFieldPaginator; use SilverStripe\Forms\HiddenField; use SilverStripe\ORM\ArrayList; -use SilverStripe\ORM\DataObject; -use SilverStripe\ORM\DB; use SilverStripe\ORM\DataList; +use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObjectInterface; +use SilverStripe\ORM\DB; use SilverStripe\ORM\ManyManyList; use SilverStripe\ORM\SS_List; use SilverStripe\ORM\SS_Map; use SilverStripe\View\ViewableData; -use Exception; /** * Allows grid field rows to be re-ordered via drag and drop. Both normal data @@ -363,7 +363,7 @@ class GridFieldOrderableRows extends RequestHandler implements */ public function handleMoveToPage(GridField $grid, $request) { - if (!$paginator = $grid->getConfig()->getComponentByType('SilverStripe\\Forms\\GridField\\GridFieldPaginator')) { + if (!$paginator = $grid->getConfig()->getComponentByType(GridFieldPaginator::class)) { $this->httpError(404, 'Paginator component not found'); }