public function setForResource($resource, $classOrCallableOrInstance)
    {

        // short this awful long name...
        $factory = $classOrCallableOrInstance;

        $resourceName = $this->resourceName($resource);

        if ($factory instanceof ValidatorContract) {
            $this->resourceFactories[$resourceName] = function () use ($factory) {
                return clone $factory; // Always return a fresh instance
            };
            return $this;
        }

        if (is_callable($factory)) {
            $this->resourceFactories[$resourceName] = $factory;
            return $this;
        }

        if (is_string($factory)) {
            $this->resourceFactories[$resourceName] = function () use ($factory) {
                return $this->createObject($factory);
            };
            return $this;
        }

        throw new InvalidArgumentException('You can pass a classname, callable or Validator');
    }
public function setForResource($resource, $classOrCallableOrInstance)
    {

        // short this awful long name...
        $factory = $classOrCallableOrInstance;

        $resourceName = $this->resourceName($resource);

        if ($factory instanceof ValidatorContract) {
            $this->resourceFactories[$resourceName] = function () use ($factory) {
                return clone $factory; // Always return a fresh instance
            };
            return $this;
        }

        if (is_callable($factory)) {
            $this->resourceFactories[$resourceName] = $factory;
            return $this;
        }

        if (is_string($factory)) {
            $this->resourceFactories[$resourceName] = function () use ($factory) {
                return $this->createObject($factory);
            };
            return $this;
        }

        throw new InvalidArgumentException('You can pass a classname, callable or Validator');
    }
public function setForResource ( $ resource , $ classOrCallableOrInstance ) { // short this awful long name... $ factory = $ classOrCallableOrInstance ; $ resourceName = $ this -> resourceName ( $ resource ) ; if ( $ factory instanceof ValidatorContract ) { $ this -> resourceFactories [ $ resourceName ] = function ( ) use ( $ factory ) { return clone $ factory ; // Always return a fresh instance } ; return $ this ; } if ( is_callable ( $ factory ) ) { $ this -> resourceFactories [ $ resourceName ] = $ factory ; return $ this ; } if ( is_string ( $ factory ) ) { $ this -> resourceFactories [ $ resourceName ] = function ( ) use ( $ factory ) { return $ this -> createObject ( $ factory ) ; } ; return $ this ; } throw new InvalidArgumentException ( 'You can pass a classname, callable or Validator' ) ; }
Set a custom validator for one resource name.
The assigned validator is used for the resource instead of all others in
the chain.

@param string|AppliesToResource          $resource
@param string|ValidatorContract|callable $classOrCallableOrInstance

@return self
Set a custom validator for one resource name . The assigned validator is used for the resource instead of all others in the chain .