You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
-86Lines changed: 0 additions & 86 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -285,92 +285,6 @@ class EmailNotifier extends EventListener {
285
285
286
286
Because this class extends `EventListener`, that parent class will manage all the details of determining if `whenJobWasPublished` should be called.
287
287
288
-
### Validation
289
-
290
-
This package also includes a validation trigger automatically. As an example, when you throw a command into the command bus, it will also determine whether an associated validator object exists. If it does,
291
-
it will call a `validate` method on this class. If it doesn't exist, it'll simply continue on. So, this gives you a nice hook to perform validation before executing the command and firing domain events.
So, simply create that class, and include a `validate` method, which we'll receive the `PostJobListingCommand` object. Then, perform your validation however you normally do. I recommend that, for failed validation, you throw an exception - perhaps `ValidationFailedException`. This way, either within your controller - or even `global.php` - you can handle failed validation appropriately (probably by linking back to the form and notifying the user).
297
-
298
-
## Overriding Paths
299
-
300
-
By default, this package makes some assumptions about your file structure. As demonstrated above:
Perhaps you had something different in mind. No problem! Just create your own command translator class that implements the `Laracasts\Commander\CommandTranslator` interface. This interface includes two methods:
306
-
307
-
-`toCommandHandler`
308
-
-`toValidator`
309
-
310
-
Maybe you want to place your validators within a `Validators/` directory. Okay:
311
-
312
-
```php
313
-
<?php namespace Acme\Core;
314
-
315
-
use Laracasts\Commander\CommandTranslator;
316
-
317
-
class MyCommandTranslator implements CommandTranslator {
Now, a `Path/To/MyGreatCommand` will look for a `Path/To/Validators/MyGreatValidator` class instead.
359
-
360
-
> It might be useful to copy and paste the `Laracasts\Commander\BasicCommandTranslator` class, and then modify as needed.
361
-
362
-
The only remaining step is to update the binding in the IoC container.
363
-
364
-
```php
365
-
// We want to use our own custom translator class
366
-
App::bind(
367
-
'Laracasts\Commander\CommandTranslator',
368
-
'Acme\Core\MyCommandTranslator'
369
-
);
370
-
```
371
-
372
-
Done!
373
-
374
288
## File Generation
375
289
376
290
You'll likely find yourself manually creating lots and lots of commands and handler classes. Instead, use the Artisan command that is included with this package!
0 commit comments