Skip to content

Commit

Permalink
re-initialization of repository in controller
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBruchmann committed May 14, 2018
1 parent 9824fdb commit b8e46a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Classes/Controller/T3quotesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,21 @@ public function initializeAction()
$this->settings['typo3Version'] = $typo3Version;
$this->settings['typo3VersionArray'] = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionStringToArray($typo3Version);


if (!is_object($this->t3quotesRepository)) {
$this->t3quotesRepository = $this->objectManager->get('WDB\T3quotes\Domain\Repository\t3quotesRepository');
}
if (!is_object($this->ttContentRepository)) {
$this->ttContentRepository = $this->objectManager->get('WDB\T3quotes\Domain\Repository\TtContentRepository');
}
if (!is_object($this->persistenceManager)) {
$this->persistenceManager = $this->objectManager->get('TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager');
}

$this->storagePageIds = \WDB\T3quotes\Utilities\ArrayUtility::getStoragePids($this->getContentObject(), $this->configuration);
$this->t3quotesRepository->setStoragePageIds($this->storagePageIds);
$this->t3quotesRepository->initializeObject();

/*
// storing flatSetup in cache if existing
// or retrieving flatSetup from cache if not existing
Expand Down Expand Up @@ -124,9 +132,6 @@ public function initializeAction()
$this->view->setLayoutRootPaths($this->configuration['view']['layoutRootPaths']);
$this->view->setTemplateRootPaths($this->configuration['view']['templateRootPaths']);
$this->view->setPartialRootPaths($this->configuration['view']['partialRootPaths']);

$storagePageIds = \WDB\T3quotes\Utilities\ArrayUtility::getStoragePids($this->getContentObject(), $this->configuration);
$this->t3quotesRepository->setStoragePageIds($storagePageIds);
}

/**
Expand Down Expand Up @@ -275,6 +280,7 @@ public function updateAction(\WDB\T3quotes\Domain\Model\T3quotes $t3quote)
$this->redirect('edit', 'T3quotes', 't3quotes', ['t3quote'=>$t3quote]);
} else {
// TODO: add choice for action/template [update | show | list]
$this->addFlashMessage($GLOBALS['LANG']->sL('LLL:EXT:t3quotes/Resources/Private/Language/locallang.xlf:tx_t3quotes_domain_model_t3quotes.controllerMessages.updateAction.updated'));
$this->redirect('show', 'T3quotes', 't3quotes', ['t3quote'=>$t3quote]);
}
// $this->t3quotesRepository->persistenceManager->persistAll(); TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager.
Expand Down Expand Up @@ -308,7 +314,7 @@ public function deleteAction(\WDB\T3quotes\Domain\Model\T3quotes $t3quote)
protected function getContentObject()
{
$cObj = $this->configurationManager->getContentObject();
if (isset($cObj->data['uid']) && $cObj->table=='tt_content') {
if (isset($cObj->data['uid']) && $cObj->getCurrentTable()=='tt_content') {
return $cObj;
} else {
$currentRecord = explode(':', $GLOBALS['TSFE']->currentRecord);
Expand Down
5 changes: 5 additions & 0 deletions Classes/Domain/Repository/T3quotesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ public function setStoragePageIds($storagePageIds)
{
$this->storagePageIds = $storagePageIds;
}

public function getStoragePageIds()
{
return $storagePageIds;
}
}
7 changes: 7 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@
<source>Path to template layouts (FE)</source>
<target state="translated">Pfad zu den Layouts (FE)</target>
</trans-unit>

<trans-unit id="tx_t3quotes_domain_model_t3quotes.controllerMessages.updateAction.noObject">
<source>Das Zitat konnte nicht gespeichert werden. Verwenden Sie den "Zurück"-Button des Browsers um eine Wiederherstellung zu versuchen und speichern Sie erneut.</source>
</trans-unit>
<trans-unit id="tx_t3quotes_domain_model_t3quotes.controllerMessages.updateAction.updated">
<source>The quote was updated.</source>
</trans-unit>


<trans-unit id="tx_t3quotes_domain_model_ttcontent.t3quotes_selected">
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
<trans-unit id="tx_t3quotes_domain_model_t3quotes.controllerMessages.updateAction.noObject">
<source>Something went wrong while saving the quote. Use the browser's back-button for trying to recover and save again.</source>
</trans-unit>
<trans-unit id="tx_t3quotes_domain_model_t3quotes.controllerMessages.updateAction.updated">
<source>The quote was updated.</source>
</trans-unit>


<trans-unit id="tx_t3quotes_domain_model_ttcontent.t3quotes_selected">
Expand Down

0 comments on commit b8e46a8

Please sign in to comment.