private function _initializeTypes() { static $hasInitialized = false; if (!$hasInitialized) { foreach (StatisticTypes::getTrackerClasses() as $_type => $_class) { if (!\class_exists($_class)) { throw TrackerException::trackerClassDoesNotExist($_class); } $_tracker = new $_class(); if (!$_tracker instanceof Tracker) { throw TrackerException::invalidTrackerClass($_tracker); } // inject dependencies $_tracker->setDoctrine($this->doctrine); $this->trackers[$_type] = $_tracker; } $hasInitialized = true; } }
private function _getCommonAdvertisementStatisticParameters($advertisement) { if ($advertisement instanceof AdvertisementDenormalizedProperty) { // transform to array data $advertisementData = array('id' => $advertisement->getId(), 'institution' => array('id' => $advertisement->getInstitution()->getId())); } else { if (!\is_array($advertisement)) { // unknown hydration type throw TrackerException::unknownAdvertisementDataType(); } $advertisementData = $advertisement; } $parameters = array(StatisticParameters::ADVERTISEMENT_ID => $advertisementData['id'], StatisticParameters::INSTITUTION_ID => $advertisementData['institution']['id'], StatisticParameters::TYPE => StatisticTypes::ADVERTISEMENT); return $parameters; }