{"action":"created","issue":{"url":"https://api.github.com/repos/zfcampus/zf-content-validation/issues/38","labels_url":"https://api.github.com/repos/zfcampus/zf-content-validation/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/zfcampus/zf-content-validation/issues/38/comments","events_url":"https://api.github.com/repos/zfcampus/zf-content-validation/issues/38/events","html_url":"https://github.com/zfcampus/zf-content-validation/pull/38","id":63817706,"number":38,"title":"Resolves Issue #37 - Allow modification of InputFilter before validation","user":{"login":"steverhoades","id":1146668,"avatar_url":"https://avatars.githubusercontent.com/u/1146668?v=3","gravatar_id":"","url":"https://api.github.com/users/steverhoades","html_url":"https://github.com/steverhoades","followers_url":"https://api.github.com/users/steverhoades/followers","following_url":"https://api.github.com/users/steverhoades/following{/other_user}","gists_url":"https://api.github.com/users/steverhoades/gists{/gist_id}","starred_url":"https://api.github.com/users/steverhoades/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steverhoades/subscriptions","organizations_url":"https://api.github.com/users/steverhoades/orgs","repos_url":"https://api.github.com/users/steverhoades/repos","events_url":"https://api.github.com/users/steverhoades/events{/privacy}","received_events_url":"https://api.github.com/users/steverhoades/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-23T19:55:17Z","updated_at":"2015-03-30T20:19:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/zfcampus/zf-content-validation/pulls/38","html_url":"https://github.com/zfcampus/zf-content-validation/pull/38","diff_url":"https://github.com/zfcampus/zf-content-validation/pull/38.diff","patch_url":"https://github.com/zfcampus/zf-content-validation/pull/38.patch"},"body":"Example Usage:\r\n```\r\nuse Zend\\EventManager\\SharedListenerAggregateInterface;\r\nuse Zend\\Mvc\\MvcEvent;\r\nuse Zend\\Validator\\Db\\NoRecordExists;\r\nuse ZF\\ContentValidation\\ContentValidationListener\r\n\r\nclass SomeValidationListener implements SharedListenerAggregateInterface\r\n{\r\n    public function attachShared(SharedEventManagerInterface $events)\r\n    {\r\n        // trigger after authentication/authorization and content negotiation\r\n        $this->listeners[] = $events->attach(\r\n            'ZF\\ContentValidation\\ContentValidationListener',\r\n            ZFValidationListener::EVENT_BEFORE_VALIDATE,\r\n            array($this, 'beforeValidate')\r\n        );\r\n    }\r\n\r\n    public function detachShared(SharedEventManagerInterface $events)\r\n    {\r\n        foreach ($this->listeners as $index => $callback) {\r\n            if ($events->detach($callback)) {\r\n                unset($this->listeners[$index]);\r\n            }\r\n        }\r\n    }\r\n\r\n    public function beforeValidate(MvcEvent $e)\r\n    {\r\n        if($e->getRequest()->getMethod() !== 'PUT') {\r\n            return;\r\n        }\r\n\r\n        $matches = $e->getRouteMatch();\r\n        $controller = $matches->getParam('controller', false);\r\n\r\n        $inputFilter = $e->getParam('ZF\\ContentValidation\\InputFilter', false);\r\n        if (! $inputFilter) {\r\n            return;\r\n        }\r\n\r\n        // look for controllers of interest.\r\n        switch($controller) {\r\n            case 'CompanyAdmin\\V1\\Rest\\Users\\Controller':\r\n                $id = $matches->getParam('user_id');\r\n                break;\r\n            default:\r\n                return;\r\n        }\r\n\r\n        $input = $inputFilter->get('username');\r\n        $chain = $input->getValidatorChain();\r\n\r\n        foreach ($chain->getValidators() as $validator) {\r\n            if (! $validator['instance'] instanceof NoRecordExists) {\r\n                continue;\r\n            }\r\n\r\n            $validator['instance']->setExclude(array(\r\n                'field' => 'id',\r\n                'value' => $id,\r\n            ));\r\n            break;\r\n        }\r\n    }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/zfcampus/zf-content-validation/issues/comments/87817435","html_url":"https://github.com/zfcampus/zf-content-validation/pull/38#issuecomment-87817435","issue_url":"https://api.github.com/repos/zfcampus/zf-content-validation/issues/38","id":87817435,"user":{"login":"weierophinney","id":25943,"avatar_url":"https://avatars.githubusercontent.com/u/25943?v=3","gravatar_id":"","url":"https://api.github.com/users/weierophinney","html_url":"https://github.com/weierophinney","followers_url":"https://api.github.com/users/weierophinney/followers","following_url":"https://api.github.com/users/weierophinney/following{/other_user}","gists_url":"https://api.github.com/users/weierophinney/gists{/gist_id}","starred_url":"https://api.github.com/users/weierophinney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weierophinney/subscriptions","organizations_url":"https://api.github.com/users/weierophinney/orgs","repos_url":"https://api.github.com/users/weierophinney/repos","events_url":"https://api.github.com/users/weierophinney/events{/privacy}","received_events_url":"https://api.github.com/users/weierophinney/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T20:19:07Z","updated_at":"2015-03-30T20:19:07Z","body":"Cool feature! Can you please add unit tests, @steverhoades ? (feature freeze for 1.1 is late this week)"}}