/** * 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; }
/** * 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); }