| 1 |
<?php |
| 2 |
/** |
| 3 |
* The feedback factory class for ThemeIsle SDK |
| 4 |
* |
| 5 |
* @package ThemeIsleSDK |
| 6 |
* @subpackage Feedback |
| 7 |
* @copyright Copyright (c) 2017, Marius Cristea |
| 8 |
* @license http://opensource.org/licenses/gpl-3.0.php GNU Public License |
| 9 |
* @since 1.0.0 |
| 10 |
*/ |
| 11 |
// Exit if accessed directly. |
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
if ( ! class_exists( 'ThemeIsle_SDK_Feedback_Factory' ) ) : |
| 16 |
/** |
| 17 |
* Feedback model for ThemeIsle SDK. |
| 18 |
*/ |
| 19 |
class ThemeIsle_SDK_Feedback_Factory { |
| 20 |
|
| 21 |
/** |
| 22 |
* @var array $instances collection of the instances that are registered with the factory |
| 23 |
*/ |
| 24 |
private $_instances = array(); |
| 25 |
|
| 26 |
/** |
| 27 |
* ThemeIsle_SDK_Feedback_Factory constructor. |
| 28 |
* |
| 29 |
* @param ThemeIsle_SDK_Product $product_object Product Object. |
| 30 |
* @param array $feedback_types the feedback types. |
| 31 |
*/ |
| 32 |
public function __construct( $product_object, $feedback_types ) { |
| 33 |
if ( $product_object instanceof ThemeIsle_SDK_Product && $feedback_types && is_array( $feedback_types ) ) { |
| 34 |
foreach ( $feedback_types as $type ) { |
| 35 |
$class = 'ThemeIsle_SDK_Feedback_' . ucwords( $type ); |
| 36 |
$instance = new $class( $product_object ); |
| 37 |
$this->_instances[ $type ] = $instance; |
| 38 |
$instance->setup_hooks(); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Get the registered instances |
| 45 |
*/ |
| 46 |
public function get_instances() { |
| 47 |
return $this->_instances; |
| 48 |
} |
| 49 |
} |
| 50 |
endif; |
| 51 |
|