pimcore / output-data-config-toolkit-bundle
v5.1.0
2024-04-23 08:12 UTC
Requires
- pimcore/pimcore: ^11.0
- symfony/config: ^6.2
- symfony/dependency-injection: ^6.2
- symfony/event-dispatcher: ^6.2
- symfony/event-dispatcher-contracts: ^3.0
- symfony/http-foundation: ^6.2
- symfony/http-kernel: ^6.2
- symfony/routing: ^6.2
- symfony/templating: ^6.2
Requires (Dev)
- phpstan/phpstan: ^1.10.5
- phpstan/phpstan-symfony: ^1.2.20
- 5.x-dev
- 5.1.x-dev
- v5.1.0
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- v5.0.0-RC2
- v5.0.0-RC1
- v5.0.0-BETA2
- v5.0.0-BETA1
- 4.1.x-dev
- v4.1.13
- v4.1.12
- v4.1.11
- v4.1.10
- v4.1.9
- v4.1.8
- v4.1.7
- v4.1.6
- v4.1.5
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.2
- v4.0.1
- v4.0.0
- v3.5.0
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.1
- v3.3.0
- v3.2.1
- v3.2.0
- v3.1.0
- v3.0.0
- v2.7.2
- v2.7.1
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.1
- 2.1.0
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-121-bug-special-chars-are-corrupted-in-output-channel-definition
- dev-update-text-addon
This package is auto-updated.
Last update: 2024-08-29 06:18:13 UTC
README
本工具包提供用户界面,用于根据不同的输出通道创建数据对象的输出格式。因此,可以定义数据对象的哪些属性应该在某个输出通道中打印。输出数据配置由以下内容组成
- values = 数据对象属性
- operators = 可以组合、修改、计算...值
目录
配置
通道配置
安装工具包后,配置文件位于 config/pimcore/outputdataconfig/config.php
。在这个配置文件中,可以配置如下可用输出通道
<?php return [ "channels" => [ "channel1", "channel2", "mychannel1", "mychannel2" ] ];
功能配置
在 config.yml
中
output_data_config_toolkit: tab_options: # order classes by name (defaults by id) order_by_name: true # classes that should be listed by default in output config tab default_classes: - Product # class name - Pimcore\Model\DataObject\ProductCategory # full namespace - 12 # class id classification_store: # defines which classification keys are displayed in the config dialog tree # the possible values are: # 'all', -> always show all keys # 'object', -> only show keys which are in any assigned group of the current object # 'relevant', -> use 'object' mode if any group is assigned, else show all keys (i.e. on a folder) # 'none' -> do not show classification store keys display_mode: relevant
定义不同输出通道的输出数据配置
可以在数据对象编辑器的附加选项卡中配置输出数据配置。因此,可以为每个数据对象类和输出通道定义输出输出数据配置。
输出数据配置可以沿数据对象树继承。对象 ID 列显示输出数据配置是从哪个数据对象继承的。通过单击覆盖,编辑器打开,可以配置新的输出数据配置。
在代码中处理输出通道
该工具包提供了一个服务类,它将 Pimcore 数据对象转换为基于其输出数据配置的输出数据结构。
<?php // returns the output data structure for the given product and the output channel productdetail_specification $specificationOutputChannel = OutputDataConfigToolkitBundle\Service::getOutputDataConfig($product, "productdetail_specification"); //printing output channel in view script with view-helper foreach($specificationOutputChannel as $property) { $this->productListSpecification($property, $this->product); }
请参阅 doc/ProductListSpecification.php
中的示例模板助手,所需的服务配置
# Product Detail Specification Template Helper app.templating.helper.productDetailSpecification: class: App\Templating\Helper\ProductDetailSpecification arguments: ['@translator', '@Pimcore\Localization\IntlFormatter'] tags: - { name: templating.helper, alias: productDetailSpecification }
事件
添加新运算符
创建 Pimcore 工具包并添加以下文件
运算符的 PHP 实现
- 必须在命名空间
OutputDataConfigToolkitBundle\ConfigElement\Operator
中 - 必须实现
AbstractOperator
<?php namespace OutputDataConfigToolkitBundle\ConfigElement\Operator; class RemoveZero extends AbstractOperator { public function __construct($config, $context = null) { parent::__construct($config, $context); } public function getLabeledValue($object) { $childs = $this->getChilds(); if($childs[0]) { $value = $childs[0]->getLabeledValue($object); $value->value = $value->value == 0 ? null : $value->value; return $value; } return null; } }
运算符的 JavaScript 实现
- 必须在命名空间
pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.operator
中 - 必须扩展
pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.Abstract
pimcore.registerNS("pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.operator.RemoveZero"); pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.operator.RemoveZero = Class.create(pimcore.bundle.outputDataConfigToolkit.outputDataConfigElements.Abstract, { type: "operator", class: "RemoveZero", iconCls: "pimcore_icon_operator_remove_zero", defaultText: "operator_remove_zero", getConfigTreeNode: function(configAttributes) { if(configAttributes) { var node = { draggable: true, iconCls: this.iconCls, text: t(this.defaultText), configAttributes: configAttributes, isTarget: true, maxChildCount: 1, expanded: true, leaf: false, expandable: false }; } else { //For building up operator list var configAttributes = { type: this.type, class: this.class}; var node = { draggable: true, iconCls: this.iconCls, text: t(this.defaultText), configAttributes: configAttributes, isTarget: true, maxChildCount: 1, leaf: true }; } return node; }, getCopyNode: function(source) { var copy = new Ext.tree.TreeNode({ iconCls: this.iconCls, text: t(this.defaultText), isTarget: true, leaf: false, maxChildCount: 1, expanded: true, configAttributes: { label: null, type: this.type, class: this.class } }); return copy; }, getConfigDialog: function(node) { }, commitData: function() { } });
通过程序定义输出数据配置
要程序化定义定义,请使用 \OutputDataConfigToolkitBundle\ConfigAttribute\...
类。
例如,将分类存储键添加到通道定义中
$config = new \OutputDataConfigToolkitBundle\ConfigAttribute\Value\DefaultValue(); $config->applyDefaults(); // datatype, type, class $config->applyFromClassificationKeyConfig($keyConfig); // create definition for channel and add value $newConfig = new \OutputDataConfigToolkitBundle\OutputDefinition(); $newConfig->setChannel("my_channel"); $newConfig->setClassId($classId); $newConfig->setObjectId(12345); $newConfig->setConfiguration($serializer->serialize($config, 'json')); $newConfig->save();
支持文本类 ID
执行以下语句
ALTER TABLE bundle_outputdataconfigtoolkit_outputdefinition MODIFY `classId` varchar(50);
从 Pimcore 4 迁移
- 将表名从
plugin_outputdataconfigtoolkit_outputdefinition
更改为bundle_outputdataconfigtoolkit_outputdefinition
。
RENAME TABLE plugin_outputdataconfigtoolkit_outputdefinition TO bundle_outputdataconfigtoolkit_outputdefinition;
- 将命名空间从
Elements\OutputDataConfigToolkit
更改为OutputDataConfigToolkitBundle
。 - 移除了键值支持。
- 更改权限键为
bundle_outputDataConfigToolkit
,执行以下 SQL 语句
UPDATE users_permission_definitions SET `key` = REPLACE(`key`, 'plugin_outputDataConfigToolkit', 'bundle_outputDataConfigToolkit'); UPDATE users SET permissions = REPLACE(`permissions`, 'plugin_outputDataConfigToolkit', 'bundle_outputDataConfigToolkit');
- 自定义运算符和值的命名空间从
pimcore.plugin.outputDataConfigToolkit.*
更改为pimcore.bundle.outputDataConfigToolkit.*