Created
November 21, 2012 14:32
-
-
Save svparijs/4125121 to your computer and use it in GitHub Desktop.
Inline Objects added
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace BKWI\Kernkaart\Domain\Model; | |
/** | |
* This script belongs to the TYPO3 Flow package "BKWI.Kernkaart". * | |
* * | |
* */ | |
use TYPO3\Flow\Annotations as Flow; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* A organisation alias | |
* | |
* @Flow\Entity | |
*/ | |
class Alias { | |
/** | |
* @var string | |
* @Flow\Validate(type="StringLength", options={ "minimum"=1, "maximum"=20 }) | |
* @ORM\Column(length=20) | |
*/ | |
protected $name; | |
/** | |
* @var \BKWI\Kernkaart\Domain\Model\Organisation | |
* @ORM\ManyToOne(inversedBy="aliases") | |
*/ | |
protected $organisation; | |
/** | |
* Returns this alias's name | |
* | |
* @return string This alias's name | |
*/ | |
public function getName() { | |
return $this->name; | |
} | |
/** | |
* Sets this alias's name | |
* | |
* @var string This alias's name | |
* @return void | |
*/ | |
public function setName($name) { | |
$this->name = $name; | |
} | |
/** | |
* Returns this alias name as a string | |
* | |
* @return string | |
*/ | |
public function __toString() { | |
return $this->name; | |
} | |
/** | |
* Returns the alias's organisation | |
* | |
* @return \BKWI\Kernkaart\Domain\Model\Organisation $organisation | |
*/ | |
public function getOrganisation() { | |
return $this->organisation; | |
} | |
/** | |
* Sets the Organisation for Alias | |
* | |
* @var \BKWI\Kernkaart\Domain\Model\Organisation $organisation | |
* @return void | |
*/ | |
public function setOrganisation($organisation) { | |
$this->organisation = $organisation; | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{namespace form=TYPO3\Form\ViewHelpers} | |
<fieldset class="t3-expose-inline t3-expose-inline-stacked t3-expose-inline-multiple" data-mode='multiple' data-counter="{inline.nextKey}"> | |
<div class="control-group"> | |
<f:if condition="{label}"> | |
<label class="control-label" for="item">{label}</label> | |
</f:if> | |
<div class="controls"> | |
<div class="t3-expose-inline-item-template"> | |
<a class="close">x</a> | |
<f:form.textfield property="aliases.alias.name" id="name" /> | |
</div> | |
</div> | |
</div> | |
<f:for each="{elements}" as="element"> | |
<div class="t3-expose-inline-item"> | |
Element: {element.name} | |
</div> | |
</f:for> | |
</fieldset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<f:layout name="Manage" /> | |
<f:section name="Title">New organisation</f:section> | |
<f:section name="Content"> | |
<div class="row"> | |
<div class="offset3 span6 well"> | |
<f:form action="create" name="newOrganisation" class="form-horizontal"> | |
<fieldset> | |
<div id="legend"> | |
<legend class="">Create Organisation</legend> | |
<f:flashMessages class="alert" /> | |
</div> | |
<div class="control-group"> | |
<label class="control-label" for="name">Organisation Name</label> | |
<div class="controls"> | |
<f:form.textfield id="name" placeholder="The Organisation name..." class="input-large" property="name" /> | |
</div> | |
</div> | |
<div class="control-group"> | |
<label class="control-label" for="phonenumber">Phone Number</label> | |
<div class="controls"> | |
<f:form.textfield id="phonenumber" placeholder="The phone number..." class="input-large" property="phoneNumber" /> | |
</div> | |
</div> | |
<div class="control-group"> | |
<label class="control-label" for="address">Address</label> | |
<div class="controls"> | |
<f:form.textarea id="address" class="input-large" property="address" /> | |
</div> | |
</div> | |
<f:render partial="Form/InlineStacked" arguments="{label: 'Alias',elements: {organisation.aliases}}"/> | |
<div class="control-group"> | |
<!-- Button --> | |
<div class="controls"> | |
<f:link.action class="btn btn-cancel" action="index">Cancel</f:link.action> | |
<button class="btn btn-success btn-large">Create</button> | |
</div> | |
</div> | |
</fieldset> | |
</f:form> | |
</div> | |
</div> | |
<script src="{f:uri.resource(path: 'JavaScript/Form/jquery.inlinehelper.js', package: 'BKWI.Kernkaart')}"></script> | |
<script src="{f:uri.resource(path: 'JavaScript/Form/Form.js', package: 'BKWI.Kernkaart')}"></script> | |
</f:section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace BKWI\Kernkaart\Domain\Model; | |
/** | |
* This script belongs to the TYPO3 Flow package "BKWI.Kernkaart". * | |
* * | |
* */ | |
use TYPO3\Flow\Annotations as Flow; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* A Organisation | |
* | |
* @Flow\Entity | |
*/ | |
class Organisation { | |
/** | |
* The name | |
* @var string | |
*/ | |
protected $name; | |
/** | |
* The phoneNumber | |
* @var string | |
*/ | |
protected $phoneNumber; | |
/** | |
* The Address | |
* @var string | |
*/ | |
protected $address; | |
/** | |
* @var \Doctrine\Common\Collections\Collection<\BKWI\Kernkaart\Domain\Model\Alias> | |
* @ORM\OneToMany(mappedBy="Alias",cascade={"persist"}) | |
*/ | |
protected $aliases; | |
/** | |
* Constructs this Organisation | |
*/ | |
public function __construct() { | |
$this->aliases = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
/** | |
* Get the Organisation's name | |
* | |
* @return string The Organisation's name | |
*/ | |
public function getName() { | |
return $this->name; | |
} | |
/** | |
* Sets this Organisation's name | |
* | |
* @param string $name The Organisation's name | |
* @return void | |
*/ | |
public function setName($name) { | |
$this->name = $name; | |
} | |
/** | |
* Get the Organisation's phoneNumber | |
* | |
* @return string The Organisation's phoneNumber | |
*/ | |
public function getPhoneNumber() { | |
return $this->phoneNumber; | |
} | |
/** | |
* Sets this Organisation's phoneNumber | |
* | |
* @param string $phoneNumber The Organisation's phoneNumber | |
* @return void | |
*/ | |
public function setphoneNumber($phoneNumber) { | |
$this->phoneNumber = $phoneNumber; | |
} | |
/** | |
* Get the Organisation's address | |
* | |
* @return string The Organisation's address | |
*/ | |
public function getAddress() { | |
return $this->address; | |
} | |
/** | |
* Sets this Organisation's address | |
* | |
* @param string $address The Organisation's address | |
* @return void | |
*/ | |
public function setAddress($address) { | |
$this->address = $address; | |
} | |
/** | |
* Setter for aliases | |
* | |
* @param \Doctrine\Common\Collections\Collection<\BKWI\Kernkaart\Domain\Model\Alias> $aliases The aliases | |
* @return void | |
*/ | |
public function setAliases(\Doctrine\Common\Collections\Collection $aliases) { | |
$this->aliases = clone $aliases; | |
} | |
/** | |
* Getter for aliases | |
* | |
* @return \Doctrine\Common\Collections\Collection<\BKWI\Kernkaart\Domain\Model\Alias> The aliases | |
*/ | |
public function getAliases() { | |
return clone $this->aliases; | |
} | |
/** | |
* Adds a alias to this organisation | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Alias $alias | |
* @return void | |
*/ | |
public function addAlias(\BKWI\Kernkaart\Domain\Model\Alias $alias) { | |
$this->aliases->add($alias); | |
} | |
/** | |
* Removes a alias to this organisation | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Alias $alias | |
* @return void | |
*/ | |
public function removeAlias(\BKWI\Kernkaart\Domain\Model\Alias $alias) { | |
$this->aliases->remove($alias); | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace BKWI\Kernkaart\Controller\Manage; | |
/** | |
* This script belongs to the TYPO3 Flow package "BKWI.Kernkaart". * | |
* * | |
* */ | |
use TYPO3\Flow\Annotations as Flow; | |
use TYPO3\Flow\Mvc\Controller\ActionController; | |
use \BKWI\Kernkaart\Domain\Model\Organisation; | |
/** | |
* Organisation controller for the BKWI.Kernkaart package | |
* | |
* @Flow\Scope("singleton") | |
*/ | |
class OrganisationController extends ActionController { | |
/** | |
* @Flow\Inject | |
* @var \BKWI\Kernkaart\Domain\Repository\OrganisationRepository | |
*/ | |
protected $organisationRepository; | |
public function initializeAction() { | |
parent::initializeAction(); | |
if ($this->arguments->hasArgument('organisation')) { | |
$propertyMappingConfigurationForOrganisation = $this->arguments->getArgument('organisation')->getPropertyMappingConfiguration(); | |
$propertyMappingConfigurationForOrganisation | |
->forProperty('aliases.*') | |
->setTypeConverterOption( | |
'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter', | |
\TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, | |
TRUE | |
); | |
$propertyMappingConfigurationForOrganisation | |
->forProperty('aliases.*') | |
->setTypeConverterOption( | |
'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter', | |
\TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, | |
TRUE | |
); | |
} | |
} | |
/** | |
* Shows a list of organisations | |
* | |
* @return void | |
*/ | |
public function indexAction() { | |
$this->view->assign('organisations', $this->organisationRepository->findAll()); | |
} | |
/** | |
* Shows a single organisation object | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Organisation $organisation The organisation to show | |
* @return void | |
*/ | |
public function showAction(Organisation $organisation) { | |
$this->view->assign('organisation', $organisation); | |
} | |
/** | |
* Shows a form for creating a new organisation object | |
* | |
* @return void | |
*/ | |
public function newAction() { | |
} | |
/** | |
* Adds the given new organisation object to the organisation repository | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Organisation $newOrganisation A new organisation to add | |
* @return void | |
*/ | |
public function createAction(Organisation $newOrganisation) { | |
$this->organisationRepository->add($newOrganisation); | |
$this->addFlashMessage('Created a new organisation.'); | |
$this->redirect('index'); | |
} | |
/** | |
* Shows a form for editing an existing organisation object | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Organisation $organisation The organisation to edit | |
* @return void | |
*/ | |
public function editAction(Organisation $organisation) { | |
$this->view->assign('organisation', $organisation); | |
} | |
/** | |
* Updates the given organisation object | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Organisation $organisation The organisation to update | |
* @return void | |
*/ | |
public function updateAction(Organisation $organisation) { | |
$this->organisationRepository->update($organisation); | |
$this->addFlashMessage('Updated the organisation.'); | |
$this->redirect('index'); | |
} | |
/** | |
* Removes the given organisation object from the organisation repository | |
* | |
* @param \BKWI\Kernkaart\Domain\Model\Organisation $organisation The organisation to delete | |
* @return void | |
*/ | |
public function deleteAction(Organisation $organisation) { | |
$this->organisationRepository->remove($organisation); | |
$this->addFlashMessage('Deleted a organisation.'); | |
$this->redirect('index'); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment