Phalcon Framework 3.2.1

Phalcon\Mvc\Dispatcher\Exception: Page 'vie-privee-de-nos-clients' not found

/app/app/modules/Page/Controller/BelgiumController.php (17)
#0Page\Controller\BelgiumController->indexAction(fr, vie-privee-de-nos-clients)
#1Phalcon\Dispatcher->callActionMethod(Object(Page\Controller\BelgiumController), indexAction, Array([lang] => fr, [slug] => vie-privee-de-nos-clients))
#2Phalcon\Dispatcher->_dispatch()
#3Phalcon\Dispatcher->dispatch()
/app/app/Bootstrap.php (481)
<?php
 
namespace YonaCMS;
 
use Application\Mvc\Helper\CmsCache;
use Application\Mvc\Model\ShopModel;
use Cms\Model\Language;
use Cms\Model\Translate;
use Application\Mvc\Helper\Meta;
 
use JdSoft\Pim\Pim;
use JdSoft\GooSe\GooSeAPI;
use Phalcon\Di;
use Phalcon\Logger as pLogger;
 
use Seo\Model\Manager;
use Seo\Plugin\SeoManager;
use YonaCMS\Plugin\DeferWrapper;
use YonaCMS\Plugin\PaperLogger;
use YonaCMS\Plugin\PimCacheImplementation;
 
require("vendor/autoload.php");
 
/**
 * Bootstrap
 * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
 * @author Aleksandr Torosh <webtorua@gmail.com>
 */
class Bootstrap
{
 
    public function run()
    {
        $di = new \Phalcon\DI\FactoryDefault();
 
        // Config
        require_once APPLICATION_PATH . '/modules/Cms/Config.php';
        $config = \Cms\Config::get();
        $di->set('config', $config);
 
        // Registry
        $registry = new \Phalcon\Registry();
        $di->set('registry', $registry);
 
        // Loader
        $loader = new \Phalcon\Loader();
        $loader->registerNamespaces($config->loader->namespaces->toArray());
        $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
        $loader->register();
 
        // Database
        $db = new \Phalcon\Db\Adapter\Pdo\Postgresql([
            "host" => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname" => $config->database->dbname,
            'options' => [
                \PDO::ATTR_TIMEOUT => 60,
                \PDO::ATTR_PERSISTENT => true
            ]
        ]);
        $di->setShared('db', $db);
 
        $this->initModelsManager($di);
 
        // View
        $this->initView($di);
 
        // URL
        $url = new \Phalcon\Mvc\Url();
        $url->setBasePath($config->base_path);
        $url->setBaseUri($config->base_path);
        $di->set('url', $url);
 
        // Cache
        $this->initCache($di);
 
        $di->set('pim', new Pim($config->pim->username, $config->pim->password, $config->pim->country, new PimCacheImplementation($di->get('cache')), $config->pim->apiurl));
        $di->set('goose', new GooSeAPI($config->goose->username, $config->goose->password, $config->goose->api_url));
 
        // CMS
        $cmsModel = new \Cms\Model\Configuration();
        $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
 
        // Application
        $application = new \Phalcon\Mvc\Application();
        $application->registerModules($config->modules->toArray());
 
        // Events Manager, Dispatcher
        $this->initEventManager($di);
 
        // Session
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        $di->set('session', $session);
 
        $acl = new \Application\Acl\DefaultAcl();
        $di->set('acl', $acl);
 
        // JS Assets
        $this->initAssetsManager($di, $config->version);
 
        // Facebook
        if(array_key_exists('FACEBOOK_APP_ID', $registry->cms) && $registry->cms['FACEBOOK_APP_ID'] && $registry->cms['FACEBOOK_APP_ENABLED']) {
            $di->set('facebook', new \Facebook\Facebook([
                'app_id' => $registry->cms['FACEBOOK_APP_ID'],
                'app_secret' => (array_key_exists('FACEBOOK_APP_SECRET', $registry->cms)) ? $registry->cms['FACEBOOK_APP_SECRET'] :  '',
                'default_graph_version' => 'v2.2',
            ]));
        }
 
        // Flash helper
        $flash = new \Phalcon\Flash\Session([
            'error' => 'ui red inverted segment',
            'success' => 'ui green inverted segment',
            'notice' => 'ui blue inverted segment',
            'warning' => 'ui orange inverted segment',
        ]);
        $di->set('flash', $flash);
 
        $di->set('helper', new \Application\Mvc\Helper());
 
        //Site verification
        if(array_key_exists('GOOGLE_SITE_VERIFICATION', $registry->cms)) {
            Meta::getInstance()->set('google-site-verification', $registry->cms['GOOGLE_SITE_VERIFICATION']);
        }
 
        // Routing
        $this->initRouting($application, $di);
 
        $di->set("logger", function() use ($di, $config) {
            $sysLogger = new \Phalcon\Logger\Adapter\Stream("php://stderr");
            $sysLogger->setLogLevel(pLogger::INFO);
 
            $multiLogger = new pLogger\Multiple();
            $multiLogger->push($sysLogger);
 
            $streamLogger = new PaperLogger('Floralshop-'.$config->unit, ['url' => 'logs2.papertrailapp.com', 'port' => 26382] );
            $streamLogger->setLogLevel(pLogger::INFO);
 
            $multiLogger->push($streamLogger);
 
            return $multiLogger;
        });
 
        $application->setDI($di);
 
        // Main dispatching process
        $this->dispatch($di);
 
    }
 
    private function initRouting($application, $di)
    {
 
 
        $di->set('shop', function() use ($di) {
            $request = $di->get('request');
            $shop = explode( '.', $request->getHttpHost());
            return $shop[0];
        });
 
        $router = new \Application\Mvc\Router\DefaultRouter();
        $router->removeExtraSlashes(true);
        $router->setDi($di);
        foreach ($application->getModules() as $module) {
            $routesClassName = str_replace('Module', 'Routes', $module['className']);
            if (class_exists($routesClassName)) {
                $routesClass = new $routesClassName();
                $router = $routesClass->init($router);
            }
            $initClassName = str_replace('Module', 'Init', $module['className']);
            if (class_exists($initClassName)) {
                new $initClassName();
            }
        }
        $di->set('router', $router);
    }
 
    private function initAssetsManager($di, $version)
    {
        $config = $di->get('config');
        $assetsManager = new \Application\Assets\Manager();
        $assetsManager->collection('extra-js')
            ->setLocal(true)
            ->addFilter(new DeferWrapper())
            ->addInlineJs('');
 
        if($config->unit == 'belgium' || $config->unit == 'czech' ) {
            $assetsManager->collection('extra-js')
                ->addInlineJs("
                    jQuery(document).ready(function() {
                        jQuery('.stickypart').affix({offset: {top: 37} }); 
                    });
                ");
            $assetsManager->collection('gtm')->addInlineJs("window.dataLayer = window.dataLayer || [];\n");
        } else {
            $assetsManager->collection('gtm')->addInlineJs("var _gaq = _gaq || [];\n");
        }
        $js_collection = $assetsManager->collection('js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/js.js')
            ->setTargetUri('assets/js.js')
            ->join(true);
        if ($config->assets->js) {
            foreach ($config->assets->js as $js) {
                $js_collection->addJs(ROOT . '/' . $js);
            }
        }
 
        if(APPLICATION_ENV === 'development') {
            $assetsManager->collection('header-js')
                ->addJs("dist/js/bower.min.js", null, false, array('defer' => 'defer'))
                ->addJs("dist/js/common.min.js", null, false, array('defer' => 'defer'))
                ->addJs("dist/js/main.min.js", null, false, array('defer' => 'defer'))
                ->addJs("static/js/ui.js", null, false, array('defer' => 'defer'))
                ->addJs('assets/headsup.min.js', null, false, ["defer" => "defer"])
                ->addJs("assets/outdatedbrowser/outdatedbrowser.min.js", null, false, array('defer' => 'defer'))
                ->addJs("assets/slippry.min.js", null, false, array('defer' => 'defer'))->setLocal(true);
            $assetsManager->collection('header-css')
                ->addCss('dist/css/bower.min.css')
                ->addCss('dist/css/interflora.min.css')
                ->addCss('assets/slippry.css')
                ->addCss('assets/outdatedbrowser/outdatedbrowser.min.css')->setLocal(true);
        } else if(APPLICATION_ENV !== 'development')  {
            $assetsManager->collection('header-js')
                ->setLocal(true)
            ->addJs('dist/production/all.min.js', null, false, array('defer' => 'defer'));
 
            $assetsManager->collection('header-css')
                ->setLocal(true)
                ->addCss('dist/production/all.min.css');
        }
 
        // Admin JS Assets
        $assetsManager->collection('modules-admin-js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/modules-admin.js')
            ->setTargetUri('assets/modules-admin.js')
            ->join(true);
 
 
        $di->set('assets', $assetsManager);
    }
 
    private function initEventManager($di)
    {
        $eventsManager = new \Phalcon\Events\Manager();
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \YonaCMS\Plugin\CheckPoint($di->get('request'));
            new \YonaCMS\Plugin\Localization($dispatcher);
            new \YonaCMS\Plugin\AdminLocalization($di->get('config'));
            new \YonaCMS\Plugin\Acl($di->get('acl'), $dispatcher, $di->get('view'));
        });
 
