mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 17:42:29 -04:00
Add newsletter management functionality
This commit is contained in:
parent
90ee0a93c9
commit
b0197d189a
57 changed files with 1017 additions and 143 deletions
5
lib/Exceptions/EbookParsingException.php
Normal file
5
lib/Exceptions/EbookParsingException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class EbookParsingException extends SeException{
|
||||
}
|
5
lib/Exceptions/InvalidAuthorException.php
Normal file
5
lib/Exceptions/InvalidAuthorException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidAuthorException extends SeException{
|
||||
}
|
6
lib/Exceptions/InvalidCaptchaException.php
Normal file
6
lib/Exceptions/InvalidCaptchaException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidCaptchaException extends SeException{
|
||||
protected $message = 'We couldn’t validate your CAPTCHA response.';
|
||||
}
|
5
lib/Exceptions/InvalidCollectionException.php
Normal file
5
lib/Exceptions/InvalidCollectionException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidCollectionException extends SeException{
|
||||
}
|
6
lib/Exceptions/InvalidCredentialsException.php
Normal file
6
lib/Exceptions/InvalidCredentialsException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidCredentialsException extends SeException{
|
||||
protected $message = 'Invalid credentials.';
|
||||
}
|
5
lib/Exceptions/InvalidEbookException.php
Normal file
5
lib/Exceptions/InvalidEbookException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidEbookException extends SeException{
|
||||
}
|
6
lib/Exceptions/InvalidEmailException.php
Normal file
6
lib/Exceptions/InvalidEmailException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidEmailException extends SeException{
|
||||
protected $message = 'We couldn’t understand your email address.';
|
||||
}
|
6
lib/Exceptions/InvalidNewsletterSubscriberException.php
Normal file
6
lib/Exceptions/InvalidNewsletterSubscriberException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidNewsletterSubscriberException extends SeException{
|
||||
protected $message = 'We couldn’t find you in our newsletter subscribers list.';
|
||||
}
|
6
lib/Exceptions/InvalidRequestException.php
Normal file
6
lib/Exceptions/InvalidRequestException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class InvalidRequestException extends SeException{
|
||||
protected $message = 'Invalid request.';
|
||||
}
|
6
lib/Exceptions/NewsletterRequiredException.php
Normal file
6
lib/Exceptions/NewsletterRequiredException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class NewsletterRequiredException extends SeException{
|
||||
protected $message = 'You must select at least one newsletter to subscribe to.';
|
||||
}
|
6
lib/Exceptions/NewsletterSubscriberExistsException.php
Normal file
6
lib/Exceptions/NewsletterSubscriberExistsException.php
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class NewsletterSubscriberExistsException extends SeException{
|
||||
protected $message = 'You’re already subscribed to the newsletter.';
|
||||
}
|
5
lib/Exceptions/NoopException.php
Normal file
5
lib/Exceptions/NoopException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class NoopException extends SeException{
|
||||
}
|
5
lib/Exceptions/SeException.php
Normal file
5
lib/Exceptions/SeException.php
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class SeException extends \Exception{
|
||||
}
|
11
lib/Exceptions/SeeOtherEbookException.php
Normal file
11
lib/Exceptions/SeeOtherEbookException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class SeeOtherEbookException extends SeException{
|
||||
public $Url;
|
||||
|
||||
public function __construct(string $url = ''){
|
||||
$this->Url = $url;
|
||||
parent::__construct('This ebook is at a different URL: ' . $url);
|
||||
}
|
||||
}
|
63
lib/Exceptions/ValidationException.php
Normal file
63
lib/Exceptions/ValidationException.php
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
use function Safe\json_encode;
|
||||
|
||||
class ValidationException extends SeException{
|
||||
public $Exceptions = [];
|
||||
public $HasExceptions = false;
|
||||
public $IsFatal = false;
|
||||
|
||||
public function __toString(): string{
|
||||
$output = '';
|
||||
foreach($this->Exceptions as $exception){
|
||||
$output .= $exception->getMessage() . '; ';
|
||||
}
|
||||
|
||||
return rtrim($output, '; ');
|
||||
}
|
||||
|
||||
public function Add(\Exception $exception, bool $isFatal = false): void{
|
||||
if(is_a($exception, static::class)){
|
||||
foreach($exception->Exceptions as $childException){
|
||||
$this->Add($childException);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->Exceptions[] = $exception;
|
||||
}
|
||||
|
||||
if($isFatal){
|
||||
$this->IsFatal = true;
|
||||
}
|
||||
|
||||
$this->HasExceptions = true;
|
||||
}
|
||||
|
||||
public function Serialize(): string{
|
||||
$val = '';
|
||||
foreach($this->Exceptions as $childException){
|
||||
$val .= $childException->getCode() . ',';
|
||||
}
|
||||
|
||||
$val = rtrim($val, ',');
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function Has(string $exception): bool{
|
||||
foreach($this->Exceptions as $childException){
|
||||
if(is_a($childException, $exception)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function Clear(): void{
|
||||
unset($this->Exceptions);
|
||||
$this->Exceptions = [];
|
||||
$this->HasExceptions = false;
|
||||
}
|
||||
}
|
11
lib/Exceptions/WebhookException.php
Normal file
11
lib/Exceptions/WebhookException.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?
|
||||
namespace Exceptions;
|
||||
|
||||
class WebhookException extends SeException{
|
||||
public $PostData;
|
||||
|
||||
public function __construct(string $message = '', string $data = null){
|
||||
$this->PostData = $data;
|
||||
parent::__construct($message);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue