Skip to content

Instantly share code, notes, and snippets.

@datacodesolutions
Last active December 27, 2015 10:39
Show Gist options
  • Save datacodesolutions/7312792 to your computer and use it in GitHub Desktop.
Save datacodesolutions/7312792 to your computer and use it in GitHub Desktop.
<?php namespace Studiobanks;
class Fields
{
public static function createEntity() {
// $field = entity_create('field_entity', [
// 'id' => 'field_text_slug',
// 'name' => 'field_text_slug',
// 'entity_type' => 'node',
// 'type' => 'text',
// 'cardinality' => 1
// ]);
// $field->save();
// entity_create('field_instance', [
// 'field_name' => 'field_text_slug',
// 'entity_type' => 'node',
// 'field_uuid' => 'node',
// 'bundle' => 'blog_post'
// ])->save();
$node = \Drupal::entityManager()
->getStorageController('node')
->create([
'title' => 'Some node',
'bundle' => 'blog_post',
]);
$test = true;
}
public static function createCategorySlugTable()
{
db_create_table('category_slug', [
'fields' => [
'category' => [
'description' => 'Category',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
],
'category_slug' => [
'description' => 'Category Slug',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
],
]
]);
echo 'Category Slug Field Created' . "\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment