Code style fixes.
This commit is contained in:
parent
a16c82babc
commit
50b117455e
18 changed files with 133 additions and 130 deletions
|
|
@ -119,10 +119,10 @@ class BuildController extends Controller
|
|||
break;
|
||||
}
|
||||
|
||||
$rebuild = Lang::get('rebuild_now');
|
||||
$rebuild = Lang::get('rebuild_now');
|
||||
$rebuildLink = APP_URL . 'build/rebuild/' . $build->getId();
|
||||
|
||||
$delete = Lang::get('delete_build');
|
||||
$delete = Lang::get('delete_build');
|
||||
$deleteLink = APP_URL . 'build/delete/' . $build->getId();
|
||||
|
||||
$project = Factory::getStore('Project')->getByPrimaryKey($build->getProjectId());
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ class BuildStatusController extends Controller
|
|||
{
|
||||
/* @var Project $project */
|
||||
$project = $this->projectStore->getById($projectId);
|
||||
$xml = new \SimpleXMLElement('<Projects/>');
|
||||
$xml = new \SimpleXMLElement('<Projects/>');
|
||||
|
||||
if (!$project instanceof Project || !$project->getAllowPublicStatus()) {
|
||||
return $this->renderXml($xml);
|
||||
|
|
|
|||
|
|
@ -19,10 +19,11 @@ class HomeController extends Controller
|
|||
$this->layout->title = Lang::get('dashboard');
|
||||
|
||||
$widgets = [
|
||||
'left' => [],
|
||||
'left' => [],
|
||||
'right' => [],
|
||||
];
|
||||
$widgets_config = Config::getInstance()->get('php-censor.dashboard_widgets', [
|
||||
|
||||
$widgetsConfig = Config::getInstance()->get('php-censor.dashboard_widgets', [
|
||||
'all_projects' => [
|
||||
'side' => 'left',
|
||||
],
|
||||
|
|
@ -30,7 +31,8 @@ class HomeController extends Controller
|
|||
'side' => 'right',
|
||||
],
|
||||
]);
|
||||
foreach($widgets_config as $name => $params) {
|
||||
|
||||
foreach($widgetsConfig as $name => $params) {
|
||||
$side = (isset($params['side']) && 'right' === $params['side'])
|
||||
? 'right'
|
||||
: 'left';
|
||||
|
|
|
|||
|
|
@ -189,17 +189,15 @@ class SessionController extends Controller
|
|||
{
|
||||
if ($this->request->getMethod() == 'POST') {
|
||||
$email = $this->getParam('email', null);
|
||||
$user = $this->userStore->getByEmail($email);
|
||||
$user = $this->userStore->getByEmail($email);
|
||||
|
||||
if (empty($user)) {
|
||||
$this->view->error = Lang::get('reset_no_user_exists');
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
$key = md5(date('Y-m-d') . $user->getHash());
|
||||
$url = APP_URL;
|
||||
|
||||
$message = Lang::get('reset_email_body', $user->getName(), $url, $user->getId(), $key);
|
||||
$key = md5(date('Y-m-d') . $user->getHash());
|
||||
$message = Lang::get('reset_email_body', $user->getName(), APP_URL, $user->getId(), $key);
|
||||
|
||||
$email = new Email();
|
||||
$email->setEmailTo($user->getEmail(), $user->getName());
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class UserController extends Controller
|
|||
$this->requireAdmin();
|
||||
|
||||
$method = $this->request->getMethod();
|
||||
$user = $this->userStore->getById($userId);
|
||||
$user = $this->userStore->getById($userId);
|
||||
|
||||
if (empty($user)) {
|
||||
throw new NotFoundException(Lang::get('user_n_not_found', $userId));
|
||||
|
|
@ -291,7 +291,7 @@ class UserController extends Controller
|
|||
{
|
||||
$this->requireAdmin();
|
||||
|
||||
$user = $this->userStore->getById($userId);
|
||||
$user = $this->userStore->getById($userId);
|
||||
|
||||
if (empty($user)) {
|
||||
throw new NotFoundException(Lang::get('user_n_not_found', $userId));
|
||||
|
|
|
|||
|
|
@ -423,10 +423,10 @@ class WebhookController extends Controller
|
|||
$url = $payload['pull_request']['commits_url'];
|
||||
|
||||
//for large pull requests, allow grabbing more then the default number of commits
|
||||
$custom_per_page = Config::getInstance()->get('php-censor.github.per_page');
|
||||
$params = [];
|
||||
if ($custom_per_page) {
|
||||
$params['per_page'] = $custom_per_page;
|
||||
$customPerPage = Config::getInstance()->get('php-censor.github.per_page');
|
||||
$params = [];
|
||||
if ($customPerPage) {
|
||||
$params['per_page'] = $customPerPage;
|
||||
}
|
||||
|
||||
$client = new Client();
|
||||
|
|
@ -490,12 +490,12 @@ class WebhookController extends Controller
|
|||
$project = $this->fetchProject($projectId, ['gitlab', 'git']);
|
||||
|
||||
$payloadString = file_get_contents("php://input");
|
||||
$payload = json_decode($payloadString, true);
|
||||
$payload = json_decode($payloadString, true);
|
||||
|
||||
// build on merge request events
|
||||
if (isset($payload['object_kind']) && $payload['object_kind'] == 'merge_request') {
|
||||
$attributes = $payload['object_attributes'];
|
||||
if ($attributes['state'] == 'opened' || $attributes['state'] == 'reopened') {
|
||||
if ($attributes['state'] === 'opened' || $attributes['state'] === 'reopened') {
|
||||
$branch = $attributes['source_branch'];
|
||||
$commit = $attributes['last_commit'];
|
||||
$committer = $commit['author']['email'];
|
||||
|
|
@ -520,8 +520,8 @@ class WebhookController extends Controller
|
|||
$status = 'failed';
|
||||
foreach ($payload['commits'] as $commit) {
|
||||
try {
|
||||
$branch = str_replace('refs/heads/', '', $payload['ref']);
|
||||
$committer = $commit['author']['email'];
|
||||
$branch = str_replace('refs/heads/', '', $payload['ref']);
|
||||
$committer = $commit['author']['email'];
|
||||
$results[$commit['id']] = $this->createBuild(
|
||||
Build::SOURCE_WEBHOOK,
|
||||
$project,
|
||||
|
|
@ -554,11 +554,11 @@ class WebhookController extends Controller
|
|||
*/
|
||||
public function svn($projectId)
|
||||
{
|
||||
$project = $this->fetchProject($projectId, 'svn');
|
||||
$branch = $this->getParam('branch', $project->getBranch());
|
||||
$commit = $this->getParam('commit');
|
||||
$project = $this->fetchProject($projectId, 'svn');
|
||||
$branch = $this->getParam('branch', $project->getBranch());
|
||||
$commit = $this->getParam('commit');
|
||||
$commitMessage = $this->getParam('message');
|
||||
$committer = $this->getParam('committer');
|
||||
$committer = $this->getParam('committer');
|
||||
|
||||
return $this->createBuild(
|
||||
Build::SOURCE_WEBHOOK,
|
||||
|
|
@ -770,13 +770,13 @@ class WebhookController extends Controller
|
|||
// Check if a build already exists for this commit ID:
|
||||
$builds = $this->buildStore->getByProjectAndCommit($project->getId(), $commitId);
|
||||
|
||||
$ignore_environments = [];
|
||||
$ignore_tags = [];
|
||||
$ignoreEnvironments = [];
|
||||
$ignoreTags = [];
|
||||
if ($builds['count']) {
|
||||
foreach($builds['items'] as $build) {
|
||||
/** @var Build $build */
|
||||
$ignore_environments[$build->getId()] = $build->getEnvironment();
|
||||
$ignore_tags[$build->getId()] = $build->getTag();
|
||||
$ignoreEnvironments[$build->getId()] = $build->getEnvironment();
|
||||
$ignoreTags[$build->getId()] = $build->getTag();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -790,20 +790,20 @@ class WebhookController extends Controller
|
|||
|
||||
$environments = $project->getEnvironmentsObjects();
|
||||
if ($environments['count']) {
|
||||
$created_builds = [];
|
||||
$environment_names = $project->getEnvironmentsNamesByBranch($branch);
|
||||
$createdBuilds = [];
|
||||
$environmentNames = $project->getEnvironmentsNamesByBranch($branch);
|
||||
// use base branch from project
|
||||
if (!empty($environment_names)) {
|
||||
if (!empty($environmentNames)) {
|
||||
$duplicates = [];
|
||||
foreach ($environment_names as $environment_name) {
|
||||
foreach ($environmentNames as $environmentName) {
|
||||
if (
|
||||
!in_array($environment_name, $ignore_environments) ||
|
||||
($tag && !in_array($tag, $ignore_tags, true))
|
||||
!in_array($environmentName, $ignoreEnvironments) ||
|
||||
($tag && !in_array($tag, $ignoreTags, true))
|
||||
) {
|
||||
// If not, create a new build job for it:
|
||||
$build = $this->buildService->createBuild(
|
||||
$project,
|
||||
$environment_name,
|
||||
$environmentName,
|
||||
$commitId,
|
||||
$project->getBranch(),
|
||||
$tag,
|
||||
|
|
@ -814,19 +814,19 @@ class WebhookController extends Controller
|
|||
$extra
|
||||
);
|
||||
|
||||
$created_builds[] = [
|
||||
$createdBuilds[] = [
|
||||
'id' => $build->getID(),
|
||||
'environment' => $environment_name,
|
||||
'environment' => $environmentName,
|
||||
];
|
||||
} else {
|
||||
$duplicates[] = array_search($environment_name, $ignore_environments);
|
||||
$duplicates[] = array_search($environmentName, $ignoreEnvironments);
|
||||
}
|
||||
}
|
||||
if (!empty($created_builds)) {
|
||||
if (!empty($createdBuilds)) {
|
||||
if (empty($duplicates)) {
|
||||
return ['status' => 'ok', 'builds' => $created_builds];
|
||||
return ['status' => 'ok', 'builds' => $createdBuilds];
|
||||
} else {
|
||||
return ['status' => 'ok', 'builds' => $created_builds, 'message' => sprintf('For this commit some builds already exists (%s)', implode(', ', $duplicates))];
|
||||
return ['status' => 'ok', 'builds' => $createdBuilds, 'message' => sprintf('For this commit some builds already exists (%s)', implode(', ', $duplicates))];
|
||||
}
|
||||
} else {
|
||||
return ['status' => 'ignored', 'message' => sprintf('For this commit already created builds (%s)', implode(', ', $duplicates))];
|
||||
|
|
@ -835,10 +835,10 @@ class WebhookController extends Controller
|
|||
return ['status' => 'ignored', 'message' => 'Branch not assigned to any environment'];
|
||||
}
|
||||
} else {
|
||||
$environment_name = null;
|
||||
$environmentName = null;
|
||||
if (
|
||||
!in_array($environment_name, $ignore_environments, true) ||
|
||||
($tag && !in_array($tag, $ignore_tags, true))
|
||||
!in_array($environmentName, $ignoreEnvironments, true) ||
|
||||
($tag && !in_array($tag, $ignoreTags, true))
|
||||
) {
|
||||
$build = $this->buildService->createBuild(
|
||||
$project,
|
||||
|
|
@ -857,7 +857,7 @@ class WebhookController extends Controller
|
|||
} else {
|
||||
return [
|
||||
'status' => 'ignored',
|
||||
'message' => sprintf('Duplicate of build #%d', array_search($environment_name, $ignore_environments)),
|
||||
'message' => sprintf('Duplicate of build #%d', array_search($environmentName, $ignoreEnvironments)),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,15 +72,15 @@ class WidgetBuildErrorsController extends Controller
|
|||
$view->builds = $builds['projects'];
|
||||
$projects = $this->projectStore->getByIds(array_keys($builds['projects']));
|
||||
|
||||
$view_projects = [];
|
||||
$viewProjects = [];
|
||||
foreach($projects as $id => $project) {
|
||||
if (!$project->getArchived()) {
|
||||
$view_projects[$id] = $project;
|
||||
$viewProjects[$id] = $project;
|
||||
} else {
|
||||
unset($builds['projects'][$id]);
|
||||
}
|
||||
}
|
||||
$view->projects = $view_projects;
|
||||
$view->projects = $viewProjects;
|
||||
} else {
|
||||
$view = new View('WidgetBuildErrors/empty');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue