mirror of
https://github.com/flarum/core.git
synced 2025-10-11 23:14:29 +02:00
Upgrade to L5 + huge refactor + more. closes #2
New stuff: - Signup + email confirmation. - Updated authentication strategy with remember cookies. closes #5 - New search system with some example gambits! This is cool - check out the source. Fulltext drivers will be implemented as decorators overriding the EloquentPostRepository’s findByContent method. - Lay down the foundation for bootstrapping the Ember app. - Update Web layer’s asset manager to properly publish CSS/JS files. - Console commands to run installation migrations and seeds. Refactoring: - New structure: move models, repositories, commands, and events into their own namespaces, rather than grouping by entity. - All events are classes. - Use L5 middleware and command bus implementations. - Clearer use of repositories and the Active Record pattern. Repositories are used only for retrieval of ActiveRecord objects, and then save/delete operations are called directly on those ActiveRecords. This way, we don’t over-abstract at the cost of Eloquent magic, but testing is still easy. - Refactor of Web layer so that it uses the Actions routing architecture. - “Actor” concept instead of depending on Laravel’s Auth. - General cleanup!
This commit is contained in:
19
src/Core/Support/Actor.php
Executable file
19
src/Core/Support/Actor.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php namespace Flarum\Core\Support;
|
||||
|
||||
use Flarum\Core\Models\User;
|
||||
use Flarum\Core\Models\Guest;
|
||||
|
||||
class Actor
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->user ?: new Guest;
|
||||
}
|
||||
|
||||
public function setUser(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
16
src/Core/Support/DispatchesEvents.php
Normal file
16
src/Core/Support/DispatchesEvents.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Flarum\Core\Support;
|
||||
|
||||
trait DispatchesEvents
|
||||
{
|
||||
/**
|
||||
* Dispatch all events for an entity.
|
||||
*
|
||||
* @param object $entity
|
||||
*/
|
||||
public function dispatchEventsFor($entity)
|
||||
{
|
||||
foreach ($entity->releaseEvents() as $event) {
|
||||
event($event);
|
||||
}
|
||||
}
|
||||
}
|
33
src/Core/Support/EventGenerator.php
Normal file
33
src/Core/Support/EventGenerator.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php namespace Flarum\Core\Support;
|
||||
|
||||
trait EventGenerator
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $pendingEvents = [];
|
||||
|
||||
/**
|
||||
* Raise a new event
|
||||
*
|
||||
* @param $event
|
||||
*/
|
||||
public function raise($event)
|
||||
{
|
||||
$this->pendingEvents[] = $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return and reset all pending events
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function releaseEvents()
|
||||
{
|
||||
$events = $this->pendingEvents;
|
||||
|
||||
$this->pendingEvents = [];
|
||||
|
||||
return $events;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user