Skip to content

Instantly share code, notes, and snippets.

View Esolutions-Design's full-sized avatar

Esolutions Design Esolutions-Design

View GitHub Profile
@Esolutions-Design
Esolutions-Design / Include with parameters
Created September 29, 2013 19:29
Include with parameters
{% include 'EsolutionsAdminBundle:Order/display/listing:list.html.twig' with {'orders': entities} %}
@Esolutions-Design
Esolutions-Design / Comparaison de date
Created September 8, 2013 18:48
Comparaison de date
{% if "now"|date('Ymd') > entity.date|date('Ymd') %}
$file = $this->getRequest()->files->get('esolutions_adminbundle_prestationtype');
if(!empty($file['logo'])) {
$extention = $file['logo']->guessExtension();
if($extention === 'jpeg' || $extention === 'png') {
$entity->setPathLogo($file['logo']);
$entity->setLogo($file['logo']);
} else {
$this->get('session')->getFlashBag()->add('error', 'Le format de votre image n\'est pas autorisé, elle doit être au format Png ou Jpeg.');
@Esolutions-Design
Esolutions-Design / A partir de là, vous pouvez depuis votre template utiliser le filtre Truncate, avec la syntaxe suivante :
Created August 3, 2013 16:35
Pour l’activer, rendez vous dans votre config.yml, et rajoutez dans le service suivant :
{# in twig template #}
{{ myString | truncate(20, false, '') }}
{# cette première utilsation coupe directement la chaîne myString #}
{{ myString | truncate(20, true, '...') }}
{# cette deuxieme utilsation coupe la chaîne myString en rajoutant ' ... '
ns3327676.ovh.net -
sdns2.ovh.net
/**
* Display widget last products.
*
* @Template("EsolutionsProductBundle:Product\widgets:last_products.html.twig")
*/
public function lastProductsAction($nb_products = 10) {
$em = $this->getDoctrine()->getManager();
$products = $em->getRepository('EsolutionsProductBundle:Product')->findBy(array(), array('last_update' => 'DESC'), $nb_products);
$data = $this->getRequest()->request->get('form');
/**
* Get the current logged in User Object
* @return \Symfony\Component\Security\Core\User\User
*/
private function getUser(){
return $this->get('security.context')->getToken()->getUser();
}
<?php
// AppKernel.php
class AppKernel extends Kernel
{
//..
//.......
//...........
// --- Append the init function below ---
$this->get('session')->getFlashBag()->add('notice', 'Your changes were saved!');