diff --git a/src/flextype/Foundation/Cache/AcpuAdapter.php b/src/flextype/Foundation/Cache/AcpuAdapter.php index 6bbd38e2..47beed8d 100644 --- a/src/flextype/Foundation/Cache/AcpuAdapter.php +++ b/src/flextype/Foundation/Cache/AcpuAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Cache\Common\AcpuCache; use Psr\Container\ContainerInterface; diff --git a/src/flextype/Foundation/Cache/ArrayAdapter.php b/src/flextype/Foundation/Cache/ArrayAdapter.php index 4264f38b..1719844a 100644 --- a/src/flextype/Foundation/Cache/ArrayAdapter.php +++ b/src/flextype/Foundation/Cache/ArrayAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\ArrayCache; use Psr\Container\ContainerInterface; diff --git a/src/flextype/Foundation/Cache/Cache.php b/src/flextype/Foundation/Cache/Cache.php index 03c0a817..7821f828 100755 --- a/src/flextype/Foundation/Cache/Cache.php +++ b/src/flextype/Foundation/Cache/Cache.php @@ -7,7 +7,7 @@ declare(strict_types=1); * Founded by Sergey Romanenko and maintained by Flextype Community. */ -namespace Flextype; +namespace Flextype\Foundation\Cache; use Flextype\Component\Filesystem\Filesystem; use function clearstatcache; diff --git a/src/flextype/Foundation/Cache/CacheAdapterInterface.php b/src/flextype/Foundation/Cache/CacheAdapterInterface.php index fda0f5f2..c2bc4a0f 100644 --- a/src/flextype/Foundation/Cache/CacheAdapterInterface.php +++ b/src/flextype/Foundation/Cache/CacheAdapterInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Psr\Container\ContainerInterface; diff --git a/src/flextype/Foundation/Cache/FilesystemAdapter.php b/src/flextype/Foundation/Cache/FilesystemAdapter.php index 992e3537..1dcd3410 100644 --- a/src/flextype/Foundation/Cache/FilesystemAdapter.php +++ b/src/flextype/Foundation/Cache/FilesystemAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\FilesystemCache; use Flextype\Component\Filesystem\Filesystem; diff --git a/src/flextype/Foundation/Cache/MemcachedAdapter.php b/src/flextype/Foundation/Cache/MemcachedAdapter.php index fdf3fc1e..89037adc 100644 --- a/src/flextype/Foundation/Cache/MemcachedAdapter.php +++ b/src/flextype/Foundation/Cache/MemcachedAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\MemcachedCache; use Memecached; diff --git a/src/flextype/Foundation/Cache/RedisAdapter.php b/src/flextype/Foundation/Cache/RedisAdapter.php index c6a15ab9..0921f546 100644 --- a/src/flextype/Foundation/Cache/RedisAdapter.php +++ b/src/flextype/Foundation/Cache/RedisAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\RedisCache; use Psr\Container\ContainerInterface; diff --git a/src/flextype/Foundation/Cache/SQLite3Adapter.php b/src/flextype/Foundation/Cache/SQLite3Adapter.php index 4bef6305..5de45fe9 100644 --- a/src/flextype/Foundation/Cache/SQLite3Adapter.php +++ b/src/flextype/Foundation/Cache/SQLite3Adapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\SQLite3Cache; use Flextype\Component\Filesystem\Filesystem; diff --git a/src/flextype/Foundation/Cache/WinCacheAdapter.php b/src/flextype/Foundation/Cache/WinCacheAdapter.php index 1e80ed71..e34c6e7f 100644 --- a/src/flextype/Foundation/Cache/WinCacheAdapter.php +++ b/src/flextype/Foundation/Cache/WinCacheAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\WinCacheCache; use Psr\Container\ContainerInterface; diff --git a/src/flextype/Foundation/Cache/ZendDataCacheAdapter.php b/src/flextype/Foundation/Cache/ZendDataCacheAdapter.php index 5a674d39..4b5f1f53 100644 --- a/src/flextype/Foundation/Cache/ZendDataCacheAdapter.php +++ b/src/flextype/Foundation/Cache/ZendDataCacheAdapter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Flextype\Cache; +namespace Flextype\Foundation\Cache; use Doctrine\Common\Cache\ZendDataCache; use Psr\Container\ContainerInterface; diff --git a/src/flextype/Foundation/Config/Config.php b/src/flextype/Foundation/Config.php similarity index 77% rename from src/flextype/Foundation/Config/Config.php rename to src/flextype/Foundation/Config.php index c812c7a2..d658d877 100644 --- a/src/flextype/Foundation/Config/Config.php +++ b/src/flextype/Foundation/Config.php @@ -7,7 +7,7 @@ declare(strict_types=1); * Founded by Sergey Romanenko and maintained by Flextype Community. */ -namespace Flextype; +namespace Flextype\Foundation; use Flextype\Component\Arr\Arr; use Flextype\Component\Filesystem\Filesystem; @@ -43,7 +43,7 @@ class Config $config_file = $this->getFileLocation($config); if (Filesystem::has($config_file)) { - return Arr::get($this->flextype->serializer->decode(Filesystem::read($config_file), 'yaml'), $key, $default); + return Arr::get($this->flextype->yaml->decode(Filesystem::read($config_file)), $key, $default); } } @@ -59,12 +59,12 @@ class Config $config_file = $this->getFileLocation($config); if (Filesystem::has($config_file)) { - $config_file_data = $this->flextype->serializer->decode(Filesystem::read($config_file), 'yaml'); + $config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file)); - if (! Arr::keyExists($config_file_data, $key)) { + if (! array_has($config_file_data, $key)) { Arr::set($config_file_data, $key, $value); - return Filesystem::write($config_file, $this->flextype->serializer->encode($config_file_data, 'yaml')); + return Filesystem::write($config_file, $this->flextype->yaml->encode($config_file_data)); } return false; @@ -85,12 +85,12 @@ class Config $config_file = $this->getFileLocation($config); if (Filesystem::has($config_file)) { - $config_file_data = $this->flextype->serializer->decode(Filesystem::read($config_file), 'yaml'); + $config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file)); - if (Arr::keyExists($config_file_data, $key)) { + if (array_has($config_file_data, $key)) { Arr::set($config_file_data, $key, $value); - return Filesystem::write($config_file, $this->flextype->serializer->encode($config_file_data, 'yaml')); + return Filesystem::write($config_file, $this->flextype->yaml->encode($config_file_data)); } return false; @@ -110,12 +110,12 @@ class Config $config_file = $this->getFileLocation($config); if (Filesystem::has($config_file)) { - $config_file_data = $this->flextype->serializer->decode(Filesystem::read($config_file), 'yaml'); + $config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file)); - if (Arr::keyExists($config_file_data, $key)) { - Arr::delete($config_file_data, $key); + if (array_has($config_file_data, $key)) { + array_delete($config_file_data, $key); - return Filesystem::write($config_file, $this->flextype->serializer->encode($config_file_data, 'yaml')); + return Filesystem::write($config_file, $this->flextype->yaml->encode($config_file_data)); } return false; @@ -135,9 +135,9 @@ class Config $config_file = $this->getFileLocation($config); if (Filesystem::has($config_file)) { - $config_file_data = $this->flextype->serializer->decode(Filesystem::read($config_file), 'yaml'); + $config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file)); - if (Arr::keyExists($config_file_data, $key)) { + if (array_has($config_file_data, $key)) { return true; } diff --git a/src/flextype/Foundation/Container/Container.php b/src/flextype/Foundation/Container/Container.php deleted file mode 100644 index 9232f60f..00000000 --- a/src/flextype/Foundation/Container/Container.php +++ /dev/null @@ -1,36 +0,0 @@ -container = $container; - } - - /** - * __get - */ - public function __get($property) - { - if ($this->container->{$property}) { - return $this->container->{$property}; - } - } -} diff --git a/src/flextype/Foundation/Cors/Cors.php b/src/flextype/Foundation/Cors.php similarity index 98% rename from src/flextype/Foundation/Cors/Cors.php rename to src/flextype/Foundation/Cors.php index d2b41393..74ed116a 100644 --- a/src/flextype/Foundation/Cors/Cors.php +++ b/src/flextype/Foundation/Cors.php @@ -7,7 +7,7 @@ declare(strict_types=1); * Founded by Sergey Romanenko and maintained by Flextype Community. */ -namespace Flextype; +namespace Flextype\Foundation; use function count; use function implode; @@ -66,5 +66,6 @@ class Cors ->withHeader('Access-Control-Allow-Expose', $expose) ->withHeader('Access-Control-Allow-Credentials', $credentials); }); + } } diff --git a/src/flextype/Foundation/Entries/Entries.php b/src/flextype/Foundation/Entries.php similarity index 94% rename from src/flextype/Foundation/Entries/Entries.php rename to src/flextype/Foundation/Entries.php index fdcf93b0..82f095da 100755 --- a/src/flextype/Foundation/Entries/Entries.php +++ b/src/flextype/Foundation/Entries.php @@ -7,7 +7,7 @@ declare(strict_types=1); * Founded by Sergey Romanenko and maintained by Flextype Community. */ -namespace Flextype; +namespace Flextype\Foundation; use Flextype\Component\Arr\Arr; use Flextype\Component\Filesystem\Filesystem; @@ -152,7 +152,7 @@ class Entries } // Try to get requested entry from the filesystem - $entry_decoded = $this->flextype['serializer']->decode(Filesystem::read($entry_file), 'frontmatter'); + $entry_decoded = $this->flextype['frontmatter']->decode(Filesystem::read($entry_file)); // Set system entry fields @@ -209,8 +209,8 @@ class Entries } if ($parser_name === 'markdown') { - if (Arr::keyExists($entry_decoded, $field)) { - Arr::set($entry_decoded, $field, $this->flextype['parser']->parse(Arr::get($entry_decoded, $field), 'markdown', $cache)); + if (array_has($entry_decoded, $field)) { + array_set($entry_decoded, $field, $this->flextype['parser']->parse(Arr::get($entry_decoded, $field), 'markdown', $cache)); } } @@ -218,11 +218,11 @@ class Entries continue; } - if (! Arr::keyExists($entry_decoded, $field)) { + if (! array_has($entry_decoded, $field)) { continue; } - Arr::set($entry_decoded, $field, $this->flextype['parser']->parse(Arr::get($entry_decoded, $field), 'shortcodes', $cache)); + array_set($entry_decoded, $field, $this->flextype['parser']->parse(Arr::get($entry_decoded, $field), 'shortcodes', $cache)); } } } @@ -335,9 +335,9 @@ class Entries if (Filesystem::has($entry_file)) { $body = Filesystem::read($entry_file); - $entry = $this->flextype['serializer']->decode($body, 'frontmatter'); + $entry = $this->flextype['frontmatter']->decode($body); - return Filesystem::write($entry_file, $this->flextype['serializer']->encode(array_merge($entry, $data), 'frontmatter')); + return Filesystem::write($entry_file, $this->flextype['frontmatter']->encode(array_merge($entry, $data))); } return false; @@ -380,7 +380,7 @@ class Entries $data['visibility'] = 'visible'; } - return Filesystem::write($entry_file, $this->flextype['serializer']->encode($data, 'frontmatter')); + return Filesystem::write($entry_file, $this->flextype['frontmatter']->encode($data)); } return false; diff --git a/src/flextype/Foundation/Media/MediaFiles.php b/src/flextype/Foundation/Media/MediaFiles.php index a0057625..7612ee31 100644 --- a/src/flextype/Foundation/Media/MediaFiles.php +++ b/src/flextype/Foundation/Media/MediaFiles.php @@ -7,7 +7,7 @@ declare(strict_types=1); * Founded by Sergey Romanenko and maintained by Flextype Community. */ -namespace Flextype; +namespace Flextype\Foundation\Media; use Flextype\Component\Filesystem\Filesystem; use Intervention\Image\ImageManagerStatic as Image; @@ -182,17 +182,17 @@ class MediaFiles // now you are able to resize the instance if ($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_width') > 0 && $this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_height') > 0) { - $img->resize($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_width'), $this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_height'), static function ($constraint) : void { + $img->resize($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_width'), $this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_height'), function ($constraint) : void { $constraint->aspectRatio(); $constraint->upsize(); }); } elseif ($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_width') > 0) { - $img->resize($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_width'), null, static function ($constraint) : void { + $img->resize($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_width'), null, function ($constraint) : void { $constraint->aspectRatio(); $constraint->upsize(); }); } elseif ($this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_height') > 0) { - $img->resize(null, $this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_height'), static function ($constraint) : void { + $img->resize(null, $this->flextype['registry']->get('plugins.admin.settings.entries.media.upload_images_height'), function ($constraint) : void { $constraint->aspectRatio(); $constraint->upsize(); }); @@ -224,7 +224,7 @@ class MediaFiles Filesystem::write( $upload_metadata_folder . basename($filename) . '.yaml', - $this->flextype['serializer']->encode($metadata, 'yaml') + $this->flextype['yaml']->encode($metadata) ); // Return new file path @@ -269,7 +269,7 @@ class MediaFiles $result = []; if (Filesystem::has($this->flextype['media_files_meta']->getFileMetaLocation($path))) { - $result = $this->flextype['serializer']->decode(Filesystem::read($this->flextype['media_files_meta']->getFileMetaLocation($path)), 'yaml'); + $result = $this->flextype['yaml']->decode(Filesystem::read($this->flextype['media_files_meta']->getFileMetaLocation($path))); $result['filename'] = pathinfo(str_replace('/.meta', '', $this->flextype['media_files_meta']->getFileMetaLocation($path)))['filename']; $result['basename'] = explode('.', basename($this->flextype['media_files_meta']->getFileMetaLocation($path)))[0]; @@ -302,7 +302,7 @@ class MediaFiles $result = []; foreach (Filesystem::listContents($this->flextype['media_folders_meta']->getDirMetaLocation($path)) as $file) { - $result[$file['basename']] = $this->flextype['serializer']->decode(Filesystem::read($file['path']), 'yaml'); + $result[$file['basename']] = $this->flextype['yaml']->decode(Filesystem::read($file['path'])); $result[$file['basename']]['filename'] = pathinfo(str_replace('/.meta', '', $this->flextype['media_files_meta']->getFileMetaLocation($file['basename'])))['filename']; $result[$file['basename']]['basename'] = explode('.', basename($this->flextype['media_files_meta']->getFileMetaLocation($file['basename'])))[0]; diff --git a/src/flextype/Foundation/Media/MediaFilesMeta.php b/src/flextype/Foundation/Media/MediaFilesMeta.php index bb705efc..77087933 100644 --- a/src/flextype/Foundation/Media/MediaFilesMeta.php +++ b/src/flextype/Foundation/Media/MediaFilesMeta.php @@ -44,12 +44,12 @@ class MediaFilesMeta */ public function update(string $id, string $field, string $value) : bool { - $file_data = $this->flextype['serializer']->decode(Filesystem::read($this->getFileMetaLocation($id)), 'yaml'); + $file_data = $this->flextype['yaml']->decode(Filesystem::read($this->getFileMetaLocation($id))); - if (Arr::keyExists($file_data, $field)) { - Arr::set($file_data, $field, $value); + if (array_has($file_data, $field)) { + array_set($file_data, $field, $value); - return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['serializer']->encode($file_data, 'yaml')); + return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['yaml']->encode($file_data)); } return false; @@ -68,12 +68,12 @@ class MediaFilesMeta */ public function add(string $id, string $field, string $value) : bool { - $file_data = $this->flextype['serializer']->decode(Filesystem::read($this->getFileMetaLocation($id)), 'yaml'); + $file_data = $this->flextype['yaml']->decode(Filesystem::read($this->getFileMetaLocation($id))); - if (! Arr::keyExists($file_data, $field)) { - Arr::set($file_data, $field, $value); + if (! array_has($file_data, $field)) { + array_set($file_data, $field, $value); - return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['serializer']->encode($file_data, 'yaml')); + return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['yaml']->encode($file_data)); } return false; @@ -91,12 +91,12 @@ class MediaFilesMeta */ public function delete(string $id, string $field) : bool { - $file_data = $this->flextype['serializer']->decode(Filesystem::read($this->getFileMetaLocation($id)), 'yaml'); + $file_data = $this->flextype['yaml']->decode(Filesystem::read($this->getFileMetaLocation($id))); - if (Arr::keyExists($file_data, $field)) { - Arr::delete($file_data, $field); + if (array_has($file_data, $field)) { + array_delete($file_data, $field); - return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['serializer']->encode($file_data, 'yaml')); + return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['yaml']->encode($file_data)); } return false; diff --git a/src/flextype/Foundation/Plugins/Plugins.php b/src/flextype/Foundation/Plugins.php similarity index 95% rename from src/flextype/Foundation/Plugins/Plugins.php rename to src/flextype/Foundation/Plugins.php index 8681b42a..603765db 100755 --- a/src/flextype/Foundation/Plugins/Plugins.php +++ b/src/flextype/Foundation/Plugins.php @@ -7,7 +7,7 @@ declare(strict_types=1); * Founded by Sergey Romanenko and maintained by Flextype Community. */ -namespace Flextype; +namespace Flextype\Foundation; use Composer\Semver\Semver; use Flextype\Component\Arr\Arr; @@ -44,7 +44,7 @@ class Plugins public function __construct($flextype, $app) { $this->flextype = $flextype; - $this->locales = $this->flextype['serializer']->decode(Filesystem::read(ROOT_DIR . '/src/flextype/locales.yaml'), 'yaml'); + $this->locales = $this->flextype['yaml']->decode(Filesystem::read(ROOT_DIR . '/src/flextype/locales.yaml')); } /** @@ -125,7 +125,7 @@ class Plugins // Get default plugin settings content $default_plugin_settings_file_content = Filesystem::read($default_plugin_settings_file); - $default_plugin_settings = $this->flextype['serializer']->decode($default_plugin_settings_file_content, 'yaml'); + $default_plugin_settings = $this->flextype['yaml']->decode($default_plugin_settings_file_content); // Create project plugin settings file ! Filesystem::has($project_plugin_settings_file) and Filesystem::write($project_plugin_settings_file, $default_plugin_settings_file_content); @@ -136,7 +136,7 @@ class Plugins if (trim($project_plugin_settings_file_content) === '') { $project_plugin_settings = []; } else { - $project_plugin_settings = $this->flextype['serializer']->decode($project_plugin_settings_file_content, 'yaml'); + $project_plugin_settings = $this->flextype['yaml']->decode($project_plugin_settings_file_content); } // Check if default plugin manifest file exists @@ -146,7 +146,7 @@ class Plugins // Get default plugin manifest content $default_plugin_manifest_file_content = Filesystem::read($default_plugin_manifest_file); - $default_plugin_manifest = $this->flextype['serializer']->decode($default_plugin_manifest_file_content, 'yaml'); + $default_plugin_manifest = $this->flextype['yaml']->decode($default_plugin_manifest_file_content); // Merge plugin settings and manifest data $plugins[$plugin['dirname']]['manifest'] = $default_plugin_manifest; @@ -167,7 +167,7 @@ class Plugins // ... and delete tmp _priority field for sorting foreach ($plugins as $plugin_name => $plugin_data) { - Arr::delete($plugins, $plugin_name . '._priority'); + array_delete($plugins, $plugin_name . '._priority'); } // Get Valid Plugins Dependencies @@ -207,7 +207,7 @@ class Plugins throw new RuntimeException('Load file: ' . $language_file . ' - failed!'); } - $translates = $this->flextype['serializer']->decode($content, 'yaml'); + $translates = $this->flextype['yaml']->decode($content); I18n::add($translates, $locale); } @@ -386,7 +386,7 @@ class Plugins continue; } - include_once PATH['project'] . '/plugins/' . $plugin_name . '/bootstrap.php'; + //include_once PATH['project'] . '/plugins/' . $plugin_name . '/bootstrap.php'; } } }