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

Commit

Permalink
Added Descriptor facade methods fluent, withModules, withoutModules, …
Browse files Browse the repository at this point in the history
…setScopes, base
  • Loading branch information
breart committed Sep 6, 2017
1 parent f3e212b commit b8c16e6
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ You can disable it by setting to `false` config value `plugin.loadRoutes`.

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

For example, you can customize it by adding to the `app\Providers\AppServiceProvider` in `boot` section the following:

```
Descriptor::base() // base descriptor contents
->setScopes(['admin' , 'act_as_user'])
->withModules([
'webhooks' => [[
'event' => 'jira:issue_created',
'url' => route('webhookHandlerRouteName')
]]
])
->set('version', $this->getLatestPluginVersion());
```

### Console commands

* `plugin:install` is a helper command that creates "dummy" tenant with fake data and publishes package resources (config, views, assets)
Expand Down
71 changes: 71 additions & 0 deletions src/Descriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,77 @@ public function modify(callable $callback)
return $this;
}

/**
* The helper method to use fluent interface
*
* @return $this
*/
public function fluent()
{
return $this;
}

/**
* Set specific modules
*
* @param array $modules
*
* @return $this
*/
public function withModules(array $modules)
{
$this->set('modules', $modules);

return $this;
}

/**
* Remove modules
*
* @return $this
*/
public function withoutModules()
{
$this->set('modules', []);

return $this;
}

/**
* Set scopes
*
* @param array $scopes
*
* @return $this
*/
public function setScopes(array $scopes)
{
$this->set('scopes', $scopes);

return $this;
}

/**
* Set base contents
*
* @return $this
*/
public function base()
{
$this->contents = array_only($this->defaultContents(), [
'name',
'description',
'key',
'baseUrl',
'vendor',
'version',
'authentication',
'lifecycle'
]);

return $this;
}

/**
* Default descriptor contents
*
Expand Down

0 comments on commit b8c16e6

Please sign in to comment.