        $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
            new \YonaCMS\Plugin\Title($di);
        });
 
 
        $eventsManager->attach('db', function ($event, $db) use ($di) {
            if ($event->getType() == 'beforeQuery') {
                $statement = $db->getSQLStatement();
                $sqlVariables = $db->getSQLVariables();
                if(count($sqlVariables)) {
                    $di->get('logger')->debug($statement . ' ' . join(',', $sqlVariables));
                } else {
                    $di->get('logger')->debug($statement);
                }
            }
        });
 
        $db = $di->get('db');
        $db->setEventsManager($eventsManager);
 
        $dispatcher->setEventsManager($eventsManager);
        $di->set('dispatcher', $dispatcher);
    }
 
    private function initView($di)
    {
        $view = new \Phalcon\Mvc\View();
 
        define('MAIN_VIEW_PATH', '../../../views/');
        $view->setMainView(MAIN_VIEW_PATH . 'main');
        $view->setLayoutsDir(MAIN_VIEW_PATH . ACTIVE_UNIT . '/layouts/');
        $view->setLayout('main');
        $view->setPartialsDir(MAIN_VIEW_PATH . ACTIVE_UNIT . '/partials/');
 
        //BASE TITLE
        $view->title = "";
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/cache/volt/', 'compileAlways' => (APPLICATION_ENV === 'development')]);
        $volt->initCompiler();
 
        //load function php
        $compiler = $volt->getCompiler();
        //define variable translate
        $compiler->addFunction('array_slice', 'array_slice');
        $compiler->addFunction('strtotime', 'strtotime');
        $compiler->addFunction(
            'tinyMCE',
            function ($resolvedArgs, $exprArgs) {
                return 'Application\Mvc\View\Tags\HelperTags::tinyMCE(' . $resolvedArgs . ')';
            }
        );
        $compiler->addFilter('capitalize_string', 'ucfirst');
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt" => $volt,
            ".phtml" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
 
        $ajax = $di->get('request')->getQuery('_ajax');
        if ($ajax) {
            $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
        }
 
        $di->set('view', $view);
 
        //Minify HTML
        $eventManager = new \Phalcon\Events\Manager();
        $view->setEventsManager($eventManager);
 
        $eventManager->attach("view:afterRender", function ($event, $view) use ($di){
            $content = $view->getContent();
            // Remove spaces at start of lines, and empty lines
           //$content = preg_replace('/\r?\n\s*(\r?\n)?/', " ", $content);
            // Remove xhtml endings
            $content = str_replace(' >', '>', str_replace('/>', '>', $content));
            $view->setContent($content);
        });
 
 
        $simpleView = new \Phalcon\Mvc\View\Simple();
 
        $voltSimple = new \Application\Mvc\View\Engine\Volt($simpleView, $di);
        $voltSimple->setOptions(['compiledPath' => APPLICATION_PATH . '/cache/volt/', 'compileAlways' => (APPLICATION_ENV === 'development')]);
        $voltSimple->initCompiler();
 
        $simpleView->registerEngines(array(
            ".volt" => $voltSimple
        ));
        $di->set('simpleView', $simpleView);
 
        return $view;
    }
 
    private function initCache(Di $di)
    {
        $config = $di->get('config');
 
        $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
            "lifetime" => 86400,
            "prefix" => HOST_HASH
        ]);
 
        $cacheOutputFrontend = new \Phalcon\Cache\Frontend\Output([
            "lifetime" => 86400,
            "prefix" => "view_"
        ]);
 
        $cache = null;
        $cacheOutput = null;
        switch ($config->cache) {
            case 'file':
                $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
                    "cacheDir" => __DIR__ . "/cache/backend/"
                ]);
                $cacheOutput = new \Phalcon\Cache\Backend\File($cacheOutputFrontend, [
                    "cacheDir" => __DIR__ . "/cache/backend/",
                    "prefix" => "view_"
                ]);
                break;
            case 'memcache':
                $cache = new \Phalcon\Cache\Backend\Memcache(
                    $cacheFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                $cacheOutput = new \Phalcon\Cache\Backend\Memcache(
                    $cacheOutputFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                break;
            case 'redis':
                $cache = new \Phalcon\Cache\Backend\Redis(
                    $cacheFrontend, [
                    "host" => $config->redis->host,
                    "port" => $config->redis->port,
                    "persistent" => $config->redis->persistent,
                    "statsKey" => "_PHCR"
                ]);
                $cacheOutput = new \Phalcon\Cache\Backend\Redis(
                    $cacheOutputFrontend, [
                    "host" => $config->redis->host,
                    "port" => $config->redis->port,
                    "persistent" => $config->redis->persistent,
                    "statsKey" => "_PHCR"
                ]);
                break;
        }
        $cacheProf = $cache; // new \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cache, $di->get('profiler'));
 
        $di->set('cache', $cacheProf, true);
        $di->set('modelsCache', $cacheProf, true);
        $di->set('viewCache', $cacheOutput, true);
 
        \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
        if($config->cache == 'redis') {
            $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Redis([
                'prefix' => 'meta_data',
                'lifetime' => 3600,
                'host' => $config->redis->host,
                'port' => $config->redis->port,
                'persistent' => $config->redis->persistent
            ]);
        } else {
            $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
        }
 
        $di->set('modelsMetadata', $modelsMetadata);
 
        if(CmsCache::getInstance()->has('languages') == FALSE) {
            CmsCache::getInstance()->save('languages',Language::buildCmsLanguagesCache());
            CmsCache::getInstance()->save('translates',Translate::buildCmsTranslatesCache());
            CmsCache::getInstance()->save('seo_manager', Manager::buildCmsSeoManagerCache());
        }
    }
 
 
    private function dispatch($di)
    {
        $router = $di['router'];
 
        $router->handle();
 
        $view = $di['view'];
 
        $dispatcher = $di['dispatcher'];
 
        $response = $di['response'];
 
        if (extension_loaded ('newrelic')) {
            newrelic_name_transaction ($router->getModuleName(). '/'. $router->getControllerName() . '/' . $router->getActionName());
        }
 
        $dispatcher->setModuleName($router->getModuleName());
        $dispatcher->setControllerName($router->getControllerName());
        $dispatcher->setActionName($router->getActionName());
        $dispatcher->setParams($router->getParams());
 
        $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
        $ModuleClassName = $moduleName . '\Module';
        if (class_exists($ModuleClassName)) {
            $module = new $ModuleClassName;
            $module->registerAutoloaders();
            $module->registerServices($di);
        }
 
        $view->start();
 
        $registry = $di['registry'];
        if ($registry->cms['DEBUG_MODE']) {
            $debug = new \Phalcon\Debug();
            $debug->listen();
 
            $dispatcher->dispatch();
        } else {
            try {
                $dispatcher->dispatch();
            } catch (\Phalcon\Exception $e) {
                // Errors catching
 
                $view->setViewsDir(__DIR__ . '/modules/Index/views/');
                $view->e = $e;
                $view->request = $di->getRequest();
 
                if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                    $response->setStatusCode(404, 'Not Found');
                    $view->pick(['error/error404']);
                    $view->render(null,null);
                } else {
                    $response->setStatusCode(503, 'Service Unavailable');
                    $view->pick(['error/error503']);
                    $view->render(null,null);
                }
                $response->sendHeaders();
                echo $response->getContent();
 
                return;
 
            }
        }
 
        $view->render(
            $dispatcher->getControllerName(),
            $dispatcher->getActionName(),
            $dispatcher->getParams()
        );
 
        $view->finish();
 
        $response = $di['response'];
 
        // AJAX
        $request = $di['request'];
        $_ajax = $request->getQuery('_ajax');
        if ($_ajax) {
            $contents = $view->getContent();
 
            $return = new \stdClass();
            $return->html = $contents;
            $return->title = $di->get('helper')->title()->get();
            $return->success = true;
 
            if ($view->bodyClass) {
                $return->bodyClass = $view->bodyClass;
            }
 
            $headers = $response->getHeaders()->toArray();
            if (isset($headers[404]) || isset($headers[503])) {
                $return->success = false;
            }
            $response->setContentType('application/json', 'UTF-8');
            $response->setContent(json_encode($return));
        } else {
            $response->setContent($view->getContent());
        }
 
        $response->sendHeaders();
 
        echo $response->getContent();
    }
 
    /**
     * @param $di
     */
    public function initModelsManager(Di $di)
    {
        $di->setShared('modelsManager', function () use ($di) {
            $eventsManager = new \Phalcon\Events\Manager();
            $eventsManager->attach('model:beforeCreate', function ($event, $model) use ($di) {
                if (get_parent_class($model) === 'Application\Mvc\Model\ShopModel') {
                    $model->setShopPrefix($di->get('shop'));
                }
 
            });
            // Setting a default EventsManager
            $modelsManager = new \Phalcon\Mvc\Model\Manager();
            $modelsManager->setEventsManager($eventsManager);
 
            return $modelsManager;
        });
    }
 
}
#4YonaCMS\Bootstrap->dispatch(Object(Phalcon\Di\FactoryDefault))
/app/app/Bootstrap.php (149)
<?php
 
