Skip to content

Commit

Permalink
Boot Performance verbessern (#40)
Browse files Browse the repository at this point in the history
* Weniger Code während des Bbootvorgangs ausführen
* Watson::hasProviders() hinzugefügt
* Watson nur initialisieren wenn Provider registriert sind
  • Loading branch information
staabm authored and tbaddade committed Nov 5, 2018
1 parent 8681803 commit 350550c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
23 changes: 10 additions & 13 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,27 @@
* file that was distributed with this source code.
*/

if (rex::isBackend() && rex::getUser()) {
$providers = \Watson\Foundation\Watson::loadProviders();
if (rex::isBackend() && rex::getUser() && \Watson\Foundation\Watson::hasProviders()) {
if (rex_get('watson_query')) {
$providers = \Watson\Foundation\Watson::loadProviders();

if (count($providers)) {
$workflows = [];

foreach ($providers as $provider) {
if ($provider instanceof \Watson\Foundation\Workflow) {
$workflows[] = $provider;
}
}

if (count($workflows)) {
rex_extension::register('PAGE_HEADER', '\Watson\Foundation\Extension::head');
rex_extension::register('PACKAGES_INCLUDED', '\Watson\Foundation\Extension::run', rex_extension::LATE, ['workflows' => $workflows]);
rex_extension::register('PACKAGES_INCLUDED', '\Watson\Foundation\Extension::callWatsonFunc', rex_extension::LATE);
}

rex_extension::register('OUTPUT_FILTER', '\Watson\Foundation\Extension::agent');
rex_extension::register('PAGE_HEADER', '\Watson\Foundation\Extension::head');

rex_extension::register('PACKAGES_INCLUDED', '\Watson\Foundation\Extension::run', rex_extension::LATE, ['workflows' => $workflows]);
rex_extension::register('PACKAGES_INCLUDED', '\Watson\Foundation\Extension::callWatsonFunc', rex_extension::LATE);
rex_extension::register('OUTPUT_FILTER', '\Watson\Foundation\Extension::agent');

if (\Watson\Foundation\Watson::getToggleButtonStatus()) {
rex_extension::register('META_NAVI', '\Watson\Foundation\Extension::toggleButton');
}
}
if (\Watson\Foundation\Watson::getToggleButtonStatus()) {
rex_extension::register('META_NAVI', '\Watson\Foundation\Extension::toggleButton');
}

foreach ($this->getProperty('stylesheets', []) as $stylesheet) {
Expand Down
7 changes: 7 additions & 0 deletions lib/Watson/Foundation/Watson.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public static function translate($key, ...$params)
{
return \rex_i18n::msg($key, ...$params);
}

public static function hasProviders() {
$providers = \rex_addon::get('watson')->getProperty('providers');
$providers = \rex_extension::registerPoint(new \rex_extension_point('WATSON_PROVIDER', $providers));

return count($providers) > 0;
}

public static function loadProviders()
{
Expand Down

0 comments on commit 350550c

Please sign in to comment.