Skip to content

Commit

Permalink
[TASK] Add v12 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
featdd committed May 7, 2023
1 parent 091d51e commit b93351c
Show file tree
Hide file tree
Showing 60 changed files with 4,799 additions and 572 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EditorConfig is awesome: http://EditorConfig.org
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Documentation_rendered
/node_modules
47 changes: 47 additions & 0 deletions Build/webpack.config.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path from 'path';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import FixStyleOnlyEntriesPlugin from "webpack-fix-style-only-entries";

module.exports = {
mode: process.env.NODE_ENV,
entry: [
path.resolve(__dirname, './../Resources/Private/Assets/Scss/Styles.scss')
],
output: {
path: path.resolve(__dirname, './../Resources/Public'),
},
plugins: [
new FixStyleOnlyEntriesPlugin(),
new MiniCssExtractPlugin({
filename: './Css/styles.css'
})
],
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
sourceMap: true,
importLoaders: 2
}
},
{
loader: "sass-loader",
options: {
sourceMap: true
}
},
],
}
]
}
};

if ('development' === process.env.NODE_ENV) {
module.exports['devtool'] = 'source-map';
module.exports['watch'] = true;
}
53 changes: 38 additions & 15 deletions Classes/Controller/TermController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
***/

use Featdd\DpnGlossary\Domain\Model\Term;
use Featdd\DpnGlossary\Domain\Repository\AbstractTermRepository;
use Featdd\DpnGlossary\Domain\Repository\TermRepository;
use Featdd\DpnGlossary\PageTitle\CharacterPaginationPageTitleProvider;
use Featdd\DpnGlossary\PageTitle\TermPageTitleProvider;
use Featdd\DpnGlossary\Pagination\CharacterPagination;
use Featdd\DpnGlossary\Pagination\CharacterPaginator;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
Expand All @@ -32,7 +34,7 @@ class TermController extends ActionController
/**
* @var \Featdd\DpnGlossary\Domain\Repository\TermRepository
*/
protected $termRepository;
protected TermRepository $termRepository;

/**
* @param \Featdd\DpnGlossary\Domain\Repository\TermRepository $termRepository
Expand All @@ -44,15 +46,16 @@ public function __construct(TermRepository $termRepository)

/**
* @param string|null $currentCharacter
* @return \Psr\Http\Message\ResponseInterface
*/
public function listAction(string $currentCharacter = null): void
public function listAction(string $currentCharacter = null): ResponseInterface
{
/** @var array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $terms */
$terms = 'character' === $this->settings['listmode']
$terms = ($this->settings['listmode'] ?? 'normal') === 'character'
? $this->termRepository->findAllGroupedByFirstCharacter()
: $this->termRepository->findAll();

if ('pagination' === $this->settings['listmode']) {
if (($this->settings['listmode'] ?? 'normal') === 'pagination') {
$paginationCharacters = GeneralUtility::trimExplode(',', $this->settings['pagination']['characters'] ?? '', true);

if (0 < $paginationCharacters) {
Expand All @@ -77,68 +80,88 @@ public function listAction(string $currentCharacter = null): void
}

$this->view->assignMultiple([
'listmode' => $this->settings['listmode'],
'listmode' => $this->settings['listmode'] ?? 'normal',
'terms' => $terms,
]);

return $this->htmlResponse();
}

public function previewNewestAction(): void
/**
* @return \Psr\Http\Message\ResponseInterface
*/
public function previewNewestAction(): ResponseInterface
{
$limit = (int) $this->settings['previewlimit'];
$limit = (int) ($this->settings['previewlimit'] ?? 5);

if (0 >= $limit) {
$limit = TermRepository::DEFAULT_LIMIT;
$limit = AbstractTermRepository::DEFAULT_LIMIT;
}

$this->view->assign(
'terms',
$this->termRepository->findNewest($limit)
);

return $this->htmlResponse();
}

public function previewRandomAction(): void
/**
* @return \Psr\Http\Message\ResponseInterface
*/
public function previewRandomAction(): ResponseInterface
{
$limit = (integer) $this->settings['previewlimit'];
$limit = (int) ($this->settings['previewlimit'] ?? 5);

if (0 >= $limit) {
$limit = TermRepository::DEFAULT_LIMIT;
$limit = AbstractTermRepository::DEFAULT_LIMIT;
}

$this->view->assign(
'terms',
$this->termRepository->findRandom($limit)
);

return $this->htmlResponse();
}

public function previewSelectedAction(): void
/**
* @return \Psr\Http\Message\ResponseInterface
*/
public function previewSelectedAction(): ResponseInterface
{
$previewSelectedUids = GeneralUtility::intExplode(',', $this->settings['previewSelected']);

$this->view->assign(
'terms',
$this->termRepository->findByUids($previewSelectedUids)
);

return $this->htmlResponse();
}

/**
* @param \Featdd\DpnGlossary\Domain\Model\Term $term
* @return \Psr\Http\Message\ResponseInterface
*/
public function showAction(Term $term): void
public function showAction(Term $term): ResponseInterface
{
$this->view->assign('term', $term);

/** @var \Featdd\DpnGlossary\PageTitle\TermPageTitleProvider $pageTitleProvider */
$pageTitleProvider = GeneralUtility::makeInstance(TermPageTitleProvider::class);
$pageTitleProvider->setTitle($term->getSeoTitle());

if (false === empty($term->getMetaDescription())) {
if (!empty($term->getMetaDescription())) {
/** @var \TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry $metaTagManagerRegistry */
$metaTagManagerRegistry = GeneralUtility::makeInstance(MetaTagManagerRegistry::class);
$metaTagManager = $metaTagManagerRegistry->getManagerForProperty('description');

if (true === empty($metaTagManager->getProperty('description'))) {
if (empty($metaTagManager->getProperty('description'))) {
$metaTagManager->addProperty('description', $term->getMetaDescription());
}
}

return $this->htmlResponse();
}
}
2 changes: 1 addition & 1 deletion Classes/DataProcessing/AddTermToMenuProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AddTermToMenuProcessor implements DataProcessorInterface
/**
* @var \Featdd\DpnGlossary\Domain\Repository\TermRepository
*/
protected $termRepository;
protected TermRepository $termRepository;

public function __construct()
{
Expand Down
25 changes: 11 additions & 14 deletions Classes/Domain/Model/AbstractTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,64 +16,61 @@

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;

/**
* @package Featdd\DpnGlossary\Domain\Model
*/
abstract class AbstractTerm extends AbstractEntity implements TermInterface
{
public const TABLE = 'tx_dpnglossary_domain_model_term';

/**
* @var string
*/
protected $name = '';
protected string $name = '';

/**
* @var string
*/
protected $parsingName = '';
protected string $parsingName = '';

/**
* @var string
*/
protected $tooltiptext = '';
protected string $tooltiptext = '';

/**
* @var string
*/
protected $termType = '';
protected string $termType = '';

/**
* @var string
*/
protected $termLang = '';
protected string $termLang = '';

/**
* @var string
*/
protected $termMode = '';
protected string $termMode = '';

/**
* @var bool
*/
protected $excludeFromParsing = false;
protected bool $excludeFromParsing = false;

/**
* @var bool
*/
protected $caseSensitive = false;
protected bool $caseSensitive = false;

/**
* @var int
*/
protected $maxReplacements = -1;
protected int $maxReplacements = -1;

/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Featdd\DpnGlossary\Domain\Model\Synonym>
*/
protected $synonyms;
protected ObjectStorage $synonyms;

public function __construct()
{
Expand Down Expand Up @@ -102,7 +99,7 @@ public function setName(string $name): void
*/
public function getParsingName(): string
{
if (true === empty($this->parsingName)) {
if (empty($this->parsingName)) {
return $this->name;
}

Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Model/Description.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class Description extends AbstractEntity
* @var string
* @Validate(validator="NotEmpty")
*/
protected $meaning = '';
protected string $meaning = '';

/**
* @var string
*/
protected $text = '';
protected string $text = '';

/**
* @return string
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Synonym.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Synonym extends AbstractEntity
* @var string
* @Validate(validator="NotEmpty")
*/
protected $name = '';
protected string $name = '';

/**
* @return string
Expand Down
11 changes: 5 additions & 6 deletions Classes/Domain/Model/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
***/

use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;

Expand All @@ -27,29 +26,29 @@ class Term extends AbstractTerm
/**
* @var string
*/
protected $termLink = '';
protected string $termLink = '';

/**
* @var string
*/
protected $seoTitle = '';
protected string $seoTitle = '';

/**
* @var string
*/
protected $metaDescription = '';
protected string $metaDescription = '';

/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Featdd\DpnGlossary\Domain\Model\Description>
* @Extbase\ORM\Lazy
*/
protected $descriptions;
protected ObjectStorage $descriptions;

/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
* @Extbase\ORM\Lazy
*/
protected $media;
protected ObjectStorage $media;

public function __construct()
{
Expand Down
2 changes: 2 additions & 0 deletions Classes/Domain/Model/TermInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
***/
interface TermInterface
{
public const TABLE = 'tx_dpnglossary_domain_model_term';

/**
* @return string
*/
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/AbstractTermRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ public function findByUids(array $uids): array
{
$query = $this->createQuery();

if (0 === count($uids)) {
if (count($uids) === 0) {
return [];
}

try {
$query->matching(
$query->in('uid', $uids)
);
} catch (InvalidQueryException $e) {
} catch (InvalidQueryException) {
// nothing
}

Expand Down
Loading

0 comments on commit b93351c

Please sign in to comment.