Phalcon Framework 1.3.4

MongoConnectionException: Failed to connect to: localhost:27017: Connection refused

/home/vegas/www/app/services/MongoServiceProvider.php (49)
#0MongoClient->__construct(mongodb://localhost, Array())
<?php
/**
 * This file is part of Vegas package
 *
 * @author Slawomir Zytko <slawomir.zytko@gmail.com>
 * @copyright Amsterdam Standard Sp. Z o.o.
 * @homepage http://vegas-cmf.github.io
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
use Phalcon\DiInterface;
use Vegas\DI\ServiceProviderInterface;
 
class MongoServiceProvider implements ServiceProviderInterface
{
    const SERVICE_NAME = 'mongo';
 
    /**
     * {@inheritdoc}
     * @see http://docs.phalconphp.com/pl/latest/reference/odm.html
     */
    public function register(DiInterface $di)
    {
        $di->set(self::SERVICE_NAME, function() use ($di) {
            $mongoConfig = $di->get('config')->mongo->toArray();
 
            if (isset($mongoConfig['dsn'])) {
                $hostname = $mongoConfig['dsn'];
                unset($mongoConfig['dsn']);
            } else {
                //obtains hostname
                if (isset($mongoConfig['host'])) {
                    $hostname = 'mongodb://' . $mongoConfig['host'];
                } else {
                    $hostname = 'mongodb://localhost';
                }
                if (isset($mongoConfig['port'])) {
                    $hostname .= ':' . $mongoConfig['port'];
                }
                //removes options that are not allowed in MongoClient constructor
                unset($mongoConfig['host']);
                unset($mongoConfig['port']);
            }
            $dbName = $mongoConfig['dbname'];
            unset($mongoConfig['dbname']);
 
            $mongo = new \MongoClient($hostname, $mongoConfig);
            return $mongo->selectDb($dbName);
        }, true);
    }
 
    /**
     * {@inheritdoc}
     */
    public function getDependencies()
    {
        return array(
            CollectionManagerServiceProvider::SERVICE_NAME
        );
    }
} 
#1MongoServiceProvider->{closure}()
#2Phalcon\DI\Service->resolve(null, Object(Phalcon\DI\FactoryDefault))
#3Phalcon\DI->getShared(mongo)
#4Phalcon\Mvc\Collection\Manager->getConnection(Object(Project\Models\Project))
#5Phalcon\Mvc\Collection->getConnection()
#6Phalcon\Mvc\Collection::find(Array([sort] => Array([contributions] => -1)))
<?php
/**
 * This file is part of Vegas package
 *
 * @author Jaroslaw <Macko>
 * @copyright Amsterdam Standard Sp. Z o.o.
 * @homepage http://vegas-cmf.github.io
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace Project\Services;
 
use Project\Models\Project;
use Vegas\DI\Service\ComponentAbstract;
 
class Gallery extends ComponentAbstract
{
    /**
     * Setups component
     *
     * @param array $params
     * @return mixed
     */
    protected function setUp($params = [])
    {
        return [
            'projects' => Project::find(['sort' => ['contributions' => -1]])
        ];
    }
}
#7Project\Services\Gallery->setUp(Array())
<?php
/**
 * This file is part of Vegas package
 *
 * @author Arkadiusz Ostrycharz <aostrycharz@amsterdam-standard.pl>
 * @copyright Amsterdam Standard Sp. Z o.o.
 * @homepage http://vegas-cmf.github.io
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Vegas\DI\Service;
 
use Phalcon\DI\InjectionAwareInterface;
use Vegas\DI\InjectionAwareTrait;
 
/**
 * Class ComponentAbstract
 * @package Vegas\DI\Service
 */
abstract class ComponentAbstract implements ComponentInterface, InjectionAwareInterface
{
    use InjectionAwareTrait;
 
    /**
     * Renderer instance
     *
     * @var
     */
    protected $renderer;
 
    /**
     * Name of module
     *
     * @var
     */
    protected $moduleName;
 
    /**
     * Name of template to render
     *
     * @var
     */
    protected $templateName;
 
    /**
     * Setups component
     *
     * @param array $params
     * @return mixed
     */
    abstract protected function setUp($params = array());
 
    /**
     * {@inheritdoc}
     */
    public function __construct(Component\RendererInterface $renderer = null)
    {
        if ($renderer) {
            $this->setRenderer($renderer);
        }
    }
 
    /**
     * {@inheritdoc}
     */
    public function getRenderer()
    {
        if (empty($this->renderer)) {
            $this->setRenderer(new Component\Renderer($this->di->get('view')));
        }
        
        return $this->renderer;
    }
 
    /**
     * {@inheritdoc}
     */
    public function setRenderer(Component\RendererInterface $renderer)
    {
        $nameArray = explode('\\',get_called_class());
        
        $moduleName = $nameArray[0];
        $templateName = lcfirst($nameArray[count($nameArray)-1]);
 
        $this->renderer = $renderer;
        $this->renderer->setModuleName($moduleName);
        $this->renderer->setTemplateName($templateName);
        
        return $this;
    }
 
    /**
     * {@inheritdoc}
     */
    public function render($params = array())
    {
        $params = $this->setUp($params);
        
        return $this->getRenderer()->render($params);
    }
 
}
#8Vegas\DI\Service\ComponentAbstract->render()
<div class="col-lg-12" id="box-docs">
    <div class="jumbotron">
        <h2 class="col-xs-6">
            <a href="https://vegas-cmf.github.io" target="_blank">
                <i class="fa fa-graduation-cap"></i> <?php echo $this->i18n->_('read the docs'); ?>
            </a>
        </h2>
        <h2 class="col-xs-6">
            <a href="https://github.com/vegas-cmf" target="_blank">
                <i class="fa fa-github"></i> <?php echo $this->i18n->_('check our github'); ?>
            </a>
        </h2>
        <div class="clearfix"></div>
    </div>
</div>
 
<div class="col-lg-12" id="box-tweets">
    <div class="inner cover">
        <h2>@VegasCMF</h2>
        <a class="twitter-timeline" href="https://twitter.com/VegasCMF" data-widget-id="542687318176698369">@VegasCMF</a>
        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
    </div>
</div>
 
<div class="col-lg-12" id="box-contact">
    <div class="row">
        <div class="col-lg-6">
            <div class="inner cover">
                <h2><?php echo $this->i18n->_('Projects'); ?></h2>
                <?php echo $this->serviceManager->get('project:gallery')->render(); ?>
            </div>
        </div>
        <div class="col-lg-6">
            <div class="inner cover">
                <h2><?php echo $this->i18n->_('Contact us'); ?></h2>
                <form action="<?php echo $this->url->get(array('for' => 'contact')); ?>" class="form-horizontal">
                    <div class="form-group">
                        <div class="col-lg-6">
                            <?php echo $contactForm->get('name'); ?>
                        </div>
                        <div class="col-lg-6">
                            <?php echo $contactForm->get('email'); ?>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-12">
                            <?php echo $contactForm->get('content'); ?>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-lg-10">
                            <p class="lead">
                                <?php echo $this->i18n->_('Keep calm and send us some nice message!'); ?>
                            </p>
                        </div>
                        <div class="col-lg-2">
                            <?php echo $contactToken->render(); ?>
                            <button data-loading-text="<?php echo $this->i18n->_('Sending...'); ?>" class="btn btn-primary pull-right" type="submit"><?php echo $this->i18n->_('Send'); ?></button>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
 
<div class="col-lg-12" id="box-contact">
    <div class="inner cover">
        <h2><?php echo $this->i18n->_('Our brave contributors'); ?></h2>
        <?php echo $this->serviceManager->get('contributor:gitHub')->render(); ?>
    </div>
</div>
#9Phalcon\Mvc\View\Engine\Volt->render(/home/vegas/www/app/modules/Home/views/home/index.volt, Array([contactForm] => Object(Home\Forms\Contact), [contactToken] => Object(Vegas\Forms\Element\Hidden)), true)
<?php
/**
 * This file is part of Vegas package
 *
 * @author Arkadiusz Ostrycharz <aostrycharz@amsterdam-standard.pl> Sławomir Żytko <slawek@amsterdam-standard.pl>
 * @copyright Amsterdam Standard Sp. Z o.o.
 * @homepage http://vegas-cmf.github.io
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace Vegas\Mvc;
 
use Phalcon\Mvc\View as PhalconView;
use Phalcon\Mvc\View\Exception;
use Vegas\Mvc\View\Engine\Volt;
 
/**
 * Class View
 * @package Vegas\Mvc
 */
class View extends PhalconView
{
    /**
     * @var string
     * @internal
     */
    private $controllerViewPath;
 
    /**
     * Full path to controller view
     *
     * @var bool|string
     */
    private $controllerFullViewPath = false;
 
    /**
     * Constructor
     * Prepares view settings and engine
     *
     * @override
     * @param null $options
     * @param null $viewDir
     */
    public function __construct($options = null, $viewDir = null) {
        parent::__construct($options);
 
        if (isset($options['layoutsDir'])) {
            $this->setLayoutsDir($options['layoutsDir']);
        }
 
        if (isset($options['partialsDir']) && $options['partialsDir']) {
            $this->setPartialsDir($options['partialsDir']);
        }
 
        if (!$this->getPartialsDir() && $viewDir) {
            $this->setPartialsDir($viewDir);
        }
 
        if (isset($options['layout']) && !empty($options['layout'])) {
            $this->setLayout($options['layout']);
        }
 
        $this->registerEngines(array(
            '.volt' => function ($this, $di) use ($options) {
                    $volt = new Volt($this, $di);
                    if (isset($options['cacheDir'])) {
                        $volt->setOptions(array(
                            'compiledPath' => $options['cacheDir'],
                            'compiledSeparator' => '_',
                            'compileAlways' => isset($options['compileAlways']) ? $options['compileAlways'] : false
                        ));
                    }
 
                    $volt->registerFilters();
                    $volt->registerHelpers();
                    $volt->setExtension('.volt');
 
                    return $volt;
                },
            '.phtml' => 'Phalcon\Mvc\View\Engine\Php'
        ));
    }
 
