Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/config/neuron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,18 @@ member:
# Email verification token expiration time (in minutes)
# Tokens older than this will be considered invalid
verification_token_expiration_minutes: 60

# Exception Handling Configuration
exceptions:
# Exceptions that should pass through to application-level handlers
# instead of being caught by the framework's error handler.
# This is useful for custom error pages or specific exception handling logic.
passthrough:
# CMS-specific exceptions that require special handling (redirects, specific error pages)
- Neuron\Cms\Exceptions\UnauthenticatedException
- Neuron\Cms\Exceptions\EmailVerificationRequiredException
- Neuron\Cms\Exceptions\CsrfValidationException
# Additional exceptions can be added as needed
# - RuntimeException
# - LogicException
# - InvalidArgumentException
16 changes: 15 additions & 1 deletion resources/config/neuron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
system:
timezone: UTC
base_path: resources
routes_path: resources/config

logging:
destination: \Neuron\Log\Destination\File
Expand Down Expand Up @@ -82,3 +81,18 @@ member:
# Email verification token expiration time (in minutes)
# Tokens older than this will be considered invalid
verification_token_expiration_minutes: 60

# Exception Handling Configuration
exceptions:
# Exceptions that should pass through to application-level handlers
# instead of being caught by the framework's error handler.
# This is useful for custom error pages or specific exception handling logic.
passthrough:
# CMS-specific exceptions that require special handling (redirects, specific error pages)
- Neuron\Cms\Exceptions\UnauthenticatedException
- Neuron\Cms\Exceptions\EmailVerificationRequiredException
- Neuron\Cms\Exceptions\CsrfValidationException
# Additional exceptions can be added as needed
# - RuntimeException
# - LogicException
# - InvalidArgumentException
8 changes: 0 additions & 8 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@

function boot( string $configPath ) : Application
{
// Register CMS exceptions that should bubble up to application-level handlers
Comment thread
ljonesfl marked this conversation as resolved.
// These exceptions require special handling (redirects, specific error pages)
Registry::getInstance()->set( 'BubbleExceptions', [
'Neuron\\Cms\\Exceptions\\UnauthenticatedException',
'Neuron\\Cms\\Exceptions\\EmailVerificationRequiredException',
'Neuron\\Cms\\Exceptions\\CsrfValidationException'
] );

// Build and register the DI container BEFORE MVC boot
// This ensures the container is available to initializers during boot
try
Expand Down
26 changes: 6 additions & 20 deletions src/Cms/Controllers/Admin/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,37 +35,23 @@ class Categories extends Content
* @param IMvcApplication $app
* @param SettingManager $settings
* @param SessionManager $sessionManager
* @param ICategoryRepository|null $categoryRepository
* @param ICategoryCreator|null $categoryCreator
* @param ICategoryUpdater|null $categoryUpdater
* @param ICategoryRepository $categoryRepository
* @param ICategoryCreator $categoryCreator
* @param ICategoryUpdater $categoryUpdater
*/
public function __construct(
IMvcApplication $app,
SettingManager $settings,
SessionManager $sessionManager,
?ICategoryRepository $categoryRepository = null,
?ICategoryCreator $categoryCreator = null,
?ICategoryUpdater $categoryUpdater = null
ICategoryRepository $categoryRepository,
ICategoryCreator $categoryCreator,
ICategoryUpdater $categoryUpdater
)
{
parent::__construct( $app, $settings, $sessionManager );

if( $categoryRepository === null )
{
throw new \InvalidArgumentException( 'ICategoryRepository must be injected' );
}
$this->_categoryRepository = $categoryRepository;

if( $categoryCreator === null )
{
throw new \InvalidArgumentException( 'ICategoryCreator must be injected' );
}
$this->_categoryCreator = $categoryCreator;

if( $categoryUpdater === null )
{
throw new \InvalidArgumentException( 'ICategoryUpdater must be injected' );
}
$this->_categoryUpdater = $categoryUpdater;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Cms/Controllers/Admin/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Controllers\Content;
use Neuron\Cms\Enums\FlashMessageType;
use Neuron\Core\Exceptions\NotFound;
use Neuron\Data\Settings\SettingManager;
use Neuron\Mvc\IMvcApplication;
Expand Down Expand Up @@ -54,6 +55,8 @@ public function index( Request $request ): string
->description( 'Admin Dashboard' )
->withCurrentUser()
->withCsrfToken()
->with( 'Error', $this->getSessionManager()->getFlash( FlashMessageType::ERROR->value ) )
->with( 'Success', $this->getSessionManager()->getFlash( FlashMessageType::SUCCESS->value ) )
->render( 'index', 'admin' );
}
}
26 changes: 6 additions & 20 deletions src/Cms/Controllers/Admin/EventCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,24 @@ class EventCategories extends Content
* @param IMvcApplication $app
* @param SettingManager $settings
* @param SessionManager $sessionManager
* @param IEventCategoryRepository|null $repository
* @param IEventCategoryCreator|null $creator
* @param IEventCategoryUpdater|null $updater
* @param IEventCategoryRepository $repository
* @param IEventCategoryCreator $creator
* @param IEventCategoryUpdater $updater
* @throws \Exception
*/
public function __construct(
IMvcApplication $app,
SettingManager $settings,
SessionManager $sessionManager,
?IEventCategoryRepository $repository = null,
?IEventCategoryCreator $creator = null,
?IEventCategoryUpdater $updater = null
IEventCategoryRepository $repository,
IEventCategoryCreator $creator,
IEventCategoryUpdater $updater
)
{
parent::__construct( $app, $settings, $sessionManager );

if( $repository === null )
{
throw new \InvalidArgumentException( 'IEventCategoryRepository must be injected' );
}
$this->_repository = $repository;

if( $creator === null )
{
throw new \InvalidArgumentException( 'IEventCategoryCreator must be injected' );
}
$this->_creator = $creator;

if( $updater === null )
{
throw new \InvalidArgumentException( 'IEventCategoryUpdater must be injected' );
}
$this->_updater = $updater;
}

Expand Down
35 changes: 8 additions & 27 deletions src/Cms/Controllers/Admin/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,26 @@ class Events extends Content
* @param IMvcApplication $app
* @param SettingManager $settings
* @param SessionManager $sessionManager
* @param IEventRepository|null $eventRepository
* @param IEventCategoryRepository|null $categoryRepository
* @param IEventCreator|null $creator
* @param IEventUpdater|null $updater
* @param IEventRepository $eventRepository
* @param IEventCategoryRepository $categoryRepository
* @param IEventCreator $creator
* @param IEventUpdater $updater
*/
public function __construct(
IMvcApplication $app,
SettingManager $settings,
SessionManager $sessionManager,
?IEventRepository $eventRepository = null,
?IEventCategoryRepository $categoryRepository = null,
?IEventCreator $creator = null,
?IEventUpdater $updater = null
IEventRepository $eventRepository,
IEventCategoryRepository $categoryRepository,
IEventCreator $creator,
IEventUpdater $updater
)
{
parent::__construct( $app, $settings, $sessionManager );

if( $eventRepository === null )
{
throw new \InvalidArgumentException( 'IEventRepository must be injected' );
}
$this->_eventRepository = $eventRepository;

if( $categoryRepository === null )
{
throw new \InvalidArgumentException( 'IEventCategoryRepository must be injected' );
}
$this->_categoryRepository = $categoryRepository;

if( $creator === null )
{
throw new \InvalidArgumentException( 'IEventCreator must be injected' );
}
$this->_creator = $creator;

if( $updater === null )
{
throw new \InvalidArgumentException( 'IEventUpdater must be injected' );
}
$this->_updater = $updater;
}

Expand Down
17 changes: 4 additions & 13 deletions src/Cms/Controllers/Admin/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,21 @@ class Media extends Content
* @param IMvcApplication $app
* @param SettingManager $settings
* @param SessionManager $sessionManager
* @param CloudinaryUploader|null $uploader
* @param MediaValidator|null $validator
* @param CloudinaryUploader $uploader
* @param MediaValidator $validator
* @throws \Exception
*/
public function __construct(
IMvcApplication $app,
SettingManager $settings,
SessionManager $sessionManager,
?CloudinaryUploader $uploader = null,
?MediaValidator $validator = null
CloudinaryUploader $uploader,
MediaValidator $validator
)
{
parent::__construct( $app, $settings, $sessionManager );

if( $uploader === null )
{
throw new \InvalidArgumentException( 'CloudinaryUploader must be injected' );
}
$this->_uploader = $uploader;

if( $validator === null )
{
throw new \InvalidArgumentException( 'MediaValidator must be injected' );
}
$this->_validator = $validator;
}

