Change bake table className for users

I want to change the bake template for table when the className = Users I want className to be ‘className’ => Configure::read(‘Users.table’), and then add also use Cake\Core\Configure; to the top.

Anyone know how to edit the table.twig?

You can create a custom bake theme like explained here

My question a bit more specific then that…

This is what is in table.twig

{%- if associations.belongsTo or associations.hasMany or associations.belongsToMany %}

{% endif %}

{%- for type, assocs in associations %}
    {%- for assoc in assocs %}
        {%- set assocData = [] %}
        {%- for key, val in assoc %}
            {%- if key is not same as('alias') %}
                {%- set assocData = assocData|merge({(key): val}) %}
            {%- endif %}
        {%- endfor %}
        $this->{{ type }}('{{ assoc.alias }}', {{ Bake.exportArray(assocData, 2)|raw }});
        {{- "\n" }}
    {%- endfor %}
{% endfor %}
{{- "\n" }}

I got something like this, but that doesnt work for the Configure::read part, if i just write 'Someclass its ok… how to get Configure::read there?

{% if key == ‘className’ and val == ‘Myplugin.Users’ %}
{% set val = Configure::read(‘Users.table’) %}
{% endif %}

I am not really sure what you are trying to achieve with this Users.table config value.
Do you have multiple table classes for the same table? Because the className in the association config only needs to be set when the association name is not the same as the class name (without the Table suffix)

That can’t work. You are inside twig, not PHP.

I want it to print Configure::read(… in the baked file… exactly. Not actualy looking up the value in the template.

then just write it as is without any twig syntax,
so like

$myVarInGeneratedTemplate = Configure::read(‘Users.table’);

and not

{% set val = Configure::read(‘Users.table’) %}

Its like writing html in PHP outside of the <?php ?> tags.

Also you technically don’t need the use statement if you just use the FQCN like so

$myVarInGeneratedTemplate = \Cake\Core\Configure::read(‘Users.table’)

{% set val = ‘Mytable’ %}

like this it will show ‘className’ => ‘Mytable’

I want ‘className’ => Configure::Read(‘Users.table’)

i see what you are trying to achieve. I am not really sure this can be done with the underlying GitHub - brick/varexporter: A powerful alternative to var_export(), which can export closures and objects without __set_state() we are using here via Bake.exportArray(assocData, 2)

yeah thats what i was looking at also here

guess ill need to change it manually each time I bake it…

How often are you baking this one table class? I bake things to get started, and then just work with them after that.