$num_nodes=$this->database->query("SELECT COUNT(*) FROM {node} WHERE type = :type",array(':type'=>$this->entity->id()))->fetchField();
$num_nodes=$this->queryFactory->get('node')
->condition('type',$this->entity->id())
->count()
->execute();
if($num_nodes){
$caption='<p>'.format_plural($num_nodes,'%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.','%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.',array('%type'=>$this->entity->label())).'</p>';