EclipseGc

DrupalVerifiedStorageSQL.php

Feb 20th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.28 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Drupal\Core\Config;
  4.  
  5. use Drupal\Core\Config\DrupalConfigVerifiedStorage;
  6.  
  7. /**
  8.  * Represents an SQL-based configuration storage object.
  9.  */
  10. class DrupalVerifiedStorageSQL extends DrupalVerifiedStorageFile {
  11.  
  12.   /**
  13.    * Implements DrupalConfigVerifiedStorage::read().
  14.    */
  15.   public function read() {
  16.     if (!empty($GLOBALS['databases']) && function_exists('db_table_exists') && db_table_exists('config')) {
  17.       return db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $this->name))->fetchField();
  18.     }
  19.     return parent::read();
  20.   }
  21.  
  22.   /**
  23.    * Implements DrupalConfigVerifiedStorageInterface::writeToActive().
  24.    */
  25.   public function writeToActive($data) {
  26.     return db_merge('config')
  27.       ->key(array('name' => $this->name))
  28.       ->fields(array('data' => $data))
  29.       ->execute();
  30.   }
  31.  
  32.   /**
  33.    * @todo
  34.    */
  35.   public function deleteFromActive() {
  36.     db_delete('config')
  37.       ->condition('name', $this->name)
  38.       ->execute();
  39.   }
  40.  
  41.   /**
  42.    * Implements DrupalConfigVerifiedStorageInterface::getNamesWithPrefix().
  43.    */
  44.   static public function getNamesWithPrefix($prefix = '') {
  45.     return db_query('SELECT name FROM {config} WHERE name LIKE :name', array(':name' => db_like($prefix) . '%'))->fetchCol();
  46.   }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment