Drupal 8 basic query work

Submitted by barnettech on Sun, 02/17/2019 - 14:43
$connection = \Drupal::database();
    $query = $connection->query("SELECT * FROM {node} n WHERE type > :type", [
      ':type' => 'article',
    ]);
    $result = $query->fetchAll();
    foreach ($result as $item) {
      $node = \Drupal\node\Entity\Node::load($item->nid);
      //dpm($node);
      $title = $node->get('title')->getValue();
      $title = $title[0]['value']);

Return HTML from a Drupal 8 form

Submitted by barnettech on Wed, 02/13/2019 - 15:09
<?php

/**
 * @file
 * Contains \Drupal\flippersearch\Form\flippersearch.
 */

namespace Drupal\flippersearch\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;

class flippersearch extends FormBase {

  /**
   *  {@inheritdoc}
   */
  public function getFormId() {
    return 'flippersearch_form';
  }

  /**
   * {@inheritdoc}
   *
   * @param \Symfony\Component\HttpFoundation\Request $request
   *   The request object.
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    // Use the Form API to define form elements.