Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
MixinGenerator | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
generate | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * Class to generate a new mixin from a template. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2017. |
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 VuFind |
24 | * @package Theme |
25 | * @author Chris Hallberg <challber@villanova.edu> |
26 | * @author Demian Katz <demian.katz@villanova.edu> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org Main Site |
29 | */ |
30 | |
31 | namespace VuFindTheme; |
32 | |
33 | /** |
34 | * Class to generate a new mixin from a template. |
35 | * |
36 | * @category VuFind |
37 | * @package Theme |
38 | * @author Chris Hallberg <challber@villanova.edu> |
39 | * @author Demian Katz <demian.katz@villanova.edu> |
40 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
41 | * @link https://vufind.org Main Site |
42 | */ |
43 | class MixinGenerator extends AbstractThemeUtility implements GeneratorInterface |
44 | { |
45 | use \VuFindConsole\ConsoleOutputTrait; |
46 | |
47 | /** |
48 | * Generate a new mixin from a template. |
49 | * |
50 | * @param string $name Name of mixin to generate. |
51 | * @param string $template Name of template mixin directory |
52 | * |
53 | * @return bool |
54 | */ |
55 | public function generate($name, $template = 'local_mixin_example') |
56 | { |
57 | // Check for existing theme |
58 | $baseDir = $this->info->getBaseDir() . '/'; |
59 | if (realpath($baseDir . $name)) { |
60 | return $this->setLastError('Mixin "' . $name . '" already exists'); |
61 | } |
62 | $this->writeln('Creating new mixin: "' . $name . '"'); |
63 | $source = $baseDir . $template; |
64 | $dest = $baseDir . $name; |
65 | $this->writeln("\tCopying $template"); |
66 | $this->writeln("\t\tFrom: " . $source); |
67 | $this->writeln("\t\tTo: " . $dest); |
68 | return $this->copyDir($source, $dest); |
69 | } |
70 | } |