first commit

This commit is contained in:
salam committed 2026-10-06 19:40:28 +02:00
commit e81864e683
2984 files changed
+267797

No files matched your search

@@ -0,0 +1,173 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use BK2K\BootstrapPackage\Updates\Criteria\CreaterThanCriteria;
use BK2K\BootstrapPackage\Updates\Criteria\EqualStringCriteria;
use BK2K\BootstrapPackage\Updates\Criteria\InCriteria;
use BK2K\BootstrapPackage\Updates\Criteria\LikeCriteria;
use Doctrine\DBAL\Result;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Updates\DatabaseUpdatedPrerequisite;
abstract class AbstractUpdate
{
const CONDITION_AND = 'AND';
const CONDITION_OR = 'OR';
/**
* @var string
*/
protected $title = '';
/**
* @var string
*/
protected $description = '';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var Connection|null
*/
protected $connection = null;
public function getIdentifier(): string
{
return get_class($this);
}
public function getTitle(): string
{
return $this->title;
}
public function getDescription(): string
{
return $this->description;
}
public function getPrerequisites(): array
{
return [
DatabaseUpdatedPrerequisite::class
];
}
protected function getConnection(): Connection
{
if ($this->connection === null) {
$this->connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->table);
}
return $this->connection;
}
protected function createQueryBuilder(): QueryBuilder
{
$queryBuilder = $this->getConnection()->createQueryBuilder();
$queryBuilder->getRestrictions()->removeAll();
return $queryBuilder;
}
protected function tableHasColumn(string $column): bool
{
/** @phpstan-ignore-next-line */
if (method_exists($this->getConnection(), 'createSchemaManager')) {
$schemaManager = $this->getConnection()->createSchemaManager();
} else {
$schemaManager = $this->getConnection()->getSchemaManager();
}
$tableColumns = $schemaManager->listTableColumns($this->table);
if (array_key_exists($column, $tableColumns)) {
return true;
}
return false;
}
protected function createCreaterThanCriteria(QueryBuilder $queryBuilder, string $field, int $value): CreaterThanCriteria
{
return (new CreaterThanCriteria($queryBuilder, $field))
->setValue($value);
}
protected function createEqualStringCriteria(QueryBuilder $queryBuilder, string $field, string $value): EqualStringCriteria
{
return (new EqualStringCriteria($queryBuilder, $field))
->setValue($value);
}
protected function createInCriteria(QueryBuilder $queryBuilder, string $field, array $values): InCriteria
{
return (new InCriteria($queryBuilder, $field))
->setValues($values);
}
protected function createLikeCriteria(QueryBuilder $queryBuilder, string $field, string $value): LikeCriteria
{
return (new LikeCriteria($queryBuilder, $field))
->setValue($value);
}
protected function getRecordsByCriteria(QueryBuilder $queryBuilder, array $criteria, string $condition = self::CONDITION_AND): array
{
$queryBuilder->select('*');
$queryBuilder->from($this->table);
if ($condition === self::CONDITION_AND) {
$queryBuilder->where(...$criteria);
} else {
$queryBuilder->orWhere(...$criteria);
}
/** @phpstan-ignore-next-line */
if (method_exists($queryBuilder, 'executeQuery')) {
$result = $queryBuilder->executeQuery();
} else {
/** @var Result $result */
/** @phpstan-ignore-next-line */
$result = $queryBuilder->execute();
}
/** @phpstan-ignore-next-line */
if (method_exists($result, 'fetchAllAssociative')) {
return $result->fetchAllAssociative(); /** @phpstan-ignore-line */
}
return $result->fetchAll(\PDO::FETCH_ASSOC); /** @phpstan-ignore-line */
}
protected function updateRecord(int $uid, array $values): void
{
$queryBuilder = $this->createQueryBuilder();
$queryBuilder->update($this->table)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \PDO::PARAM_INT)));
foreach ($values as $field => $value) {
$queryBuilder->set($field, $value);
}
/** @phpstan-ignore-next-line */
if (method_exists($queryBuilder, 'executeStatement')) {
$queryBuilder->executeStatement();
} else {
$queryBuilder->execute();
}
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* AccordionContentElementUpdate
*/
class AccordionContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate accordion content element';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'CType';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_accordion')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_accordion')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => 'accordion']
);
}
return true;
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* AccordionMediaOrientUpdate
*/
class AccordionMediaOrientUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate media orientation of accordion content element';
/**
* @var string
*/
protected $table = 'tx_bootstrappackage_accordion_item';
/**
* @var string
*/
protected $field = 'mediaorient';
/**
* @var array
*/
protected $mapping = [
0 => 'left',
1 => 'right'
];
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
if (null !== $newValue = $this->mapValues(intval($record[$this->field]))) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => $newValue]
);
}
}
return true;
}
protected function mapValues(int $value): ?string
{
if (array_key_exists($value, $this->mapping)) {
return $this->mapping[$value];
}
return null;
}
}
@@ -0,0 +1,89 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* BackendLayoutUpdate
*/
class BackendLayoutUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate backend layouts';
/**
* @var string
*/
protected $table = 'pages';
/**
* @var array
*/
protected $mapping = [
'pagets__clean' => 'pagets__simple',
'pagets__default_clean' => 'pagets__simple',
'pagets__default_2_columns' => 'pagets__2_columns',
'pagets__default_2_columns_25_75' => 'pagets__2_columns_25_75',
'pagets__default_2_columns_50_50' => 'pagets__2_columns_50_50',
'pagets__default_2_columns_offset_right' => 'pagets__2_columns_offset_right',
'pagets__default_3_columns' => 'pagets__3_columns',
'pagets__default_subnavigation_right' => 'pagets__subnavigation_right',
'pagets__default_subnavigation_right_2_columns' => 'pagets__subnavigation_right_2_columns',
'pagets__default_subnavigation_left' => 'pagets__subnavigation_left',
'pagets__default_subnavigation_left_2_columns' => 'pagets__subnavigation_left_2_columns'
];
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createInCriteria($queryBuilder, 'backend_layout', array_keys($this->mapping)),
$this->createInCriteria($queryBuilder, 'backend_layout_next_level', array_keys($this->mapping)),
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria, AbstractUpdate::CONDITION_OR);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createInCriteria($queryBuilder, 'backend_layout', array_keys($this->mapping)),
$this->createInCriteria($queryBuilder, 'backend_layout_next_level', array_keys($this->mapping)),
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria, AbstractUpdate::CONDITION_OR);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[
'backend_layout' => $this->mapValues(strval($record['backend_layout'])),
'backend_layout_next_level' => $this->mapValues(strval($record['backend_layout_next_level']))
]
);
}
return true;
}
protected function mapValues(string $value): string
{
if (array_key_exists($value, $this->mapping)) {
return $this->mapping[$value];
}
return $value;
}
}
@@ -0,0 +1,75 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* BulletContentElementUpdate
*/
class BulletContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate bullet content element';
/**
* @var string
*/
protected $table = 'tt_content';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createEqualStringCriteria($queryBuilder, 'CType', 'bullets'),
$this->createInCriteria($queryBuilder, 'layout', [100, 110, 120, 130]),
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createEqualStringCriteria($queryBuilder, 'CType', 'bullets'),
$this->createInCriteria($queryBuilder, 'layout', [100, 110, 120, 130]),
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[
'layout' => (string) 0,
'bullets_type' => (string) $this->mapValues(intval($record['layout']))
]
);
}
return true;
}
protected function mapValues(int $layout): int
{
$mapping = [
110 => 1
];
if (array_key_exists($layout, $mapping)) {
return $mapping[$layout];
}
return 0;
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* CarouselContentElementUpdate
*/
class CarouselContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate carousel content element';
/**
* @var string
*/
protected $table = 'tt_content';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, 'CType', 'bootstrap_package_carousel')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, 'CType', 'bootstrap_package_carousel')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[
'layout' => $this->resetLayout(intval($record['layout'])),
'CType' => $this->mapValues(intval($record['layout']))
]
);
}
return true;
}
protected function resetLayout(int $layout): string
{
if (in_array($layout, [100, 110, 120], true)) {
return '0';
}
return (string)$layout;
}
protected function mapValues(int $layout): string
{
$mapping = [
110 => 'carousel_small',
120 => 'carousel_fullscreen'
];
if (array_key_exists($layout, $mapping)) {
return $mapping[$layout];
}
return 'carousel';
}
}
@@ -0,0 +1,55 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* CarouselItemLayoutUpdate
*/
class CarouselItemLayoutUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate carousel item layouts';
/**
* @var string
*/
protected $table = 'tx_bootstrappackage_carousel_item';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, 'layout', '')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, 'layout', '')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
['layout' => 'custom']
);
}
return true;
}
}
@@ -0,0 +1,67 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* CarouselItemTypeUpdate
*/
class CarouselItemTypeUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate carousel item types';
/**
* @var string
*/
protected $table = 'tx_bootstrappackage_carousel_item';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, 'item_type', ['textandimage', 'backgroundimage'])];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, 'item_type', ['textandimage', 'backgroundimage'])];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
['item_type' => $this->mapValues(strval($record['item_type']))]
);
}
return true;
}
protected function mapValues(string $type): string
{
$mapping = [
'textandimage' => 'text_and_image',
'backgroundimage' => 'background_image'
];
if (array_key_exists($type, $mapping)) {
return $mapping[$type];
}
return 'header';
}
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates\Criteria;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
abstract class AbstractCriteria
{
/**
* @var QueryBuilder
*/
protected $queryBuilder;
/**
* @var string
*/
protected $field;
public function __construct(QueryBuilder $queryBuilder, string $field)
{
$this->queryBuilder = $queryBuilder;
$this->field = $field;
}
public function getField(): string
{
return $this->field;
}
}
@@ -0,0 +1,38 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates\Criteria;
class CreaterThanCriteria extends AbstractCriteria implements CriteriaInterface
{
/**
* @var int
*/
protected $value = 0;
public function setValue(int $value): self
{
$this->value = $value;
return $this;
}
public function getValue(): int
{
return $this->value;
}
public function __toString(): string
{
return $this->queryBuilder->expr()->gt(
$this->getField(),
$this->getValue()
);
}
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates\Criteria;
interface CriteriaInterface
{
public function __toString(): string;
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates\Criteria;
use TYPO3\CMS\Core\Database\Connection;
class EqualStringCriteria extends AbstractCriteria implements CriteriaInterface
{
/**
* @var string
*/
protected $value = '';
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getValue(): string
{
return $this->value;
}
public function __toString(): string
{
return $this->queryBuilder->expr()->eq(
$this->getField(),
$this->queryBuilder->createNamedParameter(
$this->getValue(),
Connection::PARAM_STR
)
);
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates\Criteria;
use TYPO3\CMS\Core\Database\Connection;
class InCriteria extends AbstractCriteria implements CriteriaInterface
{
/**
* @var array
*/
protected $values = [];
public function setValues(array $values): self
{
$this->values = $values;
return $this;
}
public function getValues(): array
{
return $this->values;
}
public function __toString(): string
{
return $this->queryBuilder->expr()->in(
$this->getField(),
$this->queryBuilder->createNamedParameter(
$this->getValues(),
Connection::PARAM_STR_ARRAY
)
);
}
}
@@ -0,0 +1,38 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates\Criteria;
class LikeCriteria extends AbstractCriteria implements CriteriaInterface
{
/**
* @var string
*/
protected $value = '';
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getValue(): string
{
return $this->value;
}
public function __toString(): string
{
return $this->queryBuilder->expr()->like(
$this->getField(),
$this->queryBuilder->expr()->literal($this->getValue())
);
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types = 1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* ExternalMediaContentElementUpdate
*/
class ExternalMediaContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate external media content element';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'CType';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_external_media')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_external_media')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => 'external_media']
);
}
return true;
}
}
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* FrameClassToBackgroundUpdate
*/
class FrameClassToBackgroundUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate obsolete frame_class options to background color';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'frame_class';
/**
* @var array
*/
protected $mapping = [
'well' => 'light',
'jumbotron' => 'primary'
];
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
if (null !== $newValue = $this->mapValues(strval($record[$this->field]))) {
$this->updateRecord(
(int) $record['uid'],
[
$this->field => 'default',
'background_color_class' => $newValue
]
);
}
}
return true;
}
protected function mapValues(string $value): ?string
{
if (array_key_exists($value, $this->mapping)) {
return $this->mapping[$value];
}
return null;
}
}
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* FrameClassUpdate
*/
class FrameClassUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate the field "section_frame" for all content elements to "frame_class"';
/**
* @var string
*/
protected $table = 'tt_content';
public function updateNecessary(): bool
{
if (!$this->tableHasColumn('section_frame')) {
return false;
}
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createCreaterThanCriteria($queryBuilder, 'section_frame', 0)];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createCreaterThanCriteria($queryBuilder, 'section_frame', 0)];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[
'section_frame' => '0',
'frame_class' => $this->mapSectionFrame(intval($record['section_frame']))
]
);
}
return true;
}
protected function mapSectionFrame(int $sectionFrame): string
{
$mapping = [
0 => 'default',
5 => 'ruler-before',
6 => 'ruler-after',
10 => 'indent',
11 => 'indent-left',
12 => 'indent-right',
20 => 'well',
21 => 'jumbotron',
66 => 'none'
];
if (array_key_exists($sectionFrame, $mapping)) {
return $mapping[$sectionFrame];
}
return 'custom-' . $sectionFrame;
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* ListGroupContentElementUpdate
*/
class ListGroupContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate list group content element';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'CType';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_listgroup')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_listgroup')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => 'listgroup']
);
}
return true;
}
}
@@ -0,0 +1,74 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* PanelContentElementUpdate
*/
class PanelContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate panel content element';
/**
* @var string
*/
protected $table = 'tt_content';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, 'CType', 'bootstrap_package_panel')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, 'CType', 'bootstrap_package_panel')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[
'CType' => 'panel',
'layout' => '0',
'panel_class' => $this->mapValues(intval($record['layout']))
]
);
}
return true;
}
protected function mapValues(int $layout): string
{
$mapping = [
110 => 'primary',
120 => 'success',
130 => 'info',
140 => 'warning',
150 => 'danger',
];
if (array_key_exists($layout, $mapping)) {
return $mapping[$layout];
}
return 'default';
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TabContentElementUpdate
*/
class TabContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate tab content element';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'CType';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_tab')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_tab')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => 'tab']
);
}
return true;
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TabMediaOrientUpdate
*/
class TabMediaOrientUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate media orientation of tab content element';
/**
* @var string
*/
protected $table = 'tx_bootstrappackage_tab_item';
/**
* @var string
*/
protected $field = 'mediaorient';
/**
* @var array
*/
protected $mapping = [
0 => 'left',
1 => 'right'
];
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
if (null !== $newValue = $this->mapValues(intval($record[$this->field]))) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => $newValue]
);
}
}
return true;
}
protected function mapValues(int $value): ?string
{
if (array_key_exists($value, $this->mapping)) {
return $this->mapping[$value];
}
return null;
}
}
@@ -0,0 +1,77 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TableContentElementUpdate
*/
class TableContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate table content element';
/**
* @var string
*/
protected $table = 'tt_content';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createEqualStringCriteria($queryBuilder, 'CType', 'table'),
$this->createInCriteria($queryBuilder, 'layout', [100, 110, 120, 130, 140, 150]),
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createEqualStringCriteria($queryBuilder, 'CType', 'table'),
$this->createInCriteria($queryBuilder, 'layout', [100, 110, 120, 130, 140, 150]),
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[
'layout' => '0',
'table_class' => $this->mapValues(intval($record['layout']))
]
);
}
return true;
}
protected function mapValues(int $layout): string
{
$mapping = [
100 => '',
110 => '',
120 => 'striped',
130 => 'bordered',
140 => 'hover',
150 => 'condensed',
];
return $mapping[$layout];
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TexticonContentElementUpdate
*/
class TexticonContentElementUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate text and icon content element';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'CType';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_texticon')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createEqualStringCriteria($queryBuilder, $this->field, 'bootstrap_package_texticon')];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => 'texticon']
);
}
return true;
}
}
@@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TexticonIconUpdate
*/
class TexticonIconUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate text and icon identifier and name';
/**
* @var string
*/
protected $table = 'tt_content';
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createLikeCriteria($queryBuilder, 'icon', 'Glyphicons%'),
$this->createLikeCriteria($queryBuilder, 'icon', 'Ionicons%')
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria, AbstractUpdate::CONDITION_OR);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [
$this->createLikeCriteria($queryBuilder, 'icon', 'Glyphicons%'),
$this->createLikeCriteria($queryBuilder, 'icon', 'Ionicons%')
];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria, AbstractUpdate::CONDITION_OR);
foreach ($records as $record) {
$icon = explode('__', strval($record['icon']));
$this->updateRecord(
(int) $record['uid'],
[
'icon' => 'EXT:bootstrap_package/Resources/Public/Images/Icons/' . $icon[0] . '/' . $icon[1] . '.svg',
'icon_set' => 'EXT:bootstrap_package/Resources/Public/Images/Icons/' . $icon[0] . '/',
]
);
}
return true;
}
}
@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TexticonSizeUpdate
*/
class TexticonSizeUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate text and icon size options';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'icon_size';
/**
* @var array
*/
protected $mapping = [
0 => 'default',
1 => 'medium',
2 => 'large',
3 => 'awesome'
];
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
if (null !== $newValue = $this->mapValues(intval($record[$this->field]))) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => $newValue]
);
}
}
return true;
}
protected function mapValues(int $value): ?string
{
if (array_key_exists($value, $this->mapping)) {
return $this->mapping[$value];
}
return null;
}
}
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/
namespace BK2K\BootstrapPackage\Updates;
use TYPO3\CMS\Install\Updates\RepeatableInterface;
use TYPO3\CMS\Install\Updates\UpgradeWizardInterface;
/**
* TexticonTypeUpdate
*/
class TexticonTypeUpdate extends AbstractUpdate implements UpgradeWizardInterface, RepeatableInterface
{
/**
* @var string
*/
protected $title = 'EXT:bootstrap_package: Migrate text and icon type options';
/**
* @var string
*/
protected $table = 'tt_content';
/**
* @var string
*/
protected $field = 'icon_type';
/**
* @var array
*/
protected $mapping = [
0 => 'default',
1 => 'square',
2 => 'circle'
];
public function updateNecessary(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
return (bool) count($records);
}
public function executeUpdate(): bool
{
$queryBuilder = $this->createQueryBuilder();
$criteria = [$this->createInCriteria($queryBuilder, $this->field, array_keys($this->mapping))];
$records = $this->getRecordsByCriteria($queryBuilder, $criteria);
foreach ($records as $record) {
if (null !== $newValue = $this->mapValues(intval($record[$this->field]))) {
$this->updateRecord(
(int) $record['uid'],
[$this->field => $newValue]
);
}
}
return true;
}
protected function mapValues(int $value): ?string
{
if (array_key_exists($value, $this->mapping)) {
return $this->mapping[$value];
}
return null;
}
}