diff --git a/src/Phalcon/Dispatcher.php b/src/Phalcon/Dispatcher.php index 3d4d4de5..d61fe55b 100644 --- a/src/Phalcon/Dispatcher.php +++ b/src/Phalcon/Dispatcher.php @@ -38,7 +38,7 @@ abstract class Dispatcher implements \Phalcon\DispatcherInterface, \Phalcon\Di\I protected $_activeHandler; - protected $_finished; + protected $_finished = false; protected $_forwarded = false; @@ -95,6 +95,9 @@ abstract class Dispatcher implements \Phalcon\DispatcherInterface, \Phalcon\Di\I protected $_modelBinder = null; + protected $_isControllerInitialize = false; + + /** * Sets the dependency injector * @@ -315,18 +318,16 @@ public function setModelBinder(\Phalcon\Mvc\Model\BinderInterface $modelBinder, public function getModelBinder() {} /** - * Dispatches a handle action taking into account the routing parameters + * Process the results of the router by calling into the appropriate controller action(s) + * including any routing data or injected parameters. * - * @return object - */ - public function dispatch() {} - - /** - * Dispatches a handle action taking into account the routing parameters + * @return object|false Returns the dispatched handler class (the Controller for Mvc dispatching or a Task + * for CLI dispatching) or false if an exception occurred and the operation was + * stopped by returning false in the exception handler. * - * @return object + * @throws \Exception if any uncaught or unhandled exception occurs during the dispatcher process. */ - protected function _dispatch() {} + public function dispatch() {} /** * Forwards the execution flow to another controller/action. @@ -340,7 +341,10 @@ protected function _dispatch() {} * ); * * - * @param array $forward + * @param array forward + * + * @throws \Phalcon\Exception + * @param mixed $forward */ public function forward($forward) {} diff --git a/src/Phalcon/db/Profiler.php b/src/Phalcon/db/Profiler.php index 17ee2978..17e3ecad 100644 --- a/src/Phalcon/db/Profiler.php +++ b/src/Phalcon/db/Profiler.php @@ -11,10 +11,32 @@ * This helps you to identify bottlenecks in your applications. * * - * $profiler = new \Phalcon\Db\Profiler(); + * use Phalcon\Db\Profiler; + * use Phalcon\Events\Event; + * use Phalcon\Events\Manager; * - * // Set the connection profiler - * $connection->setProfiler($profiler); + * $profiler = new Profiler(); + * $eventsManager = new Manager(); + * + * $eventsManager->attach( + * "db", + * function (Event $event, $connection) use ($profiler) { + * if ($event->getType() === "beforeQuery") { + * $sql = $connection->getSQLStatement(); + * + * // Start a profile with the active connection + * $profiler->startProfile($sql); + * } + * + * if ($event->getType() === "afterQuery") { + * // Stop the active profile + * $profiler->stopProfile(); + * } + * } + * ); + * + * // Set the event manager on the connection + * $connection->setEventsManager($eventsManager); * * $sql = "SELECT buyer_name, quantity, product_name * FROM buyers LEFT JOIN products ON diff --git a/src/Phalcon/http/response/Cookies.php b/src/Phalcon/http/response/Cookies.php index 808c6cb3..ba61290a 100644 --- a/src/Phalcon/http/response/Cookies.php +++ b/src/Phalcon/http/response/Cookies.php @@ -23,6 +23,9 @@ class Cookies implements \Phalcon\Http\Response\CookiesInterface, \Phalcon\Di\In protected $_cookies; + + public function __construct() {} + /** * Sets the dependency injector * diff --git a/src/Phalcon/mvc/Model.php b/src/Phalcon/mvc/Model.php index b24451e1..676373d5 100644 --- a/src/Phalcon/mvc/Model.php +++ b/src/Phalcon/mvc/Model.php @@ -30,7 +30,7 @@ * $messages = $robot->getMessages(); * * foreach ($messages as $message) { - * echo message; + * echo $message; * } * } else { * echo "Great, a new robot was saved successfully!"; @@ -1022,7 +1022,6 @@ public function writeAttribute($attribute, $value) {} * generated INSERT/UPDATE statement * * - * - * - * - * - * - * - * - * - * - * - * * // Load data from models Robots * $builder->addFrom("Robots"); * * // Load data from model 'Robots' using 'r' as alias in PHQL * $builder->addFrom("Robots", "r"); - * - * // Load data from model 'Robots' using 'r' as alias in PHQL - * // and eager load model 'RobotsParts' - * $builder->addFrom("Robots", "r", "RobotsParts"); - * - * // Load data from model 'Robots' using 'r' as alias in PHQL - * // and eager load models 'RobotsParts' and 'Parts' - * $builder->addFrom( - * "Robots", - * "r", - * [ - * "RobotsParts", - * "Parts", - * ] - * ); * * * @param mixed $model diff --git a/src/Phalcon/validation/validator/Alnum.php b/src/Phalcon/validation/validator/Alnum.php index 8c784d33..c73c1ad4 100644 --- a/src/Phalcon/validation/validator/Alnum.php +++ b/src/Phalcon/validation/validator/Alnum.php @@ -8,8 +8,11 @@ * Check for alphanumeric character(s) * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alnum as AlnumValidator; * + * $validator = new Validation(); + * * $validator->add( * "username", * new AlnumValidator( diff --git a/src/Phalcon/validation/validator/Alpha.php b/src/Phalcon/validation/validator/Alpha.php index 72c2e0c4..87c1dd50 100644 --- a/src/Phalcon/validation/validator/Alpha.php +++ b/src/Phalcon/validation/validator/Alpha.php @@ -8,8 +8,11 @@ * Check for alphabetic character(s) * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Alpha as AlphaValidator; * + * $validator = new Validation(); + * * $validator->add( * "username", * new AlphaValidator( diff --git a/src/Phalcon/validation/validator/Between.php b/src/Phalcon/validation/validator/Between.php index 1f3ffc2a..a6ec67a6 100644 --- a/src/Phalcon/validation/validator/Between.php +++ b/src/Phalcon/validation/validator/Between.php @@ -9,8 +9,11 @@ * For a value x, the test is passed if minimum<=x<=maximum. * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Between; * + * $validator = new Validation(); + * * $validator->add( * "price", * new Between( diff --git a/src/Phalcon/validation/validator/Callback.php b/src/Phalcon/validation/validator/Callback.php index f467708e..6915f1e6 100644 --- a/src/Phalcon/validation/validator/Callback.php +++ b/src/Phalcon/validation/validator/Callback.php @@ -8,9 +8,12 @@ * Calls user function for validation * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Callback as CallbackValidator; * use Phalcon\Validation\Validator\Numericality as NumericalityValidator; * + * $validator = new Validation(); + * * $validator->add( * ["user", "admin"], * new CallbackValidator( diff --git a/src/Phalcon/validation/validator/Confirmation.php b/src/Phalcon/validation/validator/Confirmation.php index c54b7b0c..2c235c3d 100644 --- a/src/Phalcon/validation/validator/Confirmation.php +++ b/src/Phalcon/validation/validator/Confirmation.php @@ -8,8 +8,11 @@ * Checks that two values have the same value * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Confirmation; * + * $validator = new Validation(); + * * $validator->add( * "password", * new Confirmation( diff --git a/src/Phalcon/validation/validator/CreditCard.php b/src/Phalcon/validation/validator/CreditCard.php index a1f8109e..fcef5b6f 100644 --- a/src/Phalcon/validation/validator/CreditCard.php +++ b/src/Phalcon/validation/validator/CreditCard.php @@ -8,8 +8,11 @@ * Checks if a value has a valid credit card number * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\CreditCard as CreditCardValidator; * + * $validator = new Validation(); + * * $validator->add( * "creditCard", * new CreditCardValidator( diff --git a/src/Phalcon/validation/validator/Date.php b/src/Phalcon/validation/validator/Date.php index 306d0747..f5a354ed 100644 --- a/src/Phalcon/validation/validator/Date.php +++ b/src/Phalcon/validation/validator/Date.php @@ -8,8 +8,11 @@ * Checks if a value is a valid date * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Date as DateValidator; * + * $validator = new Validation(); + * * $validator->add( * "date", * new DateValidator( diff --git a/src/Phalcon/validation/validator/Digit.php b/src/Phalcon/validation/validator/Digit.php index 8b6e3d20..4bcc361b 100644 --- a/src/Phalcon/validation/validator/Digit.php +++ b/src/Phalcon/validation/validator/Digit.php @@ -8,8 +8,11 @@ * Check for numeric character(s) * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Digit as DigitValidator; * + * $validator = new Validation(); + * * $validator->add( * "height", * new DigitValidator( diff --git a/src/Phalcon/validation/validator/Email.php b/src/Phalcon/validation/validator/Email.php index 9314f976..804d42f2 100644 --- a/src/Phalcon/validation/validator/Email.php +++ b/src/Phalcon/validation/validator/Email.php @@ -8,8 +8,11 @@ * Checks if a value has a correct e-mail format * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Email as EmailValidator; * + * $validator = new Validation(); + * * $validator->add( * "email", * new EmailValidator( diff --git a/src/Phalcon/validation/validator/ExclusionIn.php b/src/Phalcon/validation/validator/ExclusionIn.php index cc3167d6..f4eac992 100644 --- a/src/Phalcon/validation/validator/ExclusionIn.php +++ b/src/Phalcon/validation/validator/ExclusionIn.php @@ -8,8 +8,11 @@ * Check if a value is not included into a list of values * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\ExclusionIn; * + * $validator = new Validation(); + * * $validator->add( * "status", * new ExclusionIn( @@ -32,7 +35,7 @@ * [ * "message" => [ * "status" => "The status must not be A or B", - * "type" => "The type must not be 1 or "' + * "type" => "The type must not be 1 or " * ], * "domain" => [ * "status" => [ diff --git a/src/Phalcon/validation/validator/File.php b/src/Phalcon/validation/validator/File.php index 20abe969..aef472d0 100644 --- a/src/Phalcon/validation/validator/File.php +++ b/src/Phalcon/validation/validator/File.php @@ -8,8 +8,11 @@ * Checks if a value has a correct file * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\File as FileValidator; * + * $validator = new Validation(); + * * $validator->add( * "file", * new FileValidator( diff --git a/src/Phalcon/validation/validator/Identical.php b/src/Phalcon/validation/validator/Identical.php index a5525adc..9a28f586 100644 --- a/src/Phalcon/validation/validator/Identical.php +++ b/src/Phalcon/validation/validator/Identical.php @@ -8,8 +8,11 @@ * Checks if a value is identical to other * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Identical; * + * $validator = new Validation(); + * * $validator->add( * "terms", * new Identical( diff --git a/src/Phalcon/validation/validator/InclusionIn.php b/src/Phalcon/validation/validator/InclusionIn.php index 54b18d60..b55343d3 100644 --- a/src/Phalcon/validation/validator/InclusionIn.php +++ b/src/Phalcon/validation/validator/InclusionIn.php @@ -8,8 +8,11 @@ * Check if a value is included into a list of values * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\InclusionIn; * + * $validator = new Validation(); + * * $validator->add( * "status", * new InclusionIn( diff --git a/src/Phalcon/validation/validator/Numericality.php b/src/Phalcon/validation/validator/Numericality.php index 336b5381..baf05fe8 100644 --- a/src/Phalcon/validation/validator/Numericality.php +++ b/src/Phalcon/validation/validator/Numericality.php @@ -8,8 +8,11 @@ * Check for a valid numeric value * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Numericality; * + * $validator = new Validation(); + * * $validator->add( * "price", * new Numericality( diff --git a/src/Phalcon/validation/validator/PresenceOf.php b/src/Phalcon/validation/validator/PresenceOf.php index a0d766b7..046f395b 100644 --- a/src/Phalcon/validation/validator/PresenceOf.php +++ b/src/Phalcon/validation/validator/PresenceOf.php @@ -8,8 +8,11 @@ * Validates that a value is not null or empty string * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\PresenceOf; * + * $validator = new Validation(); + * * $validator->add( * "name", * new PresenceOf( diff --git a/src/Phalcon/validation/validator/Regex.php b/src/Phalcon/validation/validator/Regex.php index bd5a0542..f3f431b9 100644 --- a/src/Phalcon/validation/validator/Regex.php +++ b/src/Phalcon/validation/validator/Regex.php @@ -8,8 +8,11 @@ * Allows validate if the value of a field matches a regular expression * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Regex as RegexValidator; * + * $validator = new Validation(); + * * $validator->add( * "created_at", * new RegexValidator( diff --git a/src/Phalcon/validation/validator/StringLength.php b/src/Phalcon/validation/validator/StringLength.php index 1695fea9..b95904f7 100644 --- a/src/Phalcon/validation/validator/StringLength.php +++ b/src/Phalcon/validation/validator/StringLength.php @@ -10,8 +10,11 @@ * be at least min, and at most max. * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\StringLength as StringLength; * + * $validator = new Validation(); + * * $validation->add( * "name_last", * new StringLength( diff --git a/src/Phalcon/validation/validator/Uniqueness.php b/src/Phalcon/validation/validator/Uniqueness.php index 22ff4f69..26b77fb4 100644 --- a/src/Phalcon/validation/validator/Uniqueness.php +++ b/src/Phalcon/validation/validator/Uniqueness.php @@ -8,8 +8,11 @@ * Check that a field is unique in the related table * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Uniqueness as UniquenessValidator; * + * $validator = new Validation(); + * * $validator->add( * "username", * new UniquenessValidator( diff --git a/src/Phalcon/validation/validator/Url.php b/src/Phalcon/validation/validator/Url.php index 8d5af7c7..b3e86bd5 100644 --- a/src/Phalcon/validation/validator/Url.php +++ b/src/Phalcon/validation/validator/Url.php @@ -8,8 +8,11 @@ * Checks if a value has a url format * * + * use Phalcon\Validation; * use Phalcon\Validation\Validator\Url as UrlValidator; * + * $validator = new Validation(); + * * $validator->add( * "url", * new UrlValidator(