Save the oembed data in the bag.

@param Response $response
7113
private function extractOembed(Response $response)
    {
        // extract from xml
        if (($response->getUrl()->getExtension() === 'xml') || ($response->getUrl()->getQueryParameter('format') === 'xml')) {
            if ($xml = $response->getXmlContent()) {
                foreach ($xml as $element) {
                    $content = trim((string) $element);

                    if (stripos($content, '<![CDATA[') === 0) {
                        $content = substr($content, 9, -3);
                    }

                    $this->bag->set($element->getName(), $content);
                }
            }
            // extract from json
        } else {
            if (($json = $response->getJsonContent()) && empty($json['Error'])) {
                $this->bag->set($json);
            }
        }
    }
847404
protected static function _addChainedResponse($response)
    {
        $firstChainedMethodName = key($response);

        if (isset(self::$returnValues[$firstChainedMethodName])) {
            self::$returnValues[$firstChainedMethodName] = array_replace_recursive(
                self::$returnValues[$firstChainedMethodName],
                $response[$firstChainedMethodName]
            );
        } else {
            self::$returnValues[$firstChainedMethodName] = $response[$firstChainedMethodName];
        }
    }
1035825
public function save() {
		if($this->persistent) {
			$action = $this->{'update'};
			$action->directCall($this->attrsForApi($action));
			
		} else {
			// insert
			$action = $this->{'create'};
			$ret = new Response($action, $action->directCall($this->attrsForApi($action)));
			
			if($ret->isOk()) {
				$this->attrs = array_merge($this->attrs, (array) $ret->getResponse());
				
			} else {
				throw new Exception\ActionFailed($ret, "Action '".$action->name()."' failed: ".$ret->message());
			}
			
			$this->persistent = true;
		}
	}
443094
public function prepareResponse(Response $response)
    {
        $cto = $this->getContentTypeObject();
        if (!empty($cto)) {
            $ctt_type = $cto->getContentType();
        } else {
            $ctt_type = $this->getContentType();
        }
        $response->setContentType($ctt_type);
    }
1123755
private function putGatewayResponseToHolder(array $response) {
        /* @var $gatewayResponseHolder GatewayResponseHolder */
        $gatewayResponseHolder = ObjectManager::getInstance()->get(GatewayResponseHolder::class);
        $gatewayResponseHolder->setGatewayResponse($response);
    }
587025
protected function store_response($response) {

        set_config('recentfetch', time(), 'core_plugin');
        set_config('recentresponse', $response, 'core_plugin');

        if (defined('CACHE_DISABLE_ALL') and CACHE_DISABLE_ALL) {
            // Very nasty hack to work around cache coherency issues on admin/index.php?cache=0 page,
            // we definitely need to keep caches in sync when writing into DB at all times!
            \cache_helper::purge_all(true);
        }

        $this->restore_response(true);
    }
211352
public function injectDebugbar(Response $response)
    {
        $content = $response->getContent();

        $renderer = $this->getJavascriptRenderer();

        $openHandlerUrl = $this->di['url']->getStatic( array('for'=>'debugbar.openhandler') );
        $renderer->setOpenHandlerUrl($openHandlerUrl);


        $renderedContent = $renderer->renderHead() . $renderer->render();

        $pos = strripos($content, '</body>');
        if (false !== $pos) {
            $content = substr($content, 0, $pos) . $renderedContent . substr($content, $pos);
        } else {
            $content = $content . $renderedContent;
        }

        $response->setContent($content);
    }
218388
private function sendResponse($response)
    {
        if ($response instanceof ResponseInterface) {
            $response->sendContent();
        } else {
            echo $this->response->send($response);
        }
    }
526483
private function _saveResponse($aResponse, $oRemoteApp)
        {

            // get model by app-type
            $sClassName      = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType());
            $sQueryClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType() . 'Query');

            // if class exists, proceed...
            if (class_exists($sClassName)) {
                // find histories for remote-app
                $aHistories = $sQueryClassName::create()->findByRemoteAppId($oRemoteApp->getId());

                // create new history-entry
                $oRemoteHistoryClass = new $sClassName();
                $oRemoteHistoryClass->setRemoteApp($oRemoteApp);
                $oRemoteHistoryClass->setData($aResponse);

                // convert created class to array for comparsion
                $aNewHistory               = $oRemoteHistoryClass->toArray();
                $aNewHistory['Extensions'] = $aNewHistory['Extensions']->getArrayCopy();
                if (is_object($aNewHistory['Log'])) {
                    $aNewHistory['Log'] = $aNewHistory['Log']->getArrayCopy();
                } else {
                    $aNewHistory['Log'] = array();
                }
                unset($aNewHistory['Id']);


                // interate old histories and convert to array for comparsion
                foreach ($aHistories as $oHistory) {
                    $aHistory               = $oHistory->toArray();
                    $aHistory['Extensions'] = $aHistory['Extensions']->getArrayCopy();
                    if (is_object($aHistory['Log'])) {
                        $aHistory['Log'] = $aHistory['Log']->getArrayCopy();
                    } else {
                        $aHistory['Log'] = array();
                    }

                    unset($aHistory['Id']);

                    // if api-call was not successful, send notifiations if configured
                    if ($aResponse['statuscode'] != 200) {
                        if ($oRemoteApp->checkNotificationSetting("NotificationError")) {
                            $this->_sendErrorNotification($oRemoteApp, $aResponse);
                        }
                    } else {
                        // if api-call was successful, compare old and new history and send differences to user
                        $aNew = $this->arrayRecursiveDiff($aNewHistory, $aHistory);
                        // diff exists?
                        if (!empty($aNew) && $oRemoteApp->checkNotificationSetting("NotificationChange")) {
                            $aOld = $this->arrayRecursiveDiff($aHistory, $aNewHistory);
                            $this->_sendNotification(array(
                                                         'old' => $aOld,
                                                         'new' => $aNew
                                                     ), $oRemoteApp, $aNewHistory);
                        }
                    }
                    // delete old history
                    $oHistory->delete();
                }

                // save created history
                $oRemoteHistoryClass->save();
                $oRemoteApp->setLastRun(time());
                $oRemoteApp->save();

            } else {
                $this->getContainer()->get('logger')->error('Class \'' . $sClassName . '\' not found... ', array("Method"    => __METHOD__,
                                                                                                                                         "RemoteApp" => $oRemoteApp->getName(),
                                                                                                                                         "RemoteURL" => $oRemoteApp->getFullApiUrl()
                ));
                throw new \Exception('Class \'' . $sClassName . '\' not found... ');
            }
        }
