-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
326a7b6
commit d397e57
Showing
7 changed files
with
149 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Illuminate/Foundation/Queue/InteractsWithQueueAndConnection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Illuminate\Foundation\Queue; | ||
|
||
use ReflectionClass; | ||
|
||
use function Illuminate\Support\enum_value; | ||
|
||
trait InteractsWithQueueAndConnection | ||
{ | ||
/** | ||
* Extract the connection from OnConnection attribute if present. | ||
* | ||
* @param \ReflectionClass $reflectionClass | ||
* @return string|\UnitEnum|null | ||
*/ | ||
protected function getConnectionFromOnConnectionAttribute(ReflectionClass $reflectionClass) | ||
{ | ||
$onConnection = $reflectionClass->getAttributes(OnConnection::class); | ||
if ($onConnection === []) { | ||
return null; | ||
} | ||
|
||
return enum_value($onConnection[0]->newInstance()->connection); | ||
} | ||
|
||
/** | ||
* Extract the queue from OnQueue attribute if present. | ||
* | ||
* @param \ReflectionClass $reflectionClass | ||
* @return string|\UnitEnum|null | ||
*/ | ||
protected function getQueueFromOnConnectionAttribute(ReflectionClass $reflectionClass) | ||
{ | ||
$onQueue = $reflectionClass->getAttributes(OnQueue::class); | ||
if ($onQueue === []) { | ||
return null; | ||
} | ||
|
||
return enum_value($onQueue[0]->newInstance()->queue); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...oundation/Bus/Attributes/OnConnection.php → ...uminate/Foundation/Queue/OnConnection.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Illuminate\Foundation\Bus\Attributes; | ||
namespace Illuminate\Foundation\Queue; | ||
|
||
use Attribute; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...ate/Foundation/Bus/Attributes/OnQueue.php → src/Illuminate/Foundation/Queue/OnQueue.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Illuminate\Foundation\Bus\Attributes; | ||
namespace Illuminate\Foundation\Queue; | ||
|
||
use Attribute; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters