Replaced Moment with Carbon #84

Merged
Ghost merged 148 commits from develop into beta 2022-09-22 05:53:36 +02:00
6 changed files with 50 additions and 66 deletions
Showing only changes of commit 9a716acb29 - Show all commits

View file

@ -1,6 +1,10 @@
<?php <?php
use App\Services\ContentService;
function sorter() function sorter()
{ {
echo("BITCH WE ARE SORTING"); $content = new ContentService();
$pages = $content->loadAllPages();
echo(count($pages));
} }

View file

@ -1,6 +1,42 @@
<?php <?php
function tester() function createUUID()
{ {
echo("IT WORKS"); if (function_exists('com_create_guid') === true) {
return trim(com_create_guid(), '{}');
}
return sprintf(
'%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(16384, 20479),
mt_rand(32768, 49151),
mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(0, 65535)
);
}
function safeString($string)
{
return strtolower(
trim(
preg_replace(
'~[^0-9a-z]+~i',
'_',
html_entity_decode(
preg_replace(
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i',
'$1',
htmlentities($string, ENT_QUOTES, 'UTF-8')
),
ENT_QUOTES,
'UTF-8'
)
),
'-'
)
);
} }

View file

@ -11,7 +11,6 @@ use App\Services\ContentService;
use App\Services\PaginateService; use App\Services\PaginateService;
use App\Services\ThemeService; use App\Services\ThemeService;
use App\Services\DocService; use App\Services\DocService;
use App\Services\StringService;
use App\Services\FileUploadService; use App\Services\FileUploadService;
use App\Services\RenderService; use App\Services\RenderService;
use App\Services\SortingService; use App\Services\SortingService;
@ -45,10 +44,6 @@ class FipamoServiceProvider extends ServiceProvider
return new PaginateService(new ContentService()); return new PaginateService(new ContentService());
}); });
$this->app->bind(StringService::class, function ($app) {
return new StringService();
});
$this->app->bind(DocService::class, function ($app) { $this->app->bind(DocService::class, function ($app) {
return new DocService(); return new DocService();
}); });
@ -62,7 +57,6 @@ class FipamoServiceProvider extends ServiceProvider
new SortingService( new SortingService(
new SettingsService(new DocService(), new ContentService()), new SettingsService(new DocService(), new ContentService()),
new ContentService(), new ContentService(),
new StringService(),
new ThemeService(new SettingsService(new DocService(), new ContentService())) new ThemeService(new SettingsService(new DocService(), new ContentService()))
), ),
new SettingsService(new DocService(), new ContentService()), new SettingsService(new DocService(), new ContentService()),
@ -74,7 +68,6 @@ class FipamoServiceProvider extends ServiceProvider
return new SortingService( return new SortingService(
new SettingsService(new DocService(), new ContentService()), new SettingsService(new DocService(), new ContentService()),
new ContentService(), new ContentService(),
new StringService(),
new ThemeService(new SettingsService(new DocService(), new ContentService())) new ThemeService(new SettingsService(new DocService(), new ContentService()))
); );
}); });

View file

@ -192,4 +192,9 @@ class ContentService
$sorted->values()->all(); $sorted->values()->all();
return $sorted; return $sorted;
} }
public static function getAll()
{
echo("YES");
}
} }

View file

@ -13,18 +13,15 @@ class SortingService
private $p_archive = []; private $p_archive = [];
private $settings; private $settings;
private $contents; private $contents;
private $strings;
private $themes; private $themes;
public function __construct( public function __construct(
SettingsService $settingsService, SettingsService $settingsService,
ContentService $contentService, ContentService $contentService,
StringService $stringService,
ThemeService $themeService, ThemeService $themeService,
) { ) {
$this->settings = $settingsService; $this->settings = $settingsService;
$this->contents = $contentService; $this->contents = $contentService;
$this->strings = $stringService;
$this->themes = $themeService; $this->themes = $themeService;
} }
@ -40,7 +37,7 @@ class SortingService
if (!find($this->p_tags, ['tag_name' => $label])) { if (!find($this->p_tags, ['tag_name' => $label])) {
array_push($this->p_tags, [ array_push($this->p_tags, [
'tag_name' => $label, 'tag_name' => $label,
'slug' => $this->strings::safeString($label), 'slug' => safeString($label),
'pages' => $this->tagPages($label, $pages), 'pages' => $this->tagPages($label, $pages),
]); ]);
} }
@ -178,7 +175,7 @@ class SortingService
$label = trim($tag); $label = trim($tag);
array_push($tags, [ array_push($tags, [
'label' => $label . ' ', 'label' => $label . ' ',
'slug' => $this->strings->safeString($label), 'slug' => safeString($label),
]); ]);
} }
} }

View file

@ -1,51 +0,0 @@
<?php
namespace App\Services;
class StringService
{
public function __construct()
{
}
public static function createUUID()
{
if (function_exists('com_create_guid') === true) {
return trim(com_create_guid(), '{}');
}
return sprintf(
'%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(16384, 20479),
mt_rand(32768, 49151),
mt_rand(0, 65535),
mt_rand(0, 65535),
mt_rand(0, 65535)
);
}
public static function safeString($string)
{
return strtolower(
trim(
preg_replace(
'~[^0-9a-z]+~i',
'_',
html_entity_decode(
preg_replace(
'~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i',
'$1',
htmlentities($string, ENT_QUOTES, 'UTF-8')
),
ENT_QUOTES,
'UTF-8'
)
),
'-'
)
);
}
}