Skip to content

Commit

Permalink
Merge pull request #191 from FriendsOfCake/upgrade-cakephp
Browse files Browse the repository at this point in the history
Upgrade cakephp
  • Loading branch information
josegonzalez authored Jun 28, 2017
2 parents 140769e + 80d2f50 commit 8723c8c
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 121 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
language: php

php:
- 7
- 5.6
- 7.0
- 7.1

before_script:
- composer self-update
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
],
"require": {
"cakephp/cakephp": "~3.0",
"cakephp/cakephp": "~3.4",
"friendsofcake/crud": "*",
"friendsofcake/bootstrap-ui": "~1.2"
},
Expand Down
6 changes: 3 additions & 3 deletions docs/_partials/pages/index/download-format-links.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Each sub-array should contain ``title`` and ``url`` parameters.
$action->config('scaffold.index_formats', [
[
'title' => 'JSON',
'url' => ['_ext' => 'json', '?' => $this->request->query]
'url' => ['_ext' => 'json', '?' => $this->request->getQueryParams()]
],
[
'title' => 'XML',
'url' => Router::url(['_ext' => 'xml', '?' => $this->request->query])
'url' => Router::url(['_ext' => 'xml', '?' => $this->request->getQueryParams()])
],
]);
Expand Down Expand Up @@ -86,7 +86,7 @@ can be modified to add a CSV Download Link.
$this->Crud->action()->config('scaffold.index_formats', [
[
'title' => 'CSV',
'url' => ['_ext' => 'csv', '?' => $this->request->query]
'url' => ['_ext' => 'csv', '?' => $this->request->getQueryParams()]
],
]);
return $this->Crud->execute();
Expand Down
4 changes: 2 additions & 2 deletions docs/_partials/pages/index/finder-scopes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ result-set. This can be done in the mapped action as follows:
]);
// We don't need to check for `all` as it is the default findMethod
if (in_array($this->request->query('finder'), ['active', 'inactive'])) {
$this->Crud->action()->config('findMethod', $this->request->query('finder'));
if (in_array($this->request->getQuery('finder'), ['active', 'inactive'])) {
$this->Crud->action()->config('findMethod', $this->request->getQuery('finder'));
}
return $this->Crud->execute();
}
Expand Down
10 changes: 5 additions & 5 deletions docs/basic-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ alter the ``contain()`` list for the pagination query:
public function index()
{
$this->Crud->on('beforePaginate', function ($event) {
$paginationQuery = $event->subject()->query;
$paginationQuery = $event->getSubject()->query;
$paginationQuery->contain([
'Categories',
'Authors' => ['fields' => ['id', 'name']]
Expand Down Expand Up @@ -306,9 +306,9 @@ you can use the ``relatedModels`` event:
public function add()
{
$this->Crud->on('relatedModel', function(\Cake\Event\Event $event) {
if ($event->subject->association->name() === 'Categories') {
$event->subject->query->limit(3);
$event->subject->query->where(['is_active' => true]);
if ($event->getSubject()->association->name() === 'Categories') {
$event->getSubject()->query->limit(3);
$event->getSubject()->query->where(['is_active' => true]);
}
});
return $this->Crud->execute();
Expand Down Expand Up @@ -483,7 +483,7 @@ alter the ``contain()`` list for the pagination query:
public function view()
{
$this->Crud->on('beforeFind', function ($event) {
$event->subject()->query->contain([
$event->getSubject()->query->contain([
'Categories',
'Authors' => ['fields' => ['id', 'name']]
]);
Expand Down
21 changes: 9 additions & 12 deletions src/Listener/Traits/FormTypeTrait.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?php
namespace CrudView\Listener\Traits;

use Cake\Event\Event;

trait FormTypeTrait
{
/**
* beforeRender event
*
* @param \Cake\Event\Event $event Event.
* @return void
*/
protected function beforeRenderFormType(Event $event)
protected function beforeRenderFormType()
{
$controller = $this->_controller();

Expand All @@ -38,9 +35,9 @@ protected function _getFormEnableDirtyCheck()
{
$action = $this->_action();

$formEnableDirtyCheck = $action->config('scaffold.form_enable_dirty_check');
$formEnableDirtyCheck = $action->getConfig('scaffold.form_enable_dirty_check');
if ($formEnableDirtyCheck === null) {
$formEnableDirtyCheck = $action->config('scaffold.enable_dirty_check');
$formEnableDirtyCheck = $action->getConfig('scaffold.enable_dirty_check');
if ($formEnableDirtyCheck !== null) {
$this->deprecatedScaffoldKeyNotice(
'scaffold.enable_dirty_check',
Expand All @@ -61,9 +58,9 @@ protected function _getFormSubmitButtonText()
{
$action = $this->_action();

$formSubmitButtonText = $action->config('scaffold.form_submit_button_text');
$formSubmitButtonText = $action->getConfig('scaffold.form_submit_button_text');
if ($formSubmitButtonText === null) {
$formSubmitButtonText = $action->config('scaffold.submit_button_text');
$formSubmitButtonText = $action->getConfig('scaffold.submit_button_text');
if ($formSubmitButtonText !== null) {
$this->deprecatedScaffoldKeyNotice(
'scaffold.submit_button_text',
Expand Down Expand Up @@ -132,7 +129,7 @@ protected function _getFormSubmitExtraButtons()
$defaults = $newDefaults;
}

$buttons = $action->config('scaffold.form_submit_extra_buttons');
$buttons = $action->getConfig('scaffold.form_submit_extra_buttons');
if ($buttons === null || $buttons === true) {
$buttons = $defaults;
}
Expand All @@ -154,7 +151,7 @@ protected function _getFormDisableExtraButtons()
{
$action = $this->_action();

return $action->config('scaffold.disable_extra_buttons') ?: false;
return $action->getConfig('scaffold.disable_extra_buttons') ?: false;
}

/**
Expand All @@ -167,7 +164,7 @@ protected function _getFormExtraButtonsBlacklist()
{
$action = $this->_action();

return $action->config('scaffold.extra_buttons_blacklist') ?: [];
return $action->getConfig('scaffold.extra_buttons_blacklist') ?: [];
}

/**
Expand All @@ -179,7 +176,7 @@ protected function _getFormUrl()
{
$action = $this->_action();

return $action->config('scaffold.form_action') ?: null;
return $action->getConfig('scaffold.form_action') ?: null;
}

/**
Expand Down
25 changes: 11 additions & 14 deletions src/Listener/Traits/IndexTypeTrait.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?php
namespace CrudView\Listener\Traits;

use Cake\Event\Event;

trait IndexTypeTrait
{
/**
* beforeRender event
*
* @param \Cake\Event\Event $event Event.
* @return void
*/
public function beforeRenderIndexType(Event $event)
public function beforeRenderIndexType()
{
$indexTitleField = $this->_getIndexTitleField();
$indexBodyField = $this->_getIndexBodyField();
Expand Down Expand Up @@ -39,7 +36,7 @@ protected function _getIndexFinderScopes()
{
$action = $this->_action();

return $action->config('scaffold.index_finder_scopes') ?: [];
return $action->getConfig('scaffold.index_finder_scopes') ?: [];
}

/**
Expand All @@ -52,7 +49,7 @@ protected function _getIndexFormats()
{
$action = $this->_action();

return $action->config('scaffold.index_formats') ?: [];
return $action->getConfig('scaffold.index_formats') ?: [];
}

/**
Expand All @@ -64,7 +61,7 @@ protected function _getIndexType()
{
$action = $this->_action();

$indexType = $action->config('scaffold.index_type');
$indexType = $action->getConfig('scaffold.index_type');
if (empty($indexType)) {
$indexType = 'table';
}
Expand All @@ -81,9 +78,9 @@ protected function _getIndexTitleField()
{
$action = $this->_action();

$field = $action->config('scaffold.index_title_field');
$field = $action->getConfig('scaffold.index_title_field');
if ($field === null) {
$field = $action->config('scaffold.index_blog_title_field');
$field = $action->getConfig('scaffold.index_blog_title_field');
if ($field !== null) {
$this->deprecatedScaffoldKeyNotice(
'scaffold.index_blog_title_field',
Expand All @@ -93,7 +90,7 @@ protected function _getIndexTitleField()
}

if (empty($field)) {
$field = $this->_table()->displayField();
$field = $this->_table()->getDisplayField();
}

return $field;
Expand All @@ -108,9 +105,9 @@ protected function _getIndexBodyField()
{
$action = $this->_action();

$field = $action->config('scaffold.index_body_field');
$field = $action->getConfig('scaffold.index_body_field');
if ($field === null) {
$field = $action->config('scaffold.index_blog_body_field');
$field = $action->getConfig('scaffold.index_blog_body_field');
if ($field !== null) {
$this->deprecatedScaffoldKeyNotice(
'scaffold.index_blog_body_field',
Expand All @@ -135,7 +132,7 @@ protected function _getIndexImageField()
{
$action = $this->_action();

$field = $action->config('scaffold.index_image_field');
$field = $action->getConfig('scaffold.index_image_field');
if (empty($field)) {
$field = 'image';
}
Expand All @@ -152,7 +149,7 @@ protected function _getIndexGalleryCssClasses()
{
$action = $this->_action();

$field = $action->config('scaffold.index_gallery_css_classes');
$field = $action->getConfig('scaffold.index_gallery_css_classes');
if (empty($field)) {
$field = 'col-sm-6 col-md-3';
}
Expand Down
9 changes: 3 additions & 6 deletions src/Listener/Traits/SidebarNavigationTrait.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?php
namespace CrudView\Listener\Traits;

use Cake\Event\Event;

trait SidebarNavigationTrait
{
/**
* beforeRender event
*
* @param \Cake\Event\Event $event Event.
* @return void
*/
public function beforeRenderSidebarNavigation(Event $event)
public function beforeRenderSidebarNavigation()
{
$controller = $this->_controller();
$sidebarNavigation = $this->_getSidebarNavigation();
Expand All @@ -29,11 +26,11 @@ protected function _getSidebarNavigation()
$action = $this->_action();

// deprecated check
if ($action->config('scaffold.disable_sidebar')) {
if ($action->getConfig('scaffold.disable_sidebar')) {
return false;
}

return $action->config('scaffold.sidebar_navigation');
return $action->getConfig('scaffold.sidebar_navigation');
}

/**
Expand Down
12 changes: 5 additions & 7 deletions src/Listener/Traits/SiteTitleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
namespace CrudView\Listener\Traits;

use Cake\Core\Configure;
use Cake\Event\Event;

trait SiteTitleTrait
{
/**
* beforeRender event
*
* @param \Cake\Event\Event $event Event.
* @return void
*/
public function beforeRenderSiteTitle(Event $event)
public function beforeRenderSiteTitle()
{
$controller = $this->_controller();

Expand All @@ -34,7 +32,7 @@ protected function _getSiteTitle()
{
$action = $this->_action();

$title = $action->config('scaffold.site_title');
$title = $action->getConfig('scaffold.site_title');
if (!empty($title)) {
return $title;
}
Expand All @@ -45,7 +43,7 @@ protected function _getSiteTitle()
}

// deprecated
$title = $action->config('scaffold.brand');
$title = $action->getConfig('scaffold.brand');
if (!empty($title)) {
return $title;
}
Expand All @@ -62,7 +60,7 @@ protected function _getSiteTitleLink()
{
$action = $this->_action();

$link = $action->config('scaffold.site_title_link');
$link = $action->getConfig('scaffold.site_title_link');
if (empty($link)) {
$link = '';
}
Expand All @@ -79,7 +77,7 @@ protected function _getSiteTitleImage()
{
$action = $this->_action();

$image = $action->config('scaffold.site_title_image');
$image = $action->getConfig('scaffold.site_title_image');
if (empty($image)) {
$image = '';
}
Expand Down
6 changes: 2 additions & 4 deletions src/Listener/Traits/UtilityNavigationTrait.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<?php
namespace CrudView\Listener\Traits;

use Cake\Event\Event;
use CrudView\Menu\MenuItem;

trait UtilityNavigationTrait
{
/**
* beforeRender event
*
* @param \Cake\Event\Event $event Event.
* @return void
*/
public function beforeRenderUtilityNavigation(Event $event)
public function beforeRenderUtilityNavigation()
{
$controller = $this->_controller();
$controller->set('utilityNavigation', $this->_getUtilityNavigation());
Expand All @@ -27,7 +25,7 @@ protected function _getUtilityNavigation()
{
$action = $this->_action();

$utilityNavigation = $action->config('scaffold.utility_navigation');
$utilityNavigation = $action->getConfig('scaffold.utility_navigation');
if ($utilityNavigation === null) {
$utilityNavigation = [
new MenuItem('Account', ['controller' => 'Users', 'action' => 'account']),
Expand Down
Loading

0 comments on commit 8723c8c

Please sign in to comment.