Add API to add a link to an action

This commit is contained in:
Toby Zerner 2015-06-16 17:39:47 +09:30
parent f0df751465
commit 4b4ff1e7fd

28
src/Extend/ApiLink.php Normal file
View 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;
}
}
}
}