Skip to content

Commit

Permalink
Apply php-cs-fixer changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr-w authored and github-actions[bot] committed Nov 24, 2024
1 parent 915ce59 commit 0aac0f2
Showing 1 changed file with 25 additions and 34 deletions.
59 changes: 25 additions & 34 deletions lib/speed_up.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct($profile = 'auto')
}
$mount_id = rex_yrewrite::getCurrentDomain()->getMountId();
$category_mount_children = [];

if (rex_category::get($mount_id)) {
$category_mount_children = rex_category::get($mount_id)->getChildren(true);
}
Expand All @@ -35,21 +35,20 @@ public function __construct($profile = 'auto')

$category_neighbours = [];

if ($category_parent != null && $category_current->getId() != $mount_id) {
if (null != $category_parent && $category_current->getId() != $mount_id) {
// Nur wenn wir uns nicht in Root befinden oder überhalb eines Mount-Points - andere YRewrite-Domains möchten wir nicht prefetchen.
$category_neighbours = $category_parent->getChildren(true);
}

// Manuelle Einstellungen
$article_prefetch_config = explode(",", speed_up::getConfig('prefetch_articles') ?? "");

if (self::getConfig('profile') === 'auto') {
$article_prefetch_config = explode(',', self::getConfig('prefetch_articles') ?? '');

if ('auto' === self::getConfig('profile')) {
// Mount-Point = oberste Navigationsebene (Startseite könnte auch in einer Unterkategorie sein)
foreach ($category_mount_children as $category) {
$urls[$category->getId()] = $category->getUrl();
}

// Nur das erste Kind-Element
foreach ($category_children as $category) {
$urls[$category->getId()] = $category->getUrl();
Expand All @@ -64,9 +63,9 @@ public function __construct($profile = 'auto')
}
$urls[$category->getId()] = $category->getUrl();
// Nach 2 gefundenen Nachbarn aussteigen
if (++$neighbours == 2) {
if (2 == ++$neighbours) {
break;
};
}
}

$neighbours = 0;
Expand All @@ -76,36 +75,32 @@ public function __construct($profile = 'auto')
continue;
}
$urls[$article->getId()] = $article->getUrl();
if (++$neighbours == 2) {
if (2 == ++$neighbours) {
break;
};
}
}

if ($category_current && $category_current->getId() != $start_id) {
// Startseite hinzufügen
$urls[$start_id] = rex_article::get($start_id)->getUrl();
}
} elseif (self::getConfig('profile') === 'aggressive') {

} elseif ('aggressive' === self::getConfig('profile')) {
// Mount-Point = oberste Navigationsebene (Startseite könnte auch in einer Unterkategorie sein)
foreach ($category_mount_children as $category) {
$urls[$category->getId()] = $category->getUrl();
}

foreach ($category_children as $category) {
$urls[$category->getId()] = $category->getUrl();
}

foreach ($category_articles as $article) {
$urls[$article->getId()] = $article->getUrl();
}



foreach ($category_neighbours as $category) {
$urls[$category->getId()] = $category->getUrl();
}


if ($category_current && $category_current->getId() != $start_id) {
// Startseite hinzufügen
Expand All @@ -123,7 +118,7 @@ public function __construct($profile = 'auto')

$urls = rex_extension::registerPoint(new rex_extension_point(
'PREFETCH_URLS',
$urls
$urls,
));

/*
Expand All @@ -145,47 +140,43 @@ public function __construct($profile = 'auto')
unset($urls[rex_config::get('ycom/auth', 'article_id_register')]);
unset($urls[rex_config::get('ycom/auth', 'article_id_password')]);
unset($urls[rex_config::get('ycom', 'otp_article_id')]);

}

unset($urls[rex_yrewrite::getCurrentDomain()->getNotfoundId()]);

$this->urls = $urls;

return $this;
}


public function showOutput()
{
echo $this->getOutput();
return;
}

public function show() /* Alias, BC */
{
return $this->showOutput();
}


public function getOutput()
{
if (self::getConfig('profile') === 'disabled') {
if ('disabled' === self::getConfig('profile')) {
return;
}
$output = PHP_EOL;
$output .= self::getConfig('preload').PHP_EOL;
$output .= self::getConfig('prefetch').PHP_EOL;
$preload_media_config = explode(",", speed_up::getConfig('preload_media') ?? "");
$output = PHP_EOL;
$output .= self::getConfig('preload') . PHP_EOL;
$output .= self::getConfig('prefetch') . PHP_EOL;

$preload_media_config = explode(',', self::getConfig('preload_media') ?? '');

foreach ($preload_media_config as $file) {
if ($media = rex_media::get($file)) {
$output .= '<link rel="preload" href="'. $media->getUrl() .'" as="image" type="'.$media->getType().'">'.PHP_EOL;
$output .= '<link rel="preload" href="' . $media->getUrl() . '" as="image" type="' . $media->getType() . '">' . PHP_EOL;
}
}
if (self::getConfig('profile') === "custom") {

if ('custom' === self::getConfig('profile')) {
return;
}

Expand All @@ -194,7 +185,7 @@ public function getOutput()
if (isset($parsedUrl['scheme']) && !in_array($parsedUrl['scheme'], ['http', 'https'])) {
continue;
}
$output .= '<link rel="prefetch" href="'. $url .'">'.PHP_EOL;
$output .= '<link rel="prefetch" href="' . $url . '">' . PHP_EOL;
}
return $output;
}
Expand Down

0 comments on commit 0aac0f2

Please sign in to comment.