    /**
     * Checks whether view exists on registered extensions and render it
     *
     * @override
     * @param array $engines
     * @param string $viewPath
     * @param boolean $silence
     * @param boolean $mustClean
     * @param \Phalcon\Cache\BackendInterface $cache
     * @return null|void
     * @throws Exception
     */
    protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache)
    {
        $basePath = $this->_basePath;
        $notExists = true;
 
        if (is_object($cache)) {
            $renderLevel = intval($this->_renderLevel);
            $cacheLevel = intval($this->_cacheLevel);
            if ($renderLevel >= $cacheLevel) {
                if ($cache->isStarted() === false) {
                    $viewOptions = $this->_options;
                    if (is_array($viewOptions)) {
                        if (isset($viewOptions['cache'])) {
                            $cacheOptions = $viewOptions['cache'];
                            if (is_array($cacheOptions)) {
                                if (isset($cacheOptions['key'])) {
                                    $key = $cacheOptions['key'];
                                }
                                if (isset($cacheOptions['lifetime'])) {
                                    $lifeTime = $cacheOptions['lifetime'];
                                }
                            }
 
                            if (!isset($key) || !$key) {
                                $key = md5($viewPath);
                            }
 
                            if (!isset($lifeTime)) {
                                $lifeTime = 0;
                            }
 
                            $cachedView = $cache->start($key, $lifeTime);
                            if (!$cachedView) {
                                $this->_content = $cachedView;
                                return null;
                            }
                        }
 
                        if (!$cache->isFresh()) {
                            return null;
                        }
                    }
                }
            }
        }
        $viewParams = $this->_viewParams;
        $eventsManager = $this->_eventsManager;
 
        foreach ($engines as $extension => $engine) {
            $viewEnginePath = $basePath . $this->resolveFullViewPath($viewPath) . $extension;
 
            if (file_exists($viewEnginePath)) {
                if (is_object($eventsManager)) {
                    $this->_activeRenderPath = $viewEnginePath;
                    if ($eventsManager->fire("view:beforeRenderView", $this, $viewEnginePath) === false) {
                        continue;
                    }
                }
                $engine->render($viewEnginePath, $viewParams, $mustClean);
 
                $notExists = false;
                if (is_object($eventsManager)) {
                    $eventsManager->fire("view:afterRenderView", $this);
                }
                break;
            }
        }
        if ($notExists) {
            if (is_object($eventsManager)) {
                $this->_activeRenderPath = $viewEnginePath;
                $eventsManager->fire("view:notFoundView", $this, $viewEnginePath);
            }
 
            if (!$silence) {
                throw new Exception(sprintf("View %s was not found in the views directory", $viewEnginePath));
            }
        }
    }
 
    /**
     * Resolves full path to view file
     *
     * @param $viewPath
     * @return string
     */
    private function resolveFullViewPath($viewPath)
    {
        if (strlen($this->getPartialsDir()) > 0 && strpos($viewPath, $this->getPartialsDir()) === 0) {
            return $this->resolvePartialPath($viewPath);
        }
        if (strpos($viewPath, $this->getLayoutsDir()) === 0) {
            return $this->resolveLayoutPath($viewPath);
        }
 
        return $this->resolveViewPath($viewPath);
    }
 
    /**
     * Resolves view path
     *
     * @param $viewPath
     * @return string
     */
    private function resolveViewPath($viewPath)
    {
        $path = realpath($this->_viewsDir . dirname($viewPath)) . DIRECTORY_SEPARATOR . basename($viewPath);
        return $path;
    }
 
    /**
     * Resolves path to partial
     *
     * application->view->partialsDir option is optional
     * When partialsDir is not set in configuration, then by default partialsDir is the same like current viewsDir
     * Otherwise, when partialsDir is set to for example directory app/layouts/partials then partial function loads
     * global partials from this directory
     *
     * <code>
     *      //remember about trailing slashes
     *      'application' => array(
     *      ...
     *          'view' => array(
     *              'layout' => 'main',
     *              'layoutsDir' => APP_ROOT . '/app/layouts/',
     *              'partialsDir' => APP_ROOT . '/app/layouts/partials/', //[optional]
     *              ...
     *          )
     *      )
     *      ...
     * </code>
     * Usage:
     *  -   Relative partial
     *      <code>
     *          {# somewhere in module view #}
     *          {{ partial('../../../layouts/partials/header/navigation') }
     *          # goes to APP_ROOT/app/layouts/partials/header/navigation.volt
     *      </code>
     *      <code>
     *          {# somewhere in module view eg. Test/views/index/index.volt #}
     *          {{ partial('./frontend/foo/partials/other.volt') }
     *          # goes to APP_ROOT/app/modules/Test/views/frontend/foo/partials/other.volt
     *      </code>
     *
     *  -   Global partial
     *      <code>
     *          {{ partial('header/navigation') }}
     *          # when partialsDir is set to APP_ROOT/app/layouts/partials
     *          # it goes to APP_ROOT/app/layouts/partials/header/navigation.volt
     *          # otherwise it is looking for view inside current viewsDir, so: APP_ROOT/app/modules/Test/views/header/navigation.volt
     *      </code>
     *
     * -    Local partial in module Test, controller Index (app/modules/Test/views/index/)
     *      <code>
     *          {{ partial('./frontend/index/partials/content/heading') }}
     *          # goes to APP_ROOT/app/modules/Test/views/frontend/index/partials/content/heading.volt
     *      </code>
     *
     * -    Absolute path
     *      <code>
     *          {{ partial(constant("APP_ROOT") ~ "/app/layouts/partials/header/navigation.volt") }}
     *      </code>
     *
     * @param $viewPath
     * @return string
     */
    private function resolvePartialPath($viewPath)
    {
        $tempViewPath = str_replace($this->getPartialsDir(), '', $viewPath);
 
        if (strpos($tempViewPath, '../') === 0 || strpos($tempViewPath, '/../') === 0) {
            return $this->resolveRelativePath($tempViewPath);
        } else if (strpos($tempViewPath, './') === 0) {
            return $this->resolveLocalPath($tempViewPath);
        } else if (!in_array(dirname($tempViewPath), ['.','..'])
            && file_exists(dirname($tempViewPath))) {
            return $tempViewPath;
        }
 
        return $this->resolveGlobalPath($tempViewPath);
    }
 
    /**
     * Resolves path to layouts directory
     *
     * @param $viewPath
     * @return string
     */
    private function resolveLayoutPath($viewPath)
    {
        return $viewPath;
    }
 
    /**
     * Resolves path to local partials directory
     *
     * @param $partialPath
     * @return string
     */
    private function resolveLocalPath($partialPath)
    {
        $partialDir = str_replace('./', '', dirname($partialPath));
        $partialsDir = realpath(sprintf('%s%s',
                $this->_viewsDir,
                $partialDir
            )) . DIRECTORY_SEPARATOR;
 
        return $partialsDir . basename($partialPath);
    }
 
    /**
     * Resolves path to global partials directory
     *
     * @param $partialPath
     * @return string
     */
    private function resolveGlobalPath($partialPath)
    {
        $partialsDirPath = $this->getPartialsDir();
        return $partialsDirPath . $partialPath;
    }
 
    /**
     * Resolves `realpath` from relative partial path
     *
     * @param $partialPath
     * @return string
     */
    private function resolveRelativePath($partialPath)
    {
        $partialsDirPath = realpath(sprintf('%s%s',
                $this->_viewsDir,
                dirname($partialPath)
            )) . DIRECTORY_SEPARATOR;
 
        return $partialsDirPath . basename($partialPath);
    }
 
    /**
     * Renders view for controller action
     *
     * @override
     * @param string $controllerName
     * @param string $actionName
     * @param null $params
     * @return PhalconView|void
     */
    public function render($controllerName, $actionName, $params = null) {
        if (empty($this->controllerViewPath)) {
            $this->setControllerViewPath($controllerName);
        }
        parent::render($this->controllerViewPath, $actionName, $params);
    }
 
    /**
     * Returns controller's view path
     *
     * @return string
     */
    public function getControllerViewPath()
    {
        return $this->controllerViewPath;
    }
 
    /**
     * Prepares and sets path for controller view
     *
     * @param $controllerName
     * @return mixed
     * @internal
     */
    public function setControllerViewPath($controllerName)
    {
        $this->controllerViewPath = str_replace('\\','/',strtolower($controllerName));
        $this->controllerFullViewPath = $this->_viewsDir . $this->controllerViewPath;
    }
}
#10Vegas\Mvc\View->_engineRender(Array([.volt] => Object(Vegas\Mvc\View\Engine\Volt), [.phtml] => Object(Phalcon\Mvc\View\Engine\Php)), home/index, true, true, null)
#11Phalcon\Mvc\View->render(home, index, Array([auth] => ))
<?php
/**
 * This file is part of Vegas package
 *
 * @author Arkadiusz Ostrycharz <aostrycharz@amsterdam-standard.pl> Sławomir Żytko <slawek@amsterdam-standard.pl>
 * @copyright Amsterdam Standard Sp. Z o.o.
 * @homepage http://vegas-cmf.github.io
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
 
namespace Vegas\Mvc;
 
use Phalcon\Mvc\View as PhalconView;
use Phalcon\Mvc\View\Exception;
use Vegas\Mvc\View\Engine\Volt;
 
/**
 * Class View
 * @package Vegas\Mvc
 */
