Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin view extension with references table #813

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions bundles/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,36 @@ Example implementation for a custom content-type:
$propertyPrefix . $property->getName()
);
}

Extending the Admin View with a References Table
------------------------------------------------

To extend the admin view by adding a references table, follow these steps:

1. Inject the `ReferenceViewBuilderFactoryInterface`: Inject this interface into your custom Admin class. This will allow you to utilize the necessary methods to create the references view.
2. Create the Reference List View: Use the `createReferenceListViewBuilder` method to create the list view for the references table.

Here’s an example implementation from the `SnippetAdmin` class, demonstrating how to add the references tab to your custom admin view:

.. code-block:: php

if ($this->referenceViewBuilderFactory->hasReferenceListPermission()) {
$viewCollection->add(
$this->referenceViewBuilderFactory
->createReferenceListViewBuilder(
$insightsResourceTabViewName . '.reference',
'/references',
SnippetDocument::RESOURCE_KEY
)
->setParent($insightsResourceTabViewName)
);
}

The `hasReferenceListPermission` method ensures that the current user has permission to view the references list.
The `createReferenceListViewBuilder` method is used to create the view. It takes three parameters:

- The name of the new view, usually appended with .reference to indicate it is a reference view.
- The URL path for the references table.
- The resource key identifies the type of resource being referenced.

The setParent method sets the parent view to integrate the references table into the existing admin view.
Loading