Giter VIP home page Giter VIP logo

key's Introduction

Key Module for Drupal 8

Build Status

This module provides the ability for site administrators to manage sitewide keys, which can be used, for example, to integrate with external services. Keys are available for use by other modules using a Drupal service provided by Key.

Managing Keys

To manage keys, visit admin/config/security/key. When creating a file, enter a name for the key and select the key provider to be used. Additional settings for the selected key provider may be required. For instance, if the File key provider is selected, enter a path to the file that contains the key.

Key Providers

Key leverages the Drupal 8 Plugin API for key providers, so that other modules can define additional key providers through the Key Plugin Manager. A key provider defines a method for retrieving a key, along with settings specific to that key provider, which are saved when creating a Key entity. Each plugin needs to register, as an annotation, the storage method used within the plugin.

For convention, it is recommended to use one the following storage method values:

  1. File - Stored in a file and retrieved via the local filesystem or by using a stream wrapper
  2. Configuration - Stored with Drupal’s built-in configuration management (settings, entities)
  3. Database - Stored as a field in a database record
  4. Remote - Retrieved via a remote service call

Using a Key

Modules can retrieve information about keys or a specific key value by making a call to the Key Manager service. It is best practice to inject the service into your own service, form, or controller. The following examples assume the use of the \Drupal object for brevity, but the examples can be extrapolated to fit the use case of your module.

Get All Keys

Drupal::service('key_repository')->getKeys();

Get Single Key

Drupal::service('key_repository')->getKey($key_id);

Get Default Key

Drupal::service('key_repository')->getKey();

Get Key Value

Drupal::service('key_repository')->getKey($key_id)->getKeyValue();

key's People

Contributors

adam-bergstein avatar rlhawk avatar nerdstein avatar mradcliffe avatar eclipsegc avatar lahoosascoots avatar craigmoore avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.