forked from drupalcommerce/commerce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommerce.module
88 lines (76 loc) · 2.19 KB
/
commerce.module
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
<?php
/**
* @file
* Defines the Store entity type and common functions used by Commerce modules.
*/
use Drupal\commerce\Entity\CommerceStore;
use Drupal\commerce\Entity\CommerceStoreType;
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_theme().
*/
function commerce_theme() {
return array(
'commerce_store_add_list' => array(
'variables' => array('content' => NULL),
'file' => 'commerce.pages.inc',
'template' => 'commerce-store-add-list',
),
);
}
/**
* Implements hook_toolbar().
*/
function commerce_toolbar() {
$items = array();
$items['commerce'] = array(
'#type' => 'toolbar_item',
'#attached' => array(
'css' => array(
drupal_get_path('module', 'commerce') . '/css/commerce.icons.css',
),
),
);
return $items;
}
/**
* Returns the e-mail address from which to send commerce related e-mails.
*
* Currently this is just using the site's e-mail address, but this may be
* updated to use a specific e-mail address when we add a settings form for the
* store's physical address and contact information.
*/
function commerce_email_from() {
return \Drupal::config('system.site')->get('mail');
}
/**
* Implements hook_entity_operation().
*
* Add devel link if this entity type is /commerce_store[_type]/.
*/
function commerce_entity_operation(EntityInterface $entity) {
$operations = array();
if (!\Drupal::moduleHandler()->moduleExists('devel')) {
return $operations;
}
$entity_routes = array(
'commerce_store' => 'entity.commerce_store.devel',
'commerce_store_type' => 'entity.commerce_store_type.devel',
);
$entity_type_id = $entity->getEntityTypeId();
if (\Drupal::currentUser()->hasPermission('access devel information') && in_array($entity_type_id, array_keys($entity_routes))) {
$operations['devel'] = array(
'route_name' => $entity_routes[$entity_type_id],
'route_parameters' => array($entity_type_id => $entity->id()),
'title' => t('Devel'),
'weight' => 15,
);
}
return $operations;
}
/**
* Returns the currency code of the site's default currency.
*/
function commerce_default_currency() {
return \Drupal::config('commerce')->get('default_currency');
}