1: <?php
2:
3: /**
4: * This file is part of the Minion package.
5: * For the full copyright and license information, please view the LICENSE
6: * file that was distributed with this source code.
7: *
8: * @license MIT License
9: */
10:
11: namespace Minion;
12:
13: use Symfony\Component\HttpFoundation\Response;
14: use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
15:
16: /**
17: * Interface ControllerInterface.
18: *
19: * @package Minion
20: * @author Damian SzczerbiĆski <dszczer@gmail.com>
21: */
22: interface ControllerInterface
23: {
24: /**
25: * Dependency injection allowing access to framework instance and it's services.
26: *
27: * @param Application $container
28: */
29: public function setContainer(Application $container);
30:
31: /**
32: * Helper, render template under provided $path.
33: *
34: * @param string $path Path to the template file. If placed in sub-folders, separate them with "/"
35: * @param array $arguments Arguments passed to template
36: *
37: * @return Response
38: */
39: public function render($path, array $arguments = []);
40:
41: /**
42: * Helper, render template under provided $path, but returns plain text instead of Response object.
43: *
44: * @param string $path Path to the template file. If placed in sub-folders, separate them with "/"
45: * @param array $arguments Arguments passed to template
46: *
47: * @return string
48: */
49: public function renderText($path, array $arguments = []);
50:
51: /**
52: * Helper, return response with 404 HTTP status code.
53: *
54: * @param string $message Message to display
55: * @param \Exception|null $lastException Linked exception if any
56: *
57: * @return Response
58: */
59: public function createNotFoundException($message, \Exception $lastException = null);
60:
61: /**
62: * Helper, return response with 403 HTTP status code.
63: *
64: * @param string $message Message to display
65: * @param \Exception|null $lastException Linked exception if any
66: *
67: * @return Response
68: */
69: public function createNotAllowedException($message, \Exception $lastException = null);
70:
71: /**
72: * Helper, generate absolute URL path.
73: *
74: * @param string $route Route name
75: * @param array|null $params URL parameters (path and/or query)
76: * @param integer $flag URL generating method
77: *
78: * @return string Generated URL
79: */
80: public function generateUrl($route, array $params = [], $flag = UrlGeneratorInterface::ABSOLUTE_URL);
81:
82: /**
83: * Helper, get parameter by it's name.
84: *
85: * @param string $name Parameter name
86: * @param mixed $default Default value, if parameter does not exist
87: *
88: * @return mixed Parameter or default value
89: */
90: public function getParameter($name, $default = null);
91: }