Resolved #3 Added link to selected album

This commit is contained in:
2021-11-27 10:51:30 +01:00
parent 5ef5012224
commit 19db5f3575
3 changed files with 62 additions and 10 deletions

View File

@ -4,11 +4,27 @@ namespace PhotoPrismUpload\API;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\HandlerInterface;
use Psr\Log\LoggerInterface;
use PhotoPrismUpload\Exceptions\NetworkException;
use PhotoPrismUpload\Exceptions\AuthenticationException;
use PhotoPrismUpload\Entities\Album;
class LoggerFactory
{
private static $handlers = [];
public static function addHandler(HandlerInterface $handler) {
self::$handlers[] = $handler;
}
public static function create(string $name) {
$l = new Logger($name);
$l->setHandlers(self::$handlers);
$l->info('Initialized');
return $l;
}
}
class PhotoPrism
{
protected string $base_url = 'https://photos.phlaym.net';
@ -23,12 +39,11 @@ class PhotoPrism
) {
$this->api_url = $this->base_url.'/api/v1';
$this->config = $config;
$this->logger = new Logger('PhotoPrismUpload');
if (empty($log_path)) {
$log_path = __DIR__.'/logs/log.log';
}
$handler = new RotatingFileHandler($log_path, 5, Logger::DEBUG, true);
$this->logger->pushHandler($handler);
LoggerFactory::addHandler(new RotatingFileHandler($log_path, 5, Logger::DEBUG, true));
$this->logger = LoggerFactory::create('PhotoPrismUpload');
if (isset($_SESSION['pp_sessionid'])) {
$this->session_id = $_SESSION['pp_sessionid'];
}

View File

@ -2,6 +2,7 @@
namespace PhotoPrismUpload\Entities;
use Monolog\Logger;
use PhotoPrismUpload\API\LoggerFactory;
class Album
{
@ -16,5 +17,13 @@ class Album
$this->uid = $response['UID'];
$this->slug = $response['Slug'];
$this->title = $response['Title'];
$this->logger = LoggerFactory::create('PhotoPrismUpload.Album');
}
public function getUrlPath(): ?string {
if (empty($this->token)) {
return null;
}
return "/s/{$this->token}/{$this->slug}";
}
}