Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rex_media_category_service und rex_media_category - wie zuvor erstellte Kategorie finden? #5463

Open
alxndr-w opened this issue Dec 30, 2022 · 1 comment
Labels
Mediapool "Mediapool"-Addon related things

Comments

@alxndr-w
Copy link
Contributor

Description / Beschreibung
Ich möchte programmatisch einen Medienpool-Kategorie erstellen, doch leider gibt mir rex_media_category_service::addCategory() nicht als Rückgabewert die Kategorie zurück.

Ich finde allerdings auch nicht die passende Medienpool-Kategorie im Anschluss, weil es nicht so etwas wie rex_media_category::getByName("name") gibt - soweit ich weiß, ist der Name auch nicht unique.

Folglich wäre es wünschenswert, wenn rex_media_category_service::addCategory() mehr als nur eine Erfolgsmeldung zurückgeben könnte, sondern das Kategorie-Objekt der neuen Kategorie.

Affected versions / Verwendete Versionen

REDAXO: 5.14
PHP: *
Database: *
Browser: *
AddOns: *

Did it whoops? / Whoops erhalten?

@gharlan gharlan added the Mediapool "Mediapool"-Addon related things label Dec 31, 2022
@gharlan
Copy link
Member

gharlan commented Jan 8, 2023

Nicht schön, aber ein Workaround:

$id = null;
rex_extension::register('MEDIA_CATEGORY_ADDED', function (rex_extension_point $ep) use (&$id) {
    $id = $ep->getParam('id');
});

rex_media_category_service::addCategory($name, $parent);

$newCat = rex_media_category::get($id);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mediapool "Mediapool"-Addon related things
Development

No branches or pull requests

2 participants