setAcl example

 catch (ServiceNotFoundException $e) {
            $name = ucfirst($name);
            /** @var class-string<self> $class */
            $class = __NAMESPACE__ . '\\Resource\\' . $name;

            $resource = new $class();
        }

        $resource->setManager($this->getManager());

        if ($this->getAcl() !== null) {
            $resource->setAcl($this->getAcl());
        }

        if ($this->getRole() !== null) {
            $resource->setRole($this->getRole());
        }

        return $resource;
    }

    /** * Helper function which checks the option configuration for the passed collection. * * If the data property contains the "__options_$optionName" value and this value contains * the "replace" parameter, the collection will be cleared. * * @template TEntity of ModelEntity * * @param ArrayCollection<array-key, TEntity> $collection * @param array<array-key, array<string, mixed>> $data * @param string $optionName * @param bool $defaultReplace * * @return ArrayCollection<array-key, TEntity> */

    protected $apiBaseUrl;

    /** * @var AbstractResource */
    protected $resource;

    public function preDispatch()
    {
        if (($this->resource instanceof AbstractResource) && $this->container->initialized('auth')) {
            $this->resource->setAcl($this->container->get('acl'));
            $this->resource->setRole($this->container->get('auth')->getIdentity()->role);
        }

        $this->Front()->Plugins()->ViewRenderer()->setNoRender();

        $this->apiBaseUrl = $this->Request()->getScheme()
           . '://'
           . $this->Request()->getHttpHost()
           . $this->Request()->getBaseUrl()
           . '/api/';
    }

    
$name = ucfirst($name);
            $class = __NAMESPACE__ . '\\Resource\\' . $name;

            /** @var Resource\Resource $resource */
            $resource = new $class();

            $resource->setContainer($container);
            $resource->setManager($container->get(\Shopware\Components\Model\ModelManager::class));
        }

        if ($container->initialized('auth')) {
            $resource->setAcl($container->get('acl'));
            $resource->setRole($container->get('auth')->getIdentity()->role);
        }

        return $resource;
    }
}
Home | Imprint | This part of the site doesn't use cookies.