<commit_before><?php

namespace Neutrino\Providers;

use Neutrino\Constants\Services;
use Neutrino\Interfaces\Providable;
use Neutrino\View\Engine\Extensions\PhpFunction as PhpFunctionExtension;
use Phalcon\Assets\Manager as AssetsManager;
use Phalcon\Di\Injectable;
use Phalcon\DiInterface;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Phalcon\Tag;

/**
 * Class View
 *
 *  @package Neutrino\Foundation\Bootstrap
 */
class View extends Injectable implements Providable
{
    /**
     * @inheritdoc
     */
    public function registering()
    {
        $di = $this->getDI();

        $di->setShared(Services::TAG, Tag::class);
        $di->setShared(Tag::class, Tag::class);
        $di->setShared(Services::ASSETS, AssetsManager::class);
        $di->setShared(AssetsManager::class, AssetsManager::class);

        $di->setShared(Services::VIEW, function () {
            /** @var DiInterface $this */

            $view = new \Phalcon\Mvc\View();

            $view->setViewsDir($this->getShared(Services::CONFIG)->view->views_dir);

            $view->registerEngines([
                '.volt'  => function ($view, $di) {
                    /* @var \Phalcon\Di $di */
                    $volt = new VoltEngine($view, $di);

                    $volt->setOptions([
                        'compiledPath'      => $di->getShared(Services::CONFIG)->view->compiled_path,
                        'compiledSeparator' => '_'
                    ]);
                    $volt->getCompiler()->addExtension(new PhpFunctionExtension());

                    return $volt;
                },
                '.phtml' => 'Phalcon\Mvc\View\Engine\Php'
            ]);

            return $view;
        });
    }
}<commit_msg>View config: allow to set Partials & Layouts dir via config<commit_after><?php

namespace Neutrino\Providers;

use Neutrino\Constants\Services;
use Neutrino\Interfaces\Providable;
use Neutrino\View\Engine\Extensions\PhpFunction as PhpFunctionExtension;
use Phalcon\Assets\Manager as AssetsManager;
use Phalcon\Di\Injectable;
use Phalcon\DiInterface;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
use Phalcon\Tag;

/**
 * Class View
 *
 *  @package Neutrino\Foundation\Bootstrap
 */
class View extends Injectable implements Providable
{
    /**
     * @inheritdoc
     */
    public function registering()
    {
        $di = $this->getDI();

        $di->setShared(Services::TAG, Tag::class);
        $di->setShared(Tag::class, Tag::class);
        $di->setShared(Services::ASSETS, AssetsManager::class);
        $di->setShared(AssetsManager::class, AssetsManager::class);

        $di->setShared(Services::VIEW, function () {
            /** @var DiInterface $this */

            $view = new \Phalcon\Mvc\View();

            $configView = $this->getShared(Services::CONFIG)->view;
            if (isset($configView->views_dir)) {
                $view->setViewsDir($configView->views_dir);
            }
            if (isset($configView->partials_dir)) {
                $view->setPartialsDir($configView->partials_dir);
            }
            if (isset($configView->layouts_dir)) {
                $view->setLayoutsDir($configView->layouts_dir);
            }

            $view->registerEngines([
                '.volt'  => function ($view, $di) {
                    /* @var \Phalcon\Di $di */
                    $volt = new VoltEngine($view, $di);

                    $volt->setOptions([
                        'compiledPath'      => $di->getShared(Services::CONFIG)->view->compiled_path,
                        'compiledSeparator' => '_'
                    ]);
                    $volt->getCompiler()->addExtension(new PhpFunctionExtension());

                    return $volt;
                },
                '.phtml' => 'Phalcon\Mvc\View\Engine\Php'
            ]);

            return $view;
        });
    }
}
{'fraction_non_alphanumeric': 0.14152652005174643, 'fraction_numerical': 0.0, 'mean_word_length': 2.0274079874706343, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7463870', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1101, 'n_words': 183}