544868
protected function addServerTimingHeaders(Response $response)
    {
        if ($this->hasCollector('time')) {
            $collector = $this->getCollector('time');

            $headers = [];
            foreach ($collector->collect()['measures'] as $k => $m) {
                $headers[] = sprintf('%d=%F; "%s"', $k, $m['duration'] * 1000, str_replace('"', "'", $m['label']));
            }

            $response->headers->set('Server-Timing', $headers, false);
        }
    }
690521
private function insertResponseCollectionIntoData(Response $response, $collectionName, array &$data)
    {
        $property = 'cache' . ucfirst($collectionName);
        if ($this->{$property} === false) {
            return;
        }

        $collection = $response->{$collectionName};
        $all = is_array($collection) ? $collection : $collection->toArray();
        if (is_array($this->{$property})) {
            $filtered = [];
            foreach ($this->{$property} as $name) {
                if ($collectionName === 'headers') {
                    $name = strtolower($name);
                }
                if (isset($all[$name])) {
                    $filtered[$name] = $all[$name];
                }
            }
            $all = $filtered;
        }
        $data[$collectionName] = $all;
    }
870282
private function decorateResponse(Response $response)
    {
        if ($response instanceof Http\Response) {
            return $response;
        }

        return new Http\Response($response);
    }
1163520
protected function createResponse(Response $response)
    {
        $contentType = $response->getHeader('Content-Type');

        if (!$contentType) {
            $contentType = 'text/html';
        }

        if (strpos($contentType, 'charset=') === false) {
            $body = $response->getBody(true);
            if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $body, $matches)) {
                $contentType .= ';charset=' . $matches[1];
            }
            $response->setHeader('Content-Type', $contentType);
        }

        $headers = $response->getHeaders();
        $status = $response->getStatusCode();
        if ($status < 300 || $status >= 400) {
            $matches = [];

            $matchesMeta = preg_match(
                '/\<meta[^\>]+http-equiv="refresh" content="\s*(\d*)\s*;\s*url=(.*?)"/i',
                $response->getBody(true),
                $matches
            );

            if (!$matchesMeta) {
                // match by header
                preg_match(
                    '/^\s*(\d*)\s*;\s*url=(.*)/i',
                    (string)$response->getHeader('Refresh'),
                    $matches
                );
            }

            if ((!empty($matches)) && (empty($matches[1]) || $matches[1] < $this->refreshMaxInterval)) {
                $uri = $this->getAbsoluteUri($matches[2]);
                $partsUri = parse_url($uri);
                $partsCur = parse_url($this->getHistory()->current()->getUri());
                foreach ($partsCur as $key => $part) {
                    if ($key === 'fragment') {
                        continue;
                    }
                    if (!isset($partsUri[$key]) || $partsUri[$key] !== $part) {
                        $status = 302;
                        $headers['Location'] = $matchesMeta ? htmlspecialchars_decode($uri) : $uri;
                        break;
                    }
                }
            }
        }

        return new BrowserKitResponse($response->getBody(), $status, $headers);
    }
1235072
public function bind($response) {
		$this->_response = $response;
		$this->_response->headers += $this->_headers;

		foreach ($this->_queue as $message) {
			$this->_write($message);
		}
	}
986859
protected function putInCache(Response $response, $payload) {
    $this->getCache()->put($this->getCacheSection($response), $response->getCacheId(), $payload, $response->getCacheLifetime());
  }
1196453
public function record(Request $request, Response $response)
    {
        if ($this->hasResponse($request)) {
            return;
        }

        $recording = array(
            'request'  => $request->toArray(),
            'response' => $response->toArray()
        );

        $this->storage->storeRecording($recording);
    }
1232045
protected function updateOrder($response, $data)
    {
        $order = $this->getOrder();
        $order->addCapturedAmount($response->getCapturedAmount());
        $order->setPaymentStatus($data->getOrderStatus());
        $order->save();
    }