Created
February 17, 2013 14:03
-
-
Save Burgov/4971612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// namespace stuff... | |
class FriendSelectorType extends AbstractType | |
{ | |
public function setDefaultOptions(OptionsResolverInterface $resolver) | |
{ | |
$resolver->setRequired(array('user')); | |
$resolver->setDefaults(array( | |
'class' => 'Acme\WhateverBundle\Document\User', | |
'multiple' => false, | |
'expanded' => false, | |
'property' => 'title', | |
'query_builder' => function(Options $options) { | |
$user = $options['user']; | |
return function(DocumentRepository $dr) use ($user) { | |
return $dr->createQueryBuilder()->field('friends.$id')->equals(new \MongoId($user->getId())); | |
}; | |
} | |
)); | |
} | |
public function getParent() | |
{ | |
return 'document'; | |
} | |
public function getName() | |
{ | |
return 'friend_selector'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment