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

Massive refactor

- Use contextual namespaces within Flarum\Core
- Clean up and docblock everything
- Refactor Activity/Notification blueprint stuff
- Refactor Formatter stuff
- Refactor Search stuff
- Upgrade to JSON-API 1.0
- Removed “addedPosts” and “removedPosts” relationships from discussion
API. This was used for adding/removing event posts after renaming a
discussion etc. Instead we should make an additional request to get all
new posts

Todo:
- Fix Extenders and extensions
- Get rid of repository interfaces
- Fix other bugs I’ve inevitably introduced
This commit is contained in:
Toby Zerner
2015-07-04 12:24:48 +09:30
parent 5b7dafa0af
commit 41c5ed0acb
324 changed files with 6443 additions and 4197 deletions

View File

@@ -1,7 +1,7 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
use Flarum\Core\Models\Activity;
use Flarum\Core\Activity\Activity;
use Flarum\Api\Serializers\ActivitySerializer;
class ActivityType implements ExtenderInterface

View File

@@ -1,24 +0,0 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
class Formatter implements ExtenderInterface
{
protected $name;
protected $class;
protected $priority;
public function __construct($name, $class, $priority = 0)
{
$this->name = $name;
$this->class = $class;
$this->priority = $priority;
}
public function extend(Container $container)
{
$container->make('flarum.formatter')->add($this->name, $this->class, $this->priority);
}
}

View File

@@ -82,7 +82,7 @@ class Model implements ExtenderInterface
}
foreach ($this->scopeVisible as $callback) {
$model::addVisiblePostsScope($callback);
$model::addVisibleScope($callback);
}
foreach ($this->allow as $info) {

View File

@@ -1,9 +1,10 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
use Flarum\Core\Models\Notification;
use Flarum\Core\Models\User;
use Flarum\Core\Notifications\Notification;
use Flarum\Core\Users\User;
use Flarum\Api\Serializers\NotificationSerializer;
use ReflectionClass;
class NotificationType implements ExtenderInterface
{
@@ -35,15 +36,16 @@ class NotificationType implements ExtenderInterface
public function extend(Container $container)
{
$class = $this->class;
$type = $class::getType();
Notification::registerType($class);
Notification::setSubjectModel($type, $class);
User::registerPreference(User::notificationPreferenceKey($class::getType(), 'alert'), 'boolval', in_array('alert', $this->enabled));
User::addPreference(User::getNotificationPreferenceKey($type, 'alert'), 'boolval', in_array('alert', $this->enabled));
if ($class::isEmailable()) {
User::registerPreference(User::notificationPreferenceKey($class::getType(), 'email'), 'boolval', in_array('email', $this->enabled));
if ((new ReflectionClass($class))->implementsInterface('Flarum\Core\Notifications\MailableBlueprint')) {
User::addPreference(User::getNotificationPreferenceKey($type, 'email'), 'boolval', in_array('email', $this->enabled));
}
NotificationSerializer::$subjects[$class::getType()] = $this->serializer;
NotificationSerializer::setSubjectSerializer($type, $this->serializer);
}
}

View File

@@ -0,0 +1,20 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
class PostFormatter implements ExtenderInterface
{
protected $class;
protected $priority;
public function __construct($class)
{
$this->class = $class;
}
public function extend(Container $container)
{
$container->make('flarum.formatter')->add($this->class);
}
}

View File

@@ -1,7 +1,7 @@
<?php namespace Flarum\Extend;
use Illuminate\Contracts\Container\Container;
use Flarum\Core\Models\Post;
use Flarum\Core\Posts\Post;
class PostType implements ExtenderInterface
{
@@ -14,6 +14,8 @@ class PostType implements ExtenderInterface
public function extend(Container $container)
{
Post::addType($this->class);
$class = $this->class;
Post::setModel($class::$type, $class);
}
}