Phalcon Framework 4.1.2

TypeError: Return value of Multiple\Www\Controllers\ProductController::getNomenclatureMember() must be an instance of Phalcon\Mvc\Model, null returned

/home/clearair/public_html/vendor/webolie/core/Traits/NomenclatureAwareTrait.php (64)
#0Multiple\Www\Controllers\ProductController->getNomenclatureMember(aerus)
/home/clearair/public_html/apps/www/controllers/ProductController.php (85)
<?php
 
namespace Multiple\Www\Controllers;
 
use Multiple\Base\Models\BannerSet;
use Multiple\Base\Models\Page;
use Multiple\Base\Models\Product;
use Multiple\Base\Models\Promotion;
use Multiple\Www\Forms\ProductsForm;
use Webolie\Core\Traits\TextAwareTrait;
use Webolie\Core\Traits\NomenclatureAwareTrait;
 
/**
 * Class ProductController
 * @package Multiple\Www\Controllers
 */
class ProductController extends ControllerBase
{
    use TextAwareTrait, NomenclatureAwareTrait;
 
    /**
     *
     */
    public function indexAction()
    {
        // product comparison
        //set comparison mode
        $compare = $this->request->getQuery('compare', 'string');
        $inComparison = false;
        if (isset($compare)) {
            if ($compare == false) {
                $this->session->remove('productToCompare');
            } else {
                $productsToCompare = explode('-', $this->request->get('compare'));
 
                $products = [];
                foreach ($productsToCompare as $productId) {
                    $productId = (int)$productId;
                    $prod = Product::getProductById($productId);
                    if ($prod) {
                        $products[] = $prod;
                    }
                }
 
                if (count($products) > 0) {
                    $inComparison = true;
                }
            }
        }
        $this->view->showComparePanel =  true;
 
        $this->view->promotions = Promotion::getPromotionsArr();
 
        if ($inComparison) {
 
            $this->view->showComparePanel =  false;
            $this->view->productToCompareRes = $products;
            // product characteristics
            $this->view->productCharacteristicsNomenclature = $this->getNomenclatureGroupMembers('product-characteristics', 'array');
 
            // $this->view->setLayout("nosubheader");
            $this->view->pick('product/compare');
            
            // used for structured data generation
            $this->getPageDetails('products');
    
            // set structured data for comparison listing
            $this->structuredData->add($this->view->productList, null, 'ProductList');
        } else {
            $params = $this->dispatcher->getParams();
 
            $slug = str_replace('/' . $this->languages->getActiveLanguage(), '', $this->request->getUri());
            $pageDetails = Page::getPageBySlug($slug, $this->languages->getActiveLanguage());
            $pageKey = $pageDetails->key;
 
            $formFilters = [];
            $entity = new \stdClass();
        
            $brand = null;
            $type = null;
        
            if (isset($params['brand'])) {
                $pageKey = 'products';
                $pageKey = $params['brand'] . '-' . $pageKey;
                $brand = $this->getNomenclatureMember($params['brand']);
                $formFilters['brand'] = $brand->nomenclatureId;
                $formFilters['block'] = 'brand';
        
                $entity->brandIdVisual = $brand->nomenclatureId;
            } elseif (isset($params['type'])) {
                $pageKey = 'products';
                $pageKey = $params['type'] . '-' . $pageKey;
                $type = $this->getNomenclatureMember($params['type']);
                $formFilters['type'] = $type->nomenclatureId;
                $formFilters['block'] = 'type';
        
                $entity->typeIdVisual = $type->nomenclatureId;
            }
        
            if ($this->request->isPost()) {
                $postData = $this->request->getPost();
                $formFilters = array_merge($formFilters, $this->request->getPost());
                foreach ($postData as $key => $value) {
                    if ($value) {
                        $formFilters[$key] = $value;
                        $entity->{$key . 'IdVisual'} = $value;
                    }
                }
            }
 
            if ($this->request->isGet()) {
                $getData = $this->request->get();
                $formFilters = array_merge($formFilters, $this->request->get());
                foreach ($getData as $key => $value) {
                    if ($value) {
                        $formFilters[$key] = $value;
                        $entity->{$key . 'IdVisual'} = $value;
                    }
                }
            }
 
            if ($pageKey === 'products') {
                $formFilters['condition'] = 'new';
            } elseif ($pageKey === 'refurbished-products') {
                $formFilters['condition'] = 'refurbished';
            }
            $this->view->products = Product::getProducts('active', $formFilters);
            
            $this->view->characteristics = $this->getNomenclatureGroupMembers('product-characteristics', 'array', false);
            $this->view->categories = $this->getNomenclatureGroupMembers('product-category', 'array', false);
 
            $this->getPageDetails($pageKey, 'yes');
            $this->view->productForm = new ProductsForm($entity, $formFilters);
    
            // banner
            // TODO: see what slides should be here - maybe per brand/type
            $bannerSet = new BannerSet();
            $banners = $bannerSet->getBannerSet('homepage');
            $topSlides = [];
            foreach ($banners->getBanner(['status = "active"']) as $banner) {
                $topSlides[] = $banner;
            }
            
            if ($brand) {
                $this->view->brand = $brand->key;
            }
            
            $this->view->productTopSlides = $topSlides;
        }
    }
 
