Skip to content
This repository was archived by the owner on Nov 26, 2023. It is now read-only.

Commit b8c16e6

Browse files
committed
Added Descriptor facade methods fluent, withModules, withoutModules, setScopes, base
1 parent f3e212b commit b8c16e6

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ You can disable it by setting to `false` config value `plugin.loadRoutes`.
152152

153153
You can use `Descriptor` facade to customize or create from scratch your own descriptor contents.
154154

155+
For example, you can customize it by adding to the `app\Providers\AppServiceProvider` in `boot` section the following:
156+
157+
```
158+
Descriptor::base() // base descriptor contents
159+
->setScopes(['admin' , 'act_as_user'])
160+
->withModules([
161+
'webhooks' => [[
162+
'event' => 'jira:issue_created',
163+
'url' => route('webhookHandlerRouteName')
164+
]]
165+
])
166+
->set('version', $this->getLatestPluginVersion());
167+
```
168+
155169
### Console commands
156170

157171
* `plugin:install` is a helper command that creates "dummy" tenant with fake data and publishes package resources (config, views, assets)

src/Descriptor.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,77 @@ public function modify(callable $callback)
106106
return $this;
107107
}
108108

109+
/**
110+
* The helper method to use fluent interface
111+
*
112+
* @return $this
113+
*/
114+
public function fluent()
115+
{
116+
return $this;
117+
}
118+
119+
/**
120+
* Set specific modules
121+
*
122+
* @param array $modules
123+
*
124+
* @return $this
125+
*/
126+
public function withModules(array $modules)
127+
{
128+
$this->set('modules', $modules);
129+
130+
return $this;
131+
}
132+
133+
/**
134+
* Remove modules
135+
*
136+
* @return $this
137+
*/
138+
public function withoutModules()
139+
{
140+
$this->set('modules', []);
141+
142+
return $this;
143+
}
144+
145+
/**
146+
* Set scopes
147+
*
148+
* @param array $scopes
149+
*
150+
* @return $this
151+
*/
152+
public function setScopes(array $scopes)
153+
{
154+
$this->set('scopes', $scopes);
155+
156+
return $this;
157+
}
158+
159+
/**
160+
* Set base contents
161+
*
162+
* @return $this
163+
*/
164+
public function base()
165+
{
166+
$this->contents = array_only($this->defaultContents(), [
167+
'name',
168+
'description',
169+
'key',
170+
'baseUrl',
171+
'vendor',
172+
'version',
173+
'authentication',
174+
'lifecycle'
175+
]);
176+
177+
return $this;
178+
}
179+
109180
/**
110181
* Default descriptor contents
111182
*

0 commit comments

Comments
 (0)