forked from reinhardfuehricht/typo3-formhandler
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass.ext_update.php
59 lines (53 loc) · 1.66 KB
/
class.ext_update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Typoheads\Formhandler;
use TYPO3\CMS\Backend\Utility\BackendUtility;
class ext_update
{
public function main()
{
$pluginsToMigrate = $this->countListTypePlugins();
if ($pluginsToMigrate > 0) {
$this->migrateListTypePlugins();
}
$remainingPluginsToMigrate = $this->countListTypePlugins();
if ($remainingPluginsToMigrate === 0) {
return "Success: Migrated $pluginsToMigrate formhandler plugins from list_type to CType. The forms should now show up again in the frontend.";
} else {
return "Error: $pluginsToMigrate formhandler plugins should have been migrated, but $remainingPluginsToMigrate are still left.";
}
}
/**
* Activate update script if any pre 2.1 plugins are in the database
*
* @return bool
*/
public function access()
{
return $this->countListTypePlugins() > 0;
}
private function countListTypePlugins()
{
return $this->getDb()->exec_SELECTcountRows(
'*',
'tt_content',
'CType = \'list\' AND list_type = \'formhandler_pi1\'' . BackendUtility::deleteClause('tt_content')
);
}
private function migrateListTypePlugins()
{
$this->getDb()->exec_UPDATEquery(
'tt_content',
'CType = \'list\' AND list_type = \'formhandler_pi1\'' . BackendUtility::deleteClause('tt_content'),
[
'CType' => 'formhandler_pi1'
]
);
}
/**
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
private function getDb()
{
return $GLOBALS['TYPO3_DB'];
}
}