Blame view

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsKillPlotClass.php 1.19 KB
bda99a72   Benjamin Renard   Add kill plot req...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

/**
 * @class IHMInputOutputParamsKillPlotClass
 * @brief Implementation of IHMInputOutputParamsKillPlotClass to kill plot request
 * @details
*/
class IHMInputOutputParamsKillPlotClass extends IHMInputOutputParamsAbstractClass
{
	/*
	 * @brief method to unmarshall a plot request
	*/
	protected function unmarshallRequest($input)
	{
		
		$this->paramsData->setType(ProcessTypeEnumClass::KILL);
		
		$requestIdFilePath = $this->getWorkingPath().'process_id';
		
		if (!file_exists($requestIdFilePath))
			throw new Exception('Cannot retrieve current running plot request.');
		
		$process_id = file_get_contents($requestIdFilePath);
		
		if ($process_id === false)
			throw new Exception('Cannot retrieve current running plot request.');
		
		$process_id = str_replace(array("\r", "\n"), '', $process_id);
		
		$this->paramsData->setId($process_id);
		
		return $this->paramsData;
	}

	/*
	 * @brief method to marshall the result of a kill plot request
	*/
	protected function marshallResult($data)
	{
		if (!$data->getSuccess())
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		
		return array('success' => true);
	}
}
?>