1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-13 08:34:19 +02:00

Flextype Slim Integration - next round of integration

This commit is contained in:
Awilum
2019-02-27 11:42:46 +03:00
parent fa07abe565
commit 003f038de0
3 changed files with 57 additions and 40 deletions

View File

@@ -23,12 +23,12 @@ class Fieldsets
* @access public
* @return array
*/
public static function fetchList() : array
public function fetchList() : array
{
$fieldsets = [];
// Get fieldsets files
$_fieldsets = Filesystem::listContents(Fieldsets::_dir_location());
$_fieldsets = Filesystem::listContents($this->_dir_location());
// If there is any template file then go...
if (count($_fieldsets) > 0) {
@@ -52,9 +52,9 @@ class Fieldsets
* @param string $new_fieldset New fieldset
* @return bool True on success, false on failure.
*/
public static function rename(string $fieldset, string $new_fieldset) : bool
public function rename(string $fieldset, string $new_fieldset) : bool
{
return rename(Fieldsets::_file_location($fieldset), Fieldsets::_file_location($new_fieldset));
return rename($this->_file_location($fieldset), $this->_file_location($new_fieldset));
}
/**
@@ -65,9 +65,9 @@ class Fieldsets
* @param string $data Data
* @return bool True on success, false on failure.
*/
public static function update(string $fieldset, string $data) : bool
public function update(string $fieldset, string $data) : bool
{
$fieldset_file = Fieldsets::_file_location($fieldset);
$fieldset_file = $this->_file_location($fieldset);
if (Filesystem::has($fieldset_file)) {
return Filesystem::write($fieldset_file, $data);
@@ -84,9 +84,9 @@ class Fieldsets
* @param string $data Data
* @return bool True on success, false on failure.
*/
public static function create(string $fieldset, string $data = '') : bool
public function create(string $fieldset, string $data = '') : bool
{
$fieldset_file = Fieldsets::_file_location($fieldset);
$fieldset_file = $this->_file_location($fieldset);
// Check if new entry file exists
if (!Filesystem::has($fieldset_file)) {
@@ -103,9 +103,9 @@ class Fieldsets
* @param string $fieldset Fieldset
* @return bool True on success, false on failure.
*/
public static function delete(string $fieldset) : bool
public function delete(string $fieldset) : bool
{
return Filesystem::delete(Fieldsets::_file_location($fieldset));
return Filesystem::delete($this->_file_location($fieldset));
}
/**
@@ -116,9 +116,9 @@ class Fieldsets
* @param string $new_fieldset New fieldset
* @return bool True on success, false on failure.
*/
public static function copy(string $fieldset, string $new_fieldset) : bool
public function copy(string $fieldset, string $new_fieldset) : bool
{
return Filesystem::copy(Fieldsets::_file_location($fieldset), Fieldsets::_file_location($new_fieldset), false);
return Filesystem::copy($this->_file_location($fieldset), $this->_file_location($new_fieldset), false);
}
/**
@@ -128,9 +128,9 @@ class Fieldsets
* @param string $fieldset Fieldset
* @return bool True on success, false on failure.
*/
public static function has(string $fieldset) : bool
public function has(string $fieldset) : bool
{
return Filesystem::has(Fieldsets::_file_location($fieldset));
return Filesystem::has($this->_file_location($fieldset));
}
/**
@@ -139,7 +139,7 @@ class Fieldsets
* @access private
* @return string
*/
private static function _dir_location() : string
private function _dir_location() : string
{
return PATH['themes'] . '/' . Registry::get('settings.theme') . '/fieldsets/';
}
@@ -151,7 +151,7 @@ class Fieldsets
* @param string $name Name
* @return string
*/
private static function _file_location(string $name) : string
private function _file_location(string $name) : string
{
return PATH['themes'] . '/' . Registry::get('settings.theme') . '/fieldsets/' . $name . '.yaml';
}

View File

@@ -19,20 +19,20 @@ class Snippets
/**
* Get snippet
*
* Snippets::fetch('snippet-name');
* $this->fetch('snippet-name');
*
* @access public
* @param string $snippet_name Snippet name
* @return string|bool Returns the contents of the output buffer and end output buffering.
* If output buffering isn't active then FALSE is returned.
*/
public static function fetch(string $snippet)
public function fetch(string $snippet)
{
$vars = [];
$vars['fetch'] = $snippet;
return Snippets::_fetch_snippet($vars);
return $this->_fetch_snippet($vars);
}
/**
@@ -43,9 +43,9 @@ class Snippets
* @param string $new_snippet New snippet
* @return bool True on success, false on failure.
*/
public static function rename(string $snippet, string $new_snippet) : bool
public function rename(string $snippet, string $new_snippet) : bool
{
return rename(Snippets::_file_location($snippet), Snippets::_file_location($new_snippet));
return rename($this->_file_location($snippet), $this->_file_location($new_snippet));
}
/**
@@ -56,9 +56,9 @@ class Snippets
* @param string $data Data
* @return bool True on success, false on failure.
*/
public static function update(string $snippet, string $data) : bool
public function update(string $snippet, string $data) : bool
{
$snippet_file = Snippets::_file_location($snippet);
$snippet_file = $this->_file_location($snippet);
if (Filesystem::has($snippet_file)) {
return Filesystem::write($snippet_file, $data);
@@ -75,9 +75,9 @@ class Snippets
* @param string $data Data
* @return bool True on success, false on failure.
*/
public static function create(string $snippet, string $data = '') : bool
public function create(string $snippet, string $data = '') : bool
{
$snippet_file = Snippets::_file_location($snippet);
$snippet_file = $this->_file_location($snippet);
// Check if new entry file exists
if (!Filesystem::has($snippet_file)) {
@@ -94,9 +94,9 @@ class Snippets
* @param string $snippet Snippet
* @return bool True on success, false on failure.
*/
public static function delete(string $snippet) : bool
public function delete(string $snippet) : bool
{
return Filesystem::delete(Snippets::_file_location($snippet));
return Filesystem::delete($this->_file_location($snippet));
}
/**
@@ -107,9 +107,9 @@ class Snippets
* @param string $new_snippet New snippet
* @return bool True on success, false on failure.
*/
public static function copy(string $snippet, string $new_snippet) : bool
public function copy(string $snippet, string $new_snippet) : bool
{
return Filesystem::copy(Snippets::_file_location($snippet), Snippets::_file_location($new_snippet), false);
return Filesystem::copy($this->_file_location($snippet), $this->_file_location($new_snippet), false);
}
/**
@@ -119,9 +119,9 @@ class Snippets
* @param string $snippet Snippet
* @return bool True on success, false on failure.
*/
public static function has(string $snippet) : bool
public function has(string $snippet) : bool
{
return Filesystem::has(Snippets::_file_location($snippet));
return Filesystem::has($this->_file_location($snippet));
}
/**
@@ -132,7 +132,7 @@ 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 static function _fetch_snippet(array $vars) {
private function _fetch_snippet(array $vars) {
// Extracst attributes
extract($vars);
@@ -141,7 +141,7 @@ class Snippets
$name = (isset($fetch)) ? (string) $fetch : '';
// Define snippet path
$snippet_file = Snippets::_file_location($name);
$snippet_file = $this->_file_location($name);
// Process snippet
if (Filesystem::has($snippet_file)) {
@@ -166,7 +166,7 @@ class Snippets
* @param string $name Name
* @return string
*/
private static function _file_location(string $name) : string
private function _file_location(string $name) : string
{
return PATH['snippets'] . '/' . $name . '.php';
}

View File

@@ -112,7 +112,11 @@ $config = [
'determineRouteBeforeAppMiddleware' => false,
'outputBuffering' => 'append',
'responseChunkSize' => 4096,
'httpVersion' => '1.1'
'httpVersion' => '1.1',
'twig' => [
'cache' => false
]
],
];
@@ -184,7 +188,21 @@ $flextype['images'] = function($container) {
};
/**
* Add shortcodes service to Flextype container:
* Add fieldsets service to Flextype container
*/
$flextype['fieldsets'] = function($container) {
return new Fieldsets();
};
/**
* Add snippets service to Flextype container
*/
$flextype['snippets'] = function($container) {
return new Snippets();
};
/**
* Add shortcodes service to Flextype container
*/
$flextype['shortcodes'] = function($container) {
return new ShortcodeFacade();
@@ -210,10 +228,10 @@ $flextype['entries'] = function($container) {
*/
$flextype['view'] = function ($container) {
$twigSettings = $container->get('settings')['twig'];
// Create Twig View
$view = new \Slim\Views\Twig(PATH['site'], [
'cache' => false
]);
$view = new \Slim\Views\Twig(PATH['site'], $twigSettings);
// Instantiate
$router = $container->get('router');
@@ -243,7 +261,6 @@ $app->get('/image/{path:.+}', function (Request $request, Response $response, ar
*/
$plugins = new Plugins($flextype, $app);
/**
* Run application
*/