@@ 96-134 (lines=39) @@ | ||
93 | /** |
|
94 | * {@inheritdoc} |
|
95 | */ |
|
96 | public function createAction(Request $request) |
|
97 | { |
|
98 | $this->isGrantedOr403('CREATE'); |
|
99 | ||
100 | $config = $this->getConfiguration(); |
|
101 | $server = $this->findOr404($request); |
|
102 | ||
103 | $resource = $this->createResource($server, |
|
104 | $request->get('path'), |
|
105 | $request->get('type') |
|
106 | ); |
|
107 | $form = $this->getForm($resource); |
|
108 | ||
109 | $form->handleRequest($request); |
|
110 | ||
111 | if ($form->isSubmitted()) { |
|
112 | if ($form->isValid()) { |
|
113 | $resource = $this->domainManager->createResource($server, $resource); |
|
114 | ||
115 | return $this->redirectTo($server, $resource); |
|
116 | } |
|
117 | } |
|
118 | ||
119 | if ($config->isApiRequest()) { |
|
120 | return $this->handleView($this->view($form)); |
|
121 | } |
|
122 | ||
123 | $view = $this |
|
124 | ->view() |
|
125 | ->setTemplate($config->getTemplate('create.html')) |
|
126 | ->setData(array( |
|
127 | 'server' => $server, |
|
128 | 'form' => $form->createView(), |
|
129 | 'resource' => $resource, |
|
130 | )) |
|
131 | ; |
|
132 | ||
133 | return $this->handleView($view); |
|
134 | } |
|
135 | ||
136 | /** |
|
137 | * Display the form for editing or update the resource. |
|
@@ 139-174 (lines=36) @@ | ||
136 | /** |
|
137 | * Display the form for editing or update the resource. |
|
138 | */ |
|
139 | public function updateAction(Request $request) |
|
140 | { |
|
141 | $this->isGrantedOr403('UPDATE', $this->find($request)); |
|
142 | ||
143 | $config = $this->getConfiguration(); |
|
144 | $server = $this->findOr404($request); |
|
145 | ||
146 | $resource = $this->getResource($server, $request->get('path')); |
|
147 | $form = $this->getForm($resource); |
|
148 | ||
149 | $form->handleRequest($request); |
|
150 | ||
151 | if ($form->isSubmitted()) { |
|
152 | if ($form->isValid()) { |
|
153 | $resource = $this->domainManager->updateResource($server, $resource); |
|
154 | ||
155 | return $this->redirectTo($server, $resource); |
|
156 | } |
|
157 | } |
|
158 | ||
159 | if ($config->isApiRequest()) { |
|
160 | return $this->handleView($this->view($form)); |
|
161 | } |
|
162 | ||
163 | $view = $this |
|
164 | ->view() |
|
165 | ->setTemplate($config->getTemplate('update.html')) |
|
166 | ->setData(array( |
|
167 | 'server' => $server, |
|
168 | 'form' => $form->createView(), |
|
169 | 'resource' => $resource, |
|
170 | )) |
|
171 | ; |
|
172 | ||
173 | return $this->handleView($view); |
|
174 | } |
|
175 | ||
176 | /** |
|
177 | * Delete resource. |