/** * @param EventInterface $event * @return string */ public function handleEvent(EventInterface $event) { $event->trigger(); //TODO check trigger response and log card not found or stuff like that $loggerMsg = 'Trello webHook call received. Event: ' . get_class($event) . ' - Type: ' . $event->getType(); if ($event instanceof CommentEventInterface) { $loggerMsg .= ' (Updated Repositories: ' . $event->getCountUpdates() . ')'; } $this->info .= $loggerMsg; Logger::log(TrelloHooksController::TRELLO_HOOK_LOG, $loggerMsg); }
/** * @ApiDoc( * section="Github Hooks", * description="Dry run, only logs a Github webHook call to logfile: data/logs/github-hooks.log" * ) * @Rest\View() * @Rest\Route("/github-hook/log") */ public function postGithubLoggingAction(Request $request) { $data = ['content' => $request->request->all(), 'headers' => $request->headers->all()]; Logger::log(self::GITHUB_HOOK_LOG, $data); return $data; }
/** * @ApiDoc( * section="Trello Hooks", * description="Dry run, log a Trello hook call to logfile: data/logs/trello-hooks.log" * ) * @Rest\View(statusCode=200) * @Rest\Route("/trello-hook/log") */ public function postTrelloLoggingAction(Request $request) { $data = ['content' => $request->request->all(), 'headers' => $request->headers->all()]; Logger::log(self::TRELLO_HOOK_LOG, $data); return $data; }
/** * will be used by all concrete classes of the AbstractCommentEvent needs the proper message * that must be read differently in each implementation * * @param $comment * @return bool */ protected function addCommentsToIssues($comment) { $checklist = $this->loadCheckListByCard(); if (!$checklist) { return false; } if (!$this->checkIfRepositoriesMentionedInComment($comment)) { return false; } $preparedComment = $this->prepareComment($comment, $checklist); //--___________________________________________________--> //-- check if repository mentioned and store mentioned ones foreach ($checklist->getCheckItems() as $checkItem) { if (!$checkItem instanceof ChecklistItem) { //--___________________________________________________--> //-- prepare /* @var CheckListItem $checkListItem */ $checkListItem = ObjectPopulator::populate(new ChecklistItem(), $checkItem); $checkListItemName = $checkListItem->getName(); $repositoryInformationFromChecklistItemName = IssueReference::getRepositoryInformationFromUrl($checkListItemName); //--___________________________________________________--> //-- check if repository exists try { $this->githubClient->issues()->show($this->getGithubUserName(), $repositoryInformationFromChecklistItemName->getRepositoryName(), $repositoryInformationFromChecklistItemName->getIssueId()); } catch (\Github\Exception\RuntimeException $runtimeException) { $notFoundMsg = 'Github issue not found. ' . $this->getGithubUserName() . '/' . $repositoryInformationFromChecklistItemName->getRepositoryName() . '/' . $repositoryInformationFromChecklistItemName->getIssueId(); Logger::log(TrelloHooksController::TRELLO_HOOK_LOG, $notFoundMsg); continue; } //--___________________________________________________--> //-- push to all repos will skip this step, otherwise check if we shall add the comment on the current one if (!$this->pushToAllRepos) { if (!$this->checkIfCurrentRepositoryWasMentioned($repositoryInformationFromChecklistItemName)) { $notFoundMsg = 'Skipping Github issue. Not mentioned. ' . $this->getGithubUserName() . '/' . $repositoryInformationFromChecklistItemName->getRepositoryName() . '/' . $repositoryInformationFromChecklistItemName->getIssueId(); Logger::log(TrelloHooksController::TRELLO_HOOK_LOG, $notFoundMsg); continue; } } //--___________________________________________________--> //-- Add comment on github $response = $this->githubClient->issues()->comments()->create($this->getGithubUserName(), $repositoryInformationFromChecklistItemName->getRepositoryName(), $repositoryInformationFromChecklistItemName->getIssueId(), array('body' => $preparedComment)); $this->countUpdates++; } } return true; }