Skip to content

Commit d7a6458

Browse files
authored
Merge pull request #15 from kaz29/fix/template
update bake templates
2 parents 695c06d + d389911 commit d7a6458

36 files changed

+520
-398
lines changed

templates/bake/Command/command.twig

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{#
22
/**
3-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
55
*
66
* Licensed under The MIT License
77
* For full copyright and license information, please see the LICENSE.txt
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11-
* @link http://cakephp.org CakePHP(tm) Project
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
1212
* @since 1.7.4
13-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1414
*/
1515
#}
16-
<?php
17-
declare(strict_types=1);
18-
19-
namespace {{ namespace }}\Command;
20-
21-
use Cake\Command\Command;
22-
use Cake\Console\Arguments;
23-
use Cake\Console\ConsoleIo;
24-
use Cake\Console\ConsoleOptionParser;
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Command",
18+
classImports: [
19+
'Cake\\Command\\Command',
20+
'Cake\\Console\\Arguments',
21+
'Cake\\Console\\ConsoleIo',
22+
'Cake\\Console\\ConsoleOptionParser',
23+
],
24+
}) }}
2525

2626
/**
2727
* {{ name }} command.
@@ -47,7 +47,7 @@ class {{ name }}Command extends Command
4747
*
4848
* @param \Cake\Console\Arguments $args The command arguments.
4949
* @param \Cake\Console\ConsoleIo $io The console io
50-
* @return null|void|int The exit code or null for success
50+
* @return int|null|void The exit code or null for success
5151
*/
5252
public function execute(Arguments $args, ConsoleIo $io)
5353
{

templates/bake/Command/helper.twig

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{#
2+
/**
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5+
*
6+
* Licensed under The MIT License
7+
* For full copyright and license information, please see the LICENSE.txt
8+
* Redistributions of files must retain the above copyright notice.
9+
*
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
12+
* @since 2.6.0
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
14+
*/
15+
#}
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Command\\Helper",
18+
classImports: [
19+
'Cake\\Console\\Helper',
20+
],
21+
}) }}
22+
23+
/**
24+
* {{ name }} command helper.
25+
*/
26+
class {{ name }}Helper extends Helper
27+
{
28+
/**
29+
* This method should output content using `$this->_io`.
30+
*
31+
* @param array $args The arguments for the helper.
32+
* @return void
33+
*/
34+
public function output(array $args): void
35+
{
36+
}
37+
}
+14-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{#
22
/**
3-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
55
*
66
* Licensed under The MIT License
77
* For full copyright and license information, please see the LICENSE.txt
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11-
* @link http://cakephp.org CakePHP(tm) Project
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
1212
* @since 2.0.0
13-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1414
*/
1515
#}
16-
<?php
17-
declare(strict_types=1);
18-
19-
namespace {{ namespace }}\Controller\Component;
20-
21-
use Cake\Controller\Component;
22-
use Cake\Controller\ComponentRegistry;
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Controller\\Component",
18+
classImports: [
19+
'Cake\\Controller\\Component',
20+
'Cake\\Controller\\ComponentRegistry',
21+
],
22+
}) }}
2323

2424
/**
2525
* {{ name }} component
@@ -29,7 +29,7 @@ class {{ name }}Component extends Component
2929
/**
3030
* Default configuration.
3131
*
32-
* @var array
32+
* @var array<string, mixed>
3333
*/
34-
protected $_defaultConfig = [];
34+
protected array $_defaultConfig = [];
3535
}

templates/bake/Controller/controller.twig

+10-21
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,23 @@
44
*
55
* Allows templating of Controllers generated from bake.
66
*
7-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
8+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
99
*
1010
* Licensed under The MIT License
1111
* For full copyright and license information, please see the LICENSE.txt
1212
* Redistributions of files must retain the above copyright notice.
1313
*
14-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
15-
* @link http://cakephp.org CakePHP(tm) Project
14+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
15+
* @link https://cakephp.org CakePHP(tm) Project
1616
* @since 2.0.0
17-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
17+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1818
*/
1919
#}
20-
<?php
21-
declare(strict_types=1);
22-
23-
namespace {{ namespace }}\Controller{{ prefix }};
24-
25-
{% if plugin or prefix %}
26-
use {{ baseNamespace }}\Controller\AppController;
27-
{% endif %}
28-
use Cake\Event\Event;
29-
use Cake\Http\Exception\MethodNotAllowedException;
30-
use OpenApi\Attributes as OA;
20+
{{ element('Bake.file_header', {
21+
namespace: "#{namespace}\\Controller#{prefix}",
22+
classImports: (plugin or prefix) ? ["#{baseNamespace}\\Controller\\AppController"] : [],
23+
}) }}
3124

