Making url with anchor(fragment) and making url with query string appended

$options = ['fragment' => 'feedback'];
$url = Url::fromRoute('entity.node.canonical', ['node' => 22], $options);

$options = ['query' => ['animal' => 'dog', 'color' => 'black']];
$url = Url::fromRoute('entity.node.canonical', ['node' => 42], $options);

So first would give you  this result 

Some ways to make links in drupal 8

// Link to an internal path defined by a route.
$link = Link::createFromRoute('This is some link', 'entity.node.canonical', ['node' => 22])

// Link to an external URI.
$link = Link::fromTextAndUrl('This is a link', Url::fromUri(''));

// Get output as a render array.

// Get output as a string.

How to create URL's from internal route or external URI

// From a route.
$url = Url::fromRoute('contact.site_page');
// From a URI.
$url = Url::fromUri('');
// From route with additional parameters.
$url = Url::fromRoute('entity.node.canonical', ['node' => 22]);


How to put form in a block programmaticaly

Putting some form in a block is matter of creating a new block and assigning a form to it through form_builder that is called through dependency injection(DI) and then using method getForm that will get rendered array of this form, which is exactly what build method for block expects to output

Event subscribers and listeners, the short version

In drupal 8 we have cool new thing, instead of hooks we can use event subscribers and create event listeners. They do similar things as hooks, we can do something on certain "events" in system, get data and change it or somehow act upon it.

So to subscribe to some event we need to do a service with tags in it, like