-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.model.php
48 lines (40 loc) · 1.39 KB
/
build.model.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
<?php
if (!defined('MODX_BASE_PATH')) {
require 'build.config.php';
}
// define sources
$root = dirname(dirname(__FILE__)) . '/';
$sources = array(
'root' => $root,
'build' => $root . '_build/',
'source_core' => $root . 'core/components/' . PKG_NAME_LOWER,
'model' => $root . 'core/components/' . PKG_NAME_LOWER . '/model/',
'schema' => $root . 'core/components/' . PKG_NAME_LOWER . '/model/schema/',
'xml' => $root . 'core/components/' . PKG_NAME_LOWER . '/model/schema/' . PKG_NAME_LOWER . '.mysql.schema.xml',
);
unset($root);
/** @noinspection PhpIncludeInspection */
require MODX_CORE_PATH . 'model/modx/modx.class.php';
/** @noinspection PhpIncludeInspection */
require $sources['build'] . '/includes/functions.php';
$modx = new modX();
$modx->initialize('mgr');
$modx->getService('error', 'error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget('ECHO');
$modx->loadClass('transport.modPackageBuilder', '', false, true);
if (!XPDO_CLI_MODE) {
echo '<pre>';
}
/** @var xPDOManager $manager */
$manager = $modx->getManager();
/** @var xPDOGenerator $generator */
$generator = $manager->getGenerator();
// Remove old model
rrmdir($sources['model'] . PKG_NAME_LOWER . '/mysql');
// Generate a new one
$generator->parseSchema($sources['xml'], $sources['model']);
$modx->log(modX::LOG_LEVEL_INFO, 'Model generated.');
if (!XPDO_CLI_MODE) {
echo '</pre>';
}