Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
appIdParameterIsMissing example
public
function
testInvalidApiType
(
)
: void
{
$exception
= ApiException::
invalidApiType
(
'invalid_type'
)
;
static
::
assertEquals
(
ApiException::API_TYPE_PARAMETER_INVALID,
$exception
->
getErrorCode
(
)
)
;
static
::
assertEquals
(
'Parameter type invalid_type is invalid.',
$exception
->
getMessage
(
)
)
;
}
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
(
)
)
;
}
if
(
!
$context
->
isAllowed
(
$privilege
)
)
{
throw
ApiException::
missingPrivileges
(
[
$privilege
]
)
;
}
}
}
private
function
getAppPrivilege
(
Request
$request
)
: string
{
$actionId
=
$request
->
get
(
'id'
)
;
if
(
empty
(
$actionId
)
)
{
throw
ApiException::
appIdParameterIsMissing
(
)
;
}
$appName
=
$this
->connection->
fetchOne
(
' SELECT `app`.`name` AS `name` FROM `app` INNER JOIN `app_action_button` ON `app`.`id` = `app_action_button`.`app_id` WHERE `app_action_button`.`id` = :id ',
[
'id' => Uuid::
fromHexToBytes
(
$actionId
)
]
,
)
;