[TYPO3-mvc] Object not always found in repository
ktt
kestutis98 at yahoo.com
Mon Jun 4 10:10:09 CEST 2012
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
More information about the TYPO3-project-typo3v4mvc
mailing list