|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
4
|
|
|
*/ |
|
5
|
|
|
namespace eZ\Publish\Core\REST\Server\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use eZ\Publish\API\Repository\Exceptions\NotImplementedException; |
|
8
|
|
|
use eZ\Publish\API\Repository\SearchService; |
|
9
|
|
|
use eZ\Publish\API\Repository\Values\Content\Language; |
|
10
|
|
|
use eZ\Publish\API\Repository\Values\Content\LocationQuery; |
|
11
|
|
|
use eZ\Publish\Core\REST\Server\Controller; |
|
12
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
13
|
|
|
use eZ\Publish\Core\REST\Common\Message; |
|
14
|
|
|
use eZ\Publish\Core\REST\Server\Values; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Controller for Repository Views (Search, mostly). |
|
18
|
|
|
*/ |
|
19
|
|
|
class Views extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* @var \eZ\Publish\API\Repository\SearchService |
|
23
|
|
|
*/ |
|
24
|
|
|
private $searchService; |
|
25
|
|
|
|
|
26
|
|
|
public function __construct(SearchService $searchService) |
|
27
|
|
|
{ |
|
28
|
|
|
$this->searchService = $searchService; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Creates and executes a content view. |
|
33
|
|
|
* |
|
34
|
|
|
* @return \eZ\Publish\Core\REST\Server\Values\RestExecutedView |
|
35
|
|
|
*/ |
|
36
|
|
|
public function createView(Request $request) |
|
37
|
|
|
{ |
|
38
|
|
|
$viewInput = $this->inputDispatcher->parse( |
|
39
|
|
|
new Message( |
|
40
|
|
|
array('Content-Type' => $request->headers->get('Content-Type')), |
|
41
|
|
|
$request->getContent() |
|
|
|
|
|
|
42
|
|
|
) |
|
43
|
|
|
); |
|
44
|
|
|
|
|
45
|
|
|
if ($viewInput->query instanceof LocationQuery) { |
|
|
|
|
|
|
46
|
|
|
$method = 'findLocations'; |
|
47
|
|
|
} else { |
|
48
|
|
|
$method = 'findContent'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return new Values\RestExecutedView( |
|
52
|
|
|
array( |
|
53
|
|
|
'identifier' => $viewInput->identifier, |
|
|
|
|
|
|
54
|
|
|
'searchResults' => $this->searchService->$method( |
|
55
|
|
|
$viewInput->query, |
|
|
|
|
|
|
56
|
|
|
['languages' => Language::ALL] |
|
57
|
|
|
), |
|
58
|
|
|
) |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* List content views. |
|
64
|
|
|
* |
|
65
|
|
|
* @return NotImplementedException; |
|
|
|
|
|
|
66
|
|
|
*/ |
|
67
|
|
|
public function listView() |
|
68
|
|
|
{ |
|
69
|
|
|
return new NotImplementedException('ezpublish_rest.controller.content:listView'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get a content view. |
|
74
|
|
|
* |
|
75
|
|
|
* @return NotImplementedException; |
|
|
|
|
|
|
76
|
|
|
*/ |
|
77
|
|
|
public function getView() |
|
78
|
|
|
{ |
|
79
|
|
|
return new NotImplementedException('ezpublish_rest.controller.content:getView'); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get a content view results. |
|
84
|
|
|
* |
|
85
|
|
|
* @return NotImplementedException; |
|
|
|
|
|
|
86
|
|
|
*/ |
|
87
|
|
|
public function loadViewResults() |
|
88
|
|
|
{ |
|
89
|
|
|
return new NotImplementedException('ezpublish_rest.controller.content:loadViewResults'); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.