namespace YonaCMS;
 
use Application\Mvc\Helper\CmsCache;
use Application\Mvc\Model\ShopModel;
use Cms\Model\Language;
use Cms\Model\Translate;
use Application\Mvc\Helper\Meta;
 
use JdSoft\Pim\Pim;
use JdSoft\GooSe\GooSeAPI;
use Phalcon\Di;
use Phalcon\Logger as pLogger;
 
use Seo\Model\Manager;
use Seo\Plugin\SeoManager;
use YonaCMS\Plugin\DeferWrapper;
use YonaCMS\Plugin\PaperLogger;
use YonaCMS\Plugin\PimCacheImplementation;
 
require("vendor/autoload.php");
 
/**
 * Bootstrap
 * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
 * @author Aleksandr Torosh <webtorua@gmail.com>
 */
class Bootstrap
{
 
    public function run()
    {
        $di = new \Phalcon\DI\FactoryDefault();
 
        // Config
        require_once APPLICATION_PATH . '/modules/Cms/Config.php';
        $config = \Cms\Config::get();
        $di->set('config', $config);
 
        // Registry
        $registry = new \Phalcon\Registry();
        $di->set('registry', $registry);
 
        // Loader
        $loader = new \Phalcon\Loader();
        $loader->registerNamespaces($config->loader->namespaces->toArray());
        $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
        $loader->register();
 
        // Database
        $db = new \Phalcon\Db\Adapter\Pdo\Postgresql([
            "host" => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname" => $config->database->dbname,
            'options' => [
                \PDO::ATTR_TIMEOUT => 60,
                \PDO::ATTR_PERSISTENT => true
            ]
        ]);
        $di->setShared('db', $db);
 
        $this->initModelsManager($di);
 
        // View
        $this->initView($di);
 
        // URL
        $url = new \Phalcon\Mvc\Url();
        $url->setBasePath($config->base_path);
        $url->setBaseUri($config->base_path);
        $di->set('url', $url);
 
        // Cache
        $this->initCache($di);
 
        $di->set('pim', new Pim($config->pim->username, $config->pim->password, $config->pim->country, new PimCacheImplementation($di->get('cache')), $config->pim->apiurl));
        $di->set('goose', new GooSeAPI($config->goose->username, $config->goose->password, $config->goose->api_url));
 
        // CMS
        $cmsModel = new \Cms\Model\Configuration();
        $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
 
        // Application
        $application = new \Phalcon\Mvc\Application();
        $application->registerModules($config->modules->toArray());
 
        // Events Manager, Dispatcher
        $this->initEventManager($di);
 
        // Session
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        $di->set('session', $session);
 
        $acl = new \Application\Acl\DefaultAcl();
        $di->set('acl', $acl);
 
        // JS Assets
        $this->initAssetsManager($di, $config->version);
 
        // Facebook
        if(array_key_exists('FACEBOOK_APP_ID', $registry->cms) && $registry->cms['FACEBOOK_APP_ID'] && $registry->cms['FACEBOOK_APP_ENABLED']) {
            $di->set('facebook', new \Facebook\Facebook([
                'app_id' => $registry->cms['FACEBOOK_APP_ID'],
                'app_secret' => (array_key_exists('FACEBOOK_APP_SECRET', $registry->cms)) ? $registry->cms['FACEBOOK_APP_SECRET'] :  '',
                'default_graph_version' => 'v2.2',
            ]));
        }
 
        // Flash helper
        $flash = new \Phalcon\Flash\Session([
            'error' => 'ui red inverted segment',
            'success' => 'ui green inverted segment',
            'notice' => 'ui blue inverted segment',
            'warning' => 'ui orange inverted segment',
        ]);
        $di->set('flash', $flash);
 
        $di->set('helper', new \Application\Mvc\Helper());
 
        //Site verification
        if(array_key_exists('GOOGLE_SITE_VERIFICATION', $registry->cms)) {
            Meta::getInstance()->set('google-site-verification', $registry->cms['GOOGLE_SITE_VERIFICATION']);
        }
 
        // Routing
        $this->initRouting($application, $di);
 
        $di->set("logger", function() use ($di, $config) {
            $sysLogger = new \Phalcon\Logger\Adapter\Stream("php://stderr");
            $sysLogger->setLogLevel(pLogger::INFO);
 
            $multiLogger = new pLogger\Multiple();
            $multiLogger->push($sysLogger);
 
            $streamLogger = new PaperLogger('Floralshop-'.$config->unit, ['url' => 'logs2.papertrailapp.com', 'port' => 26382] );
            $streamLogger->setLogLevel(pLogger::INFO);
 
            $multiLogger->push($streamLogger);
 
            return $multiLogger;
        });
 
        $application->setDI($di);
 
        // Main dispatching process
        $this->dispatch($di);
 
    }
 
