diff --git a/.composer-require-checker.json b/.composer-require-checker.json new file mode 100644 index 0000000..c11ac16 --- /dev/null +++ b/.composer-require-checker.json @@ -0,0 +1,10 @@ +{ + "symbol-whitelist": [ + "null", "true", "false", + "static", "self", "parent", + "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", + "Contao\\ManagerPlugin\\Bundle\\BundlePluginInterface", + "Contao\\ManagerPlugin\\Bundle\\Parser\\ParserInterface", + "Contao\\ManagerPlugin\\Bundle\\Config\\BundleConfig" + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..37096d0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[{*.(xlf,xml,html5,twig,json,js,vue}] +indent_style = space +indent_size = 2 + +[*.php] +indent_style = space +indent_size = 4 +max_line_length = 120 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4c95bff --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text-auto + +# Configuration +.editorconfig export-ignore +.gitattributes export-ignore +.gitignore export-ignore +.phpcq.lock export-ignore +.phpcq.yaml.dist export-ignore +companion.json export-ignore +composer.lock -diff +phpcs.xml.dist export-ignore +psalm.xml export-ignore +rector.php export-ignore + +# PHP files +*.php text eol=lf diff=php diff --git a/.github/workflows/diagnostics.yml b/.github/workflows/diagnostics.yml new file mode 100644 index 0000000..2321a8d --- /dev/null +++ b/.github/workflows/diagnostics.yml @@ -0,0 +1,76 @@ +name: Code Quality Diagnostics + +on: + pull_request: + push: + branches: + - master + - develop + +jobs: + build: + runs-on: ubuntu-latest + + name: PHP ${{ matrix.php }} + + strategy: + fail-fast: false + matrix: + include: + - php: 8.2 + phpcq_install: 'update' + - php: 8.3 + phpcq_install: 'update' + + steps: + - name: Pull source + uses: actions/checkout@v4 + + - name: Setup PHP with PECL extension + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + + - name: Cache composer cache directory + uses: actions/cache@v1 + env: + cache-name: composer-cache-dir-${{ matrix.php }} + with: + path: ~/.cache/composer + key: ${{ runner.os }}-build-${{ env.cache-name }} + + - name: Cache vendor directory + uses: actions/cache@v3 + env: + cache-name: vendor-${{ matrix.php }} + with: + path: vendor + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + + - name: Cache phpcq directory + uses: actions/cache@v3 + env: + cache-name: phpcq-${{ matrix.php }} + with: + path: .phpcq + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.phpcq.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + + - name: Install composer dependencies + run: composer install + + - name: Install phpcq toolchain + run: ./vendor/bin/phpcq ${{ matrix.phpcq_install }} -v + + - name: Run tests + run: ./vendor/bin/phpcq run -v -o github-action -o default --threshold=info + + - name: Upload build directory to artifact + uses: actions/upload-artifact@v4 + if: ${{ success() }} || ${{ failure() }} + with: + name: phpcq-builds-php-${{ matrix.php }} + path: .phpcq/build/ diff --git a/.gitignore b/.gitignore index 0a8dbf1..d9af09f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -/* -!/.gitignore -!/.gitattributes -!/contao-module/ -!/dev/ -!/src/ -!/CHANGELOG.md -!/README.md -!/composer.json +# Companion +/.env.companion + +# Composer +/composer.lock +/vendor + +# PHPCQ +/.phpcq +/.phpcq.yaml +/.phpcs-cache diff --git a/.phpcq.lock b/.phpcq.lock new file mode 100644 index 0000000..2851d34 --- /dev/null +++ b/.phpcq.lock @@ -0,0 +1 @@ +{"plugins":{"composer-normalize":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-normalize/composer-normalize-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-json":"*"},"tool":{"composer-normalize":"^2.1"}},"checksum":{"type":"sha-512","value":"d9abda440b85d501c58abf9c81bf76f417594b397129215ffa8b777e9bb5e5eda37d7661d661db3c8d11c24f20345bc6fbe56f013b3b9435d459d2b94f086e0f"},"tools":{"composer-normalize":{"version":"2.43.0","url":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar","requirements":{"php":{"php":"~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-json":"*"}},"checksum":null,"signature":"https://github.com/ergebnis/composer-normalize/releases/download/2.43.0/composer-normalize.phar.asc"}},"composerLock":null},"composer-require-checker":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/composer-require-checker/composer-require-checker-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0"},"tool":{"composer-require-checker":"^3.8 || ^4.0"}},"checksum":{"type":"sha-512","value":"d5415bddfe024c5749d894034583882aee4e5c3e1087815d9fdd81cb5e71630f631a0e35de0ff84b97fbbf738c16ece5f83bd8c00695913eb846aa6f04577dc2"},"tools":{"composer-require-checker":{"version":"4.12.0","url":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.12.0/composer-require-checker.phar","requirements":{"php":{"php":"~8.2.0 || ~8.3.0 || ~8.4.0","ext-phar":"*"}},"checksum":null,"signature":"https://github.com/maglnet/ComposerRequireChecker/releases/download/4.12.0/composer-require-checker.phar.asc"}},"composerLock":null},"phpcpd":{"api-version":"1.0.0","version":"1.1.1.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcpd/phpcpd-1.1.1.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcpd":"^6.0"}},"checksum":{"type":"sha-512","value":"1189ce0bf3fade4cb4241f1d96f915ef8fc7651f4450dc79fdf464ee3d6be3009316f0d423ce2d4af9d76ad50807b7fdf4d77bfa6d9ee2c91d6eda32ea214433"},"tools":{"phpcpd":{"version":"6.0.3","url":"https://phar.phpunit.de/phpcpd-6.0.3.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*"}},"checksum":{"type":"sha-256","value":"2cbaea7cfda1bb4299d863eb075e977c3f49055dd16d88529fae5150d48a84cb"},"signature":"https://phar.phpunit.de/phpcpd-6.0.3.phar.asc"}},"composerLock":null},"phploc":{"api-version":"1.0.0","version":"1.0.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phploc/phploc-1.0.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*","ext-json":"*"},"tool":{"phploc":"^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0"}},"checksum":{"type":"sha-512","value":"f67b02d494796adf553cb3dd13ec06c1cb8e53c799954061749424251379541637538199afb3afa3c7a01cabd1cb6f1c53eb621f015dff9644c6c7cbf10c56d1"},"tools":{"phploc":{"version":"7.0.2","url":"https://phar.phpunit.de/phploc-7.0.2.phar","requirements":{"php":{"php":">=7.3","ext-dom":"*","ext-json":"*"}},"checksum":{"type":"sha-256","value":"3d59778ec86faf25fd00e3a329b2f9ad4a3c751ca91601ea7dab70f887b0bf46"},"signature":"https://phar.phpunit.de/phploc-7.0.2.phar.asc"}},"composerLock":null},"phpmd":{"api-version":"1.0.0","version":"1.0.2.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpmd/phpmd-1.0.2.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpmd":"^2.6.1"}},"checksum":{"type":"sha-512","value":"f22280a6dec8dbdd2ec1d83b294f23237fe32c34f4a298e52038e0a7a0074d541635b2b488b1a6098a42d8418a6cd8eb804406ea82b91e362be2b5d11a0915b0"},"tools":{"phpmd":{"version":"2.15.0","url":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar","requirements":{"php":{"php":">=5.3.9","ext-xml":"*"}},"checksum":null,"signature":"https://github.com/phpmd/phpmd/releases/download/2.15.0/phpmd.phar.asc"}},"composerLock":null},"psalm":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/psalm/psalm-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.4 || ^8.0","ext-dom":"*"},"tool":{"psalm":"^3.0 || ^4.0 || ^5.0"}},"checksum":{"type":"sha-512","value":"4a550c9226d7bca582d7c10bd87cce01190c96398936b1613421640c83df62ed1c6e0d44c1b39635414ea8cf4a892a6458d27590793238add24e7cb5547e6ffd"},"tools":{"psalm":{"version":"5.26.1","url":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar","requirements":{"php":{"php":"^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0","ext-SimpleXML":"*","ext-ctype":"*","ext-dom":"*","ext-json":"*","ext-libxml":"*","ext-mbstring":"*","ext-tokenizer":"*"}},"checksum":null,"signature":"https://github.com/vimeo/psalm/releases/download/5.26.1/psalm.phar.asc"}},"composerLock":null},"phpcs":{"api-version":"1.0.0","version":"1.2.0.0","type":"php-file","url":"https://phpcq.github.io/repository/plugin/phpcs/phpcs-1.2.0.0.php","signature":null,"requirements":{"php":{"php":"^7.3 || ^8.0","ext-dom":"*"},"tool":{"phpcs":"^3.0 || ^2.0","phpcbf":"^3.0 || ^2.0"}},"checksum":{"type":"sha-512","value":"b6ed00306e76068a6af5e3b1dec837724f9e1900ef1049ce88e7ce195b0583524ca33a73613fba13244307a7ca853b6ddaa14ded69f651c3f184ac130bd1aaad"},"tools":{"phpcs":{"version":"3.10.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcs.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcs.phar.asc"},"phpcbf":{"version":"3.10.3","url":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcbf.phar","requirements":{"php":{"php":">=5.4.0","ext-simplexml":"*","ext-tokenizer":"*","ext-xmlwriter":"*"}},"checksum":null,"signature":"https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/download/3.10.3/phpcbf.phar.asc"}},"composerLock":null}},"tools":[]} \ No newline at end of file diff --git a/.phpcq.yaml.dist b/.phpcq.yaml.dist new file mode 100644 index 0000000..306a181 --- /dev/null +++ b/.phpcq.yaml.dist @@ -0,0 +1,84 @@ +phpcq: + repositories: + - 'https://phpcq.github.io/repository/repository.json' + directories: + - src + artifact: .phpcq/build + plugins: + composer-normalize: + version: ^1.0 + signed: false + composer-require-checker: + version: ^1.0 + signed: false + phpcpd: + version: ^1.1 + signed: false + phploc: + version: ^1.0 + signed: false + phpmd: + version: ^1.0 + signed: false + psalm: + version: ^1.0 + signed: false + phpcs: + version: ^1.0 + signed: false + trusted-keys: + - C00543248C87FB13 + - 033E5F8D801A2F8D + - D2CCAC42F6295E7D + - 4AA394086372C20A + - 9093F8B32E4815AA + - 8A03EA3B385DBAA1 + - 12CE0F1D262429A5 + - 31C7E470E2138192 + - 5E6DDE998AB73B8E + - A978220305CD5C32 +tasks: + fix: + - composer-normalize-fix + - phpcbf + verify: + - composer-normalize + - composer-require-checker + analyze: + - phpcpd + - phploc + - phpmd + - psalm + - phpcs + default: + - verify + - analyze + composer-normalize-fix: + config: + dry_run: false + ignore_output: + - '#> pre-command-run: Contao\\ManagerPlugin\\Composer\\ArtifactsPlugin->preCommandRun#' + - '#Root package is not of type "project" or "contao-theme", we will not be installing Contao extensions.#' + plugin: composer-normalize + composer-normalize: + config: + ignore_output: + - '#> pre-command-run: Contao\\ManagerPlugin\\Composer\\ArtifactsPlugin->preCommandRun#' + - '#Root package is not of type "project" or "contao-theme", we will not be installing Contao extensions.#' + composer-require-checker: + config: + config_file: .composer-require-checker.json + phpcs: + config: + standard: ~ + standard_paths: + - ./vendor/slevomat/coding-standard + - ./vendor/doctrine/coding-standard/lib + phpcbf: + plugin: phpcs + config: + standard: ~ + standard_paths: + - ./vendor/slevomat/coding-standard + - ./vendor/doctrine/coding-standard/lib + fix: true diff --git a/README.md b/README.md index 7089ffc..233767d 100644 --- a/README.md +++ b/README.md @@ -267,8 +267,8 @@ If you prefer to install it manually, download the latest release here: https:// ## Compatibility -- min. Contao version: >= 3.5.0 -- max. Contao version: 4.* +- min. Contao version: ^4.9 +- PHP min. 7.4 || 8.0 ## Dependency diff --git a/companion.json b/companion.json new file mode 100644 index 0000000..9400782 --- /dev/null +++ b/companion.json @@ -0,0 +1,35 @@ +{ + "receipts": [ + "projects/contao-bundle/4.13-5.3" + ], + "config": { + "phpConstraint": "^8.2" + }, + "tools": { + "composer": { + "namespace": "Hofff\\Contao\\IconFont" + }, + "phpcq": { + "plugins": { + "phpunit": false, + "rector": false + }, + "presets": { + "composer-require-checker": { + "tasks": { + "composer-require-checker": { + "config":{ + "config_file": ".composer-require-checker.json" + } + } + } + } + } + }, + "psalm": { + "configuration": { + "errorLevel": "3" + } + } + } +} diff --git a/composer.json b/composer.json index 433d85b..bb55395 100644 --- a/composer.json +++ b/composer.json @@ -1,44 +1,64 @@ { - "name": "hofff/contao-iconfont", - "description": "Insert tag for Contao Open Source CMS to insert FontAwesome icons and individual icons", - "keywords": [ - "contao", - "icon", - "iconfont", - "FontAwesome" - ], - "type": "contao-module", - "license": "LGPL-3.0-or-later", - "homepage": "https://www.hofff.com", - "authors": [ - { - "name": "Nicky Hoff", - "homepage": "https://www.hofff.com", - "email": "nick@hofff.com", - "role": "Developer" - } - ], - "require": { - "php": "^5.6 || ^7.0", - "contao/core-bundle" : "^3.5 || ^4.4", - "contao-community-alliance/composer-plugin" : "^2.4 || ^3.0" - }, - "autoload": { - "psr-4": { - "Hofff\\Contao\\IconFont\\": "src/" - } - }, - "extra": { - "contao": { - "sources": { - "contao-module": "system/modules/hofff_iconfont" - } - }, - "branch-alias": { - "dev-develop": "2.2.x-dev", - "dev-master": "2.1.x-dev" - } - }, - "prefer-stable": true, - "minimum-stability": "dev" + "name": "hofff/contao-iconfont", + "description": "Insert tag for Contao Open Source CMS to insert FontAwesome icons and individual icons", + "license": "LGPL-3.0-or-later", + "type": "contao-bundle", + "keywords": [ + "contao", + "icon", + "iconfont", + "FontAwesome" + ], + "authors": [ + { + "name": "Nicky Hoff", + "email": "nick@hofff.com", + "homepage": "https://www.hofff.com", + "role": "Developer" + }, + { + "name": "David Molineus", + "email": "david@hofff.com", + "homepage": "https://www.hofff.com", + "role": "Developer" + } + ], + "homepage": "https://www.hofff.com", + "require": { + "php": "^8.2", + "contao/core-bundle": "^4.13 || ^5.3", + "symfony/config": "^5.4 || ^6.4", + "symfony/dependency-injection": "^5.4 || ^6.4", + "symfony/http-kernel": "^5.4 || ^6.4" + }, + "require-dev": { + "contao/manager-plugin": "^2.1", + "doctrine/coding-standard": "^12.0", + "phpcq/runner-bootstrap": "@dev" + }, + "conflict": { + "contao/manager-plugin": "<2.1 || >= 3.0" + }, + "autoload": { + "psr-4": { + "Hofff\\Contao\\IconFont\\": "src/" + } + }, + "config": { + "allow-plugins": { + "contao-community-alliance/composer-plugin": true, + "contao-components/installer": true, + "contao/manager-plugin": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "php-http/discovery": true + }, + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-develop": "3.0.x-dev", + "dev-master": "2.1.x-dev" + }, + "contao-manager-plugin": "Hofff\\Contao\\IconFont\\ContaoManager\\Plugin" + } } diff --git a/contao-module/config/autoload.ini b/contao-module/config/autoload.ini deleted file mode 100644 index cc8452d..0000000 --- a/contao-module/config/autoload.ini +++ /dev/null @@ -1,19 +0,0 @@ -;; -; List modules which are required to be loaded beforehand -;; -requires[] = "core" - -;; -; Configure what you want the autoload creator to register -;; -register_namespaces = true -register_classes = true -register_templates = true - -;; -; Override the default configuration for certain sub directories -;; -[vendor/*] -register_namespaces = false -register_classes = false -register_templates = false diff --git a/contao-module/config/config.php b/contao-module/config/config.php deleted file mode 100644 index d23add9..0000000 --- a/contao-module/config/config.php +++ /dev/null @@ -1,3 +0,0 @@ - + + + + + + + + + vendor/autoload.php + + + + + + src + + /src/Resources/contao/languages/* + + + + + + + + + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..38b25cc --- /dev/null +++ b/psalm.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ContaoManager/Plugin.php b/src/ContaoManager/Plugin.php new file mode 100644 index 0000000..2206340 --- /dev/null +++ b/src/ContaoManager/Plugin.php @@ -0,0 +1,24 @@ +setLoadAfter([ContaoCoreBundle::class]) + ->setReplace(['hofff_iconfont']), + ]; + } +} diff --git a/src/DependencyInjection/HofffContaoIconFontExtension.php b/src/DependencyInjection/HofffContaoIconFontExtension.php new file mode 100644 index 0000000..52cad3c --- /dev/null +++ b/src/DependencyInjection/HofffContaoIconFontExtension.php @@ -0,0 +1,21 @@ +load('services.xml'); + } +} diff --git a/src/EventListener/ReplaceInsertTagsListener.php b/src/EventListener/ReplaceInsertTagsListener.php new file mode 100644 index 0000000..ae40abc --- /dev/null +++ b/src/EventListener/ReplaceInsertTagsListener.php @@ -0,0 +1,162 @@ + '', + 'icon-far' => '', + 'icon-fal' => '', + 'icon-fab' => '', + 'icon' => '', + + // Icons mit fester Breite + 'icon-fas-fw' => '', + 'icon-far-fw' => '', + 'icon-fal-fw' => '', + 'icon-fab-fw' => '', + + // Icons im Textfluss (links) + 'icon-fas-left' => '', + 'icon-far-left' => '', + 'icon-fal-left' => '', + 'icon-fab-left' => '', + + // Icons im Textfluss (rechts) + 'icon-fas-right' => '', + 'icon-far-right' => '', + 'icon-fal-right' => '', + 'icon-fab-right' => '', + + // Icons mit Rahmen im Textfluss (links) + 'icon-fas-border-left' => '', + 'icon-far-border-left' => '', + 'icon-fal-border-left' => '', + 'icon-fab-border-left' => '', + + // Icons mit Rahmen im Textfluss (rechts) + 'icon-fas-border-right' => '', + 'icon-far-border-right' => '', + 'icon-fal-border-right' => '', + 'icon-fab-border-right' => '', + + // Icons drehend + 'icon-fas-spin' => '', + 'icon-far-spin' => '', + 'icon-fal-spin' => '', + 'icon-fab-spin' => '', + + // Icons pulsierend + 'icon-fas-pulse' => '', + 'icon-far-pulse' => '', + 'icon-fal-pulse' => '', + 'icon-fab-pulse' => '', + + // Icons rotieren um 90° im Uhrzeigersinn + 'icon-fas-rotate-90' => '', + 'icon-far-rotate-90' => '', + 'icon-fal-rotate-90' => '', + 'icon-fab-rotate-90' => '', + + // Icons rotieren um 180° im Uhrzeigersinn + 'icon-fas-rotate-180' => '', + 'icon-far-rotate-180' => '', + 'icon-fal-rotate-180' => '', + 'icon-fab-rotate-180' => '', + + // Icons rotieren um 270° im Uhrzeigersinn + 'icon-fas-rotate-270' => '', + 'icon-far-rotate-270' => '', + 'icon-fal-rotate-270' => '', + 'icon-fab-rotate-270' => '', + + // Icons horizontal spiegeln + 'icon-fas-flip-horizontal' => '', + 'icon-far-flip-horizontal' => '', + 'icon-fal-flip-horizontal' => '', + 'icon-fab-flip-horizontal' => '', + + // Icons vertikal spiegeln + 'icon-fas-flip-vertical' => '', + 'icon-far-flip-vertical' => '', + 'icon-fal-flip-vertical' => '', + 'icon-fab-flip-vertical' => '', + + // Icons vertikal & horizontal spiegeln + 'icon-fas-flip-both' => '', + 'icon-far-flip-both' => '', + 'icon-fal-flip-both' => '', + 'icon-fab-flip-both' => '', + + // Icons mit quadratischem Hintergrund + 'icon-fas-square' => '', + 'icon-far-square' => '', + 'icon-fal-square' => '', + 'icon-fab-square' => '', + + // Icons mit quadratischem Hintergrund - nur Umrandung + 'icon-fas-square-border' => '', + 'icon-far-square-border' => '', + 'icon-fal-square-border' => '', + 'icon-fab-square-border' => '', + + // Icons mit rundem Hintergrund + 'icon-fas-circle' => '', + 'icon-far-circle' => '', + 'icon-fal-circle' => '', + 'icon-fab-circle' => '', + + // Icons mit rundem Hintergrund - nur Umrandung + 'icon-fas-circle-border' => '', + 'icon-far-circle-border' => '', + 'icon-fal-circle-border' => '', + 'icon-fab-circle-border' => '', + + // Icons mit Verbotsschild (Farbe für .fa-ban muss per CSS gesetzt werden) + 'icon-fas-ban' => '' + . '', + 'icon-far-ban' => '' + . '', + 'icon-fal-ban' => '' + . '', + 'icon-fab-ban' => '' + . '', + ]; + + public function __invoke(string $tag): bool|string + { + $split = explode('::', $tag); + + if (isset($split[1], self::ICONS[$split[0]])) { + return sprintf(self::ICONS[$split[0]], $split[1]); + } + + return false; + } +} diff --git a/src/HofffContaoIconFontBundle.php b/src/HofffContaoIconFontBundle.php new file mode 100644 index 0000000..d8b736a --- /dev/null +++ b/src/HofffContaoIconFontBundle.php @@ -0,0 +1,11 @@ + - */ -class InsertTags -{ - /** - * @param string $tag - * @return bool|string - */ - public function hookReplaceInsertTags($tag) - { - $split = explode('::', $tag); - - // Icons Standard - if ($split[0] == 'icon-fas' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon' && isset($split[1])) { - return ''; } - - // Icons mit fester Breite - elseif ($split[0] == 'icon-fas-fw' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-fw' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-fw' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-fw' && isset($split[1])) { - return ''; } - - // Icons im Textfluss (links) - elseif ($split[0] == 'icon-fas-left' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-left' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-left' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-left' && isset($split[1])) { - return ''; } - - // Icons im Textfluss (rechts) - elseif ($split[0] == 'icon-fas-right' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-right' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-right' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-right' && isset($split[1])) { - return ''; } - - // Icons mit Rahmen im Textfluss (links) - elseif ($split[0] == 'icon-fas-border-left' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-border-left' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-border-left' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-border-left' && isset($split[1])) { - return ''; } - - // Icons mit Rahmen im Textfluss (rechts) - elseif ($split[0] == 'icon-fas-border-right' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-border-right' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-border-right' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-border-right' && isset($split[1])) { - return ''; } - - // Icons drehend - elseif ($split[0] == 'icon-fas-spin' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-spin' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-spin' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-spin' && isset($split[1])) { - return ''; } - - // Icons pulsierend - elseif ($split[0] == 'icon-fas-pulse' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-pulse' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-pulse' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-pulse' && isset($split[1])) { - return ''; } - - // Icons rotieren um 90° im Uhrzeigersinn - elseif ($split[0] == 'icon-fas-rotate-90' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-rotate-90' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-rotate-90' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-rotate-90' && isset($split[1])) { - return ''; } - - // Icons rotieren um 180° im Uhrzeigersinn - elseif ($split[0] == 'icon-fas-rotate-180' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-rotate-180' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-rotate-180' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-rotate-180' && isset($split[1])) { - return ''; } - - // Icons rotieren um 270° im Uhrzeigersinn - elseif ($split[0] == 'icon-fas-rotate-270' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-rotate-270' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-rotate-270' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-rotate-270' && isset($split[1])) { - return ''; } - - // Icons horizontal spiegeln - elseif ($split[0] == 'icon-fas-flip-horizontal' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-flip-horizontal' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-flip-horizontal' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-flip-horizontal' && isset($split[1])) { - return ''; } - - // Icons vertikal spiegeln - elseif ($split[0] == 'icon-fas-flip-vertical' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-flip-vertical' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-flip-vertical' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-flip-vertical' && isset($split[1])) { - return ''; } - - // Icons vertikal & horizontal spiegeln - elseif ($split[0] == 'icon-fas-flip-both' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-flip-both' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-flip-both' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-flip-both' && isset($split[1])) { - return ''; } - - // Icons mit quadratischem Hintergrund - elseif ($split[0] == 'icon-fas-square' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-square' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-square' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-square' && isset($split[1])) { - return ''; } - - // Icons mit quadratischem Hintergrund - nur Umrandung - elseif ($split[0] == 'icon-fas-square-border' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-square-border' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-square-border' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-square-border' && isset($split[1])) { - return ''; } - - // Icons mit rundem Hintergrund - elseif ($split[0] == 'icon-fas-circle' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-circle' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-circle' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-circle' && isset($split[1])) { - return ''; } - - // Icons mit rundem Hintergrund - nur Umrandung - elseif ($split[0] == 'icon-fas-circle-border' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-circle-border' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-circle-border' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-circle-border' && isset($split[1])) { - return ''; } - - // Icons mit Verbotsschild (Farbe für .fa-ban muss per CSS gesetzt werden) - elseif ($split[0] == 'icon-fas-ban' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-far-ban' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fal-ban' && isset($split[1])) { - return ''; } - elseif ($split[0] == 'icon-fab-ban' && isset($split[1])) { - return ''; } - - return false; - } -} diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml new file mode 100644 index 0000000..b58ffa8 --- /dev/null +++ b/src/Resources/config/services.xml @@ -0,0 +1,12 @@ + + + + + + + + +