Skip to content

Instantly share code, notes, and snippets.

View khepin's full-sized avatar

Sebastien Armand khepin

  • San Francisco, USA
View GitHub Profile
<?php
namespace Khepin\UserValidatorBundle\Aop;
use JMS\AopBundle\Aop\PointcutInterface;
use Doctrine\Common\Annotations\Reader;
/**
* Pointcut for all calls to a method that requires validating the user
*/
class Pointcut implements PointcutInterface
<?php
namespace Khepin\UserValidatorBundle\Annotation;
/**
* @Annotation
* Annotation to validate a user or redirect him to his profile edit page if
* the profile is not valid according to the given validation groups
*/
final class ValidateUser
<?php
class SomeController
{
/**
* @ValidateUser("ticket_checkout", route="profile_edit")
*/
public function checkoutAction(){
// proceed to checkout
}
<?php
class SomeController
{
public function checkoutAction(){
$user = $this->get('security.context')->getToken()->getUser();
$errors = $this->get('validator')->validate($user, 'ticket_checkout');
if(count($errors) > 0) {
// Add a warning message to the session
// Redirect user to a profile edit page where he can setup the missing info
<?php
use Doctrine\DBAL\Types\Type;
Type::addType('geotype', 'Powwow\NewdbBundle\Types\GeoType');
<?php
//....
/**
* @var string $location
*
* @ORM\Column(name="location", type="geotype")
*/
private $location;
<?php
namespace Powwow\NewdbBundle\Types;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* My custom datatype.
*/
class GeoType extends Type
<div class="hero-unit">
<section class="container-top-left">
<h2>Life is about FUN!</h2>
<h3 class="slogan">Get active. Get social. Get organized.</h3>
<p class="intro"><small>With mashup sports you will find "mashups" where everyone gets
active and social. Get started by searching for a mashup or organizing your own mashup.</small></p>
<span class="row"><!-- this should probably be a DIV instead of a span -->
<span class="organize-btn"><!-- see what the css for this could look like to have a bigger button -->
<a class="btn btn-primary btn-large" id="organize">Organize a mashup</a>
</span>
<?php
namespace Khepin;
use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
class DoctrineProxyIdRetrievalStrategy implements ObjectIdentityRetrievalStrategyInterface {
const PROXY_CLASS_NAME = 'Doctrine\ORM\Proxy\Proxy';
#config.yml
services:
security.acl.object_identity_retrieval_strategy:
class: Khepin\DoctrineProxyIdRetrievalStrategy