Skip to content

Commit

Permalink
[skip ci] update pluf cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafabarmshory committed Apr 1, 2020
1 parent 6558f2d commit 170ca41
Show file tree
Hide file tree
Showing 22 changed files with 847 additions and 520 deletions.
10 changes: 10 additions & 0 deletions .buildpath
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@
<attribute name="composer" value="vendor"/>
</attributes>
</buildpathentry>
<buildpathentry kind="src" path="vendor/phpunit/dbunit/src">
<attributes>
<attribute name="composer" value="vendor"/>
</attributes>
</buildpathentry>
<buildpathentry kind="src" path="vendor/phpunit/php-code-coverage/src">
<attributes>
<attribute name="composer" value="vendor"/>
Expand Down Expand Up @@ -388,6 +393,11 @@
<attribute name="composer" value="vendor"/>
</attributes>
</buildpathentry>
<buildpathentry kind="src" path="vendor/symfony/yaml">
<attributes>
<attribute name="composer" value="vendor"/>
</attributes>
</buildpathentry>
<buildpathentry kind="src" path="vendor/theseer/tokenizer/src">
<attributes>
<attribute name="composer" value="vendor"/>
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"squizlabs/php_codesniffer" : "~3.3",
"slevomat/coding-standard" : "~4.5",
"mediawiki/mediawiki-codesniffer" : "~23.0",
"phpstan/phpstan" : "~0.10.6"
"phpstan/phpstan" : "~0.10.6",
"phpunit/dbunit" : "*"
},
"support" : {
"wiki" : "https://github.com/pluf/core/wiki",
Expand Down
77 changes: 43 additions & 34 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="./vendor/autoload.php"
stopOnWarning="false"
verbose="false"
backupGlobals="false"
backupStaticAttributes="false"
colors="true">
<php>
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="travis" />
<var name="DB_PASSWD" value="" />
<var name="DB_DBNAME" value="dsql_test" />
</php>
<testsuites>
<testsuite name="Basics">
<directory>tests/Cache/</directory>
</testsuite>
<testsuite name="Pluf2Suit">
<directory>tests/Pluf/</directory>
<directory>tests/Pluf_Crypt/</directory>
<directory>tests/Pluf_Utils/</directory>
<directory>tests/Pluf_Encoder/</directory>
<directory>tests/Pluf_Tenant/</directory>
<directory>tests/Pluf_Tenant_Template/</directory>
<directory>tests/Pluf_Mail/</directory>
<directory>tests/Pluf_Migration/</directory>
</testsuite>
<testsuite name="ORM">
<directory>tests/Pluf_DB/</directory>
<directory>tests/Pluf_DB_Schema/</directory>
<directory>tests/Pluf_SQL/</directory>
<directory>tests/Pluf_Model/</directory>
</testsuite>
<testsuite name="View">
<directory>tests/Middleware/</directory>
<directory>tests/Dispatcher/</directory>
<directory>tests/Pluf_Dispatcher/</directory>
<directory>tests/Pluf_Paginator/</directory>
<directory>tests/Pluf_Text_Wiki/</directory>
<directory>tests/Pluf_Text_HTML_Filter/</directory>
<directory>tests/Pluf_Form/</directory>
<directory>tests/Pluf_Form_Field/</directory>
<directory>tests/Pluf_HTTP_Response</directory>
</testsuite>
<testsuite name="GraphQl">
<directory>tests/Pluf_Graphql_Compiler/</directory>
<directory>tests/Pluf_Graphql/</directory>
<!-- <testsuite name="Basics"> -->
<!-- <directory>tests/Cache/</directory> -->
<!-- </testsuite> -->
<!-- <testsuite name="Pluf2Suit"> -->
<!-- <directory>tests/Pluf/</directory> -->
<!-- <directory>tests/Pluf_Crypt/</directory> -->
<!-- <directory>tests/Pluf_Utils/</directory> -->
<!-- <directory>tests/Pluf_Encoder/</directory> -->
<!-- <directory>tests/Pluf_Tenant/</directory> -->
<!-- <directory>tests/Pluf_Tenant_Template/</directory> -->
<!-- <directory>tests/Pluf_Mail/</directory> -->
<!-- <directory>tests/Pluf_Migration/</directory> -->
<!-- </testsuite> -->
<testsuite name="DB">
<directory>tests/Db/</directory>
<!-- <directory>tests/Pluf_DB/</directory> -->
<!-- <directory>tests/Pluf_DB_Schema/</directory> -->
<!-- <directory>tests/Pluf_SQL/</directory> -->
<!-- <directory>tests/Pluf_Model/</directory> -->
<!-- </testsuite> -->
<!-- <testsuite name="Data"> -->
<!-- <directory>tests/Data/</directory> -->
<!-- </testsuite> -->
<!-- <testsuite name="View"> -->
<!-- <directory>tests/Middleware/</directory> -->
<!-- <directory>tests/Dispatcher/</directory> -->
<!-- <directory>tests/Pluf_Dispatcher/</directory> -->
<!-- <directory>tests/Pluf_Paginator/</directory> -->
<!-- <directory>tests/Pluf_Text_Wiki/</directory> -->
<!-- <directory>tests/Pluf_Text_HTML_Filter/</directory> -->
<!-- <directory>tests/Pluf_Form/</directory> -->
<!-- <directory>tests/Pluf_Form_Field/</directory> -->
<!-- <directory>tests/Pluf_HTTP_Response</directory> -->
<!-- </testsuite> -->
<!-- <testsuite name="GraphQl"> -->
<!-- <directory>tests/Pluf_Graphql_Compiler/</directory> -->
<!-- <directory>tests/Pluf_Graphql/</directory> -->
</testsuite>
</testsuites>

Expand Down
83 changes: 45 additions & 38 deletions src/Pluf.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Pluf\ModelUtils;
use Pluf\Module;
use Pluf\Options;
use Pluf\Cache;

/**
* The main class of the framework.
Expand All @@ -29,6 +30,10 @@
class Pluf
{

public static ?Options $options = null;

public static ?Cache $cache = null;

/**
* Start the framework
*
Expand All @@ -43,53 +48,66 @@ public static function start($config)
$GLOBALS['_PX_signal'] = array();
$GLOBALS['_PX_locale'] = array();

Pluf::loadConfig($config);
// Load options
if (is_array($config)) {
$GLOBALS['_PX_config'] = $config;
} else if (false !== ($file = Pluf::fileExists($config))) {
$GLOBALS['_PX_config'] = require $file;
} else {
throw new Exception('Configuration file does not exist: ' . $config);
}
self::$options = new Options($GLOBALS['_PX_config']);

// load cache
self::$cache = Cache::getInstance(self::getConfigByPrefix('cache_', true));

// Load the relations for each installed application. Each
// application folder must be in the include path.
ModelUtils::loadRelations(! Pluf::getConfig('debug', false));

date_default_timezone_set(Pluf::f('time_zone', 'UTC'));
mb_internal_encoding(Pluf::f('encoding', 'UTF-8'));
mb_regex_encoding(Pluf::f('encoding', 'UTF-8'));
date_default_timezone_set(Pluf::getConfig('time_zone', 'UTC'));
mb_internal_encoding(Pluf::getConfig('encoding', 'UTF-8'));
mb_regex_encoding(Pluf::getConfig('encoding', 'UTF-8'));

// Load modules
Module::loadModules();
}

/**
* Load the given configuration file.
*
* The configuration is saved in the $GLOBALS['_PX_config'] array.
* The relations between the models are loaded in $GLOBALS[ModelUtils::MODEL_KEY].
*
* @param
* string Configuration file to load.
* @deprecated
*/
static function loadConfig($config_file)
public static function f($cfg, $default = '')
{
if (is_array($config_file)) {
$GLOBALS['_PX_config'] = $config_file;
} else if (false !== ($file = Pluf::fileExists($config_file))) {
$GLOBALS['_PX_config'] = require $file;
} else {
throw new Exception('Configuration file does not exist: ' . $config_file);
if (isset($GLOBALS['_PX_config'][$cfg])) {
return $GLOBALS['_PX_config'][$cfg];
}
return $default;
}

// Load the relations for each installed application. Each
// application folder must be in the include path.
ModelUtils::loadRelations(! Pluf::f('debug', false));
/**
*
* @deprecated
*/
public static function pf(string $prefix, $strip = false)
{
return self::getConfigByPrefix($prefix, $strip);
}

/**
* Gets system configuration
*
* @param
* string Configuration variable
* @param string $key
* Configuration key
* @param
* mixed Possible default value if value is not set ('')
* @return mixed Configuration variable or default value if not defined.
*/
public static function f($cfg, $default = '')
public static function getConfig(string $key, $default = '')
{
if (isset($GLOBALS['_PX_config'][$cfg])) {
return $GLOBALS['_PX_config'][$cfg];
$val = self::$options->$key;
if (isset($val)) {
return $val;
}
return $default;
}
Expand All @@ -104,20 +122,9 @@ public static function f($cfg, $default = '')
* bool Strip the prefix from the keys (false).
* @return array Configuration variables.
*/
static function pf($pfx, $strip = false)
public static function getConfigByPrefix(string $prefix, bool $strip = false)
{
$ret = array();
$pfx_len = strlen($pfx);
foreach ($GLOBALS['_PX_config'] as $key => $val) {
if (0 === strpos($key, $pfx)) {
if (! $strip) {
$ret[$key] = $val;
} else {
$ret[substr($key, $pfx_len)] = $val;
}
}
}
return $ret;
return self::$options->startsWith($prefix, $strip);
}

/**
Expand Down
111 changes: 0 additions & 111 deletions src/Pluf/Cache.php

This file was deleted.

Loading

0 comments on commit 170ca41

Please sign in to comment.