Skip to content

Instantly share code, notes, and snippets.

View AmauryCarrade's full-sized avatar
🍊
I don't hate you

Amaury Carrade AmauryCarrade

🍊
I don't hate you
View GitHub Profile
<?php
// src/Zm/UserBundle/Entity/User.php
namespace Zm\UserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
@AmauryCarrade
AmauryCarrade / al.php
Created July 2, 2012 21:48
Session management in AL
<?php
// Session management
# Get session for an easier access
$session = $_SESSION[$settings['session']];
$datetime = new \Datetime();
# Saving current page in session history
$session['history'][] = array(
'page' => $dump->url,
<?php
// Blabla
public function ChangeLanguageAction()
{
$request = $this->get('request');
$language = $request->query->get('language');
$userManager = $this->get('fos_user.user_manager');
{% for key, flash in app.session.get('flashes') %}
{# Affichage #}
{{ app.session.set('flashes', '') }}
{% endfor %}
{% for key, val in app.sessio %}
{{ key }} => {{ val }} <br />
{% else %}
Rien à lister
{% endfor %}
{% set var = '' %}
{% if var is not null %}
<h1>It's work!</h1>
<!-- N'y voit pas de référence à une tribu. Non non. -->
{% endif %}
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="{{ asset('js/bootstrap.js') }}"></script>
@AmauryCarrade
AmauryCarrade / OrganisationLiens
Created July 10, 2012 23:03
Organisation des liens passés au TPL de la carte
Array (
category => Array (
link1 => Array (
href => L'attribut « href » du lien en question.
id => L'identifiant de l'élément, pour permettre des interactions avancées.
label => Le texte (traduis) à afficher.
)
link2 => Array ( ... )
)
)
<?php
# In a controller
$cardTemplateID = // Some logic to get this identifier
$infos = // Idem for user infos
$links = // Idem for links
$HTMLCard = $this->renderView('ZmCardStorageBundle:Cards:' . $cardTemplateID . '.html.twig', array(
'infos' => $infos,
'links' => $links
@AmauryCarrade
AmauryCarrade / Markdown.php
Created August 7, 2012 19:22
Version « service » du parseur Markdown
<?php
namespace Photos\PhotosBundle\Service;
#
# Markdown Extra - A text-to-HTML conversion tool for web writers
#
# PHP Markdown & Extra
# Copyright (c) 2004-2008 Michel Fortin
# <http://www.michelf.com/projects/php-markdown/>
#
# Original Markdown