bitrix-request-response

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Application, Context, Request, Response

Application、Context、Request、Response

Baseline: main 23.0+. Features newer than baseline are marked Since.
Progressive disclosure: open only the rule files that match the task. Do not read every
rules/*.md
.
基准版本:main 23.0+。晚于基准版本的功能会标记为Since
渐进式查阅:仅打开与任务匹配的规则文件。无需阅读所有
rules/*.md
文件。

How to use

使用方法

  1. Identify the layer the task touches.
  2. Open the matching
    rules/*.md
    below.
  3. Prefer framework-native Bitrix patterns over custom abstractions.
  1. 确定任务涉及的层级。
  2. 打开下方匹配的
    rules/*.md
    文件。
  3. 优先使用框架原生的Bitrix模式,而非自定义抽象实现。

Choose a rule file

选择规则文件

When to read
rules/application-context.md

何时阅读
rules/application-context.md

Read
rules/application-context.md
(
Application and Context
) when the task involves:
  • Application
  • Context
当任务涉及以下内容时,请阅读
rules/application-context.md
(《Application与Context》):
  • Application
  • Context

When to read
rules/request.md

何时阅读
rules/request.md

Read
rules/request.md
(
HttpRequest and JSON body
) when the task involves:
  • HttpRequest
  • ParameterDictionary
当任务涉及以下内容时,请阅读
rules/request.md
(《HttpRequest与JSON请求体》):
  • HttpRequest
  • ParameterDictionary

When to read
rules/response.md

何时阅读
rules/response.md

Read
rules/response.md
(
HttpResponse and typed responses
) when the task involves:
  • HttpResponse
  • Built-in Response Classes
  • Checklist
  • Encrypted Cookies
当任务涉及以下内容时,请阅读
rules/response.md
(《HttpResponse与类型化响应》):
  • HttpResponse
  • 内置响应类
  • 检查清单
  • 加密Cookie

When to read
rules/uri-uuid.md

何时阅读
rules/uri-uuid.md

Read
rules/uri-uuid.md
(
Uri and UuidGenerator
) when the task involves:
  • Uri
  • UuidGenerator
当任务涉及以下内容时,请阅读
rules/uri-uuid.md
(《Uri与UuidGenerator》):
  • Uri
  • UuidGenerator

Converter (not covered by rule files)

转换器(未包含在规则文件中)

Bitrix\Main\Engine\Response\Converter
converts strings/arrays via bitmask flags:
TO_SNAKE
,
TO_SNAKE_DIGIT
,
TO_CAMEL
,
TO_UPPER
,
TO_LOWER
,
LC_FIRST
,
UC_FIRST
,
KEYS
,
VALUES
,
RECURSIVE
. Methods:
process($data)
,
getFormat()
/
setFormat($format)
, static
toJson()
.
Converter::OUTPUT_JSON_FORMAT
=
KEYS | RECURSIVE | TO_CAMEL | LC_FIRST
— it camelCases array keys only (no
VALUES
flag); values keep their original case:
php
use Bitrix\Main\Engine\Response\Converter;

(new Converter(Converter::LC_FIRST | Converter::TO_CAMEL))->process('la_la_land'); // laLaLand

(new Converter(Converter::OUTPUT_JSON_FORMAT))->process([
    'CATEGORIES' => [['ID' => 1, 'NAME' => 'Foods']],
]);
// ['categories' => [['id' => 1, 'name' => 'Foods']]] — 'Foods' stays untouched (no VALUES flag)
Bitrix\Main\Engine\Response\Converter
通过位掩码标志转换字符串/数组:
TO_SNAKE
TO_SNAKE_DIGIT
TO_CAMEL
TO_UPPER
TO_LOWER
LC_FIRST
UC_FIRST
KEYS
VALUES
RECURSIVE
。方法包括:
process($data)
getFormat()
/
setFormat($format)
、静态方法
toJson()
Converter::OUTPUT_JSON_FORMAT
=
KEYS | RECURSIVE | TO_CAMEL | LC_FIRST
— 仅将数组键名转换为小驼峰格式(无
VALUES
标志);值保持原始大小写:
php
use Bitrix\Main\Engine\Response\Converter;

(new Converter(Converter::LC_FIRST | Converter::TO_CAMEL))->process('la_la_land'); // laLaLand

(new Converter(Converter::OUTPUT_JSON_FORMAT))->process([
    'CATEGORIES' => [['ID' => 1, 'NAME' => 'Foods']],
]);
// ['categories' => [['id' => 1, 'name' => 'Foods']]] — 'Foods'保持不变(无VALUES标志)

Checklist

检查清单

  • Opened only the rule file(s) needed for this task.
  • Followed DI /
    /local/
    / security canons from
    AGENTS.md
    .
  • 仅打开了当前任务所需的规则文件。
  • 遵循了
    AGENTS.md
    中的依赖注入(DI)/
    /local/
    目录规范/安全准则。