Download the PHP package r4nkt/laravel-resource-tidier without Composer
On this page you can find all versions of the php package r4nkt/laravel-resource-tidier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-resource-tidier
R4nkt's Laravel Resource Tidier
A simple-but-opinionated set of classes that allows for configurable tidying of various user resources. It allows you to configure "tidiers", which find resources that need to be tidied up, culling them, notifying resource owners, and eventually performing the tidying-up task. It also allows for "unmarking" resources if/when the circumstances demand it.
This package was developed to scratch an itch, but it was also inspired by Freek and his blog post about removing inactive users and teams.
It should also be noted that it's the foundation for another r4nkt package, which may be useful in your own projects or as an example on how to use laravel-resource-tidier
.
Finally, it's important to point out that this package benefitted from Spatie's Laravel package skeleton package.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
To get a registered tidier, you can simply use the tidier factory like so:
You can then cull the tidier-specific resources by calling cull()
:
You can also tidy up the culled resources by calling handle()
:
Finally, you can unmark a culled resource by calling unmark()
and passing in the individual resource:
What does it do?
The tidier is a simple class that provides a way to tidy up resources:
- First, it culls any resources that meet specific requirements. Each culled resource is marked for tidying up and the resource owner is notified.
- Second, it allows individual resources that have been culled to be unmarked.
- Finally, it performs the actual tidying up.
An example tidier might be for registered users that have not verified their email addresses. Culling will identify these users and mark them for deletion. Notifications will be sent to the resource owners, which are the users themselves, to let them know that their accounts will be deleted because the emails associated with their accounts haven't been verified. If they happen to verify their email addresses before being deleted, then they will be "unmarked". If nothing is done in time, however, then the unverified user accounts will be deleted.
Tidiers
Tidiers can be registered by name in the configuration file and must identify three items:
culler
unmarker
handler
Cullers
A culler's job is to find resources that meet some criteria, mark them as culled, and notify the individual resource owners.
Cullers can be registered by name in the configuration file and must identifiy three parameters:
finder
marker
notifier
Optionally, a class
that implements R4nkt\ResourceTidier\Actions\Contracts\CullsResources
can be provided.
Unmarkers
An unmarker's job is to unmark an individual resource that has been previously marked.
Unmarkers can be registered by name in the configuration file and must identifiy a class
that implements R4nkt\ResourceTidier\Actions\Contracts\UnmarksResource
.
Optionally, any params
that the unmarkers require can be provided.
Handlers
A handler's job is to handle the tidying up of any culled resources.
Handlers can be registered by name in the configuration file and must identifiy the following parameters:
finder
task
Optionally, a class
that implements R4nkt\ResourceTidier\Actions\Contracts\HandlesResources
can be provided.
Finders
A finder's job is to find resources. They are used by cullers and handlers, but they perform the same general function. For cullers, they are to find resources that should be culled. For handlers, they are to find culled resources that should be tidied up.
Finders can be registered by name in the configuration file and must identifiy a class
that implements R4nkt\ResourceTidier\Actions\Contracts\FindsResources
.
Optionally, any params
that the finders require can be provided.
Markers
A marker's job is to mark individual resources as having been culled.
Markers can be registered by name in the configuration file and must identifiy a class
that implements R4nkt\ResourceTidier\Actions\Contracts\MarksResources
.
Optionally, any params
that the markers require can be provided.
Notifiers
A notifier's job is to notify individual resource owners that their resources have been culled and some sort of impending action is likely to take place.
Notifiers can be registered by name in the configuration file and must identifiy a class
that implements R4nkt\ResourceTidier\Actions\Contracts\NotifiesResourceOwner
.
Optionally, any params
that the notifiers require can be provided.
Tasks
A task's job is to tidy up an individual resource.
Tasks can be registered by name in the configuration file and must identifiy a class
that implements R4nkt\ResourceTidier\Actions\Contracts\ExecutesResourceTask
.
Optionally, any params
that the notifiers require can be provided.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Travis Elkins
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-resource-tidier with dependencies
illuminate/support Version ^8.0
spatie/laravel-package-tools Version ^1.4.3