Code Duplication    Length = 24-30 lines in 2 locations

code/control/DNRoot.php 2 locations

@@ 828-851 (lines=24) @@
825
	 * @return SS_HTTPResponse
826
	 * @throws SS_HTTPResponse_Exception
827
	 */
828
	public function pipeline(SS_HTTPRequest $request) {
829
		$params = $request->params();
830
		$pipeline = Pipeline::get()->byID($params['Identifier']);
831
832
		if(!$pipeline || !$pipeline->ID || !$pipeline->Environment()) {
833
			throw new SS_HTTPResponse_Exception('Pipeline not found', 404);
834
		}
835
		if(!$pipeline->Environment()->canView()) {
836
			return Security::permissionFailure();
837
		}
838
839
		$environment = $pipeline->Environment();
840
		$project = $pipeline->Environment()->Project();
841
842
		if($environment->Name != $params['Environment']) {
843
			throw new LogicException("Environment in URL doesn't match this pipeline");
844
		}
845
		if($project->Name != $params['Project']) {
846
			throw new LogicException("Project in URL doesn't match this pipeline");
847
		}
848
849
		// Delegate to sub-requesthandler
850
		return PipelineController::create($this, $pipeline);
851
	}
852
853
	/**
854
	 * Shows the creation log.
@@ 1568-1597 (lines=30) @@
1565
		return $this->sendResponse($deployment->ResqueStatus(), $content);
1566
	}
1567
1568
	public function abortDeploy(SS_HTTPRequest $request) {
1569
		$params = $request->params();
1570
		$deployment = DNDeployment::get()->byId($params['Identifier']);
1571
1572
		if(!$deployment || !$deployment->ID) {
1573
			throw new SS_HTTPResponse_Exception('Deployment not found', 404);
1574
		}
1575
		if(!$deployment->canView()) {
1576
			return Security::permissionFailure();
1577
		}
1578
1579
		// For now restrict to ADMINs only.
1580
		if(!Permission::check('ADMIN')) {
1581
			return Security::permissionFailure();
1582
		}
1583
1584
		$environment = $deployment->Environment();
1585
		$project = $environment->Project();
1586
1587
		if($environment->Name != $params['Environment']) {
1588
			throw new LogicException("Environment in URL doesn't match this deploy");
1589
		}
1590
		if($project->Name != $params['Project']) {
1591
			throw new LogicException("Project in URL doesn't match this deploy");
1592
		}
1593
1594
		$deployment->abort();
1595
1596
		return $this->sendResponse($deployment->ResqueStatus(), []);
1597
	}
1598
1599
	/**
1600
	 * @param SS_HTTPRequest|null $request