original_string: public static function addBreadcrumbList()
      {
          $view = Yii::$app->getView();
  
          $breadcrumbList = [];
          if (isset($view->params['breadcrumbs'])) {
              $position = 1;
              foreach ($view->params['breadcrumbs'] as $breadcrumb) {
                  if (is_array($breadcrumb)) {
                      $breadcrumbList[] = (object)[
                          "@type" => "http://schema.org/ListItem",
                          "http://schema.org/position" => $position,
                          "http://schema.org/item" => (object)[
                              "@id" => Url::to($breadcrumb['url'], true),
                              "http://schema.org/name" => $breadcrumb['label'],
                          ]
                      ];
                  } else {
                      // Is it ok to omit URL here or not? Google is not clear on that:
                      // http://stackoverflow.com/questions/33688608/how-to-markup-the-last-non-linking-item-in-breadcrumbs-list-using-json-ld
                      $breadcrumbList[] = (object)[
                          "@type" => "http://schema.org/ListItem",
                          "http://schema.org/position" => $position,
                          "http://schema.org/item" => (object)[
                              "http://schema.org/name" => $breadcrumb,
                          ]
                      ];
                  }
                  $position++;
              }
          }
  
          $doc = (object)[
              "@type" => "http://schema.org/BreadcrumbList",
              "http://schema.org/itemListElement" => $breadcrumbList
          ];
  
          JsonLDHelper::add($doc);
      }
code: public static function addBreadcrumbList()
      {
          $view = Yii::$app->getView();
  
          $breadcrumbList = [];
          if (isset($view->params['breadcrumbs'])) {
              $position = 1;
              foreach ($view->params['breadcrumbs'] as $breadcrumb) {
                  if (is_array($breadcrumb)) {
                      $breadcrumbList[] = (object)[
                          "@type" => "http://schema.org/ListItem",
                          "http://schema.org/position" => $position,
                          "http://schema.org/item" => (object)[
                              "@id" => Url::to($breadcrumb['url'], true),
                              "http://schema.org/name" => $breadcrumb['label'],
                          ]
                      ];
                  } else {
                      // Is it ok to omit URL here or not? Google is not clear on that:
                      // http://stackoverflow.com/questions/33688608/how-to-markup-the-last-non-linking-item-in-breadcrumbs-list-using-json-ld
                      $breadcrumbList[] = (object)[
                          "@type" => "http://schema.org/ListItem",
                          "http://schema.org/position" => $position,
                          "http://schema.org/item" => (object)[
                              "http://schema.org/name" => $breadcrumb,
                          ]
                      ];
                  }
                  $position++;
              }
          }
  
          $doc = (object)[
              "@type" => "http://schema.org/BreadcrumbList",
              "http://schema.org/itemListElement" => $breadcrumbList
          ];
  
          JsonLDHelper::add($doc);
      }
code_tokens: public static function addBreadcrumbList ( ) { $ view = Yii :: $ app -> getView ( ) ; $ breadcrumbList = [ ] ; if ( isset ( $ view -> params [ 'breadcrumbs' ] ) ) { $ position = 1 ; foreach ( $ view -> params [ 'breadcrumbs' ] as $ breadcrumb ) { if ( is_array ( $ breadcrumb ) ) { $ breadcrumbList [ ] = ( object ) [ "@type" => "http://schema.org/ListItem" , "http://schema.org/position" => $ position , "http://schema.org/item" => ( object ) [ "@id" => Url :: to ( $ breadcrumb [ 'url' ] , true ) , "http://schema.org/name" => $ breadcrumb [ 'label' ] , ] ] ; } else { // Is it ok to omit URL here or not? Google is not clear on that: // http://stackoverflow.com/questions/33688608/how-to-markup-the-last-non-linking-item-in-breadcrumbs-list-using-json-ld $ breadcrumbList [ ] = ( object ) [ "@type" => "http://schema.org/ListItem" , "http://schema.org/position" => $ position , "http://schema.org/item" => ( object ) [ "http://schema.org/name" => $ breadcrumb , ] ] ; } $ position ++ ; } } $ doc = ( object ) [ "@type" => "http://schema.org/BreadcrumbList" , "http://schema.org/itemListElement" => $ breadcrumbList ] ; JsonLDHelper :: add ( $ doc ) ; }
docstring: Adds BreadcrumbList schema.org markup based on the application view `breadcrumbs` parameter
docstring_tokens: Adds BreadcrumbList schema . org markup based on the application view breadcrumbs parameter