Skip to content

Commit dfbed4c

Browse files
committed
Merge tag '2.2.0'
Stable release 2.2.0 This brings full Contao 4.9 support. Additionally there have been performance improvements and various bugfixes. - The optional custom icons are g-rendered as 16x16px thumbnails. - If the checkboxes are readonly, they are displayed in the list view, but have no toggle function - Widget as readonly now works correctly in the input mask
2 parents 2967e75 + ff37e4a commit dfbed4c

17 files changed

+170
-135
lines changed

.check-author.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ mapping:
88
'Andreas Isaak <info@andreas-isaak.de>': 'Andreas Isaak <andy.jared@googlemail.com>'
99
'Stefan Heimes <stefan_heimes@hotmail.com>': 'Stefan heimes <stefan_heimes@hotmail.com>'
1010
'Christopher Boelter <c.boelter@cogizz.de>': 'cogizz <c.boelter@cogizz.de>'
11+
'Ingolf Steinhardt <info@e-spin.de>':
12+
- 'xantippe <info@e-spin.de>'
13+
- 'zonky2 <info@e-spin.de>'
14+
- 'zonky <gitlab@e-spin.de>'
15+
- 'e-spin <gitlab@e-spin.de>'

.github/workflows/diagnostics.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: MetaModels attribute_checkbox
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- '**-translation'
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: [7.4]
15+
contao: [~4.9.0]
16+
17+
steps:
18+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Pull source
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
# see https://github.com/shivammathur/setup-php
24+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Setup PHP.
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
coverage: none
29+
30+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache composer cache directory
31+
uses: actions/cache@v1
32+
env:
33+
cache-name: composer-cache-dir
34+
with:
35+
path: ~/.cache/composer
36+
key: ${{ runner.os }}-build-${{ env.cache-name }}
37+
38+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Cache vendor directory
39+
uses: actions/cache@v1
40+
env:
41+
cache-name: composer-vendor
42+
with:
43+
path: vendor
44+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-build-${{ env.cache-name }}-
47+
48+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Install composer dependencies
49+
run: composer update --prefer-dist --no-interaction --no-suggest
50+
51+
- name: PHP ${{ matrix.php }} ${{ matrix.contao }} Run tests
52+
run: ant -keep-going

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.DS_Store
33
Thumbs.db
44

5-
# IDEs
5+
# IDEs
66
.buildpath
77
.project
88
.settings/
@@ -15,4 +15,6 @@ nbproject/
1515
vendor/
1616

1717
# build
18-
build/
18+
build/
19+
composer.lock
20+
.phpunit.result.cache

