Page 1 of 1

Adding a Configuration Options without default Options

Posted: 02 Nov 2019, 13:50
by tenkraD
Hello all,

Im searching a better way to do this, maybe you guys can help me.
I wrote a new subpart which has it's own data Domain.

Then i wrote the jsonadm files for it and register these files for my new data Domain under Admin Config File from my extension.

Code: Select all

return[
		....
		'jsonadm' => [
				/**
				 * admin/jsonadm/domains
				 * A list of domain names whose clients are available for the JSON API
				 */
				'domains' => [
						/* DEFAULT DOMAINS */
						'attribute', 'catalog', 'coupon', 'customer', 'locale', 'media', 'order',
						'plugin', 'price', 'product', 'service', 'supplier', 'stock', 'tag', 'text',
						/* MY NEW DOMAIN */
						'mynewdatadomain'
				],
				
				/**
				 * 	admin/jsonadm/resources
		 		 *  A list of additional resources name whose clients are available for the JSON API
				 */
				'resources' => [
						/* DEFAULT Additional RESOURCE */
						'coupon/config', 'plugin/config', 'service/config',	
						/* MY NEW Additional RESOURCE */
						 'mynewdatadomain/config',
				],
				....
]
This is working fine via config, but i have to rewrite the default domains and resources.
Means if i update the aimeos lib and you change the default domains im running into an error.

The default domains and ressources, i've found under jsonadm/src/Admin/JsonAdm/Base.php getDomains() and getResources(). These are protected functions which i can't override in my jsonadm child class to dinamically add mynewdatadomain.

Therefore i've done it with the config file but im not really happy with it.
Do you know how i can do it better?

PS: i found nothing in the documentations about admin/jsonadm/domains & admin/jsonadm/resources, maybe i dont found it but i believe its not documented.

Many thanks,
tenkraD

Re: Adding a Configuration Options without default Options

Posted: 06 Nov 2019, 13:29
by aimeos
You can add the required configuration in your own extension (./config/admin.php) by using:

Code: Select all

return [
    'jsonadm' => [
        'domains' => [
            'mynewdatadomain' => 'mynewdatadomain'
        ],
        'resources' => [
            'mynewdatadomain/config' => 'mynewdatadomain/config'
        ],
    ],
];
This adds your domain and resource only without overwriting the existing ones.

You are right, there's currently no documentation for that.

Re: Adding a Configuration Options without default Options

Posted: 06 Nov 2019, 14:54
by tenkraD
nope sorry you are wrong, this doesn't work for ressources and domains.

The additional resources 'coupon/config', 'plugin/config', 'service/config', are not setted if i only add

Code: Select all

 ...	
 				'resources' => [
						"mynewdatadomain/config"
				],
And the default domains are not setted if i only write

Code: Select all

	...
				'domains' => [
						'mynewdatadomain',
				],
in my config.

Re: Adding a Configuration Options without default Options

Posted: 07 Nov 2019, 08:51
by aimeos
It will work now if you use aimeos/ai-admin-jsonadm 2019.10.x-dev

But remember that the keys must be unique (non-integer) to add configuration only!

Code: Select all

return [
    'jsonadm' => [
        'domains' => [
            'mynewdatadomain' => 'mynewdatadomain'
        ],
        'resources' => [
            'mynewdatadomain/config' => 'mynewdatadomain/config'
        ],
    ],
];

Re: Adding a Configuration Options without default Options

Posted: 07 Nov 2019, 09:41
by tenkraD
Moved domains and resource configuration to config file - thanks for that!

Greets tenkraD

Re: Adding a Configuration Options without default Options

Posted: 29 Nov 2019, 14:04
by tenkraD
aimeos wrote: 07 Nov 2019, 08:51 It will work now if you use aimeos/ai-admin-jsonadm 2019.10.x-dev
Hello Admin,

I am using an old aimeos distribution so i can't check if these configurations are set correct in 2019.10.x Version.

In https://github.com/aimeos/ai-admin-json ... /admin.php you are setting template files without the extension "php". In my version it was neccesarry to set the file extension for template files.

Code: Select all

return [
		'jsonadm' => [
				'partials' => [
						'catalog' => [
								'template-data' => 'partials/catalog/data-standard.php',
						],
....
Bye tenkraD

Re: Adding a Configuration Options without default Options

Posted: 11 Dec 2019, 14:34
by tenkraD
https://github.com/aimeos/ai-client-jso ... d.php#L104

Same behavior for jsonapi.
Would be great if you can add domains and ressources without default one's by config, since the config option "client/jsonapi/resources" exist.

Greets tenkraD

Re: Adding a Configuration Options without default Options

Posted: 12 Dec 2019, 14:30
by aimeos
OK, the default config is now in the config file (master and 2019.10.x-dev):
https://github.com/aimeos/ai-client-jso ... 903d46dc2e

Re: Adding a Configuration Options without default Options

Posted: 12 Dec 2019, 19:28
by tenkraD
As usually, thanks for your fast support and your great work.
Hail to opensource!

Thanks tenkraD