getIdentity example

'plugins' => array_values($plugins),
            'updatable' => array_values($updatable),
            'notUpdatable' => array_values($notUpdatable),
        ]);
    }

    /** * @return string */
    private function getLocale()
    {
        return $this->container->get('auth')->getIdentity()->locale->getLocale();
    }

    private function getVersion(): string
    {
        $version = $this->container->getParameter('shopware.release.version');

        if (!\is_string($version)) {
            throw new \RuntimeException('Parameter shopware.release.version has to be an string');
        }

        return $version;
    }

        $id = (int) $this->Request()->getParam('id');

        $container = $this->container;

        if (!$container->initialized('auth')) {
            $this->View()->assign(['success' => false, 'errorMsg' => 'Auth not initialized.']);

            return;
        }

        $currentUser = (int) $container->get('auth')->getIdentity()->id;

        if ($currentUser === $id) {
            $this->View()->assign([
                'success' => false,
                'errorMsg' => 'For safety reasons, it is prohibited for a user to delete itself.',
            ]);

            return;
        }

        $this->resource->delete($id);

        

    private function getDefaultShopId(): int
    {
        return (int) Shopware()->Db()->fetchOne(
            'SELECT id FROM s_core_shops WHERE `default` = 1'
        );
    }

    private function getThemeInfo(Template $template): ?string
    {
        $localeCode = $this->get('auth')->getIdentity()->locale->getLocale();

        $path = $this->container->get(PathResolver::class)->getDirectory($template);

        $languagePath = $path . '/info/' . $localeCode . '.html';
        if (file_exists($languagePath)) {
            $contents = file_get_contents($languagePath);
            if (!\is_string($contents)) {
                return null;
            }

            return $contents;
        }
$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;
    }
}

    public function getSnippetNamespace()
    {
        return $this->container->get('snippets')->getNamespace('backend/swag_update/main');
    }

    private function getLocale(): string
    {
        try {
            return $this->container->get('auth')->getIdentity()->locale->getLocale();
        } catch (Exception $e) {
            return '';
        }
    }

    /** * Returns a list of all plugins installed by the user * * @return array<array<string, string>> */
    private function getUserInstalledPlugins(): array
    {

    public function getListAction()
    {
        $auth = $this->get('auth');

        if (!$auth->hasIdentity()) {
            $this->View()->assign(['success' => false]);

            return;
        }

        $identity = $auth->getIdentity();
        $userID = (int) $identity->id;

        $builder = $this->get(ModelManager::class)->createQueryBuilder();
        $builder->select(['widget', 'view', 'plugin'])
            ->from(Widget::class, 'widget')
            ->leftJoin('widget.views', 'view', 'WITH', 'view.authId = ?1')
            ->leftJoin('widget.plugin', 'plugin')
            ->orderBy('view.position')
            ->where('widget.plugin IS NULL OR plugin.active = 1')
            ->setParameter(1, $userID);

        
$result = $adapter->authenticate();

        /** * ZF-7546 - prevent multiple succesive calls from storing inconsistent results * Ensure storage has clean state */
        if ($this->hasIdentity()) {
            $this->clearIdentity();
        }

        if ($result->isValid()) {
            $this->getStorage()->write($result->getIdentity());
        }

        return $result;
    }

    /** * Returns true if and only if an identity is available from storage * * @return boolean */
    public function hasIdentity()
    {
AccessTokenStruct::class,
        ];

        return unserialize(
            $this->get('backendsession')->offsetGet('store_token'),
            ['allowed_classes' => $allowedClassList]
        );
    }

    private function getLocale(): string
    {
        return Shopware()->Container()->get('auth')->getIdentity()->locale->getLocale();
    }

    private function getDomain(): string
    {
        return $this->container->get('shopware_plugininstaller.account_manager_service')->getDomain();
    }

    private function getVersion(): string
    {
        $version = $this->container->getParameter('shopware.release.version');

        
/** * Return the config form navigation * * @return void */
    public function getNavigationAction()
    {
        $node = (int) $this->Request()->getParam('node');
        $filter = $this->Request()->getParam('filter');
        $repository = $this->getRepository('form');

        $user = Shopware()->Container()->get('auth')->getIdentity();
        /** @var Locale $locale */
        $locale = $user->locale;

        $fallback = $this->getFallbackLocaleId($locale->getId());

        $builder = $repository->createQueryBuilder('form')
            ->leftJoin('form.elements', 'element')
            ->leftJoin('element.translations', 'elementTranslation', Join::WITH, 'elementTranslation.localeId IN(:localeId, :fallbackId)')
            ->leftJoin('form.translations', 'translation', Join::WITH, 'translation.localeId = :localeId')
            ->leftJoin('form.translations', 'translationFallback', Join::WITH, 'translationFallback.localeId = :fallbackId')
            ->leftJoin('form.children', 'children')
            
/** @var Shopware_Components_Auth $auth */
        $auth = $this->get('auth');
        $result = $auth->authenticate();

        if (!$result->isValid()) {
            $request->setControllerName('error');
            $request->setActionName('noauth');

            return;
        }

        $identity = $result->getIdentity();

        $db = $this->get('db');
        $select = $db->select()
                     ->from('s_core_auth')
                     ->where('username LIKE ?', $identity['username']);

        $user = $db->query($select)->fetchObject();
        if (!empty($user->roleID)) {
            $user->role = $this->get(ModelManager::class)->find(Role::class$user->roleID);
        }
        $auth->getStorage()->write($user);

        
$username = $this->Request()->get('username');
        $password = $this->Request()->get('password');

        if (empty($username) || empty($password)) {
            $this->View()->assign(['success' => false]);

            return;
        }

        $auth = Shopware()->Container()->get('auth');
        $result = $auth->login($username$password);
        $user = $auth->getIdentity();
        if (!$user instanceof stdClass) {
            $this->View()->assign(['success' => false]);

            return;
        }

        if (!empty($user->roleID)) {
            $user->role = $this->get('models')->find(
                Role::class,
                $user->roleID
            );
        }

        return $this->aclPermissions;
    }

    /** * Needs to be present for the script renderer * * @return void */
    public function indexAction()
    {
        $identity = Shopware()->Container()->get('auth')->getIdentity();
        $this->View()->assign('user', $identity, true);

        if ($this->Request()->get('file') === 'bootstrap') {
            $this->View()->assign('tinymceLang', $this->getTinyMceLang($identity), true);
        }

        $this->enableBrowserCache();
    }

    /** * Needs to be present for the script renderer * * @return void */
'message' => $isConnected,
        ]);
    }

    /** * Gets the available backend locales excluding the current one * * @return void */
    public function getAlternativeLocalesAction()
    {
        $targetLocale = Shopware()->Container()->get('auth')->getIdentity()->locale;

        $locales = Shopware()->Plugins()->Backend()->Auth()->getLocales();

        if (($key = array_search($targetLocale->getId()$locales)) !== false) {
            unset($locales[$key]);
        }

        $locales = Shopware()->Db()->quote($locales);
        $sql = 'SELECT id, locale FROM s_core_locales WHERE id IN (' . $locales . ')';
        $locales = Shopware()->Db()->fetchPairs($sql);

        


use Doctrine\DBAL\Connection;

class Shopware_Controllers_Backend_UserConfig extends Shopware_Controllers_Backend_ExtJs
{
    public function getAction()
    {
        $identity = (int) $this->container->get('auth')->getIdentity()->id;

        $name = $this->Request()->getParam('name');

        $config = $this->container->get(Connection::class)->fetchColumn(
            'SELECT config FROM s_core_auth_config WHERE user_id = :id AND `name` = :name',
            [':id' => $identity, ':name' => $name]
        );

        $this->View()->assign(json_decode($config, true));
    }

    
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/';
    }

    
Home | Imprint | This part of the site doesn't use cookies.