ArrayFilterEvent::PREPARE_POST_END => 'prepare_body_final',
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'photo_upload_form',
ArrayFilterEvent::NETWORK_TO_NAME => 'network_to_name',
+ ArrayFilterEvent::PARSE_LINK => 'parse_link',
ArrayFilterEvent::CONVERSATION_START => 'conversation_start',
ArrayFilterEvent::FETCH_ITEM_BY_LINK => 'item_by_link',
ArrayFilterEvent::ITEM_TAGGED => 'tagged',
ArrayFilterEvent::PREPARE_POST_END => 'onArrayFilterEvent',
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent',
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
+ ArrayFilterEvent::PARSE_LINK => 'onArrayFilterEvent',
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
ArrayFilterEvent::FETCH_ITEM_BY_LINK => 'onArrayFilterEvent',
ArrayFilterEvent::ITEM_TAGGED => 'onArrayFilterEvent',
public const NETWORK_TO_NAME = 'friendica.data.network_to_name';
+ public const PARSE_LINK = 'friendica.data.parse_link';
+
public const CONVERSATION_START = 'friendica.data.conversation_start';
public const FETCH_ITEM_BY_LINK = 'friendica.data.fetch_item_by_link';
use Friendica\App\BaseURL;
use Friendica\BaseModule;
use Friendica\Content\Text\BBCode;
-use Friendica\Core\Hook;
use Friendica\Core\L10n;
use Friendica\Core\Session\Capability\IHandleUserSessions;
+use Friendica\Event\ArrayFilterEvent;
use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Util;
use Friendica\Util\Profiler;
+use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface;
class ParseUrl extends BaseModule
/** @var IHandleUserSessions */
protected $userSession;
- public function __construct(L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, $server, array $parameters = [])
+ private EventDispatcherInterface $eventDispatcher;
+
+ public function __construct(L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IHandleUserSessions $userSession, EventDispatcherInterface $eventDispatcher, $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->userSession = $userSession;
+ $this->eventDispatcher = $eventDispatcher;
}
protected function rawContent(array $request = [])
}
}
- $arr = ['url' => $url, 'format' => $format, 'text' => null];
+ $hook_data = [
+ 'url' => $url,
+ 'format' => $format,
+ 'text' => null,
+ ];
- Hook::callAll('parse_link', $arr);
+ $hook_data = $this->eventDispatcher->dispatch(
+ new ArrayFilterEvent(ArrayFilterEvent::PARSE_LINK, $hook_data),
+ )->getArray();
- if ($arr['text']) {
+ if ($hook_data['text']) {
if ($format == 'json') {
- $this->jsonExit($arr['text']);
+ $this->jsonExit($hook_data['text']);
} else {
- $this->httpExit($arr['text']);
+ $this->httpExit($hook_data['text']);
}
}
ArrayFilterEvent::PREPARE_POST_END => 'onArrayFilterEvent',
ArrayFilterEvent::PHOTO_UPLOAD_FORM => 'onArrayFilterEvent',
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
+ ArrayFilterEvent::PARSE_LINK => 'onArrayFilterEvent',
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
ArrayFilterEvent::FETCH_ITEM_BY_LINK => 'onArrayFilterEvent',
ArrayFilterEvent::ITEM_TAGGED => 'onArrayFilterEvent',
[ArrayFilterEvent::PREPARE_POST_END, 'prepare_body_final'],
[ArrayFilterEvent::PHOTO_UPLOAD_FORM, 'photo_upload_form'],
[ArrayFilterEvent::NETWORK_TO_NAME, 'network_to_name'],
+ [ArrayFilterEvent::PARSE_LINK, 'parse_link'],
[ArrayFilterEvent::CONVERSATION_START, 'conversation_start'],
[ArrayFilterEvent::FETCH_ITEM_BY_LINK, 'item_by_link'],
[ArrayFilterEvent::ITEM_TAGGED, 'tagged'],
[ArrayFilterEvent::PREPARE_POST_END, 'friendica.data.prepare_post_end'],
[ArrayFilterEvent::PHOTO_UPLOAD_FORM, 'friendica.data.photo_upload_form'],
[ArrayFilterEvent::NETWORK_TO_NAME, 'friendica.data.network_to_name'],
+ [ArrayFilterEvent::PARSE_LINK, 'friendica.data.parse_link'],
[ArrayFilterEvent::CONVERSATION_START, 'friendica.data.conversation_start'],
[ArrayFilterEvent::FETCH_ITEM_BY_LINK, 'friendica.data.fetch_item_by_link'],
[ArrayFilterEvent::ITEM_TAGGED, 'friendica.data.item_tagged'],