mirror of
https://github.com/flextype/flextype.git
synced 2025-08-10 07:06:45 +02:00
feat(core): use Arrays class for arrays
This commit is contained in:
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Foundation;
|
||||
|
||||
use Awilum\ArrayDots\ArrayDots;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
class Config
|
||||
@@ -43,7 +43,7 @@ class Config
|
||||
$config_file = $this->getFileLocation($config);
|
||||
|
||||
if (Filesystem::has($config_file)) {
|
||||
return ArrayDots::get($this->flextype->yaml->decode(Filesystem::read($config_file)), $key, $default);
|
||||
return Arrays::get($this->flextype->yaml->decode(Filesystem::read($config_file)), $key, $default);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ class Config
|
||||
if (Filesystem::has($config_file)) {
|
||||
$config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file));
|
||||
|
||||
if (! ArrayDots::has($config_file_data, $key)) {
|
||||
ArrayDots::set($config_file_data, $key, $value);
|
||||
if (! Arrays::has($config_file_data, $key)) {
|
||||
Arrays::set($config_file_data, $key, $value);
|
||||
|
||||
return Filesystem::write($config_file, $this->flextype->yaml->encode($config_file_data));
|
||||
}
|
||||
@@ -87,8 +87,8 @@ class Config
|
||||
if (Filesystem::has($config_file)) {
|
||||
$config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file));
|
||||
|
||||
if (ArrayDots::has($config_file_data, $key)) {
|
||||
ArrayDots::set($config_file_data, $key, $value);
|
||||
if (Arrays::has($config_file_data, $key)) {
|
||||
Arrays::set($config_file_data, $key, $value);
|
||||
|
||||
return Filesystem::write($config_file, $this->flextype->yaml->encode($config_file_data));
|
||||
}
|
||||
@@ -112,8 +112,8 @@ class Config
|
||||
if (Filesystem::has($config_file)) {
|
||||
$config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file));
|
||||
|
||||
if (ArrayDots::has($config_file_data, $key)) {
|
||||
ArrayDots::delete($config_file_data, $key);
|
||||
if (Arrays::has($config_file_data, $key)) {
|
||||
Arrays::delete($config_file_data, $key);
|
||||
|
||||
return Filesystem::write($config_file, $this->flextype->yaml->encode($config_file_data));
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class Config
|
||||
if (Filesystem::has($config_file)) {
|
||||
$config_file_data = $this->flextype->yaml->decode(Filesystem::read($config_file));
|
||||
|
||||
if (ArrayDots::has($config_file_data, $key)) {
|
||||
if (Arrays::has($config_file_data, $key)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,6 @@ use function time;
|
||||
|
||||
class Entries
|
||||
{
|
||||
|
||||
/**
|
||||
* Current entry path
|
||||
*
|
||||
|
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Foundation\Media;
|
||||
|
||||
use Awilum\ArrayDots\ArrayDots;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
|
||||
class MediaFilesMeta
|
||||
@@ -46,8 +46,8 @@ class MediaFilesMeta
|
||||
{
|
||||
$file_data = $this->flextype['yaml']->decode(Filesystem::read($this->getFileMetaLocation($id)));
|
||||
|
||||
if (ArrayDots::has($file_data, $field)) {
|
||||
ArrayDots::set($file_data, $field, $value);
|
||||
if (Arrays::has($file_data, $field)) {
|
||||
Arrays::set($file_data, $field, $value);
|
||||
|
||||
return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['yaml']->encode($file_data));
|
||||
}
|
||||
@@ -70,8 +70,8 @@ class MediaFilesMeta
|
||||
{
|
||||
$file_data = $this->flextype['yaml']->decode(Filesystem::read($this->getFileMetaLocation($id)));
|
||||
|
||||
if (! ArrayDots::has($file_data, $field)) {
|
||||
ArrayDots::set($file_data, $field, $value);
|
||||
if (! Arrays::has($file_data, $field)) {
|
||||
Arrays::set($file_data, $field, $value);
|
||||
|
||||
return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['yaml']->encode($file_data));
|
||||
}
|
||||
@@ -93,8 +93,8 @@ class MediaFilesMeta
|
||||
{
|
||||
$file_data = $this->flextype['yaml']->decode(Filesystem::read($this->getFileMetaLocation($id)));
|
||||
|
||||
if (ArrayDots::has($file_data, $field)) {
|
||||
ArrayDots::delete($file_data, $field);
|
||||
if (Arrays::has($file_data, $field)) {
|
||||
Arrays::delete($file_data, $field);
|
||||
|
||||
return Filesystem::write($this->getFileMetaLocation($id), $this->flextype['yaml']->encode($file_data));
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Foundation;
|
||||
|
||||
use Awilum\ArrayDots\ArrayDots;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
use Composer\Semver\Semver;
|
||||
use Flextype\Component\Filesystem\Filesystem;
|
||||
use Flextype\Component\I18n\I18n;
|
||||
@@ -163,11 +163,11 @@ class Plugins
|
||||
}
|
||||
|
||||
// Sort plugins list by priority.
|
||||
$plugins = ArrayDots::sort($plugins, '_priority', 'DESC');
|
||||
$plugins = Arrays::sort($plugins, '_priority', 'DESC');
|
||||
|
||||
// ... and delete tmp _priority field for sorting
|
||||
foreach ($plugins as $plugin_name => $plugin_data) {
|
||||
ArrayDots::delete($plugins, $plugin_name . '._priority');
|
||||
Arrays::delete($plugins, $plugin_name . '._priority');
|
||||
}
|
||||
|
||||
// Get Valid Plugins Dependencies
|
||||
@@ -333,7 +333,7 @@ class Plugins
|
||||
// Show alert if dependencies are not installed properly
|
||||
$diff = array_diff_key($non_verified_plugins, $verified_plugins);
|
||||
if (count($diff) > 0) {
|
||||
echo '<b>The following dependencies need to be installed properly:</b>';
|
||||
echo '<b>Dependencies need to be installed properly for this plugins:</b>';
|
||||
echo '<ul>';
|
||||
foreach ($diff as $plugin_name => $plugin_data) {
|
||||
echo '<li>' . $plugin_name . '</li>';
|
||||
|
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support;
|
||||
|
||||
use Awilum\ArrayDots\ArrayDots;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
@@ -102,7 +102,7 @@ class Collection
|
||||
$flat_array = [];
|
||||
|
||||
foreach ($items as $key => $value) {
|
||||
$flat_array[$key] = ArrayDots::dot($value);
|
||||
$flat_array[$key] = Arrays::dot($value);
|
||||
}
|
||||
|
||||
$items = $flat_array;
|
||||
@@ -294,7 +294,7 @@ class Collection
|
||||
$results = $collection->last();
|
||||
|
||||
// Return first matching result
|
||||
return is_array($results) ? ArrayDots::undot($results) : $results;
|
||||
return is_array($results) ? Arrays::undot($results) : $results;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,7 +321,7 @@ class Collection
|
||||
$results = $collection->next();
|
||||
|
||||
// Return first matching result
|
||||
return is_array($results) ? ArrayDots::undot($results) : $results;
|
||||
return is_array($results) ? Arrays::undot($results) : $results;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,7 +348,7 @@ class Collection
|
||||
$results = $collection->toArray();
|
||||
|
||||
if ($this->_isAssocArray($results)) {
|
||||
$results = ArrayDots::undot(ArrayDots::dot($results));
|
||||
$results = Arrays::undot(Arrays::dot($results));
|
||||
$this->_shuffleAssocArray($results);
|
||||
} else {
|
||||
shuffle($results);
|
||||
@@ -380,7 +380,7 @@ class Collection
|
||||
$results = $collection->first();
|
||||
|
||||
// Return first matching result
|
||||
return is_array($results) ? ArrayDots::undot($results) : $results;
|
||||
return is_array($results) ? Arrays::undot($results) : $results;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,7 +416,7 @@ class Collection
|
||||
}
|
||||
|
||||
if ($this->_isAssocArray($array)) {
|
||||
$array = ArrayDots::undot(ArrayDots::dot($array));
|
||||
$array = Arrays::undot(Arrays::dot($array));
|
||||
}
|
||||
|
||||
if ((int) $number === 1 || is_null($number)) {
|
||||
@@ -467,7 +467,7 @@ class Collection
|
||||
$results = $collection->slice($offset, $length);
|
||||
|
||||
// Return results
|
||||
return $this->_isAssocArray($results) ? ArrayDots::undot(ArrayDots::dot($results)) : $results;
|
||||
return $this->_isAssocArray($results) ? Arrays::undot(Arrays::dot($results)) : $results;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,7 +492,7 @@ class Collection
|
||||
$results = $collection->toArray();
|
||||
|
||||
// Return results
|
||||
return $this->_isAssocArray($results) ? ArrayDots::undot(ArrayDots::dot($results)) : $results;
|
||||
return $this->_isAssocArray($results) ? Arrays::undot(Arrays::dot($results)) : $results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -8,9 +8,9 @@ declare(strict_types=1);
|
||||
*/
|
||||
|
||||
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
|
||||
use Awilum\ArrayDots\ArrayDots;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
|
||||
// Shortcode: [entries_fetch id="entry-id" field="field-name" default="default-value"]
|
||||
$flextype['shortcode']->add('entries_fetch', function (ShortcodeInterface $s) use ($flextype) {
|
||||
return ArrayDots::get($flextype['entries']->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
|
||||
return Arrays::get($flextype['entries']->fetch($s->getParameter('id')), $s->getParameter('field'), $s->getParameter('default'));
|
||||
});
|
||||
|
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flextype\Support\Serializers;
|
||||
|
||||
use Awilum\ArrayDots\ArrayDots;
|
||||
use Flextype\Component\Arrays\Arrays;
|
||||
use function array_slice;
|
||||
use function count;
|
||||
use function implode;
|
||||
@@ -81,7 +81,7 @@ class Frontmatter
|
||||
{
|
||||
if (isset($input['content'])) {
|
||||
$content = $input['content'];
|
||||
ArrayDots::delete($input, 'content');
|
||||
Arrays::delete($input, 'content');
|
||||
$matter = $this->flextype['yaml']->encode($input);
|
||||
} else {
|
||||
$content = '';
|
||||
|
@@ -176,7 +176,7 @@ date_default_timezone_set($flextype['registry']->get('flextype.settings.timezone
|
||||
/**
|
||||
* Init shortocodes
|
||||
*
|
||||
* Load Flextype Shortcodes extensions from directory /flextype/Support/Parsers/Shortcodes/ based on settings.shortcodes.extensions array
|
||||
* Load Flextype Shortcodes extensions from directory /flextype/Support/Parsers/Shortcodes/ based on flextype.settings.shortcodes.extensions array
|
||||
*/
|
||||
$shortcodes_extensions = $flextype['registry']->get('flextype.settings.shortcodes.extensions');
|
||||
|
||||
|
Reference in New Issue
Block a user