Skip to content
Snippets Groups Projects
Commit ce0920f0 authored by Jon Pugh's avatar Jon Pugh
Browse files

moving contrib modules to src

parents
No related branches found
No related tags found
No related merge requests found
{
"name": "drupal/operations",
"description": "Tools for operating Drupal sites.",
"type": "drupal-module",
"authors": [
{
"name": "Jon Pugh",
"email": "jon@thinkdrop.net"
}
],
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
}
},
"require": {
"drupal/key_auth": "^2.1"
}
}
\ No newline at end of file
.toolbar-icon-operations-admin:before {
background-image: url(../../../../core/misc/icons/787878/cog.svg);
}
.toolbar-icon-operations-admin:active:before,
.toolbar-icon-operations-admin.is-active:before {
background-image: url(../../../../core/misc/icons/787878/cog.svg);
}
\ No newline at end of file
name: Operations
type: module
description: Provides tools for operating Drupal sites.
package: Operations
core_version_requirement: ^9 || ^10
<?php
operations:
css:
theme:
css/operations.icons.theme.css: {}
operations.admin:
title: 'Operations'
description: 'Manage sites, servers & tasks.'
route_name: operations.admin
weight: 8
parent: system.admin
<?php
/**
* @file
* Primary module hooks for Operations module.
*/
/**
* Implements hook_toolbar().
*/
function operations_toolbar() {
$build = [];
$build['operations']['#attached'] = [
'library' => [
'operations/operations',
],
];
return $build;
}
access operations pages:
title: 'Access operations pages'
description: 'View operations admin section.'
restrict access: true
operations.admin:
path: '/admin/operations'
defaults:
_controller: '\Drupal\system\Controller\SystemController::overview'
link_id: 'operations.admin'
_title: 'Operations'
requirements:
_permission: 'access operations pages'
<?php
namespace Drupal\operations\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Returns responses for Operations routes.
*/
class OperationsController extends ControllerBase {
/**
* Builds the response.
*/
public function build() {
$build['content'] = [
'#type' => 'item',
'#markup' => $this->t('It works!'),
];
return $build;
}
}
<?php
namespace Drupal\operations\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Configure Operations settings for this site.
*/
class SettingsForm extends ConfigFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'operations_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return ['operations.settings'];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['example'] = [
'#type' => 'textfield',
'#title' => $this->t('Example'),
'#default_value' => $this->config('operations.settings')->get('example'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
if ($form_state->getValue('example') != 'example') {
$form_state->setErrorByName('example', $this->t('The value is not correct.'));
}
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('operations.settings')
->set('example', $form_state->getValue('example'))
->save();
parent::submitForm($form, $form_state);
}
}
<?php
namespace Drupal\operations\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides an example block.
*
* @Block(
* id = "operations_example",
* admin_label = @Translation("Example"),
* category = @Translation("Operations")
* )
*/
class ExampleBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$build['content'] = [
'#markup' => $this->t('It works!'),
];
return $build;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment