* Construct new XmlEncoder and allow to change the root node element name.
*
* @param int|null $loadOptions A bit field of LIBXML_* constants
* @param int[] $ignoredNodeTypes an array of ignored XML node types, each one of the DOM Predefined XML_* Constants
*/
public function
__construct
(
string $rootNodeName
=
'response'
,
int $loadOptions
=
null
, array
$ignoredNodeTypes
= [
XML_PI_NODE
,
XML_COMMENT_NODE
])
{
$this
->
rootNodeName
=
$rootNodeName
;
$this
->
loadOptions
=
null
!==
$loadOptions
?
$loadOptions
:
LIBXML_NONET
|
LIBXML_NOBLANKS
;
$this
->
ignoredNodeTypes
=
$ignoredNodeTypes
;
}
break;
default:
return new
JsonResponse
(array(
"error"
=>
"no such class"
));
}
$entity_table
=
$this
->
getDoctrine
()->
getRepository
(
$class
)->
findAll
();
$encoders
= array(new
XmlEncoder
(), new
JsonEncoder
());
$normalizers
= array(new
ObjectNormalizer
());
$serializer
= new
Serializer
(
$normalizers
,
$encoders
);
$jsonContent
=
$serializer
->
serialize
(
$entity_table
,
'json'
);
return new
JsonResponse
(
json_decode
(
$jsonContent
));
}
$data
=
json_decode
(
$request
->
getContent
(),
true
);
$tablesToGetFromDB
= array(
"customer_tag"
,
"sub_issue_tag"
);
$allTagTables
= array();
try {
foreach (
$tablesToGetFromDB
as
$table_name
) {
$table
=
$this
->
getEntityTable
(
$table_name
);
$content
=
json_decode
(
$table
->
getContent
());
$content
=
$this
->
addTagsToTable
(
$content
,
$table_name
);
$associated_groups
=
$this
->
getAssociated_groups
(
GroupsTagtablesRelations
::class, [
'tagTable'
=>
$table_name
]);
$allTagTables
[] = array(
"table_name"
=>
$table_name
,
"tags"
=>
$content
,
"associated_groups"
=>
$associated_groups
);
$this
->
dispatcher
->
dispatch
(
KernelEvents
::
CONTROLLER_ARGUMENTS
,
$event
);
$controller
=
$event
->
getController
();
$arguments
=
$event
->
getArguments
();
// call controller
$response
= \
call_user_func_array
(
$controller
,
$arguments
);
// view
if (!
$response
instanceof
Response
) {
$event
= new
GetResponseForControllerResultEvent
(
$this
,
$request
,
$type
,
$response
);
$this
->
dispatcher
->
dispatch
(
KernelEvents
::
VIEW
,
$event
);
public function
handle
(
Request $request
,
$type
=
HttpKernelInterface
::
MASTER_REQUEST
,
$catch
=
true
)
{
$request
->
headers
->
set
(
'X-Php-Ob-Level'
,
ob_get_level
());
try {
return
$this
->
handleRaw
(
$request
,
$type
);
} catch (\
Exception $e
) {
if (
$e
instanceof
RequestExceptionInterface
) {
$e
= new
BadRequestHttpException
(
$e
->
getMessage
(),
$e
);
}
if (
false
===
$catch
) {
No log messages
ErrorException |
---|
ErrorException: Notice: Use of undefined constant XML_PI_NODE - assumed 'XML_PI_NODE' at vendor/symfony/serializer/Encoder/XmlEncoder.php:48 at Symfony\Component\Serializer\Encoder\XmlEncoder->__construct() (src/Controller/AdminController.php:954) at App\Controller\AdminController->getEntityTable('customer_tag') (src/Controller/AdminController.php:428) at App\Controller\AdminController->getTablesData(object(Request)) (vendor/symfony/http-kernel/HttpKernel.php:149) at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1) (vendor/symfony/http-kernel/HttpKernel.php:66) at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true) (vendor/symfony/http-kernel/Kernel.php:188) at Symfony\Component\HttpKernel\Kernel->handle(object(Request)) (public/index.php:52) |