Skip to content

Instantly share code, notes, and snippets.

@tarlepp
Last active January 25, 2021 20:50
Show Gist options
  • Save tarlepp/a076b841cc7f405d728b7ac94d8792c1 to your computer and use it in GitHub Desktop.
Save tarlepp/a076b841cc7f405d728b7ac94d8792c1 to your computer and use it in GitHub Desktop.
<?php
namespace App\Model;
class Header
{
/**
* @var string
*/
public $OrganizationID;
/**
* @var int
*/
public $DivisionID;
}
<?php
namespace App\Controller;
use App\Model\ItemMaintenance;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
class IndexController
{
/**
* @Route(path="/")
*/
public function __invoke(SerializerInterface $serializer): JsonResponse
{
$xml = <<<XML
<ItemMaintenance>
<Header>
<OrganizationID>Test</OrganizationID>
<DivisionID>41</DivisionID>
</Header>
</ItemMaintenance>
XML;
$data = $serializer->deserialize($xml, ItemMaintenance::class, 'xml');
dd($data);
return new JsonResponse($data);
}
}
<?php
namespace App\Model;
class ItemMaintenance
{
public $Version;
/**
* @var Header
*/
public $Header;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment