forked from projects/fipamo
removed string service
moved methods of string service to helper function and got rid of the string service class still messing around with the sorter helper to see how dependecies work. sorting as a helper may be a bit too complex for what help functions are supposed to be
This commit is contained in:
parent
65220fe06a
commit
9a716acb29
6 changed files with 50 additions and 66 deletions
|
@ -1,6 +1,10 @@
|
|||
<?php
|
||||
|
||||
use App\Services\ContentService;
|
||||
|
||||
function sorter()
|
||||
{
|
||||
echo("BITCH WE ARE SORTING");
|
||||
$content = new ContentService();
|
||||
$pages = $content->loadAllPages();
|
||||
echo(count($pages));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,42 @@
|
|||
<?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'
|
||||
)
|
||||
),
|
||||
'-'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ use App\Services\ContentService;
|
|||
use App\Services\PaginateService;
|
||||
use App\Services\ThemeService;
|
||||
use App\Services\DocService;
|
||||
use App\Services\StringService;
|
||||
use App\Services\FileUploadService;
|
||||
use App\Services\RenderService;
|
||||
use App\Services\SortingService;
|
||||
|
@ -45,10 +44,6 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
return new PaginateService(new ContentService());
|
||||
});
|
||||
|
||||
$this->app->bind(StringService::class, function ($app) {
|
||||
return new StringService();
|
||||
});
|
||||
|
||||
$this->app->bind(DocService::class, function ($app) {
|
||||
return new DocService();
|
||||
});
|
||||
|
@ -62,7 +57,6 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
new SortingService(
|
||||
new SettingsService(new DocService(), new ContentService()),
|
||||
new ContentService(),
|
||||
new StringService(),
|
||||
new ThemeService(new SettingsService(new DocService(), new ContentService()))
|
||||
),
|
||||
new SettingsService(new DocService(), new ContentService()),
|
||||
|
@ -74,7 +68,6 @@ class FipamoServiceProvider extends ServiceProvider
|
|||
return new SortingService(
|
||||
new SettingsService(new DocService(), new ContentService()),
|
||||
new ContentService(),
|
||||
new StringService(),
|
||||
new ThemeService(new SettingsService(new DocService(), new ContentService()))
|
||||
);
|
||||
});
|
||||
|
|
|
@ -192,4 +192,9 @@ class ContentService
|
|||
$sorted->values()->all();
|
||||
return $sorted;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
echo("YES");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,18 +13,15 @@ class SortingService
|
|||
private $p_archive = [];
|
||||
private $settings;
|
||||
private $contents;
|
||||
private $strings;
|
||||
private $themes;
|
||||
|
||||
public function __construct(
|
||||
SettingsService $settingsService,
|
||||
ContentService $contentService,
|
||||
StringService $stringService,
|
||||
ThemeService $themeService,
|
||||
) {
|
||||
$this->settings = $settingsService;
|
||||
$this->contents = $contentService;
|
||||
$this->strings = $stringService;
|
||||
$this->themes = $themeService;
|
||||
}
|
||||
|
||||
|
@ -40,7 +37,7 @@ class SortingService
|
|||
if (!find($this->p_tags, ['tag_name' => $label])) {
|
||||
array_push($this->p_tags, [
|
||||
'tag_name' => $label,
|
||||
'slug' => $this->strings::safeString($label),
|
||||
'slug' => safeString($label),
|
||||
'pages' => $this->tagPages($label, $pages),
|
||||
]);
|
||||
}
|
||||
|
@ -178,7 +175,7 @@ class SortingService
|
|||
$label = trim($tag);
|
||||
array_push($tags, [
|
||||
'label' => $label . ' ',
|
||||
'slug' => $this->strings->safeString($label),
|
||||
'slug' => safeString($label),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
),
|
||||
'-'
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue