You are previewing Programming Drupal 7 Entities.
O'Reilly logo
Programming Drupal 7 Entities

Book Description

Expose local or remote data as Drupal 7 entities and build custom solutions

  • Understand and develop using the entity paradigm and entity metadata wrappers

  • Create, retrieve, update, and delete (CRUD) operations on all entities

  • Programmatically attach fields to entities and manipulate their data

  • Expose remote data in a non-fieldable or fieldable entity with support for the import and export of bundle configurations

  • Thorough coverage of common core and contributed entity types along with custom data exposure

In Detail

Writing code for manipulating Drupal data has never been easier! Learn to dice and serve your data as you slowly peel back the layers of the Drupal entity onion. Next, expose your legacy local and remote data to take full advantage of Drupal's vast solution space.

Programming Drupal 7 Entities is a practical, hands-on guide that provides you with a thorough knowledge of Drupal's entity paradigm and a number of clear step-by-step exercises, which will help you take advantage of the real power that is available when developing using entities.

This book looks at the Drupal 7 entity paradigm, and breaks down the mystery and confusion that developers face when building custom solutions using entities. It will take you through a number of clear, practical recipes that will help you to take full advantage of Drupal entities in your web solutions without much coding.

You will also learn how to expose local and remote data to give your legacy data new life as fully-fledged Drupal entities that can be used by other modules such as views, rules, and so on. In addition to this, you'll learn to create, retrieve, update, and delete (CRUD) entities, their properties and fields, along with some programmatic wizardry to manipulate complex entities such as field collections. If you want to develop quickly and easily using Drupal entities, then this is the book for you.

You will learn everything you need to know to develop code and expose data using entities in Programming Drupal 7 Entities.

Table of Contents

  1. Programming Drupal 7 Entities
    1. Table of Contents
    2. Programming Drupal 7 entities
    3. Credits
    4. About the Author
    5. Acknowledgement
    6. About the Reviewers
    7. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    8. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Using the example code
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    9. 1. Understanding Entities
      1. Introducing entities
      2. Entity and solution modules
      3. Introducing entity types, bundles, and fields
        1. Types
        2. Bundles
        3. Fields
        4. Drupal core entity structure
      4. Powerful entity use cases
        1. User profiles
        2. Internationalization
        3. Commerce products
      5. Our use case
      6. Summary
    10. 2. Developing with Entity Metadata Wrappers
      1. Introducing entity metadata wrappers
      2. Creating an entity metadata wrapper object
      3. Standard entity properties
      4. Entity introspection
      5. Using an entity metadata wrapper
        1. Create
          1. Drush commands
          2. Code snippet
        2. Retrieve
          1. Drush commands
          2. Code snippet
        3. Update
          1. Drush commands
          2. Code snippet
        4. Delete
          1. Drush commands
          2. Code snippet
      6. Safely using text property values
      7. Self-imposed limitation of entity programming
      8. References
      9. A note about EntityFieldQuery
      10. Summary
    11. 3. Developing with Non-fieldable Entities
      1. What are non-fieldable entities?
      2. File entities
      3. Vocabulary entities
      4. Recipe site vocabularies
      5. Summary
    12. 4. Developing with Fieldable Entities
      1. What are fieldable entities?
      2. Node entities
      3. Comment entities
      4. Term entities
      5. Summary
    13. 5. Developing with Fields
      1. Field types
      2. Single-value and multi-value fields
      3. Structure fields
        1. Field type-specific code
          1. File and image fields
          2. Link fields
          3. Datetime fields
          4. Putting it all together
      4. Converting the recipe content type to use fields
        1. Creating fields
        2. Exporting fields to a feature
        3. Copying the code to the recipe module
        4. Tweaking recipe.module and recipe.info
        5. Upgrading recipe module
      5. Summary
    14. 6. Developing with Field Collections
      1. Before Drupal 7
      2. Creating a field collection field
      3. Field collection entities
      4. Adding a field collection to a node
      5. Attaching a field collection to a content type
        1. Exporting field collection and fields
        2. Copying the code to the recipe module
        3. Tweaking recipe.module
        4. Updating code is unnecessary
      6. Summary
    15. 7. Expose Local Entities
      1. Motivation for exposing entities
      2. Fast track your data exposure
      3. Allow fields on your entity
      4. Give it multiple bundles
      5. Administration interface and exportability
        1. Storing bundle information
        2. Exposing bundle information and handling access rights
        3. Adding the support code
      6. Summary
    16. 8. Expose Remote Entities
      1. Introducing the Remote Entity API
      2. Requirements for exposing remote entities
      3. Implementing remote entity exposure
        1. Database schema
        2. Connection code
        3. Remote query code
        4. Entity exposure code
        5. Entity metadata API integration
        6. Import and administration code
      4. Running
      5. Adding write support
      6. Customization for your use case
      7. Summary
    17. Index