[TYPO3-mvc] Object not always found in repository
Daniel Schöne
daniel at schoene.it
Mon Jun 4 21:39:57 CEST 2012
Hi Kast,
as start and stop time are enable fields it does make sense ;)
cheers,
daniel
On 04.06.2012, at 21:35, ktt wrote:
> strangely, but
>
>
> $query->getQuerySettings()->setRespectEnableFields(FALSE);
>
> helped.
>
>
>
> ________________________________
> From: ktt <kestutis98 at yahoo.com>
> To: "TYPO3-project-typo3v4mvc at lists.typo3.org" <TYPO3-project-typo3v4mvc at lists.typo3.org>
> Sent: Monday, June 4, 2012 10:10 AM
> Subject: [TYPO3-mvc] Object not always found in repository
>
> Hello,
>
>
>
> I'm using Extbase 1.3.2. And noticed, that although the object exists, sometimes repository function doesn't return it.
> Behaviour seems to be random.
>
> Functionality in controller:
>
> $myUsermodel = $this->userRepository->getUserByUsername((string)$username,1);
>
> if ( ($myUsermodel instanceof Tx_Myextension_Domain_Model_Dummyuser) && ($username === $myUsermodel->getUsername()) ){
>
> $myUsermodel->setStarttime($userStartTime);
> $myUsermodel->setEndtime($userEndTime);
> $this->userRepository->update($myUsermodel);
>
> } else {
> ...create new...
>
>
> Functionality in repository:
>
> /*
> *
> * @param string $username The username
> * @param int
> * @return object
> */
> public function getUserByUsername($username, $limit){
> if ($this->identityMap->hasIdentifier($username, $this->objectType)) {
> $object = $this->identityMap->getObjectByIdentifier($username, $this->objectType);
> } else {
>
> $query = $this->createQuery();
> $query->setLimit((integer)$limit);
>
> $query->matching(
> $query->logicalAnd(
> $query->equals('username', (string)$username),
> $query->equals('tx_extbase_type', 'Tx_Myextension_Domain_Model_Dummyuser')
> )
> );
>
> $query->setOrderings(array('uid' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING));
> $result = $query->execute();
>
> $object = NULL;
>
> if (count($result) > 0) {
>
> $object = $result->getFirst();
> $this->identityMap->registerObject($object, $username);
>
> }
>
> }
> return $object;
>
> }
>
> Thank you in advance,
> Kast
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
--
Daniel Schöne
tel.: (0351) 25 38 138
mobil: (0178) 14 81 505
email: daniel at schoene.it
web: http://schoene.it
USt-IdNr.: DE 264 29 88 81
More information about the TYPO3-project-typo3v4mvc
mailing list