Skip to main content

Posts

Showing posts from 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();

Drupal 8 how to delete the View Config entity while uninstalling the module?

Please  see the link https://www.drupal.org/node/2565543 Or in the hook_uninstall() using the following code // Deleting the views while uninstalling. \Drupal::configFactory()->getEditable('views.view.scheduled_content')->delete(); OR you can use the following code,  $entityView = \Drupal::entityTypeManager()->getStorage('view')->load('test_view_to_delete'); $entityView->delete();