Skip to content

Commit 270cb9f

Browse files
committed
Initial commit.
0 parents  commit 270cb9f

File tree

81 files changed

+2003
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2003
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Commerce 2.x installation profile
2+
3+
Enables the Commerce modules.
4+
Based on Drupal's Standard profile.
5+
6+
Used by [drupalcommerce/project-base](https://github.com/drupalcommerce/project-base).

commerce_base.info.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Commerce Base
2+
type: profile
3+
core: 8.x
4+
description: 'Install with Drupal Commerce pre-configured.'
5+
distribution:
6+
name: 'Drupal'
7+
dependencies:
8+
# Standard
9+
- node
10+
- history
11+
- block
12+
- breakpoint
13+
- ckeditor
14+
- color
15+
- config
16+
- comment
17+
- contextual
18+
- contact
19+
- menu_link_content
20+
- datetime
21+
- block_content
22+
- quickedit
23+
- editor
24+
- help
25+
- image
26+
- menu_ui
27+
- options
28+
- path
29+
- page_cache
30+
- dynamic_page_cache
31+
- taxonomy
32+
- dblog
33+
- search
34+
- shortcut
35+
- toolbar
36+
- field_ui
37+
- file
38+
- rdf
39+
- views
40+
- views_ui
41+
- tour
42+
- automated_cron
43+
44+
# Commerce
45+
- address
46+
- entity
47+
- profile
48+
- inline_entity_form
49+
- state_machine
50+
- commerce
51+
- commerce_cart
52+
- commerce_order
53+
- commerce_product
54+
- commerce_price
55+
- commerce_store
56+
- commerce_tax
57+
themes:
58+
- bartik
59+
- seven

commerce_base.install

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Install, update and uninstall functions for the commerce_base installation profile.
6+
*/
7+
8+
use Drupal\user\Entity\User;
9+
use Drupal\user\RoleInterface;
10+
11+
/**
12+
* Implements hook_install().
13+
*
14+
* Perform actions to set up the site for this profile.
15+
*
16+
* @see system_install()
17+
*/
18+
function commerce_base_install() {
19+
// Set front page to "node".
20+
\Drupal::configFactory()->getEditable('system.site')->set('page.front', '/node')->save(TRUE);
21+
22+
// Allow visitor account creation with administrative approval.
23+
$user_settings = \Drupal::configFactory()->getEditable('user.settings');
24+
$user_settings->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(TRUE);
25+
26+
// Enable default permissions for system roles.
27+
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
28+
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access comments', 'post comments', 'skip comment approval']);
29+
30+
// Assign user 1 the "administrator" role.
31+
$user = User::load(1);
32+
$user->roles[] = 'administrator';
33+
$user->save();
34+
35+
// Enable the Contact link in the footer menu.
36+
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
37+
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
38+
$menu_link_manager->updateDefinition('contact.site_page', ['enabled' => TRUE]);
39+
40+
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']);
41+
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access site-wide contact form']);
42+
43+
// Allow authenticated users to use shortcuts.
44+
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access shortcuts']);
45+
46+
// Populate the default shortcut set.
47+
$shortcut = entity_create('shortcut', [
48+
'shortcut_set' => 'default',
49+
'title' => t('Add content'),
50+
'weight' => -20,
51+
'link' => ['uri' => 'internal:/node/add'],
52+
]);
53+
$shortcut->save();
54+
55+
$shortcut = entity_create('shortcut', [
56+
'shortcut_set' => 'default',
57+
'title' => t('All content'),
58+
'weight' => -19,
59+
'link' => ['uri' => 'internal:/admin/content'],
60+
]);
61+
$shortcut->save();
62+
63+
// Allow all users to use search.
64+
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['search content']);
65+
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['search content']);
66+
67+
// Enable the admin theme.
68+
\Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE);
69+
}

commerce_base.links.menu.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
commerce_base.front_page:
2+
title: 'Home'
3+
route_name: '<front>'
4+
menu_name: main

commerce_base.profile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Enables modules and site configuration for a commerce_base site installation.
6+
*/
7+
8+
use Drupal\contact\Entity\ContactForm;
9+
use Drupal\Core\Form\FormStateInterface;
10+
11+
/**
12+
* Implements hook_form_FORM_ID_alter() for install_configure_form().
13+
*
14+
* Allows the profile to alter the site configuration form.
15+
*/
16+
function commerce_base_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
17+
// Add a placeholder as example that one can choose an arbitrary site name.
18+
$form['site_information']['site_name']['#attributes']['placeholder'] = t('My store');
19+
$form['#submit'][] = 'commerce_base_form_install_configure_submit';
20+
}
21+
22+
/**
23+
* Submission handler to sync the contact.form.feedback recipient.
24+
*/
25+
function commerce_base_form_install_configure_submit($form, FormStateInterface $form_state) {
26+
$site_mail = $form_state->getValue('site_mail');
27+
ContactForm::load('feedback')->setRecipients([$site_mail])->trustData()->save();
28+
}

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "drupalcommerce/commerce-base",
3+
"type": "drupal-profile",
4+
"description": "Commerce 2.x installation profile",
5+
"homepage": "httsp://github.com/drupalcommerce/commerce-base",
6+
"license": "GPL-2.0+"
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
interval: 10800
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
langcode: en
2+
status: true
3+
dependencies:
4+
config:
5+
- system.menu.account
6+
module:
7+
- system
8+
theme:
9+
- bartik
10+
id: bartik_account_menu
11+
theme: bartik
12+
region: secondary_menu
13+
weight: 0
14+
provider: null
15+
plugin: 'system_menu_block:account'
16+
settings:
17+
id: 'system_menu_block:account'
18+
label: 'User account menu'
19+
provider: system
20+
label_display: '0'
21+
level: 1
22+
depth: 1
23+
visibility: { }
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
langcode: en
2+
status: true
3+
dependencies:
4+
module:
5+
- system
6+
theme:
7+
- bartik
8+
id: bartik_branding
9+
theme: bartik
10+
region: header
11+
weight: 0
12+
provider: null
13+
plugin: system_branding_block
14+
settings:
15+
id: system_branding_block
16+
label: 'Site branding'
17+
provider: system
18+
label_display: '0'
19+
use_site_logo: true
20+
use_site_name: true
21+
use_site_slogan: true
22+
visibility: { }
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
langcode: en
2+
status: true
3+
dependencies:
4+
module:
5+
- system
6+
theme:
7+
- bartik
8+
id: bartik_breadcrumbs
9+
theme: bartik
10+
region: breadcrumb
11+
weight: 0
12+
provider: null
13+
plugin: system_breadcrumb_block
14+
settings:
15+
id: system_breadcrumb_block
16+
label: Breadcrumbs
17+
provider: system
18+
label_display: '0'
19+
visibility: { }

0 commit comments

Comments
 (0)