You are here

private function PageJsonForm::getEntity in Structured Data (JSON+LD Rich Snippets) 8

Get entity details from current route.

Return value

mixed|\stdClass Entity details.

1 call to PageJsonForm::getEntity()
PageJsonForm::buildForm in src/Form/PageJsonForm.php
Form constructor.

File

src/Form/PageJsonForm.php, line 111

Class

PageJsonForm
Class PageJsonForm.

Namespace

Drupal\structured_data\Form

Code

private function getEntity() {
  $route_name = $this
    ->getRouteMatch()
    ->getParameter('sd_route_name');
  $url = $this
    ->getRouteMatch()
    ->getParameter('sd_url');
  $bundle = $this
    ->getRouteMatch()
    ->getParameter('sd_bundle');
  $entity_id = $this
    ->getRouteMatch()
    ->getParameter('sd_entity_id');
  $url = str_replace('|', '/', $url);
  $url = base64_decode($url);
  $entity = Helper::getPageJson([
    'route_name' => $route_name,
    'url' => $url,
    'bundle' => $bundle,
    'entity_id' => $entity_id,
  ]);
  if (empty($entity)) {
    $entity = new \stdClass();
    $entity->route_name = $route_name;
    $entity->url = $url;
    $entity->bundle = $bundle;
    $entity->entity_id = $entity_id;
    $entity->json = '';
  }
  return $entity;
}