1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-10 15:14:20 +02:00

feat(core): Flextype Solid Core - next round #458

This commit is contained in:
Awilum
2020-08-13 19:26:24 +03:00
parent c085a5a7ec
commit 64288cec53
19 changed files with 112 additions and 112 deletions

View File

@@ -38,7 +38,7 @@ function validate_entries_token($token) : bool
* Returns:
* An array of entry item objects.
*/
$app->get('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->get('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Query Params
$query = $request->getQueryParams();
@@ -131,7 +131,7 @@ $app->get('/api/entries', function (Request $request, Response $response) use ($
* Returns:
* Returns the entry item object for the entry item that was just created.
*/
$app->post('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->post('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -235,7 +235,7 @@ $app->post('/api/entries', function (Request $request, Response $response) use (
* Returns:
* Returns the entry item object for the entry item that was just updated.
*/
$app->patch('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->patch('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -339,7 +339,7 @@ $app->patch('/api/entries', function (Request $request, Response $response) use
* Returns:
* Returns the entry item object for the entry item that was just renamed.
*/
$app->put('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->put('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -444,7 +444,7 @@ $app->put('/api/entries', function (Request $request, Response $response) use ($
* Returns:
* Returns the entry item object for the entry item that was just copied.
*/
$app->put('/api/entries/copy', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->put('/api/entries/copy', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -548,7 +548,7 @@ $app->put('/api/entries/copy', function (Request $request, Response $response) u
* Returns:
* Returns an empty body with HTTP status 204
*/
$app->delete('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->delete('/api/entries', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();

View File

@@ -37,7 +37,7 @@ function validate_files_token($token) : bool
* Returns:
* An array of file item objects.
*/
$app->get('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->get('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Query Params
$query = $request->getQueryParams();
@@ -133,7 +133,7 @@ $app->get('/api/files', function (Request $request, Response $response) use ($co
* Returns:
* Returns the file object for the file that was just uploaded.
*/
$app->post('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->post('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -237,7 +237,7 @@ $app->post('/api/files', function (Request $request, Response $response) use ($c
* Returns:
* Returns the file object for the file that was just created.
*/
$app->put('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->put('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -340,7 +340,7 @@ $app->put('/api/files', function (Request $request, Response $response) use ($co
* Returns:
* Returns the file object for the file that was just created.
*/
$app->put('/api/files/copy', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->put('/api/files/copy', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -442,7 +442,7 @@ $app->put('/api/files/copy', function (Request $request, Response $response) use
* Returns:
* Returns an empty body with HTTP status 204
*/
$app->delete('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->delete('/api/files', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -539,7 +539,7 @@ $app->delete('/api/files', function (Request $request, Response $response) use (
* Returns:
* Returns the file object for the file that was just updated.
*/
$app->patch('/api/files/meta', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->patch('/api/files/meta', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -644,7 +644,7 @@ $app->patch('/api/files/meta', function (Request $request, Response $response) u
* Returns:
* Returns the file object for the file that was just created.
*/
$app->post('/api/files/meta', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->post('/api/files/meta', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -749,7 +749,7 @@ $app->post('/api/files/meta', function (Request $request, Response $response) us
* Returns:
* Returns the file object for the file that was just created.
*/
$app->delete('/api/files/meta', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->delete('/api/files/meta', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();

View File

@@ -36,7 +36,7 @@ function validate_folders_token($token) : bool
* Returns:
* An array of folder(s) item objects.
*/
$app->get('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->get('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Query Params
$query = $request->getQueryParams();
@@ -141,7 +141,7 @@ $app->get('/api/folders', function (Request $request, Response $response) use ($
* Returns:
* Returns the folder object for the folder that was just created.
*/
$app->post('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->post('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -241,7 +241,7 @@ $app->post('/api/folders', function (Request $request, Response $response) use (
* Returns:
* Returns the folders object for the folders that was just copied.
*/
$app->put('/api/folders/copy', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->put('/api/folders/copy', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -344,7 +344,7 @@ $app->put('/api/folders/copy', function (Request $request, Response $response) u
* Returns:
* Returns the folders object for the folders that was just renamed.
*/
$app->put('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->put('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();
@@ -444,7 +444,7 @@ $app->put('/api/folders', function (Request $request, Response $response) use ($
* Returns:
* Returns an empty body with HTTP status 204
*/
$app->delete('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->delete('/api/folders', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Post Data
$post_data = $request->getParsedBody();

View File

@@ -36,7 +36,7 @@ function validate_images_token($token) : bool
* Returns:
* Image file
*/
$app->get('/api/images/{path:.+}', function (Request $request, Response $response, $args) use ($container, $api_errors) {
$flextype->get('/api/images/{path:.+}', function (Request $request, Response $response, $args) use ($container, $api_errors) {
// Get Query Params
$query = $request->getQueryParams();

View File

@@ -34,7 +34,7 @@ function validate_registry_token($token) : bool
* Returns:
* An array of registry item objects.
*/
$app->get('/api/registry', function (Request $request, Response $response) use ($container, $api_errors) {
$flextype->get('/api/registry', function (Request $request, Response $response) use ($container, $api_errors) {
// Get Query Params
$query = $request->getQueryParams();

View File

@@ -22,15 +22,15 @@ class Cors
/**
* Flextype app
*/
private $app;
private $flextype;
/**
* __construct
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -72,7 +72,7 @@ class Entries
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -84,10 +84,10 @@ class Entries
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -46,7 +46,7 @@ class MediaFiles
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -58,10 +58,10 @@ class MediaFiles
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -17,7 +17,7 @@ class MediaFilesMeta
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -29,10 +29,10 @@ class MediaFilesMeta
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -20,7 +20,7 @@ class MediaFolders
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -32,10 +32,10 @@ class MediaFolders
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -14,7 +14,7 @@ class MediaFoldersMeta
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -26,10 +26,10 @@ class MediaFoldersMeta
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -27,7 +27,7 @@ class Plugins
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -46,10 +46,10 @@ class Plugins
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
$this->locales = $this->container['yaml']->decode(Filesystem::read(ROOT_DIR . '/src/flextype/locales.yaml'));
}
@@ -70,7 +70,7 @@ class Plugins
*
* @access public
*/
public function init($container, $app) : void
public function init($container, $flextype) : void
{
// Set empty plugins item
$this->container['registry']->set('plugins', []);
@@ -186,7 +186,7 @@ class Plugins
$this->container['cache']->save($locale, $dictionary[$locale]);
}
$this->includeEnabledPlugins($container, $app);
$this->includeEnabledPlugins($container, $flextype);
$this->container['emitter']->emit('onPluginsInitialized');
}
@@ -379,7 +379,7 @@ class Plugins
*
* @access private
*/
private function includeEnabledPlugins($container, $app) : void
private function includeEnabledPlugins($container, $flextype) : void
{
if (! is_array($this->container['registry']->get('plugins')) || count($this->container['registry']->get('plugins')) <= 0) {
return;

View File

@@ -16,7 +16,7 @@ class Markdown
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -33,10 +33,10 @@ class Markdown
*
* @access public
*/
public function __construct($app, $markdown)
public function __construct($flextype, $markdown)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
$this->markdown = $markdown;
}

View File

@@ -16,7 +16,7 @@ class Shortcode
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -33,10 +33,10 @@ class Shortcode
*
* @access public
*/
public function __construct($app, $shortcode)
public function __construct($flextype, $shortcode)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
$this->shortcode = $shortcode;
}

View File

@@ -24,7 +24,7 @@ class Frontmatter
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -36,10 +36,10 @@ class Frontmatter
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -30,7 +30,7 @@ class Json
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -42,10 +42,10 @@ class Json
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -35,7 +35,7 @@ class Yaml
/**
* Application
*/
protected $app;
protected $flextype;
/**
* Dependency Container
@@ -47,10 +47,10 @@ class Yaml
*
* @access public
*/
public function __construct($app)
public function __construct($flextype)
{
$this->app = $app;
$this->container = $app->getContainer();
$this->app = $flextype;
$this->container = $flextype->getContainer();
}
/**

View File

@@ -11,7 +11,7 @@ namespace Flextype;
use Flextype\Component\Registry\Registry;
use Flextype\Component\Session\Session;
use Slim\App;
use Slim\App as Flextype;
use Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware;
use function date_default_timezone_set;
use function error_reporting;
@@ -39,7 +39,7 @@ include_once ROOT_DIR . '/src/flextype/preflight.php';
/**
* Create new application
*/
$app = new App([
$flextype = new Flextype([
'settings' => [
'debug' => $registry->get('flextype.settings.errors.display'),
'whoops.editor' => $registry->get('flextype.settings.whoops.editor'),
@@ -57,7 +57,7 @@ $app = new App([
/**
* Get Dependency Injection Container
*/
$container = $app->getContainer();
$container = $flextype->getContainer();
/**
* Include Dependencies
@@ -90,7 +90,7 @@ if ($container['registry']->get('flextype.settings.errors.display')) {
/**
* Add WhoopsMiddleware
*/
$app->add(new WhoopsMiddleware($app));
$flextype->add(new WhoopsMiddleware($flextype));
} else {
error_reporting(0);
}
@@ -135,7 +135,7 @@ foreach ($entry_fields as $field_name => $field) {
/**
* Init plugins
*/
$container['plugins']->init($container, $app);
$container['plugins']->init($container, $flextype);
/**
* Enable lazy CORS
@@ -149,4 +149,4 @@ $container['cors']->init();
/**
* Run application
*/
$app->run();
$flextype->run();

View File

@@ -55,8 +55,8 @@ use function extension_loaded;
/**
* Supply a custom callable resolver, which resolves PSR-15 middlewares.
*/
$container['callableResolver'] = function () use ($app) {
return new CallableResolver($app->getContainer());
$container['callableResolver'] = function () use ($flextype) {
return new CallableResolver($flextype->getContainer());
};
/**
@@ -86,9 +86,9 @@ $container['emitter'] = function () {
/**
* Add slugify service to Flextype container
*/
$container['slugify'] = function () use ($app) {
$container['slugify'] = function () use ($flextype) {
$container = $app->getContainer();
$container = $flextype->getContainer();
return new Slugify([
'separator' => $container['registry']->get('flextype.settings.slugify.separator'),
@@ -103,9 +103,9 @@ $container['slugify'] = function () use ($app) {
/**
* Adds the cache adapter to the Flextype container
*/
$container['cache_adapter'] = function () use ($app) {
$container['cache_adapter'] = function () use ($flextype) {
$container = $app->getContainer();
$container = $flextype->getContainer();
$driver_name = $container['registry']->get('flextype.settings.cache.driver');
@@ -142,51 +142,51 @@ $container['cache_adapter'] = function () use ($app) {
/**
* Add cache service to Flextype container
*/
$container['cache'] = function () use ($app) {
return new Cache($app->getContainer());
$container['cache'] = function () use ($flextype) {
return new Cache($flextype->getContainer());
};
/**
* Add shortcode parser service to Flextype container
*/
$container['shortcode'] = function () use ($app) {
return new Shortcode($app, new ShortcodeFacade());
$container['shortcode'] = function () use ($flextype) {
return new Shortcode($flextype, new ShortcodeFacade());
};
/**
* Add markdown parser service to Flextype container
*/
$container['markdown'] = function () use ($app) {
return new Markdown($app, new ParsedownExtra());
$container['markdown'] = function () use ($flextype) {
return new Markdown($flextype, new ParsedownExtra());
};
/**
* Add json serializer service to Flextype container
*/
$container['json'] = function () use ($app) {
return new Json($app);
$container['json'] = function () use ($flextype) {
return new Json($flextype);
};
/**
* Add yaml serializer service to Flextype container
*/
$container['yaml'] = function () use ($app) {
return new Yaml($app);
$container['yaml'] = function () use ($flextype) {
return new Yaml($flextype);
};
/**
* Add frontmatter serializer service to Flextype container
*/
$container['frontmatter'] = function ($container) use ($app) {
return new Frontmatter($app);
$container['frontmatter'] = function ($container) use ($flextype) {
return new Frontmatter($flextype);
};
/**
* Add images service to Flextype container
*/
$container['images'] = function () use ($app) {
$container['images'] = function () use ($flextype) {
$container = $app->getContainer();
$container = $flextype->getContainer();
// Get images settings
$imagesSettings = ['driver' => $registry->get('flextype.settings.image.driver')];
@@ -242,48 +242,48 @@ $container['images'] = function () use ($app) {
/**
* Add entries service to Flextype container
*/
$container['entries'] = function () use ($app) {
return new Entries($app);
$container['entries'] = function () use ($flextype) {
return new Entries($flextype);
};
/**
* Add media folders service to Flextype container
*/
$container['media_folders'] = function () use ($app) {
return new MediaFolders($app);
$container['media_folders'] = function () use ($flextype) {
return new MediaFolders($flextype);
};
/**
* Add media files service to Flextype container
*/
$container['media_files'] = function () use ($app) {
return new MediaFiles($app);
$container['media_files'] = function () use ($flextype) {
return new MediaFiles($flextype);
};
/**
* Add media folders meta service to Flextype container
*/
$container['media_folders_meta'] = function () use ($app) {
return new MediaFoldersMeta($app);
$container['media_folders_meta'] = function () use ($flextype) {
return new MediaFoldersMeta($flextype);
};
/**
* Add media files meta service to Flextype container
*/
$container['media_files_meta'] = function ($app) {
return new MediaFilesMeta($app);
$container['media_files_meta'] = function ($flextype) {
return new MediaFilesMeta($flextype);
};
/**
* Add plugins service to Flextype container
*/
$container['plugins'] = function () use ($app) {
return new Plugins($app);
$container['plugins'] = function () use ($flextype) {
return new Plugins($flextype);
};
/**
* Add cors service to Flextype container
*/
$container['cors'] = function () use ($app) {
return new Cors($app);
$container['cors'] = function () use ($flextype) {
return new Cors($flextype);
};