rename/move Api\avatar::lavatar() to Api\Contacts\Lavatar::generate() to be in line with our CS

This commit is contained in:
ralf 2023-01-25 12:27:26 +01:00
parent 6ef78c9591
commit 09ceed3ba2
3 changed files with 8 additions and 9 deletions

View File

@ -34,7 +34,7 @@ function send_image()
header('Content-type: image/jpeg');
header('Etag: '.md5(json_encode($params)));
if (($image = Api\avatar::lavatar($params)) !== false)
if (($image = Api\Contacts\Lavatar::generate($params)) !== false)
{
echo $image;
}
@ -43,4 +43,4 @@ function send_image()
http_response_code(404);
}
exit;
}
}

View File

@ -2732,7 +2732,7 @@ class Contacts extends Contacts\Storage
if(is_array($contact))
{
header('Content-type: image/jpeg');
$contact['jpegphoto'] = \EGroupware\Api\avatar::lavatar(array(
$contact['jpegphoto'] = Contacts\Lavatar::generate(array(
'id' => $contact['id'],
'firstname' => $contact['n_given'],
'lastname' => $contact['n_family'])

View File

@ -7,19 +7,18 @@
* @package api
* @subpackage avatar
* @author Hadi Nategh <hn@egroupware.de>
* @version $Id$
*/
namespace EGroupware\Api;
namespace EGroupware\Api\Contacts;
/**
* Creating letter avatar
*
* lavatar class designed for creating avatar image from given
* Lavatar class designed for creating avatar image from given
* user firstname.lastname and outputs them as in image consist of
* first letter of the firstname plus first letter of the lastname.
*/
class avatar
class Lavatar
{
// background colors
private static $BG_COLORS = array(
@ -67,7 +66,7 @@ class avatar
* )
* @param int $_size = 128 image size, default size is 128
*/
public static function lavatar ($_content = null, $_color = null, $_size = 128)
public static function generate($_content = null, $_color = null, $_size = 128)
{
// firstname
$firstname = isset($_content['firstname'])? $_content['firstname'] : '';
@ -137,4 +136,4 @@ class avatar
$index = $hash % count(self::$BG_COLORS);
return self::$BG_COLORS[$index];
}
}
}