    private function initRouting($application, $di)
    {
 
 
        $di->set('shop', function() use ($di) {
            $request = $di->get('request');
            $shop = explode( '.', $request->getHttpHost());
            return $shop[0];
        });
 
        $router = new \Application\Mvc\Router\DefaultRouter();
        $router->removeExtraSlashes(true);
        $router->setDi($di);
        foreach ($application->getModules() as $module) {
            $routesClassName = str_replace('Module', 'Routes', $module['className']);
            if (class_exists($routesClassName)) {
                $routesClass = new $routesClassName();
                $router = $routesClass->init($router);
            }
            $initClassName = str_replace('Module', 'Init', $module['className']);
            if (class_exists($initClassName)) {
                new $initClassName();
            }
        }
        $di->set('router', $router);
    }
 
    private function initAssetsManager($di, $version)
    {
        $config = $di->get('config');
        $assetsManager = new \Application\Assets\Manager();
        $assetsManager->collection('extra-js')
            ->setLocal(true)
            ->addFilter(new DeferWrapper())
            ->addInlineJs('');
 
        if($config->unit == 'belgium' || $config->unit == 'czech' ) {
            $assetsManager->collection('extra-js')
                ->addInlineJs("
                    jQuery(document).ready(function() {
                        jQuery('.stickypart').affix({offset: {top: 37} }); 
                    });
                ");
            $assetsManager->collection('gtm')->addInlineJs("window.dataLayer = window.dataLayer || [];\n");
        } else {
            $assetsManager->collection('gtm')->addInlineJs("var _gaq = _gaq || [];\n");
        }
        $js_collection = $assetsManager->collection('js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/js.js')
            ->setTargetUri('assets/js.js')
            ->join(true);
        if ($config->assets->js) {
            foreach ($config->assets->js as $js) {
                $js_collection->addJs(ROOT . '/' . $js);
            }
        }
 
        if(APPLICATION_ENV === 'development') {
            $assetsManager->collection('header-js')
                ->addJs("dist/js/bower.min.js", null, false, array('defer' => 'defer'))
                ->addJs("dist/js/common.min.js", null, false, array('defer' => 'defer'))
                ->addJs("dist/js/main.min.js", null, false, array('defer' => 'defer'))
                ->addJs("static/js/ui.js", null, false, array('defer' => 'defer'))
                ->addJs('assets/headsup.min.js', null, false, ["defer" => "defer"])
                ->addJs("assets/outdatedbrowser/outdatedbrowser.min.js", null, false, array('defer' => 'defer'))
                ->addJs("assets/slippry.min.js", null, false, array('defer' => 'defer'))->setLocal(true);
            $assetsManager->collection('header-css')
                ->addCss('dist/css/bower.min.css')
                ->addCss('dist/css/interflora.min.css')
                ->addCss('assets/slippry.css')
                ->addCss('assets/outdatedbrowser/outdatedbrowser.min.css')->setLocal(true);
        } else if(APPLICATION_ENV !== 'development')  {
            $assetsManager->collection('header-js')
                ->setLocal(true)
            ->addJs('dist/production/all.min.js', null, false, array('defer' => 'defer'));
 
            $assetsManager->collection('header-css')
                ->setLocal(true)
                ->addCss('dist/production/all.min.css');
        }
 
        // Admin JS Assets
        $assetsManager->collection('modules-admin-js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/modules-admin.js')
            ->setTargetUri('assets/modules-admin.js')
            ->join(true);
 
 
        $di->set('assets', $assetsManager);
    }
 
    private function initEventManager($di)
    {
        $eventsManager = new \Phalcon\Events\Manager();
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \YonaCMS\Plugin\CheckPoint($di->get('request'));
            new \YonaCMS\Plugin\Localization($dispatcher);
            new \YonaCMS\Plugin\AdminLocalization($di->get('config'));
            new \YonaCMS\Plugin\Acl($di->get('acl'), $dispatcher, $di->get('view'));
        });
 
