Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getCollectionEntity example
protected
function
configure
(
)
: void
{
$this
->
addArgument
(
'class', InputArgument::REQUIRED
)
;
$this
->
addArgument
(
'name', InputArgument::REQUIRED
)
;
}
protected
function
execute
(
InputInterface
$input
, OutputInterface
$output
)
: int
{
/** @var class-string $class */
$class
=
$input
->
getArgument
(
'class'
)
;
$entityClass
=
$this
->
getCollectionEntity
(
$class
)
;
$name
=
$input
->
getArgument
(
'name'
)
;
if
(
$entityClass
=== null
)
{
file_put_contents
(
$this
->
getFilePath
(
$name
)
,
json_encode
(
$this
->
dumpProperties
(
$class
)
, \JSON_PRETTY_PRINT
)
)
;
}
else
{
$collection
=
[
'type' => 'array',
'items' =>
$this
->
dumpProperties
(
$entityClass
)
,
]
;
file_put_contents
(
$this
->
getFilePath
(
$name
)
,
json_encode
(
$collection
, \JSON_PRETTY_PRINT
)
)
;
}