本文整理汇总了PHP中Doctrine_Lib::removeDirectories方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Lib::removeDirectories方法的具体用法?PHP Doctrine_Lib::removeDirectories怎么用?PHP Doctrine_Lib::removeDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Lib
的用法示例。
在下文中一共展示了Doctrine_Lib::removeDirectories方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testImport
public function testImport()
{
$this->dbh = new PDO('sqlite::memory:');
$this->dbh->exec('CREATE TABLE import_test_user (id INTEGER PRIMARY KEY, name TEXT)');
$this->conn = Doctrine_Manager::connection($this->dbh, 'tmp123');
$this->conn->import->importSchema('Import/_files', array('tmp123'));
$this->assertTrue(file_exists('Import/_files/ImportTestUser.php'));
$this->assertTrue(file_exists('Import/_files/generated/BaseImportTestUser.php'));
Doctrine_Lib::removeDirectories('Import/_files');
}
示例2: testYmlImport
public function testYmlImport()
{
$path = dirname(__FILE__) . '/import_builder_test';
$import = new Doctrine_Import_Schema();
$import->importSchema('schema.yml', 'yml', $path);
if (!file_exists($path . '/SchemaTestUser.php')) {
$this->fail();
}
if (!file_exists($path . '/SchemaTestProfile.php')) {
$this->fail();
}
$this->assertEqual(Doctrine::getTable('AliasTest')->getFieldName('test_col'), 'test_col_alias');
Doctrine_Lib::removeDirectories($path);
}
示例3: testImportOfHieriarchyOfPluginGeneration
public function testImportOfHieriarchyOfPluginGeneration()
{
$yml = <<<END
---
WikiTest:
actAs:
I18n:
fields: [title, content]
actAs:
Versionable:
fields: [title, content]
Searchable:
fields: [title, content]
Sluggable:
fields: [title]
columns:
title: string(255)
content: string
END;
file_put_contents('wiki.yml', $yml);
$path = dirname(__FILE__) . '/tmp/import_builder_test';
$import = new Doctrine_Import_Schema();
$import->setOption('generateTableClasses', true);
$import->importSchema('wiki.yml', 'yml', $path);
// check that the plugin hierarchy will produce the right sql statements
// this is almost an end-to-end testing :-)
$models = Doctrine::loadModels($path, Doctrine::MODEL_LOADING_CONSERVATIVE);
$sql = $this->conn->export->exportClassesSql(array('WikiTest'));
$result = array(
0 => 'CREATE TABLE wiki_test_translation_version (id INTEGER, lang CHAR(2), title VARCHAR(255), content VARCHAR(2147483647), version INTEGER, PRIMARY KEY(id, lang, version))',
1 => 'CREATE TABLE wiki_test_translation_index (id INTEGER, lang CHAR(2), keyword VARCHAR(200), field VARCHAR(50), position INTEGER, PRIMARY KEY(id, lang, keyword, field, position))',
2 => 'CREATE TABLE wiki_test_translation (id INTEGER, title VARCHAR(255), content VARCHAR(2147483647), lang CHAR(2), version INTEGER, slug VARCHAR(255), PRIMARY KEY(id, lang))',
3 => 'CREATE TABLE wiki_test (id INTEGER PRIMARY KEY AUTOINCREMENT)',
4 => 'CREATE INDEX sluggable_idx ON wiki_test_translation (slug)',
);
foreach($sql as $idx => $req) {
$this->assertEqual($req, $result[$idx]);
}
Doctrine_Lib::removeDirectories($path);
unlink('wiki.yml');
}
示例4: testClassExistsAfterImport
public function testClassExistsAfterImport()
{
Doctrine_Core::setModelsDirectory(dirname(__FILE__) . '/DC95/models');
$import = new Doctrine_Import_Schema();
$import->setOptions(array('pearStyle' => true, 'baseClassesDirectory' => null, 'baseClassPrefix' => 'Base_', 'classPrefix' => 'DC95_', 'classPrefixFiles' => true));
$modelsPath = dirname(__FILE__) . '/DC95/models';
$import->importSchema(dirname(__FILE__) . '/DC95/schema.yml', 'yml', $modelsPath);
/*
$this->assertTrue(file_exists($modelsPath . '/DC95/Base/Article.php'));
$this->assertTrue(file_exists($modelsPath . '/DC95/Base/Article/Category.php'));
$this->assertTrue(file_exists($modelsPath . '/DC95/Article.php'));
$this->assertTrue(file_exists($modelsPath . '/DC95/Article/Category.php'));
*/
Doctrine_Core::setModelsDirectory(null);
Doctrine_Lib::removeDirectories(dirname(__FILE__) . '/DC95/models');
}
示例5: update
/**
* Update the existing schema.yml file with any new tables that were passed
* to the method.
*
* @param string $outputFile The full path of the current schema file
* @param array $connections An associative array of connections and their
* tables. See buildPHPModels
* @param array $options Any options to be passed to
* Doctrine_Import_Builder
* @return type
*/
public function update($outputFile, array $connections = array(), array $options = array())
{
try {
$directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models';
$options['generateBaseClasses'] = isset($options['generateBaseClasses']) ? $options['generateBaseClasses'] : false;
$models = $this->buildPHPModels($directory, $connections, $options);
if (empty($models) && !is_dir($directory)) {
throw new Exception('No models generated from your databases');
}
$this->generateYaml($outputFile, $directory, array(), Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
Doctrine_Lib::removeDirectories($directory);
} catch (Exception $e) {
throw new Exception(__METHOD__ . ':' . __LINE__ . '|' . $e->getMessage());
}
return 0;
}
示例6: testTest
public function testTest()
{
$from = dirname(__FILE__) . '/Diff/schema/from.yml';
$to = dirname(__FILE__) . '/Diff/schema/to.yml';
$migrationsPath = dirname(__FILE__) . '/Diff/migrations';
Doctrine_Lib::makeDirectories($migrationsPath);
$diff = new Doctrine_Migration_Diff($from, $to, $migrationsPath);
$changes = $diff->generateChanges();
$this->assertEqual($changes['dropped_tables']['homepage']['tableName'], 'homepage');
$this->assertEqual($changes['created_tables']['blog_post']['tableName'], 'blog_post');
$this->assertEqual($changes['created_columns']['profile']['user_id'], array('type' => 'integer', 'length' => 8));
$this->assertEqual($changes['dropped_columns']['user']['homepage_id'], array('type' => 'integer', 'length' => 8));
$this->assertEqual($changes['dropped_columns']['user']['profile_id'], array('type' => 'integer', 'length' => 8));
$this->assertEqual($changes['changed_columns']['user']['username'], array('type' => 'string', 'length' => 255, 'unique' => true, 'notnull' => true));
$this->assertEqual($changes['created_foreign_keys']['profile']['profile_user_id_user_id']['local'], 'user_id');
$this->assertEqual($changes['created_foreign_keys']['blog_post']['blog_post_user_id_user_id']['local'], 'user_id');
$this->assertEqual($changes['dropped_foreign_keys']['user']['user_profile_id_profile_id']['local'], 'profile_id');
$this->assertEqual($changes['dropped_foreign_keys']['user']['user_homepage_id_homepage_id']['local'], 'homepage_id');
$this->assertEqual($changes['created_indexes']['blog_post']['blog_post_user_id'], array('fields' => array('user_id')));
$this->assertEqual($changes['created_indexes']['profile']['profile_user_id'], array('fields' => array('user_id')));
$this->assertEqual($changes['dropped_indexes']['user']['is_active'], array('fields' => array('is_active')));
$diff->generateMigrationClasses();
$files = glob($migrationsPath . '/*.php');
$this->assertEqual(count($files), 2);
$this->assertTrue(strpos($files[0], '_version1.php'));
$this->assertTrue(strpos($files[1], '_version2.php'));
$code1 = file_get_contents($files[0]);
$this->assertTrue(strpos($code1, 'this->dropTable'));
$this->assertTrue(strpos($code1, 'this->createTable'));
$this->assertTrue(strpos($code1, 'this->removeColumn'));
$this->assertTrue(strpos($code1, 'this->addColumn'));
$this->assertTrue(strpos($code1, 'this->changeColumn'));
$code2 = file_get_contents($files[1]);
$this->assertTrue(strpos($code2, 'this->dropForeignKey'));
$this->assertTrue(strpos($code2, 'this->removeIndex'));
$this->assertTrue(strpos($code2, 'this->addIndex'));
$this->assertTrue(strpos($code2, 'this->createForeignKey'));
Doctrine_Lib::removeDirectories($migrationsPath);
}
示例7: generateYamlFromDb
/**
* Generates models from database to temporary location then uses those models to generate a yaml schema file.
* This should probably be fixed. We should write something to generate a yaml schema file directly from the database.
*
* @param string $yamlPath Path to write oyur yaml schema file to
* @param array $connections Array of connection names to generate yaml for
* @param array $options Array of options
* @return void
*/
public static function generateYamlFromDb($yamlPath, array $connections = array(), array $options = array())
{
$directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models';
$options['generateBaseClasses'] = isset($options['generateBaseClasses']) ? $options['generateBaseClasses'] : false;
$result = Doctrine_Core::generateModelsFromDb($directory, $connections, $options);
if (empty($result) && !is_dir($directory)) {
throw new Doctrine_Exception('No models generated from your databases');
}
$export = new Doctrine_Export_Schema();
$result = $export->exportSchema($yamlPath, 'yml', $directory, array(), Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
Doctrine_Lib::removeDirectories($directory);
return $result;
}
示例8: _cleanup
/**
* Cleanup temporary generated models after a diff is performed
*
* @return void
*/
protected function _cleanup()
{
$modelFiles = Doctrine_Core::getLoadedModelFiles();
$filesToClean = array_diff($modelFiles, $this->_startingModelFiles);
foreach ($filesToClean as $file) {
if (file_exists($file)) {
unlink($file);
}
}
// clean up tmp directories
Doctrine_Lib::removeDirectories($this->_tmpPath . DIRECTORY_SEPARATOR . strtolower(self::$_fromPrefix) . '_doctrine_tmp_dirs');
Doctrine_Lib::removeDirectories($this->_tmpPath . DIRECTORY_SEPARATOR . strtolower(self::$_toPrefix) . '_doctrine_tmp_dirs');
}
示例9: generateMigrationsFromDb
/**
* generateMigrationsFromDb
*
* @return void
*/
public function generateMigrationsFromDb()
{
$directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models';
Doctrine::generateModelsFromDb($directory);
$result = $this->generateMigrationsFromModels($directory, Doctrine::MODEL_LOADING_CONSERVATIVE);
Doctrine_Lib::removeDirectories($directory);
return $result;
}
示例10: testInheritanceGeneration
public function testInheritanceGeneration()
{
$path = dirname(__FILE__) . '/import_builder_test';
$import = new Doctrine_Import_Schema();
$import->setOption('generateTableClasses', true);
$import->importSchema('schema.yml', 'yml', $path);
$models = Doctrine_Core::loadModels($path, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$schemaTestInheritanceParent = new ReflectionClass('SchemaTestInheritanceParent');
$schemaTestInheritanceChild1 = new ReflectionClass('SchemaTestInheritanceChild1');
$schemaTestInheritanceChild2 = new ReflectionClass('SchemaTestInheritanceChild2');
$schemaTestInheritanceParentTable = new ReflectionClass('SchemaTestInheritanceParentTable');
$schemaTestInheritanceChild1Table = new ReflectionClass('SchemaTestInheritanceChild1Table');
$schemaTestInheritanceChild2Table = new ReflectionClass('SchemaTestInheritanceChild2Table');
$this->assertTrue($schemaTestInheritanceParent->isSubClassOf('Doctrine_Record'));
$this->assertTrue($schemaTestInheritanceParent->isSubClassOf('BaseSchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceParent->isSubClassOf('PackageSchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceChild1->isSubClassOf('BaseSchemaTestInheritanceChild1'));
$this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('BaseSchemaTestInheritanceChild2'));
$this->assertTrue($schemaTestInheritanceChild1->isSubClassOf('SchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceChild1->isSubClassOf('BaseSchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('SchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('BaseSchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('SchemaTestInheritanceChild1'));
$this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('BaseSchemaTestInheritanceChild1'));
$this->assertTrue($schemaTestInheritanceChild2->isSubClassOf('PackageSchemaTestInheritanceParent'));
$this->assertTrue($schemaTestInheritanceParentTable->isSubClassOf('Doctrine_Table'));
$this->assertTrue($schemaTestInheritanceChild1Table->isSubClassOf('SchemaTestInheritanceParentTable'));
$this->assertTrue($schemaTestInheritanceChild1Table->isSubClassOf('PackageSchemaTestInheritanceParentTable'));
$this->assertTrue($schemaTestInheritanceChild2Table->isSubClassOf('SchemaTestInheritanceParentTable'));
$this->assertTrue($schemaTestInheritanceChild2Table->isSubClassOf('PackageSchemaTestInheritanceParentTable'));
$this->assertTrue($schemaTestInheritanceChild2Table->isSubClassOf('SchemaTestInheritanceChild1Table'));
$this->assertTrue($schemaTestInheritanceChild2Table->isSubClassOf('PackageSchemaTestInheritanceChild1Table'));
# Simple Inheritance
$schemaTestSimpleInheritanceParent = new ReflectionClass('SchemaTestSimpleInheritanceParent');
$schemaTestSimpleInheritanceChild = new ReflectionClass('SchemaTestSimpleInheritanceChild');
$this->assertTrue($schemaTestSimpleInheritanceParent->hasMethod('setTableDefinition'));
$this->assertTrue($schemaTestSimpleInheritanceChild->isSubClassOf('SchemaTestSimpleInheritanceParent'));
# Class Table Inheritance
$schemaTestClassTableInheritanceParent = new ReflectionClass('SchemaTestClassTableInheritanceParent');
$schemaTestClassTableInheritanceChild = new ReflectionClass('SchemaTestClassTableInheritanceChild');
# Concrete Inheritance
$schemaTestConcreteInheritanceParent = new ReflectionClass('SchemaTestConcreteInheritanceParent');
$schemaTestConcreteInheritanceChild = new ReflectionClass('SchemaTestConcreteInheritanceChild');
# Column Aggregation Inheritance
$schemaTestColumnAggregationInheritanceParent = new ReflectionClass('SchemaTestColumnAggregationInheritanceParent');
$schemaTestColumnAggregationInheritanceChild = new ReflectionClass('SchemaTestColumnAggregationInheritanceChild');
$sql = Doctrine_Core::generateSqlFromArray(array('SchemaTestSimpleInheritanceParent', 'SchemaTestSimpleInheritanceChild'));
$this->assertEqual(count($sql), 1);
$this->assertEqual($sql[0], 'CREATE TABLE schema_test_simple_inheritance_parent (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255), description VARCHAR(255))');
$sql = Doctrine_Core::generateSqlFromArray(array('SchemaTestClassTableInheritanceParent', 'SchemaTestClassTableInheritanceChild'));
$this->assertEqual(count($sql), 2);
$this->assertEqual($sql[0], 'CREATE TABLE schema_test_class_table_inheritance_parent (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255))');
$this->assertEqual($sql[1], 'CREATE TABLE schema_test_class_table_inheritance_child (id INTEGER, title VARCHAR(255), description VARCHAR(255), PRIMARY KEY(id))');
$sql = Doctrine_Core::generateSqlFromArray(array('SchemaTestConcreteInheritanceParent', 'SchemaTestConcreteInheritanceChild'));
$this->assertEqual(count($sql), 2);
$this->assertEqual($sql[0], 'CREATE TABLE schema_test_concrete_inheritance_parent (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255))');
$this->assertEqual($sql[1], 'CREATE TABLE schema_test_concrete_inheritance_child (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255), title VARCHAR(255), description VARCHAR(255))');
$sql = Doctrine_Core::generateSqlFromArray(array('SchemaTestColumnAggregationInheritanceParent', 'SchemaTestColumnAggregationInheritanceChild'));
$this->assertEqual(count($sql), 2);
$this->assertEqual($sql[0], 'CREATE TABLE schema_test_column_aggregation_inheritance_parent (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255), type VARCHAR(255), title VARCHAR(255), description VARCHAR(255))');
$this->assertEqual($sql[1], 'CREATE INDEX schema_test_column_aggregation_inheritance_parent_type_idx ON schema_test_column_aggregation_inheritance_parent (type)');
Doctrine_Lib::removeDirectories($path);
}
示例11: _deletePluginFiles
private function _deletePluginFiles()
{
$this->logSection('sympal', 'Removing plugin files');
Doctrine_Lib::removeDirectories($this->_pluginPath);
if ($this->_contentTypeName) {
chdir(sfConfig::get('sf_root_dir'));
$task = new sfDoctrineDeleteModelFilesTask($this->_dispatcher, $this->_formatter);
foreach ($this->getPluginModels() as $model) {
$task->run(array($model), array('--no-confirmation'));
}
}
$path = sfConfig::get('sf_lib_dir') . '/*/doctrine/' . $this->_pluginName;
$dirs = glob($path);
sfToolkit::clearGlob($path);
foreach ($dirs as $dir) {
Doctrine_Lib::removeDirectories($dir);
}
if ($this->hasWebDirectory()) {
unlink(sfConfig::get('sf_web_dir') . '/' . $this->_pluginName);
}
}
示例12: execute
protected function execute($arguments = array(), $options = array())
{
$name = $arguments['name'];
$pluginName = 'sfSympal' . Doctrine_Inflector::classify(Doctrine_Inflector::tableize($name)) . 'Plugin';
$path = sfConfig::get('sf_plugins_dir') . '/' . $pluginName;
if (!$options['no-confirmation'] && !$this->askConfirmation(array('This command will create a new plugin named ' . $pluginName, 'Are you sure you want to proceed? (y/N)'), 'QUESTION_LARGE', false)) {
$this->logSection('sympal', 'Plugin creation aborted');
return 1;
}
if (is_dir($path)) {
if (isset($options['re-generate']) && $options['re-generate']) {
$uninstall = new sfSympalPluginUninstallTask($this->dispatcher, $this->formatter);
$uninstall->setCommandApplication($this->commandApplication);
$uninstallOptions = array();
$uninstallOptions[] = '--delete';
$uninstallOptions[] = '--no-confirmation';
$ret = $uninstall->run(array($name), $uninstallOptions);
} else {
throw new sfException('A plugin with the name ' . $pluginName . ' already exists!');
}
}
if (is_dir($path)) {
Doctrine_Lib::removeDirectories($path);
}
$generatePlugin = new sfGeneratePluginTask($this->dispatcher, $this->formatter);
$generatePlugin->setCommandApplication($this->commandApplication);
$generatePluginOptions = array();
if (isset($options['module']) && !empty($options['module'])) {
$generatePluginOptions[] = '--module=' . implode(' --module=', $options['module']);
}
if (isset($options['test-application'])) {
$generatePluginOptions[] = '--test-application=' . $options['test-application'];
}
if (isset($options['skip-test-dir'])) {
$generatePluginOptions[] = '--skip-test-dir';
}
$generatePlugin->run(array($pluginName), $generatePluginOptions);
$contentType = isset($options['content-type']) ? $options['content-type'] : null;
$lowerName = str_replace('-', '_', Doctrine_Inflector::urlize($name));
if ($contentType) {
$pluginYamlSchema = <<<EOF
---
{$contentType}:
actAs: [sfSympalContentTypeTemplate]
columns:
title: string(255)
body: clob
EOF;
$pluginInstallDataFixtures = <<<EOF
# {$pluginName} install data fixtures
EOF;
}
$itemsToCreate = array('config' => null, 'config/doctrine' => null, 'config/routing.yml' => '# ' . $pluginName . ' routing', 'data' => null);
if (isset($pluginInstallDataFixtures)) {
$itemsToCreate['data/fixtures'] = null;
$itemsToCreate['data/fixtures/install.yml'] = $pluginInstallDataFixtures;
}
if (isset($pluginYamlSchema)) {
$itemsToCreate['config/doctrine/schema.yml'] = $pluginYamlSchema;
}
if (isset($options['theme'])) {
$itemsToCreate['config/app.yml'] = sprintf('all:
sympal_config:
themes:
%s:
layout: %s
stylesheets:
- %s', $options['theme'], $options['theme'], '/' . $pluginName . '/css/' . $options['theme'] . '.css');
$itemsToCreate['templates/' . $options['theme'] . '.php'] = file_get_contents($this->configuration->getPluginConfiguration('sfSympalPlugin')->getRootDir() . '/templates/default.php');
$itemsToCreate['web/css/' . $options['theme'] . '.css'] = file_get_contents($this->configuration->getPluginConfiguration('sfSympalPlugin')->getRootDir() . '/web/css/default.css');
}
foreach ($itemsToCreate as $item => $value) {
$itemPath = $path . '/' . $item;
if (!is_null($value)) {
$dir = dirname($itemPath);
$this->getFilesystem()->mkdirs($dir);
file_put_contents($itemPath, $value);
} else {
$this->getFilesystem()->mkdirs($itemPath);
}
}
if (isset($options['install']) && $options['install']) {
$install = new sfSympalPluginInstallTask($this->dispatcher, $this->formatter);
$install->setCommandApplication($this->commandApplication);
$installOptions = array();
if (isset($options['content-type'])) {
$installOptions[] = '--content-type=' . $options['content-type'];
}
$ret = $install->run(array($name), $installOptions);
}
$cc = new sfCacheClearTask($this->dispatcher, $this->formatter);
$ret = $cc->run(array(), array());
}
示例13: removeDirectories
/**
* removeDirectories
*
* @param string $folderPath
* @return void
*/
public static function removeDirectories($folderPath)
{
return Doctrine_Lib::removeDirectories($folderPath);
}