I am building a custom service, a membership service. This service can be called from a controller. But what I don't seem to get working, is to use another service, the QueryFactory, to use in that custom service.
the membership service:
namespace Drupal\hsbxl_members;
use Drupal\Core\Entity\Query\QueryFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class MembershipService.
*/
class MembershipService {
protected $hsbxl_member;
protected $entityQuery;
public function __construct(QueryFactory $entityQuery) {
$this->entity_query = $entity_query;
}
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.query')
);
}
public function MembershipsAll() {
$query = $this->entity_query->get('node');
$query->condition('status', 1);
$nids = $query->execute();
return "Hello World!";
}
}
services file:
services:
hsbxl_members.membership:
class: Drupal\hsbxl_members\MembershipService
arguments: ['@entity.query']
Can anyone point me out on this? What am I doing wrong / am I missing?
Tom