You are here

class TagadelicDrupalWrapper in Tagadelic 7.2

Wrapper around Drupal Core functions.

All Drupal core functionality we want to use and call in our lib is reproduced and wrapped here. That way, e.g. cache_get() becomes TagadelicDrupalWrapper::cache_get().

We don't, however, load and bootstrap Drupal. It is assumed to be loaded and bootstrapped. After all: Drupal calls and includes us, not the other way around. But it does leave us with interesting options when testing: we can then inlcude Drupal if needed.

Why? You ask? Because that way, backwards-incompatibility with version upgrades in Drupal is a minor change only in this file. We can very easily support new and old versions of Drupal by only changing this file. And we can test properly. Stubbing becomes a tad easier this way, making our tests truly isolated.

Hierarchy

Expanded class hierarchy of TagadelicDrupalWrapper

9 string references to 'TagadelicDrupalWrapper'
TagadelicCloudTest::testDrupalInstantiatesNewWrapper in tests/TagadelicCloudTest.php
@covers TagadelicCloud::drupal()
TagadelicCloudTest::testfrom_cache in tests/TagadelicCloudTest.php
@covers tagadeliccloud::from_cache
TagadelicCloudTest::testSortByCount in tests/TagadelicCloudTest.php
Sort by count. Highest count first.
TagadelicCloudTest::testSortByName in tests/TagadelicCloudTest.php
Sort By name
TagadelicCloudTest::testSortByNameWithInternationalCharacters in tests/TagadelicCloudTest.php
Sort By name should sort International characters like ÅÄÖABO

... See full list

File

./TagadelicDrupalWrapper.php, line 16

View source
class TagadelicDrupalWrapper {

  /*
   * http://api.drupal.org/api/drupal/includes!cache.inc/function/cache_get/7
   */
  public function cache_get($cid, $bin = 'cache') {
    return cache_get($cid, $bin);
  }

  /*
   * http://api.drupal.org/api/drupal/includes!cache.inc/function/cache_set/7
   * Default $expire is different from original, NULL, since we don't have the
   *  globals defined here.
   */
  public function cache_set($cid, $data, $bin = 'cache', $expire = NULL) {
    if ($expire === NULL) {
      return cache_set($cid, $data, $bin);
    }
    else {
      return cache_set($cid, $data, $bin, $expire);
    }
  }

  /**
   * http://api.drupal.org/api/drupal/includes!bootstrap.inc/function/check_plain/7
   */
  public function check_plain($text) {
    return check_plain($text);
  }

  /**
   * http://api.drupal.org/api/drupal/includes!common.inc/function/l/7
   */
  public function l($text, $path, $options = array()) {
    return l($text, $path, $options);
  }

  /**
   * Wraps PHP core function `shuffle()` http://php.net/manual/en/function.shuffle.php
   */
  public function shuffle(&$array) {
    shuffle($array);
  }

}

Members