1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 09:41:26 +02:00

Merge branch 'master' into psr-7

Conflicts:
	src/Api/Actions/Discussions/IndexAction.php
	src/Api/Actions/SerializeAction.php
	src/Core/Formatter/FormatterManager.php
	src/Extend/ForumAssets.php
	src/Forum/Actions/IndexAction.php
	src/Forum/ForumServiceProvider.php
This commit is contained in:
Franz Liedke
2015-06-17 00:52:50 +02:00
91 changed files with 1381 additions and 523 deletions

View File

@@ -0,0 +1,18 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
class AdminTranslations implements ExtenderInterface
{
protected $keys;
public function __construct($keys)
{
$this->keys = $keys;
}
public function extend(Container $container)
{
}
}

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;
}
}
}
}

View File

@@ -14,7 +14,7 @@ class ForumAssets implements ExtenderInterface
public function extend(Container $container)
{
$container->make('events')->listen('Flarum\Forum\Events\RenderView', function ($event) {
$event->assets->addFile($this->files);
$event->assets->addFiles($this->files);
});
}
}

View File

@@ -0,0 +1,19 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
use Flarum\Forum\Actions\IndexAction;
class ForumTranslations implements ExtenderInterface
{
protected $keys;
public function __construct($keys)
{
$this->keys = $keys;
}
public function extend(Container $container)
{
IndexAction::$translations = array_merge(IndexAction::$translations, $this->keys);
}
}

View File

@@ -0,0 +1,57 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
class Locale implements ExtenderInterface
{
protected $locale;
protected $translations;
protected $config;
protected $js;
public function __construct($locale)
{
$this->locale = $locale;
}
public function translations($translations)
{
$this->translations = $translations;
return $this;
}
public function config($config)
{
$this->config = $config;
return $this;
}
public function js($js)
{
$this->js = $js;
return $this;
}
public function extend(Container $container)
{
$manager = $container->make('flarum.localeManager');
if ($this->translations) {
$manager->addTranslations($this->locale, $this->translations);
}
if ($this->config) {
$manager->addConfig($this->locale, $this->config);
}
if ($this->js) {
$manager->addJsFile($this->locale, $this->js);
}
}
}

View File

@@ -7,17 +7,19 @@ class Relationship implements ExtenderInterface
{
protected $parent;
protected $type;
protected $name;
protected $type;
protected $child;
public function __construct($parent, $type, $name, $child = null)
protected $table;
public function __construct($parent, $name, $type, $child = null)
{
$this->parent = $parent;
$this->type = $type;
$this->name = $name;
$this->type = $type;
$this->child = $child;
}
@@ -30,6 +32,8 @@ class Relationship implements ExtenderInterface
return call_user_func($this->type, $model);
} elseif ($this->type === 'belongsTo') {
return $model->belongsTo($this->child, null, null, $this->name);
} elseif ($this->type === 'belongsToMany') {
return $model->belongsToMany($this->child, $this->table, null, null, $this->name);
} else {
// @todo
}