Understanding the Built-in Console

Inside the uFlex there is an object called console. The console tracks and logs processes, steps and errors inside the class object. There are three main sections inside the console: report, error, form.

Report holds every process and step inside the class, including the error and form.

  Array
  (
    [0] => Passwords matched
    [1] => No Error Found!
    [2] => New Validation Object added
    [3] => The username is Valid
    [4] => The password is Valid
    [5] => The email is Valid
    [6] => No Error Found!
    [7] => Error: This Email is Already in Use
    [8] => Error: This Username is not available
    [9] => 2 Error(s) Found!
  )

Error stores the errors that makes a process fail or return false. If an inside function returns false the detailed error will be here so be sure to check it out.

  Array
    (
      [0] => This Email is Already in Use
      [1] => This Username is not available
    )

Form holds the name of invalid fields and their error message, fields that did match with the regular expression or are not within the range limit in length. This comes very handy to notify users of invalid fields, specially if using AJAX with a javascript framework like jQuery.

  Array
  (
    [email] => Email is not valid
    [username] => Username is too short
  )

Assuming $user is the uFlex object in question, this is how the console output from above is obtained:

    //Reports
    $user->report();
    
    //Errors
    $user->error();
    
    //Form
    $user->form_error();

Here is how a full console output looks like:

Array
(
  [errors] => Array
    (
      [login] => Array
        (
          [0] => No Username or Password provided
        )

      [registration] => Array
        (
          [0] => This Email is Already in Use
          [1] => This Username is not available
        )

    )

  [reports] => Array
    (
      [login] => Array
        (
          [0] => Error: No Username or Password provided
          [1] => User is Guess
        )

      [registration] => Array
        (
          [0] => Passwords matched
          [1] => No Error Found!
          [2] => New Validation Object added
          [3] => The username is Valid
          [4] => The password is Valid
          [5] => The email is Valid
          [6] => No Error Found!
          [7] => Error: This Email is Already in Use
          [8] => Error: This Username is not available
          [9] => 2 Error(s) Found!
        )

    )

  [form] => Array
    (
      [registration] => Array
        (
          [email] => Email is not valid
          [username] => Username is too short
        )

    )

)

You can clearly see the three major sections, report, error and form. You can also notice that all have common sub-sections. This sub-sections simply indicate the process in which the the step or error was caught. There are currently three possible sub-sections: login, registration and update.

Going back to the clean prints all the way to the beginning, they look clearer because using such method only gets the last process logged, in this case the registration. Here is how you can get a clean print for report, error and form in a single object:

	$data['report'] = $user->report();
	$data['error'] = $user->error();
	$data['form'] = $user->form_error();

If you print the $data array you will get this:

Array
(
  [report] => Array
    (
      [0] => Passwords matched
      [1] => No Error Found!
      [2] => New Validation Object added
      [3] => The username is Valid
      [4] => The password is Valid
      [5] => The email is Valid
      [6] => No Error Found!
      [7] => Error: This Email is Already in Use
      [8] => Error: This Username is not available
      [9] => 2 Error(s) Found!
    )

  [error] => Array
    (
      [0] => This Email is Already in Use
      [1] => This Username is not available
    )

  [form] => Array
    (
      [email] => Email is not valid
      [username] => Username is too short
    )

)



Copyright © 2010-2013 Pablo Tejada, All Right Reserved. Webmaster | Generated in 0.09 seconds