Carbon_Fields\Exception\Incorrect_Syntax_Exception::raise PHP Method

raise() public static method

Throw an exception when WP_DEBUG is enabled, and show a friendly admin notice otherwise
public static raise ( $message, $code = null )
    public static function raise($message, $code = null)
    {
        if (empty(self::$errors)) {
            add_action('admin_notices', array(__NAMESPACE__ . '\\Incorrect_Syntax_Exception', 'print_errors'));
        }
        $exception = new self($message, $code);
        if (self::$throw_errors) {
            throw $exception;
        } else {
            self::$errors[] = $exception;
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Create a new datastore of type $type.
  *
  * @param string $type
  * @return Datastore $datastore
  **/
 public static function factory($type)
 {
     $type = str_replace(' ', '_', ucwords(str_replace('_', ' ', $type)));
     $class = __NAMESPACE__ . '\\' . $type . '_Datastore';
     if (!class_exists($class)) {
         Incorrect_Syntax_Exception::raise('Unknown data store type "' . $type . '".');
     }
     $field = new $class();
     return $field;
 }
All Usage Examples Of Carbon_Fields\Exception\Incorrect_Syntax_Exception::raise
Incorrect_Syntax_Exception