Git Product home page Git Product logo

drupal-entity_operations's Introduction

Entity Operations
=================

This module provides a framework for defining operations for entities. An operation is at its most basic 'something you can do with an entity'. Operations can be:
  - Page operations that return rendered output (such as 'view')
  - Form operations that output a form (such as 'edit')
  - Action operations, which may also have a form (such as 'publish')

Operations can be exposed as UI tabs, which allows the whole of an entity's UI to be created using Entity Operations. For example, a basic entity type's UI might have these operations, which come as part of Entity Operations module:
    - view: show the rendered entity at its basic URI.
    - edit: show the entity edit form.

Entity operations are also exposed in other ways:
  - Operations that are treated as actions are available to:
    - Views Bulk Operations as operations.
    - Services as targeted actions on entities (requires Services Entity
      module).
  - The link to an operation's tab is available as a Views field on the entity.
  - Operations that are forms can be output in a fieldset that can be shown on
    the entity (or indeed, anywhere).
  - If the Entity API admin UI is being used, the 'add', 'edit', and 'delete'
    operations can be shown there.

More complex entities can implement further operations specific to its business logic. For example, a library book entity could have a tab that allows making reservations. The operations framework allows modules to output any kind of content or form in an entity tab.

Access to an operation is defined by either the handler class, or the path component. entity_operations_get_entity_permissions() can be used to get all the permissions this invents for an entity type.

Implementation
==============

To implement basic entity operations for your entity type, add the following to your hook_entity_info():

  // Entity Operations API
  'operations ui' => array(
    // The base path for your entities. This is the same as your entity's URI
    // but without the ID suffix. (In fact, you can set
    // entity_operations_entity_uri() as your URI callback, which will use the
    // value here).
    'path' => 'node',
    'operations' => array(
      // The list of operations. The key defines the path component used after
      // the entity ID.
      // Creates the 'node/add' path.
      'add' => array(
        'handler' => 'EntityOperationsOperationAdd',
      ),
      // Creates the path at 'node/NID/view'. Also shows at 'node/NID' because
      // of the 'default' property.
      'view' => array(
        'handler' => 'EntityOperationsOperationEntityView',
        'default' => TRUE,
      ),
      // Creates the path at 'node/NID/edit'.
      'edit' => array(
        'handler' => 'EntityOperationsOperationEdit',
      ),
      // If devel module is available, creates the path at 'node/NID/devel'.
      'devel' => array(
        'handler' => 'EntityOperationsOperationDevel',
      ),
    ),
  ),
  // You also need the following Entity API properties:
  'module' => 'mymodule',
  'entity class' => 'Entity', // or a subclass of Entity
  'access callback' => 'myentity_access',
  'admin ui' => array(
    // The Add and Edit operations depend on the file path being defined here.
    'file path' => 'file/path/to/your/entity-form-callback',
  ),

See the documentation for entity_operations_hook_entity_info() for more details.




drupal-entity_operations's People

Contributors

joachim-n avatar

Watchers

 avatar  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.