You are here

function _datalayer_menu_get_any_object in dataLayer 8

Same name and namespace in other branches
  1. 7 datalayer.module \_datalayer_menu_get_any_object()

Agnosticly get the current menu object.

Return value

object Entity object of current menu callback page.

3 calls to _datalayer_menu_get_any_object()
DataLayerKernelTest::testDataLayerMenuGetAnyObjectReturnsNullWithoutContentEntityInterface in tests/src/Kernel/DataLayerKernelTest.php
Test DataLayer Menu Get Any Object.
DataLayerKernelTest::testDataLayerMenuGetAnyObjectReturnsObject in tests/src/Kernel/DataLayerKernelTest.php
Test DataLayer Menu Get Any Object Returns Object.
datalayer_get_page_data in ./datalayer.module
Return all the page meta data.

File

./datalayer.module, line 424
Client-side data space.

Code

function _datalayer_menu_get_any_object() {

  // Figure out if a content entity is being viewed.
  $route_match = \Drupal::routeMatch();
  foreach ($route_match
    ->getParameters() as $parameter) {
    if ($parameter instanceof ContentEntityInterface) {
      return $parameter;
    }
  }
  return NULL;
}