Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 08159b8

Browse files
committed
Updated MongoDumper.php
1 parent 05b6e4f commit 08159b8

File tree

3 files changed

+46
-51
lines changed

3 files changed

+46
-51
lines changed

‎dump.sql

Whitespace-only changes.

‎dump.sql.gz

20 Bytes
Binary file not shown.

‎src/Drivers/MongoDumper.php

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ protected function prepareDumpCommand(string $destinationPath): string
5454
'%smongodump %s %s %s %s %s %s %s %s',
5555
$this->dumpCommandPath,
5656
$archive,
57-
$this->getDatabaseOption(),
58-
$this->getUsernameOption(),
59-
$this->getPasswordOption(),
60-
$this->getHostOption(),
61-
$this->getPortOption(),
62-
$this->getCollectionOption(),
63-
$this->getAuthenticateDatabase()
57+
$this->prepareDatabase(),
58+
$this->prepareUsername(),
59+
$this->preparePassword(),
60+
$this->prepareHost(),
61+
$this->preparePort(),
62+
$this->prepareCollection(),
63+
$this->prepareAuthenticateDatabase()
6464
);
6565

6666
if ($this->uri) {
@@ -69,7 +69,7 @@ protected function prepareDumpCommand(string $destinationPath): string
6969
$this->dumpCommandPath,
7070
$archive,
7171
$this->uri,
72-
$this->getCollectionOption()
72+
$this->prepareCollection()
7373
);
7474
}
7575

@@ -80,74 +80,69 @@ protected function prepareDumpCommand(string $destinationPath): string
8080
return "{$dumpCommand} --out {$destinationPath}";
8181
}
8282

83-
public function getDatabaseOption()
83+
protected function prepareRestoreCommand(string $filePath): string
84+
{
85+
86+
$archive = $this->isCompress ? "--gzip --archive" : "";
87+
88+
$restoreCommand = sprintf("%smongorestore %s %s %s %s %s",
89+
$this->dumpCommandPath,
90+
$archive,
91+
$this->prepareHost(),
92+
$this->preparePort(),
93+
$this->prepareUsername(),
94+
$this->prepareAuthenticateDatabase()
95+
);
96+
97+
if ($this->uri) {
98+
$restoreCommand = sprintf(
99+
'%smongorestore %s --uri %s',
100+
$this->dumpCommandPath,
101+
$archive,
102+
$this->uri
103+
);
104+
}
105+
106+
if ($this->isCompress) {
107+
108+
return "{$restoreCommand} < {$filePath}";
109+
}
110+
111+
return "{$restoreCommand}{$filePath}";
112+
}
113+
114+
public function prepareDatabase()
84115
{
85116
return !empty($this->dbName) ? "--db {$this->dbName}" : "";
86117
}
87118

88-
public function getUsernameOption()
119+
public function prepareUsername()
89120
{
90121
return !empty($this->username) ? "--username {$this->username}" : "";
91122
}
92123

93-
public function getPasswordOption()
124+
public function preparePassword()
94125
{
95126
return !empty($this->password) ? "--password {$this->password}" : "";
96127
}
97128

98-
public function getHostOption()
129+
public function prepareHost()
99130
{
100131
return !empty($this->host) ? "--host {$this->host}" : "";
101132
}
102133

103-
public function getPortOption()
134+
public function preparePort()
104135
{
105136
return !empty($this->port) ? "--port {$this->port}" : "";
106137
}
107138

108-
public function getAuthenticateDatabase()
139+
public function prepareAuthenticateDatabase()
109140
{
110141
return !empty($this->authenticationDatabase) ? "--authenticationDatabase {$this->authenticationDatabase}" : "";
111142
}
112143

113-
public function getCollectionOption()
144+
public function prepareCollection()
114145
{
115146
return !empty($this->collection) ? "--collection {$this->collection}" : "";
116147
}
117-
118-
public function getArchiveOption()
119-
{
120-
return
121-
}
122-
123-
protected function prepareRestoreCommand(string $filePath): string
124-
{
125-
126-
$archive = $this->isCompress ? "--gzip --archive" : "";
127-
128-
$restoreCommand = sprintf("%smongorestore %s %s %s %s %s",
129-
$this->dumpCommandPath,
130-
$archive,
131-
$this->getHostOption(),
132-
$this->getPortOption(),
133-
$this->getUsernameOption(),
134-
$this->getAuthenticateDatabase()
135-
);
136-
137-
if ($this->uri) {
138-
$restoreCommand = sprintf(
139-
'%smongorestore %s --uri %s',
140-
$this->dumpCommandPath,
141-
$archive,
142-
$this->uri
143-
);
144-
}
145-
146-
if ($this->isCompress) {
147-
148-
return "{$restoreCommand} < {$filePath}";
149-
}
150-
151-
return "{$restoreCommand}{$filePath}";
152-
}
153148
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /