{#
/**
 * Controller bake template file
 *
 * Allows templating of Controllers generated from bake.
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @since         2.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */
#}
{{ element('Bake.file_header', {
    namespace: "#{namespace}\\Controller#{prefix}",
    classImports: (plugin or prefix) ? ["#{baseNamespace}\\Controller\\AppController"] : [],
}) }}

/**
 * {{ name }} Controller
 *
{% if defaultModel %}
 * @property \{{ defaultModel }} ${{ name }}
{% endif %}

{%- for component in components %}
{% set classInfo = Bake.classInfo(component, 'Controller/Component', 'Component') %}
 * @property {{ classInfo.fqn }} ${{ classInfo.name }}
{% endfor %}

{%- if 'index' in actions %}
 * @method \{{ namespace }}\Model\Entity\{{ entityClassName }}[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
{% endif %}
 */
class {{ name }}Controller extends AppController
{
{% if components or helpers %}
    /**
     * Initialize controller
     *
     * @return void
     */
    public function initialize(): void
    {
        parent::initialize();

{% for component in components %}
        $this->loadComponent('{{ component }}');
{% endfor %}
{% if helpers %}
        $this->viewBuilder()->setHelpers({{ Bake.exportArray(helpers)|raw }});
{% endif %}
    }
{% if actions|length %}{{ "\n" }}{% endif %}
{% endif %}
{%- for action in actions %}
{% if loop.index > 1 %}{{ "\n" }}{% endif %}
    {{- element('Bake.Controller/' ~ action) -}}
{% endfor %}
}
