Skip to content

Commit

Permalink
Remove deprecations from dbal
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhj committed Nov 27, 2021
1 parent 6aed3f8 commit 5be7f88
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Migration/ThemeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Contao\CoreBundle\Twig\Loader\ContaoFilesystemLoaderWarmer;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\FetchMode;
use Richardhj\ContaoThemeFramework\Configuration\ThemeManifestConfiguration;
use Richardhj\ContaoThemeFramework\Configuration\YamlLoader;
use Symfony\Component\Config\Definition\Processor;
Expand Down Expand Up @@ -75,7 +74,7 @@ public function shouldRun(): bool
$persistedHash = $this->connection
->executeQuery('SELECT manifestHash FROM tl_theme WHERE alias=:alias', [
'alias' => $manifest->getRelativePath(),
])->fetchColumn();
])->fetchOne();

if ($persistedHash !== $manifestHash) {
return true;
Expand Down Expand Up @@ -122,7 +121,7 @@ private function persistManifest(string $themeName, array $manifest, string $man
{
$row = $this->connection
->executeQuery('SELECT id, manifestHash FROM tl_theme WHERE alias=:alias', ['alias' => $themeName])
->fetch(FetchMode::ASSOCIATIVE);
->fetchAssociative();

// Prevent array-access error when theme not found
$row = false === $row ? [] : $row;
Expand Down Expand Up @@ -202,12 +201,12 @@ private function persistLayouts($layouts, int $themeId)
foreach ($layouts as $layoutName => $layout) {
$layoutId = $this->connection
->executeQuery('SELECT id FROM tl_layout WHERE pid=:pid AND alias=:alias', ['pid' => $themeId, 'alias' => $layoutName])
->fetch(FetchMode::NUMERIC)[0] ?? null;
->fetchOne();

$data = array_merge(['framework' => ''], $layout);
$data = array_merge($data, ['alias' => $layoutName, 'pid' => $themeId, 'tstamp' => time()]);

if (null === $layoutId) {
if (false === $layoutId) {
// For new layouts, enable the article module in the main column
$data = array_merge(['modules' => serialize([['mod' => '0', 'col' => 'main', 'enable' => '1']])], $data);

Expand All @@ -232,15 +231,16 @@ private function persistImageSizes(array $imageSizes, int $themeId): void
foreach ($imageSizes as $imageSizeName => $imageSize) {
$imageSizeId = $this->connection
->executeQuery('SELECT id FROM tl_image_size WHERE pid=:pid AND alias=:alias', ['pid' => $themeId, 'alias' => $imageSizeName])
->fetch(FetchMode::NUMERIC)[0] ?? null;
->fetchOne();

$items = $imageSize['items'];
unset($imageSize['items']);

$data = array_merge($imageSize, ['alias' => $imageSizeName, 'name' => $imageSizeName, 'pid' => $themeId, 'tstamp' => time()]);

if (null === $imageSizeId) {
if (false === $imageSizeId) {
$this->connection->insert('tl_image_size', $data);
$imageSizeId = $this->connection->lastInsertId();
} else {
$this->connection->update('tl_image_size', $data, ['id' => $imageSizeId]);
}
Expand Down

0 comments on commit 5be7f88

Please sign in to comment.