Add command for Doctrine metadata generating
[MAILPOET-2014]
This commit is contained in:
20
RoboFile.php
20
RoboFile.php
@ -301,6 +301,15 @@ class RoboFile extends \Robo\Tasks {
|
||||
);
|
||||
}
|
||||
|
||||
function doctrineGenerateMetadata() {
|
||||
$metadata_dir = \MailPoet\Doctrine\ConfigurationFactory::METADATA_DIR;
|
||||
$this->_exec("rm -rf $metadata_dir");
|
||||
|
||||
$entity_manager = $this->createDoctrineEntityManager();
|
||||
$entity_manager->getMetadataFactory()->getAllMetadata();
|
||||
$this->say("Doctrine metadata generated to: $metadata_dir");
|
||||
}
|
||||
|
||||
function qa() {
|
||||
$collection = $this->collectionBuilder();
|
||||
$collection->addCode([$this, 'qaLint']);
|
||||
@ -902,4 +911,15 @@ class RoboFile extends \Robo\Tasks {
|
||||
$php_config->usePersistent();
|
||||
return $exitCode;
|
||||
}
|
||||
|
||||
private function createDoctrineEntityManager() {
|
||||
define('ABSPATH', getenv('WP_ROOT') . '/');
|
||||
\MailPoet\Config\Env::$db_prefix = '';
|
||||
$configuration = (new \MailPoet\Doctrine\ConfigurationFactory(true))->createConfiguration();
|
||||
$platform_class = \MailPoet\Doctrine\ConnectionFactory::PLATFORM_CLASS;
|
||||
return \MailPoetVendor\Doctrine\ORM\EntityManager::create([
|
||||
'driver' => \MailPoet\Doctrine\ConnectionFactory::DRIVER,
|
||||
'platform' => new $platform_class,
|
||||
], $configuration);
|
||||
}
|
||||
}
|
||||
|
4
build.sh
4
build.sh
@ -27,6 +27,10 @@ echo '[BUILD] Building DI Container cache'
|
||||
./composer.phar install
|
||||
./do container:dump
|
||||
|
||||
# Generate Doctrine metadata
|
||||
echo '[BUILD] Generating Doctrine Metadata'
|
||||
./do doctrine:generate-metadata
|
||||
|
||||
# Backup dev libraries
|
||||
echo '[BUILD] Backup dev dependencies'
|
||||
if [ -d 'vendor' ]; then
|
||||
|
@ -19,8 +19,8 @@ class ConfigurationFactory {
|
||||
/** @var bool */
|
||||
private $is_dev_mode;
|
||||
|
||||
function __construct() {
|
||||
$this->is_dev_mode = WP_DEBUG;
|
||||
function __construct($is_dev_mode = null) {
|
||||
$this->is_dev_mode = $is_dev_mode === null ? WP_DEBUG : $is_dev_mode;
|
||||
}
|
||||
|
||||
function createConfiguration() {
|
||||
|
Reference in New Issue
Block a user