forked from Portugao/Video
/
Installer.php
85 lines (77 loc) · 3.75 KB
/
Installer.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* MUVideo.
*
* @copyright Michael Ueberschaer (MU)
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
* @package MUVideo
* @author Michael Ueberschaer <kontakt@webdesign-in-bremen.com>.
* @link http://webdesign-in-bremen.com
* @link http://zikula.org
* @version Generated by ModuleStudio 0.6.2 (http://modulestudio.de).
*/
/**
* Installer implementation class.
*/
class MUVideo_Installer extends MUVideo_Base_Installer
{
/**
* Upgrade the MUVideo application from an older version.
*
* If the upgrade fails at some point, it returns the last upgraded version.
*
* @param integer $oldVersion Version to upgrade from.
*
* @return boolean True on success, false otherwise.
*/
public function upgrade($oldVersion)
{
// Upgrade dependent on old version number
switch ($oldVersion) {
case '1.0.0':
// update the database schema
try {
DoctrineHelper::updateSchema($this->entityManager, $this->listEntityClasses());
} catch (\Exception $e) {
if (System::isDevelopmentMode()) {
return LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
}
return LogUtil::registerError($this->__f('An error was encountered while updating tables for the %s extension.', array($this->getName())));
}
$categoryRegistryIdsPerEntity = array();
// add default entry for category registry (property named Main)
include_once 'modules/MUVideo/lib/MUVideo/Api/Base/Category.php';
include_once 'modules/MUVideo/lib/MUVideo/Api/Category.php';
$categoryApi = new MUVideo_Api_Category($this->serviceManager);
$categoryGlobal = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Global');
$registryData = array();
$registryData['modname'] = $this->name;
$registryData['table'] = 'Collection';
$registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Collection'));
$registryData['category_id'] = $categoryGlobal['id'];
$registryData['id'] = false;
if (!DBUtil::insertObject($registryData, 'categories_registry')) {
LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('collection')));
}
$categoryRegistryIdsPerEntity['collection'] = $registryData['id'];
$registryData = array();
$registryData['modname'] = $this->name;
$registryData['table'] = 'Movie';
$registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Movie'));
$registryData['category_id'] = $categoryGlobal['id'];
$registryData['id'] = false;
if (!DBUtil::insertObject($registryData, 'categories_registry')) {
LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('movie')));
}
$categoryRegistryIdsPerEntity['movie'] = $registryData['id'];
// unregister persistent event handlers
EventUtil::unregisterPersistentModuleHandlers($this->name);
// register persistent event handlers
$this->registerPersistentEventHandlers();
case '1.1.0':
// for later updates
}
// update successful
return true;
}
}