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
2 changes: 1 addition & 1 deletion src/Cms/Container/CmsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use Neuron\Cms\Services\User\Deleter;
use Neuron\Cms\Auth\PasswordHasher;
use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Auth\ResendVerificationThrottle;
use Neuron\Cms\Services\Security\ResendVerificationThrottle;
use Neuron\Cms\Services\Content\EditorJsRenderer;
use Neuron\Cms\Services\Content\ShortcodeParser;
use Neuron\Cms\Services\Widget\WidgetRenderer;
Expand Down
17 changes: 17 additions & 0 deletions src/Cms/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

use DI\ContainerBuilder;
use Neuron\Cms\Services\SlugGenerator;
use Neuron\Cms\Services\Content\EditorJsRenderer;
use Neuron\Cms\Services\Media\CloudinaryUploader;
use Neuron\Cms\Services\Media\MediaValidator;
use Neuron\Cms\Services\Security\ResendVerificationThrottle;
use Neuron\Routing\IIpResolver;
use Neuron\Routing\DefaultIpResolver;
use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Auth\PasswordHasher;
use Neuron\Cms\Services\Auth\CsrfToken;
Expand Down Expand Up @@ -230,6 +236,17 @@ public static function build( SettingManager $settings ): IContainer
// Interface Bindings - EventCategory Services
IEventCategoryCreator::class => \DI\autowire( EventCategoryCreator::class ),
IEventCategoryUpdater::class => \DI\autowire( EventCategoryUpdater::class ),

// Content Services
EditorJsRenderer::class => \DI\autowire( EditorJsRenderer::class ),

// Media Services
CloudinaryUploader::class => \DI\autowire( CloudinaryUploader::class ),
MediaValidator::class => \DI\autowire( MediaValidator::class ),

// Security Services
ResendVerificationThrottle::class => \DI\autowire( ResendVerificationThrottle::class ),
IIpResolver::class => \DI\autowire( DefaultIpResolver::class ),
]);

$psr11Container = $builder->build();
Expand Down
32 changes: 25 additions & 7 deletions src/Cms/Controllers/Admin/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace Neuron\Cms\Controllers\Admin;

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Enums\FlashMessageType;
use Neuron\Cms\Controllers\Content;
use Neuron\Cms\Repositories\ICategoryRepository;
use Neuron\Cms\Services\Category\ICategoryCreator;
use Neuron\Cms\Services\Category\ICategoryUpdater;
use Neuron\Core\Exceptions\NotFound;
use Neuron\Data\Settings\SettingManager;
use Neuron\Mvc\Application;
use Neuron\Mvc\Requests\Request;
use Neuron\Mvc\Responses\HttpResponseStatus;
Expand All @@ -34,21 +36,37 @@ class Categories extends Content
* @param ICategoryRepository|null $categoryRepository
* @param ICategoryCreator|null $categoryCreator
* @param ICategoryUpdater|null $categoryUpdater
* @param SettingManager|null $settings
* @param SessionManager|null $sessionManager
*/
public function __construct(
?Application $app = null,
?ICategoryRepository $categoryRepository = null,
?ICategoryCreator $categoryCreator = null,
?ICategoryUpdater $categoryUpdater = null
?ICategoryUpdater $categoryUpdater = null,
?SettingManager $settings = null,
?SessionManager $sessionManager = null
)
{
parent::__construct( $app );
parent::__construct( $app, $settings, $sessionManager );

// Use dependency injection when available (container provides dependencies)
// Otherwise resolve from container (fallback for compatibility)
$this->_categoryRepository = $categoryRepository ?? $app?->getContainer()?->get( ICategoryRepository::class );
$this->_categoryCreator = $categoryCreator ?? $app?->getContainer()?->get( ICategoryCreator::class );
$this->_categoryUpdater = $categoryUpdater ?? $app?->getContainer()?->get( ICategoryUpdater::class );
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
12 changes: 10 additions & 2 deletions src/Cms/Controllers/Admin/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace Neuron\Cms\Controllers\Admin;

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Controllers\Content;
use Neuron\Core\Exceptions\NotFound;
use Neuron\Data\Settings\SettingManager;
use Neuron\Mvc\Application;
use Neuron\Mvc\Requests\Request;
use Neuron\Mvc\Responses\HttpResponseStatus;
Expand All @@ -20,12 +22,18 @@ class Dashboard extends Content
{
/**
* @param Application|null $app
* @param SettingManager|null $settings
* @param SessionManager|null $sessionManager
* @return void
* @throws \Exception
*/
public function __construct( ?Application $app = null )
public function __construct(
?Application $app = null,
?SettingManager $settings = null,
?SessionManager $sessionManager = null
)
{
parent::__construct( $app );
parent::__construct( $app, $settings, $sessionManager );
}


Expand Down
32 changes: 25 additions & 7 deletions src/Cms/Controllers/Admin/EventCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Neuron\Cms\Controllers\Admin;

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Enums\FlashMessageType;
use Neuron\Cms\Controllers\Content;
use Neuron\Cms\Repositories\IEventCategoryRepository;
use Neuron\Cms\Services\EventCategory\IEventCategoryCreator;
use Neuron\Cms\Services\EventCategory\IEventCategoryUpdater;
use Neuron\Data\Settings\SettingManager;
use Neuron\Log\Log;
use Neuron\Mvc\Application;
use Neuron\Mvc\Requests\Request;
Expand Down Expand Up @@ -34,22 +36,38 @@ class EventCategories extends Content
* @param IEventCategoryRepository|null $repository
* @param IEventCategoryCreator|null $creator
* @param IEventCategoryUpdater|null $updater
* @param SettingManager|null $settings
* @param SessionManager|null $sessionManager
* @throws \Exception
*/
public function __construct(
?Application $app = null,
?IEventCategoryRepository $repository = null,
?IEventCategoryCreator $creator = null,
?IEventCategoryUpdater $updater = null
?IEventCategoryUpdater $updater = null,
?SettingManager $settings = null,
?SessionManager $sessionManager = null
)
{
parent::__construct( $app );
parent::__construct( $app, $settings, $sessionManager );

// Use dependency injection when available (container provides dependencies)
// Otherwise resolve from container (fallback for compatibility)
$this->_repository = $repository ?? $app?->getContainer()?->get( IEventCategoryRepository::class );
$this->_creator = $creator ?? $app?->getContainer()?->get( IEventCategoryCreator::class );
$this->_updater = $updater ?? $app?->getContainer()?->get( IEventCategoryUpdater::class );
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
41 changes: 32 additions & 9 deletions src/Cms/Controllers/Admin/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Neuron\Cms\Controllers\Admin;

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Enums\FlashMessageType;
use Neuron\Cms\Controllers\Content;
use Neuron\Cms\Repositories\IEventRepository;
use Neuron\Cms\Repositories\IEventCategoryRepository;
use Neuron\Cms\Services\Event\IEventCreator;
use Neuron\Cms\Services\Event\IEventUpdater;
use Neuron\Cms\Services\Auth\CsrfToken;
use Neuron\Data\Settings\SettingManager;
use Neuron\Log\Log;
use Neuron\Mvc\Application;
use Neuron\Mvc\Requests\Request;
Expand Down Expand Up @@ -39,23 +41,44 @@ class Events extends Content
* @param IEventCategoryRepository|null $categoryRepository
* @param IEventCreator|null $creator
* @param IEventUpdater|null $updater
* @param SettingManager|null $settings
* @param SessionManager|null $sessionManager
*/
public function __construct(
?Application $app = null,
?IEventRepository $eventRepository = null,
?IEventCategoryRepository $categoryRepository = null,
?IEventCreator $creator = null,
?IEventUpdater $updater = null
?IEventUpdater $updater = null,
?SettingManager $settings = null,
?SessionManager $sessionManager = null
)
{
parent::__construct( $app );

// Use dependency injection when available (container provides dependencies)
// Otherwise resolve from container (fallback for compatibility)
$this->_eventRepository = $eventRepository ?? $app?->getContainer()?->get( IEventRepository::class );
$this->_categoryRepository = $categoryRepository ?? $app?->getContainer()?->get( IEventCategoryRepository::class );
$this->_creator = $creator ?? $app?->getContainer()?->get( IEventCreator::class );
$this->_updater = $updater ?? $app?->getContainer()?->get( IEventUpdater::class );
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
29 changes: 21 additions & 8 deletions src/Cms/Controllers/Admin/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace Neuron\Cms\Controllers\Admin;

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Enums\FlashMessageType;
use Neuron\Cms\Controllers\Content;
use Neuron\Cms\Services\Media\CloudinaryUploader;
use Neuron\Cms\Services\Media\MediaValidator;
use Neuron\Data\Settings\SettingManager;
use Neuron\Log\Log;
use Neuron\Mvc\Application;
use Neuron\Mvc\Requests\Request;
Expand All @@ -24,29 +26,40 @@
#[RouteGroup(prefix: '/admin', filters: ['auth'])]
class Media extends Content
{
private ?CloudinaryUploader $_uploader = null;
private ?MediaValidator $_validator = null;
private CloudinaryUploader $_uploader;
private MediaValidator $_validator;

/**
* Constructor
*
* @param Application|null $app
* @param CloudinaryUploader|null $uploader
* @param MediaValidator|null $validator
* @param SettingManager|null $settings
* @param SessionManager|null $sessionManager
* @throws \Exception
*/
public function __construct(
?Application $app = null,
?CloudinaryUploader $uploader = null,
?MediaValidator $validator = null
?MediaValidator $validator = null,
?SettingManager $settings = null,
?SessionManager $sessionManager = null
)
{
parent::__construct( $app );
parent::__construct( $app, $settings, $sessionManager );

// Use dependency injection when available (container provides dependencies)
// Otherwise resolve from container (fallback for compatibility)
$this->_uploader = $uploader ?? $app?->getContainer()?->get( CloudinaryUploader::class );
$this->_validator = $validator ?? $app?->getContainer()?->get( MediaValidator::class );
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
32 changes: 25 additions & 7 deletions src/Cms/Controllers/Admin/Pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace Neuron\Cms\Controllers\Admin;

use Neuron\Cms\Auth\SessionManager;
use Neuron\Cms\Controllers\Content;
use Neuron\Cms\Enums\FlashMessageType;
use Neuron\Cms\Models\Page;
use Neuron\Cms\Repositories\IPageRepository;
use Neuron\Cms\Services\Page\IPageCreator;
use Neuron\Cms\Services\Page\IPageUpdater;
use Neuron\Cms\Services\Auth\CsrfToken;
use Neuron\Data\Settings\SettingManager;
use Neuron\Mvc\Application;
use Neuron\Mvc\Requests\Request;
use Neuron\Mvc\Responses\HttpResponseStatus;
Expand Down Expand Up @@ -38,21 +40,37 @@ class Pages extends Content
* @param IPageRepository|null $pageRepository
* @param IPageCreator|null $pageCreator
* @param IPageUpdater|null $pageUpdater
* @param SettingManager|null $settings
* @param SessionManager|null $sessionManager
*/
public function __construct(
?Application $app = null,
?IPageRepository $pageRepository = null,
?IPageCreator $pageCreator = null,
?IPageUpdater $pageUpdater = null
?IPageUpdater $pageUpdater = null,
?SettingManager $settings = null,
?SessionManager $sessionManager = null
)
{
parent::__construct( $app );
parent::__construct( $app, $settings, $sessionManager );

// Use dependency injection when available (container provides dependencies)
// Otherwise resolve from container (fallback for compatibility)
$this->_pageRepository = $pageRepository ?? $app?->getContainer()?->get( IPageRepository::class );
$this->_pageCreator = $pageCreator ?? $app?->getContainer()?->get( IPageCreator::class );
$this->_pageUpdater = $pageUpdater ?? $app?->getContainer()?->get( IPageUpdater::class );
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
Loading