original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Get the validator associated to an entity based on naming conventions .