TYPO3 CMS  TYPO3_8-7
PageShortcutParentUpdate.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
28 {
32  protected $title = 'Update page shortcuts with shortcut type "Parent of selected or current page"';
33 
40  public function checkForUpdate(&$description)
41  {
42  if ($this->isWizardDone()) {
43  return false;
44  }
45 
46  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
47  $queryBuilder->getRestrictions()->removeAll();
48  $numberOfAffectedPages = $queryBuilder->count('uid')
49  ->from('pages')
50  ->where(
51  $queryBuilder->expr()->neq('shortcut', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
52  $queryBuilder->expr()->eq(
53  'shortcut_mode',
54  $queryBuilder->createNamedParameter(PageRepository::SHORTCUT_MODE_PARENT_PAGE, \PDO::PARAM_INT)
55  )
56  )
57  ->execute()
58  ->fetchColumn(0);
59 
60  if ($numberOfAffectedPages > 0) {
61  $description = 'There are some shortcut pages that need to be updated in order to preserve their current'
62  . ' behaviour.';
63  }
64 
65  return (bool)$numberOfAffectedPages;
66  }
67 
75  public function performUpdate(array &$databaseQueries, &$customMessage)
76  {
77  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
78  $queryBuilder->update('pages')
79  ->where(
80  $queryBuilder->expr()->neq('shortcut', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
81  $queryBuilder->expr()->eq(
82  'shortcut_mode',
83  $queryBuilder->createNamedParameter(PageRepository::SHORTCUT_MODE_PARENT_PAGE, \PDO::PARAM_INT)
84  )
85  )
86  ->set('shortcut', 0, false);
87  $databaseQueries[] = $queryBuilder->getSQL();
88  $queryBuilder->execute();
89  $this->markWizardAsDone();
90  return true;
91  }
92 }
performUpdate(array &$databaseQueries, &$customMessage)
static makeInstance($className,... $constructorArguments)