Example #1
0
 /**
  * Delete the token by token string
  *
  * @param string $token Token hash string
  * @return boolean Success/fail of token record deletion
  */
 public function deleteToken($token)
 {
     $tokenModel = new \Psecio\Gatekeeper\AuthTokenModel($this->datasource);
     $token = $this->datasource->find($tokenModel, array('token' => $token));
     if ($token !== false) {
         return $this->datasource->delete($token);
     }
     return false;
 }
Example #2
0
 /**
  * Build the model instance with data given
  *
  * @param string $action Action called (ex: "delete" or "create")
  * @param string $name Function nname
  * @param array $args Arguments set
  * @throws \Exception\ModelNotFoundException If model type is not found
  * @return object Model instance
  */
 public static function buildModel($action = 'find', $name, array $args)
 {
     $name = str_replace($action, '', $name);
     preg_match('/By(.+)/', $name, $matches);
     if (empty($matches) && $args[0] instanceof \Modler\Model) {
         $model = $name;
         $data = $args[0]->toArray();
     } else {
         $property = lcfirst($matches[1]);
         $model = str_replace($matches[0], '', $name);
         $data = array($property => $args[0]);
     }
     $modelNs = '\\Psecio\\Gatekeeper\\' . $model . 'Model';
     if (!class_exists($modelNs)) {
         throw new Exception\ModelNotFoundException('Model type ' . $model . ' could not be found');
     }
     $instance = new $modelNs(self::$datasource);
     $instance = self::$datasource->find($instance, $data);
     return $instance;
 }
Example #3
0
 /**
  * Create our PDO connection, then call parent
  *
  * @param array $config Configuration options
  * @param \PDO $pdo PDO instance
  */
 public function __construct(array $config, \PDO $pdo = null)
 {
     $pdo = $pdo === null ? $this->buildPdo($config) : $pdo;
     $this->setDb($pdo);
     parent::__construct($config);
 }