Skip to content

Commit 8d9a42f

Browse files
feature: option to enable/disable inheritance of dataobject values
1 parent 4e06714 commit 8d9a42f

File tree

13 files changed

+190
-9334
lines changed

13 files changed

+190
-9334
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
vendor
33
.phpunit*
44
_output
5+
composer.lock

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tests:
33
vendor/bin/phpunit --configuration ./tests/phpunit.xml --stderr --no-coverage
44

55
composer-update:
6-
docker run --rm -it --env COMPOSER_MEMORY_LIMIT=-1 --volume ${PWD}:/app prooph/composer:7.3 update --ignore-platform-reqs
6+
docker run --rm -it --env COMPOSER_MEMORY_LIMIT=-1 --volume ${PWD}:/app prooph/composer:7.3 update --ignore-platform-reqs --no-scripts
77

88
composer-install:
9-
docker run --rm -it --env COMPOSER_MEMORY_LIMIT=-1 --volume ${PWD}:/app prooph/composer:7.3 install --ignore-platform-reqs
9+
docker run --rm -it --env COMPOSER_MEMORY_LIMIT=-1 --volume ${PWD}:/app prooph/composer:7.3 install --ignore-platform-reqs --no-scripts

README.md

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# Basilicom Extended Path Formatter Bundle for Pimcore
22

33
## Usecase / Summary
4-
If you want to display specific informations of a dataObject when it's listed in a relation-field, you can use this plugin to easily configure a display-pattern.
5-
Without creating a new PathFormatter in your project to displaying the name, price and currency of a product-class you can just configure it like:
4+
5+
If you want to display specific informations of a dataObject when it's listed in a relation-field, you can use this
6+
plugin to easily configure a display-pattern.
7+
Without creating a new PathFormatter in your project to displaying the name, price and currency of a product-class you
8+
can just configure it like:
9+
610
```
711
# app/config/config.yml
812
basilicom_path_formatter:
913
pattern:
1014
Pimcore\Model\DataObject\Product: "{name} {price}{currency}"
1115
```
16+
1217
Or you might want to define a specific pattern for a product in the relation-field of a specific class.
18+
1319
```
1420
# app/config/config.yml
1521
basilicom_path_formatter:
@@ -19,73 +25,116 @@ basilicom_path_formatter:
1925
patternOverwrites:
2026
Pimcore\Model\DataObject\Product: "#{id} {name}"
2127
```
22-
While the product will be formatted like ``Sneakers 19.99EUR`` in all relation-fields with the formatter, the ProductList-Class will show them in like ``#13 - Sneakers``
28+
29+
While the product will be formatted like ``Sneakers 19.99EUR`` in all relation-fields with the formatter, the
30+
ProductList-Class will show them in like ``#13 - Sneakers``
2331

2432

2533
----------
2634

35+
## Version information
36+
37+
| Bundle Version | PHP | Pimcore |
38+
|----------------|------|---------|
39+
| ^1.0 | ^7.3 | ^6.0 |
40+
| ^2.0 | ^8.0 | ^10.0 |
41+
| ^3.0 | ^8.1 | ^11.0 |
2742

2843
## Installation
29-
Install the bundle using ``composer require basilicom/pimcore-path-formatter-bundle``
44+
45+
Install the bundle using ``composer require basilicom/pimcore-path-formatter-bundle``
3046

3147
Execute ``bin/console pimcore:bundle:enable BasilicomPathFormatterBundle``
3248
**or**
3349
add the following lines to `AppKernel::registerBundlesToCollection()` (**recommended**)
50+
3451
```php
3552
if (class_exists('\\Basilicom\\PathFormatterBundle\\BasilicomPathFormatterBundle')) {
3653
$collection->addBundle(new \Basilicom\PathFormatterBundle\BasilicomPathFormatterBundle);
3754
}
3855
```
3956