class View extends PhalconView
{
    /**
     * @var string
     * @internal
     */
    private $controllerViewPath;
 
    /**
     * Full path to controller view
     *
     * @var bool|string
     */
    private $controllerFullViewPath = false;
 
    /**
     * Constructor
     * Prepares view settings and engine
     *
     * @override
     * @param null $options
     * @param null $viewDir
     */
    public function __construct($options = null, $viewDir = null) {
        parent::__construct($options);
 
        if (isset($options['layoutsDir'])) {
            $this->setLayoutsDir($options['layoutsDir']);
        }
 
        if (isset($options['partialsDir']) && $options['partialsDir']) {
            $this->setPartialsDir($options['partialsDir']);
        }
 
        if (!$this->getPartialsDir() && $viewDir) {
            $this->setPartialsDir($viewDir);
        }
 
        if (isset($options['layout']) && !empty($options['layout'])) {
            $this->setLayout($options['layout']);
        }
 
        $this->registerEngines(array(
            '.volt' => function ($this, $di) use ($options) {
                    $volt = new Volt($this, $di);
                    if (isset($options['cacheDir'])) {
                        $volt->setOptions(array(
                            'compiledPath' => $options['cacheDir'],
                            'compiledSeparator' => '_',
                            'compileAlways' => isset($options['compileAlways']) ? $options['compileAlways'] : false
                        ));
                    }
 
                    $volt->registerFilters();
                    $volt->registerHelpers();
                    $volt->setExtension('.volt');
 
                    return $volt;
                },
            '.phtml' => 'Phalcon\Mvc\View\Engine\Php'
        ));
    }
 
