Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CmsSectionCollection example
$slot
->
getFieldConfig
(
)
;
$cmsBlock
=
new
CmsBlockEntity
(
)
;
$cmsBlock
->
setUniqueIdentifier
(
'block1'
)
;
$cmsBlock
->
setSlots
(
new
CmsSlotCollection
(
[
$slot
]
)
)
;
$cmsSection
=
new
CmsSectionEntity
(
)
;
$cmsSection
->
setUniqueIdentifier
(
'section1'
)
;
$cmsSection
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlock
]
)
)
;
$cmsPage
=
new
CmsPageEntity
(
)
;
$cmsPage
->
setSections
(
new
CmsSectionCollection
(
[
$cmsSection
]
)
)
;
$product
->
setCmsPage
(
$cmsPage
)
;
return
$slot
;
}
}
$cmsSectionEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsBlockEntity
=
new
CmsBlockEntity
(
)
;
$cmsBlockEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
=
new
CmsSlotEntity
(
)
;
$cmsSlotEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
->
setSlot
(
json_encode
(
$productEntity
->
getTranslated
(
)
, \JSON_THROW_ON_ERROR
)
)
;
$cmsBlockEntity
->
setSlots
(
new
CmsSlotCollection
(
[
$cmsSlotEntity
]
)
)
;
$cmsSectionEntity
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlockEntity
]
)
)
;
$cmsPageEntity
->
setSections
(
new
CmsSectionCollection
(
[
$cmsSectionEntity
]
)
)
;
return
$cmsPageEntity
;
}
/** * @return array<string, array<string, array<string, array<string, array<string, string>>>>> */
private
function
getCmsSlotConfig
(
)
: array
{
return
[
'data' =>
[
$cmsSectionEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsBlockEntity
=
new
CmsBlockEntity
(
)
;
$cmsBlockEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
=
new
CmsSlotEntity
(
)
;
$cmsSlotEntity
->
setId
(
Uuid::
randomHex
(
)
)
;
$cmsSlotEntity
->
setSlot
(
json_encode
(
$productEntity
->
getTranslated
(
)
, \JSON_THROW_ON_ERROR
)
)
;
$cmsBlockEntity
->
setSlots
(
new
CmsSlotCollection
(
[
$cmsSlotEntity
]
)
)
;
$cmsSectionEntity
->
setBlocks
(
new
CmsBlockCollection
(
[
$cmsBlockEntity
]
)
)
;
$cmsPageEntity
->
setSections
(
new
CmsSectionCollection
(
[
$cmsSectionEntity
]
)
)
;
return
$cmsPageEntity
;
}
}