Move Category entity to container

This commit is contained in:
Peter Kokot
2019-01-25 22:39:39 +01:00
parent 9a1af42f0d
commit 8b0f4be53b
5 changed files with 12 additions and 16 deletions

View File

@@ -37,11 +37,7 @@ $generateFixturesCommand = new GenerateFixturesCommand();
$generateFixturesCommand->setDatabase($database);
$generateFixturesCommand->setConfig($config);
$category = new Category();
$category->setDatabase($database);
$category->setRest($rest);
$fixtures = new AppFixtures($database, Factory::create(), $category, $packageEntity);
$fixtures = new AppFixtures($database, Factory::create(), $container->get(Category::class), $packageEntity);
$generateFixturesCommand->setFixtures($fixtures);
$application->add($generateFixturesCommand);

View File

@@ -136,4 +136,12 @@ $container->set(App\PackageDll::class, function ($c) {
return new App\PackageDll($c->get('tmp_dir'));
});
$container->set(App\Entity\Category::class, function ($c) {
$category = new App\Entity\Category();
$category->setDatabase($c->get(App\Database::class));
$category->setRest($c->get(App\Rest::class));
return $category;
});
return $container;

View File

@@ -32,9 +32,7 @@ use App\TreeMenu\DynamicHtml;
$auth->secure(true);
$category = new Category();
$category->setDatabase($database);
$category->setRest($rest);
$category = $container->get(Category::class);
/**
* Function to recurse thru the tree adding nodes to treemenu

View File

@@ -25,9 +25,6 @@ use App\User;
require_once __DIR__.'/../../include/pear-prepend.php';
$releaseRepository = $container->get(ReleaseRepository::class);
$category = new Category();
$category->setDatabase($database);
$category->setRest($rest);
function rssBailout() {
header('HTTP/1.0 404 Not Found');
@@ -84,7 +81,7 @@ switch ($type) {
case 'cat':
$categoryName = $argument;
if (false === $category->isValid($categoryName)) {
if (false === $container->get(Category::class)->isValid($categoryName)) {
rssBailout();
}

View File

@@ -26,7 +26,4 @@ header('Content-type: text/plain; charset=utf-8');
print htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES)."\n\n";
$category = new Category();
$category->setDatabase($database);
$category->setRest($rest);
$category->renumberVisitations(true);
$container->get(Category::class)->renumberVisitations(true);