We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 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 :)