forked from silverstripe/silverstripe-dms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/sunnysideup/silverstripe-dms
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
//1. check if DMSDocument Exists | ||
//2. foreach DMSDocument as item | ||
//3. create file | ||
//4. copy fields across | ||
//5, foreach DMS Document check that everything has been brough across to file | ||
//6. delete DMS Document fields, keeping the ones that need to be kept. | ||
//7. move DMS Document to its own location | ||
// | ||
|
||
namespace Sunnysideup\DMS\Tasks; | ||
|
||
use SilverStripe\Core\Injector\Injector; | ||
use SilverStripe\SiteConfig\SiteConfig; | ||
use SilverStripe\Versioned\Versioned; | ||
|
||
|
||
use Sunnysideup\DMS\Model\DMSDocument; | ||
use Sunnysideup\MigrateData\Tasks\MigrateDataTask; | ||
|
||
class MakeDMSTablesObsolete extends MigrateDataTask | ||
{ | ||
|
||
protected $title = 'Make DMS Tables Obsolete'; | ||
|
||
protected $description = 'Make DMS Tables Obsolete - need to run this before the first dev/build in order to avoid errors.'; | ||
|
||
protected $enabled = true; | ||
|
||
|
||
private $_folderCache = []; | ||
|
||
protected function performMigration() | ||
{ | ||
|
||
$oldFolder = ASSETS_PATH . '/_dmsassets'; | ||
$newFolder = ASSETS_PATH . '/dmsassets'; | ||
if (file_exists($oldFolder) && ! file_exists($newFolder)) { | ||
rename($oldFolder, $newFolder); | ||
} elseif (file_exists($oldFolder) && file_exists($newFolder)) { | ||
user_error($oldFolder.' AND '.$newFolder.' exist! Please review ...', E_USER_NOTICE); | ||
} | ||
|
||
$obj = Injector::inst()->get('Sunnysideup\\MigrateData\\Tasks\\MigrateDataTask'); | ||
|
||
if ($obj->tableExists('DMSDocument_versions')) { | ||
if ($obj->fieldExists('DMSDocument_versions', 'Created') && | ||
$obj->fieldExists('DMSDocument_versions', 'LastEdited') | ||
) { | ||
$obj->makeTableObsolete('DMSDocument_versions'); | ||
} | ||
} | ||
|
||
if ($obj->tableExists('DMSDocument')) { | ||
if ($obj->fieldExists('DMSDocument', 'Created') && | ||
$obj->fieldExists('DMSDocument', 'LastEdited') | ||
) { | ||
$obj->makeTableObsolete('DMSDocument'); | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
} |