Skip to content

Commit a3cbc25

Browse files
committed
Add base requirement for creating units
1 parent dae8d3d commit a3cbc25

19 files changed

+982
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# systemctl-php
22
[![Build Status](https://api.travis-ci.org/icanhazstring/systemctl-php.svg?branch=master)](https://travis-ci.org/icanhazstring/systemctl-php)
33

4+
> WORK IN PROGRESS
5+
46
PHP wrapper for systemctl (PHP7.1)
57

68
## Current supported units

assets/unit-template.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Unit]
2+
3+
[Service]
4+
5+
[Install]

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
"type": "library",
55
"require": {
66
"php": "^7.1",
7-
"symfony/process": "^3.2"
7+
"symfony/process": "^3.2",
8+
"league/plates": "^3.3"
89
},
910
"require-dev": {
1011
"phpunit/phpunit": "^6.1",
11-
"squizlabs/php_codesniffer": "^3.0"
12+
"squizlabs/php_codesniffer": "^3.0",
13+
"adlawson/vfs": "^0.12.1"
1214
},
1315
"autoload": {
1416
"psr-4": {

composer.lock

Lines changed: 160 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace SystemCtl\Exception;
4+
5+
class ConfigurationNotSupported extends \LogicException
6+
{
7+
}

src/SystemCtl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @method array getTimers(?string $unitPrefix = null)
2020
*
2121
* @package SystemCtl
22-
* @author icanhazstring frömer <[email protected]>
22+
* @author icanhazstring <[email protected]>
2323
*/
2424
class SystemCtl
2525
{
@@ -116,7 +116,7 @@ public function listUnits(array $unitTypes, ?string $unitPrefix = null): array
116116
/**
117117
* Invoke getUnit or getUnits depending on the requested method.
118118
* The method name needs to contain the unit type u want to call.
119-
*
119+
*
120120
* @param $name
121121
* @param $arguments
122122
* @return array|AbstractUnit

src/Template/PlatesRenderer.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace SystemCtl\Template;
4+
5+
use League\Plates;
6+
7+
/**
8+
* PlatesRenderer
9+
*
10+
* Wrapper for plates to be used with RendererInterface
11+
*
12+
* @package SystemCtl\Template
13+
* @author icanhazstring <[email protected]>
14+
*/
15+
class PlatesRenderer implements RendererInterface
16+
{
17+
/** @var Plates\Engine */
18+
private $engine;
19+
20+
/**
21+
* TemplateRenderer constructor.
22+
* @param Plates\Engine $engine
23+
*/
24+
public function __construct(Plates\Engine $engine)
25+
{
26+
$this->engine = $engine;
27+
}
28+
29+
/**
30+
* @inheritdoc
31+
*/
32+
public function render(string $templateFile, UnitTemplate $unitTemplate): string
33+
{
34+
return $this->engine->render($templateFile, ['unitTemplate' => $unitTemplate]);
35+
}
36+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace SystemCtl\Template;
4+
5+
interface RendererAwareInterface
6+
{
7+
/**
8+
* @param RendererInterface $renderer
9+
* @return RendererAwareInterface
10+
*/
11+
public function setRenderer(RendererInterface $renderer): RendererAwareInterface;
12+
13+
/**
14+
* @return RendererInterface
15+
*/
16+
public function getRenderer(): RendererInterface;
17+
}

src/Template/RendererInterface.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace SystemCtl\Template;
4+
5+
interface RendererInterface
6+
{
7+
/**
8+
* Render a named template with given data
9+
*
10+
* @param string $templateFile
11+
* @param UnitTemplate $unitTemplate
12+
* @return string
13+
*/
14+
public function render(string $templateFile, UnitTemplate $unitTemplate): string;
15+
}

0 commit comments

Comments
 (0)