-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Check for TYPO3 context in command controllers
resolves: https://projekte.in2code.de/issues/48026
- Loading branch information
Showing
3 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace In2code\In2publishCore\Service\Typo3Context; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use TYPO3\CMS\Core\Core\Environment; | ||
use TYPO3\CMS\Core\Http\ApplicationType; | ||
|
||
class Typo3ContextService | ||
{ | ||
public function isCliOrBackendEnvironment(): bool | ||
{ | ||
if (Environment::isCli()) { | ||
return true; | ||
} | ||
|
||
$request = $GLOBALS['TYPO3_REQUEST'] ?? null; | ||
return $request instanceof ServerRequestInterface && ApplicationType::fromRequest($request)->isBackend(); | ||
} | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
Classes/Service/Typo3Context/Typo3ContextServiceInjection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace In2code\In2publishCore\Service\Typo3Context; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
trait Typo3ContextServiceInjection | ||
{ | ||
protected Typo3ContextService $typo3ContextService; | ||
|
||
/** | ||
* @noinspection PhpUnused | ||
*/ | ||
public function injectTypo3ContextService(Typo3ContextService $typo3ContextService): void | ||
{ | ||
$this->typo3ContextService = $typo3ContextService; | ||
} | ||
} |