    /**
     *
     */
    public function detailsAction()
    {
        $this->view->pick('product/details');
        $this->getPageDetails('products', 'yes');
        $this->view->characteristics = $this->getNomenclatureGroupMembers('product-characteristics', 'array', false);
    
        $slug = $this->dispatcher->getParam('slug', 'string');
        $this->view->product = Product::getProduct($slug);
        
        if (!$this->view->product || $this->view->product->status != 'active') {
            $this->response->redirect($this->link->getLink('/products'));
            return;
        }
 
        $this->view->promotions = Promotion::getPromotionsArr();
        
        // filter characteristics
        $this->view->set = $this->getNomenclatureGroupMembers('what-s-in-the-box', 'array');
    
        $this->modifyPageMetaData($this->view->pageDetails, $this->view->product->getTranslatedResource());
        $this->modifyPageHeader($this->view->pageDetails, $this->view->product);
 
        $this->view->rentBenefit = $this->getText('short-rent-benefits');
 
        $this->view->cleancel = $this->getText('filter-tech-cleancel');
        $this->view->prefilter = $this->getText('filter-tech-prefilter');
        $this->view->carbon = $this->getText('filter-tech-carbon');
        $this->view->truehepa = $this->getText('filter-tech-truehepa');
        $this->view->plasmawave = $this->getText('filter-tech-plasmawave');
    
        $this->assets->addCss('/frontend/css/magnific-popup.min.css');
        
        $this->assets->addJs('/frontend/js/jquery.magnific-popup.min.js', true, false, ['async' => 'true', 'defer' => 'true']);
        $this->assets->addJs('/frontend/js/xzoom.min.js', true, false, []);
    }
    
    /**
     * Set custom meta tags, originating from entity ones
     * @param $pageDetails
     * @param $entity
     */
    public function modifyPageHeader(&$pageDetails, $entity)
    {
        if ($entity->headerImage) {
            $pageDetails->image = $entity->headerImage;
        }
    }
 
    /**
    * Add product for comparison
    */
    public function loadProductComparitionAction()
    {
        $this->view->disable();
        if ($this->request->isPost()) {
 
            // check if there are products in comparison list
            if ($this->session->has('productToCompare')) {
                $compared = $this->session->get('productToCompare');
                return json_encode(['result'=> true, 'count'=> count($compared), 'content'=> $this->renderCompareList($compared)]);
            }
            return json_encode(['result'=> false, 'count'=> 0, 'content'=> '']);
        }
    }
 
    /**
     * Add product for comparison
     */
    public function addProductAction()
    {
        $this->view->disable();
        if ($this->request->isPost()) {
            $productId = $this->request->getPost('productId');
 
            $compared = [];
            // check if there are products in comparison list
            if ($this->session->has('productToCompare')) {
                $compared = $this->session->get('productToCompare');
 
                if (count($compared) >= 3) {
                    return json_encode(['result'=> false, 'count'=> count($compared)+1, 'content'=> $this->translate->_('Limit to compare')]);
                }
            }
            
            // add current product in the comparison list
            if (!in_array($productId, $compared)) {
                $compared[] = $productId;
            }
            
            // write back the comparison list to session
            $this->session->set('productToCompare', $compared);
 
            return json_encode(['result'=> true, 'count'=> count($compared), 'content'=> $this->renderCompareList($compared)]);
        }
    }
    
    /**
     * Remove product from comparison
     */
    public function removeProductAction()
    {
        $this->view->disable();
        if ($this->request->isPost()) {
            $productId = $this->request->getPost('productId');
            $compared = [];
 
            if ($this->session->has('productToCompare')) {
                $compared = $this->session->get('productToCompare');
 
                if (($key = array_search($productId, $compared)) !== false) {
                    unset($compared[$key]);
                }
 
                $this->session->set('productToCompare', $compared);
            }
 
            if (count($compared)) {
                return json_encode(['result'=> true, 'count'=> count($compared), 'content'=> $this->renderCompareList($compared)]);
            } else {
                $this->session->remove('productToCompare');
            }
            return json_encode(['result'=> true, 'count'=> 0, 'content'=> '']);
        }
    }
 
    /**
     * Compare Selected products
     */
    public function compareSelectedAction()
    {
        $this->view->disable();
 
        if ($this->session->has('productToCompare')) {
            $compared = $this->session->get('productToCompare');
 
            $compareUrl = $this->link->getLink('/products');
            $compareUrl .= '?compare=' . implode('-', $compared);
 
            return json_encode(['result' => true, 'content' => $compareUrl]);
 
            // Getting a response instance
//            $response = new \Phalcon\Http\Response();
//            $this->response->redirect($compareUrl);
//            return;
 
//            foreach($compared as $product) {
//                $productResToAdd = Product::getProductById($product, $this->languages->getActiveLanguage());
//                $productToAdd = $productResToAdd->getProduct();
//            }
        }
 
        return json_encode(['result' => false, 'content' => $this->link->getLink('/products')]);
    }
 
