Skip to content

Instantly share code, notes, and snippets.

@dmitryd
Last active August 30, 2017 15:15
Show Gist options
  • Save dmitryd/f86cb00437ded943bee2 to your computer and use it in GitHub Desktop.
Save dmitryd/f86cb00437ded943bee2 to your computer and use it in GitHub Desktop.
TYPO3 Extbase and "Insert records"
<?php
namespace DmitryDulepov\Myext\Controller;
class MyController {
/**
* @var \DmitryDulepov\Myext\\Domain\Repository\RecordRepository
* @inject
*/
protected $recordRepository;
/**
* The usual action to show a single view of the record.
*
* @param \DmitryDulepov\Myext\Domain\Model\Record $record
* @return void
*/
public function showAction(\DmitryDulepov\Myext\Domain\Model\Record $record) {
if (!$recipe) {
/** @noinspection PhpUndefinedMethodInspection */
$GLOBALS['TSFE']->pageNotFoundAndExit(LocalizationUtility::translate('show.notFound', 'myext'));
}
$this->view->assign('record', $record);
}
/**
* A special action that is called for "Insert records" only.
*
* @return void
*/
public function showFromRecords() {
$contentObject = $this->configurationManager->getContentObject();
if ($contentObject->data['uid']) {
$record = $this->recordRepository->findByUid((int)$contentObject->data['uid']);
$this->forward('show', NULL, NULL, array('record' => $record));
}
}
}
<?php
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToInsertRecords('tx_myext_domain_model_record');
// ...
tt_content.shortcut.20.tables := addToList(tx_myext_domain_model_record)
tx_myext_domain_model_record < plugin.tx_myext
tx_myext_domain_model_record = USER
tx_myext_domain_model_record {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = Pluginname
extensionName = Myext
controllerConfiguration {
MyController {
actions = showFromRecords,show
}
}
vendorName = DmitryDulepov
action = showFromRecords
switchableControllerActions {
MyController {
1 = showFromRecords
2 = show
}
}
}
<?php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('dmitrydulepov.myext', 'Pluginname', array('MyController' => 'show,showFromRecords'));
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment