Sylius Stack
  • Sylius Stack Documentation
  • Getting started
  • Cookbook
    • How to customize your admin panel
      • Basic operations
      • Customizing your grids
      • Customizing the logo
      • Customizing the menu
      • Configuring the security access
      • Customizing the page titles
    • How to use in a DDD architecture
      • Architecture overview
      • Resource configuration
      • Basic operations
      • Operation using a grid
  • Admin UI
    • Getting started
  • Bootstrap Admin UI
    • Getting started
  • Resource
    • Resource Bundle documentation
      • Installation
      • Create new resource
      • Configure your resource
      • Configure your operations
      • Validation
      • Redirect
      • Resource factories
      • Providers
      • Processors
      • Responders
      • Legacy Resource Documentation
        • Configuration
        • Services
        • Routing
        • Forms
        • Getting a Single Resource
        • Getting a Collection of Resources
        • Creating Resources
        • Updating Resources
        • Deleting Resources
        • Configuring a state machine
        • Configuration Reference
  • Grid
    • Grid Bundle documentation
      • Installation
      • Creating your first grid
      • Configuring Fields
      • Field types
      • Creating a custom Field Type
      • Creating a custom Action
      • Creating a custom Bulk Action
      • Filters
      • Creating a custom Filter
      • Advanced configuration
      • Configuration Reference
  • 🍀Twig Extra
    • Getting started
  • 🌱Twig Hooks
    • Getting started
    • Passing data to your hookables
    • Making your hookables configurable
    • Autoprefixing feature
    • Composable Layouts with a predictable structure
    • Advanced
      • Ergonomic work with hooks
      • Metadata objects
      • Multiple hooks inside a single template
      • Overriding hookables
Powered by GitBook
On this page
  • Accessing a hook metadata
  • Accessing a hookable metadata
  1. Twig Hooks
  2. Advanced

Metadata objects

Metadata objects have been introduce to structurize the information passed between hooks and hookables. In Twig Hooks we have two metadata objects:

  • A hook metadata object, which contains information about the hook name, and the hook-level defined context

  • A hookable metadata object, which contains information about the hook which rendered it, the merged context, the configuration and prefixes

Accessing a hook metadata

A hook metadata object can be accessed only from a hookable metadata object.

Accessing a hookable metadata

A hookable metadata can be accessed from a Twig template that is a hookable. You can do this by:

  • using the hookable_metadata variable which is automatically created for hookables

  • using the get_hookable_metadata() function

There is no difference between these two methods, so you can pick the one you prefer the one that best fits your coding style.

There are also Twig functions which are shortcuts for accessing concrete data bags from a metadata object:

  • get_hookable_context() for accessing the context

  • get_hookable_configuration for accessing the configuration

PreviousErgonomic work with hooksNextMultiple hooks inside a single template

Last updated 12 months ago

🌱