Blog Archive

Monday, 14 March 2016

How to create Custom Config Entity Drupal 8

Monday, 29 February 2016

Drupal 8 : How to create the node programaticaly in drupal 8?

use Drupal\Core\Language\LanguageInterface;


$node = Node::create(array(
    'uid' => '1',
    'title' => 'Article Test',
    'type' => 'article',
    'status' => NODE_PUBLISHED,
    'promote' => 1,
    'sticky' => 0,
    'body' => array(
        'value' => 'Hello World!',
    ),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ))->save();
  $node->addTranslation($this->translateToLangcode, array(
    'title' => $this->translatedLabel,
  ));
$node->save();