You are here

protected function MailchimpSignupSubscribeBlock::getFormId in Mailchimp 2.x

Same name and namespace in other branches
  1. 8 modules/mailchimp_signup/src/Plugin/Block/MailchimpSignupSubscribeBlock.php \Drupal\mailchimp_signup\Plugin\Block\MailchimpSignupSubscribeBlock::getFormId()

Get the ID of the form.

Parameters

\Drupal\mailchimp_signup\Entity\MailchimpSignup $entity: An instance of the SignUp entity.

Return value

string Returns the id of the form.

1 call to MailchimpSignupSubscribeBlock::getFormId()
MailchimpSignupSubscribeBlock::build in modules/mailchimp_signup/src/Plugin/Block/MailchimpSignupSubscribeBlock.php
Builds and returns the renderable array for this block plugin.

File

modules/mailchimp_signup/src/Plugin/Block/MailchimpSignupSubscribeBlock.php, line 108

Class

MailchimpSignupSubscribeBlock
Provides a 'Subscribe' block.

Namespace

Drupal\mailchimp_signup\Plugin\Block

Code

protected function getFormId(MailchimpSignup $entity) {

  // The base form_id.
  // We keep it the same way as it was until now,
  // without having to add the suffix. We are doing this
  // in case there are already existing form hooks relying
  // on this name, so that we cant at least keep some BC
  // before having to add the suffix for each form coming up next.
  $id = 'mailchimp_signup_subscribe_block_' . $entity->id . '_form';

  // Add the suffix in case we've already created one block
  // with a signup form.
  if (static::$counter && static::$counter >= 1) {
    $id = sprintf('%s_%d', $id, static::$counter);
  }
  static::$counter++;
  return $id;
}