construct() is deprecated

My server configuration environment php7.1.2 phalcon3.2.4

I have a question

In ODM,I used Validator

$this->validate(new PresenceOf( array( 'field' => 'proname', 'message' => 'please type product name', ) ));

have a warning

Function Phalcon\Mvc\Model\Validator::__construct() is deprecated

edited 13d ago

You can use either initialize() or onConstruct(). For your use-case it should be initialize()

The initialize() method is only called once during the request, it’s intended to perform initializations that apply for all instances of the model created within the application. If you want to perform initialization tasks for every instance created you can use the onConstruct() method: