TitanFrameworkOption::factory PHP Méthode

factory() public static méthode

public static factory ( $settings, $owner )
    public static function factory($settings, $owner)
    {
        $settings = array_merge(self::$defaultSettings, $settings);
        $className = 'TitanFrameworkOption' . str_replace(' ', '', ucwords(str_replace('-', ' ', $settings['type'])));
        // assume all the classes are already required
        if (!class_exists($className) && !class_exists($settings['type'])) {
            TitanFramework::displayFrameworkError(sprintf(__('Option type or extended class %s does not exist.', TF_I18NDOMAIN), '<code>' . $settings['type'] . '</code>', $settings), $settings);
            return null;
        }
        if (class_exists($className)) {
            $obj = new $className($settings, $owner);
            return $obj;
        }
        $className = $settings['type'];
        $obj = new $className($settings, $owner);
        return $obj;
    }

Usage Example

 public function createOption($settings)
 {
     if (!apply_filters('tf_create_option_continue_' . $this->owner->owner->optionNamespace, true, $settings)) {
         return null;
     }
     $obj = TitanFrameworkOption::factory($settings, $this);
     $this->options[] = $obj;
     do_action('tf_create_option_' . $this->owner->owner->optionNamespace, $obj);
     return $obj;
 }
All Usage Examples Of TitanFrameworkOption::factory