You are here

public static function TincanService::getInfoFromExtractedPackage in Opigno module 8

Same name and namespace in other branches
  1. 3.x ActivityTypes/opigno_tincan_activity/src/TincanService.php \Drupal\opigno_tincan_activity\TincanService::getInfoFromExtractedPackage()

This method will return the Activity ID and the launch file.

These information must be in the tincan.xml file that is in the extracted package. You can find more information in the README.md file of this module.

Parameters

object $file: The file that was unzipped.

Return value

array|bool An array('id', 'launch') if all the information are found, FALSE if not.

1 call to TincanService::getInfoFromExtractedPackage()
TincanService::saveTincanPackageInfo in ActivityTypes/opigno_tincan_activity/src/TincanService.php
Save tincan package.

File

ActivityTypes/opigno_tincan_activity/src/TincanService.php, line 113

Class

TincanService
Class TincanService.

Namespace

Drupal\opigno_tincan_activity

Code

public static function getInfoFromExtractedPackage($file) {
  $tincan_file = self::getExtractPath($file) . 'tincan.xml';
  if (!file_exists(self::getExtractPath($file) . 'tincan.xml')) {
    return FALSE;
  }
  $xml = simplexml_load_file($tincan_file);
  if (!$xml) {
    return FALSE;
  }

  // Check if the launch exists.
  if (!isset($xml->activities->activity->launch)) {
    return FALSE;
  }

  // Check if the activity ID exists.
  if (!isset($xml->activities->activity['id'])) {
    return FALSE;
  }
  return [
    'launch' => (string) $xml->activities->activity->launch,
    'id' => (string) $xml->activities->activity['id'],
  ];
}