| Conditions | 6 |
| Paths | 5 |
| Total Lines | 31 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace Anomaly\Streams\Platform\Http\Controller; |
||
| 27 | public function handle(Repository $cache, Redirector $redirect, $key) |
||
| 28 | { |
||
| 29 | $parameters = $cache->get('form::' . $key); |
||
| 30 | |||
| 31 | /* @var FormCriteria $criteria */ |
||
| 32 | $criteria = $this->dispatch(new GetFormCriteria($parameters)); |
||
| 33 | |||
| 34 | /* @var FormBuilder $builder */ |
||
| 35 | $builder = $criteria->build(); |
||
| 36 | |||
| 37 | $response = $builder |
||
| 38 | ->build() |
||
| 39 | ->post() |
||
| 40 | ->getFormResponse(); |
||
| 41 | |||
| 42 | $builder->flash(); |
||
| 43 | |||
| 44 | if ($response && $response->getStatusCode() !== 200) { |
||
| 45 | return $response; |
||
| 46 | } |
||
| 47 | |||
| 48 | if ($builder->isAjax()) { |
||
| 49 | return $builder->getFormResponse(); |
||
| 50 | } |
||
| 51 | |||
| 52 | if ($builder->hasFormErrors()) { |
||
| 53 | return $redirect->back(); |
||
| 54 | } |
||
| 55 | |||
| 56 | return $response ?: $redirect->back(); |
||
| 57 | } |
||
| 58 | } |
||
| 59 |