initiate a success result

@param string $code
@param string $message
@param array $errors
@param array $extras
@return Result $Result
180714
public static function success($code = '', $message = '', $errors = [], $extras = [])
    {
        return self::loadResult(self::SUCCESS, $code, $message, $errors, $extras);
    }
139013
public function prepareResult($success, $message, $code, $data, $errors) {
        $this->success = $success;
        $this->code = $code;
        $this->message = $message;
        if(is_null($this->data)) {
            $this->data = array();
        } else {
            if(!is_array($this->data)) {
                $old = $this->data;
                $this->data = array();
                array_push($this->data, $old);
            }
        }
        if(!is_null($data)) {
            if(is_array($data)) {
                $this->data = array_merge($this->data, $data);
            } else {
                array_push($this->data, $data);
            }
        }
        if(is_object($this->errors)) {
            $this->errors = Objects::attrToArray($this->errors);
        }
        if(is_string($this->errors) || is_numeric($this->errors)) {
            $err = $this->errors;
            $this->errors = array();
            $this->errors[0] = $err;
        }
        $this->errors = !is_null($errors) ? array_merge($this->errors, $errors) : $this->errors;
    }
148320
protected static function fail(
        int $errorCode = ErrorCodes::INVALID_VALUE,
        string $messageTemplate = Messages::INVALID_VALUE,
        array $messageParams = []
    ): RuleInterface {
        return new Fail($errorCode, $messageTemplate, $messageParams);
    }
578371
public function respondInternalError($code = ApiResponse::CODE_API_ERROR, $message = null): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_INTERNAL_SERVER_ERROR)
            ->respondWithError($code, $message);
    }
1269166
protected function error($code, lang_string $message) {
        if (array_key_exists($code, $this->errors)) {
            throw new coding_exception('Error code already defined');
        }
        $this->errors[$code] = $message;
    }
442143
protected function _error($message, $code)
    {
        header("HTTP/1.0 {$code} {$message}");
        echo $message;

        TableRegistry::get('Field.FieldInstances')->connection()->disconnect();
        exit(0);
    }
670989
protected function createErrorException($message, $code, $file, $line)
    {
        return new ErrorException($message, $code, 0/* will be resolved */, $file, $line);
    }
1232038
public static Result success(int code, String message) {
        return new Result(true, String.valueOf(code), message);
    }
1047814
protected function addError($code, $extraDetails = null)
    {
        // modified from parent function to support changing the error class
        $errorClass = $this->getSchemaValidationErrorClass();
        $this->errors[] = new $errorClass($code, $extraDetails);
    }
412739
protected function addWarning($message, $code = null)
    {
        $this->adapter->add($message, $code, 'success');
        return $this;
    }
505131
public static Result failure(int code, String message, List<Error> errors) {
        return new Result(code, message, errors);
    }
658894
public static function createFailure($message, $errors = array()) {
	    $report = new static(self::TYPE_ERROR, $message);
	    foreach ($errors as $error) {
	        $report->add($error);
	    }
	    return $report;
	}
390193
public function errors(int $statusCode, string $message, $errors = null): void
    {
        $this->setStatusCode($statusCode);
        $this->setMessage($message);
        $this->setErrors($errors);

        throw new ApiException($this);
    }
372850
public function sendError($code = 204, $vars = null, $headers = [])
    {
        $languageKey = $code . '_' . error_code_string($code);

        $error = [
            'code'    => $code,
            'title'   => language()->getLine($languageKey . '_TITLE'),
            'message' => language()->getLine($languageKey . '_MESSAGE'),
        ];

        $this->statusCode = $code;
        $this->reasonPhrase = $error[ 'title' ];

        if (is_string($vars)) {
            $vars = ['message' => $vars];
        } elseif (is_array($vars) and empty($vars[ 'message' ])) {
            $vars[ 'message' ] = $error[ 'message' ];
        }

        if (isset($vars[ 'message' ])) {
            $error[ 'message' ] = $vars[ 'message' ];
        }

        if (is_ajax() or $this->mimeType !== 'text/html') {
            $this->statusCode = $code;
            $this->reasonPhrase = $error[ 'title' ];
            $this->send($vars);

            exit(EXIT_ERROR);
        }

        $this->sendHeaders($headers);

        if (services()->has('presenter')) {
            presenter()->initialize();

            if (presenter()->theme) {
                presenter()->theme->load();
            }

            $vars = presenter()->getArrayCopy();
            extract($vars);
        }

        extract($error);

        ob_start();
        include $this->getFilePath('error-code');
        $htmlOutput = ob_get_contents();
        ob_end_clean();

        if (services()->has('presenter')) {
            $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput);
        }

        echo $htmlOutput;
        exit(EXIT_ERROR);
    }
448024
public function respondCreated($code = ApiResponse::CODE_SUCCESS, array $data = [], $message = null): JsonResponse
    {
        return $this->setStatusCode(IlluminateResponse::HTTP_CREATED)->respond([
            'status' => [
                'type' => 'success',
                'message' => $this->getDefaultMessage($code, $message),
                'code' => $code,
                'http_code' => $this->getStatusCode(),
            ],
            'data' => $data,
        ]);
    }
994767
public function sendResult($code, $mime, $message)
    {
        $this->sendHeader('HTTP/1.0 ' . $code);
        $this->sendHeader('Content-Type: ' . $mime);
        $this->sendResponse($message);
    }
918236
public static function emerg($message, array $extras = [])
    {
        if (self::$logger) {
            self::$logger->emerg($message, $extras);
        }
    }