Commit d001363d authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Merge branch 'master' into alc-module-piece-jointe

parents d5a34729 208bfaa9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -65,9 +65,13 @@ Enfin, commitez le tout et testez avant de déployer!!!

## Création de composants Vue

Ose embarque BootstrapVue.
A privilégier pour utiliser des composants Boottrap.

Sites officiels :
- https://vuejs.org/
- https://vitejs.dev/
- https://bootstrap-vue.org/

Doc Vue de Stéphane : 
- https://git.unicaen.fr/bouvry/presentation-dev/-/blob/master/src/vuejs.md
+8 −2
Original line number Diff line number Diff line
@@ -211,6 +211,9 @@ $config = [
            \UnicaenApp\View\Helper\AppLink::class                     => View\Helper\AppLinkFactory::class,
            \UnicaenAuth\View\Helper\UserCurrent::class                => View\Helper\UserCurrentFactory::class,
            \UnicaenAuth\View\Helper\LocalConnectViewHelper::class     => View\Helper\LocalConnectViewHelperFactory::class,
            'tab'                                                      => View\Helper\TabViewHelperFactory::class,
            'vite'                                                     => View\Helper\ViteViewHelperFactory::class,
            'vue'                                                      => View\Helper\VueViewHelperFactory::class,
        ],
        'invokables' => [
            'utilisateur'     => View\Helper\UtilisateurViewHelper::class,
@@ -218,8 +221,6 @@ $config = [
            'formSupprimer'   => View\Helper\FormSupprimerViewHelper::class,
            'formButtonGroup' => View\Helper\FormButtonGroupViewHelper::class,
            'cartridge'       => View\Helper\CartridgeViewHelper::class,
            'vite'            => View\Helper\ViteViewHelper::class,
            'vue'             => View\Helper\VueViewHelper::class,
        ],
    ],
    'controllers'        => [
@@ -240,6 +241,11 @@ $config = [
        'template_map'        => include __DIR__ . '/../template_map.php',
        'layout'              => 'layout/layout', // e.g., 'layout/layout'
    ],
    'vite'               => [
        'host'        => 'http://localhost:5133',
        'vue-url'     => '/vendor/vue.js',
        'hot-loading' => \AppConfig::inDev() ? \AppConfig::get('dev', 'hot-loading') : false,
    ],
];

if ($customCss = \AppConfig::get('etablissement', 'css')) {
+19 −8
Original line number Diff line number Diff line
@@ -14,11 +14,22 @@ class ViteViewHelper extends AbstractHtmlElement
{
    private $config = [
        'host'   => 'http://localhost:5133',
        'vueUrl' => '/vendor/vue.js',
        'vue-url' => '/vendor/vue.js',
        'hot-loading' => true,
    ];



    /**
     * @param string[] $config
     */
    public function __construct(array $config)
    {
        $this->config = $config;
    }



    /**
     *
     * @return self|string
@@ -64,18 +75,18 @@ class ViteViewHelper extends AbstractHtmlElement

    public function useNode(): bool
    {
        if (\AppConfig::inDev()) {
            return \AppConfig::get('dev', 'hot-loading', true);
        } else {
            return false;
        }
        return $this->getConfig('hot-loading');
    }



    public function getConfig(string $param)
    {
        return $this->config[$param] ?: null;
        if (array_key_exists($param, $this->config)){
            return $this->config[$param];
        }else{
            return null;
        }
    }


@@ -93,7 +104,7 @@ class ViteViewHelper extends AbstractHtmlElement
    {
        $h = '';
        if ($this->useNode()) {
            $url = $this->getView()->basePath($this->getConfig('vueUrl'));
            $url = $this->getView()->basePath($this->getConfig('vue-url'));
            $h   = '<script type="text/javascript" src="' . $url . '"></script>';
        }
        $h .= $this->vite('main.js');
+41 −0
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Psr\Container\ContainerInterface;


/**
 * Description of ViteViewHelperFactory
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class ViteViewHelperFactory
{

    /**
     * @param ContainerInterface $container
     * @param string             $requestedName
     * @param array|null         $options
     *
     * @return ViteViewHelper
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null): ViteViewHelper
    {
        $config = $container->get('config');

        if (array_key_exists('vite', $config)) {
            $viteConfig = $config['vite'];
        } else {
            $viteConfig = [
                'host'        => 'http://localhost:5133',
                'vue-url'     => '/vendor/vue.js',
                'hot-loading' => true,
            ];
        }

        $viewHelper = new ViteViewHelper($viteConfig);

        return $viewHelper;
    }
}
 No newline at end of file
+30 −0
Original line number Diff line number Diff line
<?php

namespace Application\View\Helper;

use Application\View\Helper\VueViewHelper;
use Psr\Container\ContainerInterface;


/**
 * Description of VueViewHelperFactory
 *
 * @author Laurent Lécluse <laurent.lecluse at unicaen.fr>
 */
class VueViewHelperFactory
{

    /**
     * @param ContainerInterface $container
     * @param string             $requestedName
     * @param array|null         $options
     *
     * @return VueViewHelper
     */
    public function __invoke(ContainerInterface $container, $requestedName, $options = null): VueViewHelper
    {
        $viewHelper = new VueViewHelper();

        return $viewHelper;
    }
}
 No newline at end of file
Loading