spaceonfire/restify

This package is abandoned and no longer maintained. No replacement package was suggested.

Bitrix REST API module

Installs: 30

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 2

Forks: 3

Open Issues: 0

Type: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

Модуль, который позволяет с легкостью создавать REST API для 1С-Битрикс

Начало работы

Необходимые условия окружения

Для запуска проекта в системе должны быть установлены:

  • PHP >= 7
  • Composer

Установка

composer require spaceonfire/restify

Examples

Events

API output transformation

<?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;
}

Build full path to image in 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'];
});