    /**
     * Remove all products from comparison
     */
    public function removeAllAction()
    {
        $this->view->disable();
        if ($this->request->isPost()) {
            $this->session->remove('productToCompare');
            return json_encode(['result'=> true, 'count'=> 0, 'content'=> '']);
        }
    }
    
    /**
     * @param $compared
     * @return string
     */
    private function renderCompareList($compared)
    {
        $compareProductStr = '';
 
        // TODO: loop on compared products and add them in the return string
        foreach ($compared as $product) {
            $productResToAdd = Product::getProductById($product, $this->languages->getActiveLanguage());
            $productToAdd = $productResToAdd->getProduct();
            $productImages = $productToAdd->getImage();
 
            $compareProductStr .= '<div class="col-md-4">';
            $compareProductStr .= '<div class="row">';
            $compareProductStr .= '<div class="col-5 vertical-center">';
            
            if (!empty($productImages)) {
                $compareProductStr .= '<img class="img-fluid" src="' . $productImages[0]->filename . '">';
            }
            
            $compareProductStr .= '</div>';
            $compareProductStr .= '<div class="col-7 vertical-center justify-mobile">';
            $compareProductStr .= '<span class="pull-left">' . $productResToAdd->title . '</span>';
            $compareProductStr .= ' <a href="javascript:;" onclick="removeCompared(' . $productToAdd->productId .')" class="pull-right remove-product-from-compare">';
            $compareProductStr .= '<span class="remove">X</span>';
            $compareProductStr .= '</a>';
            $compareProductStr .= '</div>';
            $compareProductStr .= '</div>';
            $compareProductStr .= '</div>';
        }
 
 
        return $compareProductStr;
    }
 
    /**
     *
     */
    public function promotionsAction()
    {
        $this->getPageDetails('promotions', '');
 
        $this->view->promotions = Promotion::getPromotionsArr();
        $this->view->products = Promotion::getProductsInPromotions();
        $this->view->characteristics = $this->getNomenclatureGroupMembers('product-characteristics', 'array', false);
        $this->view->categories = $this->getNomenclatureGroupMembers('product-category', 'array', false);
    }
}
#1Multiple\Www\Controllers\ProductController->indexAction(aerus, bg)
#2Phalcon\Dispatcher\AbstractDispatcher->callActionMethod(Object(Multiple\Www\Controllers\ProductController), indexAction, Array([brand] => aerus, [language] => bg))
#3Phalcon\Dispatcher\AbstractDispatcher->dispatch()
#4Phalcon\Mvc\Application->handle(/bg/aerus-products)
/home/clearair/public_html/public/index.php (119)
<?php
/**
 * App env start
 */
$appEnv = 'dev';
if (isset($_SERVER['APPLICATION_ENV'])) {
    $appEnv = $_SERVER['APPLICATION_ENV'];
} elseif (getenv('APPLICATION_ENV')) {
    $appEnv = getenv(['APPLICATION_ENV']);
} elseif (ini_get('APPLICATION_ENV')) {
    $appEnv = ini_get('APPLICATION_ENV');
}
 
defined('APPLICATION_ENV') || define('APPLICATION_ENV', $appEnv);
$appEnv == "production" ? "production" : "preproduction";
 
if ($appEnv == 'production') {
    ini_set('display_errors', 'off');
    ini_set('display_startup_errors', 'off');
} else {
    ini_set('display_errors', 'on');
    ini_set('display_startup_errors', 'on');
    
    error_reporting(E_ALL);
    
    // Use Phalcon debug mechanism
    $debug = new \Phalcon\Debug();
    $debug->listen();
}
/**
 * App env end;
 */
 
require "../config/helpers.php";
 
if (is_file("../config/config.php")) {
    require "../config/config.php";
}
 
if (is_file("../config/language.php")) {
    require "../config/language.php";
} else {
    // fallback
    $languageSettings = [
        'defaultLanguage' => 'en',
        'languages' => ['active' => ['en']],
        'domainLanguages' => [$_SERVER['SERVER_NAME'] => ['active' => ['en']]],
    ];
}
 
if (is_file("../vendor/autoload.php")) {
    require "../vendor/autoload.php";
}
 
use Phalcon\Dispatcher\Exception;
use Phalcon\Mvc\Dispatcher;
 
/**
 * Class Application
 */
class Application extends \Phalcon\Mvc\Application
{
    protected $environment;
    
    protected $globalSettings;
    
    protected $languageSettings;
    
    protected $services;
    
    /**
     * Application constructor.
     * Additional settings may be added to constructor, included at the top of this file and added to initial call
     * Example of usage of such settings may be seein in base/config/services.php, commented lines about customSettings
     * @param array $settings
     */
    public function __construct($environment, $settings = [], $languageSettings = [])
    {
        $this->environment = $environment;
        $this->globalSettings = array_merge($settings, $languageSettings);
    }
    
    public function main()
    {
        $this->_registerServices();
        
        //Register the installed modules
        $this->registerModules(
            array(
                'www' => array(
                    'className' => 'Multiple\Www\Module',
                    'path' => '../apps/www/Module.php',
                    'name' => 'WWW'
                ),
                'admin' => array(
                    'className' => 'Multiple\Admin\Module',
                    'path' => '../apps/admin/Module.php',
                    'name' => 'Admin'
                ),
                'base' => array(
                    'className' => 'Multiple\Base\Module',
                    'path' => '../apps/base/Module.php',
                    'name' => 'Base'
                ),
                'client' => array(
                    'className' => 'Multiple\Client\Module',
                    'path' => '../apps/client/Module.php',
                    'name' => 'Client'
                ),
                'api' => array(
                    'className' => 'Multiple\Api\Module',
                    'path' => '../apps/api/Module.php',
                    'name' => 'Api'
                )
            )
        );
        
        try {
            echo $this->handle($this->request->getURI())->getContent();
        } catch (\Exception $e) {
            if ($this->environment != 'production') {
                dd($e);
            }
        }
    }
    
    /**
     * Register the services here to make them general
     */
    protected function _registerServices()
    {
        $di = new \Phalcon\DI\FactoryDefault();
        
        $loader = new \Phalcon\Loader();
        
        /**
         * We're registering a set of directories
         */
        $loader->registerDirs(
            array(
                __DIR__ . '/../core/service',
                __DIR__ . '/../core/facade',
                __DIR__ . '/../core/entity',
                __DIR__ . '/../vendor',
            )
        )->register();
    
        $loader->registerNamespaces(
            array(
                'Decorators' => '../apps/library/decorators/',
                'Entity' => '../core/entity/',
                'Core\Facade' => '../core/facade/',
                'Core\Service' => '../core/service/',
                'Core\Helper' => '../core/helper/',
                'Multiple\Base\Models' => '../apps/base/models/',
            )
        );
    
        $loader->register();
        
        require '../apps/base/config/services.php';
        
        
        //Registering a router
        $di->set(
            'router',
            function () use ($di) {
                $router = new \Phalcon\Mvc\Router();
                $router->removeExtraSlashes(true);
                /*Import module specific routes*/
                
                // get active languages
                foreach ($di['config']['languages']['active'] as $lang) {
                    if (file_exists('../apps/www/config/routes.' . $lang . '.php')) {
                        require '../apps/www/config/routes.' . $lang . '.php';
                    }
                }
                // then get inactive languages
                foreach ($di['config']['languages']['inactive'] as $lang) {
                    if (file_exists('../apps/www/config/routes.' . $lang . '.php')) {
                        require '../apps/www/config/routes.' . $lang . '.php';
                    }
                }
    
    
                require '../apps/api/config/routes.php';
                require '../apps/admin/config/routes.php';
                require '../apps/client/config/routes.php';
                
                return $router;
            }
        );
    
        //Registering the view component
        $di->set(
            'view',
            function () {
                $view = new \Phalcon\Mvc\View();
                $view->setViewsDir('../apps/www/views/');
                $view->setPartialsDir("partials/");
                $view->setLayoutsDir("layouts/");
                $view->setLayout("default");
                return $view;
            }
        );
    
        $response = $this->response;
        $module = $this->_getModule();
    
        //Registering a dispatcher
        $di->set(
            'dispatcher',
            function () use ($module, $response, $di) {
                $dispatcher = new \Phalcon\Mvc\Dispatcher();
            
                //Attach a event listener to the dispatcher
                $eventManager = new \Phalcon\Events\Manager();
            
                $activeLanguage = $di['config']['languages'][0];
                if (isset($_COOKIE['activeLanguage' . ucfirst($module)]) && $_COOKIE['activeLanguage' . ucfirst($module)]) {
                    $activeLanguage = $_COOKIE['activeLanguage' . ucfirst($module)];
                }
            
                //if($di['config']['env'] == 'production') {
               /* $eventManager->attach(
                    "dispatch:beforeException",
                    function ($event, $dispatcher, $exception) use ($response, $module, $activeLanguage) {
                        switch ($exception->getCode()) {
                            case Exception::EXCEPTION_CYCLIC_ROUTING:
                            case Exception::EXCEPTION_HANDLER_NOT_FOUND:
                            case Exception::EXCEPTION_INVALID_HANDLER:
                            case Exception::EXCEPTION_ACTION_NOT_FOUND:
                                $response->redirect('../' . $activeLanguage  . '/error/404');
                                return false;
                                break;
                            default:
                                $response->redirect('../' . $activeLanguage  . '/error/404');
                                return false;
                                break;
                        }
                    }
                );*/
                //}
            
                $dispatcher->setEventsManager($eventManager);
                $dispatcher->setDefaultNamespace("Multiple\Www\Controllers\\");
                return $dispatcher;
            }
        );
        
        $this->setDI($di);
    }
    
