-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 76e303b
Showing
36 changed files
with
2,531 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Pimcore CustomTwigBundle | ||
|
||
A collection of twig Extensions/Filters and Tests for Pimcore 11. | ||
|
||
- [Twig Extensions](docs/twig-extensions.md) | ||
- [Twig Filters](docs/twig-filters.md) | ||
- [Twig Tests](docs/twig-tests.md) | ||
- [Twig Statements](docs/twig-statements.md) | ||
|
||
### Installation | ||
|
||
```php | ||
"require": { | ||
"serge0design/pimcore-custom-twig": "^1.0", | ||
} | ||
``` | ||
- Execute: $ `composer require serge0design/pimcore-custom-twig` | ||
|
||
Add Bundle to `bundles.php`: | ||
```php | ||
return [ | ||
SergeDesign\PimcoreCustomTwigBundle\PimcoreCustomTwigBundle::class => ['all' => true], | ||
]; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"name": "serge0design/pimcore-custom-twig", | ||
"license": "GPL-3.0-or-later", | ||
"type": "pimcore-bundle", | ||
"keywords": [ | ||
"pimcore", | ||
"twig", | ||
"Filter", | ||
"Extension", | ||
"Test" | ||
], | ||
"description": "A collection of twig Extensions/Filters and Tests for Pimcore 11.", | ||
"homepage": "https://github.com/serge0design/pimcore-custom-twig.git", | ||
"authors": [ | ||
{ | ||
"name": "serge.design - Serge", | ||
"email": "github@serge.design", | ||
"homepage": "https://serge-design.ch", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"SergeDesign\\PimcoreCustomTwigBundle\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"pimcore": { | ||
"bundles": [ | ||
"SergeDesign\\PimcoreCustomTwigBundle\\PimcoreCustomTwigBundle" | ||
] | ||
} | ||
}, | ||
"require": { | ||
"ext-intl": "*", | ||
"ext-mbstring": "*", | ||
"pimcore/pimcore": "^v11.1.0", | ||
"symfony/ux-twig-component": "^2.7", | ||
"twig/extra-bundle": "^3.5", | ||
"twig/string-extra": "^3.5" | ||
}, | ||
"require-dev": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
imports: | ||
- { resource: twig/components.yml} | ||
- { resource: twig/extensions.yml } | ||
- { resource: twig/filters.yml } | ||
- { resource: twig/testing.yml } | ||
- { resource: twig/statements.yml } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Extension\TwigBootstrapSvgIcon: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Extension\TwigEditmodeLinkToObject: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Extension\TwigLanguageSwitcher: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Extension\TwigQrCode: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Extension\TwigSvgFun: | ||
tags: [ 'twig.extension' ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigArrayFilters: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigDateDiff: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigFileGetContents: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigFormatPrice: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigHrefFilters: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigImages: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigStringFilters: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigTextFilters: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Filter\TwigUnixToTime: | ||
tags: [ 'twig.extension' ] | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Statements\TwigSwitch: | ||
tags: [ 'twig.extension' ] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Test\TwigTests: | ||
tags: [ 'twig.extension' ] | ||
|
||
SergeDesign\PimcoreCustomTwigBundle\Twig\Test\TwigBundleChecker: | ||
tags: [ 'twig.extension' ] | ||
arguments: | ||
- '@service_container' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Twig Extension Examples | ||
|
||
TwigBootstrapSvgIcon: | ||
|
||
``` | ||
{{ twigExtensionBootstrapSvgIcon('bootstrap', 'blue', 1.6) }} | ||
``` | ||
|
||
TwigEditmodeLinkToObject: | ||
|
||
``` | ||
{{ twigExtensionEditmodeLinkToObject(object.id) }} | ||
``` | ||
|
||
TwigLanguageSwitcher: | ||
|
||
``` | ||
{% for key, lang in twigExtensionLocalizedLinks(document) %} | ||
<li {{ ( app.request.locale == key ? 'class="active"' : '') }}> | ||
<a href="{{ lang.link }}"> | ||
<img class="language-switcher-img" | ||
src="{{ twigExtensionLanguageFlag(key) }}" | ||
height="20" | ||
width="25"> | ||
{{ lang.text }} | ||
</a> | ||
{% endfor %} | ||
``` | ||
|
||
TwigQrCode: | ||
|
||
``` | ||
{{ twigExtensionQrImage('string' ,200 ,25 ,[0,0,0] ,[255,255,255] ) }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
## Twig Filter Examples | ||
|
||
twigFilterArrayFlip: | ||
Exchanges all keys with their associated values in an array | ||
|
||
``` | ||
{% for item in array|twigFilterArrayFlip %} | ||
{{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
twigFilterArrayReverse: | ||
Return an array with elements in reverse order | ||
|
||
``` | ||
{% for item in array|twigFilterArrayReverse %} | ||
{{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
twigFilterArrayShuffle | ||
Return an array with elements in shuffled order | ||
|
||
``` | ||
{% for item in array|twigFilterArrayShuffle %} | ||
{{ item }} | ||
{% endfor %} | ||
``` | ||
|
||
twigFilterPassedTimeToNow | ||
usable for logins, orders, blogs, etc | ||
Outputs something like: Last Loggin ( 1day ago ) | ||
|
||
``` | ||
{% set unixTimestamp = dateField|date('U') %} | ||
{{ unixTimestamp|twigFilterPassedTimeToNow }} | ||
``` | ||
|
||
twigFilterFileGetContents | ||
|
||
``` | ||
{{ svgImagePath|twigFilterFileGetContents }} | ||
``` | ||
|
||
#### Image | ||
|
||
twigFilterImgThumbnail | ||
|
||
``` | ||
{{ pimcoreImage|twigFilterImgThumbnail('thumbnailName', 'cssClass', 'altText', {"data-attr": "value"}) }} | ||
``` | ||
|
||
twigFilterImgThumbConfig | ||
|
||
``` | ||
{{ pimcoreImage|twigFilterImgThumbConfig('cssClass', 'altText', 200, 200, 100, 'png') }} | ||
``` | ||
|
||
twigFilterCssBgImg | ||
Output inline Code: style="background-image: url('..'); | ||
|
||
``` | ||
{{ pimcoreImage|twigFilterCssBgImg('thumbnailName') }} | ||
``` | ||
|
||
#### String | ||
|
||
twigFilterGetMd5 | ||
|
||
``` | ||
{{ "string"|twigFilterGetMd5 }} | ||
``` | ||
|
||
twigFilterGetUniqid | ||
|
||
``` | ||
{{ "string"|twigFilterGetUniqid }} | ||
``` | ||
|
||
twigFilterStringNormalizer | ||
|
||
``` | ||
{{ "String"|twigFilterStringNormalizer }} | ||
``` | ||
|
||
twigFilterStrToLower | ||
|
||
``` | ||
{{ "String"|twigFilterStrToLower }} | ||
``` | ||
|
||
twigFilterTruncate | ||
|
||
``` | ||
{{ "string"|twigFilterTruncate(120, false, '...') }} | ||
``` | ||
|
||
twigFilterWordwrap | ||
|
||
``` | ||
{{ "string"|twigFilterWordwrap(60 ,'<br>', false) }} | ||
``` | ||
|
||
#### Links | ||
|
||
twigFilterHrefUrl | ||
|
||
``` | ||
{{ "https://url.com/"|twigFilterHrefUrl }} | ||
``` | ||
|
||
twigFilterHrefEmail | ||
|
||
``` | ||
{{ emailAddress|twigFilterHrefEmail('cssClass','subjectText', 'bodyText', 'ccEmail', 'bccEmail') }} | ||
``` | ||
|
||
twigFilterHrefPhone | ||
|
||
``` | ||
{{ href|twigFilterHrefPhone }} | ||
``` | ||
|
||
twigFilterHrefWhatsApp | ||
|
||
``` | ||
{{ href|twigFilterHrefWhatsApp }} | ||
``` | ||
|
||
twigFilterHrefSocialMedia | ||
based on Bootstrap Icons: https://icons.getbootstrap.com/ | ||
|
||
``` | ||
{{ href|twigFilterHrefSocialMedia }} | ||
``` | ||
|
||
#### Time | ||
|
||
twigFilterUnixTimestampToTime | ||
|
||
``` | ||
{{ unixTimestamp|twigFilterUnixTimestampToTime }} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## Twig Statement Examples | ||
|
||
TwigSwitch | ||
|
||
``` | ||
{% set item = 'item2' %} | ||
{% switch item %} | ||
{% case 'item' %} | ||
<p>item is "value1"</p> | ||
{% case 'item2' %} | ||
<p>item is "value2"</p> | ||
{% case 'item3' %} | ||
<p>item is "value3"</p> | ||
{% default %} | ||
<p>item is something else</p> | ||
{% endswitch %} | ||
``` |
Oops, something went wrong.