Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Exportcommand not working #1216

Open
wants to merge 3 commits into
base: typo3-v12
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion Classes/Command/ExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
*/
class ExportCommand extends Command
{

use FakeRequestTrait;

/**
* @return void
*/
public function configure()
{
$this->fakeRequest();

$description =
'This task can send a mail export with an attachment (XLS or CSV) to a receiver or a group of receivers';
$this->setDescription($description);
Expand Down Expand Up @@ -104,7 +109,7 @@ protected function getFilterVariables(int $period): array
if ($period > 0) {
$variables = [
'filter' => [
'start' => strftime('%Y-%m-%d %H:%M:%S', (time() - $period)),
'start' => date('Y-m-d H:i:s', (time() - $period)),
'stop' => 'now',
],
];
Expand Down
23 changes: 23 additions & 0 deletions Classes/Command/FakeRequestTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);
namespace In2code\Powermail\Command;

use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Http\ServerRequest;

/**
* It is not possible to create an instance of an extbase repository in a symfony command anymore in TYPO3 12 or newer
* So we have to fake a request, to get this running again.
*/
trait FakeRequestTrait
{
protected function fakeRequest()
{
if (!isset($GLOBALS['TYPO3_REQUEST'])) {
$request = (new ServerRequest())
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
$GLOBALS['TYPO3_REQUEST'] = $request;
}
}
}
4 changes: 2 additions & 2 deletions Resources/Private/Templates/Module/ExportXls.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<vh:Getter.GetFieldLabelFromUid uid="{fieldUid}" />
</f:then>
<f:else>
<f:translate key="\In2code\Powermail\Domain\Model\Mail.{vh:string.underscoredToLowerCamelCase(val:fieldUid)}" />
<f:translate key="\In2code\Powermail\Domain\Model\Mail.{vh:string.underscoredToLowerCamelCase(val:fieldUid)}" extensionName="powermail" />
</f:else>
</f:if>
</th>
Expand Down Expand Up @@ -57,7 +57,7 @@
<f:if condition="{0:fieldUid} == {0:'crdate'}">
<f:then>
<f:format.date format="d.m.Y H:i:s"><vh:misc.variableInVariable obj="{mail}" prop="{fieldUid}" /></f:format.date>
<f:translate key="Clock" />
<f:translate key="Clock" extensionName="powermail" />
</f:then>
<f:else>
<f:if condition="{0 : fieldUid} == {0 : 'time'}">
Expand Down