    /**
     * @return mixed
     */
    private function _getModule()
    {
        $module = '';
        if (isset($this->request->getQuery()['_url'])) {
            $module = explode('/', $this->request->getQuery()['_url']);
        }
        return isset($module[1]) && $module[1] != 'error' ? $module[1] : 'www';
    }
    
    /**
     * Does a HMVC request inside the application
     *
     * Inside a controller we might do
     * <code>
     * $this->app->request([ 'controller' => 'do', 'action' => 'something' ], 'param');
     * </code>
     *
     * @param array $location Array with the route information: 'namespace', 'module', 'controller', 'action', 'params'
     * @return mixed
     */
    public function request(array $location)
    {
        
        /** @var \Phalcon\Mvc\Dispatcher $dispatcher */
        $dispatcher = clone $this->di->get('dispatcher');
        
        if (isset($location['module'])) {
            $dispatcher->setModuleName($location['module']);
        }
        
        if (isset($location['namespace'])) {
            $dispatcher->setNamespaceName($location['namespace']);
        }
        
        if (!isset($location['controller'])) {
            $location['controller'] = 'index';
        }
        
        if (!isset($location['action'])) {
            $location['action'] = 'index';
        }
        
        if (!isset($location['params'])) {
            $location['params'] = [];
        }
        
        $dispatcher->setControllerName($location['controller']);
        $dispatcher->setActionName($location['action']);
        $dispatcher->setParams((array)$location['params']);
        $dispatcher->dispatch();
        
        $response = $dispatcher->getReturnedValue();
        
        if ($response instanceof ResponseInterface) {
            return $response->getContent();
        }
        
        return $response;
    }
}
 
//init and load application
// Note: additional settings may be added. See instructions in constructor
$application = new Application($appEnv, $globalSettings, $languageSettings);
$application->main();
#5Application->main()
/home/clearair/public_html/public/index.php (321)
<?php
/**
 * App env start
 */
$appEnv = 'dev';
if (isset($_SERVER['APPLICATION_ENV'])) {
    $appEnv = $_SERVER['APPLICATION_ENV'];
} elseif (getenv('APPLICATION_ENV')) {
    $appEnv = getenv(['APPLICATION_ENV']);
} elseif (ini_get('APPLICATION_ENV')) {
    $appEnv = ini_get('APPLICATION_ENV');
}
 
defined('APPLICATION_ENV') || define('APPLICATION_ENV', $appEnv);
$appEnv == "production" ? "production" : "preproduction";
 
if ($appEnv == 'production') {
    ini_set('display_errors', 'off');
    ini_set('display_startup_errors', 'off');
} else {
    ini_set('display_errors', 'on');
    ini_set('display_startup_errors', 'on');
    
    error_reporting(E_ALL);
    
    // Use Phalcon debug mechanism
    $debug = new \Phalcon\Debug();
    $debug->listen();
}
/**
 * App env end;
 */
 
require "../config/helpers.php";
 
if (is_file("../config/config.php")) {
    require "../config/config.php";
}
 
if (is_file("../config/language.php")) {
    require "../config/language.php";
} else {
    // fallback
    $languageSettings = [
        'defaultLanguage' => 'en',
        'languages' => ['active' => ['en']],
        'domainLanguages' => [$_SERVER['SERVER_NAME'] => ['active' => ['en']]],
    ];
}
 
if (is_file("../vendor/autoload.php")) {
    require "../vendor/autoload.php";
}
 
use Phalcon\Dispatcher\Exception;
use Phalcon\Mvc\Dispatcher;
 
/**
 * Class Application
 */
class Application extends \Phalcon\Mvc\Application
{
    protected $environment;
    
    protected $globalSettings;
    
    protected $languageSettings;
    
    protected $services;
    
    /**
     * Application constructor.
     * Additional settings may be added to constructor, included at the top of this file and added to initial call
     * Example of usage of such settings may be seein in base/config/services.php, commented lines about customSettings
     * @param array $settings
     */
    public function __construct($environment, $settings = [], $languageSettings = [])
    {
        $this->environment = $environment;
        $this->globalSettings = array_merge($settings, $languageSettings);
    }
    
