-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
17 changed files
with
424 additions
and
20 deletions.
There are no files selected for viewing
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,94 @@ | ||
name: CI | ||
|
||
on: push | ||
|
||
jobs: | ||
check-codestyle: | ||
name: Check codestyle | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: bcmath, dom, fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, pcre, pdo_mysql, zip, zlib | ||
coverage: none | ||
|
||
env: | ||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install PHP dependencies | ||
run: composer install --no-interaction --no-progress | ||
|
||
- name: Check PHP codestyle | ||
run: | | ||
vendor-bin/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run -vvv --ansi | ||
- name: Run static analysis | ||
run: vendor-bin/phpstan/vendor/bin/phpstan analyze src/ --level max --memory-limit=-1 --ansi | ||
|
||
unit-tests: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: bcmath, dom, fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, pcre, pdo_mysql, zip, zlib | ||
coverage: none | ||
|
||
env: | ||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install the dependencies | ||
run: composer install --no-interaction --no-progress | ||
|
||
- name: Run unit tests | ||
run: vendor-bin/phpunit/vendor/bin/phpunit --colors=always | ||
|
||
check-composer-requirements: | ||
name: Check Composer requirements | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.1 | ||
extensions: bcmath, dom, fileinfo, filter, gd, hash, intl, json, mbstring, mysqli, pcre, pdo_mysql, zip, zlib | ||
coverage: none | ||
|
||
env: | ||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install the dependencies | ||
run: composer install --no-interaction --no-progress | ||
|
||
- name: Check the dependencies | ||
run: tools/require-checker/vendor/bin/composer-require-checker check --config-file=tools/require-checker/config.json composer.json --ansi | ||
|
||
security-check: | ||
name: PHP Security Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup cache | ||
uses: actions/cache@v2 | ||
id: cache-db | ||
with: | ||
path: ~/.symfony/cache | ||
key: db | ||
|
||
- name: Run security check | ||
uses: symfonycorp/security-checker-action@v3 |
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 |
---|---|---|
@@ -1,16 +1,6 @@ | ||
# OS | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# IDEs | ||
.buildpath | ||
.project | ||
.settings/ | ||
.build/ | ||
.idea/ | ||
|
||
# Composer | ||
vendor/ | ||
/vendor-bin/**/vendor | ||
/vendor/ | ||
/vendor-bin/*/vendor | ||
/vendor-bin/*/composer.lock | ||
.phpunit.result.cache | ||
composer.lock | ||
composer.phar |
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
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,3 @@ | ||
contao-backend-limited-width | ||
============================ | ||
Simply because https://github.com/contao/contao/pull/4552. |
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,22 @@ | ||
:root { | ||
--body-bg: #cfcfd3; | ||
--main-bg: #eaeaec; | ||
} | ||
|
||
html[data-color-scheme="dark"] { | ||
|
||
} | ||
|
||
body { | ||
background: var(--body-bg) !important; | ||
} | ||
|
||
#main { | ||
background: var(--main-bg) !important; | ||
} | ||
|
||
#container, | ||
#header { | ||
max-width:1440px; | ||
margin:0 auto; | ||
} |
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
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,7 @@ | ||
services: | ||
Oneup\ContaoBackendLimitedWidthBundle\EventListener\ParseTemplateListener: | ||
arguments: | ||
- '@security.helper' | ||
- '@contao.framework' | ||
tags: | ||
- { name: contao.hook, hook: parseTemplate } |
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
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" verbose="true"> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">src</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Oneup\ContaoBackendLimitedWidthBundle\EventListener; | ||
|
||
use Contao\BackendTemplate; | ||
use Contao\BackendUser; | ||
use Contao\Controller; | ||
use Contao\CoreBundle\Framework\ContaoFramework; | ||
use Contao\Template; | ||
use Symfony\Bundle\SecurityBundle\Security; | ||
|
||
final class ParseTemplateListener | ||
{ | ||
public function __construct( | ||
private readonly Security $security, | ||
private readonly ContaoFramework $contaoFramework, | ||
) { | ||
} | ||
|
||
public function __invoke(Template $template): void | ||
{ | ||
if (!$template instanceof BackendTemplate) { | ||
return; | ||
} | ||
|
||
if ('be_main' !== $template->getName() && !str_starts_with($template->getName(), 'be_main_')) { | ||
return; | ||
} | ||
|
||
$user = $this->security->getUser(); | ||
|
||
if (!$user instanceof BackendUser) { | ||
return; | ||
} | ||
|
||
if (false === (bool) $user->limitedWidth) { | ||
return; | ||
} | ||
|
||
/** @var Template $templateAdapter */ | ||
$templateAdapter = $this->contaoFramework->getAdapter(Template::class); | ||
|
||
/** @var Controller $controllerAdapter */ | ||
$controllerAdapter = $this->contaoFramework->getAdapter(Controller::class); | ||
|
||
$template->stylesheets .= $templateAdapter->generateStyleTag($controllerAdapter->addStaticUrlTo('bundles/oneupcontaobackendlimitedwidth/limited-width.min.css'), null, null); | ||
} | ||
} |
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
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Oneup\ContaoBackendLimitedWidthBundle\Tests\ContaoManager; | ||
|
||
use Contao\CoreBundle\ContaoCoreBundle; | ||
use Contao\ManagerPlugin\Bundle\Config\BundleConfig; | ||
use Contao\ManagerPlugin\Bundle\Parser\ParserInterface; | ||
use Oneup\ContaoBackendLimitedWidthBundle\ContaoManager\Plugin; | ||
use Oneup\ContaoBackendLimitedWidthBundle\OneupContaoBackendLimitedWidthBundle; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class PluginTest extends TestCase | ||
{ | ||
public function testGetsLoadedAfterCoreBundle(): void | ||
{ | ||
$plugin = new Plugin(); | ||
|
||
$bundles = $plugin->getBundles($this->createMock(ParserInterface::class)); | ||
|
||
self::assertCount(1, $bundles); | ||
|
||
/** @var BundleConfig $config */ | ||
$config = $bundles[0]; | ||
|
||
self::assertSame(OneupContaoBackendLimitedWidthBundle::class, $config->getName()); | ||
self::assertSame([ContaoCoreBundle::class], $config->getLoadAfter()); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/DependencyInjection/OneupContaoBackendLimitedWidthExtensionTest.php
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 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Oneup\ContaoBackendLimitedWidthBundle\Tests\DependencyInjection; | ||
|
||
use Oneup\ContaoBackendLimitedWidthBundle\DependencyInjection\OneupContaoBackendLimitedWidthExtension; | ||
use Oneup\ContaoBackendLimitedWidthBundle\EventListener\ParseTemplateListener; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class OneupContaoBackendLimitedWidthExtensionTest extends TestCase | ||
{ | ||
public function testLoadsServicesYaml(): void | ||
{ | ||
$extension = new OneupContaoBackendLimitedWidthExtension(); | ||
$containerBuilder = new ContainerBuilder(); | ||
|
||
$extension->load([], $containerBuilder); | ||
$definitions = array_keys($containerBuilder->getDefinitions()); | ||
|
||
self::assertContains(ParseTemplateListener::class, $definitions); | ||
self::assertCount(2, $definitions); | ||
} | ||
} |
Oops, something went wrong.