protected function _getValidator($parts)
    {
        $keyParts = array_filter(array_slice($parts, 0, -1), function ($part) {
            return !is_numeric($part);
        });
        $key = implode('.', $keyParts);
        $entity = $this->entity($parts) ?: null;

        if (isset($this->_validator[$key])) {
            $this->_validator[$key]->setProvider('entity', $entity);

            return $this->_validator[$key];
        }

        $table = $this->_getTable($parts);
        $alias = $table->getAlias();

        $method = 'default';
        if (is_string($this->_context['validator'])) {
            $method = $this->_context['validator'];
        } elseif (isset($this->_context['validator'][$alias])) {
            $method = $this->_context['validator'][$alias];
        }

        $validator = $table->getValidator($method);
        $validator->setProvider('entity', $entity);

        return $this->_validator[$key] = $validator;
    }
protected function _getValidator($parts)
    {
        $keyParts = array_filter(array_slice($parts, 0, -1), function ($part) {
            return !is_numeric($part);
        });
        $key = implode('.', $keyParts);
        $entity = $this->entity($parts) ?: null;

        if (isset($this->_validator[$key])) {
            $this->_validator[$key]->setProvider('entity', $entity);

            return $this->_validator[$key];
        }

        $table = $this->_getTable($parts);
        $alias = $table->getAlias();

        $method = 'default';
        if (is_string($this->_context['validator'])) {
            $method = $this->_context['validator'];
        } elseif (isset($this->_context['validator'][$alias])) {
            $method = $this->_context['validator'][$alias];
        }

        $validator = $table->getValidator($method);
        $validator->setProvider('entity', $entity);

        return $this->_validator[$key] = $validator;
    }
protected function _getValidator ( $ parts ) { $ keyParts = array_filter ( array_slice ( $ parts , 0 , - 1 ) , function ( $ part ) { return ! is_numeric ( $ part ) ; } ) ; $ key = implode ( '.' , $ keyParts ) ; $ entity = $ this -> entity ( $ parts ) ? : null ; if ( isset ( $ this -> _validator [ $ key ] ) ) { $ this -> _validator [ $ key ] -> setProvider ( 'entity' , $ entity ) ; return $ this -> _validator [ $ key ] ; } $ table = $ this -> _getTable ( $ parts ) ; $ alias = $ table -> getAlias ( ) ; $ method = 'default' ; if ( is_string ( $ this -> _context [ 'validator' ] ) ) { $ method = $ this -> _context [ 'validator' ] ; } elseif ( isset ( $ this -> _context [ 'validator' ] [ $ alias ] ) ) { $ method = $ this -> _context [ 'validator' ] [ $ alias ] ; } $ validator = $ table -> getValidator ( $ method ) ; $ validator -> setProvider ( 'entity' , $ entity ) ; return $ this -> _validator [ $ key ] = $ validator ; }
Get the validator associated to an entity based on naming
conventions.

@param array $parts Each one of the parts in a path for a field name
@return \Cake\Validation\Validator
Get the validator associated to an entity based on naming conventions .