Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ Options:
- composer: "composer" with all remaining arguments dispatched.
- composerNormalize: "composer normalize"
- composerUpdate: "composer update", handy if host has no PHP
- composerUpdateRector: "composer update", for rector subdirectory
- composerValidate: "composer validate"
- functional: PHP functional tests
- lint: PHP linting
Expand Down Expand Up @@ -454,18 +453,6 @@ case ${TEST_SUITE} in
cp ${ROOT_DIR}/composer.json ${ROOT_DIR}/composer.json.testing
mv ${ROOT_DIR}/composer.json.orig ${ROOT_DIR}/composer.json
;;
composerUpdateRector)
rm -rf Build/rector/.Build/bin/ Build/rector/.Build/vendor Build/rector/composer.lock
cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.orig
if [ -f "${ROOT_DIR}/Build/rector/composer.json.testing" ]; then
cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.orig
fi
COMMAND=(composer require --working-dir=${ROOT_DIR}/Build/rector --no-ansi --no-interaction --no-progress)
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-install-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
cp ${ROOT_DIR}/Build/rector/composer.json ${ROOT_DIR}/Build/rector/composer.json.testing
mv ${ROOT_DIR}/Build/rector/composer.json.orig ${ROOT_DIR}/Build/rector/composer.json
;;
composerValidate)
COMMAND=(composer validate "$@")
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name composer-command-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
Expand Down Expand Up @@ -524,9 +511,9 @@ case ${TEST_SUITE} in
;;
rector)
if [ "${CGLCHECK_DRY_RUN}" -eq 1 ]; then
COMMAND=(php -dxdebug.mode=off Build/rector/.Build/bin/rector -n --config=Build/rector/rector.php --clear-cache "$@")
COMMAND=(php -dxdebug.mode=off .Build/bin/rector -n --config=Build/rector/rector.php --clear-cache "$@")
else
COMMAND=(php -dxdebug.mode=off Build/rector/.Build/bin/rector --config=Build/rector/rector.php --clear-cache "$@")
COMMAND=(php -dxdebug.mode=off .Build/bin/rector --config=Build/rector/rector.php --clear-cache "$@")
fi
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name rector-${SUFFIX} -e COMPOSER_CACHE_DIR=.Build/.cache/composer -e COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION} ${IMAGE_PHP} "${COMMAND[@]}"
SUITE_EXIT_CODE=$?
Expand Down
20 changes: 0 additions & 20 deletions Build/rector/composer.json

This file was deleted.

