public function __construct($entity, $connection = null)
{
$this->connection = $connection;
if ($entity instanceof DefinitionInterface) {
$this->setEntity($entity->getEntity());
$this->definition = $entity;
} elseif ($entity instanceof ProviderInterface) {
$this->setEntity($entity->getEntity());
$this->provider = $entity;
} else {
$this->setEntity($entity);
}
}