/** * Tracks display of an object on a page * * @param \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject $object Object to use * @param mixed $hash Hash or page id (depending on the type) for which the object display will be associated * @param string $type 'hash' (for only one hash) or 'id' (for complete page cache of a page, for all hash combinations) * @return void */ public function trackObjectOnPage(\TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject $object = NULL, $type = 'hash', $hash = false) { if ($object && !$this->ajaxDispatcher->getIsActive()) { $this->signalSlotDispatcher->dispatch(__CLASS__, self::SIGNAL_PreTrackObjectOnPage, array('object' => $object, 'type' => $type, 'hash' => $hash)); if ($type) { switch ($type) { case 'id': if (!$hash) { $hash = intval($this->fe->id); } $pageHash = 'id-' . $hash; break; case 'hash': default: if (!$hash) { $hash = $this->fe->getHash(); } $pageHash = 'hash-' . $hash; break; } $objectIdentifier = $this->getObjectIdentifierForObject($object); $sharedLock = null; $sharedLockAcquired = $this->acquireLock($sharedLock, $objectIdentifier, FALSE); if ($sharedLockAcquired) { if ($this->trackingCache->has($objectIdentifier)) { $pageHashs = $this->trackingCache->get($objectIdentifier); if (!in_array($pageHash, $pageHashs)) { $exclusiveLock = null; $exclusiveLockAcquired = $this->acquireLock($exclusiveLock, $objectIdentifier . '-e', TRUE); if ($exclusiveLockAcquired) { $pageHashs = $this->trackingCache->get($objectIdentifier); if (!in_array($pageHash, $pageHashs)) { $pageHashs[] = $pageHash; $this->trackingCache->set($objectIdentifier, array_unique($pageHashs)); } $this->releaseLock($exclusiveLock); } } } else { $this->trackingCache->set($objectIdentifier, array($pageHash)); } $this->releaseLock($sharedLock); } } } return; }