Skip to content

Commit 6eb7047

Browse files
feature: option to enable/disable inheritance of dataobject values
1 parent 4237c54 commit 6eb7047

File tree

7 files changed

+81
-12277
lines changed

7 files changed

+81
-12277
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:8.1 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:8.1 install --ignore-platform-reqs --no-scripts

README.md

Lines changed: 59 additions & 38 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,7 +25,9 @@ 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
----------
@@ -28,92 +36,105 @@ While the product will be formatted like ``Sneakers 19.99EUR`` in all relation-f
2836

2937
| Bundle Version | PHP | Pimcore |
3038
|----------------|------|---------|
31-
| < 2.0 | ^7.3 | ^6.0 |
32-
| >= 2.0 | ^8.1 | ^10.0 |
33-
| >= 3.0 | ^8.1 | ^11.0 |
39+
| ^1.0 | ^7.3 | ^6.0 |
40+
| ^2.0 | ^8.0 | ^10.0 |
41+
| ^3.0 | ^8.1 | ^11.0 |
3442

3543
## Installation
36-
Install the bundle using ``composer require basilicom/pimcore-path-formatter-bundle``
44+
45+
Install the bundle using ``composer require basilicom/pimcore-path-formatter-bundle``
3746

3847
Execute ``bin/console pimcore:bundle:enable BasilicomPathFormatterBundle``
3948
**or**
4049
add the following lines to `AppKernel::registerBundlesToCollection()` (**recommended**)
50+
4151
```php
4252
if (class_exists('\\Basilicom\\PathFormatterBundle\\BasilicomPathFormatterBundle')) {
4353
$collection->addBundle(new \Basilicom\PathFormatterBundle\BasilicomPathFormatterBundle);
4454
}
4555
```
4656

4757
## Configuration
58+
4859
1. Add the ``basilicom_path_formatter`` key to your Pimcore ``app/config/config.yml``
4960
2. Configure a pattern by adding the full qualified dataObject class-name as key the pattern-string as value.
5061
Use class-property-names, accessible by public getter methods, surrounded by curly brackets.
51-
This also enables you to reference basic Pimcore ``Concrete``/``AbstractObject`` methods like:
52-
- ``fullPath`` for ``\Pimcore\Model\DataObject\AbstractObject::getFullPath())``
53-
- ``className`` for ``\Pimcore\Model\DataObject\AbstractObject::getClassName())``
54-
- ...
55-
56-
**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:**
5768
```
5869
basilicom_path_formatter:
5970
pattern:
6071
# output of e.g. "Product: Sneakers (/dataObject/Products/Sneakers)"
6172
6273
Pimcore\Model\DataObject\Product: "Product: {name} ({fullPath})"
6374
```
64-
**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.
6576
66-
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.
6779
**Note:** The ``@`` is important, as the formatter is registered as a service, including dependency injection.
68-
6980
7081
## Advanced configuration
71-
### Contextual pattern overwrites
72-
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.
7387
7488
**Example:**
89+
7590
```yaml
7691
# app/config/config.yml
7792
basilicom_path_formatter:
78-
pattern:
79-
# global product format
80-
Pimcore\Model\DataObject\Product: "{name} {price}{currency}"
93+
pattern:
94+
# global product format
95+
Pimcore\Model\DataObject\Product: "{name} {price}{currency}"
8196
82-
83-
# format-overwrite in the context of a ProductList for the relation-field "products"
84-
Pimcore\Model\DataObject\ProductList::products:
85-
patternOverwrites:
86-
# both classes are extending the Pimcore\Model\DataObject\Product so we still can overwrite the "Product" pattern.
87-
Pimcore\Model\DataObject\BasicProduct: "#{id} {name}"
88-
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!)"
89104
```
90105

91-
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.
92108

93109
### Formatting documents and assets
110+
94111
```yaml
95112
basilicom_path_formatter:
96-
pattern:
97-
Pimcore\Model\Asset: "{id} {key}"
98-
Pimcore\Model\Document: "{id} {key}"
99-
100-
Pimcore\Model\DataObject\Car::files:
101-
patternOverwrites:
102-
Pimcore\Model\Asset: "{key}"
103-
Pimcore\Model\Document: "{key}"
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}"
104121
```
105122
106123
## Additional features
107124
108125
### Toggle inherited values in DataObjects
126+
109127
Inherited values from DataObjects will be used by default. In order to avoid this, just disable the configuration:
128+
110129
```
111130
basilicom_path_formatter:
112131
enable_inheritance: true|false # default true
113132
```
114133
115134
### Showing images
116-
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.
117138
This feature can be disabled by setting the value of ``enable_asset_preview`` to ``false``.
118139
119140
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"suggest": {},
3333
"require-dev": {
34-
"phpunit/phpunit": "^8.5"
34+
"phpunit/phpunit": "^9.0"
3535
},
3636
"autoload": {
3737
"psr-4": {

0 commit comments

Comments
 (0)