Created
October 23, 2012 16:20
-
-
Save umpirsky/3939837 to your computer and use it in GitHub Desktop.
Use the entity form type in Silex
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 | |
$app['form.extensions'] = $app->share($this->extend('form.extensions', function ($extensions) { | |
$managerRegistry = new ManagerRegistry(null, array(), array('doctrine_orm.em'), null, null, $app['doctrine_orm.proxies_namespace']); | |
$managerRegistry->setContainer($app); | |
$extensions[] = new DoctrineOrmExtension($managerRegistry); | |
return $extensions; | |
})); |
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 Umpirsky\Doctrine\Common\Persistance; | |
use Doctrine\Common\Persistence\AbstractManagerRegistry; | |
use Silex\Application; | |
/** | |
* References Doctrine connections and entity/document managers. | |
* | |
* @author Саша Стаменковић <[email protected]> | |
*/ | |
class ManagerRegistry extends AbstractManagerRegistry | |
{ | |
/** | |
* @var Application | |
*/ | |
protected $container; | |
protected function getService($name) | |
{ | |
return $this->container[$name]; | |
} | |
protected function resetService($name) | |
{ | |
unset($this->container[$name]); | |
} | |
public function getAliasNamespace($alias) | |
{ | |
throw new \BadMethodCallException('Namespace aliases not supported.'); | |
} | |
public function setContainer(Application $container) | |
{ | |
$this->container = $container; | |
} | |
} |
replace $this->extend with $app->extend
and add $app here:
function ($extensions, $app)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$managerRegistry = new ManagerRegistry(null, array(), array('doctrine_orm.em'), null, null, $app['doctrine_orm.proxies_namespace']); doesn't work.
I use:
$managerRegistry = new ManagerRegistry(null, array(), array('doctrine_orm.em'), null, null, '\Doctrine\ORM\Proxy\Proxy');