Skip to content

Commit

Permalink
Update bundle for Contao 5
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Feb 2, 2024
1 parent 7f09c8e commit 1b470d5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 50 deletions.
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ indent_size = 4
[*.html5]
indent_style = space
indent_size = 2
insert_final_newline = false

[*.md]
trim_trailing_whitespace = false
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push: ~
pull_request: ~

permissions: read-all

jobs:
ecs:
name: build-tools
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, pcre, pdo_mysql, zlib
coverage: none

- name: Checkout
uses: actions/checkout@v3

- name: Install the dependencies
run: |
composer install --no-interaction --no-progress
- name: Run all build-tools to validate code
run: composer run build-tools
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/vendor/
composer.lock
/vendor
/composer.lock
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 terminal42 gmbh
Copyright (c) 2024 terminal42 gmbh

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
13 changes: 4 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"authors": [
{
"name": "terminal42 gmbh",
"homepage": "http://www.terminal42.ch"
"homepage": "https://www.terminal42.ch"
}
],
"funding": [
Expand All @@ -26,12 +26,12 @@
"forum": "https://community.contao.org"
},
"require": {
"php": "^7.4 || ^8.0",
"contao/core-bundle": "^4.9"
"php": "^8.1",
"contao/core-bundle": "^4.13 || ^5.0"
},
"require-dev": {
"contao/manager-plugin": "^2.0",
"contao/easy-coding-standard": "^3.0"
"terminal42/contao-build-tools": "dev-main"
},
"conflict": {
"contao/manager-plugin": "<2.0 || >=3.0"
Expand All @@ -43,10 +43,5 @@
},
"extra": {
"contao-manager-plugin": "Terminal42\\RootProtectionBundle\\ContaoManager\\Plugin"
},
"scripts": {
"cs-fixer": [
"vendor/bin/ecs check src/ --fix --ansi"
]
}
}
33 changes: 10 additions & 23 deletions contao/dca/tl_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,33 @@

use Contao\CoreBundle\DataContainer\PaletteManipulator;

$paletteManipulator = PaletteManipulator::create()
PaletteManipulator::create()
->addLegend('rootProtection_legend', 'publish_legend', PaletteManipulator::POSITION_BEFORE)
->addField('rootProtection', 'rootProtection_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('root', 'tl_page')
->applyToPalette('rootfallback', 'tl_page')
;

$GLOBALS['TL_DCA']['tl_page']['palettes']['__selector__'][] = 'rootProtection';

$GLOBALS['TL_DCA']['tl_page']['subpalettes']['rootProtection'] = 'rootProtectionUsername,rootProtectionPassword';

$GLOBALS['TL_DCA']['tl_page']['fields']['rootProtection'] = [
'label' => &$GLOBALS['TL_LANG']['tl_page']['rootProtection'],
'exclude' => true,
'exclude' => true,
'inputType' => 'checkbox',
'eval' => [
'tl_class' => 'w50',
'submitOnChange' => true,
],
'sql' => "char(1) NOT NULL default ''",
'eval' => ['tl_class' => 'w50', 'submitOnChange' => true],
'sql' => "char(1) NOT NULL default ''",
];

$GLOBALS['TL_DCA']['tl_page']['fields']['rootProtectionUsername'] = [
'label' => &$GLOBALS['TL_LANG']['tl_page']['rootProtectionUsername'],
'exclude' => true,
'exclude' => true,
'inputType' => 'text',
'eval' => [
'tl_class' => 'clr w50',
'mandatory' => true,
],
'sql' => "varchar(255) NOT NULL default ''",
'eval' => ['tl_class' => 'clr w50', 'mandatory' => true],
'sql' => "varchar(255) NOT NULL default ''",
];

$GLOBALS['TL_DCA']['tl_page']['fields']['rootProtectionPassword'] = [
'label' => &$GLOBALS['TL_LANG']['tl_page']['rootProtectionPassword'],
'exclude' => true,
'exclude' => true,
'inputType' => 'text',
'eval' => [
'tl_class' => 'w50',
'mandatory' => true,
],
'sql' => "varchar(255) NOT NULL default ''",
'eval' => ['tl_class' => 'w50', 'mandatory' => true],
'sql' => "varchar(255) NOT NULL default ''",
];
3 changes: 0 additions & 3 deletions ecs.php

This file was deleted.

17 changes: 6 additions & 11 deletions src/EventListener/RequireAuthenticationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@

namespace Terminal42\RootProtectionBundle\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\CoreBundle\Exception\ResponseException;
use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\PageModel;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

/**
* @Hook("getPageLayout")
*/
#[AsHook('getPageLayout')]
final class RequireAuthenticationListener
{
private ContaoFramework $framework;
private RequestStack $requestStack;

public function __construct(ContaoFramework $framework, RequestStack $requestStack)
{
$this->framework = $framework;
$this->requestStack = $requestStack;
public function __construct(
private readonly ContaoFramework $framework,
private readonly RequestStack $requestStack,
) {
}

public function __invoke(PageModel $page): void
Expand Down

0 comments on commit 1b470d5

Please sign in to comment.