Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setOrderSequence example
'page' => 5,
]
)
;
static
::
assertEquals
(
10,
$extensionCriteria
->
getLimit
(
)
)
;
static
::
assertEquals
(
40,
$extensionCriteria
->
getOffset
(
)
)
;
}
public
function
testItIgnoresInvalidValuesForSortDirection
(
)
: void
{
$extensionCriteria
=
new
ExtensionCriteria
(
)
;
$extensionCriteria
->
setOrderSequence
(
'random'
)
;
static
::
assertEquals
(
ExtensionCriteria::ORDER_SEQUENCE_ASC,
$extensionCriteria
->
getOrderSequence
(
)
)
;
}
public
function
testOrderSequenceDesc
(
)
: void
{
$extensionCriteria
=
new
ExtensionCriteria
(
)
;
$extensionCriteria
->
setOrderSequence
(
'DesC'
)
;
static
::
assertEquals
(
ExtensionCriteria::ORDER_SEQUENCE_DESC,
$extensionCriteria
->
getOrderSequence
(
)
)
;
}
if
(
isset
(
$parameter
[
'page'
]
)
)
{
$criteria
->
setOffset
(
(
(int)
$parameter
[
'page'
]
- 1
)
*
$criteria
->
getLimit
(
)
)
;
}
if
(
isset
(
$parameter
[
'term'
]
)
)
{
$criteria
->
setSearch
(
$parameter
[
'term'
]
)
;
}
$sorting
=
$parameter
[
'sort'
]
[
0
]
?? null;
if
(
$sorting
!== null
)
{
$criteria
->
setOrderBy
(
$sorting
[
'field'
]
)
;
$criteria
->
setOrderSequence
(
$sorting
[
'order'
]
)
;
}
if
(
isset
(
$parameter
[
'filter'
]
)
)
{
foreach
(
$parameter
[
'filter'
]
as
$filter
)
{
$criteria
->
addFilter
(
$filter
)
;
}
}
return
$criteria
;
}