Skip to content

Commit

Permalink
Merge pull request doctrine#67 from stof/forms
Browse files Browse the repository at this point in the history
Refactored the form integration to use the bridge
  • Loading branch information
jwage committed Dec 23, 2011
2 parents 8f831c7 + 4fa156e commit 1ddf367
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 1,030 deletions.
251 changes: 0 additions & 251 deletions Form/ChoiceList/DocumentChoiceList.php

This file was deleted.

71 changes: 71 additions & 0 deletions Form/ChoiceList/MongoDBQueryBuilderLoader.php
@@ -0,0 +1,71 @@
<?php

/*
* This file is part of the Doctrine MongoDBBundle
*
* The code was originally distributed inside the Symfony framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
* (c) Doctrine Project
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Doctrine\Bundle\MongoDBBundle\Form\ChoiceList;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\MongoDB\Query\Builder;
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityLoaderInterface;
use Symfony\Component\Form\Exception\FormException;
use Symfony\Component\Form\Exception\UnexpectedTypeException;

/**
* Getting Entities through the MongoDB QueryBuilder
*/
class MongoDBQueryBuilderLoader implements EntityLoaderInterface
{
/**
* Contains the query builder that builds the query for fetching the
* entities
*
* This property should only be accessed through queryBuilder.
*
* @var Builder
*/
private $queryBuilder;

/**
* Construct an ORM Query Builder Loader
*
* @param Builder|\Closure $queryBuilder
* @param ObjectManager $manager
* @param string $class
*/
public function __construct($queryBuilder, ObjectManager $manager = null, $class = null)
{
// If a query builder was passed, it must be a closure or QueryBuilder
// instance
if (!($queryBuilder instanceof Builder || $queryBuilder instanceof \Closure)) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ODM\MongoDB\Query\Builder or \Closure');
}

if ($queryBuilder instanceof \Closure) {
$queryBuilder = $queryBuilder($manager->getRepository($class));

if (!$queryBuilder instanceof Builder) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ODM\MongoDB\Query\Builder');
}
}

$this->queryBuilder = $queryBuilder;
}

/**
* {@inheritDoc}
*/
public function getEntities()
{
return $this->queryBuilder->getQuery()->execute();
}
}
75 changes: 0 additions & 75 deletions Form/DataTransformer/DocumentToIdTransformer.php

This file was deleted.

0 comments on commit 1ddf367

Please sign in to comment.