ModifyValidatorTaskEmailEvent¶
The PSR-14 event
\TYPO3\
can be used to manipulate the
\TYPO3\
,
which contains all information from the linkvalidator API. Also the
FluidEmail object can be adjusted there. This allows
to pass additional information to the view by using $fluid
or dynamically adding mail information such as the receivers list. The added
values in the event take precedence over the mod
configuration. The event contains the full mod
to access further information about the actual configuration of the task when
assigning new values to Fluid
.
Note
As it is possible to set the recipient addresses dynamically using
this event, the email
field in the task configuration can remain empty but
will be added, if defined, on top of already defined recipients from the
event. All other values such as subject
, from
or reply
will only be
set according to mod
, if not already defined through
the event.
Example¶
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Linkvalidator\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/modify-validation-task-email'
Read how to configure dependency injection in extensions.
An implementation of the event listener:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Linkvalidator\EventListener;
use Symfony\Component\Mime\Address;
use TYPO3\CMS\Linkvalidator\Event\ModifyValidatorTaskEmailEvent;
final class MyEventListener
{
public function __invoke(ModifyValidatorTaskEmailEvent $event): void
{
$linkAnalyzerResult = $event->getLinkAnalyzerResult();
$fluidEmail = $event->getFluidEmail();
$modTSconfig = $event->getModTSconfig();
if ($modTSconfig['mail.']['fromname'] === 'John Smith') {
$fluidEmail->assign('myAdditionalVariable', 'foobar');
}
$fluidEmail->subject(
$linkAnalyzerResult->getTotalBrokenLinksCount() . ' new broken links',
);
$fluidEmail->to(new Address('custom@mail.com'));
}
}
The \TYPO3\
contains the
following information by default:
$old
Broken Link Counts - Amount of broken links from the last run, separated by type (for example: all, internal)
$new
Broken Link Counts - Amount of broken links from this run, separated by type (for example: all, internal)
$broken
Links - List of broken links with the raw database row
$different
To Last Result - Whether the broken links count changed
The broken
property gets further processed internally to provide
additional information for the email. Following additional information is
provided by default:
full_
record - The full record, the broken link was found in
(for example:
pages
ortt_
)content record_
title - Value of the
full_
title fieldrecord record_
type - The title of the record type (for example: "Page" or "Page Content")
language_
code - The language code of the broken link
real_
pid - The real page ID of the record the broken link was found in
page_
record - The whole page row of records parent page
More can be added using this PSR-14 event.
Additionally to the already existing content, the email now includes a list of all broken links fetched according to the task configuration. This list consists of following columns:
Record
- The
record_
anduid record_
title Language
- The
language_
and language IDcode Page
- The
real_
andpid page_
of the parent pagerecord. title Record Type
- The
record_
type Link Target
- The
target
Link Type
- Type of the broken link (either
internal
,external
orfile
)
API¶
- class ModifyValidatorTaskEmailEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Linkvalidator\ Event\ Modify Validator Task Email Event
Allows to process and modify the LinkAnalyzer result and FluidEmail object
- getLinkAnalyzerResult ( ) ¶
-
- Returns
-
\TYPO3\
CMS\ Linkvalidator\ Result\ Link Analyzer Result
- getFluidEmail ( ) ¶
-
- Returns
-
\TYPO3\
CMS\ Core\ Mail\ Fluid Email
- getModTSconfig ( ) ¶
-
- Returns
-
array