class Database in DRD Agent 4.0.x
Same name and namespace in other branches
- 8.3 src/Agent/Action/Database.php \Drupal\drd_agent\Agent\Action\Database
Provides a 'Database' download file.
Hierarchy
- class \Drupal\drd_agent\Agent\Action\Base implements ContainerInjectionInterface, BaseInterface
- class \Drupal\drd_agent\Agent\Action\Database
Expanded class hierarchy of Database
File
- src/
Agent/ Action/ Database.php, line 11
Namespace
Drupal\drd_agent\Agent\ActionView source
class Database extends Base {
/**
* {@inheritdoc}
*/
public function execute() {
$databases = CoreDatabase::getAllConnectionInfo();
exec('mysqldump --version', $output, $ret);
$mysql = $ret === 0;
if ($mysql) {
foreach ($databases as $key => $info) {
foreach ($info as $target => $config) {
$file = $this
->realPath($this->fileSystem
->tempnam('temporary://', implode('-', [
'drd',
'db',
$target,
$key,
'',
])) . '.sql');
$credentialsfile = $this
->realPath($this->fileSystem
->tempnam('temporary://', 'mysqldump'));
$cmd = [
'mysqldump',
'--defaults-extra-file=' . $credentialsfile,
$config['database'],
'>' . $file,
];
$credentials = [
'[mysqldump]',
'host = ' . $config['host'],
'port = ' . $config['port'],
'user = ' . $config['username'],
'password = "' . $config['password'] . '"',
];
file_put_contents($credentialsfile, implode("\n", $credentials));
chmod($credentialsfile, 0600);
exec(implode(' ', $cmd), $output, $ret);
unlink($credentialsfile);
$databases[$key][$target]['file'] = $file;
}
}
return $databases;
}
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Base:: |
protected | property | ||
Base:: |
private | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | Crypt object for this DRD request. | |
Base:: |
protected | property | ||
Base:: |
private | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
protected | property | ||
Base:: |
private | function | Authenticate the request or throw an exception. | |
Base:: |
public | function |
Authorize the DRD instance, all validations have passed successfully. Overrides BaseInterface:: |
|
Base:: |
public | function | Callback to authorize a DRD instance with a given secret. | |
Base:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
Base:: |
public | function |
Get the arguments for this request. Overrides BaseInterface:: |
|
Base:: |
public | function |
Get authorised Crypt object or FALSE if none is available. Overrides BaseInterface:: |
|
Base:: |
public | function |
Get an array of database connection information. Overrides BaseInterface:: |
|
Base:: |
public | function |
Get the debug mode. Overrides BaseInterface:: |
|
Base:: |
public | function |
Overrides BaseInterface:: |
|
Base:: |
public | function |
Overrides BaseInterface:: |
|
Base:: |
public | function |
Validate a one-time-token. Overrides BaseInterface:: |
|
Base:: |
public | function |
Change current session to user 1. Overrides BaseInterface:: |
|
Base:: |
private | function | Read and decode the input from the POST request. | |
Base:: |
public | function |
Overrides BaseInterface:: |
|
Base:: |
public | function | Main callback to execute an action. | |
Base:: |
constant | |||
Base:: |
constant | |||
Base:: |
constant | |||
Base:: |
public | function |
Set the debug mode. Overrides BaseInterface:: |
|
Base:: |
private | function | Recursivly convert request arguments to an array. | |
Base:: |
public | function |
Logging if in debug mode. Overrides BaseInterface:: |
|
Base:: |
public | function | Base constructor. | |
Database:: |
public | function |
Execute an action. Overrides Base:: |