parisek/drupal-kit 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

parisek/drupal-kit

Composer 安装命令:

composer require parisek/drupal-kit

包简介

Shared Drupal infrastructure for sites built on the PORTA component pattern: services, base classes, Twig extensions, image resizer.

README 文档

README

Packagist Version Packagist Downloads CI Drupal PHPStan Coverage License: GPL-2.0-or-later

parisek/drupal-kit — base library module for Drupal sites built on the PORTA component pattern. Provides shared infrastructure (services, base classes, Twig extensions, image resizer) reused across projects. The Drupal counterpart of parisek/timber-kit (WordPress).

Requires PHP 8.3+ and Drupal 10 or 11.

Installation

Published on Packagist:

composer require parisek/drupal-kit
drush en drupal_kit

What this module provides

Services

  • drupal_kit.entity_helper — high-level entity loading and rendering helpers consumed by display plugins and Twig templates. Facade over the three builders below.
  • drupal_kit.media_array_builder — builds the documented array shapes for Media and File entities (image, SVG, video, remote video, document, Lottie).
  • drupal_kit.menu_tree_builder — renders a menu into the documented item shape (active trail, field_* enrichment, subtree scoping via params['root']).
  • drupal_kit.taxonomy_tree_builder — builds nested taxonomy term trees.
  • Drupal\drupal_kit\Services\Resizer — static utility: image style + focal point + responsive variant generator. Call Resizer::resizer($images, $variants) directly.
  • drupal_kit.menu_active_trail_resolver — resolves the active menu trail accounting for entity references and aliases.
  • drupal_kit.twig_extension — registers Twig functions used by component templates, including the typography-aware translation helpers _xt / __t / _nt / _nxt (translate, then pipe through |typography).
  • drupal_kit.typography_twig_extension — provides the |typography Twig filter; delegates to parisek/twig-typography and resolves typography config from {active_theme}/static/typography.yml.
  • drupal_kit.route_subscriber — alters routes for entity access edge cases.

Base classes

  • Drupal\drupal_kit\ComponentBase — base for component block plugins.
  • Drupal\drupal_kit\DisplayBase — base for extra_field display plugins that render components.

Filters

FilterImage, FilterLinks, FilterTable, FilterTypography, FilterYoutubetext format filters that normalize editor output into PORTA's component shape.

Required modules

Pulled automatically by Composer when you install:

Optional integrations

The following modules are optional. When present, EntityHelper automatically exposes additional fields and renderers; when absent, those code paths gracefully no-op.

Contrib (install via Composer):

Drupal core (enable via drush en …):

  • comment — comment entity support (comment_body field on Comment entities).

Drupal core patches (apply via cweagans/composer-patches):

  • drupal.org#2466553 — adds menu.language_tree_manipulator to Drupal core. When applied, EntityHelper::getMenu() filters menu links by the current content language. When absent, the filter step is silently skipped and menu items for all languages appear — on multilingual sites the status report (/admin/reports/status) shows a warning so the gap is visible.

Local development

Local environment is DDEV — pinned to PHP 8.3 in .ddev/config.yaml so it matches the production deploy target and CI. The database container is omitted; kernel tests use sqlite in-memory.

ddev start
ddev composer install
ddev exec scripts/dev-link-module.sh   # symlink module into web/modules/contrib + bridge web/autoload.php
ddev exec vendor/bin/phpunit

scripts/dev-link-module.sh resolves paths relative to where it runs, so it must be invoked inside the container — otherwise the symlinks point to host paths the container can't see.

Tests

Tests are self-contained — Composer scaffolds Drupal via installer-paths; PHPUnit bootstraps from web/core/tests/bootstrap.php.

ddev exec vendor/bin/phpunit --testsuite unit
ddev exec vendor/bin/phpunit --testsuite kernel

Coverage

ddev coverage is a custom command (defined in .ddev/commands/web/coverage) that runs PHPUnit with xdebug.mode=coverage and emits both clover XML and a textual summary:

ddev coverage
ddev coverage --filter ResizerTest   # any phpunit args pass through

CI uses the same flags so local + CI numbers stay aligned.

Step-debugging

ddev xdebug on    # loads xdebug in debug mode; listen on host port 9003
ddev xdebug off   # debug mode is a heavy perf hit; keep it off by default

See CONTRIBUTING.md for how to add tests and the unit-vs-kernel decision tree.

Without DDEV

DDEV is the canonical local environment, but the repo doesn't hard-depend on it — CI runs vanilla composer install + vendor/bin/phpunit against PHP 8.3 from the shivammathur/setup-php GitHub Action. If you prefer host-PHP, ensure you're on PHP 8.3 (matching CI / production) to avoid composer.lock drift.

Releasing

Tag-driven; published on Packagist, which syncs tags automatically via the GitHub webhook. Version bumps follow Conventional Commits, the public-API surface and deprecation lifecycle are defined in RELEASING.md — read it before tagging.

Distribution scope: composer require ships only the module files, src/, templates/, composer.json, LICENSE and README.md — everything development-only is export-ignored in .gitattributes.

Related projects

Part of the PORTA ecosystem:

  • parisek/timber-kit — the WordPress counterpart: shared Timber/ACF infrastructure for PORTA themes.
  • parisek/twig-typography — framework-agnostic typography Twig extension that powers our |typography filter.

License

GPL-2.0-or-later. See LICENSE.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固