12 changes: 6 additions & 6 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function __construct(

public function addPopulateButton(ButtonBar $buttonBar): void
{
$populateButton = $buttonBar->makeLinkButton()
$populateButton = $this->componentFactory->createLinkButton()
->setHref($this->uriBuilder->reset()->uriFor('populate'))
->setTitle('Create example data')
->setShowLabelText(true)
Expand Down Expand Up @@ -235,13 +235,13 @@ private function modifyDocHeaderComponent(ModuleTemplate $view, string &$context

$metaInformation = $this->getMetaInformation();
if (is_array($metaInformation)) {
$view->getDocHeaderComponent()->setMetaInformation($metaInformation);
$view->getDocHeaderComponent()->setPageBreadcrumb($metaInformation);
}
}

private function addReloadButton(ButtonBar $buttonBar): void
{
$reloadButton = $buttonBar->makeLinkButton()
$reloadButton = $this->componentFactory->createLinkButton()
->setHref($this->request->getAttribute('normalizedParams')->getRequestUri())
->setTitle($this->getLanguageService()->sL('core.core:labels.reload'))
->setIcon($this->iconFactory->getIcon('actions-refresh', IconSize::SMALL));
Expand All @@ -250,7 +250,7 @@ private function addReloadButton(ButtonBar $buttonBar): void

private function addShortCutButton(ButtonBar $buttonBar): void
{
$shortcutButton = $buttonBar->makeShortcutButton()
$shortcutButton = $this->componentFactory->createShortcutButton()
->setRouteIdentifier('blog_example')
->setDisplayName($this->getLanguageService()->sL('blog_example.messages:administration.menu.index'));
$buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT);
Expand Down Expand Up @@ -280,12 +280,12 @@ private function buildMenu(ModuleTemplate $view, string &$context): Menu
//$menu = $this->componentFactory->createMenu();
//$menu->setIdentifier('viewSelector')->setLabel('View');

$menu = $view->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
$menu = $this->componentFactory->createMenu();
$menu->setIdentifier('BlogExampleModuleMenu')->setLabel('View');

foreach ($menuItems as $menuItemConfig) {
$isActive = $this->request->getControllerActionName() === $menuItemConfig['action'];
$menuItem = $menu->makeMenuItem()
$menuItem = $this->componentFactory->createMenuItem()
->setTitle($menuItemConfig['label'])
->setHref($this->uriBuilder->reset()->uriFor(
$menuItemConfig['action'],
Expand Down
28 changes: 16 additions & 12 deletions Classes/Controller/BlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ public function helloWorldAction(): ResponseInterface
/**
* Displays a form for creating a new blog
*/
#[IgnoreValidation(['value' => 'newBlog'])]
public function newAction(?Blog $newBlog = null): ResponseInterface
{
public function newAction(
#[IgnoreValidation]
?Blog $newBlog = null,
): ResponseInterface {
$this->view->assignMultiple([
'newBlog' => $newBlog,
'administrators' => $this->administratorRepository->findAll(),
Expand All @@ -95,9 +96,10 @@ public function newAction(?Blog $newBlog = null): ResponseInterface
* $blog is a fresh Blog object which has not yet been added to the
* repository
*/
#[Validate(['param' => 'newBlog', 'validator' => BlogValidator::class])]
public function createAction(Blog $newBlog): ResponseInterface
{
public function createAction(
#[Validate(validator: BlogValidator::class)]
Blog $newBlog,
): ResponseInterface {
$this->checkBlogAdminAccess();
$this->blogRepository->add($newBlog);
$this->addFlashMessage('created');
Expand All @@ -111,9 +113,10 @@ public function createAction(Blog $newBlog): ResponseInterface
* modifications if the edit form has been submitted, contained errors and
* therefore ended up in this action again.
*/
#[IgnoreValidation(['value' => 'blog'])]
public function editAction(Blog $blog): ResponseInterface
{
public function editAction(
#[IgnoreValidation]
Blog $blog,
): ResponseInterface {
$this->view->assignMultiple([
'blog' => $blog,
'administrators' => $this->administratorRepository->findAll(),
Expand All @@ -129,9 +132,10 @@ public function editAction(Blog $blog): ResponseInterface
*
* @throws NoBlogAdminAccessException
*/
#[Validate(['param' => 'blog', 'validator' => BlogValidator::class])]
public function updateAction(Blog $blog): ResponseInterface
{
public function updateAction(
#[Validate(validator: BlogValidator::class)]
Blog $blog,
): ResponseInterface {
$this->checkBlogAdminAccess();
$this->blogRepository->update($blog);
$this->addFlashMessage('updated');
Expand Down
13 changes: 7 additions & 6 deletions Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ public function displayRssListAction(): ResponseInterface
/**
* Displays one single post
*/
#[IgnoreValidation(['value' => 'newComment'])]
public function showAction(
Post $post,
#[IgnoreValidation]
?Comment $newComment = null,
): ResponseInterface {
$this->blogPageTitleProvider->setTitle($post->getTitle());
Expand All @@ -156,9 +156,9 @@ public function showAction(
*
* $newPost is a fresh post object taken as a basis for the rendering
*/
#[IgnoreValidation(['value' => 'newPost'])]
public function newAction(
Blog $blog,
#[IgnoreValidation]
?Post $newPost = null,
): ResponseInterface {
$this->view->assignMultiple([
Expand All @@ -167,7 +167,6 @@ public function newAction(
'newPost' => $newPost,
'remainingPosts' => $this->postRepository->findBy(['blog' => $blog]),
]);

return $this->htmlResponse();
}

Expand All @@ -190,9 +189,11 @@ public function createAction(
/**
* Displays a form to edit an existing post
*/
#[IgnoreValidation(['value' => 'post'])]
public function editAction(Blog $blog, Post $post): ResponseInterface
{
public function editAction(
Blog $blog,
#[IgnoreValidation]
Post $post,
): ResponseInterface {
$this->view->assignMultiple([
'authors' => $this->personRepository->findAll(),
'blog' => $blog,
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Model/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
*/
class Blog extends AbstractEntity
{
#[Validate(['validator' => TitleValidator::class])]
#[Validate(validator: TitleValidator::class)]
public string $title = '';

#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 5, 'maximum' => 80]])]
#[Validate(validator: 'StringLength', options: ['minimum' => 5, 'maximum' => 80])]
public string|null $subtitle = null;

/**
* A short description of the blog
*/
#[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 150]])]
#[Validate(validator: 'StringLength', options: ['maximum' => 150])]
public string $description = '';

/**
Expand All @@ -51,7 +51,7 @@ class Blog extends AbstractEntity
* @var ?ObjectStorage<Post>
*/
#[Lazy()]
#[Cascade(['value' => 'remove'])]
#[Cascade('remove')]
public ?ObjectStorage $posts = null;

/**
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class Comment extends AbstractEntity implements \Stringable
{
protected \DateTime $date;

#[Validate(['validator' => 'NotEmpty'])]
#[Validate(validator: 'NotEmpty')]
protected string $author = '';

#[Validate(['validator' => 'EmailAddress'])]
#[Validate(validator: 'EmailAddress')]
protected string $email = '';

#[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 500]])]
#[Validate(validator: 'StringLength', options: ['maximum' => 500])]
protected string $content = '';

protected bool $hidden = true;
Expand Down
6 changes: 3 additions & 3 deletions Classes/Domain/Model/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
*/
class Person extends AbstractEntity
{
#[Validate(['validator' => 'StringLength', 'options' => ['maximum' => 80]])]
#[Validate(validator: 'StringLength', options: ['maximum' => 80])]
protected string $firstname = '';

#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 2, 'maximum' => 80]])]
#[Validate(validator: 'StringLength', options: ['minimum' => 2, 'maximum' => 80])]
protected string $lastname = '';

#[Transient()]
protected string $fullname = '';

#[Validate(['validator' => 'EmailAddress'])]
#[Validate(validator: 'EmailAddress')]
protected string $email = '';

/**
Expand Down
12 changes: 6 additions & 6 deletions Classes/Domain/Model/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Post extends AbstractEntity implements \Stringable
{
protected ?Blog $blog = null;

#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 3, 'maximum' => 50]])]
#[Validate(validator: 'StringLength', options: ['minimum' => 3, 'maximum' => 50])]
protected string $title = '';

/**
Expand All @@ -45,13 +45,13 @@ class Post extends AbstractEntity implements \Stringable
protected ?Person $secondAuthor = null;
protected ?Person $reviewer = null;

#[Validate(['validator' => 'StringLength', 'options' => ['minimum' => 3]])]
#[Validate(validator: 'StringLength', options: ['minimum' => 3])]
protected string $content = '';

/**
* @var ?ObjectStorage<Tag>
*/
#[Cascade(['value' => 'remove'])]
#[Cascade('remove')]
public ?ObjectStorage $tags = null;

/**
Expand All @@ -63,7 +63,7 @@ class Post extends AbstractEntity implements \Stringable
* @var ?ObjectStorage<Comment>
*/
#[Lazy()]
#[Cascade(['value' => 'remove'])]
#[Cascade('remove')]
public ?ObjectStorage $comments = null;

/**
Expand All @@ -75,13 +75,13 @@ class Post extends AbstractEntity implements \Stringable
/**
* 1:1 optional relation
*/
#[Cascade(['value' => 'remove'])]
#[Cascade('remove')]
public ?Info $additionalName = null;

/**
* 1:1 optional relation
*/
#[Cascade(['value' => 'remove'])]
#[Cascade('remove')]
protected ?Info $additionalInfo = null;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace T3docs\BlogExample\Upgrades;

use TYPO3\CMS\Core\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;

#[UpgradeWizard('blogExample_migratePluginsToContentElementsUpgradeWizard')]
final readonly class MigratePluginsToContentElementsUpgradeWizard implements UpgradeWizardInterface
Expand Down
4 changes: 2 additions & 2 deletions Classes/Upgrades/PluginUpgradeWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace T3docs\BlogExample\Upgrades;

use TYPO3\CMS\Core\Attribute\UpgradeWizard;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
use TYPO3\CMS\Core\Upgrades\UpgradeWizardInterface;

#[UpgradeWizard('blogExample_pluginUpgradeWizard')]
final readonly class PluginUpgradeWizard implements UpgradeWizardInterface
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"require-dev": {
"ergebnis/composer-normalize": "~2.42.0",
"friendsofphp/php-cs-fixer": "^3.52",
"phpstan/phpstan": "^1.10",
"ssch/typo3-rector": "^3.6",
"phpstan/phpstan": "^2.0.3",
"phpunit/phpunit": "^11.0.3",
"typo3/cms-install": "^14.0 || dev-main",
"typo3/testing-framework": "dev-main"
Expand Down