Restructure src/ and tests/ from package-by-type to package-by-domain
CI / Coding Standards (push) Successful in 43s
CI / PHPStan (push) Successful in 52s
CI / Tests (PHP 8.1) (push) Successful in 47s
CI / Tests (PHP 8.2) (push) Successful in 49s
CI / Tests (PHP 8.3) (push) Successful in 37s
CI / No Debug Code (push) Successful in 2s
CI / Coding Standards (push) Successful in 43s
CI / PHPStan (push) Successful in 52s
CI / Tests (PHP 8.1) (push) Successful in 47s
CI / Tests (PHP 8.2) (push) Successful in 49s
CI / Tests (PHP 8.3) (push) Successful in 37s
CI / No Debug Code (push) Successful in 2s
All classes are now organised by domain (Availability, Booking, Auth). Each domain package contains its value object, repository, admin controller, REST endpoint, and any shortcode pages under a matching sub-namespace. Cross-cutting wiring (Plugin, AdminMenu, RestRegistrar, ShortcodeRegistrar, Schema) lives at src/ root. Tests mirror the domain structure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Unsupervised\Schedular;
|
||||
|
||||
use Unsupervised\Schedular\Availability\AvailabilityController;
|
||||
use Unsupervised\Schedular\Availability\AvailabilityRepository;
|
||||
use Unsupervised\Schedular\Auth\RoleManager;
|
||||
use Unsupervised\Schedular\Booking\BookingRepository;
|
||||
use Unsupervised\Schedular\Booking\LessonController;
|
||||
|
||||
class AdminMenu {
|
||||
|
||||
private AvailabilityController $availabilityController;
|
||||
private LessonController $lessonController;
|
||||
|
||||
public function __construct( AvailabilityRepository $availability, BookingRepository $bookings ) {
|
||||
$this->availabilityController = new AvailabilityController( $availability );
|
||||
$this->lessonController = new LessonController( $bookings );
|
||||
}
|
||||
|
||||
public function register(): void {
|
||||
add_action( 'admin_menu', [ $this, 'addPages' ] );
|
||||
}
|
||||
|
||||
public function addPages(): void {
|
||||
// Admin-only dashboard: all upcoming lessons.
|
||||
add_menu_page(
|
||||
__( 'Scheduler', 'unsupervised-schedular' ),
|
||||
__( 'Scheduler', 'unsupervised-schedular' ),
|
||||
'manage_options',
|
||||
'us-scheduler',
|
||||
[ $this->lessonController, 'renderAdminDashboard' ],
|
||||
'dashicons-calendar-alt',
|
||||
30
|
||||
);
|
||||
|
||||
// Instructor: manage their own availability.
|
||||
add_menu_page(
|
||||
__( 'My Availability', 'unsupervised-schedular' ),
|
||||
__( 'My Availability', 'unsupervised-schedular' ),
|
||||
RoleManager::CAP_MANAGE_AVAILABILITY,
|
||||
'us-availability',
|
||||
[ $this->availabilityController, 'renderPage' ],
|
||||
'dashicons-clock',
|
||||
31
|
||||
);
|
||||
|
||||
// Instructor: view their upcoming lessons.
|
||||
add_menu_page(
|
||||
__( 'My Lessons', 'unsupervised-schedular' ),
|
||||
__( 'My Lessons', 'unsupervised-schedular' ),
|
||||
RoleManager::CAP_VIEW_LESSONS,
|
||||
'us-my-lessons',
|
||||
[ $this->lessonController, 'renderInstructorLessons' ],
|
||||
'dashicons-welcome-learn-more',
|
||||
32
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user