-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from itx-informationssysteme/v12
v12
- Loading branch information
Showing
37 changed files
with
441 additions
and
135 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: publish | ||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [published] | ||
jobs: | ||
publish: | ||
name: Publish new version to TER | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-20.04 | ||
env: | ||
TYPO3_EXTENSION_KEY: ${{ secrets.TYPO3_EXTENSION_KEY }} | ||
TYPO3_API_USERNAME: ${{ secrets.TYPO3_API_USERNAME }} | ||
TYPO3_API_PASSWORD: ${{ secrets.TYPO3_API_PASSWORD }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Check tag | ||
run: | | ||
if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then | ||
exit 1 | ||
fi | ||
- name: Get version | ||
id: get-version | ||
run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//} | ||
|
||
- name: Get comment | ||
id: get-comment | ||
run: | | ||
readonly local comment=$(git tag -n1 -l ${{ steps.get-version.outputs.version }} | sed "s/^[0-9.]*[ ]*//g") | ||
if [[ -z "${comment// }" ]]; then | ||
echo ::set-output name=comment::Released version ${{ steps.get-version.outputs.version }} of ${{ env.TYPO3_EXTENSION_KEY }} | ||
else | ||
echo ::set-output name=comment::$comment | ||
fi | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 7.4 | ||
extensions: intl, mbstring, json, zip, curl | ||
tools: composer:v2 | ||
|
||
- name: Install tailor | ||
run: composer global require typo3/tailor --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Publish to TER | ||
run: | ||
php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ steps.get-comment.outputs.comment }}" ${{ | ||
steps.get-version.outputs.version }} |
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,41 @@ | ||
name: Static analysis | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main, v12] | ||
|
||
jobs: | ||
phpstan: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- php-version: 8.2 | ||
- php-version: 8.3 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php-version }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
coverage: none | ||
tools: composer:v2 | ||
|
||
- run: | ||
composer config --no-plugins allow-plugins.typo3/class-alias-loader true && composer config --no-plugins | ||
allow-plugins.typo3/cms-composer-installers true | ||
|
||
- run: composer install --no-progress | ||
|
||
- run: vendor/bin/phpstan analyse Classes -c phpstan.neon |
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
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,17 @@ | ||
<?php | ||
|
||
namespace Itx\Typo3GraphQL\Hook; | ||
|
||
use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
class DataHandlerHooks | ||
{ | ||
public function processDatamap_afterDatabaseOperations($status, $table, $id, array $fieldArray, \TYPO3\CMS\Core\DataHandling\DataHandler &$pObj) { | ||
$container = GeneralUtility::getContainer(); | ||
/** @var FrontendInterface $cache */ | ||
$cache = $container->get('cache.typo3_graphql_cache'); | ||
|
||
$cache->flushByTag($table); | ||
} | ||
} |
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,126 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
namespace Itx\Typo3GraphQL\Middleware; | ||
|
||
/* | ||
* This file is part of TYPO3 CMS-based extension "SlimPHP Bridge" by b13. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
*/ | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Psr\Http\Server\MiddlewareInterface; | ||
use Psr\Http\Server\RequestHandlerInterface; | ||
use TYPO3\CMS\Core\Context\Context; | ||
use TYPO3\CMS\Core\Routing\PageArguments; | ||
use TYPO3\CMS\Core\Site\Entity\Site; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Core\Bootstrap; | ||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | ||
|
||
/** | ||
* Sets up TSFE and Extbase, in order to use Extbase within a Slim Controller | ||
*/ | ||
class ExtbaseBridge | ||
{ | ||
private string $typo3Version = ''; | ||
private Context $context; | ||
|
||
public function __construct(Context $context) | ||
{ | ||
$this->context = $context; | ||
$this->typo3Version = (string)(new \TYPO3\CMS\Core\Information\Typo3Version()); | ||
} | ||
|
||
public function boot(ServerRequestInterface $request, RequestHandlerInterface $handler): void | ||
{ | ||
$site = $request->getAttribute('site'); | ||
if (!$site instanceof Site) { | ||
return; | ||
} | ||
|
||
if (($GLOBALS['TYPO3_REQUEST'] ?? null) === null) { | ||
$GLOBALS['TYPO3_REQUEST'] = $request; | ||
} | ||
|
||
if (!isset($GLOBALS['TSFE']) || !$GLOBALS['TSFE'] instanceof TypoScriptFrontendController) { | ||
$request = $this->createGlobalTsfe($site, $request); | ||
} else { | ||
$GLOBALS['TSFE']->id = $site->getRootPageId(); | ||
} | ||
|
||
$request = $this->bootFrontend($request); | ||
$this->bootExtbase($request); | ||
} | ||
|
||
protected function createGlobalTsfe(Site $site, ServerRequestInterface $request): ServerRequestInterface | ||
{ | ||
if (version_compare($this->typo3Version, '11.5', '>=')) { | ||
$controller = GeneralUtility::makeInstance( | ||
TypoScriptFrontendController::class, | ||
$this->context, | ||
$site, | ||
$request->getAttribute('language', $site->getDefaultLanguage()), | ||
new PageArguments($site->getRootPageId(), '0', []), | ||
$request->getAttribute('frontend.user') | ||
); | ||
|
||
$controller->determineId($request); | ||
|
||
$request = $request->withAttribute('frontend.controller', $controller); | ||
|
||
// Make TSFE globally available | ||
// @todo deprecate $GLOBALS['TSFE'] once TSFE is retrieved from the | ||
// PSR-7 request attribute frontend.controller throughout TYPO3 core | ||
$GLOBALS['TSFE'] = $controller; | ||
} else { | ||
$GLOBALS['TSFE'] = GeneralUtility::makeInstance( | ||
TypoScriptFrontendController::class, | ||
null, | ||
$site, | ||
$request->getAttribute('language'), | ||
null, | ||
$request->getAttribute('frontend.user') | ||
); | ||
} | ||
|
||
return $request; | ||
} | ||
|
||
protected function bootFrontend(ServerRequestInterface $request): ServerRequestInterface | ||
{ | ||
if (version_compare($this->typo3Version, '12.2', '>=')) { | ||
// Run Frontend TypoScript | ||
$request = $GLOBALS['TSFE']->getFromCache($request); | ||
} elseif (version_compare($this->typo3Version, '11.5', '>=')) { | ||
// nothing to do, TSFE is already ready | ||
} else { | ||
$GLOBALS['TSFE']->fetch_the_id($request); | ||
$GLOBALS['TSFE']->getConfigArray($request); | ||
$GLOBALS['TSFE']->settingLanguage($request); | ||
$GLOBALS['TSFE']->newCObj(); | ||
} | ||
return $request; | ||
} | ||
|
||
protected function bootExtbase(ServerRequestInterface $request): void | ||
{ | ||
if (version_compare($this->typo3Version, '12.4', '>=')) { | ||
GeneralUtility::makeInstance(Bootstrap::class)->initialize([ | ||
'extensionName' => 'typo3_graphql', | ||
'vendorName' => 'Itx', | ||
'pluginName' => 'graphql', | ||
], $request); | ||
}else { | ||
GeneralUtility::makeInstance(Bootstrap::class)->initialize([ | ||
'extensionName' => 'typo3_graphql', | ||
'vendorName' => 'Itx', | ||
'pluginName' => 'graphql', | ||
], $request); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.