4057
## Configuration
58+
4159
1. Add the ``basilicom_path_formatter`` key to your Pimcore ``app/config/config.yml``
4260
2. Configure a pattern by adding the full qualified dataObject class-name as key the pattern-string as value.
4361
Use class-property-names, accessible by public getter methods, surrounded by curly brackets.
44-
This also enables you to reference basic Pimcore ``Concrete``/``AbstractObject`` methods like:
45-
- ``fullPath`` for ``\Pimcore\Model\DataObject\AbstractObject::getFullPath())``
46-
- ``className`` for ``\Pimcore\Model\DataObject\AbstractObject::getClassName())``
47-
- ...
48-
49-
**Example:**
62+
This also enables you to reference basic Pimcore ``Concrete``/``AbstractObject`` methods like:
63+
- ``fullPath`` for ``\Pimcore\Model\DataObject\AbstractObject::getFullPath())``
64+
- ``className`` for ``\Pimcore\Model\DataObject\AbstractObject::getClassName())``
65+
- ...
66+
67+
**Example:**
5068
```
5169
basilicom_path_formatter:
5270
pattern:
5371
# output of e.g. "Product: Sneakers (/dataObject/Products/Sneakers)"
5472
5573
Pimcore\Model\DataObject\Product: "Product: {name} ({fullPath})"
5674
```
57-
**Note:** If no getter exists for the property, the placeholder will stay untouched.
75+
**Note:** If no getter exists for the property, the placeholder will stay untouched.
5876
59-
3. Add ``@Basilicom\PathFormatterBundle\DependencyInjection\BasilicomPathFormatter`` to the Formatter-Field in the relation-fieldType.
77+
3. Add ``@Basilicom\PathFormatterBundle\DependencyInjection\BasilicomPathFormatter`` to the Formatter-Field in the
78+
relation-fieldType.
6079
**Note:** The ``@`` is important, as the formatter is registered as a service, including dependency injection.
61-
6280
6381
## Advanced configuration
64-
It is possible to configure a context-based pattern, so that a dataObject in a relation-field of a specific class will be formatted differently.
82+
83+
### Contextual pattern overwrites
84+
85+
It is possible to configure a context-based pattern, so that a dataObject in a relation-field of a specific class will
86+
be formatted differently.
6587
6688
**Example:**
67-
```
89+
90+
```yaml
6891
# app/config/config.yml
6992
basilicom_path_formatter:
70-
pattern:
71-
# global product format
72-
Pimcore\Model\DataObject\Product: "{name} {price}{currency}"
93+
pattern:
94+
# global product format
95+
Pimcore\Model\DataObject\Product: "{name} {price}{currency}"
7396
74-
75-
# format-overwrite in the context of a ProductList for the relation-field "products"
76-
Pimcore\Model\DataObject\ProductList::products:
77-
patternOverwrites:
78-
# both classes are extending the Pimcore\Model\DataObject\Product so we still can overwrite the "Product" pattern.
79-
Pimcore\Model\DataObject\BasicProduct: "#{id} {name}"
80-
Pimcore\Model\DataObject\PremiumProduct: "#{id} {name} (premium-only!)"
97+
98+
# format-overwrite in the context of a ProductList for the relation-field "products"
99+
Pimcore\Model\DataObject\ProductList::products:
100+
patternOverwrites:
101+
# both classes are extending the Pimcore\Model\DataObject\Product so we still can overwrite the "Product" pattern.
102+
Pimcore\Model\DataObject\BasicProduct: "#{id} {name}"
103+
Pimcore\Model\DataObject\PremiumProduct: "#{id} {name} (premium-only!)"
81104
```
82105

83-
While the product will be formatted like ``Sneakers 19.99EUR`` in all relation-fields, the ProductList-Class will show them like ``#13 - Sneakers`` or ``#13 - Sneakers (premium-only!)``, based on the product class.
106+
While the product will be formatted like ``Sneakers 19.99EUR`` in all relation-fields, the ProductList-Class will show
107+
them like ``#13 - Sneakers`` or ``#13 - Sneakers (premium-only!)``, based on the product class.
108+
109+
### Formatting documents and assets
110+
111+
```yaml
112+
basilicom_path_formatter:
113+
pattern:
114+
Pimcore\Model\Asset: "{id} {key}"
115+
Pimcore\Model\Document: "{id} {key}"
116+
117+
Pimcore\Model\DataObject\Car::files:
118+
patternOverwrites:
119+
Pimcore\Model\Asset: "{key}"
120+
Pimcore\Model\Document: "{key}"
121+
```
84122
85123
## Additional features
86124
125+
### Toggle inherited values in DataObjects
126+
127+
Inherited values from DataObjects will be used by default. In order to avoid this, just disable the configuration:
128+
129+
```
130+
basilicom_path_formatter:
131+
enable_inheritance: true|false # default true
132+
```
133+
87134
### Showing images
88-
As soon as you reference a property in the pattern, which is a ``Pimcore\ModelAsset\Image``, it will be rendered as small preview in the relation-list.
135+
136+
As soon as you reference a property in the pattern, which is a ``Pimcore\ModelAsset\Image``, it will be rendered as
137+
small preview in the relation-list.
89138
This feature can be disabled by setting the value of ``enable_asset_preview`` to ``false``.
90139
91140
```

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020
}
2121
],
2222
"config": {
23-
"sort-packages": true
23+
"sort-packages": true,
24+
"allow-plugins": {
25+
"ocramius/package-versions": true
26+
}
2427
},
2528
"require": {
2629
"php": ">=7.3",
27-
"pimcore/pimcore": ">=6.0"
30+
"pimcore/pimcore": ">=6.0 < 10"
2831
},
2932
"suggest": {},
3033
"require-dev": {

0 commit comments

Comments
 (0)