Little response helper to merge data

@example Api::responseMerge()
@param $mdata
@param $mergedData
@param null $status
@param null $msg
@return array
@internal param $data
550906
public static function responseMerge($mdata, $mergedData, $status = null, $msg = null){
        $data = self::response($mdata, $status, $msg);

        $data = Arr::merge($data, $mergedData);

        return $data;
    }
709493
public function successData($data, $msg = null, $extraData = [])
    {
        $return = $this->output(1, $msg, $data, $extraData);

        return $this->responseJson($return);
    }
276985
public static function createFromResponse($responseData)
    {
        $verifyCode = new self(null, null);
        $verifyCode->setRawResponseData($responseData)
            ->processResponse();

        if ($verifyCode['status'] !== 0 && $verifyCode['status'] !== '0') {
            throw new Exception($verifyCode['err_msg']);
        }

        return $verifyCode;
    }
576212
public function mergePropertyData(array $data)
    {
        $this->propertyData = array_replace($this->propertyData, $data);

        if (!$this->isMergingWidgetData) {
            $this->setCoreData($this->propertyData);
        }

        if ($this->property) {
            $this->property->setData($data);
        }

        return $this;
    }
193778
private function messageToResponse($msg)
    {
        $response = new ResponseMessage($msg);
        $actionId = $response->getActionId();
        if (is_null($actionId)) {
            $actionId = $this->lastActionId;
            $response->setActionId($this->lastActionId);
        }
        return $response;
    }
373275
public static function responseError($mdata = array(), $status = null, $msg = null)
    {
        if (!$status) {
            $status = 400;
        }

        if (method_exists($mdata, 'getFile')) {
            $data = [
                "msg" => $msg ?: $mdata->getMessage(),
                "status" => $status,
                "data" => [],
            ];
            if (LEVEL_ENV < 2) {
                $data['data']['file'] = $mdata->getFile();
                $data['data']['line'] = $mdata->getLine();
                $data['data']['code'] = $mdata->getCode();
                $data['data']['debug'] = debug_backtrace();
            }
        } else{
            $data = [
                "msg" => $msg,
                "status" => $status,
                "data" => $mdata,
            ];
        }

        return $data;
    }
950514
protected void sendMergeResponse(Address sender, View view, Digest digest, MergeId merge_id) {
        Message msg=new Message(sender).setBuffer(GMS.marshal(view, digest)).setFlag(Message.Flag.OOB,Message.Flag.INTERNAL)
          .putHeader(gms.getId(), new GMS.GmsHeader(GMS.GmsHeader.MERGE_RSP).mergeId(merge_id));
        gms.getDownProtocol().down(msg);
    }
216256
public static function createFromResponse($responseData)
    {
        $messageStatus = new self(null);
        $messageStatus->setRawResponseData($responseData)
            ->processResponse();

        if ($messageStatus['status'] !== 0 && $messageStatus['status'] !== '0') {
            throw new Exception($messageStatus['err_msg']);
        }

        //show message status instead of integer status code
        $messageStatus['message_status'] = self::$messageStatusType[$messageStatus['message_status']];

        return $messageStatus;
    }
234118
public function resourceJson($data = array(), $status = 200, array $headers = array())
  {
    $headers = array_merge($headers, $this->getRequestLimitHeader());
    $headers = array_merge($headers, $this->getConfig('headers'));

    return $this->getResponse()->resourceJson($data, $status, $headers);
  }
1014723
public function success($data = [], $status = Response::HTTP_OK, $headers = [])
    {
        return $this->response($data, $status, $headers);
    }
381626
private function niceMerge(array &$source, array &$destination): array
    {
        $merged = $source;

        foreach ($destination as $key => &$value) {
            if (
                    $this->mergeRecursive &&
                    isset($merged[$key]) &&
                    is_array($merged[$key])
            ) {
                $merged[$key] = $this->niceMerge($source[$key], $value);
                continue;
            }

            $merged[$key] = $value;
        }

        return $merged;
    }
1293393
public function setData(array $data)
    {
        $this->isMergingData = true;
        /**
         * @todo Kinda hacky, but works with the concept of form.
         *     Should work embeded in a form group or in a dashboard.
         */
        $data = array_merge($_GET, $data);

        parent::setData($data);

        /** Merge any available presets */
        $data = $this->mergePresets($data);

        parent::setData($data);

        $this->isMergingData = false;

        if ($this->lang()) {
            $this->translator()->setLocale($this->lang());
        }

        return $this;
    }
505275
public static function mergePrefixData($data, $prefixData)
    {
        $prefixGroups = $prefixData['prefix-groups'];

        foreach ($data["partitions"] as $index => $partition) {
            foreach ($prefixGroups as $current => $old) {
                $serviceData = Env::search("services.{$current}", $partition);
                if (!empty($serviceData)) {
                    foreach ($old as $prefix) {
                        if (empty(Env::search("services.{$prefix}", $partition))) {
                            $data["partitions"][$index]["services"][$prefix] = $serviceData;
                        }
                    }
                }
            }
        }

        return $data;
    }
279450
public function respondWithData(array $data)
    {

        $responseData = $this->getResponseStructure(true, $data, '');
        $response = new JsonResponse($responseData, $this->getStatusCode(), $this->getHeaders());
        return $response;
    }
669760
private function mergeFromServer($data, $completeData = true)
    {
        $this->hasBeenFetched = ($this->hasBeenFetched || $completeData) ? true : false;
        $this->mergeMagicFields($data);
        foreach ($data as $key => $value)
        {
            if ($key === '__type' && $value === 'className')
            {
                continue;
            }

            $decodedValue = AVClient::_decode($value);

            if (is_array($decodedValue))
            {
                if (isset($decodedValue['__type']))
                {
                    if ($decodedValue['__type'] === 'Relation')
                    {
                        $className = $decodedValue['className'];
                        $decodedValue = new AVRelation($this, $key, $className);
                    }
                }
                if ($key == 'ACL')
                {
                    $decodedValue = AVACL::_createACLFromJSON($decodedValue);
                }
            }
            $this->serverData[$key] = $decodedValue;
            $this->dataAvailability[$key] = true;

        }
        if (!$this->updatedAt && $this->createdAt)
        {
            $this->updatedAt = $this->createdAt;
        }
    }
984981
public static function responseJson($mdata = array(), $status = null, $msg = '', array $headers = array(), $options = 0)
    {
        $response = self::response($mdata, $status, $msg);
        return Response::json($response, $response['status'], $headers, $options);
    }
472049
protected function getStatusData($status, $messages = null, $msgKey = 'messages')
	{
		$data = ['status' => $status];

		if ($messages !== null) {
			if ($messages instanceof MessageProviderInterface) {
				$messages = $messages->getMessageBag();
			}

			if ($messages instanceof ArrayableInterface) {
				$messages = $messages->toArray();
			}

			$data[$msgKey] = (array) $messages;
		}

		return $data;
	}