Skip to content

Commit

Permalink
Merge pull request #282 from FriendsOfCake/cake-4.x
Browse files Browse the repository at this point in the history
Cake 4.x
  • Loading branch information
ADmad authored Sep 23, 2020
2 parents 7500143 + 9808ba4 commit d7b7a63
Show file tree
Hide file tree
Showing 122 changed files with 1,361 additions and 953 deletions.
8 changes: 3 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ insert_final_newline = true
trim_trailing_whitespace = true

[*.yml]
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

[*.neon]
indent_style = tab
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ docs export-ignore
.github export-ignore
.coveralls.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
phpstan-baseline.neon export-ignore
psalm.xml export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ phpunit.xml
vendor/
composer.lock
tmp
.phpunit.result.cache
4 changes: 2 additions & 2 deletions .stickler.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
linters:
phpcs:
standard: CakePHP
extensions: 'php,ctp'
standard: CakePHP4
extensions: 'php'
fixer: true

fixers:
Expand Down
27 changes: 13 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: php

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

env:
global:
Expand All @@ -15,33 +14,33 @@ matrix:
fast_finish: true

include:
- php: 7.0
- php: 7.2
env: PHPCS=1 DEFAULT=0

- php: 7.0
env: PHPSTAN=1 DEFAULT=0
- php: 7.2
env: STATIC_ANALYSIS=1 DEFAULT=0

- php: 7.2
env: DEFAULT=1 LOWEST=1

before_script:
- if [[ $TRAVIS_PHP_VERSION != 7.0 ]]; then phpenv config-rm xdebug.ini; fi
- if [[ $TRAVIS_PHP_VERSION != 7.3 ]]; then phpenv config-rm xdebug.ini; fi

- if [[ $LOWEST = 0 ]]; then composer install --prefer-dist --no-interaction; fi
- if [[ $LOWEST = 1 ]]; then composer update --prefer-lowest --prefer-dist --no-interaction; fi

- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:dev-master; fi
- if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan:^0.9; fi
- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:^4.2; fi
- if [[ $STATIC_ANALYSIS = 1 ]]; then composer require phpstan/phpstan:^0.12 psalm/phar:^3.7; fi

script:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.0 ]]; then vendor/bin/phpunit; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.3 ]]; then vendor/bin/phpunit; fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi

- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ config/; fi
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 5 src; fi
- if [[ $STATIC_ANALYSIS = 1 ]]; then vendor/bin/phpstan.phar analyse src && vendor/bin/psalm.phar; fi

after_success:
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.0 ]]; then bash <(curl -s https://codecov.io/bash); fi
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; then bash <(curl -s https://codecov.io/bash); fi

notifications:
email: false
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ Automated admin backend based on your [Crud](https://github.com/friendsofcake/cr

# Installation

For CakePHP 3.x:

```shell
composer require friendsofcake/crud-view
```
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
}
],
"require": {
"cakephp/cakephp": "^3.7",
"friendsofcake/crud": "^5.4",
"friendsofcake/bootstrap-ui": "^1.4"
"cakephp/cakephp": "^4.0",
"friendsofcake/crud": "^6.0",
"friendsofcake/bootstrap-ui": "^3.0"
},
"require-dev": {
"friendsofcake/cakephp-test-utilities": "^1.0",
"markstory/asset_compress": "^3.2",
"phpunit/phpunit": "^5.7.14|^6.0"
"friendsofcake/cakephp-test-utilities": "^2.0",
"markstory/asset_compress": "^4.0",
"phpunit/phpunit": "~8.5.0"
},
"autoload": {
"psr-4": {
Expand All @@ -53,5 +53,6 @@
"issues": "https://github.com/FriendsOfCake/crud-view/issues",
"wiki": "http://cakephp.nu/cakephp-crud/",
"irc": "irc://irc.freenode.org/friendsofcake"
}
},
"prefer-stable": true
}
18 changes: 9 additions & 9 deletions config/asset_compress.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[crudview.css]
files[]=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.css
files[]=https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css
files[]=https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/css/selectize.bootstrap3.min.css
files[]=https://cdn.jsdelivr.net/npm/bootstrap@^4.5/dist/css/bootstrap.min.css
files[]=https://cdn.jsdelivr.net/npm/[email protected]/dist/flatpickr.min.css
files[]=https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css
files[]=https://cdn.jsdelivr.net/npm/@ttskch/[email protected]/dist/select2-bootstrap4.css
files[]=plugin:CrudView:css/local.css

