Add default profile picture path dependency

- Update default profile picture
This commit is contained in:
Hypolite Petovan 2023-07-31 01:11:33 +02:00
parent 95ffadb19f
commit 064fd922e7
4 changed files with 12 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

After

Width:  |  Height:  |  Size: 2.6 KiB

View file

@ -14,12 +14,18 @@ class Photo
* @var \Atlas\Pdo\Connection * @var \Atlas\Pdo\Connection
*/ */
private $atlas; private $atlas;
/**
* @var string
*/
private $defaultProfilePictureSmallPath;
public function __construct( public function __construct(
\Atlas\Pdo\Connection $atlas \Atlas\Pdo\Connection $atlas,
string $defaultProfilePictureSmallPath
) )
{ {
$this->atlas = $atlas; $this->atlas = $atlas;
$this->defaultProfilePictureSmallPath = $defaultProfilePictureSmallPath;
} }
public function render(Request $request, Response $response, array $args): Response public function render(Request $request, Response $response, array $args): Response
@ -30,7 +36,7 @@ class Photo
); );
if (!$data) { if (!$data) {
$data = file_get_contents('public/images/default-profile-sm.jpg'); $data = file_get_contents($this->defaultProfilePictureSmallPath);
} }
//Try and cache our result. //Try and cache our result.

View file

@ -10,7 +10,8 @@ class Photo extends BaseRoute
public function __invoke(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args): \Slim\Http\Response public function __invoke(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args): \Slim\Http\Response
{ {
return (new \Friendica\Directory\Controllers\Api\Photo( return (new \Friendica\Directory\Controllers\Api\Photo(
$this->container->atlas $this->container->atlas,
$this->container->get('defaultProfilePictureSmallPath')
))->render($request, $response, $args); ))->render($request, $response, $args);
} }
} }

View file

@ -99,6 +99,8 @@ $container['http'] = function (ContainerInterface $c): GuzzleHttp\ClientInterfac
return new GuzzleHttp\Client(['timeout' => 20, 'headers' => ['User-Agent' => 'FriendicaDirectory/' . trim($version) . ' ' . \GuzzleHttp\default_user_agent()]]); return new GuzzleHttp\Client(['timeout' => 20, 'headers' => ['User-Agent' => 'FriendicaDirectory/' . trim($version) . ' ' . \GuzzleHttp\default_user_agent()]]);
}; };
$container['defaultProfilePictureSmallPath'] = __DIR__ . '/../public/assets/images/default-profile-sm.jpg';
// Internal Dependency Injection // Internal Dependency Injection
$container[\Friendica\Directory\Models\Profile::class] = function (ContainerInterface $c): Friendica\Directory\Models\Profile { $container[\Friendica\Directory\Models\Profile::class] = function (ContainerInterface $c): Friendica\Directory\Models\Profile {