diff --git a/Classes/Controller/ProfileController.php b/Classes/Controller/ProfileController.php index 93d1268..ac83a1f 100644 --- a/Classes/Controller/ProfileController.php +++ b/Classes/Controller/ProfileController.php @@ -2,6 +2,7 @@ declare(strict_types=1); namespace In2code\Instagram\Controller; +use Psr\Http\Message\ResponseInterface; use In2code\Instagram\Domain\Repository\FeedRepository; use In2code\Instagram\Domain\Repository\TokenRepository; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -35,7 +36,7 @@ public function __construct(FeedRepository $feedRepository, TokenRepository $tok /** * @return void */ - public function showAction() + public function showAction(): ResponseInterface { $feed = $this->feedRepository->findDataByUsername((string)$this->settings['username']); $this->view->assignMultiple([ @@ -43,5 +44,6 @@ public function showAction() 'feed' => $feed, 'token' => $this->tokenRepository->findValidTokenByUsername((string)$this->settings['username']) ]); + return $this->htmlResponse(); } } diff --git a/Classes/Domain/Repository/FeedRepository.php b/Classes/Domain/Repository/FeedRepository.php index 5edef0f..034ac52 100644 --- a/Classes/Domain/Repository/FeedRepository.php +++ b/Classes/Domain/Repository/FeedRepository.php @@ -20,7 +20,7 @@ class FeedRepository public function findDataByUsername(string $username): array { $queryBuilder = DatabaseUtility::getQueryBuilderForTable(self::TABLE_NAME); - $data = (string)$queryBuilder + $data = $queryBuilder ->select('data') ->from(self::TABLE_NAME) ->where( @@ -28,10 +28,10 @@ public function findDataByUsername(string $username): array ) ->setMaxResults(1) ->orderBy('uid', 'desc') - ->execute() - ->fetchColumn(); - if (ArrayUtility::isJsonArray($data)) { - return json_decode($data, true); + ->executeQuery() + ->fetchFirstColumn(); + if (ArrayUtility::isJsonArray($data[0])) { + return json_decode($data[0], true); } return []; } @@ -59,7 +59,7 @@ protected function deleteByUsername(string $username): void ->where( $queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username)) ) - ->execute(); + ->executeStatement(); } /** @@ -77,6 +77,6 @@ protected function insertByUsername(string $username, array $feed): void 'data' => json_encode($feed), 'import_date' => time() ]) - ->execute(); + ->executeStatement(); } } diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index 196a591..7d4fcc3 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -41,7 +41,7 @@ public function addEmptyToken(string $username, string $appId, string $appSecret 'app_return_url' => $appReturnUrl, 'crdate' => time(), ]) - ->execute(); + ->executeStatement(); } /** @@ -58,16 +58,16 @@ public function addEmptyToken(string $username, string $appId, string $appSecret public function updateToken(string $username, string $token, int $expires, $userId = '0'): void { $queryBuilder = DatabaseUtility::getQueryBuilderForTable(self::TABLE_NAME); - $uid = (int)$queryBuilder + $uid = $queryBuilder ->select('uid') ->from(self::TABLE_NAME) ->where( $queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username)) ) ->orderBy('crdate', 'desc') - ->execute() - ->fetchColumn(); - if ($uid === 0) { + ->executeQuery() + ->fetchFirstColumn(); + if (empty($uid)) { throw new ConfigurationException('No empty token record found that can be extended', 1615748471); } @@ -79,7 +79,7 @@ public function updateToken(string $username, string $token, int $expires, $user $properties += ['user_id' => $userId]; } $connection = DatabaseUtility::getConnectionForTable(self::TABLE_NAME); - $connection->update(self::TABLE_NAME, $properties, ['uid' => (int)$uid]); + $connection->update(self::TABLE_NAME, $properties, ['uid' => (int)$uid[0]]); } /** @@ -99,8 +99,8 @@ public function findLatestEmptyToken(): array $queryBuilder->expr()->eq('expire_date', 0) ) ->orderBy('crdate', 'desc') - ->execute() - ->fetch(); + ->executeQuery() + ->fetchAssociative(); if ($username === false) { throw new ConfigurationException('No empty token record found that can be filled', 1615750700); } @@ -135,8 +135,8 @@ public function findValidTokenByUsername(string $username): array $queryBuilder->expr()->gt('expire_date', time()) ) ->orderBy('crdate', 'desc') - ->execute() - ->fetch(); + ->executeQuery() + ->fetchAssociative(); if ($token === false) { return []; } @@ -157,7 +157,7 @@ protected function removeTokensByUsername(string $username): void ->where( $queryBuilder->expr()->eq('username', $queryBuilder->createNamedParameter($username)) ) - ->execute(); + ->executeStatement(); } /** diff --git a/Classes/Hooks/PageLayoutView/AbstractPreviewRenderer.php b/Classes/Hooks/PageLayoutView/AbstractPreviewRenderer.php index d6a91f6..d3e5c6c 100644 --- a/Classes/Hooks/PageLayoutView/AbstractPreviewRenderer.php +++ b/Classes/Hooks/PageLayoutView/AbstractPreviewRenderer.php @@ -3,6 +3,7 @@ namespace In2code\Instagram\Hooks\PageLayoutView; use In2code\Instagram\Exception\ConfigurationException; +use TYPO3\CMS\Backend\Preview\StandardContentPreviewRenderer; use TYPO3\CMS\Backend\View\PageLayoutView; use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface; use TYPO3\CMS\Core\Service\FlexFormService; @@ -13,7 +14,7 @@ /** * Class AbstractPreviewRenderer */ -abstract class AbstractPreviewRenderer implements PageLayoutViewDrawItemHookInterface +abstract class AbstractPreviewRenderer extends StandardContentPreviewRenderer { /** * @var array tt_content.* diff --git a/Classes/Tca/GetToken.php b/Classes/Tca/GetToken.php index 1ccd238..0499737 100644 --- a/Classes/Tca/GetToken.php +++ b/Classes/Tca/GetToken.php @@ -16,6 +16,7 @@ */ class GetToken extends AbstractFormElement { + /** * Note when a token is nearly expired - define the number of days * diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index d9b27fb..c1a9b2d 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -4,6 +4,10 @@ services: autoconfigure: true public: false + In2code\Instagram\: + resource: '../Classes/*' + exclude: '../Classes/{Domain/Model}' + In2code\Instagram\Command\ImportFeedCommand: tags: - name: 'console.command' diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 915b4cc..60175f9 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,5 +1,5 @@ 'stable', 'constraints' => [ 'depends' => [ - 'typo3' => '10.4.0-11.5.99', - 'php' => '7.2.0-7.99.99' + 'typo3' => '11.5.0-12.5.99', + 'php' => '7.2.0-8.1.99' ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index 30985d5..458e8f2 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,6 +1,10 @@ 'show' - ] + [ProfileController::class => 'show'], + [], + ExtensionUtility::PLUGIN_TYPE_PLUGIN ); /** * Caching framework */ - if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['instagram'])) { + if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['instagram'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['instagram'] = []; } @@ -36,7 +40,7 @@ function () { /** * ContentElementWizard */ - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig( + ExtensionManagementUtility::addPageTSConfig( '@import "EXT:instagram/Configuration/TSConfig/ContentElementWizard.typoscript"' ); } diff --git a/ext_tables.php b/ext_tables.php index 1f08934..7f24bed 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,5 +1,5 @@