basilicom/pimcore-path-formatter-bundle
Composer 安装命令:
composer require basilicom/pimcore-path-formatter-bundle
包简介
This bundle provides path formatter pattern configuration for Pimcore DataObjects in multi-relation.
README 文档
README
Usecase / Summary
If you want to display specific information of a DataObject when it's listed in a relation-field (Many-to-Many, Many-to-One, Advanced Many-to-Many, etc.), you can use this bundle to easily configure a display pattern.
Instead of creating a new PathFormatter PHP class for every specific display requirement (e.g., showing the name, price, and currency of a product), you can simply define patterns in your configuration.
# config/packages/basilicom_path_formatter.yaml basilicom_path_formatter: pattern: Pimcore\Model\DataObject\Product: "{name} {price}{currency}"
You can also define specific pattern overwrites for a class when it is referenced in a specific field of another class:
# config/packages/basilicom_path_formatter.yaml basilicom_path_formatter: pattern: Pimcore\Model\DataObject\Product: "{name} {price}{currency}" # global product format Pimcore\Model\DataObject\ProductList::products: patternOverwrites: Pimcore\Model\DataObject\Product: "#{id} {name}"
While the product will be formatted like Sneakers 19.99EUR in most relation-fields, the products field in the ProductList class will show them like #13 Sneakers.
Version information
| Bundle Version | PHP | Pimcore |
|---|---|---|
| ^1.0 | ^7.3 | ^6.0 |
| ^2.0 | ^8.0 | ^10.0 |
| ^3.0 | ^8.1 | ^11.0 |
Installation
-
Install the bundle using composer:
composer require basilicom/pimcore-path-formatter-bundle
-
Enable the bundle:
- Pimcore >= 10: The bundle should be automatically registered. If not, add it to
config/bundles.php. - Pimcore < 10: Add the following to
AppKernel::registerBundlesToCollection():if (class_exists('\\Basilicom\\PathFormatterBundle\\BasilicomPathFormatterBundle')) { $collection->addBundle(new \Basilicom\PathFormatterBundle\BasilicomPathFormatterBundle); }
- Pimcore >= 10: The bundle should be automatically registered. If not, add it to
Configuration
- Create a configuration file (e.g.,
config/packages/basilicom_path_formatter.yaml). - Configure your patterns using the full qualified class names as keys.
Basic Configuration
Use curly brackets {} to reference class properties. Any property accessible via a public getter (e.g., {name} calls getName()) can be used.
basilicom_path_formatter: pattern: # Output example: "Product: Sneakers (/dataObject/Products/Sneakers)" Pimcore\Model\DataObject\Product: "Product: {name} ({fullPath})"
Nested Properties
The bundle supports nested property access using dot notation. For example, if a Product has a Category, and you want to show the category name:
basilicom_path_formatter: pattern: Pimcore\Model\DataObject\Product: "{name} (Category: {category.name})"
Note: This will call $product->getCategory()->getName().
Contextual Pattern Overwrites
You can override patterns based on the context (the parent object and the specific field).
basilicom_path_formatter: pattern: # Global default Pimcore\Model\DataObject\Product: "{name}" # Overwrite when a Product is shown in the 'featuredProducts' field of a Category object Pimcore\Model\DataObject\Category::featuredProducts: patternOverwrites: Pimcore\Model\DataObject\Product: "FEATURED: {name} ({price})"
Formatting Documents and Assets
The formatter is not limited to DataObjects; it also works for Assets and Documents.
basilicom_path_formatter: pattern: Pimcore\Model\Asset: "{id} {filename}" Pimcore\Model\Document: "{id} {key}"
Additional Features
Inheritance in DataObjects
By default, inherited values are used when resolving placeholders. You can disable this globally:
basilicom_path_formatter: enable_inheritance: false # default: true
Asset Previews
If a referenced property resolves to a Pimcore\Model\Asset\Image, the bundle automatically renders a small preview thumbnail in the relation list.
basilicom_path_formatter: enable_asset_preview: true # default: true pattern: Pimcore\Model\DataObject\Product: "{mainImage} {name}"
If the target element itself is an Asset\Image, a preview is also prepended to the pattern.
Usage in Pimcore Admin
To apply the formatter to a field:
- Open your Class Definition.
- Select a relation field (e.g., Many-to-Many Relation).
- In the Formatter input field, enter the service ID:
@Basilicom\PathFormatterBundle\DependencyInjection\BasilicomPathFormatter
Author: Alexander Heidrich (Basilicom GmbH)
License: GPL v3
basilicom/pimcore-path-formatter-bundle 适用场景与选型建议
basilicom/pimcore-path-formatter-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.2k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pimcore」 「path formatter」 「pathformatter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 basilicom/pimcore-path-formatter-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 basilicom/pimcore-path-formatter-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 basilicom/pimcore-path-formatter-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Pimcore 5.x Website Indexer (powered by Zend Search Lucene)
Yii2 phone formatter and validator.
JSONPath implementation for querying and updating JSON objects with support for json flattening into a table
Integration module allows to integrate Pimcore platform with Magento 2
Custom laravel monolog logger for datadog logs management, both api and agent ways
The InstantConfigurationCopy module provides easy way to copy configuration field information for admin in back office Magento 2.
统计信息
- 总下载量: 47.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2020-09-10