Skip to content

Commit 2ad52a4

Browse files
committed
Create factory for IssueMaker.
1 parent 5071eba commit 2ad52a4

File tree

4 files changed

+79
-9
lines changed

4 files changed

+79
-9
lines changed

module/GeebyDeebyLocal/config/module.config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
'factories' => [
188188
'GeebyDeebyLocal\Ingest\DatabaseIngester' => 'GeebyDeebyLocal\Ingest\DatabaseIngesterFactory',
189189
'GeebyDeebyLocal\Ingest\FedoraHarvester' => 'GeebyDeebyLocal\Ingest\FedoraHarvesterFactory',
190+
'GeebyDeebyLocal\Ingest\IssueMaker' => 'GeebyDeebyLocal\Ingest\IssueMakerFactory',
190191
'GeebyDeebyLocal\Ingest\SolrHarvester' => 'GeebyDeebyLocal\Ingest\SolrHarvesterFactory',
191192
],
192193
],

module/GeebyDeebyLocal/src/GeebyDeebyLocal/Command/Make/IssueCommandFactory.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ public function __invoke(
6767
throw new \Exception('Unexpected options sent to factory.');
6868
}
6969
$dbManager = $container->get(\GeebyDeeby\Db\Table\PluginManager::class);
70-
$issueMaker = new IssueMaker(
71-
$dbManager,
72-
$container->get(\GeebyDeeby\Articles::class)
73-
);
7470
return new $requestedName(
75-
$issueMaker,
71+
$container->get(IssueMaker::class),
7672
$dbManager->get('edition'),
7773
$dbManager->get('series')
7874
);

module/GeebyDeebyLocal/src/GeebyDeebyLocal/Command/Make/IssuesCommandFactory.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ public function __invoke(
6767
throw new \Exception('Unexpected options sent to factory.');
6868
}
6969
$dbManager = $container->get(\GeebyDeeby\Db\Table\PluginManager::class);
70-
$issueMaker = new IssueMaker(
71-
$dbManager,
72-
$container->get(\GeebyDeeby\Articles::class)
70+
return new $requestedName(
71+
$container->get(IssueMaker::class),
72+
$dbManager->get('series')
7373
);
74-
return new $requestedName($issueMaker, $dbManager->get('series'));
7574
}
7675
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
/**
4+
* Factory for IssueMaker
5+
*
6+
* PHP version 7
7+
*
8+
* Copyright (C) Demian Katz 2025.
9+
*
10+
* This program is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 2,
12+
* as published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
* @category GeebyDeeby
24+
* @package Console
25+
* @author Demian Katz <demian.katz@villanova.edu>
26+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27+
* @link https://github.com/demiankatz/Geeby-Deeby Main Site
28+
*/
29+
30+
namespace GeebyDeebyLocal\Ingest;
31+
32+
use Interop\Container\ContainerInterface;
33+
use Laminas\ServiceManager\Factory\FactoryInterface;
34+
35+
/**
36+
* Factory for IssueMaker
37+
*
38+
* @category GeebyDeeby
39+
* @package Console
40+
* @author Demian Katz <demian.katz@villanova.edu>
41+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
42+
* @link https://github.com/demiankatz/Geeby-Deeby Main Site
43+
*/
44+
class IssueMakerFactory implements FactoryInterface
45+
{
46+
/**
47+
* Create an object
48+
*
49+
* @param ContainerInterface $container Service manager
50+
* @param string $requestedName Service being created
51+
* @param null|array $options Extra options (optional)
52+
*
53+
* @return object
54+
*
55+
* @throws ServiceNotFoundException if unable to resolve the service.
56+
* @throws ServiceNotCreatedException if an exception is raised when
57+
* creating a service.
58+
* @throws ContainerException if any other error occurs
59+
*/
60+
public function __invoke(
61+
ContainerInterface $container,
62+
$requestedName,
63+
array $options = null
64+
) {
65+
if (!empty($options)) {
66+
throw new \Exception('Unexpected options sent to factory.');
67+
}
68+
$dbManager = $container->get(\GeebyDeeby\Db\Table\PluginManager::class);
69+
return new $requestedName(
70+
$dbManager,
71+
$container->get(\GeebyDeeby\Articles::class)
72+
);
73+
}
74+
}

0 commit comments

Comments
 (0)