groupRequestNotFound example


        $criteria = new Criteria($customerIds);
        $result = $this->customerRepository->search($criteria$context);

        $customers = [];

        if ($result->getTotal()) {
            /** @var CustomerEntity $customer */
            foreach ($result->getElements() as $customer) {
                if ($customer->getRequestedGroupId() === null) {
                    if ($silentError === false) {
                        throw CustomerException::groupRequestNotFound($customer->getId());
                    }

                    continue;
                }

                $customers[] = $customer;
            }

            return $customers;
        }

        

    public static function exceptionDataProvider(): iterable
    {
        yield CustomerException::CUSTOMER_GROUP_NOT_FOUND => [
            'exception' => CustomerException::customerGroupNotFound('id-1'),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::CUSTOMER_GROUP_NOT_FOUND,
            'message' => 'Customer group with id "id-1" not found',
        ];

        yield CustomerException::CUSTOMER_GROUP_REQUEST_NOT_FOUND => [
            'exception' => CustomerException::groupRequestNotFound('id-1'),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::CUSTOMER_GROUP_REQUEST_NOT_FOUND,
            'message' => 'Group request for customer "id-1" is not found',
        ];

        yield CustomerException::CUSTOMERS_NOT_FOUND => [
            'exception' => CustomerException::customersNotFound(['id-1', 'id-2']),
            'statusCode' => Response::HTTP_NOT_FOUND,
            'errorCode' => CustomerException::CUSTOMERS_NOT_FOUND,
            'message' => 'These customers "id-1, id-2" are not found',
        ];

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