/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->logSection('Diem Extended', 'Setup ' . dmProject::getKey());
     $this->dispatcher->notify(new sfEvent($this, 'dm.setup.before', array('clear-db' => $options['clear-db'])));
     // don't use cache:clear task because it changes current app & environment
     @sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
     if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'))) {
         $this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineRecord.php'));
     }
     if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'))) {
         $this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineQuery.php'));
     }
     if (!file_exists(dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineTable.php'))) {
         $this->getContext()->get('filesystem')->copy(dmOs::join(sfConfig::get('dm_core_dir'), 'data', 'skeleton', 'lib', 'model', 'doctrine', 'myDoctrineTable.php'), dmOs::join(sfConfig::get('sf_root_dir'), 'lib', 'model', 'doctrine', 'myDoctrineTable.php'));
     }
     $this->runTask('doctrine:build', array(), array('model' => true));
     if ($options['clear-db'] || $options['clear-tables'] || $this->isProjectLocked()) {
         $this->reloadAutoload();
         if ($options['clear-db']) {
             $this->runTask('doctrine:drop-db', array(), array('env' => $options['env'], 'no-confirmation' => dmArray::get($options, 'no-confirmation', false)));
         } else {
             $this->runTask('dm:drop-tables', array(), array('env' => $options['env']));
         }
         if ($options['clear-db'] && ($ret = $this->runTask('doctrine:build-db', array(), array('env' => $options['env'])))) {
             return $ret;
         }
         $this->runTask('doctrine:build-sql', array(), array('env' => $options['env']));
         $this->runTask('doctrine:insert-sql', array(), array('env' => $options['env']));
     } else {
         $this->runTask('dm:upgrade', array(), array('env' => $options['env']));
     }
     $this->reloadAutoload();
     $this->withDatabase();
     $this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
     $this->getContext()->reloadModuleManager();
     $this->runTask('doctrine:build-forms', array(), array('generator-class' => 'dmDoctrineFormGenerator'));
     $this->runTask('doctrine:build-filters', array(), array('generator-class' => 'dmDoctrineFormFilterGenerator'));
     $this->runTask('dm:publish-assets');
     $this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
     $this->reloadAutoload();
     $this->getContext()->reloadModuleManager();
     $this->runTask('dmAdmin:generate', array(), array('env' => $options['env']));
     if (!$options['dont-load-data']) {
         $this->runTask('dm:data', array(), array('load-doctrine-data' => $options['load-doctrine-data'], 'env' => $options['env']));
     }
     $this->logSection('Diem Extended', 'generate front modules');
     if (!($return = $this->context->get('filesystem')->sf('dmFront:generate --env=' . dmArray::get($options, 'env', 'dev')))) {
         $this->logBlock(array('Can\'t run dmFront:generate: ' . $this->context->get('filesystem')->getLastExec('output'), 'Please run "php symfony dmFront:generate" manually to generate front templates'), 'ERROR');
     }
     $this->runTask('dm:permissions');
     // fix db file permissions
     if ('Sqlite' === Doctrine_Manager::connection()->getDriverName()) {
         $this->filesystem->chmod(sfConfig::get('sf_data_dir'), 0777, 00);
     }
     $this->runTask('dm:clear-cache', array(), array('env' => $options['env']));
     $this->dispatcher->notify(new sfEvent($this, 'dm.setup.after', array('clear-db' => $options['clear-db'])));
     $this->logBlock('Setup successful', 'INFO_LARGE');
     $this->unlockProject();
 }
Beispiel #2
0
 protected function loadUsers()
 {
     if (!($superAdmin = dmDb::query('DmUser u')->where('u.is_super_admin = ?', true)->count())) {
         $password = Doctrine_Manager::connection()->getOption('password');
         if (empty($password)) {
             $password = '******';
         }
         dmDb::create('DmUser', array('is_super_admin' => true, 'username' => 'admin', 'password' => $password, 'email' => 'admin@' . dmProject::getKey() . '.com'))->save();
     }
 }
