Skip to content

Commit

Permalink
Pass customAttributes along to parent constructor for validation (sun…
Browse files Browse the repository at this point in the history
…spikes#12)

* Pass customAttributes along to parent constructor for validation

* Added missing use statement

* Renamed variable per sunspikes request.
Defaulted additional parameter to an array for backwards compatibility.
  • Loading branch information
Levivb authored and sunspikes committed Jul 9, 2018
1 parent d52c441 commit 4a4a681
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
21 changes: 17 additions & 4 deletions src/ClamavValidator/ClamavValidator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Sunspikes\ClamavValidator;

use Illuminate\Contracts\Translation\Translator;
use Illuminate\Validation\Validator;
use Xenolope\Quahog\Client;
use Socket\Raw\Factory;
Expand Down Expand Up @@ -33,11 +34,23 @@ class ClamavValidator extends Validator
const CLAMAV_SOCKET_READ_TIMEOUT = 30;

/**
* Creates a new instance of ClamavValidator
* Creates a new instance of ClamavValidator]
*
* ClamavValidator constructor.
* @param Translator $translator
* @param array $data
* @param array $rules
* @param array $messages
* @param array $customAttributes
*/
public function __construct($translator, $data, $rules, $messages)
{
parent::__construct($translator, $data, $rules, $messages);
public function __construct(
Translator $translator,
array $data,
array $rules,
array $messages = [],
array $customAttributes = []
) {
parent::__construct($translator, $data, $rules, $messages, $customAttributes);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/ClamavValidator/ClamavValidatorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ public function boot()
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'clamav-validator');

$this->app['validator']
->resolver(function ($translator, $data, $rules, $messages) {
->resolver(function ($translator, $data, $rules, $messages, $customAttributes = []) {
return new ClamavValidator(
$translator,
$data,
$rules,
$messages
$messages,
$customAttributes
);
});

Expand Down

0 comments on commit 4a4a681

Please sign in to comment.