Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
Validate.php
Go to the documentation of this file.
1 <?php
8 
15 {
21  public function execute()
22  {
23  $response = new \Magento\Framework\DataObject(['error' => false]);
24  $variable = $this->_initVariable();
25  $variable->addData($this->getRequest()->getPost('variable'));
26  $result = $variable->validate();
27  if ($result instanceof \Magento\Framework\Phrase) {
28  $this->messageManager->addError($result->getText());
29  $layout = $this->layoutFactory->create();
30  $layout->initMessages();
31  $response->setError(true);
32  $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml());
33  }
35  $resultJson = $this->resultJsonFactory->create();
36  return $resultJson->setData($response->toArray());
37  }
38 }
$response
Definition: 404.php:11
$variable
Definition: variable.php:7