checkPrivilege example


    public function getList(
        $offset = 0,
        $limit = 25,
        array $criteria = [],
        array $orderBy = []
    ) {
        $this->checkPrivilege('read');

        /** @var Query<array<string, mixed>> $query */
        $query = $this->getListQuery($offset$limit$criteria$orderBy)->getQuery();
        $query->setHydrationMode(self::HYDRATE_ARRAY);
        $paginator = $this->getManager()->createPaginator($query);

        $translations = iterator_to_array($paginator);

        foreach ($translations as &$translation) {
            unset($translation['id']);
            $translation['data'] = $this->getTranslationComponent()->unFilterData(
                
/** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|AddressModel */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $query = $this->getRepository()->getOne($id);

        $address = $query->getOneOrNullResult($this->getResultMode());

        if (!$address) {
            throw new NotFoundException(sprintf('Address by id %d not found', $id));
        }
/** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|ManufacturerModel */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $query = $this->getRepository()->getDetailQuery($id);

        $manufacturer = $query->getOneOrNullResult($this->getResultMode());

        if (!$manufacturer) {
            throw new NotFoundException(sprintf('Manufacturer by id %d not found', $id));
        }
/** * @param int $id * * @throws \Shopware\Components\Api\Exception\ParameterMissingException * @throws \Shopware\Components\Api\Exception\NotFoundException * * @return array|\Shopware\Models\Property\Group */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ApiException\ParameterMissingException('id');
        }

        $filters = [['property' => 'groups.id', 'expression' => '=', 'value' => $id]];
        $query = $this->getRepository()->getListGroupsQuery($filters);

        /** @var \Shopware\Models\Property\Group|null $property */
        $property = $query->getOneOrNullResult($this->getResultMode());

        
/** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|ShopModel */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $builder = $this->getRepository()->createQueryBuilder('shop')
                ->select('shop', 'currency')
                ->leftJoin('shop.currency', 'currency')
                ->where('shop.id = :id')
                ->setParameter(':id', $id);

        
/** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|Detail */
    public function getOne($id, array $options = [])
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $builder = $this->getRepository()->getVariantDetailQuery();
        $builder->addSelect('article')
                ->andWhere('variants.id = :variantId')
                ->addOrderBy('variants.id', 'ASC')
                ->addOrderBy('customerGroup.id', 'ASC')
                ->addOrderBy('prices.from', 'ASC')
                
/** * @param int|null $id * @param int $offset * @param int|null $limit * @param string $conditions * @param string $sortings * * @return CustomerNumberSearchResult */
    public function getOne($id$offset = 0, $limit = 50, $conditions = '', $sortings = '')
    {
        $this->checkPrivilege('read');

        $criteria = new Criteria();

        $parsedConditions = $this->getConditions($id$conditions);

        foreach ($parsedConditions as $condition) {
            $criteria->addCondition($condition);
        }
        $decodedSortings = json_decode($sortings, true);
        if (!empty($decodedSortings)) {
            $unserializedSortings = $this->reflectionHelper->unserialize($decodedSortings, '');

            
/** * @param int $id * * @throws ParameterMissingException * @throws NotFoundException * * @return CategoryModel|array */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $query = $this->getRepository()->getDetailQueryWithoutArticles($id);

        $categoryResult = $query->getOneOrNullResult($this->getResultMode());

        if (!$categoryResult) {
            throw new NotFoundException(sprintf('Category by id %d not found', $id));
        }
/** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array|ProductModel */
    public function getOne($id, array $options = [])
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $builder = $this->getManager()->createQueryBuilder();
        $builder->select([
            'article',
            'mainDetail',
            'mainDetailPrices',
            'tax',
            

    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $filters = [['property' => 'orders.id', 'expression' => '=', 'value' => $id]];
        $order = $this->getRepository()->getOrdersQueryBuilder($filters)->getQuery()
            ->getOneOrNullResult($this->getResultMode());

        if ($order === null) {
            throw new NotFoundException(sprintf('Order by id %d not found', $id));
        }


    /** * @param string $id * * @throws ParameterMissingException * * @return array */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        return $this->getCacheInfo($id);
    }

    /** * @return array */
    
/** * @param int $id * * @throws ParameterMissingException * @throws NotFoundException * * @return array|MediaModel */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $filters = [['property' => 'media.id', 'expression' => '=', 'value' => $id]];
        $query = $this->getRepository()->getMediaListQuery($filters[], 1);

        /** @var MediaModel|array $media */
        $media = $query->getOneOrNullResult($this->getResultMode());

        
/** * @param int $id * * @throws ParameterMissingException * @throws NotFoundException * * @return array|UserModel */
    public function getOne($id)
    {
        $this->checkPrivilege('read', 'usermanager');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $builder = $this->getRepository()->createQueryBuilder('user');
        $builder->select(['users', 'attribute'])
            ->from(UserModel::class, 'users')
            ->leftJoin('users.attribute', 'attribute')
            ->where('users.id = ?1')
            ->setParameter(1, $id);

        
/** * @param int $id * * @throws NotFoundException * @throws ParameterMissingException * * @return array<string, mixed>|CustomerModel */
    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $builder = $this->getRepository()->createQueryBuilder('customer');

        $builder->select([
            'customer',
            'attribute',
            'billing',
            

    public function getOne($id)
    {
        $this->checkPrivilege('read');

        if (empty($id)) {
            throw new ParameterMissingException('id');
        }

        $filters = [
            [
                'property' => 'countries.id',
                'expression' => '=',
                'value' => $id,
            ],
        ];
Home | Imprint | This part of the site doesn't use cookies.