Controllers are usually notIf you want to define a controller, then don't use a static methodsmethod:
namespace Drupal\content_statistics\Controller;
use Drupal\Core\Controller\ControllerBase;
class ContentStatisticsController extends ControllerBase {
public function count() {
$value = $this->t('hi');
return $value;
}
}
The use statement should import the class, not the namespace. CreateBut this is not the only problem.
If you want to use a controller class in a hook, create an instance of the objectcontroller and use the method of that instance:
use Drupal\content_statistics\Controller\ContentStatisticsController
$statistics = new ContentStatistics;ContentStatisticsController;
$value = $statistics->Count>count();
Your class and method havehad the same name, I made themsplit the name in a bit shortercontroller class name and the method count().