Last active
December 12, 2015 05:28
-
-
Save benjaminrau/4721948 to your computer and use it in GitHub Desktop.
Remove all objects from a mn relation / objectstorage
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
/** | |
* action update | |
* | |
* @param Tx_Hcbookings_Domain_Model_Item | |
* @dontverifyrequesthash | |
* @return void | |
*/ | |
public function updateAction(Tx_Hcbookings_Domain_Model_Item $item) { | |
// Empty storage if no got submitted by form / last one has been removed | |
// Remember, if you use this action on a form that doesnt contain all the availabilityRanges | |
// we need to bind the condition to an "indicator" field and not to "if form contains this elements" | |
$formItem = $this->request->getArgument('item'); | |
if(!array_key_exists('availabilityRanges', $formItem)) { | |
$storage = $item->getAvailabilityRanges(); | |
$storage->removeAll(clone $storage); | |
} | |
$this->itemRepository->update($item); | |
$this->flashMessageContainer->add('Your Item was updated.'); | |
$this->redirect('show', null, null, array('item'=>$item)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment