toArray(); } $this->setAdapter($options); } /** * Returns the name of the set adapter * * @return string */ public function getAdapter() { return $this->_adapter->toString(); } /** * Sets new encryption options * * @param string|array $options (Optional) Encryption options * @return Zend_Filter_Encrypt */ public function setAdapter($options = null) { if (is_string($options)) { $adapter = $options; } else if (isset($options['adapter'])) { $adapter = $options['adapter']; unset($options['adapter']); } else { $adapter = 'Mcrypt'; } if (!is_array($options)) { $options = array(); } if (Zend_Loader::isReadable('Zend/Filter/Encrypt/' . ucfirst($adapter). '.php')) { $adapter = 'Zend_Filter_Encrypt_' . ucfirst($adapter); } if (!class_exists($adapter)) { Zend_Loader::loadClass($adapter); } $this->_adapter = new $adapter($options); if (!$this->_adapter instanceof Zend_Filter_Encrypt_Interface) { #require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("Encoding adapter '" . $adapter . "' does not implement Zend_Filter_Encrypt_Interface"); } return $this; } /** * Calls adapter methods * * @param string $method Method to call * @param string|array $options Options for this method */ public function __call($method, $options) { $part = substr($method, 0, 3); if ((($part != 'get') and ($part != 'set')) or !method_exists($this->_adapter, $method)) { #require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception("Unknown method '{$method}'"); } return call_user_func_array(array($this->_adapter, $method), $options); } /** * Defined by Zend_Filter_Interface * * Encrypts the content $value with the defined settings * * @param string $value Content to encrypt * @return string The encrypted content */ public function filter($value) { return $this->_adapter->encrypt($value); } }