        $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
            new \YonaCMS\Plugin\Title($di);
        });
 
 
        $eventsManager->attach('db', function ($event, $db) use ($di) {
            if ($event->getType() == 'beforeQuery') {
                $statement = $db->getSQLStatement();
                $sqlVariables = $db->getSQLVariables();
                if(count($sqlVariables)) {
                    $di->get('logger')->debug($statement . ' ' . join(',', $sqlVariables));
                } else {
                    $di->get('logger')->debug($statement);
                }
            }
        });
 
        $db = $di->get('db');
        $db->setEventsManager($eventsManager);
 
        $dispatcher->setEventsManager($eventsManager);
        $di->set('dispatcher', $dispatcher);
    }
 
    private function initView($di)
    {
        $view = new \Phalcon\Mvc\View();
 
        define('MAIN_VIEW_PATH', '../../../views/');
        $view->setMainView(MAIN_VIEW_PATH . 'main');
        $view->setLayoutsDir(MAIN_VIEW_PATH . ACTIVE_UNIT . '/layouts/');
        $view->setLayout('main');
        $view->setPartialsDir(MAIN_VIEW_PATH . ACTIVE_UNIT . '/partials/');
 
        //BASE TITLE
        $view->title = "";
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/cache/volt/', 'compileAlways' => (APPLICATION_ENV === 'development')]);
        $volt->initCompiler();
 
        //load function php
        $compiler = $volt->getCompiler();
        //define variable translate
        $compiler->addFunction('array_slice', 'array_slice');
        $compiler->addFunction('strtotime', 'strtotime');
        $compiler->addFunction(
            'tinyMCE',
            function ($resolvedArgs, $exprArgs) {
                return 'Application\Mvc\View\Tags\HelperTags::tinyMCE(' . $resolvedArgs . ')';
            }
        );
        $compiler->addFilter('capitalize_string', 'ucfirst');
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt" => $volt,
            ".phtml" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
 
        $ajax = $di->get('request')->getQuery('_ajax');
        if ($ajax) {
            $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
        }
 
        $di->set('view', $view);
 
        //Minify HTML
        $eventManager = new \Phalcon\Events\Manager();
        $view->setEventsManager($eventManager);
 
        $eventManager->attach("view:afterRender", function ($event, $view) use ($di){
            $content = $view->getContent();
            // Remove spaces at start of lines, and empty lines
           //$content = preg_replace('/\r?\n\s*(\r?\n)?/', " ", $content);
            // Remove xhtml endings
            $content = str_replace(' >', '>', str_replace('/>', '>', $content));
            $view->setContent($content);
        });
 
 
        $simpleView = new \Phalcon\Mvc\View\Simple();
 
        $voltSimple = new \Application\Mvc\View\Engine\Volt($simpleView, $di);
        $voltSimple->setOptions(['compiledPath' => APPLICATION_PATH . '/cache/volt/', 'compileAlways' => (APPLICATION_ENV === 'development')]);
        $voltSimple->initCompiler();
 
        $simpleView->registerEngines(array(
            ".volt" => $voltSimple
        ));
        $di->set('simpleView', $simpleView);
 
        return $view;
    }
 
    private function initCache(Di $di)
    {
        $config = $di->get('config');
 
        $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
            "lifetime" => 86400,
            "prefix" => HOST_HASH
        ]);
 
        $cacheOutputFrontend = new \Phalcon\Cache\Frontend\Output([
            "lifetime" => 86400,
            "prefix" => "view_"
        ]);
 
        $cache = null;
        $cacheOutput = null;
        switch ($config->cache) {
            case 'file':
                $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
                    "cacheDir" => __DIR__ . "/cache/backend/"
                ]);
                $cacheOutput = new \Phalcon\Cache\Backend\File($cacheOutputFrontend, [
                    "cacheDir" => __DIR__ . "/cache/backend/",
                    "prefix" => "view_"
                ]);
                break;
            case 'memcache':
                $cache = new \Phalcon\Cache\Backend\Memcache(
                    $cacheFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                $cacheOutput = new \Phalcon\Cache\Backend\Memcache(
                    $cacheOutputFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                break;
            case 'redis':
                $cache = new \Phalcon\Cache\Backend\Redis(
                    $cacheFrontend, [
                    "host" => $config->redis->host,
                    "port" => $config->redis->port,
                    "persistent" => $config->redis->persistent,
                    "statsKey" => "_PHCR"
                ]);
                $cacheOutput = new \Phalcon\Cache\Backend\Redis(
                    $cacheOutputFrontend, [
                    "host" => $config->redis->host,
                    "port" => $config->redis->port,
                    "persistent" => $config->redis->persistent,
                    "statsKey" => "_PHCR"
                ]);
                break;
        }
        $cacheProf = $cache; // new \Fabfuel\Prophiler\Decorator\Phalcon\Cache\BackendDecorator($cache, $di->get('profiler'));
 
        $di->set('cache', $cacheProf, true);
        $di->set('modelsCache', $cacheProf, true);
        $di->set('viewCache', $cacheOutput, true);
 
        \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
        if($config->cache == 'redis') {
            $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Redis([
                'prefix' => 'meta_data',
                'lifetime' => 3600,
                'host' => $config->redis->host,
                'port' => $config->redis->port,
                'persistent' => $config->redis->persistent
            ]);
        } else {
            $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
        }
 
        $di->set('modelsMetadata', $modelsMetadata);
 
        if(CmsCache::getInstance()->has('languages') == FALSE) {
            CmsCache::getInstance()->save('languages',Language::buildCmsLanguagesCache());
            CmsCache::getInstance()->save('translates',Translate::buildCmsTranslatesCache());
            CmsCache::getInstance()->save('seo_manager', Manager::buildCmsSeoManagerCache());
        }
    }
 
 
    private function dispatch($di)
    {
        $router = $di['router'];
 
        $router->handle();
 
        $view = $di['view'];
 
        $dispatcher = $di['dispatcher'];
 
        $response = $di['response'];
 
        if (extension_loaded ('newrelic')) {
            newrelic_name_transaction ($router->getModuleName(). '/'. $router->getControllerName() . '/' . $router->getActionName());
        }
 
        $dispatcher->setModuleName($router->getModuleName());
        $dispatcher->setControllerName($router->getControllerName());
        $dispatcher->setActionName($router->getActionName());
        $dispatcher->setParams($router->getParams());
 
        $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
        $ModuleClassName = $moduleName . '\Module';
        if (class_exists($ModuleClassName)) {
            $module = new $ModuleClassName;
            $module->registerAutoloaders();
            $module->registerServices($di);
        }
 
        $view->start();
 
        $registry = $di['registry'];
        if ($registry->cms['DEBUG_MODE']) {
            $debug = new \Phalcon\Debug();
            $debug->listen();
 
            $dispatcher->dispatch();
        } else {
            try {
                $dispatcher->dispatch();
            } catch (\Phalcon\Exception $e) {
                // Errors catching
 
                $view->setViewsDir(__DIR__ . '/modules/Index/views/');
                $view->e = $e;
                $view->request = $di->getRequest();
 
                if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                    $response->setStatusCode(404, 'Not Found');
                    $view->pick(['error/error404']);
                    $view->render(null,null);
                } else {
                    $response->setStatusCode(503, 'Service Unavailable');
                    $view->pick(['error/error503']);
                    $view->render(null,null);
                }
                $response->sendHeaders();
                echo $response->getContent();
 
                return;
 
            }
        }
 
        $view->render(
            $dispatcher->getControllerName(),
            $dispatcher->getActionName(),
            $dispatcher->getParams()
        );
 
        $view->finish();
 
        $response = $di['response'];
 
        // AJAX
        $request = $di['request'];
        $_ajax = $request->getQuery('_ajax');
        if ($_ajax) {
            $contents = $view->getContent();
 
            $return = new \stdClass();
            $return->html = $contents;
            $return->title = $di->get('helper')->title()->get();
            $return->success = true;
 
            if ($view->bodyClass) {
                $return->bodyClass = $view->bodyClass;
            }
 
            $headers = $response->getHeaders()->toArray();
            if (isset($headers[404]) || isset($headers[503])) {
                $return->success = false;
            }
            $response->setContentType('application/json', 'UTF-8');
            $response->setContent(json_encode($return));
        } else {
            $response->setContent($view->getContent());
        }
 
        $response->sendHeaders();
 
        echo $response->getContent();
    }
 
    /**
     * @param $di
     */
    public function initModelsManager(Di $di)
    {
        $di->setShared('modelsManager', function () use ($di) {
            $eventsManager = new \Phalcon\Events\Manager();
            $eventsManager->attach('model:beforeCreate', function ($event, $model) use ($di) {
                if (get_parent_class($model) === 'Application\Mvc\Model\ShopModel') {
                    $model->setShopPrefix($di->get('shop'));
                }
 
            });
            // Setting a default EventsManager
            $modelsManager = new \Phalcon\Mvc\Model\Manager();
            $modelsManager->setEventsManager($eventsManager);
 
            return $modelsManager;
        });
    }
 
}
#5YonaCMS\Bootstrap->run()
/app/web/index.php (14)
<?php
 
