Skip to content

Commit

Permalink
Merge pull request #14207 from jdalsem/event_dispatcher
Browse files Browse the repository at this point in the history
Event dispatcher
  • Loading branch information
jdalsem committed Nov 4, 2022
2 parents 77487ed + 697481f commit ddce45c
Show file tree
Hide file tree
Showing 36 changed files with 832 additions and 718 deletions.
2 changes: 1 addition & 1 deletion engine/classes/Elgg/Application/SystemEventHandlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function init() {
elgg_register_event_handler('registeruser:validate:password', 'all', [_elgg_services()->passwordGenerator, 'registerUserPasswordValidation']);
elgg_register_event_handler('view_vars', 'input/password', [_elgg_services()->passwordGenerator, 'addInputRequirements']);

$widgets = ['online_users', 'new_users', 'content_stats', 'banned_users', 'admin_welcome', 'cron_status'];
$widgets = ['online_users', 'new_users', 'content_stats', 'banned_users', 'admin_welcome', 'cron_status', 'elgg_blog'];
foreach ($widgets as $widget) {
elgg_register_widget_type([
'id' => $widget,
Expand Down
23 changes: 2 additions & 21 deletions engine/classes/Elgg/Assets/ImageFetcherService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Elgg\Cache\SystemCache;
use Elgg\Config;
use Elgg\Exceptions\InvalidArgumentException;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\RequestOptions;
Expand All @@ -25,7 +24,7 @@ class ImageFetcherService {
protected $cache;

/**
* @var \GuzzleHttp\Client
* @var \Elgg\Http\Client
*/
protected $client;

Expand All @@ -51,25 +50,7 @@ public function __construct(Config $config, SystemCache $cache, \ElggSession $se
$this->cache = $cache;
$this->session = $session;

$proxy_config = $this->config->proxy ?? [];

$options = [
RequestOptions::TIMEOUT => 5,
RequestOptions::HTTP_ERRORS => false,
RequestOptions::VERIFY => (bool) elgg_extract('verify_ssl', $proxy_config, true),
];

$host = elgg_extract('host', $proxy_config);
if (!empty($host)) {
$port = (int) elgg_extract('port', $proxy_config);
if ($port > 0) {
$host = rtrim($host, ':') . ":{$port}";
}

$options[RequestOptions::PROXY] = $host;
}

$this->client = new Client($options);
$this->client = elgg_get_http_client();
}

/**
Expand Down
33 changes: 0 additions & 33 deletions engine/classes/Elgg/Controllers/AdminPluginsRefresh.php

This file was deleted.

42 changes: 42 additions & 0 deletions engine/classes/Elgg/Http/Client.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace Elgg\Http;

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\RequestOptions;

/**
* Helper class to construct a Guzzle Client with the correct defaults
*
* @since 5.0
*/
class Client extends GuzzleClient {

/**
* {@inheritdoc}
*/
public function __construct(array $options = []) {

$proxy_config = (array) elgg_get_config('proxy', []);

$defaults = [
RequestOptions::TIMEOUT => 5,
RequestOptions::HTTP_ERRORS => false,
RequestOptions::VERIFY => (bool) elgg_extract('verify_ssl', $proxy_config, true),
];

$host = elgg_extract('host', $proxy_config);
if (!empty($host)) {
$port = (int) elgg_extract('port', $proxy_config);
if ($port > 0) {
$host = rtrim($host, ':') . ":{$port}";
}

$defaults[RequestOptions::PROXY] = $host;
}

$options = array_merge($defaults, $options);

parent::__construct($options);
}
}

0 comments on commit ddce45c

Please sign in to comment.