Implementing a Query Container

Edit on GitHub

To create a new Query Container you can copy and paste the following snippet and replace MyBundle with your module name.

<?php
namespace Pyz\Zed\MyBundle\Persistence;

use Spryker\Zed\Kernel\Persistence\AbstractQueryContainer;

/**
 * @method MyBundlePersistenceFactory getFactory()
 */
class MyBundleQueryContainer extends AbstractQueryContainer implements MyBundleQueryContainerInterface
{
}

Conventions for Query Containers

There are some conventions which should be followed here:

  • All methods have the prefix query*().
  • All public methods are exposed in the related interface (e.g. MyBundleQueryContainerInterface).
  • Queries are returned unterminated, so that the user can add restrictions (limit, offset) and can choose how to terminate (count(), find(), findAll()).
  • Query containers do not access higher layers. So no usage of a facade here.
  • Query containers do not contain any logic which is not needed to build queries.