Follow up to #3020352: Create a new AnnounceCommand to call Drupal.announce on an AjaxResponse β
In that issue we use CommandWithAttachedAssetsInterface because we needed to attach the core/drupal.announce library.
This works well because \Drupal\Core\Ajax\AjaxResponse::addCommand()
will call \Drupal\Core\Ajax\CommandWithAttachedAssetsInterface::getAttachedAssets()
for any $command that implements the interface.
The documentation though on this interface says
* Interface for Ajax commands that render content and attach assets.
*
* All Ajax commands that render HTML should implement these methods
* to be able to return attached assets to the calling AjaxResponse object.
*
The interface itself has nothing to do with rendering content. Just commands that need to attach libraries.
Furthermore "render content" is ambiguous here. Does the new AnnounceCommand do this? It calls Drupal.announce which does cause html to be update on the page similarly to \Drupal\Core\Ajax\InsertCommand which also implements this interface and calls ultimately the jQuery insert method.
I think what was probably meant instead of "render content" was probably "returns a render array"
We can see this with the Trait CommandWithAttachedAssetsTrait. This trait sets attached assets based on $this->content being a render array. Before
#3020352: Create a new AnnounceCommand to call Drupal.announce on an AjaxResponse β
all classes that implemented CommandWithAttachedAssetsInterface also used CommandWithAttachedAssetsTrait
Update the docs in CommandWithAttachedAssetsInterface to separate it out of it's use can in CommandWithAttachedAssetsTrait
Needs work
10.1 β¨
Last updated
Used to track the progress of issues reviewed by the Drupal Needs Review Queue Initiative.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.