Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getAdminUi example
'custom_entity_field'
]
)
;
}
/** * @return Entity[] */
private
function
getEntities
(
AdminUiXmlSchema
$adminUiXmlSchema
)
: array
{
static
::
assertInstanceOf
(
AdminUiXmlSchema::
class
,
$adminUiXmlSchema
)
;
$adminUi
=
$adminUiXmlSchema
->
getAdminUi
(
)
;
static
::
assertInstanceOf
(
AdminUi::
class
,
$adminUi
)
;
return
$adminUi
->
getEntities
(
)
;
}
/** * @param Entity[] $entities */
private
function
checkEntity
(
array
$entities
, string
$name
)
: Entity
{
static
::
assertInstanceOf
(
Entity::
class
,
$entities
[
$name
]
)
;
private
function
validate
(
string
$fixturePath
)
: void
{
$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
,
)
;
}
}
$flags
=
$entity
->
getFlags
(
)
;
$flags
=
[
...
$flags
, ...
[
'cms-aware' =>
[
'name' =>
$entity
->
getName
(
)
]
]
]
;
$entity
->
setFlags
(
$flags
)
;
}
return
$customEntityXmlSchema
;
}
private
function
enrichAdminUi
(
CustomEntityXmlSchema
$customEntityXmlSchema
, AdminUiXmlSchema
$adminUiXmlSchema
)
: CustomEntityXmlSchema
{
$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
(
)
]
,