Skip to content

Commit

Permalink
Merge pull request #84 from slub/fix-83
Browse files Browse the repository at this point in the history
Feature to use content elements like in news extensions
  • Loading branch information
Alexander Bigga authored Oct 2, 2021
2 parents a3c27f6 + 50032b7 commit 66bd758
Show file tree
Hide file tree
Showing 13 changed files with 883 additions and 30 deletions.
134 changes: 115 additions & 19 deletions Classes/Domain/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,46 @@ class Event extends AbstractEntity
*/
protected $description;

/**
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Slub\SlubEvents\Domain\Model\TtContent>
* @TYPO3\CMS\Extbase\Annotation\ORM\Lazy
*/
protected $contentElements;

/**
* Fal media items
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $image;


/**
* Minimum of Subscribers
*
* @var integer
* @var int
*/
protected $minSubscriber = 0;

/**
* Maximum of Subscribers
*
* @var integer
* @var int
*/
protected $maxSubscriber = 0;

/**
* Maximum amount of Persons per Subscription
*
* @var integer
* @var int
*/
protected $maxNumber = 0;

/**
* Target Audience
*
* @Extbase\Validate("NotEmpty")
* @var integer
* @var int
*/
protected $audience = 0;

Expand Down Expand Up @@ -229,6 +243,36 @@ class Event extends AbstractEntity
*/
protected $recurringEndDateTime;

/**
* Event constructor.
*/
public function __construct()
{
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}

/**
* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
*
* @return void
*/
protected function initStorageObjects()
{
/**
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*/
$this->categories = new ObjectStorage();

$this->contentElements = new ObjectStorage();

$this->discipline = new ObjectStorage();

$this->subscribers = new ObjectStorage();
}

/**
* Returns hidden
*
Expand Down Expand Up @@ -310,31 +354,83 @@ public function setDescription($description)
}

/**
* Event constructor.
* Get content elements
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function __construct()
public function getContentElements()
{
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
return $this->contentElements;
}

/**
* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
* Set content element list
*
* @return void
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $contentElements content elements
*/
protected function initStorageObjects()
public function setContentElements($contentElements)
{
/**
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*/
$this->categories = new ObjectStorage();
$this->contentElements = $contentElements;
}

$this->discipline = new ObjectStorage();
/**
* Get id list of content elements
*
* @return string
*/
public function getContentElementIdList()
{
return $this->getIdOfContentElements();
}

$this->subscribers = new ObjectStorage();
/**
* Get translated id list of content elements
*
* @return string
*/
public function getTranslatedContentElementIdList()
{
return $this->getIdOfContentElements(false);
}

/**
* Collect id list
*
* @param bool $original
* @return string
*/
protected function getIdOfContentElements($original = true)
{
$idList = [];
$contentElements = $this->getContentElements();
if ($contentElements) {
foreach ($this->getContentElements() as $contentElement) {
if ($contentElement->getColPos() >= 0) {
$idList[] = $original ? $contentElement->getUid() : $contentElement->_getProperty('_localizedUid');
}
}
}
return implode(',', $idList);
}

/**
* Returns the image
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $image
*/
public function getImage()
{
return $this->image;
}

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

/**
Expand Down
Loading

0 comments on commit 66bd758

Please sign in to comment.