ced90d8c7da166701681b8ce8e0c6292b097ac9f
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Updates / AbstractDatabaseSchemaUpdate.php
1 <?php
2 namespace TYPO3\CMS\Install\Updates;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2014 Stephan Großberndt <stephan@grossberndt.de>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the text file GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Contains the update class to create and alter tables, fields and keys to comply to the database schema
32 *
33 * @author Stephan Großberndt <stephan@grossberndt.de>
34 */
35 abstract class AbstractDatabaseSchemaUpdate extends AbstractUpdate {
36
37 /**
38 * @var string
39 */
40 protected $title;
41
42 /**
43 * @var \TYPO3\CMS\Install\Service\SqlSchemaMigrationService
44 */
45 protected $schemaMigrationService;
46
47 /**
48 * @var \TYPO3\CMS\Install\Service\SqlExpectedSchemaService
49 */
50 protected $expectedSchemaService;
51
52 /**
53 * Constructor function.
54 */
55 public function __construct() {
56 $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
57 $this->schemaMigrationService = $objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
58 $this->expectedSchemaService = $objectManager->get('TYPO3\\CMS\\Install\\Service\\SqlExpectedSchemaService');
59 }
60
61 /**
62 * Compare current and expected database schemas and return the database differences
63 *
64 * @return array database differences
65 */
66 protected function getDatabaseDifferences() {
67 $expectedSchema = $this->expectedSchemaService->getExpectedDatabaseSchema();
68 $currentSchema = $this->schemaMigrationService->getFieldDefinitions_database();
69
70 // Difference from expected to current
71 return $this->schemaMigrationService->getDatabaseExtra($expectedSchema, $currentSchema);
72 }
73
74 }