Skip to content
Snippets Groups Projects
Commit 75b339c7 authored by Maksym Chubin's avatar Maksym Chubin
Browse files

[FEATURE] Change relation to content elements

parent ceed6947
Branches master
No related tags found
No related merge requests found
......@@ -239,27 +239,84 @@ class MenuItem extends AbstractEntity
}
/**
* Returns the content
*
* @return string $content
* @return string
*/
public function getContent(): string
{
$uids = array_map(function (TtContent $ce) {
return $ce->getUid();
}, $this->getContentRecords()->toArray());
return implode(',', $uids);
return $this->getContentElementIdList();
}
/**
* @return ObjectStorage
* Get content elements
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
*/
public function getContentRecords(): ObjectStorage
public function getContentElements(): ObjectStorage
{
return $this->content;
}
/**
* Set content element list
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $contentElements content elements
*/
public function setContentElements(ObjectStorage $contentElements): void
{
$this->content = $contentElements;
}
/**
* Adds a content element to the record
*
* @param TtContent $contentElement
*/
public function addContentElement(TtContent $contentElement): void
{
if ($this->getContentElements() === null) {
$this->content = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
$this->content->attach($contentElement);
}
/**
* Get id list of content elements
*
* @return string
*/
public function getContentElementIdList(): string
{
return $this->getIdOfContentElements();
}
/**
* Get translated id list of content elements
*
* @return string
*/
public function getTranslatedContentElementIdList(): string
{
return $this->getIdOfContentElements(false);
}
/**
* Collect id list
*
* @param bool $original
* @return string
*/
protected function getIdOfContentElements(bool $original = true): string
{
$idList = [];
$contentElements = $this->getContentElements();
if ($contentElements) {
foreach ($this->getContentElements() as $contentElement) {
$idList[] = $original ? $contentElement->getUid() : $contentElement->_getProperty('_localizedUid');
}
}
return implode(',', $idList);
}
/**
* Adds a MenuItem
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment