コード例 #1
0
 /**
  * @test
  */
 public function removeHolidayFromObjectStorageHoldingHoliday()
 {
     $holiday = new \MUM\BjrFreizeit\Domain\Model\Holiday();
     $holidayObjectStorageMock = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage', array('detach'), array(), '', FALSE);
     $holidayObjectStorageMock->expects($this->once())->method('detach')->with($this->equalTo($holiday));
     $this->inject($this->subject, 'holiday', $holidayObjectStorageMock);
     $this->subject->removeHoliday($holiday);
 }
コード例 #2
0
 /**
  * Save an image with FAL
  * @param \TYPO3\CMS\Core\Resource\File $fileObject
  * @param \MUM\BjrFreizeit\Domain\Model\Leisure $leisure
  * @param $pid
  * @return int last insert id, file reference uid
  *
  */
 public function saveImage(\TYPO3\CMS\Core\Resource\File $fileObject, \MUM\BjrFreizeit\Domain\Model\Leisure $leisure)
 {
     //$dateiname = $filename; // Dateinamen auslesen
     $tabellenName = 'tx_bjrfreizeit_domain_model_leisure';
     $feldName = 'image';
     $data = array('uid_local' => $fileObject->getUid(), 'uid_foreign' => $leisure->getUid(), 'tablenames' => $tabellenName, 'fieldname' => $feldName, 'pid' => $leisure->getPid(), 'table_local' => 'sys_file', 'tstamp' => time(), 'crdate' => time(), 'cruser_id' => 100);
     $where = 'deleted ="0" AND hidden ="0" AND tablenames ="' . $tabellenName . '" AND uid_foreign=' . (int) $leisure->getUid() . ' AND table_local="sys_file"' . ' AND fieldname ="' . $feldName . '"';
     $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', 'sys_file_reference', $where);
     if (empty($row)) {
         $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_file_reference', $data, FALSE);
         $res = $GLOBALS['TYPO3_DB']->sql_insert_id();
     } else {
         $data = array('uid_local' => $fileObject->getUid(), 'tstamp' => time(), 'cruser_id' => 100);
         $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_file_reference', $where, $data, FALSE);
     }
     return $res;
 }
コード例 #3
0
 /**
  * @param Leisure $leisure
  * @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
  *
  * Image remove from sys_file_reference
  */
 protected function removeLeisureImage(Leisure $leisure)
 {
     $image = $leisure->getImage();
     //foreach ($images as $img) {
     if (is_a($image, '\\TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference')) {
         //remove the file reference
         $reference = $this->fileReferenceRepository->findByUid($image->getUid());
         $this->fileReferenceRepository->remove($reference);
         //remove the image in model (only one image allowed)
         $leisure->setImage(null);
     }
 }
コード例 #4
0
 /**
  * @param \MUM\BjrFreizeit\Domain\Model\Leisure $leisure
  * @return \MUM\BjrFreizeit\Domain\Model\Organization
  */
 public function findByLeisure(\MUM\BjrFreizeit\Domain\Model\Leisure $leisure)
 {
     $query = $this->createQuery();
     $organization = $query->matching($query->equals('leisureFolderPid', $leisure->getPid()))->execute()->getFirst();
     return $organization;
 }