mirror of
https://github.com/flextype/flextype.git
synced 2025-08-12 16:14:16 +02:00
Flextype Slim Integration - next round of integration
This commit is contained in:
@@ -20,7 +20,7 @@ class Entries
|
||||
{
|
||||
|
||||
/**
|
||||
* Flextype DIC
|
||||
* Flextype Dependency Container
|
||||
*/
|
||||
private $flextype;
|
||||
|
||||
|
@@ -19,14 +19,6 @@ use Flextype\Component\Registry\Registry;
|
||||
|
||||
class Plugins
|
||||
{
|
||||
/**
|
||||
* An instance of the Cache class
|
||||
*
|
||||
* @var object
|
||||
* @access private
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Locales array
|
||||
*
|
||||
|
@@ -23,12 +23,11 @@ use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
/**
|
||||
* The version of Flextype
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// const VERSION = '0.8.3';
|
||||
|
||||
* The version of Flextype
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
define ('FLEXTYPE_VERSION', '0.8.3');
|
||||
|
||||
// Set empty settings array
|
||||
Registry::set('settings', []);
|
||||
@@ -108,11 +107,19 @@ $config = ['settings' => [
|
||||
'addContentLengthHeader' => false,
|
||||
]];
|
||||
|
||||
/**
|
||||
* Create new application
|
||||
*/
|
||||
$app = new \Slim\App($config);
|
||||
|
||||
// DIC configuration
|
||||
/**
|
||||
* Set Flextype Dependency Container
|
||||
*/
|
||||
$flextype = $app->getContainer();
|
||||
|
||||
/**
|
||||
* Add images service to Flextype container
|
||||
*/
|
||||
$flextype['images'] = function($container) {
|
||||
|
||||
// Set source filesystem
|
||||
@@ -170,6 +177,9 @@ $flextype['images'] = function($container) {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add shortcodes service to Flextype container:
|
||||
*/
|
||||
$flextype['shortcodes'] = function($container) {
|
||||
return new ShortcodeFacade();
|
||||
};
|
||||
@@ -182,11 +192,16 @@ foreach ($shortcodes_list as $shortcode) {
|
||||
include_once $shortcode['path'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add entries service to Flextype container
|
||||
*/
|
||||
$flextype['entries'] = function($container) {
|
||||
return new Entries($container);
|
||||
};
|
||||
|
||||
// Register Twig View helper
|
||||
/**
|
||||
* Add view service to Flextype container
|
||||
*/
|
||||
$flextype['view'] = function ($container) {
|
||||
|
||||
$view = new \Slim\Views\Twig(PATH['site'], [
|
||||
@@ -204,8 +219,12 @@ $flextype['view'] = function ($container) {
|
||||
return $view;
|
||||
};
|
||||
|
||||
// Get Plugins Instance
|
||||
/**
|
||||
* Init plugins
|
||||
*/
|
||||
$plugins = new Plugins($flextype, $app);
|
||||
|
||||
// Run app
|
||||
/**
|
||||
* Run application
|
||||
*/
|
||||
$app->run();
|
||||
|
@@ -9,8 +9,9 @@ use Flextype\Component\Arr\Arr;
|
||||
use Flextype\Component\Event\Event;
|
||||
use Flextype\Component\Registry\Registry;
|
||||
|
||||
|
||||
// Define app routes
|
||||
/**
|
||||
* Define site plugin routes
|
||||
*/
|
||||
$app->get('{uri:.+}', function (Request $request, Response $response, array $args) {
|
||||
|
||||
// Get uri
|
||||
@@ -55,9 +56,6 @@ $app->get('{uri:.+}', function (Request $request, Response $response, array $arg
|
||||
$entry['template'] = Registry::get('settings.entries.error404.template');
|
||||
}
|
||||
|
||||
// Set current requested entry data to global $entry array
|
||||
$entry = $entry;
|
||||
|
||||
$path = 'themes/' . Registry::get('settings.theme') . '/' . (empty($entry['template']) ? 'templates/default' : 'templates/' . $entry['template']) . '.twig';
|
||||
|
||||
return $this->view->render($response,
|
||||
|
@@ -1,3 +0,0 @@
|
||||
{{ test }}
|
||||
{{ entries_fetch('home')['title'] }}
|
||||
@ {{ current_path() }} @
|
Reference in New Issue
Block a user