Commit 384ed137 authored by Joshua Fernandes's avatar Joshua Fernandes Committed by Adrian Cid Almaguer
Browse files

Issue #3017588 by joshua1234511, adriancid: Block to display information in the front end

parent 8e0692ac
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ class ContributeManager implements ContributeManagerInterface {
  /**
   * {@inheritdoc}
   */
  public function getAccount() {
  public function getAccount($display_type = TRUE) {
    $account_type = $this->getAccountType();
    $account_id = $this->getAccountId() ?: 'anonymous';

@@ -187,6 +187,7 @@ class ContributeManager implements ContributeManagerInterface {
        '#prefix' => '<br/>',
        '#markup' => $this->t('On Drupal.org for @date', $t_args),
      ];
      if ($display_type) {
        $account['description']['link'] = [
          '#type' => 'link',
          '#title' => $this->t('Configure'),
@@ -194,6 +195,7 @@ class ContributeManager implements ContributeManagerInterface {
          '#attributes' => $configure_attributes + ['class' => ['use-ajax']],
        ];
      }
    }
    else {
      $t_args = [
        ':href_register' => 'https://register.drupal.org/user/register',
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ interface ContributeManagerInterface {
   * @return array
   *   An associative array containing account status.
   */
  public function getAccount();
  public function getAccount($display_type);

  /**
   * Get membership status.
+34 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\contribute\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a 'Community Information' block.
 *
 * @Block(
 *   id = "community_information_block",
 *   admin_label = @Translation("Community Information block"),
 *   category = @Translation("Community Information Block")
 * )
 */
class CommunityInformationBlock extends BlockBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];
    /** @var \Drupal\contribute\ContributeManagerInterface $contribute_manager */
    $contribute_manager = \Drupal::service('contribute.manager');
    if ($contribute_manager->getStatus()) {
      $build['#theme'] = 'contribute_status_report_community_info';
      $build['#account'] = $contribute_manager->getAccount(FALSE);
      $build['#membership'] = $contribute_manager->getMembership();
      $build['#contribution'] = $contribute_manager->getContribution();
    }
    return $build;
  }

}