You are here

class RealisticDummyContentLiveEnvironment in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentLiveEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentLiveEnvironment
  2. 7.2 api/src/includes/RealisticDummyContentLiveEnvironment.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentLiveEnvironment

The live environment.

During normal execution, we want to do things like interact with the file- system and such. However during testing we want to abstract that away. This class represents the live environment.

Hierarchy

Expanded class hierarchy of RealisticDummyContentLiveEnvironment

File

api/src/includes/RealisticDummyContentLiveEnvironment.php, line 12

Namespace

Drupal\realistic_dummy_content_api\includes
View source
class RealisticDummyContentLiveEnvironment extends RealisticDummyContentEnvironment {

  /**
   * {@inheritdoc}
   */
  public function implementFileGetContents($filename) : string {
    $return = file_get_contents($filename);
    if ($return === FALSE) {
      throw new \Exception('Cannot get contents of ' . $filename);
    }
    return $return;
  }

  /**
   * {@inheritdoc}
   */
  public function implementFileSaveData($data, $destination = NULL) {
    return file_save_data($data, $destination);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RealisticDummyContentEnvironment::$env private static property Private variable containing the environment to use.
RealisticDummyContentEnvironment::addFileToArray public static function Adds a file to an array of file group parts.
RealisticDummyContentEnvironment::attributeName public static function Returns the attribute of a filename if one exists.
RealisticDummyContentEnvironment::fileGetContents public function Get the contents of a file.
RealisticDummyContentEnvironment::filenameRadical public static function Returns the name radical of a filename.
RealisticDummyContentEnvironment::fileSaveData public function Save the file data to the real or test environment.
RealisticDummyContentEnvironment::get public static function Get the current environment.
RealisticDummyContentEnvironment::getAllFileGroups public static function Returns all files with a given extension for a given filepath.
RealisticDummyContentEnvironment::getFileContents public static function Returns the trimmed contents of a Drpual file object, or NULL if empty.
RealisticDummyContentEnvironment::getFileParts public static function Retrieves the parts constituting a filename.
RealisticDummyContentEnvironment::implementSortCandidateFiles public static function Given a list of candidate files, sort them by names and parts.
RealisticDummyContentEnvironment::lowercaseRadicalNoExtension public static function Returns the part of a string before the extension, in lowercase.
RealisticDummyContentEnvironment::replace public static function Returns part of a filename.
RealisticDummyContentEnvironment::set public static function Set the current environment.
RealisticDummyContentEnvironment::sortCandidateFiles public static function Given a list of candidate files, sort them by names and parts.
RealisticDummyContentEnvironment::strToLower public static function Wrapper around drupal_strtolower(if it exists) or strtolower.
RealisticDummyContentEnvironment::validCandidateFilename public static function Checks if a filename is valid.
RealisticDummyContentLiveEnvironment::implementFileGetContents public function Internal function used to get the contents of a file. Overrides RealisticDummyContentEnvironment::implementFileGetContents
RealisticDummyContentLiveEnvironment::implementFileSaveData public function Implements $this->fileSaveData(). Overrides RealisticDummyContentEnvironment::implementFileSaveData