Skip to content

Commit

Permalink
Update symfony to latest lts & allow 5+ where easily possible
Browse files Browse the repository at this point in the history
  • Loading branch information
flack committed Jan 7, 2020
1 parent 45ae57e commit 7f30d4f
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 87 deletions.
35 changes: 18 additions & 17 deletions composer.json
Expand Up @@ -36,24 +36,25 @@
"simplepie/simplepie": "^1.5.1",
"studio-42/elfinder": "> 2.1.42",
"swiftmailer/swiftmailer": "^6.2",
"symfony/config": "~3.4 | ^4.0",
"symfony/config": ">=4.4",
"symfony/console" : ">=2.6.0",
"symfony/css-selector": "~3.4 | ^4.0",
"symfony/debug": "~3.4 | ^4.0",
"symfony/dom-crawler": "~3.4 | ^4.0",
"symfony/event-dispatcher": "~3.4 | ^4.0",
"symfony/finder": "~3.4 | ^4.0",
"symfony/form": "~3.4 | ^4.0",
"symfony/http-foundation": "~3.4 | ^4.0",
"symfony/intl": "~3.4 | <4.3",
"symfony/options-resolver": "~3.4 | ^4.0",
"symfony/routing": "~3.4 | ^4.0",
"symfony/security-csrf": "~3.4 | ^4.0",
"symfony/translation": "~3.4 | ^4.0",
"symfony/validator": "~3.4 | ^4.0",
"symfony/var-dumper": "~3.4 | ^4.0",
"symfony/yaml": "~3.4 | ^4.0",
"symfony/http-kernel": "~3.4 | ^4.0",
"symfony/css-selector": ">=4.4",
"symfony/debug": ">=4.4",
"symfony/dom-crawler": ">=4.4",
"symfony/event-dispatcher": ">=4.4",
"symfony/finder": ">=4.4",
"symfony/form": ">=4.4",
"symfony/http-foundation": ">=4.4",
"symfony/intl": ">=4.4",
"symfony/mime": ">=4.4",
"symfony/options-resolver": ">=4.4",
"symfony/routing": "^4.4",
"symfony/security-csrf": ">=4.4",
"symfony/translation": ">=4.4",
"symfony/validator": ">=4.4",
"symfony/var-dumper": ">=4.4",
"symfony/yaml": ">=4.4",
"symfony/http-kernel": ">=4.4",
"cocur/slugify": "^3.2"
},
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions lib/midcom/baseclasses/core/dbobject.php
Expand Up @@ -88,7 +88,7 @@ public static function update_post_ops(midcom_core_dbaobject $object)

$object->_on_updated();

midcom::get()->dispatcher->dispatch(dbaevent::UPDATE, new dbaevent($object));
midcom::get()->dispatcher->dispatch(new dbaevent($object), dbaevent::UPDATE);
}

