/** * Creates instance of target class * * @param string $type Class ID * @param array $args Class arguments * @return object Class instance */ public static function create($type, array $args = array()) { // Create object $obj = parent::create($type, $args); // Track object if trackable if ($obj instanceof TrackableObjectAbstract) { ObjectTracker::getInstance()->track($obj); } return $obj; }
/** * Handles any call to undefined static methods * * @param string $name Name of the target method * @param array $args Arguments for the target method * @return mixed */ public static function __callStatic($name, $args) { ////////////////////////////// // Check for correct method // ////////////////////////////// // Check for get $is_get = substr($name, 0, 3) == 'get' ? true : false; ///////// // Get // ///////// if ($is_get) { $get_action = substr($name, 3, strlen($name)); $is_getPostType = $get_action == 'PostType' ? true : false; $is_getTaxonomy = $get_action == 'Taxonomy' ? true : false; $is_getMetabox = $get_action == 'Metabox' ? true : false; if ($is_getPostType || $is_getTaxonomy || $is_getMetabox) { if (!isset($args[0])) { return; } if (is_string($args[0])) { $key = Utils::slugify($args[0]); if ($is_getPostType) { $type = 'post_type'; } if ($is_getTaxonomy) { $type = 'taxonomy'; } if ($is_getMetabox) { $type = 'metabox'; } return $type ? ObjectTracker::get($type, $key) : null; } } } else { return call_user_func_array(array('Ponticlaro\\Bebop\\Core\\Helpers\\BebopFactory', 'create'), array($name, $args)); } }