Pass params to service from controller

Hello there,

I think I have a fundamental problem with understanding how to call a service from a different controller.

My bundle uses an Installer and during the installation I want to pass some params to other pimcore services/controllers to install user roles, thumbnails and so on.

With the symfony profiler i found out, that the following controller route is called after creating a new user in the backend: /admin/user/add which resolves to the following controller/action:


The method looks like this:

public function addAction(Request $request)
    try {
        $type = $request->get('type');

        $className = User\Service::getClassNameForType($type);
        $user = $className::create([
            'parentId' => intval($request->get('parentId')),
            'name' => trim($request->get('name')),
            'password' => '',
            'active' => $request->get('active')
// shorten for readability ....

So my problems are the following:
1. How can i call this (or any other) method with my given params? By route or by directly calling the Controller? What about the Request object?
2. Because the argument of the addAction() is a Type of Request i can’t just pass an array to it, do i need to create a new Request with new Request() if so, what arguments do I need to pass through?

My Installer.php

class Installer extends AbstractInstaller

     * @inheritDoc
    public function install()

    public function installUserRoles()
        // assume this is filled with settings about the user
        $params = [...];
       // how can i call it correctly?
      Pimcore\Bundle\AdminBundle\Controller\Admin\UserController::addAction($params) // not working..

I read about $this->forward() in the Symfony docs but that still results in the Problem that the argument needed is a Request object.

Kind of clueless now :frowning:

Why do you want to call Actions on installation? Use the Pimcore API to create those models or directly insert it into the database.

Its not a question about WHY i want to call an action. I’m new to pimcore 6 and try to get my head around it. What i want is to install/add thumbnails/users and other stuff when i activate my bundle. And because there is not a good enough explanation in the pimcore documentation on how to achieve this, i came up with this idea without knowing if its good or not. And besides that, i read the Pimcore API documentation but couldn’t make use of it or rather i don’t understand how and where i use/call it.

But i found a solution… Actually it is derived from your own PimcoreImageThumbnailsInstaller from CoreShop. Because you actually doing exactly what i want. During Installation you install Thumbnails with the Pimcore\Model\Asset\Image\Thumbnail\Config Class and thats what i will try next. At least for the thumbnails stuff. For Users its similar by using the Pimcore\Model\User class.

Good, you can use the service directly by requiring the ResourceBundle, thats what I made it for actually