/** * @param ProfileInterface $profile * * @return PersistenceHandlerInterface $this */ public function persist(ProfileInterface $profile) { // This is messed up, but this is finally compatible with XHGui, which is more important to me now. // Find a way to abstract this nicely! BUT FIRST! Release time! YEAH! (I am _SO_ gonna regret this...) $profileArray = $profile->toArray(); $serverData = $profileArray['serverData']; $requestTime = isset($serverData['REQUEST_TIME']) ? $serverData['REQUEST_TIME'] : time(); $requestTimeFloat = isset($serverData['REQUEST_TIME_FLOAT']) ? $serverData['REQUEST_TIME_FLOAT'] : microtime(true); $timeParts = explode('.', $requestTimeFloat); if (!isset($timeParts[1])) { $timeParts[1] = 0; } $scriptName = isset($serverData['SCRIPT_NAME']) ? $serverData['SCRIPT_NAME'] : '__unknown__'; $uri = isset($serverData['REQUEST_URI']) ? $serverData['REQUEST_URI'] : $scriptName; $mongoData = array('identifier' => $profile->getIdentifier(), 'profile' => $profileArray['profileData'], 'meta' => array('url' => $uri, 'SERVER' => $profileArray['serverData'], 'get' => array(), 'env' => array(), 'simple_url' => $uri, 'request_ts' => new MongoDate($requestTime), 'request_ts_micro' => new MongoDate($timeParts[0], $timeParts[1]), 'request_date' => date('Y-m-d', $requestTime))); $this->collection->insert($mongoData); return $this; }
/** * @param ProfileInterface $profile * @throws Exception * @return PersistenceHandlerInterface */ public function persist(ProfileInterface $profile) { $serializer = $this->getSerializer(); $fullPath = $this->getFullPath($profile->getIdentifier()); if ($this->getFilesystem()->put($fullPath, $serializer->serialize($profile->toArray())) === false) { throw new Exception('Unable to persist Profile[identifier=' . $profile->getIdentifier() . ']'); } return $this; }
/** * @param ProfileInterface $profile * @return PersistenceHandlerInterface */ public function persist(ProfileInterface $profile) { $this->state[$profile->getIdentifier()] = $this->getSerializer()->serialize($profile->toArray()); return $this; }
/** * @param ProfileInterface $profile * @return PersistenceHandlerInterface */ public function persist(ProfileInterface $profile) { $sql = $this->getSql(); $insert = $sql->insert()->into($this->getTableName())->values(array($this->getIdentifierColumn() => $profile->getIdentifier(), $this->getDataColumn() => $this->getSerializer()->serialize($profile->toArray()))); $sql->prepareStatementForSqlObject($insert)->execute(); return $this; }