/** * Entity manager class for storing information and meta-data about entities */ public function entityManager() { if (null === self::$_entityManager) { self::$_entityManager = new Spot_Entity_Manager(); } return self::$_entityManager; }
/** * Authenticate the request * * @throws Saros_Auth_Exception if setCredential hasn't been called * @return Saros_Auth_Result the result of the authentication * * @see Saros_Auth_Result */ public function authenticate() { if (!$this->setCred) { throw new \Saros\Auth\Exception("You must call setCredential before you can authenticate"); } // Get all the users with the identifier of $this->identifier. $user = $this->mapper->all($this->entityName, array($this->identifierCol => $this->identifier))->execute(); /** * @todo figure out which we need. * @todo Documentation needs to mention that we should ALWAYS compare based on the consts of Saros_Auth_Result */ $identity = null; if (!$user || count($user) == 0) { $status = \Saros\Auth\Result::UNKNOWN_USER; } elseif (count($user) > 1) { $status = \Saros\Auth\Result::AMBIGUOUS_ID; } else { // We have exactly one user // We need to get the salt assert(count($user) == 1); $user = $user->first(); $status = $this->validateUser($user); $identity = new \Saros\Auth\Identity\Spot($this->mapper, $user); } return new \Saros\Auth\Result($status, $identity); }