spaceonfire/restify

此包已被 放弃 并且不再维护。未建议替代包。

Bitrix REST API 模块

安装: 30

依赖: 0

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 3

开放问题: 0

类型:bitrix-d7-module

1.0.0-beta.2 2018-12-11 16:14 UTC

This package is auto-updated.

Last update: 2023-08-16 01:29:42 UTC


README

一个允许轻松创建 1C-Битрикс REST API 的模块

开始使用

所需环境条件

为了在系统中运行此项目,以下软件必须已安装:

  • PHP >= 7
  • Composer

安装

composer require spaceonfire/restify

示例

事件

API 输出转换

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';

use Bitrix\Main\Event;
use Bitrix\Main\EventManager;
use Emonkak\HttpException\InternalServerErrorHttpException;

EventManager::getInstance()->addEventHandler(
	'spaceonfire.restify',
	'transform',
	'modifyStatusCode'
);

function throw500() {
	throw new InternalServerErrorHttpException();
}

function modifyStatusCode(Event $event) {
	$params = $event->getParameters();
	$params['statusCode'] = 500;
}

在 FileFormatter 中构建图像的完整路径

use Bitrix\Main\Event;
use Bitrix\Main\EventManager;

EventManager::getInstance()->addEventHandler('spaceonfire.restify', 'OnFileFormatter', function(Event $event) {
	$params = $event->getParameters();
	$params['data']['SRC'] = $_SERVER['REQUEST_SCHEME'] . '://' . (env('DOMAIN') ?: $_SERVER['HTTP_HOST']) . $params['data']['SRC'];
});