Expand Down
26 changes: 6 additions & 20 deletions src/Cms/Controllers/Admin/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,23 @@ class Pages extends Content
* @param IMvcApplication $app
* @param SettingManager $settings
* @param SessionManager $sessionManager
* @param IPageRepository|null $pageRepository
* @param IPageCreator|null $pageCreator
* @param IPageUpdater|null $pageUpdater
* @param IPageRepository $pageRepository
* @param IPageCreator $pageCreator
* @param IPageUpdater $pageUpdater
*/
public function __construct(
IMvcApplication $app,
SettingManager $settings,
SessionManager $sessionManager,
?IPageRepository $pageRepository = null,
?IPageCreator $pageCreator = null,
?IPageUpdater $pageUpdater = null
IPageRepository $pageRepository,
IPageCreator $pageCreator,
IPageUpdater $pageUpdater
)
{
parent::__construct( $app, $settings, $sessionManager );

if( $pageRepository === null )
{
throw new \InvalidArgumentException( 'IPageRepository must be injected' );
}
$this->_pageRepository = $pageRepository;

if( $pageCreator === null )
{
throw new \InvalidArgumentException( 'IPageCreator must be injected' );
}
$this->_pageCreator = $pageCreator;

if( $pageUpdater === null )
{
throw new \InvalidArgumentException( 'IPageUpdater must be injected' );
}
$this->_pageUpdater = $pageUpdater;
}

Expand Down
53 changes: 12 additions & 41 deletions src/Cms/Controllers/Admin/Posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,61 +44,32 @@ class Posts extends Content
* @param IMvcApplication $app
* @param SettingManager $settings
* @param SessionManager $sessionManager
* @param IPostRepository|null $postRepository
* @param ICategoryRepository|null $categoryRepository
* @param ITagRepository|null $tagRepository
* @param IPostCreator|null $postCreator
* @param IPostUpdater|null $postUpdater
* @param IPostDeleter|null $postDeleter
* @param IPostRepository $postRepository
* @param ICategoryRepository $categoryRepository
* @param ITagRepository $tagRepository
* @param IPostCreator $postCreator
* @param IPostUpdater $postUpdater
* @param IPostDeleter $postDeleter
*/
public function __construct(
IMvcApplication $app,
SettingManager $settings,
SessionManager $sessionManager,
?IPostRepository $postRepository = null,
?ICategoryRepository $categoryRepository = null,
?ITagRepository $tagRepository = null,
?IPostCreator $postCreator = null,
?IPostUpdater $postUpdater = null,
?IPostDeleter $postDeleter = null
IPostRepository $postRepository,
ICategoryRepository $categoryRepository,
ITagRepository $tagRepository,
IPostCreator $postCreator,
IPostUpdater $postUpdater,
IPostDeleter $postDeleter
)
{
parent::__construct( $app, $settings, $sessionManager );

if( $postRepository === null )
{
throw new \InvalidArgumentException( 'IPostRepository must be injected' );
}
$this->_postRepository = $postRepository;

if( $categoryRepository === null )
{
throw new \InvalidArgumentException( 'ICategoryRepository must be injected' );
}
$this->_categoryRepository = $categoryRepository;

if( $tagRepository === null )
{
throw new \InvalidArgumentException( 'ITagRepository must be injected' );
}
$this->_tagRepository = $tagRepository;

if( $postCreator === null )
{
throw new \InvalidArgumentException( 'IPostCreator must be injected' );
}
$this->_postCreator = $postCreator;

if( $postUpdater === null )
{
throw new \InvalidArgumentException( 'IPostUpdater must be injected' );
}
$this->_postUpdater = $postUpdater;

if( $postDeleter === null )
{
throw new \InvalidArgumentException( 'IPostDeleter must be injected' );
}
$this->_postDeleter = $postDeleter;
}

Expand Down
Loading