Generates result response object

@param mixed  $data
@param string $message

@return array
354891
public static function makeResult($data, $message)
	{
		$result = array();
		$result['flag'] = true;
		$result['message'] = $message;
		$result['data'] = $data;

		return $result;
	}
460899
public function replyMessageAction(Message $message)
     {
        $subject = $message->getSubject();
        $forum = $subject->getCategory()->getForum();
        $reply = new Message();
        $form = $this->container->get('form.factory')->create(new MessageType, $reply);
        $form->handleRequest($this->get('request'));

        if ($form->isValid()) {
            $newMsg = $form->getData();
            $this->manager->createMessage($newMsg, $subject);

            return new RedirectResponse(
                $this->generateUrl('claro_forum_messages', array('subject' => $subject->getId()))
            );
        }

        return array(
            'subject' => $subject,
            'form' => $form->createView(),
            'message' => $message,
            '_resource' => $forum,
            'workspace' => $forum->getResourceNode()->getWorkspace()
        );

     }
1016839
public function respondCreatedWithPayload($payload = null, $message = "Created")
    {

        $reponse = $this->setStatusCode(ResponseHTTP::HTTP_CREATED)
            ->respondWithMessageAndPayload($payload, $message);
        return $reponse;
    }
1357807
public static function ajaxResponse($status = 1, $data = [], $message = '')
    {
        $out = [
            'status' => $status,
            'message' => $message,
            'data' => $data,
            'timestamp' => time()
        ];

        echo json_encode($out);
        exit;
    }
590689
public function json($code,$message='',$data=[])
    {
        header('Content-type:application/json');
        if(is_array($code)){
            echo json_encode($code);
        }else{
            echo json_encode(['code'=>$code,'message'=>$message,'result'=>$data]);
        }
        exit;
    }
1224885
private function throwNotFound($message, $data = [], array $headers = [])
    {
        throw new HttpResponseException($this->notFoundResponse($message, $data, $headers));
    }
1271409
private function whenError($message)
    {
        return $this->result->setData([
            'success' => false,
            'payload' => [
                'error'    => $message,
                'redirect' => sprintf('%s%s', $this->baseUrl(), 'pagseguro/payment/failure')
            ]
        ]);
    }
641040
public function respondWithMessageAndPayload($payload = null, $message = "Ok")
    {
        $data = $this->getResponseStructure(true, $payload, $message);
        $reponse = $this->respond($data);
        return $reponse;
    }
1105559
private function errorResponse($message, $data = [], $status = 400, array $headers = [])
    {
        return new JsonResponse(array_merge(['message' => $message], $data), $status, $headers);
    }
1024931
protected function formatMessage( $message )
	{
		if ( is_array( $message ) )
			return var_export( $message, true );
		elseif ( $message instanceof Jsonable )
			return $message->toJson();
		elseif ( $message instanceof Arrayable )
			return var_export( $message->toArray(), true );

		return $message;
	}
611842
public function deserialize($data, Message $message, array $options = [])
    {
        $message = $this->messageSerializer->deserialize($data, $message, $options);

        if (isset($data['subject'])) {
            $subject = $this->om->getObject($data['subject'], Subject::class);

            if (!empty($subject)) {
                $message->setSubject($subject);
            }
        }

        if (isset($data['parent'])) {
            $parent = $this->om->getRepository($this->getClass())->findOneBy(['uuid' => $data['parent']['id']]);

            if ($parent) {
                $message->setParent($parent);
            }
        }
        $this->sipe('meta.flagged', 'setFlagged', $data, $message);
        $this->sipe('meta.moderation', 'setModerated', $data, $message);

        return $message;
    }
798610
public function success($message = null, $data = array(), $return = false)
    {
        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->add($key, $value);
            }
        }
        $json = $this->jsonEncode(
            array(
                'success' => true,
                'message' => $message,
                'data' => $this->_data,
            )
        );
        if (!$return) {
            echo $json;
            Yii::app()->end();
        } else {
            return $json;
        }
    }
917082
public function prettyMessage($message = null, $data = null)
    {
        $this->setMyMessage($message);
        $this->setMyData($data);


        return $this->template([
            'title' => $this->getMyTitle(),
            'message' => $this->getMyMessage(),
            'file' => $this->getMyFile(),
            'line' => $this->getMyLine(),
            'data' => $this->getMyData(),
            'traces' => $this->getMyTraces(),
            'footer' => $this->getMyFooter()
        ]);
    }
865282
public function respondWithError($code = null, $message = null, array $data = []): JsonResponse
    {
        return $this->respond([
            'status' => [
                'type' => 'error',
                'message' => $this->getDefaultMessage($code, $message),
                'code' => $code,
                'http_code' => $this->getStatusCode(),
            ],
            'exception' => $data,
        ]);
    }
619920
private function processResultMessages(Message $message, array $recipients, $resultMessages): ResultCollection
    {
        if (is_scalar($resultMessages)) {
            $key = $this->responseParser->parse($resultMessages);

            if ($key === 'signature_not_allowed') {
                throw new SenderNameNotAllowedException(sprintf(
                    'The signature (sender) "%s" not allowed.',
                    $message->getSender()
                ));
            } elseif ($key === 'signature_invalid') {
                throw new InvalidSenderNameException(sprintf(
                    'Invalid signature (sender): %s',
                    $message->getSender()
                ));
            }

            throw new SendSmsException(sprintf(
                'Cannot resolve the error for sending SMS. Error: %s',
                $resultMessages
            ));
        }

        $sendResult = $resultMessages[0];
        $sendResultKey = $this->responseParser->parse($sendResult);

        if ($sendResultKey === 'missing_required_parameters') {
            throw new MissingRequiredParameterException('Missing required parameters.');
        }

        if ($sendResultKey !== 'success' && $sendResultKey !== 'fail') {
            throw new SendSmsException(sprintf(
                'Fail send sms. Result messages: %s',
                json_encode($resultMessages)
            ));
        }

        array_shift($resultMessages);

        $resultData = [];

        foreach ($recipients as $recipient) {
            $messageId = array_shift($resultMessages);
            $success = preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $messageId);

            if ($success) {
                $resultData[] = Result::successfully($recipient, $messageId);
            } else {
                $reason = $this->tryResolveErrorReason($messageId);
                $resultData[] = Result::failed($recipient, new Error($reason, $messageId));
            }
        }

        return new ResultCollection(...$resultData);
    }
1052010
public function getResponseStructure($success = false, $payload = null, $message = '', $debug = null)
    {
        if (isset($debug)) {
            $data = [
                'success' => $success,
                'message' => $message,
                'payload' => $payload,
                'debug' => $debug
            ];
        } else {
            $data = [
                'success' => $success,
                'message' => $message,
                'payload' => $payload
            ];
        }
        return $data;
    }
1057988
protected function output($message, $data = [], $code = 0)
    {
        JsonOutput::output($message, $data, $code);
        $this->getApp()->end();
    }