Commit 41a89680 authored by DevOps's avatar DevOps

Добавил обработку запроса для данных сайта

parent a1406d4e
...@@ -21,7 +21,7 @@ return [ ...@@ -21,7 +21,7 @@ return [
$acl->deny(null, null) $acl->deny(null, null)
->allow(Roles::ROLE_GUEST, 'home'); ->allow(Roles::ROLE_GUEST, 'home');
$acl->allow(Roles::ROLE_GUEST, 'test-react') $acl->allow(Roles::ROLE_GUEST, 'get-site-data')
; ;
return $acl; return $acl;
......
...@@ -15,8 +15,8 @@ return [ ...@@ -15,8 +15,8 @@ return [
$container $container
); );
}, },
App\Action\TestReact::class => function (ContainerInterface $container) { App\Action\SiteData::class => function (ContainerInterface $container) {
return new \App\Action\TestReact( return new \App\Action\SiteData(
$container->get(\Zend\Expressive\Router\RouterInterface::class), $container->get(\Zend\Expressive\Router\RouterInterface::class),
$container->get(\Zend\Expressive\Template\TemplateRendererInterface::class), $container->get(\Zend\Expressive\Template\TemplateRendererInterface::class),
$container $container
...@@ -37,10 +37,10 @@ return [ ...@@ -37,10 +37,10 @@ return [
], ],
], ],
[ [
'name' => 'test-react', 'name' => 'get-site-data',
'path' => '/test-react/', 'path' => '/get-site-data/',
'middleware' => App\Action\TestReact::class, 'middleware' => App\Action\SiteData::class,
'allowed_methods' => ['POST', 'GET'], 'allowed_methods' => ['POST'],
'options' => [ 'options' => [
'constraints' => [], 'constraints' => [],
'defaults' => [] 'defaults' => []
......
...@@ -11,7 +11,7 @@ class SiteForm extends React.Component { ...@@ -11,7 +11,7 @@ class SiteForm extends React.Component {
}; };
}; };
componentDidMount = () => { componentDidMount = () => {
fetch("/test-react/", {method: 'POST'}) fetch("/get-site-data/", {method: 'POST'})
.then(res => res.json()) .then(res => res.json())
.then( .then(
(result) => { (result) => {
...@@ -45,7 +45,7 @@ class SiteForm extends React.Component { ...@@ -45,7 +45,7 @@ class SiteForm extends React.Component {
return <div>Loading...</div>; return <div>Loading...</div>;
} else { } else {
return ( return (
<form id="site-form" method="POST" action="/test-react"> <form id="site-form" method="POST" action="/get-site-data/">
<div className="form-group-data marker"> <div className="form-group-data marker">
<ConnectedService /> <ConnectedService />
<ConnectedSlots /> <ConnectedSlots />
......
...@@ -11,10 +11,10 @@ use Zend\Diactoros\Response\JsonResponse; ...@@ -11,10 +11,10 @@ use Zend\Diactoros\Response\JsonResponse;
/** /**
* Class TestReact * Class SiteData
* @package App\Action\Admin * @package App\Action\Admin
*/ */
class TestReact extends Common class SiteData extends Common
{ {
/** /**
...@@ -28,20 +28,19 @@ class TestReact extends Common ...@@ -28,20 +28,19 @@ class TestReact extends Common
if ($request->getMethod() == 'POST') if ($request->getMethod() == 'POST')
{ {
$action = $request->getAttribute('action'); $action = $request->getAttribute('action');
return $this->getTestData(); return $this->getTestSiteData();
} }
/*
else else
{ {
$response = new HtmlResponse($this->template->render('app::react/testredux', [ return new HtmlResponse($this->template->render('app::react/testredux', [
'layout' => 'empty', 'layout' => 'empty',
])); ]));
return $response;
} }
*/
} }
private function getTestData() private function getTestSiteData()
{ {
$data = array( $data = array(
'onlyNative' => true, 'onlyNative' => true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment