You are here

public function SearchByPageTesterTest::search_by_page_test_node_insert in Search by Page 8

Implements hook_node_insert().

Manage the "private" flag on nodes. Code taken form the Node Access Example module on drupal.org.

File

tests/src/Functional/SearchByPageTesterTest.php, line 296
General Functional Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com

Class

SearchByPageTesterTest
Base class for testing Search by Page.

Namespace

Drupal\Tests\search_by_page\Functional

Code

public function search_by_page_test_node_insert($node) {

  // Make sure we are saving an integer for this field!
  if (isset($node->test_private) && $node->test_private) {
    $node->test_private = 1;
  }
  else {
    $node->test_private = 0;
  }
  \Drupal::database()
    ->insert('search_by_page_test_access')
    ->fields(array(
    'nid' => $node->nid,
    'private' => $node->test_private,
  ))
    ->execute();
}