Skip to content

Commit 42fbd23

Browse files
First version including basic formatting by only one pattern and unit tests
0 parents  commit 42fbd23

File tree

18 files changed

+9856
-0
lines changed

18 files changed

+9856
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
vendor
3+
.phpunit*
4+
_output

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile

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

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Basilicom Extended Path Formatter Bundle for Pimcore
2+
3+
###How it works
4+
This plugin provides a custom Pimcore path formatter as well as a simple, yaml-file-based configuration for the printed path for multi-relation-fields.
5+
6+
###Usage
7+
Add ``@Basilicom\PathFormatterBundle\DependencyInjection\BasilicomPathFormatter`` to the Formatter-Field in the relation-fieldType.
8+
**Note:** The ``@`` is important, as the formatter is registered as a service, including dependency injection.
9+
10+
Configure the pathformatter in your ``config.yml`` by using the first-level class-property-names in camelcase and between ``{`` and ``}``. The key between the braces will be used to call data object getters.
11+
If no getter exists for the property, the pattern-part will stay untouched.
12+
13+
As soon as a class property is a ``Pimcore\ModelAsset\Image`` it will be visible as small preview in the relation-list.
14+
15+
####Example
16+
app/config/config.yml
17+
```
18+
basilicom_path_formatter:
19+
pattern: "{logo} {identifier}"
20+
```
21+
22+
var/classes/DataObject/Client.php
23+
```
24+
class Client extends Concrete
25+
{
26+
protected $o_classId = "1";
27+
protected $o_className = "Client";
28+
protected $identifier;
29+
protected $logo;
30+
31+
/**
32+
* Get identifier
33+
*
34+
* @return string
35+
*/
36+
public function getIdentifier()
37+
{
38+
// ...
39+
}
40+
41+
/**
42+
* Get logo
43+
*
44+
* @return \Pimcore\Model\Asset\Image
45+
*/
46+
public function getLogo()
47+
{
48+
// ...
49+
}
50+
}
51+
```
52+
53+
### Todos
54+
- allow different patterns for different classes like e.g.:
55+
```
56+
basilicom_path_formatter:
57+
pattern:
58+
Pimcore\Model\DataObject\Client: "{logo} {identifier}"
59+
Pimcore\Model\DataObject\Product: "{price}{unit}"
60+
```
61+
- add button to relation-fields to prefill the formatter class
62+
- implement helper methods for simple string modifications
63+
- allow output of nested properties like ``{productImage.fullPath}``

composer.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "basilicom/path-formatter",
3+
"license": "GPL-3.0-or-later",
4+
"type": "pimcore-bundle",
5+
"description": "This bundle provides path formatter pattern configuration for Pimcore DataObjects in multi-relation.",
6+
"keywords": [
7+
"pimcore",
8+
"path formatter",
9+
"pathformatter"
10+
],
11+
"homepage": "https://basilicom.de",
12+
"authors": [
13+
{
14+
"name": "Alexander Heidrich",
15+
"email": "[email protected]"
16+
},
17+
{
18+
"name": "Basilicom GmbH",
19+
"homepage": "https://basilicom.de"
20+
}
21+
],
22+
"config": {
23+
"sort-packages": true
24+
},
25+
"require": {
26+
"php": ">=7.3",
27+
"pimcore/pimcore": ">=6.0 <7.0"
28+
},
29+
"suggest": {},
30+
"require-dev": {
31+
"phpunit/phpunit": "^8.5"
32+
},
33+
"autoload": {
34+
"psr-4": {
35+
"Basilicom\\PathFormatterBundle\\": "./src/"
36+
},
37+
"exclude-from-classmap": [
38+
"tests"
39+
]
40+
},
41+
"autoload-dev": {
42+
"psr-4": {
43+
"Basilicom\\PathFormatterBundle\\Fixtures\\": "tests/fixtures"
44+
}
45+
},
46+
"extra": {
47+
"pimcore": {
48+
"bundles": [
49+
"Basilicom\\PathFormatterBundle\\BasilicomPathFormatterBundle"
50+
]
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)