i have seen that are two ways to create new pages with extbase, once with datamap like this:
$data = array(
‚pages‘ => array(
‚NEW_1‘ => array(
‚pid‘ => 1,
‚title‘ => ‚Hello World‚
),
)
);
$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
$tce->start($data, array());
$tce->process_datamap();
\TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
$tce->clear_cacheCmd('pages');
And the other way with mapping like this
Model
class Pages extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity{
…
}
Repository
class PagesRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
…
}
Controller
$page->setTitle('Hell World');
$this->pagesRepository->add($page);
TypoScript
persistence{
classes{
<Vendor>\<extKey>\Domain\Model\Pages{
mapping{
tableName = pages
columns{
title.mapOnProperty = title
…
}
}
}
}
}
Which one should I use to create pages and what is the difference between both of them?