We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Access to a Dependency in a Model

Hi, i want to know if im doing this correctly, currently im using the following code:

$this->password = \Phalcon\DI::getDefault()->getSecurity()->hash($this->password);

Is it ok, or is there any other method?



595
Accepted
answer

$this->password = $this->getDI()->getSecurity()->hash($this->password);

Thanks man :)