    public function main()
    {
        $this->_registerServices();
        
        //Register the installed modules
        $this->registerModules(
            array(
                'www' => array(
                    'className' => 'Multiple\Www\Module',
                    'path' => '../apps/www/Module.php',
                    'name' => 'WWW'
                ),
                'admin' => array(
                    'className' => 'Multiple\Admin\Module',
                    'path' => '../apps/admin/Module.php',
                    'name' => 'Admin'
                ),
                'base' => array(
                    'className' => 'Multiple\Base\Module',
                    'path' => '../apps/base/Module.php',
                    'name' => 'Base'
                ),
                'client' => array(
                    'className' => 'Multiple\Client\Module',
                    'path' => '../apps/client/Module.php',
                    'name' => 'Client'
                ),
                'api' => array(
                    'className' => 'Multiple\Api\Module',
                    'path' => '../apps/api/Module.php',
                    'name' => 'Api'
                )
            )
        );
        
        try {
            echo $this->handle($this->request->getURI())->getContent();
        } catch (\Exception $e) {
            if ($this->environment != 'production') {
                dd($e);
            }
        }
    }
    
    /**
     * Register the services here to make them general
     */
    protected function _registerServices()
    {
        $di = new \Phalcon\DI\FactoryDefault();
        
        $loader = new \Phalcon\Loader();
        
        /**
         * We're registering a set of directories
         */
        $loader->registerDirs(
            array(
                __DIR__ . '/../core/service',
                __DIR__ . '/../core/facade',
                __DIR__ . '/../core/entity',
                __DIR__ . '/../vendor',
            )
        )->register();
    
        $loader->registerNamespaces(
            array(
                'Decorators' => '../apps/library/decorators/',
                'Entity' => '../core/entity/',
                'Core\Facade' => '../core/facade/',
                'Core\Service' => '../core/service/',
                'Core\Helper' => '../core/helper/',
                'Multiple\Base\Models' => '../apps/base/models/',
            )
        );
    
        $loader->register();
        
        require '../apps/base/config/services.php';
        
        
        //Registering a router
        $di->set(
            'router',
            function () use ($di) {
                $router = new \Phalcon\Mvc\Router();
                $router->removeExtraSlashes(true);
                /*Import module specific routes*/
                
                // get active languages
                foreach ($di['config']['languages']['active'] as $lang) {
                    if (file_exists('../apps/www/config/routes.' . $lang . '.php')) {
                        require '../apps/www/config/routes.' . $lang . '.php';
                    }
                }
                // then get inactive languages
                foreach ($di['config']['languages']['inactive'] as $lang) {
                    if (file_exists('../apps/www/config/routes.' . $lang . '.php')) {
                        require '../apps/www/config/routes.' . $lang . '.php';
                    }
                }
    
    
                require '../apps/api/config/routes.php';
                require '../apps/admin/config/routes.php';
                require '../apps/client/config/routes.php';
                
                return $router;
            }
        );
    
        //Registering the view component
        $di->set(
            'view',
            function () {
                $view = new \Phalcon\Mvc\View();
                $view->setViewsDir('../apps/www/views/');
                $view->setPartialsDir("partials/");
                $view->setLayoutsDir("layouts/");
                $view->setLayout("default");
                return $view;
            }
        );
    
        $response = $this->response;
        $module = $this->_getModule();
    
        //Registering a dispatcher
        $di->set(
            'dispatcher',
            function () use ($module, $response, $di) {
                $dispatcher = new \Phalcon\Mvc\Dispatcher();
            
                //Attach a event listener to the dispatcher
                $eventManager = new \Phalcon\Events\Manager();
            
                $activeLanguage = $di['config']['languages'][0];
                if (isset($_COOKIE['activeLanguage' . ucfirst($module)]) && $_COOKIE['activeLanguage' . ucfirst($module)]) {
                    $activeLanguage = $_COOKIE['activeLanguage' . ucfirst($module)];
                }
            
                //if($di['config']['env'] == 'production') {
               /* $eventManager->attach(
                    "dispatch:beforeException",
                    function ($event, $dispatcher, $exception) use ($response, $module, $activeLanguage) {
                        switch ($exception->getCode()) {
                            case Exception::EXCEPTION_CYCLIC_ROUTING:
                            case Exception::EXCEPTION_HANDLER_NOT_FOUND:
                            case Exception::EXCEPTION_INVALID_HANDLER:
                            case Exception::EXCEPTION_ACTION_NOT_FOUND:
                                $response->redirect('../' . $activeLanguage  . '/error/404');
                                return false;
                                break;
                            default:
                                $response->redirect('../' . $activeLanguage  . '/error/404');
                                return false;
                                break;
                        }
                    }
                );*/
                //}
            
                $dispatcher->setEventsManager($eventManager);
                $dispatcher->setDefaultNamespace("Multiple\Www\Controllers\\");
                return $dispatcher;
            }
        );
        
        $this->setDI($di);
    }
    
    /**
     * @return mixed
     */
    private function _getModule()
    {
        $module = '';
        if (isset($this->request->getQuery()['_url'])) {
            $module = explode('/', $this->request->getQuery()['_url']);
        }
        return isset($module[1]) && $module[1] != 'error' ? $module[1] : 'www';
    }
    
    /**
     * Does a HMVC request inside the application
     *
     * Inside a controller we might do
     * <code>
     * $this->app->request([ 'controller' => 'do', 'action' => 'something' ], 'param');
     * </code>
     *
     * @param array $location Array with the route information: 'namespace', 'module', 'controller', 'action', 'params'
     * @return mixed
     */
    public function request(array $location)
    {
        
        /** @var \Phalcon\Mvc\Dispatcher $dispatcher */
        $dispatcher = clone $this->di->get('dispatcher');
        
        if (isset($location['module'])) {
            $dispatcher->setModuleName($location['module']);
        }
        
        if (isset($location['namespace'])) {
            $dispatcher->setNamespaceName($location['namespace']);
        }
        
        if (!isset($location['controller'])) {
            $location['controller'] = 'index';
        }
        
        if (!isset($location['action'])) {
            $location['action'] = 'index';
        }
        
        if (!isset($location['params'])) {
            $location['params'] = [];
        }
        
        $dispatcher->setControllerName($location['controller']);
        $dispatcher->setActionName($location['action']);
        $dispatcher->setParams((array)$location['params']);
        $dispatcher->dispatch();
        
        $response = $dispatcher->getReturnedValue();
        
        if ($response instanceof ResponseInterface) {
            return $response->getContent();
        }
        
        return $response;
    }
}
 
//init and load application
// Note: additional settings may be added. See instructions in constructor
$application = new Application($appEnv, $globalSettings, $languageSettings);
$application->main();
KeyValue
_url/bg/aerus-products
KeyValue
TZEurope/Sofia
PHP_INI_SCAN_DIR/home/clearair/.sh.phpmanager/php74.d
PWD/home/clearair
SHLVL0
PATH/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin
HTTP_CONNECTIONclose
SCRIPT_NAME/public/index.php
REQUEST_URI/bg/aerus-products
QUERY_STRING_url=/bg/aerus-products
REQUEST_METHODGET
SERVER_PROTOCOLHTTP/2.0
GATEWAY_INTERFACECGI/1.1
REDIRECT_QUERY_STRING_url=/bg/aerus-products
REDIRECT_URL/public/bg/aerus-products
REMOTE_PORT56482
SCRIPT_FILENAME/home/clearair/public_html/public/index.php
SERVER_ADMINwebmaster@clearair.bg
CONTEXT_DOCUMENT_ROOT/home/clearair/public_html
CONTEXT_PREFIX
REQUEST_SCHEMEhttps
DOCUMENT_ROOT/home/clearair/public_html
REMOTE_ADDR18.97.9.175
SERVER_PORT443
SERVER_ADDR185.45.67.120
SERVER_NAMEclearair.bg
SERVER_SOFTWAREApache
SERVER_SIGNATURE
HTTP_X_HTTPS1
HTTP_HOSTclearair.bg
HTTP_ACCEPT_ENCODINGzstd, br, gzip
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
H2_STREAM_TAG3917467-2647-3
H2_STREAM_ID3
H2_PUSHED_ON
H2_PUSHED
H2_PUSHon
H2PUSHon
HTTP2on
SSL_TLS_SNIclearair.bg
HTTPSon
APPLICATION_ENVdevelopment
SH_COMPANY_ORIGINsuperhosting.bg
SCRIPT_URIhttps://clearair.bg/bg/aerus-products
SCRIPT_URL/bg/aerus-products
UNIQUE_IDaoT1wGl41UN6-PhbR4MekQACTgo
REDIRECT_STATUS200
REDIRECT_H2_STREAM_TAG3917467-2647-3
REDIRECT_H2_STREAM_ID3
REDIRECT_H2_PUSHED_ON
REDIRECT_H2_PUSHED
REDIRECT_H2_PUSHon
REDIRECT_H2PUSHon
REDIRECT_HTTP2on
REDIRECT_SSL_TLS_SNIclearair.bg
REDIRECT_HTTPSon
REDIRECT_APPLICATION_ENVdevelopment
REDIRECT_SH_COMPANY_ORIGINsuperhosting.bg
REDIRECT_SCRIPT_URIhttps://clearair.bg/bg/aerus-products
REDIRECT_SCRIPT_URL/bg/aerus-products
REDIRECT_UNIQUE_IDaoT1wGl41UN6-PhbR4MekQACTgo
REDIRECT_REDIRECT_STATUS200
REDIRECT_REDIRECT_H2_STREAM_TAG3917467-2647-3
REDIRECT_REDIRECT_H2_STREAM_ID3
REDIRECT_REDIRECT_H2_PUSHED_ON
REDIRECT_REDIRECT_H2_PUSHED
REDIRECT_REDIRECT_H2_PUSHon
REDIRECT_REDIRECT_H2PUSHon
REDIRECT_REDIRECT_HTTP2on
REDIRECT_REDIRECT_SSL_TLS_SNIclearair.bg
REDIRECT_REDIRECT_HTTPSon
REDIRECT_REDIRECT_SH_COMPANY_ORIGINsuperhosting.bg
REDIRECT_REDIRECT_SCRIPT_URIhttps://clearair.bg/bg/aerus-products
REDIRECT_REDIRECT_SCRIPT_URL/bg/aerus-products
REDIRECT_REDIRECT_UNIQUE_IDaoT1wGl41UN6-PhbR4MekQACTgo
FCGI_ROLERESPONDER
PHP_SELF/public/index.php
REQUEST_TIME_FLOAT1787098560.4425
REQUEST_TIME1787098560
argvArray([0] => _url=/bg/aerus-products)
argc1
#Path
0/home/clearair/public_html/public/index.php
1/home/clearair/public_html/config/helpers.php
2/home/clearair/public_html/config/config.php
3/home/clearair/public_html/config/language.php
4/home/clearair/public_html/vendor/autoload.php
5/home/clearair/public_html/vendor/composer/autoload_real.php
6/home/clearair/public_html/vendor/composer/platform_check.php
7/home/clearair/public_html/vendor/composer/ClassLoader.php
8/home/clearair/public_html/vendor/composer/autoload_static.php
9/home/clearair/public_html/vendor/symfony/polyfill-php80/bootstrap.php
10/home/clearair/public_html/vendor/symfony/deprecation-contracts/function.php
11/home/clearair/public_html/vendor/symfony/polyfill-ctype/bootstrap.php
12/home/clearair/public_html/vendor/symfony/polyfill-mbstring/bootstrap.php
13/home/clearair/public_html/vendor/symfony/polyfill-php81/bootstrap.php
14/home/clearair/public_html/vendor/symfony/polyfill-php73/bootstrap.php
15/home/clearair/public_html/vendor/cakephp/core/functions.php
16/home/clearair/public_html/vendor/cakephp/collection/functions.php
17/home/clearair/public_html/vendor/cakephp/utility/bootstrap.php
18/home/clearair/public_html/vendor/cakephp/utility/Inflector.php
19/home/clearair/public_html/vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php
20/home/clearair/public_html/apps/base/config/services.php
21/home/clearair/public_html/apps/www/config/routes.bg.php
22/home/clearair/public_html/apps/www/config/routes.en.php
23/home/clearair/public_html/apps/api/config/routes.php
24/home/clearair/public_html/apps/admin/config/routes.php
25/home/clearair/public_html/apps/client/config/routes.php
26/home/clearair/public_html/apps/www/Module.php
27/home/clearair/public_html/vendor/webolie/core/Service/LanguageService.php
28/home/clearair/public_html/apps/base/models/IpToLocation.php
29/home/clearair/public_html/apps/www/controllers/ProductController.php
30/home/clearair/public_html/apps/www/controllers/ControllerBase.php
31/home/clearair/public_html/vendor/webolie/core/Traits/TextAwareTrait.php
32/home/clearair/public_html/vendor/webolie/core/Traits/NomenclatureAwareTrait.php
33/home/clearair/public_html/vendor/webolie/core/Service/RedirectService.php
34/home/clearair/public_html/apps/base/models/Redirect.php
35/home/clearair/public_html/apps/base/models/ModelBase.php
36/home/clearair/public_html/apps/www/forms/ContactMessageForm.php
37/home/clearair/public_html/vendor/webolie/form/AbstractForm.php
38/home/clearair/public_html/vendor/webolie/form/Decorator/Form.php
39/home/clearair/public_html/vendor/webolie/form/Element/CustomHtml.php
40/home/clearair/public_html/vendor/webolie/form/Validator/StringLength.php
41/home/clearair/public_html/apps/www/messages/lang.bg.php
42/home/clearair/public_html/vendor/webolie/core/Helper/TranslationHelper.php
43/home/clearair/public_html/vendor/webolie/core/Traits/DiAwareTrait.php
44/home/clearair/public_html/vendor/webolie/form/Validator/Email.php
45/home/clearair/public_html/apps/base/models/Label.php
46/home/clearair/public_html/vendor/webolie/form/Element/CheckSet.php
47/home/clearair/public_html/vendor/webolie/form/Element/Select.php
48/home/clearair/public_html/apps/base/models/Nomenclature.php
49/home/clearair/public_html/apps/base/models/NomenclatureResource.php
50/home/clearair/public_html/apps/base/models/Product.php
51/home/clearair/public_html/vendor/webolie/gridview/Traits/CurrencyAwareTrait.php
52/home/clearair/public_html/apps/base/models/ProductResource.php
53/home/clearair/public_html/apps/www/config/seo_settings.php
54/home/clearair/public_html/apps/www/config/settings.php
55/home/clearair/public_html/apps/client/plugins/Acl.php
56/home/clearair/public_html/apps/base/models/Promotion.php
57/home/clearair/public_html/apps/base/models/Page.php
58/home/clearair/public_html/apps/base/models/PageResource.php
Memory
Usage4194304