Skip to content

Commit 267c4fb

Browse files
committed
Change messaging to notifier
1 parent 6106b83 commit 267c4fb

46 files changed

Lines changed: 292 additions & 244 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3333
- Added connection state validation with `ensureConnection()` method
3434
- **Environment Configuration**: Fixed path handling by removing unreliable `realpath()` usage
3535
- **Configuration Loader**: Improved validation and error handling
36-
- **Messaging System**: Fixed PHPUnit mock issues and corrected type signatures
36+
- **Notifier System**: Fixed PHPUnit mock issues and corrected type signatures
3737
- **Test Suite**: Renamed test methods to snake_case for consistency
3838
- **Database Tests**: Significantly expanded test coverage across connection, migration, pagination, and query builders
3939

@@ -44,7 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4444
- **FTP Service**: Fixed directory listing parser to handle filenames with spaces
4545
- **FTP Service**: Improved error messages with connection details
4646
- **Environment Configuration**: Fixed `Env::configure()` error handling
47-
- **Queue Tests**: Fixed mock configuration issues in MessagingTest
47+
- **Queue Tests**: Fixed mock configuration issues in NotifierTest
4848
- **Notification Tests**: Added missing timestamp columns in test schema
4949

5050
### Improved

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ The project is organized into the following directories, each representing an in
151151
- **Event/**: Event management and dispatching.
152152
- **Http/**: HTTP requests and responses management.
153153
- **Mail/**: Email sending and configuration.
154-
- **Messaging/**: Messaging and notifications.
154+
- **Notifier/**: Notifications.
155155
- **Middleware/**: Middleware classes for request handling.
156156
- **Queue/**: Job queues and background processing.
157157
- **Router/**: HTTP request routing.

src/Configuration/EnvConfiguration.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ class EnvConfiguration extends Configuration
1313
*/
1414
public function create(Loader $config): void
1515
{
16-
Env::configure(base_path('.env.json'));
16+
$this->container->bind('env', function () {
17+
Env::configure(base_path('.env.json'));
1718

18-
$event = Env::getInstance();
19+
$event = Env::getInstance();
1920

20-
$this->container->instance('env', $event);
21+
$this->container->instance('env', $event);
22+
});
2123
}
2224

2325
/**
2426
* @inheritdoc
2527
*/
2628
public function run(): void
2729
{
28-
// Nothing to do
30+
$this->container->make('env');
2931
}
3032
}

src/Console/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Bow\Console\Command\Generator\GenerateSessionCommand;
2222
use Bow\Console\Command\Generator\GenerateAppEventCommand;
2323
use Bow\Console\Command\Generator\GenerateExceptionCommand;
24-
use Bow\Console\Command\Generator\GenerateMessagingCommand;
24+
use Bow\Console\Command\Generator\GenerateNotifierCommand;
2525
use Bow\Console\Command\Generator\GenerateMigrationCommand;
2626
use Bow\Console\Command\Generator\GenerateControllerCommand;
2727
use Bow\Console\Command\Generator\GenerateMiddlewareCommand;
@@ -59,7 +59,7 @@ class Command extends AbstractCommand
5959
"add:listener" => GenerateEventListenerCommand::class,
6060
"add:job" => GenerateJobCommand::class,
6161
"add:command" => GenerateConsoleCommand::class,
62-
"add:message" => GenerateMessagingCommand::class,
62+
"add:notifier" => GenerateNotifierCommand::class,
6363
"run:console" => ReplCommand::class,
6464
"run:server" => ServerCommand::class,
6565
"run:worker" => WorkerCommand::class,

src/Console/Command/Generator/GenerateMessagingCommand.php

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bow\Console\Command\Generator;
6+
7+
use Bow\Console\AbstractCommand;
8+
use Bow\Console\Color;
9+
use Bow\Console\Generator;
10+
11+
class GenerateNotifierCommand extends AbstractCommand
12+
{
13+
/**
14+
* Generate session
15+
*
16+
* @param string $messaging
17+
* @return void
18+
*/
19+
public function run(string $notifier): void
20+
{
21+
$generator = new Generator(
22+
$this->setting->getNotifierDirectory(),
23+
$notifier
24+
);
25+
26+
if ($generator->fileExists()) {
27+
echo Color::red("The notifier already exists");
28+
29+
exit(1);
30+
}
31+
32+
$generator->write('notifier', [
33+
'baseNamespace' => $this->namespaces['notifier'] ?? "App\\Notifier",
34+
]);
35+
36+
echo Color::green("The notifier {$this->setting->getNotifierDirectory()}/{$notifier} has been well created.");
37+
exit(0);
38+
}
39+
}

src/Console/Command/Generator/GenerateRouterResourceCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,12 @@ private function createResourceController(
9999
string $controller,
100100
string $model_namespace = ''
101101
): void {
102-
$generator->write(
103-
'controller/rest',
104-
[
102+
$generator->write('controller/rest', [
105103
'modelNamespace' => $model_namespace,
106104
'prefix' => $prefix,
107105
'className' => $controller,
108106
'baseNamespace' => $this->namespaces['controller'] ?? 'App\\Controllers'
109-
]
110-
);
107+
]);
111108

112109
echo Color::green('The controller Rest was well created.');
113110
}

src/Console/Console.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Console
6363
'job',
6464
'command',
6565
'listener',
66-
'message'
66+
'notifier'
6767
];
6868

6969
/**
@@ -542,7 +542,7 @@ private function help(?string $command = null): int
542542
\033[0;33madd:listener\033[00m Create a new event listener
543543
\033[0;33madd:job\033[00m Create a new job
544544
\033[0;33madd:command\033[00m Create a new console command
545-
\033[0;33madd:message\033[00m Create a new messaging handler
545+
\033[0;33madd:notifier\033[00m Create a new messaging handler
546546
547547
\033[0;32mMIGRATION\033[00m Apply migration to database
548548
\033[0;33mmigration:migrate\033[00m Run migrations
@@ -595,7 +595,7 @@ private function help(?string $command = null): int
595595
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:event name Create a new event listener
596596
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:job name Create a new queue job
597597
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:command name Create a new console command
598-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:message name Create a new messaging handler
598+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:notifier name Create a new messaging handler
599599
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add help Display this help
600600
601601
U;

src/Console/Setting.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ class Setting
171171
private array $namespaces = [];
172172

173173
/**
174-
* The messaging directory
174+
* The notifier directory
175175
*
176176
* @var string
177177
*/
178-
private string $messaging_directory;
178+
private string $notifier_directory;
179179

180180
/**
181181
* Command constructor.
@@ -507,24 +507,24 @@ public function setMiddlewareDirectory(string $middleware_directory): void
507507
}
508508

509509
/**
510-
* Get the messaging directory
510+
* Get the notifier directory
511511
*
512512
* @return string
513513
*/
514-
public function getMessagingDirectory(): string
514+
public function getNotifierDirectory(): string
515515
{
516-
return $this->messaging_directory;
516+
return $this->notifier_directory;
517517
}
518518

519519
/**
520-
* Set the messaging directory
520+
* Set the notifier directory
521521
*
522-
* @param string $messaging_directory
522+
* @param string $notifier_directory
523523
* @return void
524524
*/
525-
public function setMessagingDirectory(string $messaging_directory): void
525+
public function setNotifierDirectory(string $notifier_directory): void
526526
{
527-
$this->messaging_directory = $messaging_directory;
527+
$this->notifier_directory = $notifier_directory;
528528
}
529529

530530
/**

src/Console/stubs/controller/controller.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace {baseNamespace}{namespace};
55
use {baseNamespace}\Controller;
66
use Bow\Http\Request;
77

8-
class {className} extends Controller
8+
class {className}
99
{
1010
//
1111
}

0 commit comments

Comments
 (0)