29581.diff

Skeleton - Xavier Perseguers, 2011-09-09 08:34

Download (4.93 KB)

View differences:

ext_localconf.php (working copy)
55 55
	Tx_Identity_Configuration_IdentityProviderInterface::DEFAULT_PROVIDER	=> 'recordUuid',
56 56
);
57 57

  
58
// Register a hook for the extension manager
59
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/tools/em/index.php']['checkDBupdates'][] = 'EXT:identity/Classes/Hooks/class.tx_identity_em_hook.php:tx_identity_em_hook';
60

  
58 61
?>
ext_tables.sql (working copy)
1
#
2
# Table structure for table 'sys_uuid'
3
#
4

  
5
CREATE TABLE sys_identity (
6
  uid int(11) NOT NULL auto_increment,
7
  foreign_tablename varchar(255) NOT NULL default '',
8
  foreign_uid int(11) DEFAULT '0' NOT NULL,
9
  
10
  PRIMARY KEY (uid)
11
);
Classes/Hooks/class.tx_identity_em_hook.php (revision 0)
1
<?php
2
/***************************************************************
3
 *  Copyright notice
4
 *
5
 *  (c) 2011 Xavier Perseguers <xavier@typo3.org>
6
 *  All rights reserved
7
 *
8
 *  This script is part of the TYPO3 project. The TYPO3 project is
9
 *  free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  The GNU General Public License can be found at
15
 *  http://www.gnu.org/copyleft/gpl.html.
16
 *  A copy is found in the textfile GPL.txt and important notices to the license
17
 *  from the author is found in LICENSE.txt distributed with these scripts.
18
 *
19
 *
20
 *  This script is distributed in the hope that it will be useful,
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 *  GNU General Public License for more details.
24
 *
25
 *  This copyright notice MUST APPEAR in all copies of the script!
26
 ***************************************************************/
27

  
28
/**
29
 * Hooks for TYPO3 Extension Manager.
30
 *
31
 * @author Xavier Perseguers <xavier@typo3.org>
32
 *
33
 * @package TYPO3
34
 * @subpackage identity
35
 */
36
class tx_identity_em_hook implements tx_em_Index_CheckDatabaseUpdatesHook {
37

  
38
	/**
39
	 * Hook that allows pre-processing of database structure modifications.
40
	 * The hook implementation may return a user form that will temporarily
41
	 * replace the standard database update form. This allows additional
42
	 * operations to be performed before the database structure gets updated.
43
	 *
44
	 * @param string $extKey: Extension key
45
	 * @param array $extInfo: Extension information array
46
	 * @param array $diff: Database differences
47
	 * @param t3lib_install $instObj: Instance of the installer
48
	 * @param tx_em_Install $parent: The calling parent object
49
	 * @return string Either empty string or a pre-processing user form
50
	 */
51
	public function preProcessDatabaseUpdates($extKey, array $extInfo, array $diff, t3lib_install $instObj, tx_em_Install $parent) {
52
		if ($extKey !== 'identity') {
53
			// TODO: more clever way could be to dynamically extend the tables to be created to
54
			//       automatically include the uuid column for newly installed extensions
55
			return '';
56
		}
57

  
58
		$tables = $this->getOwnTables();
59

  
60
		// TODO: refactor the existing code to define a list of statement like that:
61
		// CREATE TABLE <table> (
62
		//     uuid char(36) NOT NULL default \'\',
63
		//
64
		//     KEY uuid (uuid)
65
		// );
66

  
67
		$definitionFile = t3lib_extMgm::extPath('identity') . 'ext_tables.sql';
68
		t3lib_div::writeFile($definitionFile, $tables);
69
	}
70

  
71
	/**
72
	 * Returns the definition of own EXT:identity tables.
73
	 *
74
	 * @return string
75
	 */
76
	protected function getOwnTables() {
77
		return <<<EOT
78
#
79
# Table structure for table 'sys_identity'
80
#
81
CREATE TABLE sys_identity (
82
	uid int(11) NOT NULL auto_increment,
83
	foreign_tablename varchar(255) NOT NULL DEFAULT '',
84
	foreign_uid int(11) DEFAULT '0' NOT NULL,
85

  
86
	PRIMARY KEY (uid)
87
);
88
EOT;
89
	}
90

  
91
}
92

  
93

  
94
if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/identity/Classes/Hooks/class.tx_identity_em_hook.php'])) {
95
	include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/identity/Classes/Hooks/class.tx_identity_em_hook.php']);
96
}
97

  
98
?>