original_string: protected function _prepare()
      {
          $table = $this->_context['table'];
          $entity = $this->_context['entity'];
          if (empty($table)) {
              if (is_array($entity) || $entity instanceof Traversable) {
                  foreach ($entity as $e) {
                      $entity = $e;
                      break;
                  }
              }
              $isEntity = $entity instanceof EntityInterface;
  
              if ($isEntity) {
                  $table = $entity->getSource();
              }
              if (!$table && $isEntity && get_class($entity) !== 'Cake\ORM\Entity') {
                  list(, $entityClass) = namespaceSplit(get_class($entity));
                  $table = Inflector::pluralize($entityClass);
              }
          }
          if (is_string($table)) {
              $table = $this->getTableLocator()->get($table);
          }
  
          if (!($table instanceof RepositoryInterface)) {
              throw new RuntimeException(
                  'Unable to find table class for current entity'
              );
          }
          $this->_isCollection = (
              is_array($entity) ||
              $entity instanceof Traversable
          );
  
          $alias = $this->_rootName = $table->getAlias();
          $this->_tables[$alias] = $table;
      }
code: protected function _prepare()
      {
          $table = $this->_context['table'];
          $entity = $this->_context['entity'];
          if (empty($table)) {
              if (is_array($entity) || $entity instanceof Traversable) {
                  foreach ($entity as $e) {
                      $entity = $e;
                      break;
                  }
              }
              $isEntity = $entity instanceof EntityInterface;
  
              if ($isEntity) {
                  $table = $entity->getSource();
              }
              if (!$table && $isEntity && get_class($entity) !== 'Cake\ORM\Entity') {
                  list(, $entityClass) = namespaceSplit(get_class($entity));
                  $table = Inflector::pluralize($entityClass);
              }
          }
          if (is_string($table)) {
              $table = $this->getTableLocator()->get($table);
          }
  
          if (!($table instanceof RepositoryInterface)) {
              throw new RuntimeException(
                  'Unable to find table class for current entity'
              );
          }
          $this->_isCollection = (
              is_array($entity) ||
              $entity instanceof Traversable
          );
  
          $alias = $this->_rootName = $table->getAlias();
          $this->_tables[$alias] = $table;
      }
code_tokens: protected function _prepare ( ) { $ table = $ this -> _context [ 'table' ] ; $ entity = $ this -> _context [ 'entity' ] ; if ( empty ( $ table ) ) { if ( is_array ( $ entity ) || $ entity instanceof Traversable ) { foreach ( $ entity as $ e ) { $ entity = $ e ; break ; } } $ isEntity = $ entity instanceof EntityInterface ; if ( $ isEntity ) { $ table = $ entity -> getSource ( ) ; } if ( ! $ table && $ isEntity && get_class ( $ entity ) !== 'Cake\ORM\Entity' ) { list ( , $ entityClass ) = namespaceSplit ( get_class ( $ entity ) ) ; $ table = Inflector :: pluralize ( $ entityClass ) ; } } if ( is_string ( $ table ) ) { $ table = $ this -> getTableLocator ( ) -> get ( $ table ) ; } if ( ! ( $ table instanceof RepositoryInterface ) ) { throw new RuntimeException ( 'Unable to find table class for current entity' ) ; } $ this -> _isCollection = ( is_array ( $ entity ) || $ entity instanceof Traversable ) ; $ alias = $ this -> _rootName = $ table -> getAlias ( ) ; $ this -> _tables [ $ alias ] = $ table ; }
docstring: Prepare some additional data from the context.
  
  If the table option was provided to the constructor and it
  was a string, TableLocator will be used to get the correct table instance.
  
  If an object is provided as the table option, it will be used as is.
  
  If no table option is provided, the table name will be derived based on
  naming conventions. This inference will work with a number of common objects
  like arrays, Collection objects and ResultSets.
  
  @return void
  @throws \RuntimeException When a table object cannot be located/inferred.
docstring_tokens: Prepare some additional data from the context .