work in progress to support phalcon 5 (https://github.com/opnsense/core/pull/5711)
parent
1e8effc20d
commit
1e30d5c483
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
|
||||
// copy this template to config.local.php and adjust settings
|
||||
return new \Phalcon\Config(array(
|
||||
return new PhalconConfig(array(
|
||||
'application' => array(
|
||||
/* Usually keep defaults as is */
|
||||
'cacheDir' => __DIR__ . '/../cache/',
|
||||
|
|
|
@ -26,6 +26,26 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
use Phalcon\Config\Config as PhalconConfig5;
|
||||
use Phalcon\Config as PhalconConfig4;
|
||||
|
||||
if (!class_exists("PhalconConfig", false)) {
|
||||
if (class_exists("Phalcon\Config\Config", false)) {
|
||||
class ConfigWrapper extends PhalconConfig5
|
||||
{
|
||||
}
|
||||
} else {
|
||||
class ConfigWrapper extends PhalconConfig4
|
||||
{
|
||||
}
|
||||
}
|
||||
class PhalconConfig extends ConfigWrapper
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$conf = include __DIR__ . "/config.local.php";
|
||||
|
||||
ini_set('session.save_path',dirname(realpath(__FILE__)) . '/../temp');
|
||||
|
@ -35,14 +55,14 @@ if (empty(session_save_path())) {
|
|||
}
|
||||
|
||||
// Always register OPNsense core libraries into package list
|
||||
$conf->merge(new \Phalcon\Config(["environment" =>
|
||||
$conf->merge(new PhalconConfig(["environment" =>
|
||||
["packages" => array(
|
||||
preg_replace('#/+#','/',"{$conf->environment->coreDir}/")),],
|
||||
]
|
||||
));
|
||||
|
||||
// Register our document root as one of the directories to server static pages from
|
||||
$conf->merge(new \Phalcon\Config(["application" =>
|
||||
$conf->merge(new PhalconConfig(["application" =>
|
||||
["docroot" => array(
|
||||
preg_replace('#/+#','/',"{$_SERVER['DOCUMENT_ROOT']}/")),],
|
||||
]
|
||||
|
@ -69,7 +89,7 @@ foreach ($conf->environment->packages as $package) {
|
|||
if (!isset($conf->application->$packageDir) || !in_array($location,
|
||||
$conf->application->$packageDir->toArray())) {
|
||||
// merge configuration
|
||||
$conf->merge(new \Phalcon\Config(["application" => [$packageDir => array($location),],]));
|
||||
$conf->merge(new PhalconConfig(["application" => [$packageDir => array($location),],]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,33 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
$loader = new \Phalcon\Loader();
|
||||
|
||||
use Phalcon\Autoload\Loader as PhalconLoader5;
|
||||
use Phalcon\Loader as PhalconLoader4;
|
||||
|
||||
if (!class_exists("PhalconLoader", false)) {
|
||||
if (class_exists("Phalcon\Autoload\Loader", false)) {
|
||||
class LoaderWrapper extends PhalconLoader5 {}
|
||||
} else {
|
||||
class LoaderWrapper extends PhalconLoader4 {}
|
||||
}
|
||||
|
||||
class PhalconLoader extends LoaderWrapper
|
||||
{
|
||||
|
||||
public function __call($fName, $args) {
|
||||
if (method_exists($this, $fName)) {
|
||||
return $this->fName(...$args);
|
||||
} elseif ($fName == 'setDirectories') {
|
||||
/* Phalcon5 renamed registerDirs to setDirectories */
|
||||
return $this->registerDirs(...$args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$loader = new PhalconLoader();
|
||||
|
||||
$loaderDirs = array();
|
||||
foreach (array("controllersDir", "modelsDir", "libraryDir") as $topic) {
|
||||
|
@ -38,4 +64,4 @@ foreach (array("controllersDir", "modelsDir", "libraryDir") as $topic) {
|
|||
/**
|
||||
* We're a registering a set of directories taken from the configuration file
|
||||
*/
|
||||
$loader->registerDirs($loaderDirs)->register();
|
||||
$loader->setDirectories($loaderDirs)->register();
|
||||
|
|
Loading…
Reference in New Issue