/** * Constructor * * @param array $config configuration options for this object. Requires the * `hashers` key to be present in the array with a list of other hashers to be * used */ public function __construct(array $config = []) { parent::__construct($config); foreach ($this->_config['hashers'] as $key => $hasher) { if (is_array($hasher) && !isset($hasher['className'])) { $hasher['className'] = $key; } $this->_hashers[] = PasswordHasherFactory::build($hasher); } }
/** * Constructor * * @param array $config configuration options for this object. Requires the * `hashers` key to be present in the array with a list of other hashers to be * used */ public function __construct(array $config = []) { parent::__construct($config); foreach ($this->_config['hashers'] as $key => $hasher) { if (!is_string($hasher)) { $hasher += ['className' => $key]; } $this->_hashers[] = PasswordHasherFactory::build($hasher); } }
/** * PasswordableBehavior::_getPasswordHasher() * * @param mixed $hasher Name or options array. * @return PasswordHasher */ protected function _getPasswordHasher($hasher) { return PasswordHasherFactory::build($hasher); $class = $hasher; $config = []; if (is_array($hasher)) { $class = $hasher['className']; unset($hasher['className']); $config = $hasher; } list($plugin, $class) = pluginSplit($class, true); $className = $class . 'PasswordHasher'; App::uses($className, $plugin . 'Controller/Component/Auth'); if (!class_exists($className)) { throw new CakeException(sprintf('Password hasher class "%s" was not found.', $class)); } if (!is_subclass_of($className, 'AbstractPasswordHasher')) { throw new CakeException('Password hasher must extend AbstractPasswordHasher class.'); } return new $className($config); }