You are previewing Programming Drupal 7 Entities.

Programming Drupal 7 Entities

Cover of Programming Drupal 7 Entities by Sammy Spets Published by Packt Publishing
  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
      1. Support files, eBooks, discount offers and more
    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
    9. 1. Understanding Entities
      1. Introducing entities
      2. Entity and solution modules
      3. Introducing entity types, bundles, and fields
      4. Powerful entity use cases
      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
      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
      4. Converting the recipe content type to use fields
      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
      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
      6. Summary
    16. 8. Expose Remote Entities
      1. Introducing the Remote Entity API
      2. Requirements for exposing remote entities
      3. Implementing remote entity exposure
      4. Running
      5. Adding write support
      6. Customization for your use case
      7. Summary
    17. Index

File entities

Drupal 7 introduced some rather important changes for files. First and foremost, they became entities, although they are not fully-fledged entities. This is most likely due to how different they are to content. For example, at the time of writing, file entities don't have any write support through wrappers. All changes must be done using the entity object itself or the File API. The latter is the best option, as the File API is quite simple to use. The wrapper save() method still works if you truly wish to bypass the File API.

In your applications, you will more often read values from file entities than you will write them. For reading, we should use wrappers or entity properties. The following table shows the wrapper and entity properties ...

The best content for your career. Discover unlimited learning on demand for around $1/day.