| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Suppress "error - 0 - No summary was found for this file" on phpdoc generation |
| 5 |
* |
| 6 |
* @package WPDataProjects\Data_Dictionary |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace WPDataProjects\Data_Dictionary { |
| 10 |
|
| 11 |
/** |
| 12 |
* Class WPDP_List_Columns_Cache |
| 13 |
* |
| 14 |
* Instances of object WPDP_List_Columns are cached in this class |
| 15 |
* |
| 16 |
* @author Peter Schulz |
| 17 |
* @since 2.0.0 |
| 18 |
*/ |
| 19 |
class WPDP_List_Columns_Cache { |
| 20 |
|
| 21 |
/** |
| 22 |
* List of cached instances of WPDP_List_Columns |
| 23 |
* |
| 24 |
* @var array |
| 25 |
*/ |
| 26 |
protected static $cached_list_columns = array(); |
| 27 |
|
| 28 |
/** |
| 29 |
* Gets an instance of WPDP_List_Columns from cache or creates a new instance |
| 30 |
* |
| 31 |
* New instances are added to the cache |
| 32 |
* |
| 33 |
* @param string $schema_name Database schema name |
| 34 |
* @param string $table_name Database table name |
| 35 |
* @param string $label_type Label type |
| 36 |
* @param string $setname Options set name |
| 37 |
* |
| 38 |
* @return object Handle to WPDP_List_Columns instance |
| 39 |
*/ |
| 40 |
public static function get_list_columns( $schema_name, $table_name, $label_type, $setname = 'default' ) { |
| 41 |
$index = "$schema_name.$table_name.$label_type.$setname"; |
| 42 |
if ( ! isset( self::$cached_list_columns[ $index ] ) ) { |
| 43 |
self::$cached_list_columns[ $index ] = new WPDP_List_Columns( $schema_name, $table_name, $label_type, $setname ); |
| 44 |
} |
| 45 |
|
| 46 |
return self::$cached_list_columns[ $index ]; |
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
} |
| 52 |
|