ParameterMissingException example


    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());

        if (!$media) {
            throw new NotFoundException(sprintf('Media by id %d not found', $id));
        }

        

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

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

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

    /** * @return array */
    public function getList()
    {
        $this->checkPrivilege('read');

        

    public function getIdFromNumber($number)
    {
        if (empty($number)) {
            throw new ParameterMissingException('id');
        }

        $builder = Shopware()->Models()->createQueryBuilder();
        $builder->select(['customer.id'])
                ->from(CustomerModel::class, 'customer')
                ->where('customer.number = ?1')
                ->setParameter(1, $number);

        try {
            $id = $builder->getQuery()->getOneOrNullResult();
        } catch (NonUniqueResultException $nonUniqueResultException) {
            

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

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

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

        /** @var PaymentModel|null $payment */
        $payment = $query->getOneOrNullResult($this->getResultMode());

        if (!$payment) {
            throw new ApiException\NotFoundException(sprintf('Payment by id %d not found', $id));
        }

        

    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));
        }

        if ($this->getResultMode() === Resource::HYDRATE_ARRAY) {
            

    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));
        }

        return $address;
    }
/** * Generate product images * * PUT /api/generateArticleImages/{id} */
    public function putAction(): void
    {
        $request = $this->Request();
        $id = $request->getParam('id');

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

        $useNumberAsId = (bool) $request->getParam('useNumberAsId', 0);
        $id = $useNumberAsId ? $this->resource->getIdFromNumber($id) : (int) $id;

        if (!$useNumberAsId && $id <= 0) {
            throw new ApiException\CustomValidationException('Invalid product id');
        }

        /** @var Article|null $product */
        $product = $this->resource->getRepository()->find($id);

        

    public function getIdFromNumber($number)
    {
        if (empty($number)) {
            throw new ParameterMissingException('id');
        }

        $productVariant = $this->getDetailRepository()->findOneBy(['number' => $number]);

        if (!$productVariant instanceof Detail) {
            throw new NotFoundException(sprintf('Product by number "%s" not found', $number));
        }

        return $productVariant->getArticle()->getId();
    }

    

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

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

        $filters = [
            [
                'property' => 'countries.id',
                'expression' => '=',
                'value' => $id,
            ],
        ];
        $builder = $this->getRepository()->getCountriesWithStatesQueryBuilder($filters);
        /** @var CountryModel|null $country */
        

    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);

        /** @var UserModel|array|null $user */
        $user = $builder->getQuery()->getOneOrNullResult($this->getResultMode());

        

    public function getIdFromNumber($number)
    {
        if (empty($number)) {
            throw new ParameterMissingException('number');
        }

        $orderModel = $this->getRepository()->findOneBy(['number' => $number]);

        if (!$orderModel) {
            throw new NotFoundException(sprintf('Order by number %s not found', $number));
        }

        return $orderModel->getId();
    }

    

    public function update($id, array $data$index = false)
    {
        $this->checkPrivilege('save');

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

        $stream = $this->getManager()->find(CustomerStreamEntity::class$id);

        if (!$stream instanceof CustomerStreamEntity) {
            throw new NotFoundException(sprintf('Customer Stream by id %d not found', $id));
        }

        $data = $this->prepareData($data);

        $stream->fromArray($data);

        

    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);

        $query = $builder->getQuery();
        $query->setHydrationMode($this->getResultMode());

        
/** * @param int $presetId * * @throws NotFoundException * @throws ParameterMissingException * @throws Exception */
    public function delete($presetId)
    {
        if (!$presetId) {
            throw new ParameterMissingException('id');
        }

        /** @var Preset|null $preset */
        $preset = $this->models->find(Preset::class$presetId);

        if (!$preset) {
            throw new NotFoundException(sprintf('Emotion preset with id %s not found', $presetId));
        }

        if (!$preset->getCustom()) {
            throw new PrivilegeException(sprintf('Emotion preset %s is not defined as custom preset', $preset->getName()));
        }

    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')
                ->setParameter('variantId', $id);

        $variant = $builder->getQuery()->getOneOrNullResult($this->getResultMode());

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