DoctrineChoiceLoader example

// Unless the choices are given explicitly, load them on demand             if (null === $options['choices']) {
                // If there is no QueryBuilder we can safely cache                 $vary = [$options['em']$options['class']];

                // also if concrete Type can return important QueryBuilder parts to generate                 // hash key we go for it as well, otherwise fallback on the instance                 if ($options['query_builder']) {
                    $vary[] = $this->getQueryBuilderPartsForCachingHash($options['query_builder']) ?? $options['query_builder'];
                }

                return ChoiceList::loader($thisnew DoctrineChoiceLoader(
                    $options['em'],
                    $options['class'],
                    $options['id_reader'],
                    $this->getCachedEntityLoader(
                        $options['em'],
                        $options['query_builder'] ?? $options['em']->getRepository($options['class'])->createQueryBuilder('e'),
                        $options['class'],
                        $vary
                    )
                )$vary);
            }

            
->method('getClassMetadata')
            ->with($this->class)
            ->willReturn(new ClassMetadata($this->class));
        $this->repository->expects($this->any())
            ->method('findAll')
            ->willReturn([$this->obj1, $this->obj2, $this->obj3])
        ;
    }

    public function testLoadChoiceList()
    {
        $loader = new DoctrineChoiceLoader(
            $this->om,
            $this->class,
            $this->idReader
        );

        $choices = [$this->obj1, $this->obj2, $this->obj3];
        $value = function D) {};
        $choiceList = new ArrayChoiceList($choices$value);

        $this->repository->expects($this->once())
            ->method('findAll')
            
Home | Imprint | This part of the site doesn't use cookies.