Skip to content

Commit e9c7608

Browse files
authoredDec 13, 2022
Merge pull request #29 from b13/task/v12
[!!!][TASK] change dependencies
2 parents eda4b64 + 445eb57 commit e9c7608

9 files changed

+43
-83
lines changed
 

‎Classes/Command/MigrateFieldsCommand.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
declare(strict_types = 1);
2+
3+
declare(strict_types=1);
34
namespace B13\Masi\Command;
45

56
/*
@@ -14,8 +15,6 @@
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617
use Symfony\Component\Console\Style\SymfonyStyle;
17-
use TYPO3\CMS\Core\Core\ClassLoadingInformation;
18-
use TYPO3\CMS\Core\Core\Environment;
1918
use TYPO3\CMS\Core\Database\Connection;
2019
use TYPO3\CMS\Core\Database\ConnectionPool;
2120
use TYPO3\CMS\Core\Utility\GeneralUtility;

‎Classes/SlugModifier.php

+23-56
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
declare(strict_types = 1);
2+
3+
declare(strict_types=1);
34
namespace B13\Masi;
45

56
/*
@@ -11,6 +12,7 @@
1112
*/
1213

1314
use TYPO3\CMS\Backend\Utility\BackendUtility;
15+
use TYPO3\CMS\Core\Database\ConnectionPool;
1416
use TYPO3\CMS\Core\DataHandling\SlugHelper;
1517
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
1618
use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -20,50 +22,23 @@
2022
*/
2123
class SlugModifier
2224
{
23-
/**
24-
* @var string
25-
*/
26-
protected $tableName;
27-
28-
/**
29-
* @var string
30-
*/
31-
protected $fieldName;
32-
33-
/**
34-
* @var int
35-
*/
36-
protected $workspaceId;
37-
38-
/**
39-
* @var array
40-
*/
41-
protected $configuration;
25+
protected string $tableName;
26+
protected string $fieldName;
27+
protected int $workspaceId;
28+
protected array $configuration;
4229

4330
/**
4431
* Defines whether the slug field should start with "/".
4532
* For pages (due to rootline functionality), this is a must have, otherwise the root level page
4633
* would have an empty value.
47-
*
48-
* @var bool
4934
*/
50-
protected $prependSlashInSlug;
35+
protected bool $prependSlashInSlug;
5136

52-
/**
53-
* @var int
54-
*/
55-
protected $pid;
56-
/**
57-
* @var array
58-
*/
59-
protected $recordData;
37+
protected int $pid;
38+
protected array $recordData;
6039

6140
/**
6241
* Hooks into after a page URL was generated.
63-
*
64-
* @param array $parameters
65-
* @param SlugHelper $helper
66-
* @return string
6742
*/
6843
public function modifyGeneratedSlugForPage(array $parameters, SlugHelper $helper): string
6944
{
@@ -80,15 +55,8 @@ public function modifyGeneratedSlugForPage(array $parameters, SlugHelper $helper
8055

8156
/**
8257
* Take over hook values to our own class.
83-
*
84-
* @param array $configuration
85-
* @param $tableName
86-
* @param $fieldName
87-
* @param $pid
88-
* @param $workspaceId
89-
* @param $record
9058
*/
91-
protected function resolveHookParameters(array $configuration, $tableName, $fieldName, $pid, $workspaceId, $record)
59+
protected function resolveHookParameters(array $configuration, string $tableName, string $fieldName, int $pid, int $workspaceId, array $record): void
9260
{
9361
$overrides = BackendUtility::getPagesTSconfig($pid)['TCEMAIN.'][$tableName . '.'][$fieldName . '.'] ?? [];
9462
if ($overrides) {
@@ -108,6 +76,17 @@ protected function resolveHookParameters(array $configuration, $tableName, $fiel
10876
$this->pid = $pid;
10977
$this->workspaceId = $workspaceId;
11078
$this->recordData = $record;
79+
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
80+
$row = $queryBuilder->select('*')
81+
->from('pages')
82+
->where(
83+
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($record['uid'], \PDO::PARAM_INT))
84+
)
85+
->execute()
86+
->fetchAssociative();
87+
if ($row !== false) {
88+
$this->recordData = $row;
89+
}
11190

11291
if ($tableName === 'pages' && $fieldName === 'slug') {
11392
$this->prependSlashInSlug = true;
@@ -118,9 +97,6 @@ protected function resolveHookParameters(array $configuration, $tableName, $fiel
11897

11998
/**
12099
* Re-creates the slug like core, however, uses our custom "resolveParentPageRecord" method.
121-
*
122-
* @param SlugHelper $helper
123-
* @return string
124100
*/
125101
protected function regenerateSlug(SlugHelper $helper): string
126102
{
@@ -168,7 +144,7 @@ protected function regenerateSlug(SlugHelper $helper): string
168144
$slug = $helper->sanitize($slug);
169145
// No valid data found
170146
if ($slug === '' || $slug === '/') {
171-
$slug = 'default-' . GeneralUtility::shortMD5(json_encode($this->recordData));
147+
$slug = 'default-' . substr(md5(json_encode($this->recordData)), 0, 10);
172148
}
173149
if ($this->prependSlashInSlug && ($slug[0] ?? '') !== '/') {
174150
$slug = '/' . $slug;
@@ -183,14 +159,9 @@ protected function regenerateSlug(SlugHelper $helper): string
183159
/**
184160
* Similar to core logic, but a bit different:
185161
* Fetches the parent page, but only respects recyclers! includes sysfolders
186-
*
187-
* @param int $pid
188-
* @param int $languageId
189-
* @return array|null
190162
*/
191163
protected function resolveParentPageRecord(int $pid, int $languageId): ?array
192164
{
193-
$parentPageRecord = null;
194165
$rootLine = BackendUtility::BEgetRootLine($pid, '', true, ['nav_title', 'exclude_slug_for_subpages']);
195166
do {
196167
$parentPageRecord = array_shift($rootLine) ?? [];
@@ -202,10 +173,6 @@ protected function resolveParentPageRecord(int $pid, int $languageId): ?array
202173

203174
/**
204175
* Fetches a record translation if there is one and returns that one instead.
205-
*
206-
* @param array $page
207-
* @param int $languageId
208-
* @return array
209176
*/
210177
protected function tryRecordOverlay(array $page, int $languageId): array
211178
{

‎Classes/Updates/MigrateRealUrlExcludeField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function updateNecessary(): bool
9292
public function getPrerequisites(): array
9393
{
9494
return [
95-
DatabaseUpdatedPrerequisite::class
95+
DatabaseUpdatedPrerequisite::class,
9696
];
9797
}
9898
}

‎Configuration/Commands.php

-8
This file was deleted.

‎Configuration/TCA/Overrides/pages.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
2-
defined('TYPO3_MODE') or die();
32

3+
defined('TYPO3') or die();
44

55
$GLOBALS['TCA']['pages']['columns']['slug']['config']['generatorOptions']['postModifiers'][] = \B13\Masi\SlugModifier::class . '->modifyGeneratedSlugForPage';
66

7-
87
$additionalColumns = [
98
'exclude_slug_for_subpages' => [
109
'exclude' => true,
@@ -16,16 +15,15 @@
1615
[
1716
0 => '',
1817
1 => '',
19-
]
18+
],
2019
],
2120
'behaviour' => [
22-
'allowLanguageSynchronization' => true
23-
]
24-
]
25-
]
21+
'allowLanguageSynchronization' => true,
22+
],
23+
],
24+
],
2625
];
2726

2827
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $additionalColumns);
2928
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette('pages', 'title', 'exclude_slug_for_subpages', 'after:slug');
3029
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette('pages', 'titleonly', 'exclude_slug_for_subpages', 'after:slug');
31-

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# masi - Extend TYPO3's URL Handling
22

3-
Masi is the missing piece for the people who want to customize _everything_ when generating URLs in TYPO3 v9+.
3+
Masi is the missing piece for the people who want to customize _everything_ when generating URLs in TYPO3 v10+.
44

55
## Features
66

7-
1. TYPO3 v9 skips pages of type "SysFolder" and "Spacers" by default when generating the URL of subpages. _masi_ includes them by default!
7+
1. TYPO3 v10 skips pages of type "SysFolder" and "Spacers" by default when generating the URL of subpages. _masi_ includes them by default!
88

99
2. _masi_ also ships with a new checkbox for pages, to exclude a certain page slug when generating subpages. This way, you can exclude only certain SysFolders.
1010

@@ -36,7 +36,7 @@ Of course, all the values within the "slug" field can be changed by the editor,
3636

3737
Use it via `composer req b13/masi` or install the Extension `masi` from the TYPO3 Extension Repository.
3838

39-
_masi_ requires TYPO3 v9.5.6 or later.
39+
_masi_ requires TYPO3 v10.4.0 or later.
4040

4141
If you want to migrate from RealURL, execute this one-time command as long as the database field `pages.tx_realurl_exclude` exists, and transfers the data to `pages.exclude_slug_for_subpages`:
4242

@@ -51,7 +51,7 @@ As TYPO3 Core, _masi_ is licensed under GPL2 or later. See the LICENSE file for
5151

5252
## Background, Authors & Further Maintenance
5353

54-
This extension was created as a show-case on what you can do with one magic hook for TYPO3 v9 and customize
54+
This extension was created as a show-case on what you can do with one magic hook for TYPO3 v10 and customize
5555
so many things.
5656

5757
TYPO3 community often requests functionality, which can be put in small and efficient extensions, and _masi_ does

‎composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"homepage": "https://github.com/b13/masi",
1414
"license": ["GPL-2.0-or-later"],
1515
"require": {
16-
"typo3/cms-core": "^9.5.6 || ^10.0 || ^11.0"
16+
"php": "^7.4 || ~8.0",
17+
"typo3/cms-core": "^10.4 || ^11.5 || ^12.0"
1718
},
1819
"replace": {
1920
"typo3-ter/masi": "self.version"

‎ext_emconf.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
$EM_CONF[$_EXTKEY] = [
34
'title' => 'Masi - customize your Page URLs',
45
'description' => 'Adds convenient features for excluding pages when generating URLs.',
@@ -7,10 +8,10 @@
78
'author' => 'Benni Mack',
89
'author_email' => 'benjamin.mack@b13.com',
910
'author_company' => 'b13 GmbH',
10-
'version' => '1.2.2',
11+
'version' => '2.0.0',
1112
'constraints' => [
1213
'depends' => [
13-
'typo3' => '9.5.0-11.5.99',
14+
'typo3' => '10.4.0-12.99.99',
1415
],
1516
],
1617
];

‎ext_localconf.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
defined('TYPO3') or die();
4+
35
/**
46
* Registering Upgrade Wizards
57
*/

0 commit comments

Comments
 (0)
Please sign in to comment.