Skip to content

Instantly share code, notes, and snippets.

@Koalabaerchen
Koalabaerchen / LocaleListener.php
Created November 24, 2015 16:45
Locale Sessions in Symfony
<?php
class LocaleListener implements EventSubscriberInterface
{
private $defaultLocale;
public function __construct($defaultLocale = User::DEFAULT_LOCALE)
{
$this->defaultLocale = $defaultLocale;
}
@Koalabaerchen
Koalabaerchen / MenuBuilder.php
Created October 15, 2015 14:49 — forked from nateevans/MenuBuilder.php
KNP Menu Bundle with Bootstrap 3 and Font Awesome 4 (see http://bit.ly/1sd1rJr , thanks to Niels Mouthaan!)
<?php
namespace Acme\HelloBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class MenuBuilder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
@Koalabaerchen
Koalabaerchen / MaintenanceListener.php
Last active March 11, 2023 18:31
Maintenance Mode for Symfony
<?php
/**
* Based on http://www.wenigersh.com/blog/post/maintenance-mode-for-symfony-2-applications
*
* Includes support of user permisson check (here: check if user has role ADMIN), so admins can still surf the site while in maintenance mode
* Be aware that if you clear the cache (to start maintenance in prod environment) your sessions might be cleared as well, so people get logged out
* The config.yml will move the sessions to /app/sessions/[environment]
*
* Also be aware that you need at least Symfony 2.6 for this permission check. For older versions the call is different
* @see http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@Koalabaerchen
Koalabaerchen / User.php
Last active August 29, 2015 14:08
FOSUserBundle + HWIOAuthBundle + EVE Online SSO
<?php
namespace Acme\UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
/**
* User
*
<?php
namespace Dpn\ToolsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Dpn\ToolsBundle\Form\DataTransformer\EntityToIdTransformer;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Doctrine\Common\Persistence\ObjectManager;
@Koalabaerchen
Koalabaerchen / 0_reuse_code.js
Created April 23, 2014 11:02
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console