Entity Share
Entity Share enables content sharing between multiple Drupal websites using the JSON:API. It provides server-side channels and client-side pull interfaces for synchronizing entities across sites.
entity_share
インストール
composer require 'drupal/entity_share:8.x-3.13'
概要
Entity Shareは、JSON:APIを使用して複数のDrupalウェブサイト間でコンテンツを共有できる包括的なモジュールです。このモジュールはサーバー・クライアントアーキテクチャに従い、1つのウェブサイトが「サーバー」(チャンネル経由でコンテンツを提供)として機能し、別のサイトが「クライアント」(サーバーからコンテンツをプル)として機能します。1つのウェブサイトがサーバーとクライアントの両方として同時に機能することもできます。
このモジュールは、カスタマイズ可能なフィルター、ソート、検索、アクセス制御を備えたサーバーチャンネルを管理するための完全なUIを提供します。クライアント側では、リモートウェブサイト管理、プロセッサベースのパイプラインによるインポート設定、エンティティインポートステータスの追跡を提供します。高度な機能には、ローカルとリモートのエンティティ間の差分表示、インポートされたコンテンツの編集を防ぐインポートロック、キュー処理による非同期インポート機能が含まれます。
Entity Shareは、OAuth 2.0、Basic Auth、ヘッダーベース認証、匿名アクセスなど、複数の認証方法をサポートしています。また、メタタグ、Pathautoフィールド、ブロックフィールド、埋め込みエンティティなどの複雑なフィールドタイプ用のJSON:APIフィールドエンハンサーも提供しています。
Features
- 完全なCRUDサポートを備えたJSON:APIベースのDrupalサイト間エンティティ共有
- フィルター、ソート、検索、フィルターグループを備えたサーバー側チャンネル設定
- 複数の認証方法(OAuth、Basic Auth、ヘッダー、匿名)を備えたクライアント側リモートウェブサイト管理
- 前処理、処理、後処理ステージをサポートするプロセッサベースのエンティティインポートパイプラインを備えたインポート設定
- 変更検出機能を備えたエンティティインポートステータス追跡
- Queueワーカーによる非同期エンティティインポートサポート
- ローカルとリモートのエンティティバージョンの並列差分表示
- 同期されたコンテンツの編集を防ぐインポートロック
- メタタグ、Pathauto、ブロックフィールド、埋め込みエンティティ用のJSON:APIフィールドエンハンサー
- CLIベースのエンティティインポート用Drushコマンド
- インポートステータス管理用のViews統合
- Paragraphs、エンティティ参照、ファイル、メディアを含む複雑なフィールドタイプのサポート
Use Cases
Multi-site Content Distribution
Set up a central content hub as the Entity Share Server with multiple regional or department sites as clients. Content editors create articles on the hub, then regional editors pull relevant content to their sites. Each regional site can have different import configurations to handle local requirements like translation handling or content policies.
Staging to Production Content Sync
Use Entity Share to synchronize content from a staging environment to production. Configure the staging site as the server with channels for reviewed content. Production acts as the client, pulling only approved content. Import configurations can skip already-imported content and prevent overwrites of locally modified entities.
Content Aggregation from Multiple Sources
Configure a site as a client connecting to multiple Entity Share servers (different departments, partners, or content sources). Each remote has its own authentication configuration. Import configurations can be customized per source to handle different content structures or policies.
Headless CMS Content Distribution
Use Entity Share Server to expose content channels from a headless Drupal CMS. Multiple presentation layer applications can pull content via the JSON:API-based channels. This provides a standardized content synchronization mechanism beyond the basic JSON:API read operations.
Content Backup and Recovery
Set up Entity Share between primary and backup sites for content redundancy. The backup site periodically pulls content from the primary site using Drush commands in cron jobs. Import status tracking ensures only changed content is synchronized, and the diff feature allows verification of content integrity.
Selective Content Sharing Between Partner Sites
Organizations with partner relationships can share specific content types through carefully configured channels with access controls. Channels can be restricted to specific users or roles on the server side, and clients can be configured with appropriate authentication. Import policies control how shared content integrates with local content.
Tips
- Use OAuth authentication for production environments rather than Basic Auth for improved security
- Configure channel filters to limit exposed content and reduce import overhead
- Set appropriate recursion depth in Entity Reference processor to balance completeness with performance
- Enable Skip Imported processor to avoid re-processing unchanged content on subsequent imports
- Use the diff feature to review changes before importing updated content
- Consider using the Key module for credential storage in multi-environment deployments
- Set up Drush commands with cron for automated content synchronization
- Use filter groups with AND/OR conjunctions for complex channel filtering logic
- Configure searches on channels to enable content editors to find specific content easily
- Monitor import status entities to track synchronization state and identify issues
Technical Details
Admin Pages 10
/admin/config/services/entity_share
Main configuration hub for Entity Share module. Provides links to all Entity Share configuration pages including channels, remote websites, import configurations, and diff settings.
/admin/config/services/entity_share/channel
List and manage server channels for sharing content. Each channel exposes a specific entity type and bundle via JSON:API. Channels can be configured with filters, sorts, searches, and access controls.
/admin/config/services/entity_share/channel/add
Create a new channel to expose entities for sharing.
/admin/config/services/entity_share/remote
List and manage remote website connections for pulling content. Configure the remote site URL and authorization method.
/admin/config/services/entity_share/remote/add
Configure a connection to a remote Entity Share server.
/admin/config/services/entity_share/import_config
List and manage import configurations that define how entities are processed during import. Each configuration contains a set of processors with specific settings.
/admin/config/services/entity_share/import_config/add
Create a new import configuration with processor settings.
/admin/content/entity_share
Main interface for pulling entities from remote websites. Select a remote, choose a channel, search and filter entities, then import selected content.
/admin/content/entity_share/statuses
View tracking information for imported entities. Shows entity type, bundle, UUID, source remote, channel, and last change time.
/admin/config/services/entity_share/diff
Configure diff display settings for entity comparison.
権限 8
Hooks 1
hook_entity_share_server_channel_list_alter
Allows modules to alter the list of channels returned to clients.
Drush Commands 2
drush entity-share-client:pull
Pull all entities from a channel on a remote website.
drush entity-share-client:pull-entities
Pull specific entities by UUID from a channel.
Troubleshooting 8
Verify the remote URL is correct and accessible. Check that the authorization method is properly configured with valid credentials. Ensure the authenticated user on the remote has the 'Access channels list' permission. Check browser console for CORS errors if sites are on different domains.
The authenticated user on the remote server needs view access to the entities being pulled. For nodes, this typically requires 'View published content' or appropriate node access permissions. For menu links, install the Menu Link Content View Access module.
Enable the Entity Reference processor in the import configuration. Check the 'Max recursion depth' setting - it may need to be increased for deeply nested references. For paragraphs, ensure the Embedded Entity Importer processor is enabled.
Enable the Physical File processor. Ensure the remote server allows file downloads and the client site has proper file system permissions. Check that the authenticated user can access file entities on the remote.
Import status tracking is based on entity UUID and language. If entities were deleted and re-created locally, or if the import status entities were cleared, they will appear as new. The import service tracks status per remote/channel combination.
Verify all OAuth credentials (client ID, secret, endpoints). Ensure the Simple OAuth module is properly configured on the server with matching client configuration. Check that the username/password for Resource Owner Password Credentials grant are correct.
Check Entity Share Diff settings for context line configuration. Ensure both local and remote entities exist. The diff feature requires the entity to have been previously imported to have a local version for comparison.
Ensure cron is running regularly on the site. Check the queue status in Database logging. The entity_share_async_worker queue needs to be processed. Consider increasing PHP memory limits for large imports.
Security Notes 7
- Store OAuth credentials and API keys using the Key module rather than in config for production sites
- Restrict 'Administer channel entity', 'Administer remote website entity', and 'Administer import config entity' permissions to trusted administrators only
- Channel access controls should be configured to limit which users can access content via JSON:API
- Consider network-level restrictions (firewall, VPN) for content sharing between sensitive environments
- The 'Display technical errors' permission should only be granted to developers as it may expose sensitive request details
- Review imported content policies to ensure appropriate content ownership and moderation workflows
- OAuth tokens and credentials should be rotated periodically following security best practices