work in progress to support phalcon 5 (https://github.com/opnsense/core/pull/5711)
This commit is contained in:
parent
1e8effc20d
commit
1e30d5c483
|
@ -28,7 +28,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// copy this template to config.local.php and adjust settings
|
// copy this template to config.local.php and adjust settings
|
||||||
return new \Phalcon\Config(array(
|
return new PhalconConfig(array(
|
||||||
'application' => array(
|
'application' => array(
|
||||||
/* Usually keep defaults as is */
|
/* Usually keep defaults as is */
|
||||||
'cacheDir' => __DIR__ . '/../cache/',
|
'cacheDir' => __DIR__ . '/../cache/',
|
||||||
|
|
|
@ -26,6 +26,26 @@
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* 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";
|
$conf = include __DIR__ . "/config.local.php";
|
||||||
|
|
||||||
ini_set('session.save_path',dirname(realpath(__FILE__)) . '/../temp');
|
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
|
// Always register OPNsense core libraries into package list
|
||||||
$conf->merge(new \Phalcon\Config(["environment" =>
|
$conf->merge(new PhalconConfig(["environment" =>
|
||||||
["packages" => array(
|
["packages" => array(
|
||||||
preg_replace('#/+#','/',"{$conf->environment->coreDir}/")),],
|
preg_replace('#/+#','/',"{$conf->environment->coreDir}/")),],
|
||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
|
||||||
// Register our document root as one of the directories to server static pages from
|
// 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(
|
["docroot" => array(
|
||||||
preg_replace('#/+#','/',"{$_SERVER['DOCUMENT_ROOT']}/")),],
|
preg_replace('#/+#','/',"{$_SERVER['DOCUMENT_ROOT']}/")),],
|
||||||
]
|
]
|
||||||
|
@ -69,7 +89,7 @@ foreach ($conf->environment->packages as $package) {
|
||||||
if (!isset($conf->application->$packageDir) || !in_array($location,
|
if (!isset($conf->application->$packageDir) || !in_array($location,
|
||||||
$conf->application->$packageDir->toArray())) {
|
$conf->application->$packageDir->toArray())) {
|
||||||
// merge configuration
|
// 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.
|
* 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();
|
$loaderDirs = array();
|
||||||
foreach (array("controllersDir", "modelsDir", "libraryDir") as $topic) {
|
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
|
* 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