-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththing_one.module
More file actions
107 lines (89 loc) · 2.34 KB
/
thing_one.module
File metadata and controls
107 lines (89 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* @file
* Main implementation file for Thing One.
*/
include_once 'includes/thing_one.entity.inc';
/**
* Implements hook_entity_info().
*/
function thing_one_entity_info() {
$entity_info = array();
$entity_info['blog'] = array(
// The basics.
'label' => t('Blog'),
'base table' => 'blog',
'module' => 'thing_one',
'load hook' => 'blog_load',
'access callback' => 'thing_one_access_callback',
'uri callback' => 'entity_class_uri',
// Allow users to add fields to an entity instance.
'fieldable' => TRUE,
// Provide a single, default bundle.
'bundles' => array(
'blog' => array(
'label' => t('Project'),
'admin' => array(
'path' => 'admin/blogs',
)
),
),
// Default view modes.
'view modes' => array(
'full' => array(
'label' => t('Default'),
'custom settings' => FALSE,
),
'teaser' => array(
'label' => t('Teaser'),
'custom settings' => FALSE,
),
),
// Use common pattern for id and label.
'entity keys' => array(
'id' => 'id',
'label' => 'title',
),
// Custom backend and controller.
'entity class' => 'BlogEntity',
'controller class' => 'BlogEntityController',
// Admin UI. Let drupal help us with the default UI controller.
'admin ui' => array(
'path' => 'admin/blogs',
'controller class' => 'EntityDefaultUIController',
),
);
return $entity_info;
}
/**
* Implements hook_menu().
*/
function thing_one_menu() {
$items = array();
// View a single blog.
$blog_uri = 'blog/%blog';
$blog_id_arg_position = 1;
$items[$blog_uri] = array(
'title callback' => 'entity_label',
'title arguments' => array('blog', $blog_id_arg_position),
'page callback' => 'blog_view',
'page arguments' => array($blog_id_arg_position),
'access arguments' => array('access content'),
'file' => 'includes/thing_one.pages.inc',
);
// View a blog listing.
$items['blogs'] = array(
'title' => 'Blogs',
'page callback' => 'blog_listing_view',
'access arguments' => array('access content'),
'file' => 'includes/thing_one.pages.inc',
);
return $items;
}
/**
* Access callback for Blog instances.
*/
function thing_one_access_callback($op, $blog = NULL, $account = NULL) {
// Placeholder.
return true;
}