    /**
     * Checks whether view exists on registered extensions and render it
     *
     * @override
     * @param array $engines
     * @param string $viewPath
     * @param boolean $silence
     * @param boolean $mustClean
     * @param \Phalcon\Cache\BackendInterface $cache
     * @return null|void
     * @throws Exception
     */
    protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache)
    {
        $basePath = $this->_basePath;
        $notExists = true;
 
        if (is_object($cache)) {
            $renderLevel = intval($this->_renderLevel);
            $cacheLevel = intval($this->_cacheLevel);
            if ($renderLevel >= $cacheLevel) {
                if ($cache->isStarted() === false) {
                    $viewOptions = $this->_options;
                    if (is_array($viewOptions)) {
                        if (isset($viewOptions['cache'])) {
                            $cacheOptions = $viewOptions['cache'];
                            if (is_array($cacheOptions)) {
                                if (isset($cacheOptions['key'])) {
                                    $key = $cacheOptions['key'];
                                }
                                if (isset($cacheOptions['lifetime'])) {
                                    $lifeTime = $cacheOptions['lifetime'];
                                }
                            }
 
                            if (!isset($key) || !$key) {
                                $key = md5($viewPath);
                            }
 
                            if (!isset($lifeTime)) {
                                $lifeTime = 0;
                            }
 
                            $cachedView = $cache->start($key, $lifeTime);
                            if (!$cachedView) {
                                $this->_content = $cachedView;
                                return null;
                            }
                        }
 
                        if (!$cache->isFresh()) {
                            return null;
                        }
                    }
                }
            }
        }
        $viewParams = $this->_viewParams;
        $eventsManager = $this->_eventsManager;
 
        foreach ($engines as $extension => $engine) {
            $viewEnginePath = $basePath . $this->resolveFullViewPath($viewPath) . $extension;
 
            if (file_exists($viewEnginePath)) {
                if (is_object($eventsManager)) {
                    $this->_activeRenderPath = $viewEnginePath;
                    if ($eventsManager->fire("view:beforeRenderView", $this, $viewEnginePath) === false) {
                        continue;
                    }
                }
                $engine->render($viewEnginePath, $viewParams, $mustClean);
 
                $notExists = false;
                if (is_object($eventsManager)) {
                    $eventsManager->fire("view:afterRenderView", $this);
                }
                break;
            }
        }
        if ($notExists) {
            if (is_object($eventsManager)) {
                $this->_activeRenderPath = $viewEnginePath;
                $eventsManager->fire("view:notFoundView", $this, $viewEnginePath);
            }
 
            if (!$silence) {
                throw new Exception(sprintf("View %s was not found in the views directory", $viewEnginePath));
            }
        }
    }
 
    /**
     * Resolves full path to view file
     *
     * @param $viewPath
     * @return string
     */
    private function resolveFullViewPath($viewPath)
    {
        if (strlen($this->getPartialsDir()) > 0 && strpos($viewPath, $this->getPartialsDir()) === 0) {
            return $this->resolvePartialPath($viewPath);
        }
        if (strpos($viewPath, $this->getLayoutsDir()) === 0) {
            return $this->resolveLayoutPath($viewPath);
        }
 
        return $this->resolveViewPath($viewPath);
    }
 
    /**
     * Resolves view path
     *
     * @param $viewPath
     * @return string
     */
    private function resolveViewPath($viewPath)
    {
        $path = realpath($this->_viewsDir . dirname($viewPath)) . DIRECTORY_SEPARATOR . basename($viewPath);
        return $path;
    }
 
    /**
     * Resolves path to partial
     *
     * application->view->partialsDir option is optional
     * When partialsDir is not set in configuration, then by default partialsDir is the same like current viewsDir
     * Otherwise, when partialsDir is set to for example directory app/layouts/partials then partial function loads
     * global partials from this directory
     *
     * <code>
     *      //remember about trailing slashes
     *      'application' => array(
     *      ...
     *          'view' => array(
     *              'layout' => 'main',
     *              'layoutsDir' => APP_ROOT . '/app/layouts/',
     *              'partialsDir' => APP_ROOT . '/app/layouts/partials/', //[optional]
     *              ...
     *          )
     *      )
     *      ...
     * </code>
     * Usage:
     *  -   Relative partial
     *      <code>
     *          {# somewhere in module view #}
     *          {{ partial('../../../layouts/partials/header/navigation') }
     *          # goes to APP_ROOT/app/layouts/partials/header/navigation.volt
     *      </code>
     *      <code>
     *          {# somewhere in module view eg. Test/views/index/index.volt #}
     *          {{ partial('./frontend/foo/partials/other.volt') }
     *          # goes to APP_ROOT/app/modules/Test/views/frontend/foo/partials/other.volt
     *      </code>
     *
     *  -   Global partial
     *      <code>
     *          {{ partial('header/navigation') }}
     *          # when partialsDir is set to APP_ROOT/app/layouts/partials
     *          # it goes to APP_ROOT/app/layouts/partials/header/navigation.volt
     *          # otherwise it is looking for view inside current viewsDir, so: APP_ROOT/app/modules/Test/views/header/navigation.volt
     *      </code>
     *
     * -    Local partial in module Test, controller Index (app/modules/Test/views/index/)
     *      <code>
     *          {{ partial('./frontend/index/partials/content/heading') }}
     *          # goes to APP_ROOT/app/modules/Test/views/frontend/index/partials/content/heading.volt
     *      </code>
     *
     * -    Absolute path
     *      <code>
     *          {{ partial(constant("APP_ROOT") ~ "/app/layouts/partials/header/navigation.volt") }}
     *      </code>
     *
     * @param $viewPath
     * @return string
     */
    private function resolvePartialPath($viewPath)
    {
        $tempViewPath = str_replace($this->getPartialsDir(), '', $viewPath);
 
        if (strpos($tempViewPath, '../') === 0 || strpos($tempViewPath, '/../') === 0) {
            return $this->resolveRelativePath($tempViewPath);
        } else if (strpos($tempViewPath, './') === 0) {
            return $this->resolveLocalPath($tempViewPath);
        } else if (!in_array(dirname($tempViewPath), ['.','..'])
            && file_exists(dirname($tempViewPath))) {
            return $tempViewPath;
        }
 
        return $this->resolveGlobalPath($tempViewPath);
    }
 
    /**
     * Resolves path to layouts directory
     *
     * @param $viewPath
     * @return string
     */
    private function resolveLayoutPath($viewPath)
    {
        return $viewPath;
    }
 
    /**
     * Resolves path to local partials directory
     *
     * @param $partialPath
     * @return string
     */
    private function resolveLocalPath($partialPath)
    {
        $partialDir = str_replace('./', '', dirname($partialPath));
        $partialsDir = realpath(sprintf('%s%s',
                $this->_viewsDir,
                $partialDir
            )) . DIRECTORY_SEPARATOR;
 
        return $partialsDir . basename($partialPath);
    }
 
    /**
     * Resolves path to global partials directory
     *
     * @param $partialPath
     * @return string
     */
    private function resolveGlobalPath($partialPath)
    {
        $partialsDirPath = $this->getPartialsDir();
        return $partialsDirPath . $partialPath;
    }
 
    /**
     * Resolves `realpath` from relative partial path
     *
     * @param $partialPath
     * @return string
     */
    private function resolveRelativePath($partialPath)
    {
        $partialsDirPath = realpath(sprintf('%s%s',
                $this->_viewsDir,
                dirname($partialPath)
            )) . DIRECTORY_SEPARATOR;
 
        return $partialsDirPath . basename($partialPath);
    }
 
    /**
     * Renders view for controller action
     *
     * @override
     * @param string $controllerName
     * @param string $actionName
     * @param null $params
     * @return PhalconView|void
     */
    public function render($controllerName, $actionName, $params = null) {
        if (empty($this->controllerViewPath)) {
            $this->setControllerViewPath($controllerName);
        }
        parent::render($this->controllerViewPath, $actionName, $params);
    }
 
    /**
     * Returns controller's view path
     *
     * @return string
     */
    public function getControllerViewPath()
    {
        return $this->controllerViewPath;
    }
 
    /**
     * Prepares and sets path for controller view
     *
     * @param $controllerName
     * @return mixed
     * @internal
     */
    public function setControllerViewPath($controllerName)
    {
        $this->controllerViewPath = str_replace('\\','/',strtolower($controllerName));
        $this->controllerFullViewPath = $this->_viewsDir . $this->controllerViewPath;
    }
}
#12Vegas\Mvc\View->render(Home, index, Array([auth] => ))
#13Phalcon\Mvc\Application->handle(null)
<?php
/**
 * This file is part of Vegas package
 *
 * @author Slawomir Zytko <slawek@amsterdam-standard.pl>
 * @copyright Amsterdam Standard Sp. Z o.o.
 * @homepage http://vegas-cmf.github.io
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */ 
 
