Example #1
0
                $response->applyBearCMSTheme = true;
                if ($pageID !== 'home') {
                    $response->bearCMSPageID = $pageID;
                }
                return $response;
            }
        });
    }
});
// Updates the Bear CMS components when created
if (Options::hasFeature('ELEMENTS') || Options::hasFeature('ELEMENTS_*')) {
    $app->hooks->add('componentCreated', function ($component) {
        if ($component->src === 'bearcms-elements') {
            ElementsHelper::updateContainerComponent($component);
        } elseif (array_search($component->src, ['bearcms-heading-element', 'bearcms-text-element', 'bearcms-link-element', 'bearcms-video-element', 'bearcms-image-element', 'bearcms-image-gallery-element', 'bearcms-navigation-element', 'bearcms-html-element', 'bearcms-blog-posts-element']) !== false) {
            ElementsHelper::updateElementComponent($component);
        }
    });
}
$app->hooks->add('responseCreated', function ($response) use($app, $context) {
    if ($response instanceof App\Response\NotFound) {
        $response->enableBearCMS = true;
        $response->applyBearCMSTheme = true;
        $response->setContentType('text/html');
    } elseif ($response instanceof App\Response\TemporaryUnavailable) {
        $response->enableBearCMS = true;
        $response->applyBearCMSTheme = true;
        $response->setContentType('text/html');
    } elseif ($app->request->path === '/' && $response instanceof App\Response\HTML) {
        $response->enableBearCMS = true;
        $response->applyBearCMSTheme = true;