Auth_PrefManager2
[ class tree: Auth_PrefManager2 ] [ index: Auth_PrefManager2 ] [ all elements ]

Source for file Array.php

Documentation is available at Array.php

  1. <?php
  2. require_once('Auth/PrefManager2/Container.php');
  3.  
  4. class Auth_PrefManager2_Container_Mock extends Auth_PrefManager2_Container
  5. {
  6.     var $_prefs = array();
  7.     
  8.     /**
  9.      * Sets a value with the container.
  10.      * This method should be overridden by container classes to do whatever
  11.      * needs doing.
  12.      *
  13.      * @param string $owner The owner to set the preference for.
  14.      * @param string $preference The name of the preference to set.
  15.      * @param string $application The application to set for.
  16.      * @return bool Success/failure
  17.      * @access protected
  18.      * @abstract
  19.      */
  20.     function _set($owner$preference$value$application)
  21.     {
  22.         $hash $this->_hash($application$owner);
  23.         
  24.         $this->_prefs[$hash][$preference$value;
  25.         
  26.         return true;
  27.     }
  28.     
  29.     /**
  30.      * Gets a value from the container.
  31.      * This method should be overridden by container classes to do whatever
  32.      * needs doing.
  33.      *
  34.      * @param string $owner The owner to set the preference for.
  35.      * @param string $preference The name of the preference to set.
  36.      * @param mixed $value The value to set the preference to.
  37.      * @param string $application The application to set for.
  38.      * @return bool Success/failure
  39.      * @access protected
  40.      * @abstract
  41.      */
  42.     function _get($owner$preference$application)
  43.     {
  44.         $hash $this->_hash($application$owner);
  45.         if (isset($this->_prefs[$hash][$preference])) {
  46.             return $this->_prefs[$hash][$preference];
  47.         }
  48.         
  49.         return null;
  50.     }
  51.     
  52.     /**
  53.      * Deletes a value from the container.
  54.      * This method should be overridden by container classes to do whatever
  55.      * needs doing.
  56.      *
  57.      * @param string $owner The owner to delete the preference for.
  58.      * @param string $preference The name of the preference to delete.
  59.      * @param string $application The application to delete from.
  60.      * @return bool Success/failure
  61.      * @access protected
  62.      * @abstract
  63.      */
  64.     function _delete($owner$preference$application)
  65.     {
  66.         $hash $this->_hash($application$owner);
  67.         if (isset($this->_prefs[$hash][$preference])) {
  68.             unset($this->_prefs[$hash][$preference]);
  69.         }
  70.         
  71.         return true;
  72.     }
  73.     
  74.     /**
  75.      * Checks if the specified preference exists in the data container.
  76.      * This method should be overridden by container classes to do whatever
  77.      * needs doing.
  78.      *
  79.      * Returns null if an error occurs.
  80.      *
  81.      * @param string $owner The owner to delete the preference for.
  82.      * @param string $preference The name of the preference to delete.
  83.      * @param string $application The application to delete from.
  84.      * @return bool Does the pref exist?
  85.      * @access protected
  86.      * @abstract
  87.      */
  88.     function _exists($owner$preference$application)
  89.     {
  90.         $hash $this->_hash($application$owner);
  91.         return isset($this->_prefs[$hash][$preference]);
  92.     }
  93.     
  94.     /**
  95.      * Creates a hash key for the specified owner and application.
  96.      * 
  97.      * If the owner/application pair hasn't been used before a key will be created
  98.      * for them.
  99.      *
  100.      * @param string $owner The owner.
  101.      * @param application $application The application.
  102.      * @return string The hash.
  103.      */
  104.     function _hash($owner$application)
  105.     {
  106.         $hash serialize(array($owner$application));
  107.         if (!isset($this->_prefs[$hash])) {
  108.             $this->_prefs[$hash= array();
  109.         }
  110.         
  111.         return $hash;
  112.     }
  113. }
  114.  
  115. ?>

Documentation generated on Mon, 11 Mar 2019 13:54:06 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.