Skip to content

Commit a7adfe3

Browse files
author
Konrad Michalik
authored
Merge pull request #7 from xima-media/housekeeping
build: housekeeping
2 parents 7d78ad6 + a531a7e commit a7adfe3

43 files changed

Lines changed: 983 additions & 343 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ddev/.typo3-setup/templates/index.php

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
#ddev-generated
4-
# If you want to take over this file and customize it, remove the line above
5-
# and ddev will respect it and won't overwrite the file.
3+
//ddev-generated
4+
// If you want to take over this file and customize it, remove the line above
5+
// and ddev will respect it and won't overwrite the file.
66

77
$extensionKey = getenv('EXTENSION_NAME');
88
$typo3AdminUser = getenv('TYPO3_INSTALL_ADMIN_USER');
@@ -23,7 +23,7 @@
2323
<html lang="en">
2424
<head>
2525
<meta charset="UTF-8">
26-
<title><?php echo($extensionKey); ?></title>
26+
<title><?php echo $extensionKey; ?></title>
2727
<link
2828
rel="stylesheet"
2929
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
@@ -39,66 +39,66 @@
3939
<header class="container">
4040
<h1>
4141
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="-0.5 -0.5 24 24" id="Typo3-Icon--Streamline-Svg-Logos.svg" height="40" width="40"><path fill="#F49700" d="M9.895582291666667 0.5915863541666667c-0.4094479166666667 0.35015104166666666 -0.7003020833333333 0.7595869791666667 -0.7003020833333333 1.9823292708333333 0 3.32738125 4.19994375 13.322414583333334 7.060448958333334 13.322414583333334 0.32128125 0.004360416666666667 0.6412927083333333 -0.04125625 0.9485583333333334 -0.13522083333333335l-0.0060375 0.0016770833333333334 -0.07309687499999999 0.11725208333333334C14.656414583333333 19.815003125000004 11.685221875 22.70162291666667 9.887244791666667 22.759530208333334L9.832571875000001 22.760416666666668C5.927195833333333 22.760416666666668 0.38405927083333335 10.970137500000002 0.38405927083333335 5.7827270833333335c0 -0.8170270833333334 0.185265 -1.45805625 0.46686645833333335 -1.8563635416666668C2.194099375 2.2849110416666667 6.394071875000001 0.9991703125 9.895582291666667 0.5915863541666667ZM15.379429166666668 0.23958333333333334c3.616366666666667 0 7.236446875 0.5835842708333334 7.236446875 2.6252104166666665 0 4.142515625000001 -2.627055208333333 9.1632 -3.9683864583333337 9.1632 -2.391760416666667 0 -5.372680208333334 -6.652869791666666 -5.372680208333334 -9.980222291666667C13.274809375 0.5304494791666666 13.856541666666667 0.23958333333333334 15.373870833333335 0.23958333333333334h0.0055583333333333335Z" stroke-width="1"></path></svg>
42-
<?php echo($extensionKey); ?></h1>
42+
<?php echo $extensionKey; ?></h1>
4343
</header>
4444
<main class="container">
45-
<blockquote><?php echo($description); ?></blockquote>
45+
<blockquote><?php echo $description; ?></blockquote>
4646
<hr/>
4747
<p>Run <code>ddev install all</code> to install all TYPO3 instances below:</p>
4848
<?php
4949
foreach ($supportedVersions as $version) {
50-
$directoryPath = "/var/www/html/.Build/" . $version;
50+
$directoryPath = '/var/www/html/.Build/' . $version;
5151
if (is_dir($directoryPath)) {
5252
echo "<article class='flex'><kbd>{$version}</kbd><div><strong>Frontend</strong><br/><strong>Backend</strong></div><div><a target='_blank' href='https://{$version}.{$extensionKey}.ddev.site'>https://{$version}.{$extensionKey}.ddev.site</a><br/><a target='_blank' href='https://{$version}.{$extensionKey}.ddev.site/typo3/?u={$typo3AdminUser}&p={$typo3AdminPassword}'>https://{$version}.{$extensionKey}.ddev.site/typo3</a></div></article>";
5353
} else {
5454
echo "<article>Version {$version} is not installed. Run <code>ddev install {$version}</code> to install.</article>";
5555
}
5656
}
57-
?>
57+
?>
5858
<h2>Additional information</h2>
5959
<h4>DDEV commands</h4>
6060
<?php
61-
// Directories to scan for DDEV commands
62-
$directories = [
63-
'/var/www/html/.ddev/commands/web',
64-
'/var/www/html/.ddev/commands/host'
65-
];
61+
// Directories to scan for DDEV commands
62+
$directories = [
63+
'/var/www/html/.ddev/commands/web',
64+
'/var/www/html/.ddev/commands/host',
65+
];
6666

