I have a content type called ip_range
and i was trying to create a node programmatically . I tried the follows :
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
$data = array(
'type' => 'ip_range',
'title' => '192.168.7.100/24',
'field_ip_range_gw' => '192.168.7.100',
'field_ip_range_hidden' => '',
'field_ip_range_blocked' => '192.168.7.200',
'field_ip_range_access_type' => 'Blocked',
'field_ip_threshold' => '20',
'field_ip_range_sec_zone' => 'C2',
'field_ip_range_vlan_name' => 'Network58',
'field_ip_range_vlan_tag' => '4054',
'field_ip_range_comment' => 'Ip ranges from 192.168.7.100 to 192.168.7.255',
);
$node = Drupal::entityManager()
->getStorage('node')
->create($data);
$node->save();
But its not creating any . Any idea ?
UPDATE
Its creating the node . But its creating as anonymous user . So i cant see it in front end . That was the problem . How to create it as a admin user ?