chdir(dirname(__DIR__));
 
define('ROOT', __DIR__);
define('HOST_HASH', substr(md5($_SERVER['HTTP_HOST']), 0, 12));
 
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
 
define('APPLICATION_PATH', __DIR__ . '/../app');
 
require_once APPLICATION_PATH . '/Bootstrap.php';
$bootstrap = new YonaCMS\Bootstrap();
$bootstrap->run();
KeyValue
_url/fr/vie-privee-de-nos-clients.html
KeyValue
REDIRECT_UNITbelgium
REDIRECT_DATABASE_HOST172.30.62.200
REDIRECT_DATABASE_USERNAMEfloraladmin
REDIRECT_DATABASE_PASSWORDLnqocV87wscijt8s
REDIRECT_DATABASE_DBNAMEfloralshop
REDIRECT_REDIS_HOST172.30.241.203
REDIRECT_REDIS_PORT6379
REDIRECT_STATUS200
UNITbelgium
DATABASE_HOST172.30.62.200
DATABASE_USERNAMEfloraladmin
DATABASE_PASSWORDLnqocV87wscijt8s
DATABASE_DBNAMEfloralshop
REDIS_HOST172.30.241.203
REDIS_PORT6379
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_IF_MODIFIED_SINCESun, 23 Sep 2018 05:05:27 UTC
HTTP_HOSTbloemendhondt.floralshop.be
HTTP_ACCEPT_ENCODINGgzip
HTTP_X_FORWARDED_HOSTbloemendhondt.floralshop.be
HTTP_X_FORWARDED_PORT443
HTTP_X_FORWARDED_PROTOhttps
HTTP_FORWARDEDfor=54.235.48.106;host=bloemendhondt.floralshop.be;proto=https
HTTP_X_FORWARDED_FOR54.235.48.106
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SERVER_SIGNATURE
SERVER_SOFTWAREApache/2.4.34 (Unix)
SERVER_NAMEbloemendhondt.floralshop.be
SERVER_ADDR10.1.2.39
SERVER_PORT80
REMOTE_ADDR10.1.9.1
DOCUMENT_ROOT/app/web
REQUEST_SCHEMEhttp
CONTEXT_PREFIX
CONTEXT_DOCUMENT_ROOT/app/web
SERVER_ADMINnoc@weepee.io
SCRIPT_FILENAME/app/web/index.php
REMOTE_PORT32808
REDIRECT_URL/fr/vie-privee-de-nos-clients.html
REDIRECT_QUERY_STRING_url=/fr/vie-privee-de-nos-clients.html
GATEWAY_INTERFACECGI/1.1
SERVER_PROTOCOLHTTP/1.1
REQUEST_METHODGET
QUERY_STRING_url=/fr/vie-privee-de-nos-clients.html
REQUEST_URI/fr/vie-privee-de-nos-clients.html
SCRIPT_NAME/index.php
PHP_SELF/index.php
REQUEST_TIME_FLOAT1542227386.149
REQUEST_TIME1542227386
#Path
0/app/web/index.php
1/app/app/Bootstrap.php
2/app/vendor/autoload.php
3/app/vendor/composer/autoload_real.php
4/app/vendor/composer/ClassLoader.php
5/app/vendor/composer/autoload_static.php
6/app/vendor/guzzlehttp/psr7/src/functions_include.php
7/app/vendor/guzzlehttp/psr7/src/functions.php
8/app/vendor/symfony/polyfill-mbstring/bootstrap.php
9/app/vendor/clue/stream-filter/src/functions.php
10/app/vendor/php-http/message/src/filters.php
11/app/vendor/guzzlehttp/promises/src/functions_include.php
12/app/vendor/guzzlehttp/promises/src/functions.php
13/app/vendor/guzzlehttp/guzzle/src/functions_include.php
14/app/vendor/guzzlehttp/guzzle/src/functions.php
15/app/vendor/swiftmailer/swiftmailer/lib/swift_required.php
16/app/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php
17/app/vendor/facebook/php-sdk-v4/src/Facebook/polyfills.php
18/app/app/modules/Cms/Config.php
19/app/app/config/production/application.php
20/app/app/config/global.php
21/app/app/config/production/belgium.php
22/app/vendor/JdSoft/GooSe/src/GooSeAPI.php
23/app/app/modules/Application/Loader/Modules.php
24/app/app/modules/Application/Mvc/View/Engine/Volt.php
25/app/app/modules/Application/Widget/Proxy.php
26/app/app/modules/Application/Mvc/Helper/CmsCache.php
27/app/vendor/JdSoft/Pim/src/Pim.php
28/app/app/plugins/PimCacheImplementation.php
29/tmp/pim.auth.token
30/app/goose.auth.token
31/app/app/modules/Cms/Model/Configuration.php
32/app/app/modules/Application/Acl/DefaultAcl.php
33/app/app/config/acl.php
34/app/app/modules/Application/Assets/Manager.php
35/app/app/plugins/DeferWrapper.php
36/app/app/modules/Application/Mvc/Helper.php
37/app/app/modules/Menu/Helper/Menu.php
38/app/app/modules/Application/Mvc/Helper/Meta.php
39/app/app/modules/Application/Mvc/Router/DefaultRouter.php
40/app/app/modules/Cms/Routes.php
41/app/app/modules/Index/Routes.php
42/app/app/modules/Application/Mvc/Router/Routes.php
43/app/app/modules/Index/Routes/Belgium.php
44/app/app/modules/Frontend/Routes.php
45/app/app/modules/Frontend/Routes/Belgium.php
46/app/app/modules/Shopping/Routes.php
47/app/app/modules/Admin/Routes.php
48/app/app/modules/Pim/Routes.php
49/app/app/modules/Page/Routes.php
50/app/app/modules/Page/Routes/Belgium.php
51/app/app/modules/Seo/Routes.php
52/app/app/modules/ProductMenu/Routes.php
53/app/app/modules/Account/Routes.php
54/app/app/modules/Account/Routes/Belgium.php
55/app/app/modules/Services/Routes.php
56/app/app/modules/Services/Routes/Belgium.php
57/app/app/modules/Slider/Routes.php
58/app/app/modules/Search/Routes.php
59/app/app/modules/Members/Routes.php
60/app/app/modules/Members/Routes/Belgium.php
61/app/app/modules/OrderManager/Routes.php
62/app/app/modules/OrderManager/Routes/Belgium.php
63/app/app/modules/Basket/Routes.php
64/app/app/modules/Basket/Routes/Belgium.php
65/app/app/modules/Customcss/Routes.php
66/app/app/modules/Page/Model/Page.php
67/app/app/modules/Application/Mvc/Model/ShopModel.php
68/app/app/modules/Application/Mvc/Model/Model.php
69/app/app/modules/Page/Model/Translate/PageTranslate.php
70/app/app/modules/Application/Mvc/Model/Translate.php
71/app/app/plugins/PaperLogger.php
72/app/app/modules/Application/Utils/ModuleName.php
73/app/app/modules/Page/Module.php
74/app/app/plugins/CheckPoint.php
75/app/app/plugins/Localization.php
76/app/app/modules/Cms/Model/Translate.php
77/app/app/plugins/AdminLocalization.php
78/app/app/translations/admin/nl.php
79/app/app/plugins/Acl.php
80/app/app/modules/Page/Controller/BelgiumController.php
81/app/app/modules/Application/Mvc/Controller.php
Memory
Usage2097152