Example #1
0
 /**
  * This method will return an array of cache keys that may be used to store this model in cache.  The $modelAttributes
  * array should contain all the fields required to populate the unique keys returned from getUniqueKeys()
  *
  * @access public
  * @static
  * @param  array $modelAttributes
  * @return array Returns an array of cache keys, keyed off the column names.
  */
 public static function uniqueKeys(Model $sourceObject)
 {
     $objectKeys = $sourceObject->getUniqueKeys();
     $primaryKey = $sourceObject->getKeyName();
     if (!in_array($primaryKey, $objectKeys)) {
         $objectKeys[] = $primaryKey;
     }
     $uniqueKeys = [];
     foreach ($objectKeys as $value) {
         $key = $value;
         if (is_array($key)) {
             sort($key);
             sort($value);
             $key = implode(",", $key);
         }
         $uniqueKeys[$key] = $value;
     }
     ksort($uniqueKeys);
     return $uniqueKeys;
 }