Symfony\Bridge\Doctrine\RegistryInterface::getRepository PHP Method

getRepository() public method

Gets the EntityRepository for an entity.
public getRepository ( string $entityName, $entityManagerName = null ) : Doctrine\ORM\EntityRepository
$entityName string The name of the entity.
return Doctrine\ORM\EntityRepository
    function getRepository($entityName, $entityManagerName = null);

Usage Example

 /**
  * @inheritdoc
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     /** @var ChoiceView $choice */
     foreach ($view->vars['choices'] as $choice) {
         if ($options['select2_template_result']) {
             $object = $choice->value;
             if ($this->doctrine && $options['class']) {
                 $object = $this->doctrine->getRepository($options['class'])->find($object);
             }
             if (is_string($options['select2_template_result'])) {
                 $choice->attr['data-template-result'] = $this->templating->render($options['select2_template_result'], ['choice' => $choice, 'object' => $object]);
             } else {
                 $choice->attr['data-template-result'] = call_user_func_array($options['select2_template_result'], [$choice, $object]);
             }
         }
         if ($options['select2_template_selection']) {
             $object = $choice->value;
             if ($this->doctrine && $options['class']) {
                 $object = $this->doctrine->getRepository($options['class'])->find($object);
             }
             if (is_string($options['select2_template_selection'])) {
                 $choice->attr['data-template-selection'] = $this->templating->render($options['select2_template_selection'], ['choice' => $choice, 'object' => $object]);
             } else {
                 $choice->attr['data-template-selection'] = call_user_func_array($options['select2_template_selection'], [$choice, $object]);
             }
         }
     }
     if ($options['select2'] === true) {
         $options['select2_options'] = array_merge($this->select2DefaultOptions, $options['select2_options']);
         $view->vars['select2_options'] = json_encode($options['select2_options']);
     }
 }
All Usage Examples Of Symfony\Bridge\Doctrine\RegistryInterface::getRepository