1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-28 15:29:59 +02:00

Slim Framework integration #118 #117

- PHP Coding Standards Fixer
This commit is contained in:
Awilum
2019-05-31 23:41:49 +03:00
parent fbfb9d7ad6
commit fa75b52ad2
6 changed files with 24 additions and 29 deletions

View File

@@ -44,7 +44,6 @@ class Entries
$entry_file = $this->_file_location($id);
if (Filesystem::has($entry_file)) {
$cache_id = md5('entry' . $entry_file . ((Filesystem::getTimestamp($entry_file) === false) ? '' : Filesystem::getTimestamp($entry_file)));
// Try to get the entry from cache
@@ -61,7 +60,6 @@ class Entries
return false;
}
} else {
if ($entry_body = Filesystem::read($entry_file)) {
if ($entry_decoded = JsonParser::decode($entry_body)) {
@@ -85,7 +83,6 @@ class Entries
return false;
}
}
} else {
return false;
}
@@ -147,7 +144,6 @@ class Entries
// Sort and Slice entries if $raw === false
if (count($entries) > 0) {
$entries = Arr::sort($entries, $order_by, $order_type);
if ($offset !== null && $length !== null) {
@@ -207,7 +203,6 @@ class Entries
// Try to create directory for new entry
if (Filesystem::createDir($entry_dir)) {
$entry_file = $entry_dir . '/entry.json';
// Check if new entry file exists

View File

@@ -193,7 +193,8 @@ class Snippets
* @return string|bool Returns the contents of the output buffer and end output buffering.
* If output buffering isn't active then FALSE is returned.
*/
private function _display_snippet(array $vars) {
private function _display_snippet(array $vars)
{
// Extracst attributes
extract($vars);

View File

@@ -24,13 +24,12 @@ use League\Glide\ServerFactory;
use League\Glide\Responses\SlimResponseFactory;
use League\Event\Emitter;
/**
* The version of Flextype
*
* @var string
*/
define ('FLEXTYPE_VERSION', '0.8.3');
define('FLEXTYPE_VERSION', '0.8.3');
// Start the session
Session::start();
@@ -83,7 +82,7 @@ $app->add($flextype->get('csrf'));
/**
* Add emitter service to Flextype container
*/
$flextype['emitter'] = function($container) {
$flextype['emitter'] = function ($container) {
return new Emitter();
};
@@ -97,7 +96,7 @@ $flextype['flash'] = function ($container) {
/**
* Add registry service to Flextype container
*/
$flextype['registry'] = function($container) {
$flextype['registry'] = function ($container) {
return new Registry();
};
@@ -110,7 +109,6 @@ $site_settings_file_path = PATH['config']['site'] . '/settings.json';
// Set settings if Flextype settings and Site settings config files exist
if (Filesystem::has($default_settings_file_path) && Filesystem::has($site_settings_file_path)) {
if (($content = Filesystem::read($default_settings_file_path)) === false) {
throw new \RuntimeException('Load file: ' . $default_settings_file_path . ' - failed!');
} else {
@@ -167,14 +165,14 @@ date_default_timezone_set($flextype['registry']->get('settings.timezone'));
/**
* Add cache service to Flextype container
*/
$flextype['cache'] = function($container) use ($flextype) {
$flextype['cache'] = function ($container) use ($flextype) {
return new Cache($flextype);
};
/**
* Add images service to Flextype container
*/
$flextype['images'] = function($container) {
$flextype['images'] = function ($container) {
// Get images settings
$imagesSettings = $container->get('settings')['images'];
@@ -232,21 +230,21 @@ $flextype['images'] = function($container) {
/**
* Add fieldsets service to Flextype container
*/
$flextype['fieldsets'] = function($container) use ($flextype) {
$flextype['fieldsets'] = function ($container) use ($flextype) {
return new Fieldsets($flextype);
};
/**
* Add snippets service to Flextype container
*/
$flextype['snippets'] = function($container) use ($flextype){
$flextype['snippets'] = function ($container) use ($flextype) {
return new Snippets($flextype);
};
/**
* Add shortcodes service to Flextype container
*/
$flextype['shortcodes'] = function($container) {
$flextype['shortcodes'] = function ($container) {
return new ShortcodeFacade();
};
@@ -261,7 +259,7 @@ foreach ($shortcodes_list as $shortcode) {
/**
* Add entries service to Flextype container
*/
$flextype['entries'] = function($container) {
$flextype['entries'] = function ($container) {
return new Entries($container);
};
@@ -327,7 +325,7 @@ $app->get('/image/{path:.+}', function (Request $request, Response $response, ar
/**
* Add themes service to Flextype container
*/
$flextype['themes'] = function($container) use ($flextype, $app) {
$flextype['themes'] = function ($container) use ($flextype, $app) {
return new Themes($flextype, $app);
};
@@ -340,7 +338,7 @@ $app->get('/image/{path:.+}', function (Request $request, Response $response, ar
/**
* Add plugins service to Flextype container
*/
$flextype['plugins'] = function($container) use ($flextype, $app) {
$flextype['plugins'] = function ($container) use ($flextype, $app) {
return new Plugins($flextype, $app);
};

View File

@@ -12,7 +12,8 @@
namespace Flextype;
class JsonParser {
class JsonParser
{
/**
* Encode options
@@ -75,9 +76,9 @@ class JsonParser {
public static function encode($input, int $encode_options = 0, int $encode_depth = 512) : string
{
$encoded = @json_encode(
$input,
$encode_options ? $encode_options : JsonParser::$encode_options,
$encode_depth ? $encode_depth : JsonParser::$encode_depth
$input,
$encode_options ? $encode_options : JsonParser::$encode_options,
$encode_depth ? $encode_depth : JsonParser::$encode_depth
);
if ($encoded === false) {
@@ -103,10 +104,10 @@ class JsonParser {
public static function decode(string $input, bool $decode_assoc = true, int $decode_depth = 512, int $decode_options = 0)
{
$decoded = @json_decode(
$input,
$decode_assoc ? $decode_assoc : JsonParser::$decode_assoc,
$decode_depth ? $decode_depth : JsonParser::$decode_depth,
$decode_options ? $decode_options : JsonParser::$decode_options
$input,
$decode_assoc ? $decode_assoc : JsonParser::$decode_assoc,
$decode_depth ? $decode_depth : JsonParser::$decode_depth,
$decode_options ? $decode_options : JsonParser::$decode_options
);
if ($decoded === false) {

View File

@@ -16,6 +16,6 @@ use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [site_url]
$flextype['shortcodes']->addHandler('site_url', function() {
$flextype['shortcodes']->addHandler('site_url', function () {
return \Slim\Http\Uri::createFromEnvironment(new \Slim\Http\Environment($_SERVER))->getBaseUrl();
});

View File

@@ -16,6 +16,6 @@ use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
// Shortcode: [snippets id=snippet-name]
$flextype['shortcodes']->addHandler('snippets', function(ShortcodeInterface $s) use ($flextype) {
$flextype['shortcodes']->addHandler('snippets', function (ShortcodeInterface $s) use ($flextype) {
return $flextype['shortcodes']->display($s->getParameter('id'));
});