mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Typehint container contract instead of application class.
This helps us in decoupling from Laravel, as we only need any implementation of the container contract now.
This commit is contained in:
parent
7513b50f8f
commit
68f68171cc
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Flarum\Core\Models\Activity;
|
||||
use Flarum\Api\Serializers\ActivitySerializer;
|
||||
|
||||
|
@ -16,7 +16,7 @@ class ActivityType implements ExtenderInterface
|
|||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$class = $this->class;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class ApiInclude implements ExtenderInterface
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ class ApiInclude implements ExtenderInterface
|
|||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
foreach ((array) $this->actions as $action) {
|
||||
$parts = explode('.', $action);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class DiscussionGambit implements ExtenderInterface
|
||||
{
|
||||
|
@ -11,9 +11,9 @@ class DiscussionGambit implements ExtenderInterface
|
|||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$app['events']->listen('Flarum\Core\Events\RegisterDiscussionGambits', function ($event) {
|
||||
$container->make('events')->listen('Flarum\Core\Events\RegisterDiscussionGambits', function ($event) {
|
||||
$event->gambits->add($this->class);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class EventSubscribers implements ExtenderInterface
|
||||
{
|
||||
|
@ -11,10 +11,10 @@ class EventSubscribers implements ExtenderInterface
|
|||
$this->subscribers = $subscribers;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
foreach ((array) $this->subscribers as $subscriber) {
|
||||
$app['events']->subscribe($subscriber);
|
||||
$container->make('events')->subscribe($subscriber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
interface ExtenderInterface
|
||||
{
|
||||
public function extend(Application $app);
|
||||
public function extend(Container $container);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class Formatter implements ExtenderInterface
|
||||
{
|
||||
|
@ -17,8 +17,8 @@ class Formatter implements ExtenderInterface
|
|||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$app['flarum.formatter']->add($this->name, $this->class, $this->priority);
|
||||
$container->make('flarum.formatter')->add($this->name, $this->class, $this->priority);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class ForumAssets implements ExtenderInterface
|
||||
{
|
||||
|
@ -11,9 +11,9 @@ class ForumAssets implements ExtenderInterface
|
|||
$this->files = $files;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$app['events']->listen('Flarum\Forum\Events\RenderView', function ($event) {
|
||||
$container->make('events')->listen('Flarum\Forum\Events\RenderView', function ($event) {
|
||||
$event->assets->addFile($this->files);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Flarum\Core\Models\Notification;
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Api\Serializers\NotificationSerializer;
|
||||
|
@ -26,7 +26,7 @@ class NotificationType implements ExtenderInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$class = $this->class;
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Flarum\Core\Models\Permission as PermissionModel;
|
||||
use Flarum\Extend\SerializeAttributes;
|
||||
|
||||
class Permission implements ExtenderInterface
|
||||
{
|
||||
|
@ -31,7 +30,7 @@ class Permission implements ExtenderInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
PermissionModel::addPermission($this->permission);
|
||||
|
||||
|
@ -45,7 +44,7 @@ class Permission implements ExtenderInterface
|
|||
}
|
||||
);
|
||||
|
||||
$extender->extend($app);
|
||||
$extender->extend($container);
|
||||
}
|
||||
|
||||
foreach ($this->grant as $callback) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Flarum\Core\Models\Post;
|
||||
|
||||
class PostType implements ExtenderInterface
|
||||
|
@ -12,7 +12,7 @@ class PostType implements ExtenderInterface
|
|||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
Post::addType($this->class);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Closure;
|
||||
|
||||
class Relationship implements ExtenderInterface
|
||||
|
@ -21,7 +21,7 @@ class Relationship implements ExtenderInterface
|
|||
$this->child = $child;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$parent = $this->parent;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
|
||||
class SerializeAttributes implements ExtenderInterface
|
||||
{
|
||||
|
@ -15,9 +14,9 @@ class SerializeAttributes implements ExtenderInterface
|
|||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$app['events']->listen('Flarum\Api\Events\SerializeAttributes', function ($event) {
|
||||
$container->make('events')->listen('Flarum\Api\Events\SerializeAttributes', function ($event) {
|
||||
if ($event->serializer instanceof $this->serializer) {
|
||||
call_user_func_array($this->callback, [&$event->attributes, $event->model, $event->serializer]);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Closure;
|
||||
|
||||
class SerializeRelationship implements ExtenderInterface
|
||||
|
@ -21,7 +21,7 @@ class SerializeRelationship implements ExtenderInterface
|
|||
$this->child = $child;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
public function extend(Container $container)
|
||||
{
|
||||
$parent = $this->parent;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user