Adding a Configuration Options without default Options

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Adding a Configuration Options without default Options

Post by tenkraD » 02 Nov 2019, 13:50

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

User avatar
aimeos
Administrator
Posts: 8262
Joined: 01 Jan 1970, 00:00

Re: Adding a Configuration Options without default Options

Post by aimeos » 06 Nov 2019, 13:29

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.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: Adding a Configuration Options without default Options

Post by tenkraD » 06 Nov 2019, 14:54

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.

User avatar
aimeos
Administrator
Posts: 8262
Joined: 01 Jan 1970, 00:00

Re: Adding a Configuration Options without default Options

Post by aimeos » 07 Nov 2019, 08:51

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'
        ],
    ],
];
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: Adding a Configuration Options without default Options

Post by tenkraD » 07 Nov 2019, 09:41

Moved domains and resource configuration to config file - thanks for that!

Greets tenkraD

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: Adding a Configuration Options without default Options

Post by tenkraD » 29 Nov 2019, 14:04

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

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: Adding a Configuration Options without default Options

Post by tenkraD » 11 Dec 2019, 14:34

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

User avatar
aimeos
Administrator
Posts: 8262
Joined: 01 Jan 1970, 00:00

Re: Adding a Configuration Options without default Options

Post by aimeos » 12 Dec 2019, 14:30

OK, the default config is now in the config file (master and 2019.10.x-dev):
https://github.com/aimeos/ai-client-jso ... 903d46dc2e
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

tenkraD
Advanced
Posts: 110
Joined: 25 Jul 2017, 08:38

Re: Adding a Configuration Options without default Options

Post by tenkraD » 12 Dec 2019, 19:28

As usually, thanks for your fast support and your great work.
Hail to opensource!

Thanks tenkraD

Post Reply