* avatar overrides added

* cli commands framework added
* labinfo service for lab temp monitoring
* kanban entry label support
This commit is contained in:
Dávid Danyi 2017-08-18 15:49:19 +02:00
parent f6e918ed86
commit 1ab6691827
23 changed files with 727 additions and 59 deletions

17
bin/cli Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/php
<?php
require __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\Console\Application;
/** @var \Interop\Container\ContainerInterface $container */
$container = require __DIR__ . '/../config/container.php';
$application = new Application('Application console');
$commands = $container->get('config')['console']['commands'];
foreach ($commands as $command) {
$application->add($container->get($command));
}
$application->run();

View File

@ -13,6 +13,8 @@
"doctrine/common": "^2.8",
"los/basepath": "^1.0",
"roave/security-advisories": "dev-master",
"symfony/console": "^3.3",
"symfony/css-selector": "^3.3",
"zendframework/zend-cache": "^2.7",
"zendframework/zend-component-installer": "^1.0",
"zendframework/zend-config": "^3.1",

333
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "5339f5a32d2cf40a211bd68ff895f13a",
"content-hash": "58819bed1efddc237ebfcd76754b3380",
"packages": [
{
"name": "container-interop/container-interop",
@ -727,6 +727,53 @@
],
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2016-10-10T12:19:37+00:00"
},
{
"name": "roave/security-advisories",
"version": "dev-master",
@ -864,6 +911,243 @@
"description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it",
"time": "2017-07-18T08:09:10+00:00"
},
{
"name": "symfony/console",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "b0878233cb5c4391347e5495089c7af11b8e6201"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/b0878233cb5c4391347e5495089c7af11b8e6201",
"reference": "b0878233cb5c4391347e5495089c7af11b8e6201",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.3",
"symfony/dependency-injection": "~3.3",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/filesystem": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Console\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2017-07-29T21:27:59+00:00"
},
{
"name": "symfony/css-selector",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "4d882dced7b995d5274293039370148e291808f2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/4d882dced7b995d5274293039370148e291808f2",
"reference": "4d882dced7b995d5274293039370148e291808f2",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\CssSelector\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jean-François Simon",
"email": "jeanfrancois.simon@sensiolabs.com"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2017-05-01T15:01:29+00:00"
},
{
"name": "symfony/debug",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/7c13ae8ce1e2adbbd574fc39de7be498e1284e13",
"reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"psr/log": "~1.0"
},
"conflict": {
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"require-dev": {
"symfony/http-kernel": "~2.8|~3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Debug\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2017-07-28T15:27:31+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7c8fae0ac1d216eb54349e6a8baa57d515fe8803",
"reference": "7c8fae0ac1d216eb54349e6a8baa57d515fe8803",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2017-06-14T15:44:48+00:00"
},
{
"name": "zendframework/zend-cache",
"version": "2.7.2",
@ -2820,53 +3104,6 @@
],
"time": "2017-06-30T08:15:21+00:00"
},
{
"name": "psr/log",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2016-10-10T12:19:37+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
"version": "1.0.1",

View File

@ -0,0 +1,15 @@
<?php
return [
'dependencies' => [
'invokables' => [],
'factories' => [
App\Command\UpdateLabInfoCommand::class => App\Command\UpdateLabInfoFactory::class,
],
],
'console' => [
'commands' => [
App\Command\UpdateLabInfoCommand::class,
],
],
];

View File

@ -15,9 +15,11 @@ return [
'baseUrl' => 'https://jirapducc.mo.ca.am.ericsson.se/rest/api/2/search?jql=filter=%s&maxResults=1000&fields=%s',
'filterId' => 14229,
'fields' => [
'assignee',
'summary',
'priority',
'issuetype',
'labels',
'assignee',
'status',
'customfield_10010',
'customfield_11226',
@ -31,6 +33,7 @@ return [
'customfield_11692',
],
],
'url.labTemperatureUrl' => 'https://159.107.194.61/public/mapshow_simple.htm?id=3381&mapid=884B46A7-AE59-4523-9981-8E9FEB7C1FCF',
'http.proxy.enabled' => false,
'http.proxy.type' => CURLPROXY_SOCKS5,
'http.proxy.url' => "localhost:1080",

BIN
public/avatars/enorsos Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
public/avatars/epetfid Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
public/avatars/ethzto Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

BIN
public/avatars/etorist Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

View File

@ -3,7 +3,7 @@
namespace App\Action;
use App\Response\JsonCorsResponse;
use App\Service\DataCollectorService;
use App\Service\JiraCollectorService;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
use Psr\Http\Message\ServerRequestInterface;
@ -12,7 +12,7 @@ class KanbanAction implements ServerMiddlewareInterface
{
private $dataCollector;
public function __construct(DataCollectorService $dataCollectorService)
public function __construct(JiraCollectorService $dataCollectorService)
{
$this->dataCollector = $dataCollectorService;
}

View File

@ -2,14 +2,14 @@
namespace App\Action;
use App\Service\DataCollectorService;
use App\Service\JiraCollectorService;
use Interop\Container\ContainerInterface;
class KanbanFactory
{
public function __invoke(ContainerInterface $container)
{
$dataCollectorService = $container->get(DataCollectorService::class);
$dataCollectorService = $container->get(JiraCollectorService::class);
return new KanbanAction($dataCollectorService);
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Command;
use App\Service\LabInfoCollectorService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class UpdateLabInfoCommand extends Command
{
/**
* @var LabInfoCollectorService
*/
private $labInfoService;
public function __construct(LabInfoCollectorService $labInfoService)
{
$this->labInfoService = $labInfoService;
parent::__construct();
}
protected function configure()
{
$this->setName('labinfo:print')
->setDescription('Updates cache of jcat packages, streams and active nightly ci configuration');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln($this->labInfoService->getLabTemperatureData());
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Command;
use App\Service\LabInfoCollectorService;
use Interop\Container\ContainerInterface;
class UpdateLabInfoFactory
{
public function __invoke(ContainerInterface $container)
{
/** @var LabInfoCollectorService $labInfoService */
$labInfoService = $container->get(LabInfoCollectorService::class);
return new UpdateLabInfoCommand($labInfoService);
}
}

View File

@ -48,7 +48,8 @@ class ConfigProvider
Action\KanbanAction::class => Action\KanbanFactory::class,
Service\AvatarService::class => Service\AvatarServiceFactory::class,
Service\DataCollectorService::class => Service\DataCollectorServiceFactory::class,
Service\JiraCollectorService::class => Service\JiraCollectorServiceFactory::class,
Service\LabInfoCollectorService::class => Service\LabInfoCollectorServiceFactory::class,
'service.avatarCache' => function(ContainerInterface $container): StorageInterface {
$cache = new FilesytemCache();
@ -65,11 +66,18 @@ class ConfigProvider
$httpClient = new Client();
$httpClient->setAdapter($curlAdapter = new Client\Adapter\Curl());
$curlAdapter->setOptions(['timeout' => 300]);
$curlAdapter->setOptions([
'timeout' => 300,
]);
$curlAdapter
->setCurlOption(CURLOPT_SSL_VERIFYPEER, false)
->setCurlOption(CURLOPT_SSL_VERIFYHOST, false)
;
if($config->get('http.proxy.enabled', false)) {
$curlAdapter
->setCurlOption(CURLOPT_PROXYTYPE, $config->get('http.proxy.type'))
->setCurlOption(CURLOPT_PROXY, $config->get('http.proxy.url'));
->setCurlOption(CURLOPT_PROXY, $config->get('http.proxy.url'))
;
}
return $httpClient;
},

View File

@ -47,6 +47,11 @@ class KanbanEntry implements \JsonSerializable
*/
private $issuePriorityIcon;
/**
* @var string[]
*/
private $labels;
/**
* JIRA: customfield_11226
* @var int
@ -277,6 +282,24 @@ class KanbanEntry implements \JsonSerializable
return $this;
}
/**
* @return string[]
*/
public function getLabels(): ?array
{
return $this->labels;
}
/**
* @param string[] $labels
* @return KanbanEntry
*/
public function setLabels(?array $labels): KanbanEntry
{
$this->labels = $labels;
return $this;
}
/**
* @return string[]|ArrayCollection
*/
@ -477,6 +500,7 @@ class KanbanEntry implements \JsonSerializable
'assignee' => $this->getAssignee(),
'issuePriority' => $this->getIssuePriority(),
'issuePriorityIcon' => $this->getIssuePriorityIcon(),
'labels' => $this->getLabels(),
'prio' => $this->getPrio(),
'functionalArea' => $this->getFunctionalAreas()->getValues(),
'externalId' => $this->getExternalId(),

View File

@ -12,7 +12,7 @@ use Zend\Http\Client;
use Zend\Json\Decoder;
use Zend\Json\Json;
class DataCollectorService
class JiraCollectorService
{
/**
* @var Config
@ -89,6 +89,7 @@ class DataCollectorService
->setAnswerCode($jsonIssue['fields']['customfield_11692'])
->setIssuePriority($jsonIssue['fields']['priority']['name'])
->setIssuePriorityIcon($jsonIssue['fields']['priority']['iconUrl'])
->setLabels($jsonIssue['fields']['labels'])
;
// externalId : customfield_10010

View File

@ -6,7 +6,7 @@ use Interop\Container\ContainerInterface;
use Zend\Config\Config;
use Zend\Http\Client;
class DataCollectorServiceFactory
class JiraCollectorServiceFactory
{
public function __invoke(ContainerInterface $container)
{
@ -14,6 +14,6 @@ class DataCollectorServiceFactory
$httpClient = $container->get(Client::class);
$config = new Config($configArray['app.config']);
$avatarService = $container->get(AvatarService::class);
return new DataCollectorService($httpClient, $config, $avatarService);
return new JiraCollectorService($httpClient, $config, $avatarService);
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Service;
use Symfony\Component\CssSelector\CssSelectorConverter;
use Zend\Config\Config;
use Zend\Http\Client;
class LabInfoCollectorService
{
/**
* @var Config
*/
private $config;
/**
* @var Client
*/
private $httpClient;
/**
* @var array
*/
private $tempSensors = [
'Temp 5' => 'back_left',
'Temp 4' => 'back_middle',
'Temp 3' => 'back_right',
];
/**
* JiraClientService constructor.
* @param Client $client
* @param Config $config
*/
public function __construct(Client $client, Config $config)
{
$this->httpClient = $client;
$this->config = $config;
}
public function getLabTemperatureData()
{
/** @var Config $labTemperatureUrl */
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
$response = $this->httpClient
->setUri($labTemperatureUrl)
->send();
if(!$response->isSuccess()) {
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
}
return $this->parseHtml($response->getBody());
}
private function parseHtml($html): array
{
$cssToXpathConverter = new CssSelectorConverter();
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
$domDocument = new \DOMDocument();
$domDocument->loadHTML($html);
libxml_clear_errors();
libxml_use_internal_errors($xmlErrorHandling);
$documentXpath = new \DOMXPath($domDocument);
/** @var \DOMNodeList $element */
$element = $documentXpath->query($xpathLabelQuery);
$thing = [];
/** @var \DOMElement $item */
foreach($element as $item) {
$sensorName = trim($item->nodeValue);
if( in_array($sensorName, array_keys($this->tempSensors)) ){
/** @var \DOMNodeList $element */
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
}
}
return $thing;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Service;
use Interop\Container\ContainerInterface;
use Zend\Config\Config;
use Zend\Http\Client;
class LabInfoCollectorServiceFactory
{
public function __invoke(ContainerInterface $container)
{
$configArray = $container->get('config');
$httpClient = $container->get(Client::class);
$config = new Config($configArray['app.config']);
return new LabInfoCollectorService($httpClient, $config);
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Service;
use Symfony\Component\CssSelector\CssSelectorConverter;
use Zend\Config\Config;
use Zend\Http\Client;
class TrInfoCollectorService
{
/**
* @var Config
*/
private $config;
/**
* @var Client
*/
private $httpClient;
/**
* @var array
*/
private $tempSensors = [
'Temp 5' => 'back_left',
'Temp 4' => 'back_middle',
'Temp 3' => 'back_right',
];
/**
* JiraClientService constructor.
* @param Client $client
* @param Config $config
*/
public function __construct(Client $client, Config $config)
{
$this->httpClient = $client;
$this->config = $config;
}
public function getLabTemperatureData()
{
/** @var Config $labTemperatureUrl */
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
$response = $this->httpClient
->setUri($labTemperatureUrl)
->send();
if(!$response->isSuccess()) {
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
}
return $this->parseHtml($response->getBody());
}
private function parseHtml($html): array
{
$cssToXpathConverter = new CssSelectorConverter();
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
$domDocument = new \DOMDocument();
$domDocument->loadHTML($html);
libxml_clear_errors();
libxml_use_internal_errors($xmlErrorHandling);
$documentXpath = new \DOMXPath($domDocument);
/** @var \DOMNodeList $element */
$element = $documentXpath->query($xpathLabelQuery);
$thing = [];
/** @var \DOMElement $item */
foreach($element as $item) {
$sensorName = trim($item->nodeValue);
if( in_array($sensorName, array_keys($this->tempSensors)) ){
/** @var \DOMNodeList $element */
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
}
}
return $thing;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Service;
use Interop\Container\ContainerInterface;
use Zend\Config\Config;
use Zend\Http\Client;
class TrInfoCollectorServiceFactory
{
public function __invoke(ContainerInterface $container)
{
$configArray = $container->get('config');
$httpClient = $container->get(Client::class);
$config = new Config($configArray['app.config']);
return new TrInfoCollectorService($httpClient, $config);
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace App\Service;
use Symfony\Component\CssSelector\CssSelectorConverter;
use Zend\Config\Config;
use Zend\Http\Client;
class VacationInfoCollectorService
{
/**
* @var Config
*/
private $config;
/**
* @var Client
*/
private $httpClient;
/**
* @var array
*/
private $tempSensors = [
'Temp 5' => 'back_left',
'Temp 4' => 'back_middle',
'Temp 3' => 'back_right',
];
/**
* JiraClientService constructor.
* @param Client $client
* @param Config $config
*/
public function __construct(Client $client, Config $config)
{
$this->httpClient = $client;
$this->config = $config;
}
public function getLabTemperatureData()
{
/** @var Config $labTemperatureUrl */
$labTemperatureUrl = $this->config->get('url.labTemperatureUrl');
$response = $this->httpClient
->setUri($labTemperatureUrl)
->send();
if(!$response->isSuccess()) {
throw new \UnexpectedValueException("Bad LAB result", $response->getStatusCode());
}
return $this->parseHtml($response->getBody());
}
private function parseHtml($html): array
{
$cssToXpathConverter = new CssSelectorConverter();
$xpathLabelQuery = $cssToXpathConverter->toXPath('a.sensormenu.isnotpaused');
$xpathValueQuery = $cssToXpathConverter->toXPath('div.graphlabel2');
$xmlErrorHandling = libxml_use_internal_errors(TRUE);
$domDocument = new \DOMDocument();
$domDocument->loadHTML($html);
libxml_clear_errors();
libxml_use_internal_errors($xmlErrorHandling);
$documentXpath = new \DOMXPath($domDocument);
/** @var \DOMNodeList $element */
$element = $documentXpath->query($xpathLabelQuery);
$thing = [];
/** @var \DOMElement $item */
foreach($element as $item) {
$sensorName = trim($item->nodeValue);
if( in_array($sensorName, array_keys($this->tempSensors)) ){
/** @var \DOMNodeList $element */
$valueElement = $documentXpath->query($xpathValueQuery, $item->parentNode->parentNode);
$thing[$this->tempSensors[$sensorName]] = $valueElement->item(0)->nodeValue;
}
}
return $thing;
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Service;
use Interop\Container\ContainerInterface;
use Zend\Config\Config;
use Zend\Http\Client;
class VacationInfoCollectorServiceFactory
{
public function __invoke(ContainerInterface $container)
{
$configArray = $container->get('config');
$httpClient = $container->get(Client::class);
$config = new Config($configArray['app.config']);
return new VacationInfoCollectorService($httpClient, $config);
}
}