public function forEntity($entityClass, DataMapperInterface $dataMapper = null)
    {
        if (empty($dataMapper)) {
            try {
                $dataMapper = $this->unitOfWork->getDataMapper($entityClass);
            } catch (\RuntimeException $e) {
                $dataMapper = $this->createDataMapper($entityClass);
            }
        }

        return new Repository($entityClass, $dataMapper, $this->unitOfWork);
    }
public function forEntity($entityClass, DataMapperInterface $dataMapper = null)
    {
        if (empty($dataMapper)) {
            try {
                $dataMapper = $this->unitOfWork->getDataMapper($entityClass);
            } catch (\RuntimeException $e) {
                $dataMapper = $this->createDataMapper($entityClass);
            }
        }

        return new Repository($entityClass, $dataMapper, $this->unitOfWork);
    }
public function forEntity ( $ entityClass , DataMapperInterface $ dataMapper = null ) { if ( empty ( $ dataMapper ) ) { try { $ dataMapper = $ this -> unitOfWork -> getDataMapper ( $ entityClass ) ; } catch ( \ RuntimeException $ e ) { $ dataMapper = $ this -> createDataMapper ( $ entityClass ) ; } } return new Repository ( $ entityClass , $ dataMapper , $ this -> unitOfWork ) ; }
Gets a repository for an entity class.

The Repository is created on first call. Any subsequent call will return the same instance, so the DataMapper
can not be exchanged afterwards.

On creation, the Repository gets supplied with the provided DataMapper. If data mapper is omitted, looks for
a DataMapper for the given entity class registered to the UnitOfWork. If that fails, too, a new DataMapper is
created using the information from the configuration.

@api

@param   string              $entityClass The Entity's class
@param   DataMapperInterface $dataMapper  An optional DataMapper

@return  RepositoryInterface
Gets a repository for an entity class .