Drupal Technology & Digital Applications 5 — Questions and Answers
Question 1: What Drupal feature allows editors to preview unpublished content as it would appear on the live site?
- Content Moderation's preview tab combined with revision system
- The BigPipe streaming module
- The Configuration Split module
- The Workspaces (core) module (Correct answer)
Correct answer: The Workspaces (core) module
The Workspaces module allows content editors to group unpublished changes across multiple entities and preview them together as a staged environment before publishing.
Question 2: In a headless Drupal setup, which authentication method is commonly used to secure API requests from a JavaScript front-end?
- HTTP Basic Authentication
- OAuth 2.0 / Simple OAuth tokens (Correct answer)
- IP whitelisting
- Drupal's session cookie only
Correct answer: OAuth 2.0 / Simple OAuth tokens
OAuth 2.0, typically implemented via the Simple OAuth contributed module, is the recommended approach for authenticating API consumers in a headless Drupal architecture.
Question 3: What does Drupal's 'Search API' contributed module provide over core search?
- Spell-check suggestions for all content
- A flexible framework supporting multiple search backends like Elasticsearch or Solr (Correct answer)
- Built-in Google Custom Search integration
- Automatic content indexing via webhooks
Correct answer: A flexible framework supporting multiple search backends like Elasticsearch or Solr
Search API is a contributed module that provides a backend-agnostic framework allowing Drupal to use powerful external search engines like Apache Solr or Elasticsearch.
Question 4: Which Drupal development practice involves using Feature flags to control functionality deployment?
- Using Drupal's State API to toggle feature states per environment (Correct answer)
- Embedding flags in Twig templates only
- Hardcoding conditions in settings.php
- Storing flags in the default content module
Correct answer: Using Drupal's State API to toggle feature states per environment
The State API is commonly used to store environment-specific feature flags since state data does not export with configuration, keeping flags isolated to their respective environments.
Question 5: What is the primary advantage of using Drupal's 'Single Directory Components' (SDC) introduced in Drupal 10.1?
- They compile Twig templates to PHP classes for performance
- They co-locate a component's Twig, CSS, JS, and schema in one directory for better organization (Correct answer)
- They replace the block system entirely
- They enable server-side React rendering in Drupal
Correct answer: They co-locate a component's Twig, CSS, JS, and schema in one directory for better organization
Single Directory Components allow developers to bundle a component's Twig template, CSS, JavaScript, and YAML schema definition together in one directory, improving maintainability.
Question 6: In Drupal, what is the purpose of the 'Typed Data API'?
- Enforcing PHP type hints across modules
- Providing a consistent way to define, validate, and interact with different data types in Drupal (Correct answer)
- Generating TypeScript definitions from entity schemas
- Restricting field input to specific HTML input types
Correct answer: Providing a consistent way to define, validate, and interact with different data types in Drupal
The Typed Data API provides a uniform interface for defining data types with metadata, validation constraints, and access control, used extensively by the Entity and Configuration systems.
Question 7: Which approach does Drupal recommend for overriding a contrib module's service in a custom module?
- Directly editing the contrib module's services.yml file
- Implementing a ServiceProviderBase class in the custom module to alter the service definition (Correct answer)
- Copying the service class into the active theme
- Adding an override key in settings.php
Correct answer: Implementing a ServiceProviderBase class in the custom module to alter the service definition
To override a contrib service, a custom module creates a class extending ServiceProviderBase (or implementing ContainerBuilderHookInterface) that alters the container definition, keeping customizations upgrade-safe.
What Drupal feature allows editors to preview unpublished content as it would appear on the live site?