namespace Vegas\Mvc;
 
use Phalcon\Config;
use Phalcon\DI\FactoryDefault;
use Phalcon\DI;
use Phalcon\DiInterface;
use Phalcon\Mvc\Dispatcher;
use Vegas\Bootstrap\EnvironmentInitializerTrait;
use Vegas\Bootstrap\ErrorHandlerInitializerTrait;
use Vegas\Bootstrap\LoaderInitializerTrait;
use Vegas\Bootstrap\ModulesInitializerTrait;
use Vegas\Bootstrap\RoutesInitializerTrait;
use Vegas\Bootstrap\ServicesInitializerTrait;
use Vegas\BootstrapInterface;
use Vegas\Mvc\Dispatcher\Events\ExceptionListener;
use Vegas\Mvc\Router;
 
class Bootstrap implements BootstrapInterface
{
    use ModulesInitializerTrait;
 
    use ServicesInitializerTrait;
 
    use RoutesInitializerTrait;
 
    use EnvironmentInitializerTrait;
 
    use ErrorHandlerInitializerTrait;
 
    use LoaderInitializerTrait;
 
    /**
     * Dependency injection
     *
     * @var DiInterface
     */
    protected $di;
 
    /**
     * MVC Application
     *
     * @var Application
     */
    protected $application;
 
    /**
     * Application config
     *
     * @var Config
     */
    protected $config;
 
    /**
     * Constructor
     * Initializes MVC Application
     * Initializes DI for Application
     *
     * @param Config $config
     */
    public function __construct(Config $config)
    {
        $this->config = $config;
        $this->di = new FactoryDefault();
        $this->application = new Application();
    }
 
    /**
     * Sets Dependency Injector
     *
     * @param DiInterface $di
     */
    public function setDi(DiInterface $di)
    {
        $this->di = $di;
    }
 
    /**
     * Returns Dependency Injector
     *
     * @return FactoryDefault|DiInterface
     */
    public function getDI()
    {
        return $this->di;
    }
 
    /**
     * @return Application
     */
    public function getApplication()
    {
        return $this->application;
    }
 
    /**
     * Registers default dispatcher
     */
    public function initDispatcher()
    {
        $this->di->set('dispatcher', function() {
            $dispatcher = new Dispatcher();
 
            /**
             * @var \Phalcon\Events\Manager $eventsManager
             */
            $eventsManager = $this->di->getShared('eventsManager');
            $eventsManager->attach(
                'dispatch:beforeException',
                (new ExceptionListener())->beforeException()
            );
 
            $dispatcher->setEventsManager($eventsManager);
 
            return $dispatcher;
        });
    }
 
    /**
     * Executes all bootstrap initialization methods
     * This method can be overloaded to load own initialization method.
     * @return mixed
     */
    public function setup()
    {
        $this->di->set('config', $this->config);
 
        $this->initEnvironment($this->config);
        $this->initErrorHandler($this->config);
        $this->initLoader($this->config);
        $this->initModules($this->config);
        $this->initRoutes($this->config);
        $this->initServices($this->config);
        $this->initDispatcher();
 
        $this->application->setDI($this->di);
        DI::setDefault($this->di);
 
        return $this;
    }
 
    /**
     * Start handling MVC requests
     *
     * @param string $uri
     * @return string
     */
    public function run($uri = null)
    {
        return $this->application
            ->handle($uri)
            ->getContent();
    }
}
#14Vegas\Mvc\Bootstrap->run()
<?php
define('APP_ROOT', dirname(dirname(__FILE__)));
 
require APP_ROOT . '/vendor/autoload.php';
require APP_ROOT . '/app/Bootstrap.php';
 
//ensure that you copied config.sample.php to config.php
$config = require APP_ROOT . '/app/config/config.php';
 
$bootstrap = new \Bootstrap(new \Phalcon\Config($config));
 
echo $bootstrap->setup()->run();
KeyValue
KeyValue
USERvegas
HOME/home/vegas
FCGI_ROLERESPONDER
QUERY_STRING
REQUEST_METHODGET
CONTENT_TYPE
CONTENT_LENGTH
SCRIPT_NAME/index.php
REQUEST_URI/
DOCUMENT_URI/index.php
DOCUMENT_ROOT/home/vegas/www/public
SERVER_PROTOCOLHTTP/1.1
REQUEST_SCHEMEhttp
GATEWAY_INTERFACECGI/1.1
SERVER_SOFTWAREnginx/1.10.3
REMOTE_ADDR3.234.214.179
REMOTE_PORT49090
SERVER_ADDR31.179.222.41
SERVER_PORT80
SERVER_NAMEvegas.dev.amsterdamstandard.pl
REDIRECT_STATUS200
PATH_INFO
PATH_TRANSLATED/home/vegas/www/public
SCRIPT_FILENAME/home/vegas/www/public/index.php
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_HOSTvegas.amsterdamstandard.pl
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip
PHP_SELF/index.php
REQUEST_TIME_FLOAT1576303138.8044
REQUEST_TIME1576303138
#Path
0/home/vegas/www/public/index.php
1/home/vegas/www/vendor/autoload.php
2/home/vegas/www/vendor/composer/autoload_real.php
3/home/vegas/www/vendor/composer/ClassLoader.php
4/home/vegas/www/vendor/composer/include_paths.php
5/home/vegas/www/vendor/composer/autoload_namespaces.php
6/home/vegas/www/vendor/composer/autoload_psr4.php
7/home/vegas/www/vendor/composer/autoload_classmap.php
8/home/vegas/www/vendor/composer/autoload_files.php
9/home/vegas/www/vendor/swiftmailer/swiftmailer/lib/swift_required.php
10/home/vegas/www/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php
11/home/vegas/www/app/Bootstrap.php
12/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Bootstrap.php
13/home/vegas/www/vendor/vegas-cmf/core/src/BootstrapInterface.php
14/home/vegas/www/vendor/vegas-cmf/core/src/Bootstrap/ModulesInitializerTrait.php
15/home/vegas/www/vendor/vegas-cmf/core/src/Bootstrap/ServicesInitializerTrait.php
16/home/vegas/www/vendor/vegas-cmf/core/src/Bootstrap/RoutesInitializerTrait.php
17/home/vegas/www/vendor/vegas-cmf/core/src/Bootstrap/EnvironmentInitializerTrait.php
18/home/vegas/www/vendor/vegas-cmf/core/src/Bootstrap/ErrorHandlerInitializerTrait.php
19/home/vegas/www/vendor/vegas-cmf/core/src/Bootstrap/LoaderInitializerTrait.php
20/home/vegas/www/app/config/config.php
21/home/vegas/www/vendor/vegas-cmf/core/src/Constants.php
22/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Application.php
23/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Module/Loader.php
24/home/vegas/www/vendor/vegas-cmf/core/src/Util/FileWriter.php
25/home/vegas/www/app/modules/Home/config/config.php
26/home/vegas/www/app/modules/Auth/config/config.php
27/home/vegas/www/app/modules/Project/config/config.php
28/home/vegas/www/app/modules/Error/config/config.php
29/home/vegas/www/app/modules/Contributor/config/config.php
30/home/vegas/www/app/modules/Documentation/config/config.php
31/home/vegas/www/app/modules/User/config/config.php
32/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router/Adapter/Standard.php
33/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router.php
34/home/vegas/www/vendor/vegas-cmf/core/src/DI/InjectionAwareTrait.php
35/home/vegas/www/app/modules/Home/config/routes.php
36/home/vegas/www/app/modules/Auth/config/routes.php
37/home/vegas/www/app/modules/Project/config/routes.php
38/home/vegas/www/app/modules/Error/config/routes.php
39/home/vegas/www/app/modules/Contributor/config/routes.php
40/home/vegas/www/app/modules/Documentation/config/routes.php
41/home/vegas/www/app/modules/User/config/routes.php
42/home/vegas/www/app/config/routes.php
43/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router/Route.php
44/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router/Route/BaseRoute.php
45/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router/RouteInterface.php
46/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router/Route/StaticRoute.php
47/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Router/Route/NotfoundRoute.php
48/home/vegas/www/vendor/vegas-cmf/core/src/DI/ServiceProviderLoader.php
49/home/vegas/www/app/services/AssetsServiceProvider.php
50/home/vegas/www/vendor/vegas-cmf/core/src/DI/ServiceProviderInterface.php
51/home/vegas/www/app/services/AuthServiceProvider.php
52/home/vegas/www/app/services/SessionManagerServiceProvider.php
53/home/vegas/www/app/services/UserPasswordManagerServiceProvider.php
54/home/vegas/www/app/services/CollectionManagerServiceProvider.php
55/home/vegas/www/app/services/FlashServiceProvider.php
56/home/vegas/www/app/services/I18nServiceProvider.php
57/home/vegas/www/app/services/MailerServiceProvider.php
58/home/vegas/www/app/services/MongoServiceProvider.php
59/home/vegas/www/app/services/ScaffoldingServiceProvider.php
60/home/vegas/www/app/services/ServiceManagerServiceProvider.php
61/home/vegas/www/app/services/SessionServiceProvider.php
62/home/vegas/www/app/services/UploaderServiceProvider.php
63/home/vegas/www/app/services/UrlServiceProvider.php
64/home/vegas/www/app/services/ViewCacheServiceProvider.php
65/home/vegas/www/vendor/vegas-cmf/core/src/DI/Scaffolding/Adapter/Mongo.php
66/home/vegas/www/vendor/vegas-cmf/core/src/Db/AdapterInterface.php
67/home/vegas/www/vendor/vegas-cmf/core/src/DI/Scaffolding/AdapterInterface.php
68/home/vegas/www/vendor/vegas-cmf/core/src/Db/Adapter/Mongo/AdapterTrait.php
69/home/vegas/www/vendor/vegas-cmf/core/src/DI/Scaffolding.php
70/home/vegas/www/vendor/vegas-cmf/core/src/DI/ScaffoldingInterface.php
71/home/vegas/www/vendor/vegas-cmf/core/src/Db/MappingManager.php
72/home/vegas/www/vendor/vegas-cmf/core/src/Db/Mapping/Json.php
73/home/vegas/www/vendor/vegas-cmf/core/src/Db/MappingInterface.php
74/home/vegas/www/vendor/vegas-cmf/media/src/Media/Db/Mapping/File.php
75/home/vegas/www/app/modules/File/models/File.php
76/home/vegas/www/vendor/vegas-cmf/core/src/Db/Decorator/CollectionAbstract.php
77/home/vegas/www/vendor/vegas-cmf/core/src/Db/MappingResolverTrait.php
78/home/vegas/www/vendor/vegas-cmf/core/src/Db/Decorator/Helper/MappingHelperTrait.php
79/home/vegas/www/vendor/vegas-cmf/core/src/Db/Decorator/Helper/SlugTrait.php
80/home/vegas/www/vendor/vegas-cmf/core/src/Db/Decorator/Helper/WriteAttributesTrait.php
81/home/vegas/www/vendor/vegas-cmf/core/src/Db/Decorator/Helper/ReadNestedAttributeTrait.php
82/home/vegas/www/vendor/vegas-cmf/core/src/Db/Adapter/Mongo/RefResolverTrait.php
83/home/vegas/www/vendor/vegas-cmf/media/src/Media/Db/FileInterface.php
84/home/vegas/www/app/modules/Home/Module.php
85/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/ModuleAbstract.php
86/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/Dispatcher/Events/ExceptionListener.php
87/home/vegas/www/app/plugins/SecurityPlugin.php
88/home/vegas/www/vendor/vegas-cmf/auth/src/Authentication/EventsManager/Plugin.php
89/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View.php
90/home/vegas/www/app/modules/Home/controllers/HomeController.php
91/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/ControllerAbstract.php
92/home/vegas/www/app/modules/Home/forms/Contact.php
93/home/vegas/www/vendor/vegas-cmf/forms/src/Form.php
94/home/vegas/www/vendor/vegas-cmf/forms/src/Element/Text.php
95/home/vegas/www/vendor/vegas-cmf/forms/src/Decorator/UnDecoratedTrait.php
96/home/vegas/www/vendor/vegas-cmf/core/src/Translate/Adapter/Gettext.php
97/home/vegas/www/vendor/vegas-cmf/validation/src/Validator/PresenceOf.php
98/home/vegas/www/vendor/vegas-cmf/validation/src/ValidatorTrait.php
99/home/vegas/www/vendor/vegas-cmf/validation/src/Validator/Email.php
100/home/vegas/www/vendor/vegas-cmf/forms/src/Element/TextArea.php
101/home/vegas/www/vendor/vegas-cmf/forms/src/Element/Hidden.php
102/home/vegas/www/vendor/vegas-cmf/session/src/Session/Adapter/Files.php
103/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/Volt.php
104/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/RegisterFiltersTrait.php
105/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/RegisterHelpersTrait.php
106/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/Volt/Filter/ToString.php
107/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/Volt/VoltFilterAbstract.php
108/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/Volt/Helper/Pagination.php
109/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/Volt/VoltHelperAbstract.php
110/home/vegas/www/vendor/vegas-cmf/core/src/Mvc/View/Engine/Volt/Helper/ShortenText.php
111/home/vegas/www/cache/_home_vegas_www_app_modules_home_views_home_index.volt.php
112/home/vegas/www/vendor/vegas-cmf/core/src/DI/ServiceManager.php
113/home/vegas/www/app/modules/Project/services/Gallery.php
114/home/vegas/www/vendor/vegas-cmf/core/src/DI/Service/ComponentAbstract.php
115/home/vegas/www/vendor/vegas-cmf/core/src/DI/Service/ComponentInterface.php
116/home/vegas/www/app/modules/Project/models/Project.php
Memory
Usage1572864