From 3988dffe00b7f3733ac42f873017fead407218aa Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 14 Aug 2020 13:54:21 +0300 Subject: [PATCH] feat(core): Flextype Solid Core - next round #458 --- .../app/Foundation/Cache/AcpuCacheAdapter.php | 2 +- .../Foundation/Cache/ArrayCacheAdapter.php | 2 +- src/flextype/app/Foundation/Cache/Cache.php | 12 +++---- .../Cache/FilesystemCacheAdapter.php | 2 +- .../Cache/MemcachedCacheAdapter.php | 2 +- .../Cache/PhpArrayFileCacheAdapter.php | 2 +- .../Foundation/Cache/PhpFileCacheAdapter.php | 2 +- .../Foundation/Cache/RedisCacheAdapter.php | 2 +- .../Foundation/Cache/SQLite3CacheAdapter.php | 2 +- .../Foundation/Cache/WinCacheCacheAdapter.php | 2 +- .../Cache/ZendDataCacheCacheAdapter.php | 2 +- src/flextype/app/Foundation/Container.php | 36 ------------------- .../app/Foundation/Entries/Entries.php | 6 ++-- src/flextype/app/Support/Parsers/Markdown.php | 10 ++---- 14 files changed, 21 insertions(+), 63 deletions(-) delete mode 100644 src/flextype/app/Foundation/Container.php diff --git a/src/flextype/app/Foundation/Cache/AcpuCacheAdapter.php b/src/flextype/app/Foundation/Cache/AcpuCacheAdapter.php index 7efd8e47..ae3cea48 100644 --- a/src/flextype/app/Foundation/Cache/AcpuCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/AcpuCacheAdapter.php @@ -18,7 +18,7 @@ class AcpuCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/ArrayCacheAdapter.php b/src/flextype/app/Foundation/Cache/ArrayCacheAdapter.php index 7cd46f39..6d8dae4b 100644 --- a/src/flextype/app/Foundation/Cache/ArrayCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/ArrayCacheAdapter.php @@ -18,7 +18,7 @@ class ArrayCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/Cache.php b/src/flextype/app/Foundation/Cache/Cache.php index 9fff0b5d..d10617b9 100755 --- a/src/flextype/app/Foundation/Cache/Cache.php +++ b/src/flextype/app/Foundation/Cache/Cache.php @@ -58,7 +58,7 @@ class Cache */ public function __construct($flextype) { - $this->container = $flextype; + $this->flextype = $flextype; // Create Cache Directory ! Filesystem::has(PATH['cache']) and Filesystem::createDir(PATH['cache']); @@ -85,7 +85,7 @@ class Cache */ public function getCacheDriver() : object { - return $this->container['cache_adapter']->getDriver(); + return $this->flextype->container('cache_adapter')->getDriver(); } /** @@ -325,7 +325,7 @@ class Cache public function purge(string $directory) : void { // Run event: onCacheBeforePurge - $this->container['emitter']->emit('onCacheBeforePurge'); + $this->flextype['emitter']->emit('onCacheBeforePurge'); // Remove specific cache directory Filesystem::deleteDir(PATH['cache'] . '/' . $directory); @@ -344,7 +344,7 @@ class Cache error_reporting($errorReporting); // Run event: onCacheAfterPurge - $this->container['emitter']->emit('onCacheAfterPurge'); + $this->flextype['emitter']->emit('onCacheAfterPurge'); } /** @@ -357,7 +357,7 @@ class Cache public function purgeAll() : void { // Run event: onCacheAfterPurgeAll - $this->container['emitter']->emit('onCacheAfterPurgeAll'); + $this->flextype['emitter']->emit('onCacheAfterPurgeAll'); // Remove cache directory Filesystem::deleteDir(PATH['cache']); @@ -376,6 +376,6 @@ class Cache error_reporting($errorReporting); // Run event: onCacheAfterPurgeAll - $this->container['emitter']->emit('onCacheAfterPurgeAll'); + $this->flextype['emitter']->emit('onCacheAfterPurgeAll'); } } diff --git a/src/flextype/app/Foundation/Cache/FilesystemCacheAdapter.php b/src/flextype/app/Foundation/Cache/FilesystemCacheAdapter.php index f9367eda..5dfae8ed 100644 --- a/src/flextype/app/Foundation/Cache/FilesystemCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/FilesystemCacheAdapter.php @@ -19,7 +19,7 @@ class FilesystemCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/MemcachedCacheAdapter.php b/src/flextype/app/Foundation/Cache/MemcachedCacheAdapter.php index ba9a56e5..e053ea3e 100644 --- a/src/flextype/app/Foundation/Cache/MemcachedCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/MemcachedCacheAdapter.php @@ -19,7 +19,7 @@ class MemcachedCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/PhpArrayFileCacheAdapter.php b/src/flextype/app/Foundation/Cache/PhpArrayFileCacheAdapter.php index fbe3f307..9b6d0624 100644 --- a/src/flextype/app/Foundation/Cache/PhpArrayFileCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/PhpArrayFileCacheAdapter.php @@ -18,7 +18,7 @@ class PhpArrayFileCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/PhpFileCacheAdapter.php b/src/flextype/app/Foundation/Cache/PhpFileCacheAdapter.php index b5126fbe..c626db00 100644 --- a/src/flextype/app/Foundation/Cache/PhpFileCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/PhpFileCacheAdapter.php @@ -19,7 +19,7 @@ class PhpFileCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/RedisCacheAdapter.php b/src/flextype/app/Foundation/Cache/RedisCacheAdapter.php index f4ef1459..1b1f0458 100644 --- a/src/flextype/app/Foundation/Cache/RedisCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/RedisCacheAdapter.php @@ -20,7 +20,7 @@ class RedisCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/SQLite3CacheAdapter.php b/src/flextype/app/Foundation/Cache/SQLite3CacheAdapter.php index 19afa71e..8e4d2b32 100644 --- a/src/flextype/app/Foundation/Cache/SQLite3CacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/SQLite3CacheAdapter.php @@ -20,7 +20,7 @@ class SQLite3CacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/WinCacheCacheAdapter.php b/src/flextype/app/Foundation/Cache/WinCacheCacheAdapter.php index 0941b6bc..ca96c7ce 100644 --- a/src/flextype/app/Foundation/Cache/WinCacheCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/WinCacheCacheAdapter.php @@ -18,7 +18,7 @@ class WinCacheCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Cache/ZendDataCacheCacheAdapter.php b/src/flextype/app/Foundation/Cache/ZendDataCacheCacheAdapter.php index 5f4718f8..094be4a9 100644 --- a/src/flextype/app/Foundation/Cache/ZendDataCacheCacheAdapter.php +++ b/src/flextype/app/Foundation/Cache/ZendDataCacheCacheAdapter.php @@ -18,7 +18,7 @@ class ZendDataCacheCacheAdapter implements CacheAdapterInterface public function __construct(ContainerInterface $flextype) { - $this->container = $flextype; + $this->flextype = $flextype; } public function getDriver() : object diff --git a/src/flextype/app/Foundation/Container.php b/src/flextype/app/Foundation/Container.php deleted file mode 100644 index 6cf2daed..00000000 --- a/src/flextype/app/Foundation/Container.php +++ /dev/null @@ -1,36 +0,0 @@ -container = $flextype; - } - - /** - * __get - */ - public function __get($property) - { - if ($this->container->{$property}) { - return $this->container->{$property}; - } - } -} diff --git a/src/flextype/app/Foundation/Entries/Entries.php b/src/flextype/app/Foundation/Entries/Entries.php index ee47ded7..92094535 100755 --- a/src/flextype/app/Foundation/Entries/Entries.php +++ b/src/flextype/app/Foundation/Entries/Entries.php @@ -194,7 +194,7 @@ class Entries // Fetch single entry. if (count($entries_list) > 0) { foreach ($entries_list as $current_entry) { - if ($current_entry->getType() === 'file' && $current_entry->getFilename() === 'entry' . '.' . $this->container->registry->get('flextype.settings.entries.extension')) { + if ($current_entry->getType() === 'file' && $current_entry->getFilename() === 'entry' . '.' . $this->flextype->registry->get('flextype.settings.entries.extension')) { $_id = ltrim(rtrim(str_replace(PATH['project'] . '/entries/', '', $current_entry->getPath()), '/'), '/'); $this->entries[$_id] = $this->fetchSingle($_id); } @@ -281,7 +281,7 @@ class Entries // Try to create directory for new entry if (Filesystem::createDir($entry_dir)) { // Check if new entry file exists - if (! Filesystem::has($entry_file = $entry_dir . '/entry' . '.' . $this->container->registry->get('flextype.settings.entries.extension'))) { + if (! Filesystem::has($entry_file = $entry_dir . '/entry' . '.' . $this->flextype->registry->get('flextype.settings.entries.extension'))) { // Store data in the entry_create_data $this->entry_create_data = $data; @@ -360,7 +360,7 @@ class Entries */ public function getFileLocation(string $id) : string { - return PATH['project'] . '/entries/' . $id . '/entry' . '.' . $this->container->registry->get('flextype.settings.entries.extension'); + return PATH['project'] . '/entries/' . $id . '/entry' . '.' . $this->flextype->registry->get('flextype.settings.entries.extension'); } /** diff --git a/src/flextype/app/Support/Parsers/Markdown.php b/src/flextype/app/Support/Parsers/Markdown.php index 0b4d9764..5c009b78 100644 --- a/src/flextype/app/Support/Parsers/Markdown.php +++ b/src/flextype/app/Support/Parsers/Markdown.php @@ -18,11 +18,6 @@ class Markdown */ protected $flextype; - /** - * Application - */ - protected $flextype; - /** * Markdown */ @@ -35,9 +30,8 @@ class Markdown */ public function __construct($flextype, $markdown) { - $this->flextype = $flextype; - $this->container = $flextype->getContainer(); - $this->markdown = $markdown; + $this->flextype = $flextype; + $this->markdown = $markdown; } /**