mirror of
https://github.com/flarum/core.git
synced 2025-07-25 18:51:40 +02:00
Update various event APIs
This commit is contained in:
@@ -17,7 +17,7 @@ abstract class AbstractConfigureGambits
|
|||||||
/**
|
/**
|
||||||
* @var GambitManager
|
* @var GambitManager
|
||||||
*/
|
*/
|
||||||
protected $gambits;
|
public $gambits;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param GambitManager $gambits
|
* @param GambitManager $gambits
|
||||||
|
@@ -27,6 +27,15 @@ class ConfigureApiController
|
|||||||
$this->controller = $controller;
|
$this->controller = $controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $controller
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isController($controller)
|
||||||
|
{
|
||||||
|
return $this->controller instanceof $controller;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the serializer that will serialize data for the endpoint.
|
* Set the serializer that will serialize data for the endpoint.
|
||||||
*
|
*
|
||||||
@@ -40,11 +49,11 @@ class ConfigureApiController
|
|||||||
/**
|
/**
|
||||||
* Include the given relationship by default.
|
* Include the given relationship by default.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string|array $name
|
||||||
*/
|
*/
|
||||||
public function addInclude($name)
|
public function addInclude($name)
|
||||||
{
|
{
|
||||||
$this->controller->include[] = $name;
|
$this->controller->include = array_merge($this->controller->include, (array) $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -64,9 +64,9 @@ class ConfigureClientView
|
|||||||
$this->view->addBootstrapper($bootstrapper);
|
$this->view->addBootstrapper($bootstrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTranslations(array $keys)
|
public function addTranslations($keys)
|
||||||
{
|
{
|
||||||
foreach ($keys as $key) {
|
foreach ((array) $keys as $key) {
|
||||||
$this->keys[] = $key;
|
$this->keys[] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,4 +44,14 @@ class GetApiRelationship
|
|||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->relationship = $relationship;
|
$this->relationship = $relationship;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $serializer
|
||||||
|
* @param string $relationship
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isRelationship($serializer, $relationship)
|
||||||
|
{
|
||||||
|
return $this->serializer instanceof $serializer && $this->relationship === $relationship;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,4 +37,14 @@ class GetModelRelationship
|
|||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
$this->relationship = $relationship;
|
$this->relationship = $relationship;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $model
|
||||||
|
* @param string $relationship
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isRelationship($model, $relationship)
|
||||||
|
{
|
||||||
|
return $this->model instanceof $model && $this->relationship === $relationship;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,6 +41,11 @@ class PrepareApiAttributes
|
|||||||
*/
|
*/
|
||||||
public $attributes;
|
public $attributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Flarum\Core\User
|
||||||
|
*/
|
||||||
|
public $actor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AbstractSerializer $serializer The class doing the serializing.
|
* @param AbstractSerializer $serializer The class doing the serializing.
|
||||||
* @param object|array $model The model being serialized.
|
* @param object|array $model The model being serialized.
|
||||||
@@ -51,5 +56,15 @@ class PrepareApiAttributes
|
|||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->model = $model;
|
$this->model = $model;
|
||||||
$this->attributes = &$attributes;
|
$this->attributes = &$attributes;
|
||||||
|
$this->actor = $serializer->getActor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $serializer
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isSerializer($serializer)
|
||||||
|
{
|
||||||
|
return $this->serializer instanceof $serializer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -37,9 +37,15 @@ class PrepareApiData
|
|||||||
public $document;
|
public $document;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param AbstractSerializeController $endpoint
|
* @var \Flarum\Core\User
|
||||||
|
*/
|
||||||
|
public $actor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AbstractSerializeController $controller
|
||||||
* @param mixed $data
|
* @param mixed $data
|
||||||
* @param ServerRequestInterface $request
|
* @param ServerRequestInterface $request
|
||||||
|
* @param Document $document
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
AbstractSerializeController $controller,
|
AbstractSerializeController $controller,
|
||||||
@@ -51,5 +57,15 @@ class PrepareApiData
|
|||||||
$this->data = &$data;
|
$this->data = &$data;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->document = $document;
|
$this->document = $document;
|
||||||
|
$this->actor = $request->getAttribute('actor');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $controller
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isController($controller)
|
||||||
|
{
|
||||||
|
return $this->controller instanceof $controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user