mirror of
https://github.com/archtechx/tenancy.git
synced 2026-08-06 11:04:04 +00:00
Clarify how the pivot saving listener throws
The comment said an exception is thrown but not how -- it happens indirectly via findCentralResource() -> getResourceClass(). Also added a @throws annotation to getCentralResourceAndTenant().
This commit is contained in:
parent
d2fb4bc0d5
commit
7900457254
1 changed files with 7 additions and 3 deletions
|
|
@ -22,9 +22,9 @@ trait TriggerSyncingEvents
|
||||||
public static function bootTriggerSyncingEvents(): void
|
public static function bootTriggerSyncingEvents(): void
|
||||||
{
|
{
|
||||||
static::saving(static function (self $pivot) {
|
static::saving(static function (self $pivot) {
|
||||||
// Try getting the central resource to see if it is available
|
// Try getting the central resource to see if it is available.
|
||||||
// If it is not available, throw an exception to interrupt the saving process
|
// If it is not, getCentralResourceAndTenant() throws (indirectly, via findCentralResource() -> getResourceClass()),
|
||||||
// And prevent creating a pivot record without a central resource
|
// interrupting the save, preventing the creation of a pivot record without a central resource.
|
||||||
$pivot->getCentralResourceAndTenant();
|
$pivot->getCentralResourceAndTenant();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -56,6 +56,10 @@ trait TriggerSyncingEvents
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws CentralResourceNotAvailableInPivotException Throws when the tenant is the pivot parent
|
||||||
|
* but the central resource class cannot be resolved (thrown indirectly via findCentralResource() -> getResourceClass())
|
||||||
|
*/
|
||||||
public function getCentralResourceAndTenant(): array
|
public function getCentralResourceAndTenant(): array
|
||||||
{
|
{
|
||||||
/** @var $this&Pivot $this */
|
/** @var $this&Pivot $this */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue