Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
salesChannelIdParameterIsMissing example
'createdById' =>
$userId
, 'id' => Uuid::
fromHexToBytes
(
$orderId
)
]
)
;
}
)
;
return
new
JsonResponse
(
$order
)
;
}
#[Route(path: '/api/_proxy/switch-customer', name: 'api.proxy.switch-customer', methods: ['PATCH'], defaults: ['_acl' => ['api_proxy_switch-customer']])]
public
function
assignCustomer
(
Request
$request
, Context
$context
)
: Response
{
if
(
!
$request
->request->
has
(
self::SALES_CHANNEL_ID
)
)
{
throw
ApiException::
salesChannelIdParameterIsMissing
(
)
;
}
$salesChannelId
=
(string)
$request
->request->
get
(
'salesChannelId'
)
;
if
(
!
$request
->request->
has
(
self::CUSTOMER_ID
)
)
{
throw
ApiException::
salesChannelIdParameterIsMissing
(
)
;
}
$this
->
fetchSalesChannel
(
$salesChannelId
,
$context
)
;
$salesChannelContext
=
$this
->
fetchSalesChannelContext
(
$salesChannelId
,
$request
,
$context
)
;
public
function
testAppIdParameterIsMissing
(
)
: void
{
$exception
= ApiException::
appIdParameterIsMissing
(
)
;
static
::
assertEquals
(
ApiException::API_APP_ID_PARAMETER_IS_MISSING,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Parameter "id" is missing.',
$exception
->
getMessage
(
)
)
;
}
public
function
testSalesChannelIdParameterIsMissing
(
)
: void
{
$exception
= ApiException::
salesChannelIdParameterIsMissing
(
)
;
static
::
assertEquals
(
ApiException::API_SALES_CHANNEL_ID_PARAMETER_IS_MISSING,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Parameter "salesChannelId" is missing.',
$exception
->
getMessage
(
)
)
;
}
public
function
testCustomerIdParameterIsMissing
(
)
: void
{
$exception
= ApiException::
customerIdParameterIsMissing
(
)
;
static
::
assertEquals
(
ApiException::API_CUSTOMER_ID_PARAMETER_IS_MISSING,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Parameter "customerId" is missing.',
$exception
->
getMessage
(
)
)
;
}
$salesChannelId
= 'invalid-sales-channel-id';
$exception
= SeoException::
invalidSalesChannelId
(
$salesChannelId
)
;
static
::
assertInstanceOf
(
InvalidSalesChannelIdException::
class
,
$exception
)
;
static
::
assertEquals
(
Response::HTTP_BAD_REQUEST,
$exception
->
getStatusCode
(
)
)
;
}
public
function
testSalesChannelIdParameterIsMissing
(
)
: void
{
$exception
= SeoException::
salesChannelIdParameterIsMissing
(
)
;
static
::
assertEquals
(
Response::HTTP_BAD_REQUEST,
$exception
->
getStatusCode
(
)
)
;
static
::
assertEquals
(
SeoException::SALES_CHANNEL_ID_PARAMETER_IS_MISSING,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Parameter "salesChannelId" is missing.',
$exception
->
getMessage
(
)
)
;
}
public
function
testTemplateParameterIsMissing
(
)
: void
{
$exception
= SeoException::
templateParameterIsMissing
(
)
;
static
::
assertEquals
(
Response::HTTP_BAD_REQUEST,
$exception
->
getStatusCode
(
)
)
;
$validation
=
$this
->seoUrlValidator->
buildValidation
(
$context
,
$seoUrlRoute
->
getConfig
(
)
)
;
$seoUrlData
=
$seoUrl
->
all
(
)
;
$this
->validator->
validate
(
$seoUrlData
,
$validation
)
;
$seoUrlData
[
'isModified'
]
??= true;
$salesChannelId
=
$seoUrlData
[
'salesChannelId'
]
?? null;
if
(
$salesChannelId
=== null
)
{
throw
SeoException::
salesChannelIdParameterIsMissing
(
)
;
}
/** @var SalesChannelEntity|null $salesChannel */
$salesChannel
=
$this
->salesChannelRepository->
search
(
new
Criteria
(
[
$salesChannelId
]
)
,
$context
)
->
first
(
)
;
if
(
$salesChannel
=== null
)
{
throw
SeoException::
salesChannelNotFound
(
$salesChannelId
)
;
}
if
(
$salesChannel
->
getTypeId
(
)
=== Defaults::SALES_CHANNEL_TYPE_API
)
{
if
(
Feature::
isActive
(
'v6.6.0.0'
)
)
{