Skip to content

Instantly share code, notes, and snippets.

<?php
// src/Acme/TaskBundle/Controller/DefaultController.php
// ajoutez cette nouvelle déclaration « use » en haut de la classe
use Acme\TaskBundle\Form\Type\TaskType;
public function newAction()
{
$task = // Mon objet de base a partir du quel je crée le form
$form = $this->createForm(new TaskType(), $task);
<?php
$result = $res_new_indispoGroupBy->fetchAll();
foreach($result as $k => $v)
{
//Si il y a plussieur result
}
if (0 === count(result)) {
//Else
}
SELECT
*
FROM AppliControle AS ac
INNER JOIN applicontrole_controlinterne AS aci ON aci.applicontrole_id = ac.id
INNER JOIN ControlInterne AS ci ON aci.controlinterne_id = ci.id
INNER JOIN Task AS t ON ci.task_id = t.id
INNER JOIN (
SELECT
aci2.applicontrole_id AS id,
max(t2.date) as recent
{% for item in appliControle %}
{% set htmlFile = "" %}
{% set isPerime = false %}
{% for file in item.DataFileNeeded %}
{% set htmlFile = htmlFile~ "<li>" %}
{% set htmlFile = htmlFile~ file.name %}
{% if file.lastUpdate.date|date('Y-m-d') == "now"|date('Y-m-d') %}
{% set htmlFile = htmlFile~ '<span class="uk-badge uk-badge-success uk-float-right">Récent</span>' %}
{% elseif file.lastUpdate.date|date('Y-m-d') < "now"|date_modify('-2 Day')|date('Y-m-d') %}
{% set htmlFile = htmlFile~ '<span class="uk-badge uk-badge-danger uk-float-right">Périmé</span>' %}
<?php
namespace Shadow\WowBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function testAction()
{
@alborq
alborq / MenuBuilder.php
Created July 24, 2015 14:12
KNPMenuBuilder, WIth Event how to order element => solution
<?php
namespace xxxx\Menu;
use Knp\Menu\FactoryInterface;
use Knp\Menu\ItemInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
use xxx\Event\ConfigureMenuEvent;
class MenuBuilder extends ContainerAware
@alborq
alborq / CodingGame.php
Created September 20, 2015 19:04
Gist for codingame, PHP dump for error output.
/**
* Envoi un var_dump dans la sortie erreur
* @param mixed $var
*/
function dump($var){
ob_start();
var_dump($var);
$result = ob_get_clean();
fwrite(STDERR,$result);
}
@alborq
alborq / srm.php
Last active February 9, 2016 18:42
<?php
$mapperConfiguration = new MapperConfiguration();
static class MapperCallableHelper{
protected static $attributName = "";
protected static $setterCallable = function(Mapper $mapper, $object, $value){
$method = 'set'.ucfirst(self::$attributName);
$object->$method($value);
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
require 'capifony_symfony2'
load 'app/config/deploy'
@alborq
alborq / DocumentationNormalizer.php
Last active July 21, 2020 11:14
API-Platform Use JWT Token to auth, Add JWT in documentation | Api-platofrm, JWT, PHP, Documentation, Security, Swagger
<?php
namespace AppBundle\Documentation;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
/**
* Class DocumentationNormalizer
* @package AppBundle\Documentation