pluf2

pluf2 Commit Details


Date:2009-04-07 03:00:33 (15 years 8 months ago)
Author:Loic d'Anterroches
Branch:master
Commit:69bc435014d37d730777f18e664c7f8f055ccace
Parents: 9f2a573297da70a7ec7e3ab72a8605f9d90196be
Message:Added the cache of the relations and signals.

This is particularily useful when using multiple applications, with one
or 2 applications the differences are negligeable.
Changes:

File differences

src/Pluf.php
6060
6161
6262
63
64
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
6582
6683
67
84
85
86
87
88
89
90
6891
6992
7093
94
95
96
97
98
99
100
101
71102
72103
73104
} else {
throw new Exception('Configuration file does not exist: '.$config_file);
}
// Load the relations for each installed application.
// Each application folder must be in the include path.
// Load the relations for each installed application. Each
// application folder must be in the include path.
self::loadRelations(!Pluf::f('debug', false));
}
/**
* Get the model relations and signals.
*
* If not in debug mode, it will automatically cache the
* information. This allows one include file when many
* applications and thus many includes are needed.
*
* Signals and relations are cached in the same file as the way to
* go for signals is to put them in the relations.php file.
*
* @param bool Use the cache (true)
*/
static function loadRelations($usecache=true)
{
$GLOBALS['_PX_models'] = array();
$GLOBALS['_PX_models_init_cache'] = array();
foreach (Pluf::f('installed_apps', array()) as $app) {
$apps = Pluf::f('installed_apps', array());
$cache = Pluf::f('tmp_folder').'/Pluf_relations_cache_'.md5(serialize($apps)).'.phps';
if ($usecache and file_exists($cache)) {
list($GLOBALS['_PX_models'], $GLOBALS['_PX_signal']) = include $cache;
return;
}
foreach ($apps as $app) {
$m = require $app.'/relations.php';
$GLOBALS['_PX_models'] = array_merge($m, $GLOBALS['_PX_models']);
}
// $GLOBALS['_PX_signal'] is automatically set by the require
// statement and possibly in the configuration file.
if ($usecache) {
$s = var_export(array($GLOBALS['_PX_models'], $GLOBALS['_PX_signal']), true);
file_put_contents($cache,
'<?php return '.$s.';'."\n",
LOCK_EX);
}
}
/**

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.05990s using 13 queries.