Beispiel #3
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->withDatabase();
     $this->logSection('diem', 'Upgrade ' . dmProject::getKey());
     foreach ($this->diemVersions as $version) {
         $upgradeMethod = 'upgradeTo' . ucfirst($version);
         try {
             $this->{$upgradeMethod}();
         } catch (Exception $e) {
             $this->logBlock('Can not upgrade to version ' . $version . ' : ' . $e->getMessage(), 'ERROR');
         }
     }
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $this->withDatabase();
     $this->logSection('Diem Extended', 'Upgrade ' . dmProject::getKey());
     foreach ($this->changes as $change) {
         $upgradeMethod = 'upgradeTo' . ucfirst($change);
         try {
             $this->{$upgradeMethod}();
         } catch (Exception $e) {
             $this->logBlock('Can not upgrade to change ' . $change . ' : ' . $e->getMessage(), 'ERROR');
         }
     }
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $filesystem = $this->get('filesystem');
     $uploadDir = dmOs::join(sfConfig::get('sf_web_dir'), 'uploads');
     if (!$filesystem->mkdir($uploadDir)) {
         throw new dmException(dmProject::unRootify($uploadDir) . ' is not writable');
     }
     $cacheDir = dmOs::join(sfConfig::get('sf_cache_dir'), 'open_package', dmProject::getKey());
     if (!$filesystem->mkdir($cacheDir)) {
         throw new dmException(dmProject::unRootify($cacheDir) . ' is not writable');
     }
     $filesystem->deleteDirContent($cacheDir);
     if (file_exists(dmOs::join($uploadDir, dmProject::getKey() . '.tgz'))) {
         $filesystem->unlink(dmOs::join($uploadDir, dmProject::getKey() . '.tgz'));
     }
     $this->log('Building the package, please wait...');
     $finder = sfFinder::type('all')->prune(array('.thumbs'))->discard(array('.thumbs'));
     foreach (array('apps', 'config', 'lib', 'plugins', 'public_html', 'test') as $dir) {
         $filesystem->mirror(dmOs::join(sfConfig::get('sf_root_dir'), $dir), dmOs::join($cacheDir, $dir), $finder);
     }
     $filesystem->copy(dmOs::join(sfConfig::get('sf_root_dir'), 'symfony'), dmOs::join($cacheDir, 'symfony'));
     foreach (array('cache', 'data') as $dir) {
         $filesystem->mkdir(dmOs::join($cacheDir, $dir));
     }
     if (file_exists(dmOs::join(sfConfig::get('sf_data_dir'), 'mysql'))) {
         $filesystem->mirror(dmOs::join(sfConfig::get('sf_data_dir'), 'mysql'), dmOs::join($cacheDir, 'data/mysql'), sfFinder::type('all'));
     }
     $databasesFile = dmOs::join($cacheDir, 'config/databases.yml');
     $databasesConfig = sfYaml::load($databasesFile);
     foreach ($databasesConfig as $namespace => $nsConfig) {
         foreach ($nsConfig as $dbName => $config) {
             $dsn = $databasesConfig[$namespace][$dbName]['param']['dsn'];
             $databasesConfig[$namespace][$dbName]['param']['dsn'] = preg_replace('#//(.+)\\:(.*)@#', '//#DB_USER#:#DB_PASSWORD#@', $dsn);
             foreach (array('username', 'password') as $key) {
                 if (isset($databasesConfig[$namespace][$dbName]['param'][$key])) {
                     unset($databasesConfig[$namespace][$dbName]['param'][$key]);
                 }
             }
         }
         file_put_contents($databasesFile, sfYaml::dump($databasesConfig, 5));
     }
     $filesystem->unlink(dmOs::join($cacheDir, 'test/functional'));
     $command = 'cd ' . dirname($cacheDir) . '; tar -czf ' . dmProject::getKey() . '.tgz ' . dmProject::getKey();
     $this->logSection('Compression', $command);
     if (!$filesystem->exec($command)) {
         throw new dmException($filesystem->getLastExec('output'));
     }
     rename(dmOs::join(dirname($cacheDir), dmProject::getKey() . '.tgz'), dmOs::join($uploadDir, dmProject::getKey() . '.tgz'));
     $filesystem->unlink($cacheDir);
     $this->logBlock('Done !', 'INFO');
 }
Beispiel #6
0
<?php

require_once realpath(dirname(__FILE__) . '/../../..') . '/unit/helper/dmModuleUnitTestHelper.php';
$helper = new dmModuleUnitTestHelper();
$helper->boot();
$t = new lime_test(10);
$models = dmProject::getModels();
$dmModels = dmProject::getDmModels();
$allModels = dmProject::getAllModels();
$t->is_deeply($models, $expected = array('DmTestCateg', 'DmTestComment', 'DmTestDomainCateg', 'DmTestDomain', 'DmTestFruit', 'DmTestPost', 'DmTestPostTag', 'DmTestTag', 'DmTestUser', 'DmContact', 'DmTag'), 'dmProject::getModels() -> ' . implode(', ', $expected));
$t->is_deeply(array_intersect($models, $allModels), $models, 'dmProject::getAllModels() contain all project models');
$t->is_deeply(array_intersect($dmModels, $allModels), $dmModels, 'dmProject::getAllModels() contain all Diem models');
$t->is_deeply(array_intersect($models, $dmModels), array(), 'dmProject::getDmModels() contain no project models');
$t->is_deeply(array_intersect($dmModels, $models), array(), 'dmProject::getModels() contain no Diem models');
$t->is(count($dmModels), $expected = 17, 'Diem has ' . $expected . ' models');
$t->is(dmProject::getKey(), 'project', 'project key is "project"');
$t->ok(dmProject::appExists('front'), 'project has a front app');
$t->ok(dmProject::appExists('admin'), 'project has a admin app');
$t->ok(!dmProject::appExists('bluk'), 'project has no bluk app');
Beispiel #7
0
try {
    $serverCheck->run();
} catch (dmServerCheckException $e) {
    if (!$this->askConfirmation('Do you want to continue the installation ? (y/n)')) {
        $this->log('Aborted.');
        exit;
    }
}
/*
 * INITIALIZATION
 */
$settings = array();
if ('Doctrine' != $this->options['orm']) {
    throw new Exception('We are sorry, but Diem ' . DIEM_VERSION . ' supports only Doctrine for ORM.');
}
$projectKey = dmProject::getKey();
/*
 * QUESTIONS
 */
$this->logSection($projectKey, 'Please answer a few questions to configure the ' . $projectKey . ' project' . "\n");
$culture = $this->askAndValidate(array('', 'Choose your site\'s main language ( default: en )', ''), new sfValidatorRegex(array('pattern' => '/^[\\w\\d-]+$/', 'max_length' => 2, 'min_length' => 2, 'required' => false), array('invalid' => 'Language must contain two alphanumeric characters')));
$settings['culture'] = empty($culture) ? 'en' : $culture;
$webDirName = $this->askAndValidate(array('', 'Choose a web directory name ( examples: web, html, public_html;  default: web )', ''), new sfValidatorAnd(array(new sfValidatorRegex(array('pattern' => '/^[\\w\\d-]+$/', 'required' => false), array('invalid' => 'Web directory name must contain only alphanumeric characters')), new sfValidatorRegex(array('pattern' => '/^(apps|lib|config|data|cache|log|plugins|test)$/', 'must_match' => false, 'required' => false), array('invalid' => 'This directory name is already used by symfony'))), array('required' => false)), array('required' => false));
$settings['web_dir_name'] = empty($webDirName) ? 'web' : $webDirName;
do {
    $defaultDbName = dmString::underscore(str_replace('-', '_', $projectKey));
    $isDatabaseOk = false;
    $dbm = $this->askAndValidate(array('', 'What kind of database will be used? ( mysql | pgsql | sqlite )', ''), new sfValidatorChoice(array('choices' => array('mysql', 'pgsql', 'sqlite'))));
    if ('sqlite' !== $dbm) {
        $settings['database'] = array('name' => $this->ask(array('', 'What is the database name? ( default: ' . $defaultDbName . ' )', ''), 'QUESTION', $defaultDbName), 'host' => $this->ask(array('', 'What is the database host? ( default: localhost )', ''), 'QUESTION', 'localhost', ''), 'user' => $this->ask(array('', 'What is the database user?', '')), 'password' => $this->ask(array('', 'What is the database password?', '')));
    } else {