Beispiel #1
0
 /**
  * Post request for creating widget instance.
  *
  * @param FixtureInterface $fixture [optional]
  * @throws \Exception
  * @return array
  */
 public function persist(FixtureInterface $fixture = null)
 {
     $code = $this->mappingData['code'][$fixture->getCode()];
     $themeId = $this->getThemeId($fixture->getThemeId());
     $data = $this->prepareData($fixture);
     $url = $_ENV['app_backend_url'] . 'admin/widget_instance/save/code/' . $code . '/theme_id/' . $themeId;
     $curl = new BackendDecorator(new CurlTransport(), $this->_configuration);
     $curl->write($url, $data);
     $response = $curl->read();
     $curl->close();
     if (!strpos($response, 'data-ui-id="messages-message-success"')) {
         throw new \Exception("Widget instance creation by curl handler was not successful! Response: {$response}");
     }
     $id = null;
     if (preg_match_all('/\\/widget_instance\\/edit\\/instance_id\\/(\\d+)/', $response, $matches)) {
         $id = $matches[1][count($matches[1]) - 1];
     }
     return ['id' => $id];
 }