original_string: public function loadModel($modelClass = null, $modelType = null)
      {
          if ($modelClass === null) {
              $modelClass = $this->modelClass;
          }
          if ($modelType === null) {
              $modelType = $this->getModelType();
  
              if ($modelType === null) {
                  throw new UnexpectedValueException('No model type has been defined');
              }
          }
  
          list(, $alias) = pluginSplit($modelClass, true);
  
          if (isset($this->{$alias})) {
              return $this->{$alias};
          }
  
          if (isset($this->_modelFactories[$modelType])) {
              $factory = $this->_modelFactories[$modelType];
          }
          if (!isset($factory)) {
              $factory = FactoryLocator::get($modelType);
          }
          $this->{$alias} = $factory($modelClass);
          if (!$this->{$alias}) {
              throw new MissingModelException([$modelClass, $modelType]);
          }
  
          return $this->{$alias};
      }
code: public function loadModel($modelClass = null, $modelType = null)
      {
          if ($modelClass === null) {
              $modelClass = $this->modelClass;
          }
          if ($modelType === null) {
              $modelType = $this->getModelType();
  
              if ($modelType === null) {
                  throw new UnexpectedValueException('No model type has been defined');
              }
          }
  
          list(, $alias) = pluginSplit($modelClass, true);
  
          if (isset($this->{$alias})) {
              return $this->{$alias};
          }
  
          if (isset($this->_modelFactories[$modelType])) {
              $factory = $this->_modelFactories[$modelType];
          }
          if (!isset($factory)) {
              $factory = FactoryLocator::get($modelType);
          }
          $this->{$alias} = $factory($modelClass);
          if (!$this->{$alias}) {
              throw new MissingModelException([$modelClass, $modelType]);
          }
  
          return $this->{$alias};
      }
code_tokens: public function loadModel ( $ modelClass = null , $ modelType = null ) { if ( $ modelClass === null ) { $ modelClass = $ this -> modelClass ; } if ( $ modelType === null ) { $ modelType = $ this -> getModelType ( ) ; if ( $ modelType === null ) { throw new UnexpectedValueException ( 'No model type has been defined' ) ; } } list ( , $ alias ) = pluginSplit ( $ modelClass , true ) ; if ( isset ( $ this -> { $ alias } ) ) { return $ this -> { $ alias } ; } if ( isset ( $ this -> _modelFactories [ $ modelType ] ) ) { $ factory = $ this -> _modelFactories [ $ modelType ] ; } if ( ! isset ( $ factory ) ) { $ factory = FactoryLocator :: get ( $ modelType ) ; } $ this -> { $ alias } = $ factory ( $ modelClass ) ; if ( ! $ this -> { $ alias } ) { throw new MissingModelException ( [ $ modelClass , $ modelType ] ) ; } return $ this -> { $ alias } ; }
docstring: Loads and constructs repository objects required by this object
  
  Typically used to load ORM Table objects as required. Can
  also be used to load other types of repository objects your application uses.
  
  If a repository provider does not return an object a MissingModelException will
  be thrown.
  
  @param string|null $modelClass Name of model class to load. Defaults to $this->modelClass
  @param string|null $modelType The type of repository to load. Defaults to the modelType() value.
  @return \Cake\Datasource\RepositoryInterface The model instance created.
  @throws \Cake\Datasource\Exception\MissingModelException If the model class cannot be found.
  @throws \InvalidArgumentException When using a type that has not been registered.
  @throws \UnexpectedValueException If no model type has been defined
docstring_tokens: Loads and constructs repository objects required by this object