Ejemplo n.º 1
0
 /**
  * Execute the controller.
  *
  * @return  mixed Return executed result.
  *
  * @throws  \LogicException
  * @throws  \RuntimeException
  */
 public function execute()
 {
     try {
         $id = $this->input->get('id');
         if ($id) {
             $author = Author::getAuthor($id);
             $author->image = "0";
             (new DataMapper('authors'))->updateOne($author, 'id');
         }
     } catch (\Exception $e) {
         $response = new Response();
         $response->setBody(json_encode(['error' => $e->getMessage()]));
         $response->setMimeType('text/json');
         $response->respond();
         exit;
     }
     $return = new Registry();
     $return['success'] = true;
     $return['image'] = UserHelper::getGavatar('*****@*****.**', 400);
     $response = new Response();
     $response->setBody((string) $return);
     $response->setMimeType('text/json');
     $response->respond();
     exit;
 }
Ejemplo n.º 2
0
 /**
  * getAvatar
  *
  * @param integer $pk
  * @param integer $size
  *
  * @return  string
  */
 public static function getAvatar($pk, $size = 48)
 {
     if ($pk instanceof Data) {
         $author = $pk;
     } else {
         $author = static::getAuthor($pk);
     }
     if (!$author->user) {
         return $author->image ?: UserHelper::getGavatar('*****@*****.**', $size);
     }
     return UserHelper::getAvatar($author->user, $size);
 }