use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Event\ArrayFilterEvent;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
item_drop($uid, $_REQUEST['dropitems']);
}
- Hook::callAll('post_local_start', $_REQUEST);
+ $eventDispatcher = DI::eventDispatcher();
+
+ $_REQUEST = $eventDispatcher->dispatch(
+ new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL_START, $_REQUEST)
+ )->getArray();
$return_path = $_REQUEST['return'] ?? '';
$preview = intval($_REQUEST['preview'] ?? 0);
System::jsonExit(['preview' => $o]);
}
- Hook::callAll('post_local', $post);
+ $eventDispatcher = DI::eventDispatcher();
+
+ $post = $eventDispatcher->dispatch(
+ new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL, $post)
+ )->getArray();
unset($post['edit']);
unset($post['self']);
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Event\ArrayFilterEvent;
use Friendica\Model\Attach;
use Friendica\Model\Circle;
use Friendica\Model\Contact;
use Friendica\Util\XML;
use GuzzleHttp\Psr7\Uri;
use ImagickException;
+use Psr\EventDispatcher\EventDispatcherInterface;
/**
* A content helper class for displaying items
private $emailer;
/** @var AppHelper */
private $appHelper;
+ private EventDispatcherInterface $eventDispatcher;
- public function __construct(Profiler $profiler, Activity $activity, L10n $l10n, IHandleUserSessions $userSession, Video $bbCodeVideo, ACLFormatter $aclFormatter, IManagePersonalConfigValues $pConfig, BaseURL $baseURL, Emailer $emailer, AppHelper $appHelper)
+ public function __construct(Profiler $profiler, Activity $activity, L10n $l10n, IHandleUserSessions $userSession, Video $bbCodeVideo, ACLFormatter $aclFormatter, IManagePersonalConfigValues $pConfig, BaseURL $baseURL, Emailer $emailer, AppHelper $appHelper, EventDispatcherInterface $eventDispatcher)
{
- $this->profiler = $profiler;
- $this->activity = $activity;
- $this->l10n = $l10n;
- $this->userSession = $userSession;
- $this->bbCodeVideo = $bbCodeVideo;
- $this->aclFormatter = $aclFormatter;
- $this->baseURL = $baseURL;
- $this->pConfig = $pConfig;
- $this->emailer = $emailer;
- $this->appHelper = $appHelper;
+ $this->profiler = $profiler;
+ $this->activity = $activity;
+ $this->l10n = $l10n;
+ $this->userSession = $userSession;
+ $this->bbCodeVideo = $bbCodeVideo;
+ $this->aclFormatter = $aclFormatter;
+ $this->baseURL = $baseURL;
+ $this->pConfig = $pConfig;
+ $this->emailer = $emailer;
+ $this->appHelper = $appHelper;
+ $this->eventDispatcher = $eventDispatcher;
}
/**
Tag::createImplicitMentions($post['uri-id'], $post['thr-parent-id']);
}
- Hook::callAll('post_local_end', $post);
+ $post = $this->eventDispatcher->dispatch(
+ new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL_END, $post)
+ )->getArray();
$author = DBA::selectFirst('contact', ['thumb'], ['uid' => $post['uid'], 'self' => true]);
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
+use Friendica\Event\ArrayFilterEvent;
use Friendica\Model\Post\Category;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
$item['private'] = self::PRIVATE;
}
+ $eventDispatcher = DI::eventDispatcher();
+
if ($notify && $post_local) {
$item['edit'] = false;
$item['parent'] = $parent_id;
$dummy_session = false;
}
- Hook::callAll('post_local', $item);
+ $item = $eventDispatcher->dispatch(
+ new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL, $item)
+ )->getArray();
if ($dummy_session) {
unset($_SESSION['authenticated']);
}
if (empty($item['event-id'])) {
- unset($item['event-id']);
+ if (array_key_exists('event-id', $item)) {
+ unset($item['event-id']);
+ }
$ev = Event::fromBBCode($item['body']);
if ((!empty($ev['desc']) || !empty($ev['summary'])) && !empty($ev['start'])) {
* @return bool
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
- * @hook 'post_local_end'
- * array $arr
- * 'post_id' => ID of posted item
*/
public static function performActivity(int $item_id, string $verb, int $uid, string $allow_cid = null, string $allow_gid = null, string $deny_cid = null, string $deny_gid = null): bool
{
use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Core\System;
use Friendica\Core\Worker;
+use Friendica\Event\ArrayFilterEvent;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Protocol\Delivery;
use Friendica\Util\Profiler;
use Friendica\Util\XML;
+use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
/**
{
/** @var IHandleUserSessions */
private $session;
+ private EventDispatcherInterface $eventDispatcher;
- public function __construct(IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(IHandleUserSessions $session, EventDispatcherInterface $eventDispatcher, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
- $this->session = $session;
+ $this->session = $session;
+ $this->eventDispatcher = $eventDispatcher;
}
protected function post(array $request = [])
Tag::store($item['uri-id'], Tag::HASHTAG, $term);
$post['id'] = $post_id;
- Hook::callAll('post_local_end', $post);
+
+ $post = $this->eventDispatcher->dispatch(
+ new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL_END, $post)
+ )->getArray();
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $post_id]);