Commit 70aecb6b authored by michael's avatar michael

60: Remove class properties from service

parent f2781413
......@@ -68,18 +68,18 @@ class PublishController extends Controller {
return new Response($response, 200);
}
$library = $this->get('library');
$identifiers = $library->getIdentifiersByRepo($processor->repo);
$identifiers = $library->getIdentifiersByRepo($hookData['repo']);
if ($identifiers) {
$this->publisher = $this->get('publisher');
foreach ($identifiers as $identifier) {
$fullIdentifier = "{$identifier}/{$processor->branch}";
$fullIdentifier = sprintf('%s/%s', $identifier, $hookData['branch']);
$this->publisher->publish($fullIdentifier);
$this->sendEmail($fullIdentifier, $hookData);
}
$response = $this->publisher->getMessagesInPlainText();
}
else {
$response = "CRITICAL - No books found which match {$processor->repo}";
$response = "CRITICAL - No books found which match " . $hookData['repo'];
}
return new Response($response, 200);
......
......@@ -4,16 +4,6 @@ namespace AppBundle\Utils;
class GitHubHookProcessor {
/**
* @var string the URL for the repository
*/
public $repo;
/**
* @var string the name of the branch to publish
*/
public $branch;
/**
* Process a GitHub webhook
*
......@@ -54,12 +44,14 @@ class GitHubHookProcessor {
* @throws \Exception
*/
protected function getDetailsFromPush($payload) {
$this->branch = preg_replace("#.*/(.*)#", "$1", $payload->ref);
if (empty($this->branch)) {
$branch = preg_replace("#.*/(.*)#", "$1", $payload->ref);
if (empty($branch)) {
throw new \Exception("Unable to determine branch from payload data");
}
$this->repo = $payload->repository->html_url;
if (empty($this->repo)) {
$repo = $payload->repository->html_url;
if (empty($repo)) {
throw new \Exception("Unable to determine repository from payload data");
}
......@@ -71,7 +63,9 @@ class GitHubHookProcessor {
return [
'commits' => $payload->commits,
'recipients' => $recipients
'recipients' => $recipients,
'branch' => $branch,
'repo' => $repo
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment