public function findLinkedFilesInRte($ttContentRow)
    {
        $fileObjects = array();
        // check if there are links to files in the rte text
        /* @var $rteHtmlParser \TYPO3\CMS\Core\Html\RteHtmlParser */
        $rteHtmlParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(RteHtmlParser::class);

        /** @var \TYPO3\CMS\Core\LinkHandling\LinkService $linkService */
        $linkService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\LinkHandling\LinkService::class);
        $blockSplit = $rteHtmlParser->splitIntoBlock('A', $ttContentRow['bodytext'], 1);
        foreach ($blockSplit as $k => $v) {
            list($attributes) = $rteHtmlParser->get_tag_attributes($rteHtmlParser->getFirstTag($v), true);
            if (!empty($attributes['href'])) {
                $hrefInformation = $linkService->resolve($attributes['href']);
                if ($hrefInformation['type'] === \TYPO3\CMS\Core\LinkHandling\LinkService::TYPE_FILE) {
                    $fileObjects[] = $hrefInformation['file'];
                }
            }
        }

        return $fileObjects;
    }
public function findLinkedFilesInRte($ttContentRow)
    {
        $fileObjects = array();
        // check if there are links to files in the rte text
        /* @var $rteHtmlParser \TYPO3\CMS\Core\Html\RteHtmlParser */
        $rteHtmlParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(RteHtmlParser::class);

        /** @var \TYPO3\CMS\Core\LinkHandling\LinkService $linkService */
        $linkService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\LinkHandling\LinkService::class);
        $blockSplit = $rteHtmlParser->splitIntoBlock('A', $ttContentRow['bodytext'], 1);
        foreach ($blockSplit as $k => $v) {
            list($attributes) = $rteHtmlParser->get_tag_attributes($rteHtmlParser->getFirstTag($v), true);
            if (!empty($attributes['href'])) {
                $hrefInformation = $linkService->resolve($attributes['href']);
                if ($hrefInformation['type'] === \TYPO3\CMS\Core\LinkHandling\LinkService::TYPE_FILE) {
                    $fileObjects[] = $hrefInformation['file'];
                }
            }
        }

        return $fileObjects;
    }
public function findLinkedFilesInRte ( $ ttContentRow ) { $ fileObjects = array ( ) ; // check if there are links to files in the rte text /* @var $rteHtmlParser \TYPO3\CMS\Core\Html\RteHtmlParser */ $ rteHtmlParser = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: makeInstance ( RteHtmlParser :: class ) ; /** @var \TYPO3\CMS\Core\LinkHandling\LinkService $linkService */ $ linkService = GeneralUtility :: makeInstance ( \ TYPO3 \ CMS \ Core \ LinkHandling \ LinkService :: class ) ; $ blockSplit = $ rteHtmlParser -> splitIntoBlock ( 'A' , $ ttContentRow [ 'bodytext' ] , 1 ) ; foreach ( $ blockSplit as $ k => $ v ) { list ( $ attributes ) = $ rteHtmlParser -> get_tag_attributes ( $ rteHtmlParser -> getFirstTag ( $ v ) , true ) ; if ( ! empty ( $ attributes [ 'href' ] ) ) { $ hrefInformation = $ linkService -> resolve ( $ attributes [ 'href' ] ) ; if ( $ hrefInformation [ 'type' ] === \ TYPO3 \ CMS \ Core \ LinkHandling \ LinkService :: TYPE_FILE ) { $ fileObjects [ ] = $ hrefInformation [ 'file' ] ; } } } return $ fileObjects ; }
Finds files linked in rte text
returns them as array of file objects
@param array $ttContentRow content element
@return array
@author Christian Bülter <buelter@kennziffer.com>
@since 24.09.13
Finds files linked in rte text returns them as array of file objects