/**
Expand Down Expand Up @@ -298,7 +298,7 @@ public static function create_post_ops(midcom_core_dbaobject $object)
self::_set_owner_privileges($object);

$object->_on_created();
midcom::get()->dispatcher->dispatch(dbaevent::CREATE, new dbaevent($object));
midcom::get()->dispatcher->dispatch(new dbaevent($object), dbaevent::CREATE);

if ($object->_use_rcs) {
midcom::get()->rcs->update($object, $object->get_rcs_message());
Expand Down Expand Up @@ -431,7 +431,7 @@ public static function delete_tree(midcom_core_dbaobject $object) : bool
public static function delete_post_ops(midcom_core_dbaobject $object)
{
$object->_on_deleted();
midcom::get()->dispatcher->dispatch(dbaevent::DELETE, new dbaevent($object));
midcom::get()->dispatcher->dispatch(new dbaevent($object), dbaevent::DELETE);
if ($object->_use_rcs) {
midcom::get()->rcs->update($object, $object->get_rcs_message());
}
Expand Down Expand Up @@ -673,7 +673,7 @@ public static function refresh(midcom_core_dbaobject $object) : bool
*/
try {
return $object->get_by_id($object->id);
} catch (exception $e) {
} catch (Exception $e) {
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/midcom/core/dbaobject.php
Expand Up @@ -358,7 +358,7 @@ public function approve() : bool
return true;
}
if ($this->__object->approve()) {
midcom::get()->dispatcher->dispatch(dbaevent::APPROVE, new dbaevent($this));
midcom::get()->dispatcher->dispatch(new dbaevent($this), dbaevent::APPROVE);
return true;
}
return false;
Expand All @@ -370,7 +370,7 @@ public function unapprove() : bool
return true;
}
if ($this->__object->unapprove()) {
midcom::get()->dispatcher->dispatch(dbaevent::UNAPPROVE, new dbaevent($this));
midcom::get()->dispatcher->dispatch(new dbaevent($this), dbaevent::UNAPPROVE);
return true;
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions lib/midcom/helper/head.php
Expand Up @@ -6,8 +6,8 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
*/

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\ResponseEvent;

/**
* Helper functions for managing HTML head
Expand Down Expand Up @@ -414,9 +414,9 @@ public function print_head_elements()
* This function renders the elements added by the various add methods
* and injects them into the response
*
* @param FilterResponseEvent $event
* @param ResponseEvent $event
*/
public function inject_head_elements(FilterResponseEvent $event)
public function inject_head_elements(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand Down
12 changes: 6 additions & 6 deletions lib/midcom/services/cache/module/content.php
Expand Up @@ -8,9 +8,9 @@

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;

/**
* This is the Output Caching Engine of MidCOM. It will intercept page output,
Expand Down Expand Up @@ -150,9 +150,9 @@ class midcom_services_cache_module_content extends midcom_services_cache_module
private $context_guids = [];

/**
* @param GetResponseEvent $event
* @param RequestEvent $event
*/
public function on_request(GetResponseEvent $event)
public function on_request(RequestEvent $event)
{
if ($event->isMasterRequest()) {
$request = $event->getRequest();
Expand Down Expand Up @@ -256,9 +256,9 @@ private function _check_hit(Request $request)
* has been called, the cache file will not be written, but the header stuff will be added like
* usual to allow for browser-side caching.
*
* @param FilterResponseEvent $event The request object
* @param ResponseEvent $event The request object
*/
public function on_response(FilterResponseEvent $event)
public function on_response(ResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
Expand Down
8 changes: 5 additions & 3 deletions lib/midcom/services/i18n/main.php
Expand Up @@ -7,6 +7,8 @@
*/

use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\Languages;
use Symfony\Component\Intl\Locales;

/**
* This is a basic MidCOM Service which provides an interfaces to the
Expand Down Expand Up @@ -198,7 +200,7 @@ public function set_charset($charset)
*/
public function set_language($lang) : bool
{
if (Intl::getLocaleBundle()->getLocaleName($lang) === null) {
if (Locales::getName($lang) === null) {
debug_add("Language {$lang} not found.", MIDCOM_LOG_ERROR);
return false;
}
Expand Down Expand Up @@ -358,9 +360,9 @@ private function _load_l10n_db($component, string $database)
*/
public function list_languages() : array
{
$languages = Intl::getLanguageBundle()->getLanguageNames('en');
$languages = Languages::getNames('en');
foreach ($languages as $identifier => &$language) {
$localname = Intl::getLanguageBundle()->getLanguageName($identifier, null, $identifier);
$localname = Languages::getName($identifier, $identifier);
if ($localname != $language) {
$language .= ' (' . $localname . ')';
}
Expand Down
4 changes: 2 additions & 2 deletions src/midcom/datamanager/exec/preview-tmpfile.php
@@ -1,5 +1,5 @@
<?php
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
use Symfony\Component\Mime\FileBinaryMimeTypeGuesser;

if (empty($_GET['identifier'])) {
throw new midcom_error_notfound('Identifier missing');
Expand All @@ -11,7 +11,7 @@
}

$guesser = new FileBinaryMimeTypeGuesser();
$mimetype = $guesser->guess($path);
$mimetype = $guesser->guessMimeType($path);

if (!in_array($mimetype, ['image/jpeg', 'image/gif', 'image/png'])) {
throw new midcom_error_notfound('Unsupported mimetype');
Expand Down
8 changes: 1 addition & 7 deletions src/midcom/datamanager/extension/buttonExtension.php
Expand Up @@ -24,13 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
]);
}

// Symfony < 4.2 compat
public function getExtendedType()
{
return ButtonType::class;
}

public static function getExtendedTypes()
public static function getExtendedTypes() : iterable
{
return [ButtonType::class];
}
Expand Down
8 changes: 1 addition & 7 deletions src/midcom/datamanager/extension/formExtension.php
Expand Up @@ -73,13 +73,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
}
}

// Symfony < 4.2 compat
public function getExtendedType()
{
return FormType::class;
}

public static function getExtendedTypes()
public static function getExtendedTypes() : iterable
{
return [FormType::class];
}
Expand Down
8 changes: 1 addition & 7 deletions src/midcom/datamanager/extension/textExtension.php
Expand Up @@ -54,13 +54,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
}

// Symfony < 4.2 compat
public function getExtendedType()
{
return TextType::class;
}

public static function getExtendedTypes()
public static function getExtendedTypes() : iterable
{
return [TextType::class];
}
Expand Down
8 changes: 1 addition & 7 deletions src/midcom/datamanager/extension/textareaExtension.php
Expand Up @@ -51,13 +51,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
$view->vars['output_mode'] = $options['type_config']['output_mode'];
}

// Symfony < 4.2 compat
public function getExtendedType()
{
return TextareaType::class;
}

public static function getExtendedTypes()
public static function getExtendedTypes() : iterable
{
return [TextareaType::class];
}
Expand Down
4 changes: 2 additions & 2 deletions src/midcom/datamanager/helper/imagefilter.php
Expand Up @@ -9,7 +9,7 @@
use midcom_db_attachment;
use midcom_error;
use midgard\portable\api\blob;
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
use Symfony\Component\Mime\FileBinaryMimeTypeGuesser;

/**
* Image filter
Expand Down Expand Up @@ -66,7 +66,7 @@ private function get_attachment(midcom_db_attachment $input, array $existing, st
// upload case
if ($input->id == 0) {
$guesser = new FileBinaryMimeTypeGuesser;
$input->mimetype = $guesser->guess($input->location);
$input->mimetype = $guesser->guessMimeType($input->location);
}

$filename = midcom_db_attachment::safe_filename($identifier . '_' . $input->name, true);
Expand Down
4 changes: 2 additions & 2 deletions src/midcom/datamanager/storage/blobs.php
Expand Up @@ -5,12 +5,12 @@

namespace midcom\datamanager\storage;

use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;
use midcom_db_attachment;
use midcom_error;
use midcom_connection;
use midcom;
use midcom\datamanager\helper\attachment;
use Symfony\Component\Mime\FileBinaryMimeTypeGuesser;

/**
* Experimental storage class
Expand Down Expand Up @@ -69,7 +69,7 @@ public function save()
$filename = midcom_db_attachment::safe_filename($att->name, true);
$title = $att->title ?: $att->name;
$source = $att->location;
$mimetype = $guesser->guess($source);
$mimetype = $guesser->guessMimeType($source);

if (empty($db_att)) {
$db_att = $att;
Expand Down
4 changes: 2 additions & 2 deletions src/midcom/dba/parameters.php
Expand Up @@ -228,7 +228,7 @@ public function set_parameter($domain, $name, $value) : bool
self::$parameter_cache[$this->guid][$domain][$name] = $value;
}

midcom::get()->dispatcher->dispatch(dbaevent::PARAMETER, new dbaevent($this));
midcom::get()->dispatcher->dispatch(new dbaevent($this), dbaevent::PARAMETER);

return true;
}
Expand Down Expand Up @@ -278,7 +278,7 @@ public function delete_parameter($domain, $name) : bool
// Unset via MgdSchema API directly
$result = $this->__object->set_parameter($domain, $name, '');

midcom::get()->dispatcher->dispatch(dbaevent::PARAMETER, new dbaevent($this));
midcom::get()->dispatcher->dispatch(new dbaevent($this), dbaevent::PARAMETER);

return $result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/midcom/events/dbaevent.php
Expand Up @@ -8,7 +8,7 @@

namespace midcom\events;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;
use midcom_core_dbaobject;

/**
Expand Down
20 changes: 10 additions & 10 deletions src/midcom/httpkernel/subscriber.php
Expand Up @@ -12,15 +12,15 @@
use midcom_response_styled;
use midcom_baseclasses_components_handler;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use midcom\routing\resolver;
use Symfony\Component\HttpFoundation\Request;
use midcom;
use midcom_connection;
use midcom_core_context;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
use Symfony\Component\HttpKernel\Event\ViewEvent;

/**
* @package midcom.httpkernel
Expand Down Expand Up @@ -63,9 +63,9 @@ private function initialize(Request $request)
}

/**
* @param GetResponseEvent $event
* @param RequestEvent $event
*/
public function on_request(GetResponseEvent $event)
public function on_request(RequestEvent $event)
{
$request = $event->getRequest();
if (!$this->initialized) {
Expand All @@ -86,7 +86,7 @@ public function on_request(GetResponseEvent $event)
$request->attributes->set('data', '__request_data__');
}

public function on_arguments(FilterControllerArgumentsEvent $event)
public function on_arguments(ControllerArgumentsEvent $event)
{
$arguments = $event->getArguments();
foreach ($arguments as $i => $argument) {
Expand All @@ -98,7 +98,7 @@ public function on_arguments(FilterControllerArgumentsEvent $event)
$event->setArguments($arguments);
}

public function on_view(GetResponseForControllerResultEvent $event)
public function on_view(ViewEvent $event)
{
$attributes = $event->getRequest()->attributes;
$controller = $attributes->get('_controller');
Expand All @@ -108,9 +108,9 @@ public function on_view(GetResponseForControllerResultEvent $event)
$event->setResponse(new midcom_response_styled($attributes->get('context')));
}

public function on_exception(GetResponseForExceptionEvent $event)
public function on_exception(ExceptionEvent $event)
{
$handler = new \midcom_exception_handler();
$event->setResponse($handler->render($event->getException()));
$event->setResponse($handler->render($event->getThrowable()));
}
}

0 comments on commit 7f30d4f

Please sign in to comment.