[crudview_head.js]
files[]=https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js
files[]=https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js
files[]=https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js
files[]=https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js
files[]=https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.6/js/standalone/selectize.js
files[]=https://cdn.jsdelivr.net/jquery.dirtyforms/1.2.3/jquery.dirtyforms.min.js
files[]=https://cdn.jsdelivr.net/npm/jquery@^3.4/dist/jquery.min.js
files[]=https://cdn.jsdelivr.net/npm/bootstrap@^4.5/dist/js/bootstrap.min.js
files[]=https://cdn.jsdelivr.net/npm/[email protected]
files[]=https://cdn.jsdelivr.net/npm/[email protected]
files[]=https://cdn.jsdelivr.net/npm/jquery.dirtyforms@2/jquery.dirtyforms.min.js

[crudview.js]
files[]=plugin:CrudView:js/local.js
7 changes: 5 additions & 2 deletions config/defaults.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

use Cake\Core\Plugin;

// The function `parse_ini_file` may be disabled
Expand Down Expand Up @@ -28,10 +31,10 @@
'headjs' => $assets['crudview_head.js']['files'],
'script' => $assets['crudview.js']['files'],
],
'timezoneAwareDateTimeWidget' => false,
'datetimePicker' => false,
'useAssetCompress' => Plugin::isLoaded('AssetCompress'),
'tablesBlacklist' => [
'phinxlog',
],
]
],
];
2 changes: 1 addition & 1 deletion config/forms.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$config = [
return [
'fieldset' => '{{content}}',

'formGroup' => '{{label}}<div class="col-sm-10">{{input}}{{error}}</div>',
Expand Down
4 changes: 2 additions & 2 deletions config/paginator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
$config = [
return [
'nextActive' => '<li class="next active"><a rel="next" href="{{url}}">{{text}}</a></li>',
'prevActive' => '<li class="prev active"><a rel="prev" href="{{url}}">{{text}}</a></li>'
'prevActive' => '<li class="prev active"><a rel="prev" href="{{url}}">{{text}}</a></li>',
];
2 changes: 1 addition & 1 deletion docs/_partials/fields/field-blacklist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ functionality:
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields_blacklist', ['created', 'modified']);
$action->setConfig('scaffold.fields_blacklist', ['created', 'modified']);
2 changes: 1 addition & 1 deletion docs/_partials/fields/field-settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ to specify settings for a few of the fields, you can use the
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.field_settings', [
$action->setConfig('scaffold.field_settings', [
'title' => [
// options here
]
Expand Down
6 changes: 3 additions & 3 deletions docs/_partials/fields/formatter-callable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ wanted to also display who approved the article:
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields', [
$action->setConfig('scaffold.fields', [
'title',
'published_time' => [
'formatter' => function ($name, $value, $entity) {
Expand All @@ -37,7 +37,7 @@ only configure the settings for one or two.
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.field_settings', [
$action->setConfig('scaffold.field_settings', [
'published_time' => [
'formatter' => function ($name, Time $value, Entity $entity) {
return $value->nice() . sprintf(' (Approved by %s)', $entity->approver->name);
Expand All @@ -50,7 +50,7 @@ In some cases, it may be useful to access a helper within the callable. For inst
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields', [
$action->setConfig('scaffold.fields', [
'title',
'external_id' => [
'formatter' => function ($name, $value, $entity, $options, $View) {
Expand Down
4 changes: 2 additions & 2 deletions docs/_partials/fields/formatter-element.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ to the same index action by passing some search arguments:
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields', [
$action->setConfig('scaffold.fields', [
'published_time' => [
'formatter' => 'element',
'element' => 'search/published_time',
Expand All @@ -29,7 +29,7 @@ it is just a matter of creating the element file with the right content:

.. code-block:: php
// src/Template/Element/search/published_time.ctp
// templates/element/search/published_time.ctp
echo $this->Html->link($value->timeAgoInWords(), [
'action' => $options['action'],
Expand Down
4 changes: 2 additions & 2 deletions docs/_partials/fields/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ in scope. To limit the fields used, simply specify an array of fields.
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields', ['title', 'description']);
$action->setConfig('scaffold.fields', ['title', 'description']);
You may also specify an options array. For forms, *CrudView* makes use of the
``FormHelper::inputs()`` method and will pass your array values as options when
Expand All @@ -17,7 +17,7 @@ generating the output.
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields', [
$action->setConfig('scaffold.fields', [
'title',
'thread_id' => [
'type' => 'text'
Expand Down
2 changes: 1 addition & 1 deletion docs/_partials/fields/sorting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the ``disableSort`` option:
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.fields', [
$action->setConfig('scaffold.fields', [
'title' => [
'disableSort' => true,
]
Expand Down
4 changes: 2 additions & 2 deletions docs/_partials/fields/tab-groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ configuration key:
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.form_tab_groups', [
$action->setConfig('scaffold.form_tab_groups', [
'First Tab Header' => ['field_1', 'field_2'],
'Second Tab Header' => ['field_3', 'field_4'],
]);
Expand All @@ -19,4 +19,4 @@ the primary group's name using `scaffold.form_primary_tab` config.
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.form_primary_tab', 'Key Info');
$action->setConfig('scaffold.form_primary_tab', 'Key Info');
6 changes: 3 additions & 3 deletions docs/_partials/pages/dashboard/elements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Available Elements
------------------

All the *CrudView* templates are built from several elements that can be
overridden by creating them in your own ``src/Template/Element`` folder. The
overridden by creating them in your own ``templates/element`` folder. The
following sections will list all the elements that can be overridden for each
type of action.

In general, if you want to override a template, it is a good idea to copy the
original implementation from
``vendor/friendsofcake/crud-view/src/Template/Element``
``vendor/friendsofcake/crud-view/templates/element``

action-header
Create ``src/Template/Element/action-header.ctp`` to have full control over
Create ``templates/element/action-header.ctp`` to have full control over
what is displayed at the top of the page. This is shared across all page
types.
8 changes: 4 additions & 4 deletions docs/_partials/pages/form/elements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ Available Elements
------------------

All the *CrudView* templates are built from several elements that can be
overridden by creating them in your own ``src/Template/Element`` folder. The
overridden by creating them in your own ``templates/element`` folder. The
following sections will list all the elements that can be overridden for each
type of action.

In general, if you want to override a template, it is a good idea to copy the
original implementation from
``vendor/friendsofcake/crud-view/src/Template/Element``
``vendor/friendsofcake/crud-view/templates/element``

action-header
Create ``src/Template/Element/action-header.ctp`` to have full control over
Create ``templates/element/action-header.ctp`` to have full control over
what is displayed at the top of the page. This is shared across all page
types.

form/buttons
Create ``src/Template/Element/form/buttons.ctp`` to change what is displayed
Create ``templates/element/form/buttons.ctp`` to change what is displayed
for form submission. You can expect the ``$formSubmitButtonText`` and
``$formSubmitExtraButtons`` variables to be available
2 changes: 1 addition & 1 deletion docs/_partials/pages/form/submission.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ However, you may force a user prompt by enabling dirty form checks using the
.. code-block:: php
$action = $this->Crud->action();
$action->config('scaffold.form_enable_dirty_check', true);
$action->setConfig('scaffold.form_enable_dirty_check', true);
Loading

0 comments on commit d7b7a63

Please sign in to comment.