3225
/**
3326
* {{ name }} Controller
@@ -40,10 +33,6 @@ use OpenApi\Attributes as OA;
4033
{% set classInfo = Bake.classInfo(component, 'Controller/Component', 'Component') %}
4134
* @property {{ classInfo.fqn }} ${{ classInfo.name }}
4235
{% endfor %}
43-
44-
{%- if 'index' in actions %}
45-
* @method \{{ namespace }}\Model\Entity\{{ entityClassName }}[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
46-
{% endif %}
4736
*/
4837
class {{ name }}Controller extends AppController
4938
{
@@ -61,7 +50,7 @@ class {{ name }}Controller extends AppController
6150
$this->loadComponent('{{ component }}');
6251
{% endfor %}
6352
{% if helpers %}
64-
$this->viewBuilder()->setHelpers([{{ Bake.stringifyList(helpers, {'indent': false})|raw }}]);
53+
$this->viewBuilder()->setHelpers({{ Bake.exportArray(helpers)|raw }});
6554
{% endif %}
6655
}
6756
{% if actions|length %}{{ "\n" }}{% endif %}

templates/bake/Form/form.twig

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
{#
22
/**
3-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
55
*
66
* Licensed under The MIT License
77
* For full copyright and license information, please see the LICENSE.txt
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11-
* @link http://cakephp.org CakePHP(tm) Project
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
1212
* @since 2.0.0
13-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1414
*/
1515
#}
16-
<?php
17-
declare(strict_types=1);
18-
19-
namespace {{ namespace }}\Form;
20-
21-
use Cake\Form\Form;
22-
use Cake\Form\Schema;
23-
use Cake\Validation\Validator;
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Form",
18+
classImports: [
19+
'Cake\\Form\\Form',
20+
'Cake\\Form\\Schema',
21+
'Cake\\Validation\\Validator',
22+
],
23+
}) }}
2424

2525
/**
2626
* {{ name }} Form.

templates/bake/Mailer/mailer.twig

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{#
22
/**
3-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
55
*
66
* Licensed under The MIT License
77
* For full copyright and license information, please see the LICENSE.txt
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11-
* @link http://cakephp.org CakePHP(tm) Project
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
1212
* @since 2.0.0
13-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1414
*/
1515
#}
16-
<?php
17-
declare(strict_types=1);
18-
19-
namespace {{ namespace }}\Mailer;
20-
21-
use Cake\Mailer\Mailer;
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Mailer",
18+
classImports: [
19+
'Cake\\Mailer\\Mailer',
20+
],
21+
}) }}
2222

2323
/**
2424
* {{ name }} mailer.
@@ -30,5 +30,5 @@ class {{ name }}Mailer extends Mailer
3030
*
3131
* @var string
3232
*/
33-
public static $name = '{{ name }}';
33+
public static string $name = '{{ name }}';
3434
}

templates/bake/Middleware/middleware.twig

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
{#
22
/**
3-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
55
*
66
* Licensed under The MIT License
77
* For full copyright and license information, please see the LICENSE.txt
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11-
* @link http://cakephp.org CakePHP(tm) Project
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
1212
* @since 2.0.0
13-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1414
*/
1515
#}
16-
<?php
17-
declare(strict_types=1);
18-
19-
namespace {{namespace }}\Middleware;
20-
21-
use Psr\Http\Message\ResponseInterface;
22-
use Psr\Http\Message\ServerRequestInterface;
23-
use Psr\Http\Server\MiddlewareInterface;
24-
use Psr\Http\Server\RequestHandlerInterface;
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Middleware",
18+
classImports: [
19+
'Psr\\Http\\Message\\ResponseInterface',
20+
'Psr\\Http\\Message\\ServerRequestInterface',
21+
'Psr\\Http\\Server\\MiddlewareInterface',
22+
'Psr\\Http\\Server\\RequestHandlerInterface',
23+
],
24+
}) }}
2525

2626
/**
2727
* {{ name }} middleware

templates/bake/Model/behavior.twig

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{#
22
/**
3-
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4-
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
3+
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4+
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
55
*
66
* Licensed under The MIT License
77
* For full copyright and license information, please see the LICENSE.txt
88
* Redistributions of files must retain the above copyright notice.
99
*
10-
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11-
* @link http://cakephp.org CakePHP(tm) Project
10+
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11+
* @link https://cakephp.org CakePHP(tm) Project
1212
* @since 2.0.0
13-
* @license http://www.opensource.org/licenses/mit-license.php MIT License
13+
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1414
*/
1515
#}
16-
<?php
17-
declare(strict_types=1);
18-
19-
namespace {{ namespace }}\Model\Behavior;
20-
21-
use Cake\ORM\Behavior;
22-
use Cake\ORM\Table;
16+
{{ element('Bake.file_header', {
17+
namespace: "#{namespace}\\Model\\Behavior",
18+
classImports: [
19+
'Cake\\ORM\\Behavior',
20+
'Cake\\ORM\\Table',
21+
],
22+
}) }}
2323

2424
/**
2525
* {{ name }} behavior
@@ -29,7 +29,7 @@ class {{ name }}Behavior extends Behavior
2929
/**
3030
* Default configuration.
3131
*
32-
* @var array
32+
* @var array<string, mixed>
3333
*/
34-
protected $_defaultConfig = [];
34+
protected array $_defaultConfig = [];
3535
}

0 commit comments

Comments
 (0)