public function getMainNode($returnId = true)
    {
        $node = \Drupal::routeMatch()->getParameter('node');
        if ($node)
        {
            return $returnId ? $node->id() : $node;
        }


        return null;
    }
public function getMainNode($returnId = true)
    {
        $node = \Drupal::routeMatch()->getParameter('node');
        if ($node)
        {
            return $returnId ? $node->id() : $node;
        }


        return null;
    }
public function getMainNode ( $ returnId = true ) { $ node = \ Drupal :: routeMatch ( ) -> getParameter ( 'node' ) ; if ( $ node ) { return $ returnId ? $ node -> id ( ) : $ node ; } return null ; }
Load main node object anywhere
@param bool|true $returnId
@return mixed|null
Load main node object anywhere