[TYPO3-mvc] 6.2 session handling
Bjoern Haverland
mrwhy at arcor.de
Sun May 11 21:18:36 CEST 2014
Hi Jacco,
please try the following in your QuestionController instead of:
/**
*@var Tx_Jpadvisor_Domain_Repository_QuestionRepository
*/
protected $questionRepository;
protected function initializeAction() {
$this->questionRepository = t3lib_div::makeInstance('Tx_Jpadvisor_Domain_Repository_QuestionRepository');
}
////////////////////////////////////////////////////////////////
just try this:
/**
*@var Tx_Jpadvisor_Domain_Repository_QuestionRepository
*@inject
*/
protected $questionRepository;
Then you could omit your initializeAction.
In the same way you could inject an ObjectManager or your SessionHandler.
With the ObjectManager you could also get an instance of your SessionHandler.
Best regards
Björn
Am 11.05.2014 20:37, schrieb Jacco van der Post:
> Hi Bjoern,
>
> I am not an hero in building extensions and this one I built couple
> years back and works in 4.7.
>
> I am not even sure if the objectManager needs to get injected. I just
> want to be able to use the class SessionHandler.php, a t3lib_Singleton.
>
> Error : http://dev62.typo3-dev.com/index.php?id=6
>
> Code now :
>
> class Tx_Jpadvisor_Domain_Repository_QuestionRepository extends
> Tx_Extbase_Persistence_Repository {
>
> protected $defaultOrderings = array(
> 'sorting' =>
> Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING
> );
>
> /**
> * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
> */
> protected $objectManager;
>
> /**
> * The session handler
> * @var Tx_Jpadvisor_Domain_Session_SessionHandler
> *
> */
> protected $sessionHandler;
>
> /**
> * Injects the object manager
> *
> * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
> $objectManager
> * @return void
> */
> public function
> injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface
> $objectManager) {
> $this->objectManager = $objectManager;
> }
>
> /**
> * @param Tx_Jpadvisor_Domain_Session_SessionHandler $sessionHandler
> * @return void
> */
> public function
> injectSessionHandler(Tx_Jpadvisor_Domain_Session_SessionHandler
> $sessionHandler) {
> $this->sessionHandler =
> $this->objectManager->get('Tx_Jpadvisor_Domain_Session_SessionHandler');
> }
>
>
>
>
>
> This does not give the above error and the session stuf seems to work.
>
> public function __construct() {
> $this->objectManager =
> \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
> $this->sessionHandler =
> $this->objectManager->get('Tx_Jpadvisor_Domain_Session_SessionHandler');
> }
>
> However than I get Fatal error when trying a findAll()
>
> Call to a member function createQueryForType() on a non-object in
> /html/sources/typo3_src-6.2.2/typo3/sysext/extbase/Classes/Persistence/Repository.php
> on line 265
>
>
> Thanks a lot.
>
>
>
>
> Bjoern Haverland schreef op 11-5-2014 20:09:
>
>> occurs the error in the calling controller or directly in the
>> repository? How does your controller inject the repository?
>>
>
More information about the TYPO3-project-typo3v4mvc
mailing list