original_string: public function cartBlock($pid) {
      $site_commerce = $this->entityTypeManager->getStorage('site_commerce')->load($pid);
  
      // Проверяем добавлена ли текущая позиция в корзину.
      $position_in_cart = FALSE;
      $databaseSendOrder = \Drupal::service('site_orders.database');
      if ($databaseSendOrder->hasPositionInCart($site_commerce->getEntityTypeId(), $site_commerce->id())) {
        $position_in_cart = TRUE;
      }
  
      // Тип отображения.
      $type = 'default';
      if ($position_in_cart) {
        // Доступные варианты: default, load_open_cart_form, load_order_form, load_message_form.
        $type = $site_commerce->get('field_cart')->event;
      }
  
      return [
        '#theme' => 'site_commerce_cart_block',
        '#site_commerce' => $site_commerce,
        '#type' => $type,
      ];
    }
code: public function cartBlock($pid) {
      $site_commerce = $this->entityTypeManager->getStorage('site_commerce')->load($pid);
  
      // Проверяем добавлена ли текущая позиция в корзину.
      $position_in_cart = FALSE;
      $databaseSendOrder = \Drupal::service('site_orders.database');
      if ($databaseSendOrder->hasPositionInCart($site_commerce->getEntityTypeId(), $site_commerce->id())) {
        $position_in_cart = TRUE;
      }
  
      // Тип отображения.
      $type = 'default';
      if ($position_in_cart) {
        // Доступные варианты: default, load_open_cart_form, load_order_form, load_message_form.
        $type = $site_commerce->get('field_cart')->event;
      }
  
      return [
        '#theme' => 'site_commerce_cart_block',
        '#site_commerce' => $site_commerce,
        '#type' => $type,
      ];
    }
code_tokens: public function cartBlock ( $ pid ) { $ site_commerce = $ this -> entityTypeManager -> getStorage ( 'site_commerce' ) -> load ( $ pid ) ; // Проверяем добавлена ли текущая позиция в корзину. $ position_in_cart = FALSE ; $ databaseSendOrder = \ Drupal :: service ( 'site_orders.database' ) ; if ( $ databaseSendOrder -> hasPositionInCart ( $ site_commerce -> getEntityTypeId ( ) , $ site_commerce -> id ( ) ) ) { $ position_in_cart = TRUE ; } // Тип отображения. $ type = 'default' ; if ( $ position_in_cart ) { // Доступные варианты: default, load_open_cart_form, load_order_form, load_message_form. $ type = $ site_commerce -> get ( 'field_cart' ) -> event ; } return [ '#theme' => 'site_commerce_cart_block' , '#site_commerce' => $ site_commerce , '#type' => $ type , ] ; }
docstring: Callback lazy builder for to cart block.
  
  @param [int] $pid
  @return array
docstring_tokens: Callback lazy builder for to cart block .