Created
August 15, 2016 11:26
-
-
Save gebi84/602b9680e15afc156e2fa09ebd3e522a to your computer and use it in GitHub Desktop.
contao postupload, recreate intern cache and check if db update is required
This file contains hidden or 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
<?php | |
include_once __DIR__.'/../system/initialize.php'; | |
class Postuplaod extends Database\Installer | |
{ | |
private static $instance = null; | |
public function __construct() | |
{ | |
$this->import('Automator'); | |
$this->import('RepositoryManager'); | |
parent::__construct(); | |
} | |
public static function getInstance() | |
{ | |
if(!self::$instance) { | |
self::$instance = new self(); | |
} | |
return self::$instance; | |
} | |
public function run() | |
{ | |
$this->resetInternCache(); | |
$this->checkSql(); | |
} | |
public function checkSql() | |
{ | |
if($update = $this->getSql()) { | |
echo 'need database update!!!'."\n"; | |
echo $update; | |
} | |
} | |
public function getSql() | |
{ | |
$count = 0; | |
$return = ''; | |
$sql_command = $this->compileCommands(); | |
if (empty($sql_command)) | |
{ | |
return ''; | |
} | |
$_SESSION['sql_commands'] = array(); | |
$arrOperations = array | |
( | |
'CREATE' => $GLOBALS['TL_LANG']['tl_install']['CREATE'], | |
'ALTER_ADD' => $GLOBALS['TL_LANG']['tl_install']['ALTER_ADD'], | |
// 'ALTER_CHANGE' => $GLOBALS['TL_LANG']['tl_install']['ALTER_CHANGE'], | |
// 'ALTER_DROP' => $GLOBALS['TL_LANG']['tl_install']['ALTER_DROP'], | |
// 'DROP' => $GLOBALS['TL_LANG']['tl_install']['DROP'] | |
); | |
foreach ($arrOperations as $command => $label) | |
{ | |
if (is_array($sql_command[$command])) { | |
// Headline | |
$return .= $label . "\n"; | |
} | |
} | |
return $return; | |
} | |
private function resetInternCache() | |
{ | |
echo 'delete internal Cache'."\n"; | |
$this->Automator->purgeInternalCache(); | |
echo 'generate internal Cache'."\n"; | |
$this->Automator->generateInternalCache(); | |
} | |
} | |
$post = Postuplaod::getInstance(); | |
$post->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment