Project

General

Profile

Bug #57272 » Product.php

Jan Rieland, 2016-07-15 14:31

 
<?php

class Product extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{

/**
* sysLanguageUid
*
* @var integer
* @validate NotEmpty
*/
protected $sysLanguageUid = null;

/**
* localizedUid
*
* @var integer
* @validate NotEmpty
*/
protected $_localizedUid = null;

/**
* pictograms
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
*/
protected $pictograms = null;

/**
* productImage
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $productImage = null;

/**
* Returns the productImage
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $productImage
*/
public function getProductImage()
{
if ($this->getSysLanguageUid() > 0) {
$fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$fileObjects = $fileRepository->findByRelation('tx_kajadoproductcatalog_domain_model_product', 'product_image', $this->getLocalizedUid());
if (count($fileObjects) == 0) {
return null;
}
$myfile = $fileObjects[0]->toArray();
$image = new \TYPO3\CMS\Extbase\Domain\Model\FileReference();
// can not set, uid is protected
//$image->uidLocal = (int) $myfile['uid_local'];
$image->setOriginalResource = NULL;
$image->uid = (int) $myfile['uid'];
$image->_localizedUid = (int) $myfile['uid'];
$image->_languageUid = 0;
$image->_versionedUid = (int) $myfile['uid'];
$image->pid = (int) $myfile['pid'];
return $image;
}
return $this->productImage;
}

/**
* Sets the productImage
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $productImage
* @return void
*/
public function setProductImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $productImage)
{
$this->productImage = $productImage;
}


/**
* Returns the pictograms
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage pictograms
*/
public function getPictograms()
{
if ($this->getSysLanguageUid() != 0) {
$fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
$fileObjects = $fileRepository->findByRelation('tx_kajadoproductcatalog_domain_model_product', 'pictograms', $this->getLocalizedUid());
return $fileObjects;
}
return $this->pictograms;
}

/**
* Sets the pictograms
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $pictograms
* @return void
*/
public function setPictograms(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $pictograms)
{
$this->pictograms = $pictograms;
}


/**
* Returns the sysLanguageUid
*
* @return integer $alt
*/
public function getSysLanguageUid()
{
return $this->sysLanguageUid;
}

/**
* Sets the sysLanguageUid
*
* @param integer $sysLanguageUid
* @return void
*/
public function setSysLanguageUid($sysLanguageUid)
{
$this->sysLanguageUid = $sysLanguageUid;
}

/**
* Returns the localizedUid
*
* @return integer $localizedUid
*/
public function getLocalizedUid()
{
return $this->_localizedUid;
}

/**
* Sets the _localizedUid
*
* @param integer $_localizedUid
* @return void
*/
public function setLocalizedUid($_localizedUid)
{
$this->_localizedUid = $_localizedUid;
}

}


(1-1/3)