Suppression du module Smarty en standalone pour passer sur composer
This commit is contained in:
parent
f9229a6025
commit
adfdfe2b63
@ -57,6 +57,9 @@ return [
|
||||
'doctype' => 'HTML5',
|
||||
'not_found_template' => 'error/404',
|
||||
'exception_template' => 'error/index',
|
||||
'strategies' => [
|
||||
'Smarty\View\Strategy'
|
||||
],
|
||||
'template_map' => [
|
||||
'layout/layout' => __DIR__ . '/../view/layout/layout.tpl',
|
||||
'application/index/index' => __DIR__ . '/../view/application/index/index.tpl',
|
||||
|
@ -31,7 +31,544 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{$content}
|
||||
|
||||
|
||||
<!--------------------------------------HEADER-------------------------------------->
|
||||
|
||||
<header id="main-header">
|
||||
<div class="header-wrapper">
|
||||
<a class="logo" href="#">Nicolas</a>
|
||||
|
||||
<div class="mobile-toggle">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<ul>
|
||||
<!--Main nav to navigate to different parts of the page-->
|
||||
<li><a id="hero-link" href="#hero">Accueil</a></li>
|
||||
<li><a id="about-link" href="#about">À propos </a></li>
|
||||
<li><a id="competences-link" href="#competences">Competences</a></li>
|
||||
<li><a id="experiences-link" href="#experiences">Experiences</a></li>
|
||||
{*<li><a id="engagement-link" href="#engagement">Engagements</a></li>*}
|
||||
<li><a id="contact-link" href="#contact">Contact</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!--------------------------------------HERO IMAGE-------------------------------------->
|
||||
|
||||
|
||||
<section id="hero">
|
||||
<div id="particles-js">
|
||||
<div class="row center-xs center-sm center-md center-lg middle-xs middle-sm middle-md middle-lg">
|
||||
<div class="static col-xs-10 col-sm-10 col-md-10 col-lg-10">
|
||||
<div class="hero-content">
|
||||
<img src="img/profile-pic2.jpg">
|
||||
<h1>Nicolas Riault</h1>
|
||||
<h2 id="hero-text-animation">Web Developer Full Stack, Consultant IT</h2>
|
||||
<button class="download"><a download href="downloads/example.txt">Télécharger mon CV</a></button>
|
||||
<!--To add your file simply replace example.txt with whatever file you want-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--------------------------------------ABOUT SECTION-------------------------------------->
|
||||
|
||||
<section id="about">
|
||||
<div class="container">
|
||||
<div class="row left-xs left-sm left-md left-lg">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<div class="about-text">
|
||||
<h2>Bonjour, je m'appelle <span class="accent-text">Nicolas</span></h2>
|
||||
<p>
|
||||
Ouvert et curieux de caractère, je suis à l’aise dans la relation client et apprécie le travail
|
||||
en équipe.
|
||||
J’aime ce travail de développeur qui nécessite une capacité d’adaptation et d’écoute au service
|
||||
d’un projet.
|
||||
<br>
|
||||
Du point de vue technique, je développe principalement en PHP, C#. Je suis également a l'aise
|
||||
avec SQL Server et la solution MSBI.
|
||||
<br>
|
||||
Sur mon temps libre je travaille sur des projets personnels que j'autilise au quotidien en
|
||||
utilisant de nouvelles technologies (AngularJs, Ionic ... ).
|
||||
</p>
|
||||
<ul class="about-social">
|
||||
<!--Social icons for the about section-->
|
||||
<!--These icons are font-awesome icons and more can be looked up at https://fontawesome.com/icons?d=gallery-->
|
||||
<li><a href="http://www.google.com"><i class="fab fa-facebook-f"></i></a></li>
|
||||
<!--Simply replace the google link with your social media link-->
|
||||
<li><a href="http://www.google.com"><i class="fab fa-twitter"></i></a></li>
|
||||
<li><a href="http://www.google.com"><i class="far fa-envelope"></i></a></li>
|
||||
<li><a href="http://www.google.com"><i class="fab fa-google-plus-g"></i></a></li>
|
||||
<li><a href="http://www.google.com"><i class="fab fa-youtube"></i></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<div class="about-resume">
|
||||
<div class="education">
|
||||
<h2>Cursus et certifications</h2>
|
||||
<div class="eduction-block">
|
||||
<h4>SQL Server 2014 Performance Tuning and Optimization</h4>
|
||||
<p>2017 - IB Formation - Paris</p>
|
||||
</div>
|
||||
<div class="eduction-block">
|
||||
<h4>Licence Professionelle logiciel libre et propriétaire</h4>
|
||||
<p>2012 - UFR Des Sciences - Angers</p>
|
||||
</div>
|
||||
<div class="eduction-block">
|
||||
<h4>BTS Informatique de Gestion</h4>
|
||||
<p>2011 - Lycée Chevrollier - Angers</p>
|
||||
</div>
|
||||
<div class="eduction-block">
|
||||
<h4>Lycée Notre Dame</h4>
|
||||
<p>2009 - Baccalauréat Scientifique - La Flèche</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--------------------------------------COMPETENCES SECTION-------------------------------------->
|
||||
|
||||
<section id="competences">
|
||||
<div class="container">
|
||||
<div class="section-title">
|
||||
<h1>Mes <span class="accent-text">Compétences</span></h1>
|
||||
</div>
|
||||
<div class="row left-xs left-sm left-md left-lg">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<div class="about-resume">
|
||||
<div class="skills">
|
||||
<h2>Développement</h2>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>PHP</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent php">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>Javascript</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent php">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>HTML / CSS</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent html">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>.NET / C#</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent net">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<div class="about-resume">
|
||||
<div class="skills">
|
||||
<h2>SGBD / Business intelligence</h2>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>SQL Server</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent php">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>Microsoft BI</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent msbi">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>MySQL</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent mysql">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>PostgreSQL</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent postgresql">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row left-xs left-sm left-md left-lg">
|
||||
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<div class="about-resume">
|
||||
<div class="skills">
|
||||
<h2>Autres</h2>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>MongoDb / CassandraDb</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent msbi">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>Python</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent msbi">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>NodeJs</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent mysql">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>AngularJS</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent mysql">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="skill-progress-container">
|
||||
<p>Ionic Framework</p>
|
||||
<div class="skill-bar">
|
||||
<div class="bar-percent postgresql">
|
||||
<div class="inner-percent"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--------------------------------------EXPERIENCES SECTION-------------------------------------->
|
||||
|
||||
<section id="experiences" class="timeline">
|
||||
<div class="container">
|
||||
<div class="section-title">
|
||||
<h1>Mes <span class="accent-text">Experiences</span></h1>
|
||||
</div>
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-img"></div>
|
||||
<div class="timeline-content js--fadeInLeft">
|
||||
<h3>Développeur Full Stack - Serveurcom</h3>
|
||||
<div class="date">12/2015 - Actuel</div>
|
||||
<p>
|
||||
Maintenance évolutive d'une application de facturation pour les télécoms.
|
||||
<br>
|
||||
Macro gestion de l'équipe de développement.
|
||||
<br>
|
||||
Formation Microsoft 55144B.
|
||||
</p>
|
||||
<a class="bnt-more" onclick="launchModale('#modalServeurcom')">Détail</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-img"></div>
|
||||
<div class="timeline-content js--fadeInRight">
|
||||
<h3>Consultant SI - Capgémini</h3>
|
||||
<div class="date">02/2013 - 11/2015</div>
|
||||
<p>
|
||||
Développeur référent pour une TMA pour le groupe La Poste.
|
||||
<br>
|
||||
<small><i>PHP(CakePhp), MSBI/Asp.NET ( SSAS, SSRS, SSIS)</i></small>
|
||||
<br>
|
||||
TMA pour le ministère des sports.
|
||||
<br>
|
||||
<small><i>.NET/MSBI</i></small>
|
||||
<br>
|
||||
TMA pour l'Agence nationale de la recherche.
|
||||
<br>
|
||||
<small><i>C#, ASP, Sharepoint</i></small>
|
||||
<br>
|
||||
</p>
|
||||
<a class="bnt-more" onclick="launchModale('#modalCapgemini')">Détail</a>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-img"></div>
|
||||
<div class="timeline-content js--fadeInLeft">
|
||||
<div class="date">04/2012 - 11/2012</div>
|
||||
<h3>Développeur - INRA</h3>
|
||||
<p>
|
||||
Développement d'une application web pour informatiser le métier des chercheurs.
|
||||
<br>
|
||||
<small><i>Qooxdoo, Python, PostgreSQL</i></small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-img"></div>
|
||||
<div class="timeline-content js--fadeInRight">
|
||||
<h3>Développeur Web - Archimède</h3>
|
||||
<div class="date">06/2011 - 07/2011</div>
|
||||
<p>Developpement d'un site vitrine sous Joomla</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--------------------------------------ENGAGEMENT SECTION-------------------------------------->
|
||||
{*
|
||||
<section id="engagement">
|
||||
<div class="container">
|
||||
<div class="section-title">
|
||||
<h1>Mes <span class="accent-text">Engagements</span></h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row center-xs center-sm center-md center-lg trigger"><!--Row 1-->
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 hb vb">
|
||||
<div class="service-block">
|
||||
<i class="icon fas fa-code"></i>
|
||||
<h3>Web Development</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 hb vb">
|
||||
<div class="service-block">
|
||||
<i class="icon fas fa-laptop"></i>
|
||||
<h3>Web Design</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 hb vb">
|
||||
<div class="service-block">
|
||||
<i class="icon fas fa-mobile-alt"></i>
|
||||
<h3>Responsif</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 hb vb">
|
||||
<div class="service-block">
|
||||
<i class="icon far fa-file-alt"></i>
|
||||
<h3>Documentation</h3>
|
||||
<p>
|
||||
Analyse du besoin, qualification, chiffrage, rédaction des spécifications et des cahiers de
|
||||
test.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 hb vb">
|
||||
<div class="service-block">
|
||||
<i class="icon far fa-copy"></i>
|
||||
<h3>Clean Coder</h3>
|
||||
<p>
|
||||
Adepte du manifeste "Software craftsmanship manifesto".
|
||||
<br>
|
||||
<small>
|
||||
<i>Pas seulement une application qui marche, mais une application bien faite, perreine,
|
||||
robuste, maintenable et évolutive. </i>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4 hb vb">
|
||||
<div class="service-block">
|
||||
<i class="icon fas fa-cogs"></i>
|
||||
<h3>Support</h3>
|
||||
<p>Gestion du SAV, priorisation des tickets.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
*}
|
||||
|
||||
<!--------------------------------------CONTACT SECTION-------------------------------------->
|
||||
|
||||
<section id="contact">
|
||||
<div class="container">
|
||||
<div class="section-title">
|
||||
<h1>Contactez <span class="accent-text">Moi</span></h1>
|
||||
</div>
|
||||
|
||||
<div class="row center-xs center-sm center-md center-lg">
|
||||
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4">
|
||||
<div class="contact-info">
|
||||
|
||||
<div class="contact-block">
|
||||
<i class="fas fa-mobile-alt"></i>
|
||||
<div class="contact-text">
|
||||
<p>Numéro :</p>
|
||||
<p>+33637290170</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="contact-block">
|
||||
<i class="far fa-envelope"></i>
|
||||
<div class="contact-text">
|
||||
<p>Email : </p>
|
||||
<p>nicolas.riault@gmail.com</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="contact-block">
|
||||
<i class="fas fa-location-arrow"></i>
|
||||
<div class="contact-text">
|
||||
<p>
|
||||
Addresse :
|
||||
</p>
|
||||
<p>
|
||||
90 boulevard de la butte
|
||||
72230 - Mulsanne
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8">
|
||||
<form id="contact-form" onsubmit="submitForm(); return false;">
|
||||
<div class="field">
|
||||
Nom<br>
|
||||
<input type="text" id="name" value="" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
Email<br>
|
||||
<input type="text" id="email" value="" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
Sujet<br>
|
||||
<input type="text" id="subject" value="" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
Message<br>
|
||||
<textarea id="message" rows="10" cols="75"
|
||||
required></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" id="contact-submit" value="Envoyer"><span id="status"></span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!--------------------------------------MODALES LIST-------------------------------------->
|
||||
<div class="modal fade" id="modalServeurcom" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Développeur Full Stack - Serveurcom</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
Reprise en interne puis maintenance évolutive d'une application de facturation
|
||||
Télécom développée par un prestataire externe.<br>
|
||||
Développements de plusieurs briques dont une refonte visuelle complète de
|
||||
l'application et la création de tableaux de bords complets dans le but de suivre
|
||||
l'activité de l'entreprise mais aussi permettre aux revendeurs de suivre leur
|
||||
activité.<br>
|
||||
Responsable de la tenue des performances et de l'optimisation des traitements de
|
||||
facturation sous SQL Server 2014.<br>
|
||||
Rédaction de spécifications fonctionnelles pour les évolutions, définition de
|
||||
roadmap pour planifier les besoins, macro gestion de l'équipe de développeurs et
|
||||
organisation de daily meetings pour gérer l’activité de l'équipe de développement.<br>
|
||||
Mise en place de JIRA pour gérer les taches de l'équipe.<br>
|
||||
<br>
|
||||
Formation Microsoft 55144B : "SQL Server 2014 Performance Tuning and
|
||||
Optimization"
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="modalCapgemini" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Consultant SI - Capgémini</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>
|
||||
Projet de TMA pour le groupe La Poste, Développeur référent <br>
|
||||
- 6 applications php, sous framework CakePhp<br>
|
||||
- 3 applications MSBI/Asp.NET ( SSAS, SSRS, SSIS)<br>
|
||||
- Outre le développement pur, j'ai régulièrement réalisé les conceptions techniques, la mise à jour
|
||||
des spécifications fonctionnelles, mais aussi la rédaction et le passage des campagnes de tests sous
|
||||
quality center.<br>
|
||||
-Communication régulière avec le client<br><br>
|
||||
|
||||
TMA pour le ministère des sports.<br>
|
||||
- Développeur en support pour 2 applications .NET/MSBI pour le ministère des sports.<br>
|
||||
- Réalisation de conception techniques, mise à jour des spécifications fonctionnelles, rédaction et
|
||||
passage des campagnes de tests sous quality center.<br><br>
|
||||
|
||||
Développeur - Projet de TMA pour l'ANR.<br>
|
||||
- Maintenance et évolution d'une application de gestion des demandes
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--------------------------------------FOOTER SECTION-------------------------------------->
|
||||
|
||||
<footer>
|
||||
<p>Copyright © 2018 bricho.com And Made With Love All Rights Reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
|
||||
@ -43,7 +580,7 @@
|
||||
<script src="js/scrollmagic/uncompressed/plugins/debug.addIndicators.js"></script>
|
||||
<script src="js/bootstrap.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
<!--<script src="js/timeline.js"></script>-->
|
||||
<!--<script src="js/timeline.js"></script>-->view_manager
|
||||
<script src="https://cdn.jsdelivr.net/scrollreveal.js/3.3.1/scrollreveal.min.js"></script>
|
||||
|
||||
</body>
|
||||
|
7
module/Smarty/.gitignore
vendored
7
module/Smarty/.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
.idea
|
||||
vendor
|
||||
composer.lock
|
||||
composer.phar
|
||||
phpunit.xml
|
||||
phpmd.xml
|
||||
phpdox.xml
|
@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 skillfish
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,88 +0,0 @@
|
||||
# zf3-smarty-module
|
||||
Based on https://github.com/randlem/zf2-smarty-module and modified for use with ZF3
|
||||
|
||||
# Installation
|
||||
Although you could just clone this repository, it is highly recommended to install the module via composer.
|
||||
- run `php composer.phar require skillfish/zf3-smarty-module`
|
||||
- add Smarty to your ZF3 modules Configuration e.g /config/modules.config.php
|
||||
- change the View Manager Strategy to Smarty in your module or apllication config like:
|
||||
```php
|
||||
<?php
|
||||
return [
|
||||
'view_manager' => [
|
||||
'strategies' => [
|
||||
'Smarty\View\Strategy'
|
||||
],
|
||||
],
|
||||
];
|
||||
```
|
||||
you might also want to change your View Manager's Template Map to actually use .tpl files instead of the default .phtml
|
||||
```php
|
||||
<?php
|
||||
return [
|
||||
'view_manager' => [
|
||||
'template_map' => [
|
||||
'layout/layout' => '/module/Application/view/layout/layout.tpl',
|
||||
'application/index/index' => '/module/Application/view/application/index/index.tpl',
|
||||
'error/404' => '/module/Application/view/error/404.tpl',
|
||||
'error/index' => '/module/Applicationview/error/index.tpl',
|
||||
],
|
||||
],
|
||||
];
|
||||
```
|
||||
# Template Inheritance
|
||||
In order for template inheritance to work, you must terminate your ViewModel inside your Controller with `$viewModel->setTerminal(true);` and make use of the smarty `{extends}` tag. Otherwise the ViewModel will render the default layout template and inheritance won't work.
|
||||
|
||||
### Example
|
||||
|
||||
layout.tpl
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<title>{block 'title'}Page name{/block}</title>
|
||||
</head>
|
||||
<body>
|
||||
{block 'content'}{/block}
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
index.tpl
|
||||
```html
|
||||
{extends 'layout.tpl'}
|
||||
{block 'title' append} - Index{/block}
|
||||
{block 'content'}This is the index template{/block}
|
||||
```
|
||||
Controller
|
||||
```php
|
||||
public function indexAction()
|
||||
{
|
||||
$viewModel = new ViewModel();
|
||||
$viewModel->setTerminal(true);
|
||||
return $viewModel;
|
||||
}
|
||||
```
|
||||
|
||||
will result in
|
||||
```html
|
||||
<html>
|
||||
<head>
|
||||
<title>Page name - Index</title>
|
||||
</head>
|
||||
<body>
|
||||
This is the index template
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
# Requirements
|
||||
The composer module currently requires:
|
||||
```json
|
||||
"require": {
|
||||
"php": ">5.4",
|
||||
"smarty/smarty": "~3.1.29",
|
||||
"zendframework/zend-stdlib": "~3.0.1",
|
||||
"zendframework/zend-mvc": "~3.0.1",
|
||||
"zendframework/zend-servicemanager": "~3.1",
|
||||
"zendframework/zend-modulemanager": "~2.7.1"
|
||||
},
|
||||
```
|
@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "skillfish/zf3-smarty-module",
|
||||
"description": "Zend Framework 3 Module for integrating Smarty 3 as View Manager",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"smarty",
|
||||
"module",
|
||||
"zf3"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Heiko Baumgärtner",
|
||||
"email": "skillfish@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">5.4",
|
||||
"smarty/smarty": "^3.1",
|
||||
"zendframework/zend-stdlib": "^3.0",
|
||||
"zendframework/zend-mvc": "^3.0",
|
||||
"zendframework/zend-servicemanager": "^3.1",
|
||||
"zendframework/zend-modulemanager": "^2.7"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Smarty\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty2;
|
||||
|
||||
use Smarty\View\Strategy;
|
||||
use Smarty\Service\StrategyFactory;
|
||||
use Smarty\View\Renderer;
|
||||
use Smarty\Service\RendererFactory;
|
||||
use Smarty\Service\PluginManager;
|
||||
use Smarty\Service\PluginManagerFactory;
|
||||
use Smarty\Service\PluginDelegator;
|
||||
|
||||
return [
|
||||
'view_manager' => [
|
||||
'strategies' => [
|
||||
Strategy::class,
|
||||
],
|
||||
],
|
||||
'service_manager' => [
|
||||
'factories' => [
|
||||
Strategy::class => StrategyFactory::class,
|
||||
Renderer::class => RendererFactory::class,
|
||||
PluginManager::class => PluginManagerFactory::class,
|
||||
],
|
||||
'delegators' => [
|
||||
Renderer::class => [
|
||||
PluginDelegator::class,
|
||||
],
|
||||
],
|
||||
],
|
||||
'smarty' => [
|
||||
'suffix' => 'tpl',
|
||||
'compile_dir' => getcwd() . '/data/smarty/templates_c',
|
||||
'config_file' => getcwd() . '/config/autoload/smarty.conf',
|
||||
'escape_html' => true,
|
||||
'caching' => false,
|
||||
'cache_dir' => getcwd() . '/data/smarty/cache',
|
||||
'plugins_dir' => getcwd() . '/data/smarty/plugins',
|
||||
'plugins' => [
|
||||
// Plugin manager configuration.
|
||||
'manager' => [
|
||||
],
|
||||
// Plugins.
|
||||
// For example (MyFuncPlugin should be added in Plugin manager):
|
||||
// 'functions' => [
|
||||
// 'my_func' => MyFuncPlugin::class,
|
||||
// ]
|
||||
// This config register MyFuncPlugin with "my_func" name in Smarty.
|
||||
'functions' => [
|
||||
],
|
||||
'modifiers' => [
|
||||
],
|
||||
'blocks' => [
|
||||
],
|
||||
'if_blocks' => [
|
||||
],
|
||||
'cycle_blocks' => [
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Exception;
|
||||
|
||||
use Zend\ServiceManager\Exception\InvalidServiceException as ZendInvalidServiceException;
|
||||
|
||||
class InvalidServiceException extends ZendInvalidServiceException
|
||||
{
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty;
|
||||
|
||||
class Module
|
||||
{
|
||||
public function getConfig()
|
||||
{
|
||||
return include __DIR__ . '/../config/module.config.php';
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Plugin;
|
||||
|
||||
use Smarty;
|
||||
|
||||
/**
|
||||
* Interface to detect if a class is Smarty Block plugin.
|
||||
*/
|
||||
interface BlockPluginInterface extends PluginInterface
|
||||
{
|
||||
/**
|
||||
* @param array $params
|
||||
* @param string $content
|
||||
* @param Smarty $smarty
|
||||
* @param bool $repeat
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function prepare(array $params, $content, $smarty, &$repeat);
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Plugin;
|
||||
|
||||
use Smarty;
|
||||
|
||||
/**
|
||||
* Interface to detect if a class is Smarty CycleBlock plugin.
|
||||
*/
|
||||
interface CycleBlockPluginInterface extends PluginInterface
|
||||
{
|
||||
/**
|
||||
* Call before cycle.
|
||||
*
|
||||
* @param array $params
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function init(array $params, $smarty);
|
||||
|
||||
/**
|
||||
* Call before iteration.
|
||||
*
|
||||
* @param array $params
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return bool true - if the current iteration is valid.
|
||||
*/
|
||||
public function isValid(array $params, $smarty);
|
||||
|
||||
/**
|
||||
* Attention: move the pointer to this method.
|
||||
*
|
||||
* @param array $params
|
||||
* @param string $content
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return string Content of the current iteration.
|
||||
*/
|
||||
public function prepareIteration(array $params, $content, $smarty);
|
||||
|
||||
/**
|
||||
* Call after cycle.
|
||||
*
|
||||
* @param array $params
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function end(array $params, $smarty);
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Plugin;
|
||||
|
||||
use Smarty;
|
||||
|
||||
/**
|
||||
* Interface to detect if a class is Smarty Function plugin.
|
||||
*/
|
||||
interface FunctionPluginInterface extends PluginInterface
|
||||
{
|
||||
/**
|
||||
* @param array $params
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function run(array $params, $smarty);
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Plugin;
|
||||
|
||||
use Smarty;
|
||||
|
||||
/**
|
||||
* Interface to detect if a class is Smarty IfBlock plugin.
|
||||
*/
|
||||
interface IfBlockPluginInterface extends PluginInterface
|
||||
{
|
||||
/**
|
||||
* @param array $params
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkCondition(array $params, $smarty);
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param string $content
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return string Content, if the condition is true.
|
||||
*/
|
||||
public function prepareTrue(array $params, $content, $smarty);
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param string $content
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return string Content, if the condition is false.
|
||||
*/
|
||||
public function prepareFalse(array $params, $content, $smarty);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Plugin;
|
||||
|
||||
/**
|
||||
* Interface to detect if a class is Smarty Modifier plugin.
|
||||
*/
|
||||
interface ModifierPluginInterface extends PluginInterface
|
||||
{
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed ...
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function modify($value);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Plugin;
|
||||
|
||||
/**
|
||||
* Interface to detect if a class is Smarty plugin.
|
||||
*
|
||||
* Abstract base interface that cannot be implemented alone. Instead it must be
|
||||
* implemented by either FunctionPluginInterface, ModifierPluginInterface,
|
||||
* BlockPluginInterface or IfBlockPluginInterface.
|
||||
*/
|
||||
interface PluginInterface
|
||||
{
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service;
|
||||
|
||||
use Zend\ServiceManager\Factory\DelegatorFactoryInterface;
|
||||
use Zend\ServiceManager\PluginManagerInterface;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Smarty;
|
||||
use Smarty\Service\PluginManager;
|
||||
use Smarty\Service\PluginProxy\IfBlockProxy;
|
||||
use Smarty\Service\PluginProxy\CycleBlockProxy;
|
||||
use Smarty\Exception\InvalidServiceException;
|
||||
use Smarty\Plugin\FunctionPluginInterface;
|
||||
use Smarty\Plugin\ModifierPluginInterface;
|
||||
use Smarty\Plugin\BlockPluginInterface;
|
||||
use Smarty\Plugin\IfBlockPluginInterface;
|
||||
use Smarty\Plugin\CycleBlockPluginInterface;
|
||||
|
||||
/**
|
||||
* This delegator used for registration Object-plugins in Smarty.
|
||||
*/
|
||||
class PluginDelegator implements DelegatorFactoryInterface
|
||||
{
|
||||
/**
|
||||
* @var Smarty
|
||||
*/
|
||||
private $smarty;
|
||||
|
||||
/**
|
||||
* @var PluginManagerInterface
|
||||
*/
|
||||
private $pluginManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __invoke(ContainerInterface $container, $name, callable $callback, array $options = null)
|
||||
{
|
||||
$config = $container->get('Configuration');
|
||||
$pluginsConfig = $config['smarty']['plugins'];
|
||||
|
||||
$renderer = call_user_func($callback);
|
||||
$this->smarty = $renderer->getEngine();
|
||||
$this->pluginManager = $container->get(PluginManager::class);
|
||||
|
||||
$this->registerFunctionPlugins($pluginsConfig['functions']);
|
||||
$this->registerModifierPlugins($pluginsConfig['modifiers']);
|
||||
$this->registerBlockPlugins($pluginsConfig['blocks']);
|
||||
$this->registerIfBlockPlugins($pluginsConfig['if_blocks']);
|
||||
$this->registerCycleBlockPlugins($pluginsConfig['cycle_blocks']);
|
||||
|
||||
return $renderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $pluginsConfig
|
||||
* @param string $expectedInstance
|
||||
*
|
||||
* @throws InvalidServiceException
|
||||
*
|
||||
* @return PluginInterface[]
|
||||
*/
|
||||
protected function getPlugins(array $pluginsConfig, $expectedInstance)
|
||||
{
|
||||
$plugins = [];
|
||||
foreach ($pluginsConfig as $name => $pluginClass) {
|
||||
$plugin = $this->pluginManager->build($pluginClass, ['name' => $name]);
|
||||
if (!$plugin instanceOf $expectedInstance) {
|
||||
throw new InvalidServiceException(sprintf(
|
||||
'Plugin delegator "%s" expected an instance of type "%s", but "%s" was received',
|
||||
__CLASS__,
|
||||
$expectedInstance,
|
||||
is_object($plugin) ? get_class($plugin) : gettype($plugin)
|
||||
));
|
||||
}
|
||||
$plugins[$name] = $plugin;
|
||||
}
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
public function registerFunctionPlugins(array $plugins)
|
||||
{
|
||||
foreach ($this->getPlugins($plugins, FunctionPluginInterface::class) as $name => $plugin) {
|
||||
$this->smarty->registerPlugin('function', $name, [$plugin, 'run']);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerModifierPlugins(array $plugins)
|
||||
{
|
||||
foreach ($this->getPlugins($plugins, ModifierPluginInterface::class) as $name => $plugin) {
|
||||
$this->smarty->registerPlugin('modifier', $name, [$plugin, 'modify']);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerBlockPlugins(array $plugins)
|
||||
{
|
||||
foreach ($this->getPlugins($plugins, BlockPluginInterface::class) as $name => $plugin) {
|
||||
$this->smarty->registerPlugin('block', $name, [$plugin, 'prepare']);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerIfBlockPlugins(array $plugins)
|
||||
{
|
||||
foreach ($this->getPlugins($plugins, IfBlockPluginInterface::class) as $name => $plugin) {
|
||||
$proxy = new IfBlockProxy($plugin, $name);
|
||||
$this->smarty->registerPlugin('block', $name, [$proxy, '__invoke']);
|
||||
$this->smarty->registerPlugin('function', $name . '_else', [$proxy, 'elseFunction']);
|
||||
}
|
||||
}
|
||||
|
||||
public function registerCycleBlockPlugins(array $plugins)
|
||||
{
|
||||
foreach ($this->getPlugins($plugins, CycleBlockPluginInterface::class) as $name => $plugin) {
|
||||
$proxy = new CycleBlockProxy($plugin);
|
||||
$this->smarty->registerPlugin('block', $name, [$proxy, '__invoke']);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service;
|
||||
|
||||
use Zend\ServiceManager\AbstractPluginManager;
|
||||
use Smarty\Plugin\PluginInterface;
|
||||
|
||||
class PluginManager extends AbstractPluginManager
|
||||
{
|
||||
protected $instanceOf = PluginInterface::class;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service;
|
||||
|
||||
use Zend\ServiceManager\Factory\FactoryInterface;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
|
||||
class PluginManagerFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
{
|
||||
$config = $container->get('Configuration');
|
||||
$config = $config['smarty']['plugins'];
|
||||
return new PluginManager($container, $config['manager']);
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service\PluginProxy;
|
||||
|
||||
use Smarty\Plugin\CycleBlockPluginInterface;
|
||||
|
||||
class CycleBlockProxy
|
||||
{
|
||||
/**
|
||||
* @var IfBlockPluginInterface
|
||||
*/
|
||||
private $plugin;
|
||||
|
||||
/**
|
||||
* @param IfBlockPluginInterface $plugin
|
||||
*/
|
||||
public function __construct(CycleBlockPluginInterface $plugin)
|
||||
{
|
||||
$this->plugin = $plugin;
|
||||
}
|
||||
|
||||
public function __invoke(array $params, $content, $smarty, &$repeat)
|
||||
{
|
||||
if (is_null($content)) {
|
||||
return $this->plugin->init($params, $smarty);
|
||||
}
|
||||
if (!$this->plugin->isValid($params, $smarty)) {
|
||||
$repeat = false;
|
||||
return $this->plugin->end($params, $smarty);
|
||||
}
|
||||
$repeat = true;
|
||||
return $this->plugin->prepareIteration($params, $content, $smarty);
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service\PluginProxy;
|
||||
|
||||
use Smarty\Plugin\IfBlockPluginInterface;
|
||||
|
||||
class IfBlockProxy
|
||||
{
|
||||
/**
|
||||
* @var IfBlockPluginInterface
|
||||
*/
|
||||
private $plugin;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @param IfBlockPluginInterface $plugin
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(IfBlockPluginInterface $plugin, $name)
|
||||
{
|
||||
$this->plugin = $plugin;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function __invoke(array $params, $content, $smarty, &$repeat)
|
||||
{
|
||||
$trueFalseBlockContents = explode(sprintf('{%s_else}', $this->name), $content);
|
||||
if (!isset($trueFalseBlockContents[1])) {
|
||||
$trueFalseBlockContents[1] = '';
|
||||
}
|
||||
|
||||
if (!$this->plugin->checkCondition($params, $smarty)) {
|
||||
return $this->plugin->prepareFalse($params, $trueFalseBlockContents[1], $smarty);
|
||||
}
|
||||
|
||||
return $this->plugin->prepareTrue($params, $trueFalseBlockContents[0], $smarty);
|
||||
}
|
||||
|
||||
public function elseFunction(array $params, $smarty)
|
||||
{
|
||||
return $smarty->left_delimiter . $this->name . '_else' . $smarty->right_delimiter;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service;
|
||||
|
||||
use Zend\ServiceManager\Factory\FactoryInterface;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Smarty\View\Renderer;
|
||||
use Smarty;
|
||||
|
||||
class RendererFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
{
|
||||
$config = $container->get('Configuration');
|
||||
$config = $config['smarty'];
|
||||
|
||||
/** @var $pathResolver \Zend\View\Resolver\TemplatePathStack */
|
||||
$pathResolver = clone $container->get('ViewTemplatePathStack');
|
||||
$pathResolver->setDefaultSuffix($config['suffix']);
|
||||
|
||||
/** @var $resolver \Zend\View\Resolver\AggregateResolver */
|
||||
$resolver = $container->get('ViewResolver');
|
||||
$resolver->attach($pathResolver);
|
||||
|
||||
$engine = new Smarty();
|
||||
$engine->setCompileDir($config['compile_dir']);
|
||||
$engine->setEscapeHtml($config['escape_html']);
|
||||
$engine->setTemplateDir($pathResolver->getPaths()->toArray());
|
||||
$engine->setCaching($config['caching']);
|
||||
$engine->setCacheDir($config['cache_dir']);
|
||||
$engine->addPluginsDir($config['plugins_dir']);
|
||||
|
||||
if (file_exists($config['config_file'])) {
|
||||
$engine->configLoad($config['config_file']);
|
||||
}
|
||||
|
||||
$renderer = new Renderer();
|
||||
$renderer->setEngine($engine);
|
||||
$renderer->setSuffix($config['suffix']);
|
||||
$renderer->setResolver($resolver);
|
||||
|
||||
return $renderer;
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Service;
|
||||
|
||||
use Zend\ServiceManager\Factory\FactoryInterface;
|
||||
use Interop\Container\ContainerInterface;
|
||||
use Smarty\View\Renderer;
|
||||
use Smarty\View\Strategy;
|
||||
|
||||
class StrategyFactory implements FactoryInterface
|
||||
{
|
||||
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
|
||||
{
|
||||
$renderer = $container->get(Renderer::class);
|
||||
$strategy = new Strategy($renderer);
|
||||
return $strategy;
|
||||
}
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\View;
|
||||
|
||||
use Zend\View\Renderer\RendererInterface;
|
||||
use Zend\View\Resolver\ResolverInterface;
|
||||
use Zend\View\Model\ModelInterface;
|
||||
use Zend\View\Exception\DomainException;
|
||||
use Smarty;
|
||||
use ArrayObject;
|
||||
|
||||
class Renderer implements RendererInterface
|
||||
{
|
||||
/**
|
||||
* @var Smarty
|
||||
*/
|
||||
protected $engine;
|
||||
/**
|
||||
* @var ResolverInterface
|
||||
*/
|
||||
protected $resolver;
|
||||
/**
|
||||
* Template suffix for this renderer
|
||||
* @var string
|
||||
*/
|
||||
protected $suffix;
|
||||
|
||||
public function setEngine(Smarty $engine)
|
||||
{
|
||||
$this->engine = $engine;
|
||||
$this->engine->assign('this', $this);
|
||||
}
|
||||
|
||||
public function getEngine()
|
||||
{
|
||||
return $this->engine;
|
||||
}
|
||||
|
||||
public function setResolver(ResolverInterface $resolver)
|
||||
{
|
||||
$this->resolver = $resolver;
|
||||
}
|
||||
|
||||
public function render($nameOrModel, $values = null)
|
||||
{
|
||||
if ($nameOrModel instanceof ModelInterface) {
|
||||
$model = $nameOrModel;
|
||||
$nameOrModel = $nameOrModel->getTemplate();
|
||||
if (empty($nameOrModel)) {
|
||||
throw new DomainException(sprintf(
|
||||
'%s: recieved View Model argument, but template is empty.',
|
||||
__METHOD__
|
||||
));
|
||||
}
|
||||
$values = $model->getVariables();
|
||||
unset($model);
|
||||
}
|
||||
if (!($file = $this->resolver->resolve($nameOrModel))) {
|
||||
throw new DomainException(sprintf(
|
||||
'Unable to find template "%s"',
|
||||
$nameOrModel
|
||||
));
|
||||
}
|
||||
|
||||
if ($values instanceof ArrayObject) {
|
||||
$values = $values->getArrayCopy();
|
||||
}
|
||||
|
||||
$smarty = $this->getEngine();
|
||||
$smarty->clearAllAssign();
|
||||
$smarty->assign($values);
|
||||
|
||||
$content = $smarty->fetch($file);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function canRender($nameOrModel)
|
||||
{
|
||||
if ($nameOrModel instanceof ModelInterface) {
|
||||
$nameOrModel = $nameOrModel->getTemplate();
|
||||
}
|
||||
$tpl = $this->resolver->resolve($nameOrModel);
|
||||
$ext = pathinfo($tpl, PATHINFO_EXTENSION);
|
||||
if ($tpl && $ext == $this->getSuffix()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setSuffix($suffix)
|
||||
{
|
||||
$this->suffix = $suffix;
|
||||
}
|
||||
|
||||
public function getSuffix()
|
||||
{
|
||||
return $this->suffix;
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\View;
|
||||
|
||||
use Zend\EventManager\ListenerAggregateInterface;
|
||||
use Zend\EventManager\EventManagerInterface;
|
||||
use Zend\View\ViewEvent;
|
||||
use Smarty\View\Renderer;
|
||||
|
||||
class Strategy implements ListenerAggregateInterface
|
||||
{
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
protected $listeners = [];
|
||||
/**
|
||||
* @var Renderer
|
||||
*/
|
||||
protected $renderer;
|
||||
|
||||
public function __construct(Renderer $renderer)
|
||||
{
|
||||
$this->renderer = $renderer;
|
||||
}
|
||||
|
||||
public function attach(EventManagerInterface $events, $priority = 100)
|
||||
{
|
||||
$this->listeners[] = $events->attach(ViewEvent::EVENT_RENDERER, [$this, 'selectRenderer'], $priority);
|
||||
$this->listeners[] = $events->attach(ViewEvent::EVENT_RESPONSE, [$this, 'injectResponse'], $priority);
|
||||
}
|
||||
|
||||
public function detach(EventManagerInterface $events)
|
||||
{
|
||||
foreach ($this->listeners as $index => $listener) {
|
||||
$events->detach($listener);
|
||||
unset($this->listeners[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
public function selectRenderer(ViewEvent $e)
|
||||
{
|
||||
if (!$this->renderer->canRender($e->getModel())) {
|
||||
return false;
|
||||
}
|
||||
return $this->renderer;
|
||||
}
|
||||
|
||||
public function injectResponse(ViewEvent $e)
|
||||
{
|
||||
$renderer = $e->getRenderer();
|
||||
if ($renderer !== $this->renderer) {
|
||||
return false;
|
||||
}
|
||||
$result = $e->getResult();
|
||||
$response = $e->getResponse();
|
||||
$response->setContent($result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user