SHOW:
|
|
- or go back to the newest paste.
| 1 | Model | |
| 2 | ||
| 3 | ||
| 4 | <?php | |
| 5 | namespace MAS\Pro\Domain\Model; | |
| 6 | ||
| 7 | use TYPO3\FLOW3\Annotations as FLOW3; | |
| 8 | use Doctrine\ORM\Mapping as ORM; | |
| 9 | ||
| 10 | /** | |
| 11 | * A Location | |
| 12 | * | |
| 13 | * @FLOW3\Scope("prototype")
| |
| 14 | * @FLOW3\Entity | |
| 15 | */ | |
| 16 | class Location {
| |
| 17 | /** | |
| 18 | * @var string | |
| 19 | */ | |
| 20 | protected $street; | |
| 21 | ||
| 22 | /** | |
| 23 | * @var string | |
| 24 | */ | |
| 25 | protected $streetExtended; | |
| 26 | ||
| 27 | /** | |
| 28 | * @var string | |
| 29 | * @FLOW3\Validate(type="\MAS\Pro\Validation\Validator\StringValidator", options={ "length"=2})
| |
| 30 | * | |
| 31 | */ | |
| 32 | protected $city; | |
| 33 | ||
| 34 | /** | |
| 35 | * @var string | |
| 36 | */ | |
| 37 | protected $state; | |
| 38 | ||
| 39 | /** | |
| 40 | * @var string | |
| 41 | */ | |
| 42 | protected $postalcode; | |
| 43 | ||
| 44 | /** | |
| 45 | * | |
| 46 | * @var string | |
| 47 | */ | |
| 48 | protected $country; | |
| 49 | ||
| 50 | /** | |
| 51 | * @var \Doctrine\Common\Collections\ArrayCollection<\MAS\Pro\Domain\Model\Workshop> | |
| 52 | * @ORM\OneToMany(mappedBy="location") | |
| 53 | */ | |
| 54 | protected $workshop; | |
| 55 | ||
| 56 | /** | |
| 57 | * | |
| 58 | * @return \MAS\Pro\Domain\Model\Workshop | |
| 59 | */ | |
| 60 | public function getWorkshop() {
| |
| 61 | return $this->workshop; | |
| 62 | } | |
| 63 | ||
| 64 | public function setWorkshop($workshop) {
| |
| 65 | $this->workshop = $workshop; | |
| 66 | } | |
| 67 | ||
| 68 | ||
| 69 | /** | |
| 70 | * @return string | |
| 71 | */ | |
| 72 | public function getCountry() {
| |
| 73 | return $this->country; | |
| 74 | } | |
| 75 | ||
| 76 | /** | |
| 77 | * @param string $country | |
| 78 | */ | |
| 79 | public function setCountry($country) {
| |
| 80 | $this->country = $country; | |
| 81 | } | |
| 82 | ||
| 83 | /** | |
| 84 | * @return string | |
| 85 | */ | |
| 86 | public function getStreet() {
| |
| 87 | return $this->street; | |
| 88 | } | |
| 89 | ||
| 90 | /** | |
| 91 | * @param string $street | |
| 92 | * @return void | |
| 93 | */ | |
| 94 | public function setStreet($street) {
| |
| 95 | $this->street = $street; | |
| 96 | } | |
| 97 | ||
| 98 | /** | |
| 99 | * @return string | |
| 100 | */ | |
| 101 | public function getStreetExtended() {
| |
| 102 | return $this->streetExtended; | |
| 103 | } | |
| 104 | /** | |
| 105 | * @param string $streetExtended | |
| 106 | * @return void | |
| 107 | */ | |
| 108 | public function setStreetExtended($streetExtended) {
| |
| 109 | $this->streetExtended = $streetExtended; | |
| 110 | } | |
| 111 | ||
| 112 | /** | |
| 113 | * @return string | |
| 114 | */ | |
| 115 | public function getCity() {
| |
| 116 | return $this->city; | |
| 117 | } | |
| 118 | /** | |
| 119 | * @param string $city | |
| 120 | * @return void | |
| 121 | */ | |
| 122 | public function setCity($city) {
| |
| 123 | $this->city = $city; | |
| 124 | } | |
| 125 | ||
| 126 | /** | |
| 127 | * @return string | |
| 128 | */ | |
| 129 | public function getState() {
| |
| 130 | return $this->state; | |
| 131 | } | |
| 132 | ||
| 133 | /** | |
| 134 | * @param string $state | |
| 135 | * @return void | |
| 136 | */ | |
| 137 | public function setState($state) {
| |
| 138 | $this->state = $state; | |
| 139 | } | |
| 140 | ||
| 141 | /** | |
| 142 | * @return string | |
| 143 | */ | |
| 144 | public function getPostalcode() {
| |
| 145 | return $this->postalcode; | |
| 146 | } | |
| 147 | ||
| 148 | /** | |
| 149 | * @param string $postalcode | |
| 150 | * @return void | |
| 151 | */ | |
| 152 | public function setPostalcode($postalcode) {
| |
| 153 | $this->postalcode = $postalcode; | |
| 154 | } | |
| 155 | ||
| 156 | } | |
| 157 | ?> | |
| 158 | ||
| 159 | ||
| 160 | ||
| 161 | ||
| 162 | Controller | |
| 163 | <?php | |
| 164 | namespace MAS\Pro\Controller; | |
| 165 | ||
| 166 | /* * | |
| 167 | * This script belongs to the FLOW3 package "MAS.Pro". * | |
| 168 | * * | |
| 169 | - | public function updateAction(Location $location) {
|
| 169 | + | * */ |
| 170 | ||
| 171 | use TYPO3\FLOW3\Annotations as FLOW3; | |
| 172 | ||
| 173 | use TYPO3\FLOW3\MVC\Controller\ActionController; | |
| 174 | use \MAS\Pro\Domain\Model\Location; | |
| 175 | ||
| 176 | /** | |
| 177 | * Location controller for the MAS.Pro package | |
| 178 | * | |
| 179 | * @FLOW3\Scope("singleton")
| |
| 180 | */ | |
| 181 | class LocationController extends ActionController {
| |
| 182 | ||
| 183 | /** | |
| 184 | * @FLOW3\Inject | |
| 185 | * @var \MAS\Pro\Domain\Repository\LocationRepository | |
| 186 | */ | |
| 187 | protected $locationRepository; | |
| 188 | ||
| 189 | /** | |
| 190 | * Shows a list of locations | |
| 191 | * | |
| 192 | * @return void | |
| 193 | */ | |
| 194 | public function indexAction() {
| |
| 195 | $this->view->assign('locations', $this->locationRepository->findAll());
| |
| 196 | } | |
| 197 | ||
| 198 | /** | |
| 199 | * Shows a single location object | |
| 200 | * | |
| 201 | * @param \MAS\Pro\Domain\Model\Location $location The location to show | |
| 202 | * @return void | |
| 203 | */ | |
| 204 | public function showAction(Location $location) {
| |
| 205 | $this->view->assign('location', $location);
| |
| 206 | } | |
| 207 | ||
| 208 | /** | |
| 209 | * Shows a form for creating a new location object | |
| 210 | * | |
| 211 | * @return void | |
| 212 | */ | |
| 213 | public function newAction() {
| |
| 214 | } | |
| 215 | ||
| 216 | /** | |
| 217 | * Adds the given new location object to the location repository | |
| 218 | * | |
| 219 | * @param \MAS\Pro\Domain\Model\Location $newLocation A new location to add | |
| 220 | * @return void | |
| 221 | */ | |
| 222 | public function createAction(Location $newLocation) {
| |
| 223 | $this->locationRepository->add($newLocation); | |
| 224 | $this->addFlashMessage('Created a new location.');
| |
| 225 | $this->redirect('index');
| |
| 226 | } | |
| 227 | ||
| 228 | /** | |
| 229 | * Shows a form for editing an existing location object | |
| 230 | * | |
| 231 | * @param \MAS\Pro\Domain\Model\Location $location T he location to edit | |
| 232 | * @FLOW3\Validate | |
| 233 | * @return void | |
| 234 | */ | |
| 235 | public function editAction(Location $location) {
| |
| 236 | $this->view->assign('location', $location);
| |
| 237 | } | |
| 238 | ||
| 239 | /** | |
| 240 | * Updates the given location object | |
| 241 | * | |
| 242 | * @param \MAS\Pro\Domain\Model\Location $location The location to update | |
| 243 | * @return void | |
| 244 | */ | |
| 245 | public function updateAction(Location $location) {
| |
| 246 | $this->locationRepository->update($location); | |
| 247 | $this->addFlashMessage('Updated the location.');
| |
| 248 | $this->redirect('index');
| |
| 249 | } | |
| 250 | ||
| 251 | /** | |
| 252 | * Removes the given location object from the location repository | |
| 253 | * | |
| 254 | * @param \MAS\Pro\Domain\Model\Location $location The location to delete | |
| 255 | * @return void | |
| 256 | */ | |
| 257 | public function deleteAction(Location $location) {
| |
| 258 | $this->locationRepository->remove($location); | |
| 259 | $this->addFlashMessage('Deleted a location.');
| |
| 260 | $this->redirect('index');
| |
| 261 | } | |
| 262 | ||
| 263 | } | |
| 264 | ||
| 265 | ?> | |
| 266 | ||
| 267 | ||
| 268 | ||
| 269 | ||
| 270 | template | |
| 271 | ||
| 272 | <f:layout name="admin" /> | |
| 273 | ||
| 274 | <f:section name="Title">Edit location "{location.name}"</f:section>
| |
| 275 | ||
| 276 | <f:section name="Content"> | |
| 277 | <f:form action="update" object="{location}" name="location">
| |
| 278 | <f:form.validationResults for="location"> | |
| 279 | <f:if condition="{validationResults.flattenedErrors}">
| |
| 280 | <div class="error"> | |
| 281 | <f:for each="{validationResults.flattenedErrors}" key="propertyPath" as="errors">{propertyPath}: <f:for each="{errors}" as="error">{error}</f:for></f:for>
| |
| 282 | </div> | |
| 283 | </f:if> | |
| 284 | </f:form.validationResults> | |
| 285 | <div id="wrapper" > | |
| 286 | <div id="container"> | |
| 287 | ||
| 288 | <div class="label"><label for="street">Street</label> </div> | |
| 289 | <div class="input" > <f:form.textfield property="street" id="street" /></div> | |
| 290 | ||
| 291 | <div class="label"><label for="streetExtended">Street extended</label> </div> | |
| 292 | <div class="input" ><f:form.textfield property="streetExtended" id="streetExtended" /> </div> | |
| 293 | ||
| 294 | <div class="label"><label for="city">City</label> </div> | |
| 295 | <div class="input" ><f:form.textfield property="city" id="city" /> </div> | |
| 296 | ||
| 297 | <div class="label"> <label for="state">State</label></div> | |
| 298 | <div class="input" > <f:form.textfield property="state" id="state" /></div> | |
| 299 | ||
| 300 | <div class="label"> <label for="postalcode">Postalcode</label></div> | |
| 301 | <div class="input" > <f:form.textfield property="postalcode" id="postalcode" /></div> | |
| 302 | ||
| 303 | <div class="label"><label for="country">Country</label> </div> | |
| 304 | <div class="input" ><f:form.textfield property="country" id="country" /> </div> | |
| 305 | ||
| 306 | <li> | |
| 307 | <f:form.submit value="Update"/> | |
| 308 | </li> | |
| 309 | </div> | |
| 310 | </div> | |
| 311 | </f:form> | |
| 312 | </f:section> |