szurubooru/src/UpgradeService.php
Marcin Kurczewski f3096ffc5d Changed object initialization
DI FTW
2014-10-18 18:48:15 +02:00

29 lines
596 B
PHP

<?php
namespace Szurubooru;
final class UpgradeService
{
private $db;
public function __construct(\Szurubooru\DatabaseConnection $databaseConnection)
{
$this->db = $databaseConnection->getDatabase();
}
public function prepareForUsage()
{
$this->db->createCollection('posts');
}
public function removeAllData()
{
foreach ($this->db->getCollectionNames() as $collectionName)
$this->removeCollectionData($collectionName);
}
private function removeCollectionData($collectionName)
{
$this->db->$collectionName->remove();
$this->db->$collectionName->deleteIndexes();
}
}