%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/bbw/farmaci/kritik-portale/
Upload File :
Create Path :
Current File : /var/www/html/bbw/farmaci/kritik-portale/Kripo.php

<?php

use ConLayout\Service\BlocksBuilder;
use ConLayout\Service\LayoutService;
use Zend\Mvc\Application;
use Zend\Mvc\MvcEvent;
use Zend\View\Model\ModelInterface;
use Zend\View\Model\ViewModel;

chdir(__DIR__);

require __DIR__ . '/init_autoloader.php';

class Kripo
{
    protected static $app;
    
    protected static $layout;
    
    public static function app()
    {
        if (null === self::$app) {
            switch(getenv('APPLICATION_ENV')) {
                case 'development':
                    $config = require 'config/application.dev.config.php';
                    break;
                case 'production':
                default:
                    $config = require 'config/application.config.php';
                    break;
            }

            self::$app = Application::init($config);     
        }
        return self::$app;
    }
    
    public static function renderBlock($blockName)
    {
        $block = self::loadLayout()->getBlock($blockName);
        $phpRenderer = self::app()->getServiceManager()
            ->get('ViewManager')
            ->getRenderer();        
        /* @var $blocksBuilder BlocksBuilder */
        if (!$block instanceof ModelInterface) {
            return '';
        }

        if ($block->hasChildren()) {
            foreach ($block->getChildren() as $child) {
                $child->setOption('has_parent', true);
                $result  = $phpRenderer->render($child);
                $child->setOption('has_parent', null);
                $capture = $child->captureTo();
                if (!empty($capture)) {
                    if ($child->isAppend()) {
                        $oldResult=$block->{$capture};
                        $block->setVariable($capture, $oldResult . $result);
                    } else {
                        $block->setVariable($capture, $result);
                    }
                }
            }
        }
        return $phpRenderer->render($block);        
    }
    
    public static function basePath($path = '/')
    {
        $helper = self::app()->getServiceManager()
            ->get('ViewHelperManager')
            ->get('basePath');
        $helper->setBasePath($path);        
    }
    
    public static function renderHelper($name)
    {
        $helper = self::app()->getServiceManager()
            ->get('ViewHelperManager')
            ->get($name);        
        return (string) $helper;
    }
    
    public static function loadLayout(array $handles = [])
    {
        if (null === self::$layout) {            
            $sm = self::app()->getServiceManager();        
            $blocksBuilder = $sm->get('ConLayout\Service\BlocksBuilder');
            /* @var $layoutService LayoutService */
            $layoutService = $sm->get('ConLayout\Service\LayoutService');
            $layoutService->addHandle($handles);
            
            $mvcEvent = new MvcEvent();
            $mvcEvent->setViewModel(new ViewModel());
            
            $layoutModifierListener = $sm->get('ConLayout\Listener\LayoutModifierListener');
            $layoutModifierListener->applyHelpers($mvcEvent);
            $layoutModifierListener->addBlocksToLayout($mvcEvent);
            
            self::$layout = $blocksBuilder;
        }
        return self::$layout;
    }
}

Zerion Mini Shell 1.0