.travis.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build Status](https://travis-ci.org/MetaModels/attribute_checkbox.svg)](https://travis-ci.org/MetaModels/attribute_checkbox)
1+
[![Build Status](https://github.com/MetaModels/attribute_checkbox/actions/workflows/diagnostics.yml/badge.svg)](https://github.com/MetaModels/attribute_checkbox/actions)
22
[![Latest Version tagged](http://img.shields.io/github/tag/MetaModels/attribute_checkbox.svg)](https://github.com/MetaModels/attribute_checkbox/tags)
33
[![Latest Version on Packagist](http://img.shields.io/packagist/v/MetaModels/attribute_checkbox.svg)](https://packagist.org/packages/MetaModels/attribute_checkbox)
44
[![Installations via composer per month](http://img.shields.io/packagist/dm/MetaModels/attribute_checkbox.svg)](https://packagist.org/packages/MetaModels/attribute_checkbox)

composer.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"nontranslatable"
1010
],
1111
"type": "contao-bundle",
12-
"homepage": "http://now.metamodel.me/",
12+
"homepage": "https://now.metamodel.me/",
1313
"license": "LGPL-3.0-or-later",
1414
"authors": [
1515
{
1616
"name": "Christian Schiffler",
1717
"email": "c.schiffler@cyberspectrum.de",
18-
"homepage": "http://www.cyberspectrum.de",
18+
"homepage": "https://www.cyberspectrum.de",
1919
"role": "Developer"
2020
},
2121
{
@@ -27,17 +27,17 @@
2727
"support": {
2828
"email": "mail@metamodel.me",
2929
"issues": "https://github.com/MetaModels/attribute_checkbox/issues",
30-
"wiki": "http://de.contaowiki.org/MetaModels",
30+
"wiki": "https://de.contaowiki.org/MetaModels",
3131
"irc": "irc://irc.freenode.org/contao.mm",
3232
"source": "https://github.com/MetaModels/attribute_checkbox"
3333
},
3434
"require": {
35-
"php": "^7.1",
36-
"contao-community-alliance/dc-general": "^2.1.0",
37-
"contao/core-bundle": "^4.4.8",
38-
"metamodels/core": "^2.1",
39-
"symfony/dependency-injection": "^3.3 || ^4.0",
40-
"symfony/http-kernel": "^3.3 || ^4.0"
35+
"php": "^7.4",
36+
"contao-community-alliance/dc-general": "^2.2",
37+
"contao/core-bundle": "^4.9.0, <4.13.0",
38+
"metamodels/core": "^2.2",
39+
"symfony/dependency-injection": "^4.4.6",
40+
"symfony/http-kernel": "^4.4.13"
4141
},
4242
"require-dev": {
4343
"contao/manager-plugin": "^2.1",
@@ -60,10 +60,14 @@
6060
"extra": {
6161
"contao-manager-plugin": "MetaModels\\AttributeCheckboxBundle\\ContaoManager\\Plugin",
6262
"branch-alias": {
63-
"dev-master": "2.1.x-dev"
63+
"dev-feature/2.2.0": "2.2.x-dev"
6464
}
6565
},
6666
"config": {
67+
"allow-plugins": {
68+
"contao-components/installer": false,
69+
"contao/manager-plugin": false
70+
},
6771
"sort-packages": true
6872
}
6973
}

src/EventListener/BuildMetaModelOperationsListener.php

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* This file is part of MetaModels/attribute_checkbox.
55
*
6-
* (c) 2012-2019 The MetaModels team.
6+
* (c) 2012-2020 The MetaModels team.
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -15,7 +15,8 @@
1515
* @author Christopher Boelter <c.boelter@cogizz.de>
1616
* @author Sven Baumann <baumann.sv@gmail.com>
1717
* @author David Molineus <david.molineus@netzmacht.de>
18-
* @copyright 2012-2019 The MetaModels team.
18+
* @author Ingolf Steinhardt <info@e-spin.de>
19+
* @copyright 2012-2020 The MetaModels team.
1920
* @license https://github.com/MetaModels/attribute_checkbox/blob/master/LICENSE LGPL-3.0-or-later
2021
* @filesource
2122
*/
@@ -31,6 +32,7 @@
3132
use ContaoCommunityAlliance\DcGeneral\DataDefinition\Definition\View\ToggleCommandInterface;
3233
use MetaModels\Attribute\IAttribute;
3334
use MetaModels\AttributeCheckboxBundle\Attribute\Checkbox;
35+
use MetaModels\CoreBundle\Assets\IconBuilder;
3436
use MetaModels\DcGeneral\Events\MetaModel\BuildMetaModelOperationsEvent;
3537

3638
/**
@@ -45,14 +47,24 @@ class BuildMetaModelOperationsListener
4547
*/
4648
private $scopeMatcher;
4749

50+
/**
51+
* The icon builder.
52+
*
53+
* @var IconBuilder
54+
*/
55+
private $iconBuilder;
56+
4857
/**
4958
* CreatePropertyConditionListener constructor.
5059
*
5160
* @param RequestScopeDeterminator $scopeMatcher Request scope determinator.
61+
*
62+
* @param IconBuilder $iconBuilder The icon builder.
5263
*/
53-
public function __construct(RequestScopeDeterminator $scopeMatcher)
64+
public function __construct(RequestScopeDeterminator $scopeMatcher, IconBuilder $iconBuilder)
5465
{
5566
$this->scopeMatcher = $scopeMatcher;
67+
$this->iconBuilder = $iconBuilder;
5668
}
5769

5870
/**
@@ -66,7 +78,7 @@ public function __construct(RequestScopeDeterminator $scopeMatcher)
6678
* @SuppressWarnings(PHPMD.Superglobals)
6779
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
6880
*/
69-
private function buildCommand($attribute, array $propertyData)
81+
private function buildCommand(Checkbox $attribute, array $propertyData)
7082
{
7183
if ($attribute->get('check_listview') == 1) {
7284
$commandName = 'listviewtoggle_' . $attribute->getColName();
@@ -82,16 +94,18 @@ private function buildCommand($attribute, array $propertyData)
8294
$attribute->getName()
8395
)
8496
);
97+
8598
$extra = $toggle->getExtra();
8699
$extra['icon'] = 'visible.svg';
87100
$objIconEnabled = FilesModel::findByUuid($attribute->get('check_listviewicon'));
88101
$objIconDisabled = FilesModel::findByUuid($attribute->get('check_listviewicondisabled'));
89102

90-
if ($attribute->get('check_listview') == 1 && $objIconEnabled->path && $objIconDisabled->path) {
91-
$extra['icon'] = $objIconEnabled->path;
92-
$extra['icon_disabled'] = $objIconDisabled->path;
93-
} else {
94-
$extra['icon'] = 'visible.svg';
103+
if ($attribute->get('check_listview') == 1 && $objIconEnabled->path) {
104+
$extra['icon'] = $this->iconBuilder->getBackendIcon($objIconEnabled->path);
105+
}
106+
107+
if ($attribute->get('check_listview') == 1 && $objIconDisabled->path) {
108+
$extra['icon_disabled'] = $this->iconBuilder->getBackendIcon($objIconDisabled->path);
95109
}
96110

97111
$toggle->setToggleProperty($attribute->getColName());
@@ -114,7 +128,7 @@ private function buildCommand($attribute, array $propertyData)
114128
*
115129
* @return Contao2BackendViewDefinition
116130
*/
117-
protected function createBackendViewDefinition($container)
131+
protected function createBackendViewDefinition(ContainerInterface $container)
118132
{
119133
if ($container->hasDefinition(Contao2BackendViewDefinitionInterface::NAME)) {
120134
$view = $container->getDefinition(Contao2BackendViewDefinitionInterface::NAME);
@@ -142,9 +156,12 @@ public function handle(BuildMetaModelOperationsEvent $event)
142156
return;
143157
}
144158
$allProps = $event->getScreen()['properties'];
145-
$properties = \array_map(function ($property) {
146-
return ($property['col_name'] ?? null);
147-
}, $allProps);
159+
$properties = \array_map(
160+
function ($property) {
161+
return ($property['col_name'] ?? null);
162+
},
163+
$allProps
164+
);
148165
foreach ($event->getMetaModel()->getAttributes() as $attribute) {
149166
if (!$this->wantToAdd($attribute, $properties)) {
150167
continue;
@@ -153,6 +170,7 @@ public function handle(BuildMetaModelOperationsEvent $event)
153170
foreach ($allProps as $prop) {
154171
if ($prop['col_name'] === $attribute->getColName()) {
155172
$info = $prop;
173+
break;
156174
}
157175
}
158176

@@ -181,10 +199,10 @@ public function handle(BuildMetaModelOperationsEvent $event)
181199
*
182200
* @return bool
183201
*/
184-
private function wantToAdd($attribute, array $properties): bool
202+
private function wantToAdd(IAttribute $attribute, array $properties): bool
185203
{
186204
return ($attribute instanceof Checkbox)
187-
&& (($attribute->get('check_publish') === '1') || ($attribute->get('check_listview') === '1'))
188-
&& (\in_array($attribute->getColName(), $properties, true));
205+
&& (($attribute->get('check_publish') === '1') || ($attribute->get('check_listview') === '1'))
206+
&& (\in_array($attribute->getColName(), $properties, true));
189207
}
190208
}

src/EventListener/PublishedFilterSettingTypeRendererListener.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* This file is part of MetaModels/attribute_checkbox.
55
*
6-
* (c) 2012-2019 The MetaModels team.
6+
* (c) 2012-2022 The MetaModels team.
77
*
88
* For the full copyright and license information, please view the LICENSE
99
* file that was distributed with this source code.
@@ -13,7 +13,8 @@
1313
* @package MetaModels/attribute_checkbox
1414
* @author Christian Schiffler <c.schiffler@cyberspectrum.de>
1515
* @author David Molineus <david.molineus@netzmacht.de>
16-
* @copyright 2012-2019 The MetaModels team.
16+
* @author Ingolf Steinhardt <info@e-spin.de>
17+
* @copyright 2012-2022 The MetaModels team.
1718
* @license https://github.com/MetaModels/attribute_checkbox/blob/master/LICENSE LGPL-3.0-or-later
1819
* @filesource
1920
*/
@@ -26,6 +27,8 @@
2627

2728
/**
2829
* Handles rendering of model from tl_metamodel_filtersetting.
30+
*
31+
* @SuppressWarnings(PHPMD.LongClassName)
2932
*/
3033
class PublishedFilterSettingTypeRendererListener extends AbstractFilterSettingTypeRenderer
3134
{

0 commit comments

Comments
 (0)