Skip to main content
create() takes only one argument (probably the api had changed)
Source Link

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there:

*   entity_keys = {
*     "id" = "tid",
*     "bundle" = "vid",
*     "label" = "name",
*     "uuid" = "uuid"
*   },

So, what you want is

$term = Term::create('taxonomy_term', array([
  'name' => 'test', 
  'vid' => 'client',
)])->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there:

*   entity_keys = {
*     "id" = "tid",
*     "bundle" = "vid",
*     "label" = "name",
*     "uuid" = "uuid"
*   },

So, what you want is

$term = Term::create('taxonomy_term', array(
  'name' => 'test', 
  'vid' => 'client',
))->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there:

*   entity_keys = {
*     "id" = "tid",
*     "bundle" = "vid",
*     "label" = "name",
*     "uuid" = "uuid"
*   },

So, what you want is

$term = Term::create([
  'name' => 'test', 
  'vid' => 'client',
])->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.

reformatted, used Term::create
Source Link
user49
user49

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there: `

  • entity_keys = {
  • "id" = "tid",
    
  • "bundle" = "vid",
    
  • "label" = "name",
    
  • "uuid" = "uuid"
    
  • }, `
*   entity_keys = {
*     "id" = "tid",
*     "bundle" = "vid",
*     "label" = "name",
*     "uuid" = "uuid"
*   },

So, what you want is

$term = entity_create('taxonomy_term', array( 'name' => 'test', 'vid' => 'client', ))->save();

$term = Term::create('taxonomy_term', array(
  'name' => 'test', 
  'vid' => 'client',
))->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there: `

  • entity_keys = {
  • "id" = "tid",
    
  • "bundle" = "vid",
    
  • "label" = "name",
    
  • "uuid" = "uuid"
    
  • }, `

So, what you want is

$term = entity_create('taxonomy_term', array( 'name' => 'test', 'vid' => 'client', ))->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there:

*   entity_keys = {
*     "id" = "tid",
*     "bundle" = "vid",
*     "label" = "name",
*     "uuid" = "uuid"
*   },

So, what you want is

$term = Term::create('taxonomy_term', array(
  'name' => 'test', 
  'vid' => 'client',
))->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.

Source Link
user49
user49

You know that you want something from taxonomy module so first you need to look in Drupal\taxonomy\Entity -- or the corresponding directory -- you will find the Term class there. Now look at the annotation, it says @ContentEntityType and in there: `

  • entity_keys = {
  • "id" = "tid",
    
  • "bundle" = "vid",
    
  • "label" = "name",
    
  • "uuid" = "uuid"
    
  • }, `

So, what you want is

$term = entity_create('taxonomy_term', array( 'name' => 'test', 'vid' => 'client', ))->save();

because the label entity key is name and the bundle entity key is vid. I added a ->save() call as well as I presume you wanted to save it too.