|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * AppserverIo\Apps\Example\Actions\Test\TestInjectWithSameNameAction |
| 5 | + * |
| 6 | + * NOTICE OF LICENSE |
| 7 | + * |
| 8 | + * This source file is subject to the Open Software License (OSL 3.0) |
| 9 | + * that is available through the world-wide-web at this URL: |
| 10 | + * http://opensource.org/licenses/osl-3.0.php |
| 11 | + * |
| 12 | + * PHP version 5 |
| 13 | + * |
| 14 | + * @author Tim Wagner <[email protected]> |
| 15 | + * @copyright 2015 TechDivision GmbH <[email protected]> |
| 16 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
| 17 | + * @link https://github.com/appserver-io-apps/example |
| 18 | + * @link http://www.appserver.io |
| 19 | + */ |
| 20 | + |
| 21 | +namespace AppserverIo\Apps\Example\Actions\Test; |
| 22 | + |
| 23 | +use AppserverIo\Routlt\DispatchAction; |
| 24 | +use AppserverIo\Routlt\Annotations as RLT; |
| 25 | +use AppserverIo\Psr\EnterpriseBeans\Annotations as EPB; |
| 26 | +use AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface; |
| 27 | +use AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface; |
| 28 | + |
| 29 | +/** |
| 30 | + * Example action implementation that loads data over a persistence container proxy |
| 31 | + * and renders a list, based on the returned values. |
| 32 | + * |
| 33 | + * Additional it provides functionality to edit, delete und persist the data after |
| 34 | + * changing it. |
| 35 | + * |
| 36 | + * @author Tim Wagner <[email protected]> |
| 37 | + * @copyright 2015 TechDivision GmbH <[email protected]> |
| 38 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
| 39 | + * @link https://github.com/appserver-io-apps/example |
| 40 | + * @link http://www.appserver.io |
| 41 | + * |
| 42 | + * @RLT\Path( |
| 43 | + * name="/test/inject-with-same-name", |
| 44 | + * results={ |
| 45 | + * @RLT\Result(name="input", result="input", type="RawResult") |
| 46 | + * } |
| 47 | + * ) |
| 48 | + * |
| 49 | + */ |
| 50 | +class TestInjectWithSameNameAction extends DispatchAction |
| 51 | +{ |
| 52 | + |
| 53 | + /** |
| 54 | + * The first bean reference. |
| 55 | + * |
| 56 | + * @var \AppserverIo\Apps\Example\Actions\Test\RandomBeanImplementation |
| 57 | + * @EPB\Inject(name="RandomBeanImplementation") |
| 58 | + */ |
| 59 | + protected $beanImpl1; |
| 60 | + |
| 61 | + /** |
| 62 | + * The second bean reference. |
| 63 | + * |
| 64 | + * @var \AppserverIo\Apps\Example\Actions\Test\RandomBeanImplementation |
| 65 | + * @EPB\Inject(name="RandomBeanImplementation") |
| 66 | + */ |
| 67 | + protected $beanImpl2; |
| 68 | + |
| 69 | + /** |
| 70 | + * The third bean reference. |
| 71 | + * |
| 72 | + * @var \AppserverIo\Apps\Example\Actions\Test\RandomBeanImplementation |
| 73 | + * @EPB\Inject(name="RandomBeanImplementation") |
| 74 | + */ |
| 75 | + protected $beanImpl3; |
| 76 | + |
| 77 | + /** |
| 78 | + * Returns the first bean reference. |
| 79 | + * |
| 80 | + * @return \AppserverIo\Apps\Example\Actions\Test\RandomBeanImplementation The refrence |
| 81 | + */ |
| 82 | + public function getBeanImpl1() |
| 83 | + { |
| 84 | + return $this->beanImpl1; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Returns the second bean reference. |
| 89 | + * |
| 90 | + * @return \AppserverIo\Apps\Example\Actions\Test\RandomBeanImplementation The refrence |
| 91 | + */ |
| 92 | + public function getBeanImpl2() |
| 93 | + { |
| 94 | + return $this->beanImpl2; |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Returns the third bean reference. |
| 99 | + * |
| 100 | + * @return \AppserverIo\Apps\Example\Actions\Test\RandomBeanImplementation The refrence |
| 101 | + */ |
| 102 | + public function getBeanImpl3() |
| 103 | + { |
| 104 | + return $this->beanImpl3; |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Default action to invoke if no action parameter has been found in the request. |
| 109 | + * |
| 110 | + * Loads all sample data and attaches it to the servlet context ready to be rendered |
| 111 | + * by the template. |
| 112 | + * |
| 113 | + * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance |
| 114 | + * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The response instance |
| 115 | + * |
| 116 | + * @return void |
| 117 | + * |
| 118 | + * @RLT\Action(name="/index") |
| 119 | + */ |
| 120 | + public function indexAction(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) |
| 121 | + { |
| 122 | + $servletResponse->appendBodyStream( |
| 123 | + $this->getBeanImpl2()->someMethod( |
| 124 | + $this->getBeanImpl3()->someMethod( |
| 125 | + $this->getBeanImpl1()->someMethod('Test') |
| 126 | + ) |
| 127 | + ) |
| 128 | + ); |
| 129 | + } |
| 130 | +} |
0 commit comments