You are here

public static function OpignoTinCanApiStatements::setVerb in Opigno TinCan API 8

Same name and namespace in other branches
  1. 3.x src/OpignoTinCanApiStatements.php \Drupal\opigno_tincan_api\OpignoTinCanApiStatements::setVerb()

Sets statement verb.

Parameters

\TinCan\Statement $statement: The statement to add the verb.

array $verb: An array containing the verb name and id (url). Use TinCanVerbs.

Throws

Exception Throw an Exception if $verb is not conform.

3 calls to OpignoTinCanApiStatements::setVerb()
OpignoTinCanApiStatements::statementBaseCreation in src/OpignoTinCanApiStatements.php
Adds the current user as the actor.
_opigno_tincan_badges_create_and_send_statements in modules/opigno_tincan_badges/opigno_tincan_badges.module
Function for creating and sending tincan statemens when user get a badge.
_opigno_tincan_learning_path_send_statemets_certificate in modules/opigno_tincan_learning_path/opigno_tincan_learning_path.module
Sends statements certificate.

File

src/OpignoTinCanApiStatements.php, line 340

Class

OpignoTinCanApiStatements
Class OpignoTinCanApiStatements.

Namespace

Drupal\opigno_tincan_api

Code

public static function setVerb(Statement &$statement, array $verb) {

  // opigno_tincan_api_set_verb.
  if (empty($verb) || empty($verb['name']) || empty($verb['id'])) {
    throw new Exception('The verb given does not exist');
  }
  $verb = new Verb([
    'id' => $verb['id'],
    'display' => [
      'en-US' => $verb['name'],
    ],
  ]);
  $statement
    ->setVerb($verb);
}