mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 07:29:29 +08:00
Add API to add a link to an action
This commit is contained in:
parent
f0df751465
commit
4b4ff1e7fd
28
src/Extend/ApiLink.php
Normal file
28
src/Extend/ApiLink.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
|
||||
class ApiLink implements ExtenderInterface
|
||||
{
|
||||
protected $actions;
|
||||
|
||||
protected $relationships;
|
||||
|
||||
public function __construct($actions, $relationships)
|
||||
{
|
||||
$this->actions = $actions;
|
||||
$this->relationships = $relationships;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
{
|
||||
foreach ((array) $this->actions as $action) {
|
||||
$parts = explode('.', $action);
|
||||
$class = 'Flarum\Api\Actions\\'.ucfirst($parts[0]).'\\'.ucfirst($parts[1]).'Action';
|
||||
|
||||
foreach ((array) $this->relationships as $relationship) {
|
||||
$class::$link[] = $relationship;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user