Skip to content

Commit

Permalink
Merge pull request #83 from bearsunday/logical-or
Browse files Browse the repository at this point in the history
Refactor QueryRepositoryAopModule
  • Loading branch information
koriym committed Jan 17, 2021
2 parents 2d04e51 + 2c20966 commit 2017c55
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/QueryRepositoryAopModule.php
Expand Up @@ -17,29 +17,35 @@ class QueryRepositoryAopModule extends AbstractModule
*/
protected function configure()
{
// @Cacheable
$this->bindPriorityInterceptor(
$this->matcher->annotatedWith(Cacheable::class),
$this->matcher->startsWith('onGet'),
[CacheInterceptor::class]
);
foreach (['onPost', 'onPut', 'onPatch', 'onDelete'] as $starts) {
$this->bindInterceptor(
$this->matcher->annotatedWith(Cacheable::class),
$this->matcher->startsWith($starts),
[CommandInterceptor::class]
);
$this->bindInterceptor(
$this->matcher->logicalNot(
$this->matcher->annotatedWith(Cacheable::class)
),
$this->bindInterceptor(
$this->matcher->annotatedWith(Cacheable::class),
$this->matcher->logicalOr(
$this->matcher->startsWith('onPost'),
$this->matcher->logicalOr(
$this->matcher->annotatedWith(Purge::class),
$this->matcher->annotatedWith(Refresh::class)
),
[RefreshInterceptor::class]
);
}
$this->matcher->startsWith('onPut'),
$this->matcher->logicalOr(
$this->matcher->startsWith('onPatch'),
$this->matcher->startsWith('onDelete')
)
)
),
[CommandInterceptor::class]
);
$this->bindInterceptor(
$this->matcher->logicalNot(
$this->matcher->annotatedWith(Cacheable::class)
),
$this->matcher->logicalOr(
$this->matcher->annotatedWith(Purge::class),
$this->matcher->annotatedWith(Refresh::class)
),
[RefreshInterceptor::class]
);

$this->bindInterceptor(
$this->matcher->annotatedWith(AbstractCacheControl::class),
Expand Down

0 comments on commit 2017c55

Please sign in to comment.