Skip to content

Commit

Permalink
Support Callable Component Config
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Mar 3, 2021
1 parent 242f874 commit d742495
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,8 @@ You just need input your config like below config. Official Accounts authorizati

// Open Platform - Third-party Platform Need
'component' => [
// or 'app_id', 'component_app_id' as key
'id' => 'component-app-id',
// or 'app_token', 'access_token', 'component_access_token' as key
'token' => 'component-access-token',
'token' => 'component-access-token', // or Using a callable as value.
]
]
],
Expand Down
4 changes: 4 additions & 0 deletions src/Providers/WeChat.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ protected function prepareForComponent()
$component = $this->getConfig()->get('component');

foreach ($component as $key => $value) {
if (\is_callable($value)) {
$value = \call_user_func($value, $this);
}

switch ($key) {
case 'id':
case 'app_id':
Expand Down

0 comments on commit d742495

Please sign in to comment.