public function save() {
    $return = parent::save();

    // Create Game opportunity.
    $campaignMembers = $this->getActiveCampaignMembers();

    foreach (array_keys($campaignMembers) as $campaignMemberId) {
      $isAllowedToCreateAnEntry = FALSE;

      $memberCampaign = MemberCampaign::load($campaignMemberId);
      /** @var \Drupal\node\NodeInterface $campaign */
      $campaign = $memberCampaign->getCampaign();
      foreach ($campaign->get('field_ways_to_earn_entries')->getValue() as $item) {
        if ($item['value'] == MemberGame::TYPE_CHECKIN) {
          $isAllowedToCreateAnEntry = TRUE;
          break;
        }
      }

      if ($isAllowedToCreateAnEntry) {
        $game = MemberGame::create([
          'member' => $campaignMemberId,
          'chance_type' => MemberGame::TYPE_CHECKIN,
        ]);

        $game->save();
      }
    }

    return $return;
  }
public function save() {
    $return = parent::save();

    // Create Game opportunity.
    $campaignMembers = $this->getActiveCampaignMembers();

    foreach (array_keys($campaignMembers) as $campaignMemberId) {
      $isAllowedToCreateAnEntry = FALSE;

      $memberCampaign = MemberCampaign::load($campaignMemberId);
      /** @var \Drupal\node\NodeInterface $campaign */
      $campaign = $memberCampaign->getCampaign();
      foreach ($campaign->get('field_ways_to_earn_entries')->getValue() as $item) {
        if ($item['value'] == MemberGame::TYPE_CHECKIN) {
          $isAllowedToCreateAnEntry = TRUE;
          break;
        }
      }

      if ($isAllowedToCreateAnEntry) {
        $game = MemberGame::create([
          'member' => $campaignMemberId,
          'chance_type' => MemberGame::TYPE_CHECKIN,
        ]);

        $game->save();
      }
    }

    return $return;
  }
public function save ( ) { $ return = parent :: save ( ) ; // Create Game opportunity. $ campaignMembers = $ this -> getActiveCampaignMembers ( ) ; foreach ( array_keys ( $ campaignMembers ) as $ campaignMemberId ) { $ isAllowedToCreateAnEntry = FALSE ; $ memberCampaign = MemberCampaign :: load ( $ campaignMemberId ) ; /** @var \Drupal\node\NodeInterface $campaign */ $ campaign = $ memberCampaign -> getCampaign ( ) ; foreach ( $ campaign -> get ( 'field_ways_to_earn_entries' ) -> getValue ( ) as $ item ) { if ( $ item [ 'value' ] == MemberGame :: TYPE_CHECKIN ) { $ isAllowedToCreateAnEntry = TRUE ; break ; } } if ( $ isAllowedToCreateAnEntry ) { $ game = MemberGame :: create ( [ 'member' => $ campaignMemberId , 'chance_type' => MemberGame :: TYPE_CHECKIN , ] ) ; $ game -> save ( ) ; } } return $ return ; }
Create Game opportunity and utilization activity while checkin record is created.
Create Game opportunity and utilization activity while checkin record is created .