Passed
Push — develop ( d59462...7f0625 )
by Jens
02:38
created
cloudcontrol/library/storage/Repository.php 1 patch
Indentation   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -24,217 +24,217 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class Repository
26 26
 {
27
-    protected $storagePath;
28
-
29
-    protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users', 'valuelists', 'redirects');
30
-
31
-    protected $sitemap;
32
-    protected $sitemapChanges = false;
33
-
34
-    protected $applicationComponents;
35
-    protected $applicationComponentsChanges = false;
36
-
37
-    protected $documentTypes;
38
-    protected $documentTypesChanges = false;
39
-
40
-    protected $bricks;
41
-    protected $bricksChanges = false;
42
-
43
-    protected $imageSet;
44
-    protected $imageSetChanges = false;
45
-
46
-    protected $images;
47
-    protected $imagesChanges = false;
48
-
49
-    protected $files;
50
-    protected $filesChanges = false;
51
-
52
-    protected $users;
53
-    protected $usersChanges = false;
54
-
55
-    protected $valuelists;
56
-    protected $valuelistsChanges = false;
57
-
58
-    protected $redirects;
59
-    protected $redirectsChanges = false;
60
-
61
-    protected $contentDbHandle;
62
-
63
-
64
-    /**
65
-     * Repository constructor.
66
-     * @param $storagePath
67
-     * @throws \Exception
68
-     */
69
-    public function __construct($storagePath)
70
-    {
71
-        $storagePath = realpath($storagePath);
72
-        if (is_dir($storagePath) && $storagePath !== false) {
73
-            $this->storagePath = $storagePath;
74
-        } else {
75
-            throw new \Exception('Repository not yet initialized.');
76
-        }
77
-    }
78
-
79
-    /**
80
-     * Creates the folder in which to create all storage related files
81
-     *
82
-     * @param $storagePath
83
-     * @return bool
84
-     */
85
-    public static function create($storagePath)
86
-    {
87
-        return mkdir($storagePath);
88
-    }
89
-
90
-    /**
91
-     * Initiates default storage
92
-     * @throws \Exception
93
-     */
94
-    public function init()
95
-    {
96
-        $storageDefaultPath = realpath('../library/cc/install/_storage.json');
97
-        $contentSqlPath = realpath('../library/cc/install/content.sql');
98
-
99
-        $this->initConfigStorage($storageDefaultPath);
100
-        $this->initContentDb($contentSqlPath);
101
-
102
-        $this->save();
103
-    }
104
-
105
-    /**
106
-     * Load filebased subset and return it's contents
107
-     *
108
-     * @param $name
109
-     * @return mixed|string
110
-     * @throws \Exception
111
-     */
112
-    public function __get($name)
113
-    {
114
-        if (isset($this->$name)) {
115
-            if (in_array($name, $this->fileBasedSubsets)) {
116
-                return $this->$name;
117
-            } else {
118
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
119
-            }
120
-        } else {
121
-            if (in_array($name, $this->fileBasedSubsets)) {
122
-                return $this->loadSubset($name);
123
-            } else {
124
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
125
-            }
126
-        }
127
-    }
128
-
129
-    /**
130
-     * Set filebased subset contents
131
-     * @param $name
132
-     * @param $value
133
-     * @throws \Exception
134
-     */
135
-    public function __set($name, $value)
136
-    {
137
-        if (in_array($name, $this->fileBasedSubsets)) {
138
-            $this->$name = $value;
139
-            $changes = $name . 'Changes';
140
-            $this->$changes = true;
141
-        } else {
142
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
143
-        }
144
-    }
145
-
146
-    /**
147
-     * Persist all subsets
148
-     */
149
-    public function save()
150
-    {
151
-        $host = $this;
152
-        array_map(function ($value) use ($host) {
153
-            $host->saveSubset($value);
27
+	protected $storagePath;
28
+
29
+	protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users', 'valuelists', 'redirects');
30
+
31
+	protected $sitemap;
32
+	protected $sitemapChanges = false;
33
+
34
+	protected $applicationComponents;
35
+	protected $applicationComponentsChanges = false;
36
+
37
+	protected $documentTypes;
38
+	protected $documentTypesChanges = false;
39
+
40
+	protected $bricks;
41
+	protected $bricksChanges = false;
42
+
43
+	protected $imageSet;
44
+	protected $imageSetChanges = false;
45
+
46
+	protected $images;
47
+	protected $imagesChanges = false;
48
+
49
+	protected $files;
50
+	protected $filesChanges = false;
51
+
52
+	protected $users;
53
+	protected $usersChanges = false;
54
+
55
+	protected $valuelists;
56
+	protected $valuelistsChanges = false;
57
+
58
+	protected $redirects;
59
+	protected $redirectsChanges = false;
60
+
61
+	protected $contentDbHandle;
62
+
63
+
64
+	/**
65
+	 * Repository constructor.
66
+	 * @param $storagePath
67
+	 * @throws \Exception
68
+	 */
69
+	public function __construct($storagePath)
70
+	{
71
+		$storagePath = realpath($storagePath);
72
+		if (is_dir($storagePath) && $storagePath !== false) {
73
+			$this->storagePath = $storagePath;
74
+		} else {
75
+			throw new \Exception('Repository not yet initialized.');
76
+		}
77
+	}
78
+
79
+	/**
80
+	 * Creates the folder in which to create all storage related files
81
+	 *
82
+	 * @param $storagePath
83
+	 * @return bool
84
+	 */
85
+	public static function create($storagePath)
86
+	{
87
+		return mkdir($storagePath);
88
+	}
89
+
90
+	/**
91
+	 * Initiates default storage
92
+	 * @throws \Exception
93
+	 */
94
+	public function init()
95
+	{
96
+		$storageDefaultPath = realpath('../library/cc/install/_storage.json');
97
+		$contentSqlPath = realpath('../library/cc/install/content.sql');
98
+
99
+		$this->initConfigStorage($storageDefaultPath);
100
+		$this->initContentDb($contentSqlPath);
101
+
102
+		$this->save();
103
+	}
104
+
105
+	/**
106
+	 * Load filebased subset and return it's contents
107
+	 *
108
+	 * @param $name
109
+	 * @return mixed|string
110
+	 * @throws \Exception
111
+	 */
112
+	public function __get($name)
113
+	{
114
+		if (isset($this->$name)) {
115
+			if (in_array($name, $this->fileBasedSubsets)) {
116
+				return $this->$name;
117
+			} else {
118
+				throw new \Exception('Trying to get undefined property from Repository: ' . $name);
119
+			}
120
+		} else {
121
+			if (in_array($name, $this->fileBasedSubsets)) {
122
+				return $this->loadSubset($name);
123
+			} else {
124
+				throw new \Exception('Trying to get undefined property from Repository: ' . $name);
125
+			}
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * Set filebased subset contents
131
+	 * @param $name
132
+	 * @param $value
133
+	 * @throws \Exception
134
+	 */
135
+	public function __set($name, $value)
136
+	{
137
+		if (in_array($name, $this->fileBasedSubsets)) {
138
+			$this->$name = $value;
139
+			$changes = $name . 'Changes';
140
+			$this->$changes = true;
141
+		} else {
142
+			throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
143
+		}
144
+	}
145
+
146
+	/**
147
+	 * Persist all subsets
148
+	 */
149
+	public function save()
150
+	{
151
+		$host = $this;
152
+		array_map(function ($value) use ($host) {
153
+			$host->saveSubset($value);
154 154
 		}, $this->fileBasedSubsets);
155
-    }
156
-
157
-    /**
158
-     * Persist subset to disk
159
-     * @param $subset
160
-     */
161
-    public function saveSubset($subset)
162
-    {
155
+	}
156
+
157
+	/**
158
+	 * Persist subset to disk
159
+	 * @param $subset
160
+	 */
161
+	public function saveSubset($subset)
162
+	{
163 163
 		$changes = $subset . 'Changes';
164 164
 		if ($this->$changes === true) {
165
-            if (!defined('JSON_PRETTY_PRINT')) {
166
-                $json = json_encode($this->$subset);
167
-            } else {
168
-                $json = json_encode($this->$subset, JSON_PRETTY_PRINT);
169
-            }
165
+			if (!defined('JSON_PRETTY_PRINT')) {
166
+				$json = json_encode($this->$subset);
167
+			} else {
168
+				$json = json_encode($this->$subset, JSON_PRETTY_PRINT);
169
+			}
170 170
 			$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
171 171
 			file_put_contents($subsetStoragePath, $json);
172 172
 
173 173
 			$this->$changes = false;
174 174
 		}
175
-    }
176
-
177
-    /**
178
-     * Load subset from disk
179
-     * @param $subset
180
-     * @return mixed|string
181
-     */
182
-    protected function loadSubset($subset)
183
-    {
184
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
185
-        $json = file_get_contents($subsetStoragePath);
186
-        $json = json_decode($json);
187
-        $this->$subset = $json;
188
-        return $json;
189
-    }
190
-
191
-    /**
192
-     * @param $contentSqlPath
193
-     */
194
-    protected function initContentDb($contentSqlPath)
195
-    {
196
-        $db = $this->getContentDbHandle();
197
-        $sql = file_get_contents($contentSqlPath);
198
-        $db->exec($sql);
199
-    }
200
-
201
-    /**
202
-     * @param $storageDefaultPath
203
-     */
204
-    protected function initConfigStorage($storageDefaultPath)
205
-    {
206
-        $json = file_get_contents($storageDefaultPath);
207
-        $json = json_decode($json);
208
-        $this->sitemap = $json->sitemap;
209
-        $this->sitemapChanges = true;
210
-        $this->applicationComponents = $json->applicationComponents;
211
-        $this->applicationComponentsChanges = true;
212
-        $this->documentTypes = $json->documentTypes;
213
-        $this->documentTypesChanges = true;
214
-        $this->bricks = $json->bricks;
215
-        $this->bricksChanges = true;
216
-        $this->imageSet = $json->imageSet;
217
-        $this->imageSetChanges = true;
218
-        $this->images = $json->images;
219
-        $this->imagesChanges = true;
220
-        $this->files = $json->files;
221
-        $this->filesChanges = true;
222
-        $this->users = $json->users;
223
-        $this->usersChanges = true;
224
-        $this->valuelists = $json->valuelists;
225
-        $this->valuelistsChanges = true;
226
-    }
227
-
228
-    /**
229
-     * @return \PDO
230
-     */
231
-    public function getContentDbHandle()
232
-    {
233
-        if ($this->contentDbHandle === null) {
234
-            $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db');
235
-        }
236
-        return $this->contentDbHandle;
237
-    }
175
+	}
176
+
177
+	/**
178
+	 * Load subset from disk
179
+	 * @param $subset
180
+	 * @return mixed|string
181
+	 */
182
+	protected function loadSubset($subset)
183
+	{
184
+		$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
185
+		$json = file_get_contents($subsetStoragePath);
186
+		$json = json_decode($json);
187
+		$this->$subset = $json;
188
+		return $json;
189
+	}
190
+
191
+	/**
192
+	 * @param $contentSqlPath
193
+	 */
194
+	protected function initContentDb($contentSqlPath)
195
+	{
196
+		$db = $this->getContentDbHandle();
197
+		$sql = file_get_contents($contentSqlPath);
198
+		$db->exec($sql);
199
+	}
200
+
201
+	/**
202
+	 * @param $storageDefaultPath
203
+	 */
204
+	protected function initConfigStorage($storageDefaultPath)
205
+	{
206
+		$json = file_get_contents($storageDefaultPath);
207
+		$json = json_decode($json);
208
+		$this->sitemap = $json->sitemap;
209
+		$this->sitemapChanges = true;
210
+		$this->applicationComponents = $json->applicationComponents;
211
+		$this->applicationComponentsChanges = true;
212
+		$this->documentTypes = $json->documentTypes;
213
+		$this->documentTypesChanges = true;
214
+		$this->bricks = $json->bricks;
215
+		$this->bricksChanges = true;
216
+		$this->imageSet = $json->imageSet;
217
+		$this->imageSetChanges = true;
218
+		$this->images = $json->images;
219
+		$this->imagesChanges = true;
220
+		$this->files = $json->files;
221
+		$this->filesChanges = true;
222
+		$this->users = $json->users;
223
+		$this->usersChanges = true;
224
+		$this->valuelists = $json->valuelists;
225
+		$this->valuelistsChanges = true;
226
+	}
227
+
228
+	/**
229
+	 * @return \PDO
230
+	 */
231
+	public function getContentDbHandle()
232
+	{
233
+		if ($this->contentDbHandle === null) {
234
+			$this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db');
235
+		}
236
+		return $this->contentDbHandle;
237
+	}
238 238
 
239 239
 	/**
240 240
 	 * Get all documents
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	 * @return array
245 245
 	 * @throws \Exception
246 246
 	 */
247
-    public function getDocuments($state = 'published')
248
-    {
247
+	public function getDocuments($state = 'published')
248
+	{
249 249
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
250 250
 			throw new \Exception('Unsupported document state: ' . $state);
251 251
 		}
252
-        return $this->getDocumentsByPath('/', $state);
253
-    }
252
+		return $this->getDocumentsByPath('/', $state);
253
+	}
254 254
 
255 255
 	public function getDocumentsWithState($folderPath = '/')
256 256
 	{
@@ -297,51 +297,51 @@  discard block
 block discarded – undo
297 297
 	 * @return array
298 298
 	 * @throws \Exception
299 299
 	 */
300
-    public function getDocumentsByPath($folderPath, $state = 'published')
301
-    {
302
-    	if (!in_array($state, Document::$DOCUMENT_STATES)) {
303
-    		throw new \Exception('Unsupported document state: ' . $state);
300
+	public function getDocumentsByPath($folderPath, $state = 'published')
301
+	{
302
+		if (!in_array($state, Document::$DOCUMENT_STATES)) {
303
+			throw new \Exception('Unsupported document state: ' . $state);
304 304
 		}
305
-        $db = $this->getContentDbHandle();
306
-        $folderPathWithWildcard = $folderPath . '%';
305
+		$db = $this->getContentDbHandle();
306
+		$folderPathWithWildcard = $folderPath . '%';
307 307
 
308
-        $sql = 'SELECT *
308
+		$sql = 'SELECT *
309 309
               FROM documents_' . $state . '
310 310
              WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . '
311 311
                AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%"
312 312
                AND path != ' . $db->quote($folderPath) . '
313 313
           ORDER BY `type` DESC, `path` ASC';
314
-        $stmt = $this->getDbStatement($sql);
314
+		$stmt = $this->getDbStatement($sql);
315 315
 
316
-        $documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
317
-        foreach ($documents as $key => $document) {
316
+		$documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
317
+		foreach ($documents as $key => $document) {
318 318
 			$documents = $this->setAssetsToDocumentFolders($document, $db, $documents, $key);
319
-        }
320
-        return $documents;
321
-    }
322
-
323
-
324
-    /**
325
-     * @param $path
326
-     * @return bool|Document
327
-     */
328
-    public function getDocumentContainerByPath($path)
329
-    {
330
-        $document = $this->getDocumentByPath($path, 'unpublished');
331
-        if ($document === false) {
332
-            return false;
333
-        }
334
-        $slugLength = strlen($document->slug);
335
-        $containerPath = substr($path, 0, -$slugLength);
336
-        if ($containerPath === '/') {
337
-            return $this->getRootFolder();
338
-        }
339
-        if (substr($containerPath, -1) === '/'){
319
+		}
320
+		return $documents;
321
+	}
322
+
323
+
324
+	/**
325
+	 * @param $path
326
+	 * @return bool|Document
327
+	 */
328
+	public function getDocumentContainerByPath($path)
329
+	{
330
+		$document = $this->getDocumentByPath($path, 'unpublished');
331
+		if ($document === false) {
332
+			return false;
333
+		}
334
+		$slugLength = strlen($document->slug);
335
+		$containerPath = substr($path, 0, -$slugLength);
336
+		if ($containerPath === '/') {
337
+			return $this->getRootFolder();
338
+		}
339
+		if (substr($containerPath, -1) === '/'){
340 340
 			$containerPath = substr($containerPath, 0, -1);
341 341
 		}
342
-        $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished');
343
-        return $containerFolder;
344
-    }
342
+		$containerFolder = $this->getDocumentByPath($containerPath, 'unpublished');
343
+		return $containerFolder;
344
+	}
345 345
 
346 346
 	/**
347 347
 	 * @param        $path
@@ -350,23 +350,23 @@  discard block
 block discarded – undo
350 350
 	 * @return bool|\library\storage\Document
351 351
 	 * @throws \Exception
352 352
 	 */
353
-    public function getDocumentByPath($path, $state = 'published')
354
-    {
353
+	public function getDocumentByPath($path, $state = 'published')
354
+	{
355 355
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
356 356
 			throw new \Exception('Unsupported document state: ' . $state);
357 357
 		}
358
-        $db = $this->getContentDbHandle();
359
-        $document = $this->fetchDocument('
358
+		$db = $this->getContentDbHandle();
359
+		$document = $this->fetchDocument('
360 360
             SELECT *
361 361
               FROM documents_' .  $state . '
362 362
              WHERE path = ' . $db->quote($path) . '
363 363
         ');
364
-        if ($document instanceof Document && $document->type === 'folder') {
365
-            $document->dbHandle = $db;
366
-            $document->documentStorage = new DocumentStorage($this);
367
-        }
368
-        return $document;
369
-    }
364
+		if ($document instanceof Document && $document->type === 'folder') {
365
+			$document->dbHandle = $db;
366
+			$document->documentStorage = new DocumentStorage($this);
367
+		}
368
+		return $document;
369
+	}
370 370
 
371 371
 	/**
372 372
 	 * Returns the count of all documents stored in the db
@@ -461,58 +461,58 @@  discard block
 block discarded – undo
461 461
 	}
462 462
 
463 463
 	/**
464
-     * Return the results of the query as array of Documents
465
-     * @param $sql
466
-     * @return array
467
-     * @throws \Exception
468
-     */
469
-    protected function fetchAllDocuments($sql)
470
-    {
471
-        $stmt = $this->getDbStatement($sql);
472
-        return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
473
-    }
474
-
475
-    /**
476
-     * Return the result of the query as Document
477
-     * @param $sql
478
-     * @return mixed
479
-     * @throws \Exception
480
-     */
481
-    protected function fetchDocument($sql)
482
-    {
483
-        $stmt = $this->getDbStatement($sql);
484
-        return $stmt->fetchObject('\library\storage\Document');
485
-    }
486
-
487
-    /**
488
-     * Prepare the sql statement
489
-     * @param $sql
490
-     * @return \PDOStatement
491
-     * @throws \Exception
492
-     */
493
-    protected function getDbStatement($sql)
494
-    {
495
-        $db = $this->getContentDbHandle();
496
-        $stmt = $db->query($sql);
497
-        if ($stmt === false) {
498
-            $errorInfo = $db->errorInfo();
499
-            $errorMsg = $errorInfo[2];
500
-            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
501
-        }
502
-        return $stmt;
503
-    }
504
-
505
-    /**
506
-     * Create a (non-existent) root folder Document and return it
507
-     * @return Document
508
-     */
509
-    protected function getRootFolder()
510
-    {
511
-        $rootFolder = new Document();
512
-        $rootFolder->path = '/';
513
-        $rootFolder->type = 'folder';
514
-        return $rootFolder;
515
-    }
464
+	 * Return the results of the query as array of Documents
465
+	 * @param $sql
466
+	 * @return array
467
+	 * @throws \Exception
468
+	 */
469
+	protected function fetchAllDocuments($sql)
470
+	{
471
+		$stmt = $this->getDbStatement($sql);
472
+		return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
473
+	}
474
+
475
+	/**
476
+	 * Return the result of the query as Document
477
+	 * @param $sql
478
+	 * @return mixed
479
+	 * @throws \Exception
480
+	 */
481
+	protected function fetchDocument($sql)
482
+	{
483
+		$stmt = $this->getDbStatement($sql);
484
+		return $stmt->fetchObject('\library\storage\Document');
485
+	}
486
+
487
+	/**
488
+	 * Prepare the sql statement
489
+	 * @param $sql
490
+	 * @return \PDOStatement
491
+	 * @throws \Exception
492
+	 */
493
+	protected function getDbStatement($sql)
494
+	{
495
+		$db = $this->getContentDbHandle();
496
+		$stmt = $db->query($sql);
497
+		if ($stmt === false) {
498
+			$errorInfo = $db->errorInfo();
499
+			$errorMsg = $errorInfo[2];
500
+			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
501
+		}
502
+		return $stmt;
503
+	}
504
+
505
+	/**
506
+	 * Create a (non-existent) root folder Document and return it
507
+	 * @return Document
508
+	 */
509
+	protected function getRootFolder()
510
+	{
511
+		$rootFolder = new Document();
512
+		$rootFolder->path = '/';
513
+		$rootFolder->type = 'folder';
514
+		return $rootFolder;
515
+	}
516 516
 
517 517
 	/**
518 518
 	 * Save the document to the database
@@ -524,13 +524,13 @@  discard block
 block discarded – undo
524 524
 	 * @throws \Exception
525 525
 	 * @internal param $path
526 526
 	 */
527
-    public function saveDocument($documentObject, $state = 'published')
528
-    {
527
+	public function saveDocument($documentObject, $state = 'published')
528
+	{
529 529
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
530 530
 			throw new \Exception('Unsupported document state: ' . $state);
531 531
 		}
532
-        $db = $this->getContentDbHandle();
533
-        $stmt = $this->getDbStatement('
532
+		$db = $this->getContentDbHandle();
533
+		$stmt = $this->getDbStatement('
534 534
             INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
535 535
             VALUES(
536 536
               ' . $db->quote($documentObject->path) . ',
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
               ' . $db->quote(json_encode($documentObject->dynamicBricks)) . '
549 549
             )
550 550
         ');
551
-        $result = $stmt->execute();
552
-        return $result;
553
-    }
551
+		$result = $stmt->execute();
552
+		return $result;
553
+	}
554 554
 
555 555
 	/**
556 556
 	 * Delete the document from the database
@@ -561,29 +561,29 @@  discard block
 block discarded – undo
561 561
 	 * @internal param string $state
562 562
 	 *
563 563
 	 */
564
-    public function deleteDocumentByPath($path)
565
-    {
566
-        $db = $this->getContentDbHandle();
567
-        $documentToDelete = $this->getDocumentByPath($path, 'unpublished');
568
-        if ($documentToDelete instanceof Document) {
569
-            if ($documentToDelete->type == 'document') {
570
-                $stmt = $this->getDbStatement('
564
+	public function deleteDocumentByPath($path)
565
+	{
566
+		$db = $this->getContentDbHandle();
567
+		$documentToDelete = $this->getDocumentByPath($path, 'unpublished');
568
+		if ($documentToDelete instanceof Document) {
569
+			if ($documentToDelete->type == 'document') {
570
+				$stmt = $this->getDbStatement('
571 571
                     DELETE FROM documents_unpublished
572 572
                           WHERE path = ' . $db->quote($path) . '
573 573
                 ');
574
-                $stmt->execute();
575
-            } elseif ($documentToDelete->type == 'folder') {
576
-                $folderPathWithWildcard = $path . '%';
577
-                $stmt = $this->getDbStatement('
574
+				$stmt->execute();
575
+			} elseif ($documentToDelete->type == 'folder') {
576
+				$folderPathWithWildcard = $path . '%';
577
+				$stmt = $this->getDbStatement('
578 578
                     DELETE FROM documents_unpublished
579 579
                           WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . '
580 580
                             AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/")
581 581
                             OR path = ' . $db->quote($path) . '
582 582
                 ');
583
-                $stmt->execute();
584
-            }
585
-        }
586
-    }
583
+				$stmt->execute();
584
+			}
585
+		}
586
+	}
587 587
 
588 588
 	/**
589 589
 	 * @param $document
Please login to merge, or discard this patch.