drupal/rat
最新稳定版本:1.0.1
Composer 安装命令:
composer require drupal/rat
包简介
无描述信息
README 文档
README
See Examples.
Don't mess with #access!
One of the reasons for this library is the restrictAccess method.
Altering the #access property of a render array is quite dangerous,
and the restrictAccess method does the heavy lifting to do it safely.
So what can happen. Take this example:
$fieldRenderable['#access'] = $fieldIsTranslatable;
What can happen? If this code is not the only one messing with the render array, and there are other components doing their work before this one, then a lot can happen. And in Drupal, due to the complex nature of the build and render process, this is usually the case.
Another component may have set access to false, and this code overwrites it to true, and boom.
Even more tricky: Another component may have sett access to a AccessResult object which contains cacheability. Which is overwritten, and boom.
Both cases open the door for information disclosure. Not good.
It turns out that restricting access and adding cacheability, while preserving cacheability from other components is not trivial. RenderArrayTool to the rescue!
// Add access restriction and cacheability, while preserving any existing access
// restrictions, including cacheability.
\Drupal\rat\v1\RenderArray::alter($fieldRenderable)
->restrictAccess($fieldIsTranslatable, $fieldConfig);
统计信息
- 总下载量: 4.65M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: gpl-2.0-or-later
- 更新时间: 2026-01-04