/**
  * action update
  * @param \MUM\BjrFreizeit\Domain\Model\Leisure $leisure
  * @return void
  *
  */
 public function updateAction(\MUM\BjrFreizeit\Domain\Model\Leisure $leisure)
 {
     $redirectParams = array();
     $args = $this->request->getArguments();
     $persistenceManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
     //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($leisure);
     //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($args);
     //exit();
     if ($leisure->_isDirty() || $leisure->_isNew()) {
         if ($leisure->_isNew()) {
             $organization = $this->findOrganizationBySession();
             if (!is_a($organization, '\\MUM\\BjrFreizeit\\Domain\\Model\\Organization')) {
                 $organization = 'Error';
                 $GLOBALS['TSFE']->fe_user->setKey("ses", "leisureChange", 'Der Artikel konnte nicht angelegt werden. Errorcode: 1413190651');
             } else {
                 //$leisure->copyDataFromOrganization($organization);
                 $leisure->setPid($organization->getLeisureFolderPid());
                 $this->leisureRepository->add($leisure);
                 //now organization ist persistent
                 $GLOBALS['TSFE']->fe_user->setKey("ses", "leisureChange", 'Der Artikel wurde neu angelegt.');
             }
         } else {
             $this->leisureRepository->update($leisure);
             $GLOBALS['TSFE']->fe_user->setKey("ses", "leisureChange", 'Der Artikel ' . $leisure->getTitle() . ' wurde geändert.');
         }
         //it is not persistent already, we have to do it!
         $persistenceManager->persistAll();
         DebuggerUtility::var_dump($_FILES['tx_bjrfreizeitfeadmin_leisure']['name']['image'], 'FILES INhalt: ');
     }
     if (strlen($_FILES['tx_bjrfreizeitfeadmin_leisure']['name']['image']) > 0) {
         if ($leisure->hasImage) {
             $leisure->setImage(null);
             $persistenceManager->persistAll();
         }
         $success = $this->doUploadImage($leisure);
         //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($imageFileName);
         if ($success) {
             /** @var  $fileRepository \TYPO3\CMS\Core\Resource\FileRepository  */
             /*   $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
                             $fileReferenceObject = $fileRepository->findFileReferenceByUid($referenceUid);
             
                             $leisure->setImage($fileReferenceObject);
                          */
             $this->leisureRepository->update($leisure);
             $persistenceManager->persistAll();
         }
         //DebuggerUtility::var_dump($leisure, 'Leisure');
         //exit;
     }
     /*    DebuggerUtility::var_dump($_FILES, '_Files');
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileReferenceObject(1)->getOriginalFile();
             $fileReferenceData = $GLOBALS['TSFE']->sys_page->checkRecord('sys_file_reference', 1);
             DebuggerUtility::var_dump($fileObject, 'Fileobject');
             DebuggerUtility::var_dump($fileReferenceData, 'Filereference');
     
             exit;
         */
     $redirectParams['leisure'] = $leisure;
     $this->redirect('successUpdate', 'Leisure', NULL, $redirectParams);
 }