Skip to content

Commit 0b8fc57

Browse files
rasgormschwemer
authored andcommitted
Add fakequest trait
1 parent d90afc9 commit 0b8fc57

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Classes/Command/FakeRequestTrait.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
namespace In2code\Powermail\Command;
5+
6+
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
7+
use TYPO3\CMS\Core\Http\ServerRequest;
8+
9+
/**
10+
* It is not possible to create an instance of an extbase repository in a symfony command anymore in TYPO3 12 or newer
11+
* So we have to fake a request, to get this running again.
12+
*/
13+
trait FakeRequestTrait
14+
{
15+
protected function fakeRequest()
16+
{
17+
if (!isset($GLOBALS['TYPO3_REQUEST'])) {
18+
$request = (new ServerRequest())
19+
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
20+
$GLOBALS['TYPO3_REQUEST'] = $request;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)