/** * @test */ public function isPropertySettableWorksOnStdClass() { $stdClassObject = new stdClass(); $stdClassObject->property = 'foo'; $this->assertTrue(Tx_Extbase_Reflection_ObjectAccess::isPropertySettable($stdClassObject, 'property')); $this->assertFalse(Tx_Extbase_Reflection_ObjectAccess::isPropertySettable($stdClassObject, 'undefinedProperty')); }
/** * action beCopy * * @param Tx_WoehrlSeminare_Domain_Model_Event $event * @ignorevalidation $event * @return void */ public function beCopyAction($event) { $availableProperties = Tx_Extbase_Reflection_ObjectAccess::getGettablePropertyNames($event); $newEvent = $this->objectManager->create('Tx_WoehrlSeminare_Domain_Model_Event'); foreach ($availableProperties as $propertyName) { if (Tx_Extbase_Reflection_ObjectAccess::isPropertySettable($newEvent, $propertyName) && !in_array($propertyName, array('uid', 'pid', 'subscribers', 'cancelled', 'subEndDateTime', 'subEndDateInfoSent', 'categories', 'discipline'))) { $propertyValue = Tx_Extbase_Reflection_ObjectAccess::getProperty($event, $propertyName); Tx_Extbase_Reflection_ObjectAccess::setProperty($newEvent, $propertyName, $propertyValue); } } foreach ($event->getCategories() as $cat) { $newEvent->addCategory($cat); } foreach ($event->getDiscipline() as $discipline) { $newEvent->addDiscipline($discipline); } if ($event->getGeniusBar()) { $newEvent->setTitle('Wissensbar ' . $newEvent->getContact()->getName()); } else { $newEvent->setTitle($newEvent->getTitle()); } $newEvent->setHidden(TRUE); $this->eventRepository->add($newEvent); $this->flashMessageContainer->add('Die Veranstaltung ' . $newEvent->getTitle() . ' wurde kopiert.'); $this->redirect('beList'); }