-
-
Save dwolke/a05493557bff31d46dbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace HTMLPurifier\Controller\Plugin; | |
use Zend\Mvc\Controller\Plugin\AbstractPlugin; | |
class Purifier extends AbstractPlugin | |
{ | |
public function __invoke($data) | |
{ | |
$purifier = $this->getController()->getServiceLocator()->get('HTMLPurifier'); | |
if (is_string($data)) { | |
$data = $purifier->purify($data); | |
} else if (is_array($data)) { | |
array_walk_recursive($data, function(&$value, $key) use ($purifier) { | |
$value = $purifier->purify($value); | |
}); | |
} | |
return $data; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple usage scenario. | |
if ($this->request->isPost()) { | |
$post = $this->purify($request->getPost()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment