execute any function in Extension
Notice: This thread is very old.
- fan2misa
- Member | 6
Hi everybody ^^,
I want to install Doctrine 2 in Nette Framework. And I want to set Entity
Namespace.
I wrote this in config.neon :
production:
parameters:
database:
driver: pdo_mysql
host: localhost
user: root
password:
dbname: test
php:
date.timezone: Europe/Paris
...
doctrine:
entities:
Backend: /App/Backend/Model
Frontend: /App/Frontend/Model
...
And I wrote this in app/bootstrap.php :
...
$configurator->onCompile[] = function ($configurator, $compiler) {
$compiler->addExtension('doctrine', new App\lib\Config\Doctrine());
};
...
And I have this in app/lib/Config/Doctrine :
namespace App\lib\Config;
use Nette\DI\CompilerExtension;
class Doctrine extends CompilerExtension {
public function loadConfiguration() {
$config = $this->getConfig();
$this->getContainerBuilder()
->addDefinition($this->prefix('configuration'))
->setFactory('\Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration', array($config['entities'], false));
}
}
And in this loadConfiguration() function, I need instance of \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration for execute method setEntityNamespace()
Could you help me for this problem ? Thx