Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
validateConfigurations example
$adminUiEntitiesConfig
=
$adminUiXmlSchema
->
getAdminUi
(
)
?->
getEntities
(
)
;
if
(
$adminUiEntitiesConfig
=== null
)
{
return
$customEntityXmlSchema
;
}
foreach
(
$customEntityXmlSchema
->
getEntities
(
)
?->
getEntities
(
)
??
[
]
as
$entity
)
{
if
(
!\
array_key_exists
(
$entity
->
getName
(
)
,
$adminUiEntitiesConfig
)
)
{
continue
;
}
$this
->adminUiXmlSchemaValidator->
validateConfigurations
(
$adminUiEntitiesConfig
[
$entity
->
getName
(
)
]
,
$entity
)
;
$flags
=
[
...
$entity
->
getFlags
(
)
, ...
[
'admin-ui' =>
$adminUiEntitiesConfig
[
$entity
->
getName
(
)
]
]
]
;
$entity
->
setFlags
(
$flags
)
;
unset
(
$adminUiEntitiesConfig
[
$entity
->
getName
(
)
]
)
;
}
if
(
!
empty
(
$adminUiEntitiesConfig
)
)
{
$adminUiXmlSchema
= AdminUiXmlSchema::
createFromXmlFile
(
__DIR__ . "/../../../_fixtures/AdminUiXmlSchemaValidatorTest/
$fixturePath
/" . AdminUiXmlSchema::FILENAME
)
;
$customEntityXmlSchema
= CustomEntityXmlSchema::
createFromXmlFile
(
__DIR__ . "/../../../_fixtures/AdminUiXmlSchemaValidatorTest/
$fixturePath
/" . CustomEntityXmlSchema::FILENAME
)
;
static
::
assertNotNull
(
$adminUiEntities
=
$adminUiXmlSchema
->
getAdminUi
(
)
?->
getEntities
(
)
)
;
static
::
assertNotNull
(
$customEntities
=
$customEntityXmlSchema
->
getEntities
(
)
?->
getEntities
(
)
)
;
static
::
assertInstanceOf
(
AdminUiEntity::
class
,
$adminUiEntity
= \
array_pop
(
$adminUiEntities
)
)
;
static
::
assertInstanceOf
(
Entity::
class
,
$customEntity
= \
array_pop
(
$customEntities
)
)
;
(
new
AdminUiXmlSchemaValidator
(
)
)
->
validateConfigurations
(
$adminUiEntity
,
$customEntity
,
)
;
}
}