67-
foreach ($directories as $directory) {
68-
foreach (new DirectoryIterator($directory) as $fileInfo) {
69-
$filePath = $fileInfo->getPathname();
70-
$fileName = $fileInfo->getFilename();
67+
foreach ($directories as $directory) {
68+
foreach (new DirectoryIterator($directory) as $fileInfo) {
69+
$filePath = $fileInfo->getPathname();
70+
$fileName = $fileInfo->getFilename();
7171

72-
if ($fileName[0] === '.' || $fileInfo->isDir()) {
73-
continue;
74-
}
72+
if ($fileName[0] === '.' || $fileInfo->isDir()) {
73+
continue;
74+
}
7575

76-
$fileContent = file($filePath);
77-
if (strpos($fileContent[0], '#!/bin/bash') === 0) {
78-
$description = '';
79-
$usage = '';
80-
$example = '';
76+
$fileContent = file($filePath);
77+
if (str_starts_with($fileContent[0], '#!/bin/bash')) {
78+
$description = '';
79+
$usage = '';
80+
$example = '';
8181

82-
foreach ($fileContent as $line) {
83-
if (strpos($line, '## Description:') === 0) {
84-
$description = trim(str_replace('## Description:', '', $line));
85-
} elseif (strpos($line, '## Usage:') === 0) {
86-
$usage = trim(str_replace('## Usage:', '', $line));
87-
} elseif (strpos($line, '## Example:') === 0) {
88-
$example = trim(str_replace('## Example:', '', $line));
89-
}
82+
foreach ($fileContent as $line) {
83+
if (str_starts_with($line, '## Description:')) {
84+
$description = trim(str_replace('## Description:', '', $line));
85+
} elseif (str_starts_with($line, '## Usage:')) {
86+
$usage = trim(str_replace('## Usage:', '', $line));
87+
} elseif (str_starts_with($line, '## Example:')) {
88+
$example = trim(str_replace('## Example:', '', $line));
9089
}
91-
92-
echo "<article><code>ddev $usage</code><br/>$description<br/> <em>Example: $example</em></article>";
9390
}
91+
92+
echo "<article><code>ddev $usage</code><br/>$description<br/> <em>Example: $example</em></article>";
9493
}
9594
}
96-
?>
95+
}
96+
?>
9797
<details open>
9898
<summary><h4>TYPO3 Backend Credentials</h4></summary>
9999
<ul>
100-
<li>Username: <code><?php echo($typo3AdminUser); ?></code></li>
101-
<li>Password: <code><?php echo($typo3AdminPassword); ?></code></li>
100+
<li>Username: <code><?php echo $typo3AdminUser; ?></code></li>
101+
<li>Password: <code><?php echo $typo3AdminPassword; ?></code></li>
102102
</ul>
103103
</details>
104104
</main>

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,20 @@ insert_final_newline = unset
5858
# phpstan.neon
5959
[*.neon]
6060
indent_style = tab
61+
62+
# Ignore paths
63+
[/.ddev/**]
64+
charset = unset
65+
end_of_line = unset
66+
insert_final_newline = unset
67+
trim_trailing_whitespace = unset
68+
indent_style = unset
69+
indent_size = unset
70+
71+
[/Documentation/**]
72+
charset = unset
73+
end_of_line = unset
74+
insert_final_newline = unset
75+
trim_trailing_whitespace = unset
76+
indent_style = unset
77+
indent_size = unset

.github/workflows/cgl.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: CGL
2+
on:
3+
push:
4+
branches:
5+
- '**'
6+
7+
jobs:
8+
cgl:
9+
uses: jackd248/reusable-github-actions/.github/workflows/cgl.yml@main

.github/workflows/sca.yml

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

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* hej@konradmichalik.dev

CODE_OF_CONDUCT.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Code of Conduct
2+
3+
This project uses the
4+
[TYPO3 Code of Conduct](https://typo3.org/community/values/code-of-conduct).
5+
6+
When you contribute to this project or interact with community members,
7+
you agree to adhere to this code of conduct.

CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contributing
2+
3+
Thank you for considering contributing to this project! Every contribution is welcome and helps improve the quality of the project. To ensure a smooth process and maintain high code quality, please follow the steps below.
4+
5+
## Requirements
6+
7+
- [DDEV](https://ddev.readthedocs.io/en/stable/)
8+
9+
## Preparation
10+
11+
```bash
12+
# Clone repository
13+
git clone https://github.com/xima-media/xima-typo3-internal-news.git
14+
cd xima-typo3-internal-news
15+
16+
# Start the project with DDEV
17+
ddev start
18+
19+
# Install dependencies
20+
ddev composer install
21+
```
22+
23+
## Run linters
24+
25+
```bash
26+
# All linters
27+
ddev composer lint
28+
29+
# Specific linters
30+
ddev composer lint:composer
31+
ddev composer lint:editorconfig
32+
ddev composer lint:language
33+
ddev composer lint:php
34+
ddev composer lint:typoscript
35+
ddev composer lint:yaml
36+
37+
# Fix all CGL issues
38+
ddev composer fix
39+
40+
# Fix specific CGL issues
41+
ddev composer fix:composer
42+
ddev composer fix:editorconfig
43+
ddev composer fix:php
44+
```
45+
46+
## Run static code analysis
47+
48+
```bash
49+
# All static code analyzers
50+
ddev composer sca
51+
52+
# Specific static code analyzers
53+
ddev composer sca:php
54+
```
55+
56+
## TYPO3 Setup
57+
58+
For testing the extension, you need to set up the TYPO3 instances.
59+
60+
```bash
61+
# Install all TYPO3 versions, which are supported by the extension
62+
ddev install all
63+
64+
# Or install specific TYPO3 versions
65+
ddev install 12
66+
ddev install 13
67+
68+
# Open the overview page
69+
ddev launch
70+
71+
# Run TYPO3 specific commands
72+
ddev 12 typo3 cache:flush
73+
ddev 13 composer install
74+
ddev all typo3 database:updateschema
75+
```
76+
77+
## Submit a pull request
78+
79+
After completing your work, **open a pull request** and provide a description of your changes. Ideally, your PR should reference an issue that explains the problem you are addressing.
80+
81+
All mentioned code quality tools will run automatically on every pull request. For more details, see the relevant [workflows][1].
82+
83+
[1]: .github/workflows

Classes/Backend/ToolbarItems/NewsItem.php

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,38 @@
22

33
declare(strict_types=1);
44

5+
/*
6+
* This file is part of the TYPO3 CMS extension "xima_typo3_internal_news".
7+
*
8+
* Copyright (C) 2025 Konrad Michalik <hej@konradmichalik.dev>
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License as published by
12+
* the Free Software Foundation, either version 2 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
524
namespace Xima\XimaTypo3InternalNews\Backend\ToolbarItems;
625

726
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
8-
use TYPO3\CMS\Core\Utility\GeneralUtility;
9-
use TYPO3\CMS\Fluid\View\StandaloneView;
10-
use Xima\XimaTypo3InternalNews\Configuration;
27+
use Xima\XimaTypo3InternalNews\Domain\Model\News;
1128
use Xima\XimaTypo3InternalNews\Domain\Repository\NewsRepository;
29+
use Xima\XimaTypo3InternalNews\Utilities\ViewFactoryHelper;
1230

1331
class NewsItem implements ToolbarItemInterface
1432
{
1533
protected array $configuration;
1634
public function __construct(
1735
private readonly NewsRepository $newsRepository
18-
) {
19-
}
36+
) {}
2037

2138
/**
2239
* Checks whether the user has access to this toolbar item
@@ -36,14 +53,14 @@ public function checkAccess(): bool
3653
public function getItem(): string
3754
{
3855
$items = $this->newsRepository->findAllByCurrentUser();
39-
$newItemsCount = count(array_filter($items, fn ($item) => $item->isNew()));
40-
$view = GeneralUtility::makeInstance(StandaloneView::class);
41-
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:' . Configuration::EXT_KEY
42-
. '/Resources/Private/Templates/Backend/ToolbarItems/NewsItem.html'));
56+
$newItemsCount = count(array_filter($items, static fn(News $item) => $item->isNew()));
4357

44-
return $view->assignMultiple([
45-
'count' => $newItemsCount,
46-
])->render();
58+
return ViewFactoryHelper::renderView(
59+
'Backend/ToolbarItems/NewsItem.html',
60+
[
61+
'count' => $newItemsCount,
62+
]
63+
);
4764
}
4865

4966
/**
@@ -63,15 +80,12 @@ public function hasDropDown(): bool
6380
*/
6481
public function getDropDown(): string
6582
{
66-
$view = GeneralUtility::makeInstance(StandaloneView::class);
67-
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:' . Configuration::EXT_KEY
68-
. '/Resources/Private/Templates/Backend/ToolbarItems/NewsItemDropDown.html'));
69-
$view->setPartialRootPaths([
70-
GeneralUtility::getFileAbsFileName('EXT:' . Configuration::EXT_KEY . '/Resources/Private/Partials/'),
71-
]);
72-
return $view->assignMultiple([
73-
'data' => $this->newsRepository->findAllByCurrentUser(3),
74-
])->render();
83+
return ViewFactoryHelper::renderView(
84+
'Backend/ToolbarItems/NewsItemDropDown.html',
85+
[
86+
'data' => $this->newsRepository->findAllByCurrentUser(3),
87+
]
88+
);
7589
}
7690

7791
/**

0 commit comments

Comments
 (0)