protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        //check if the query is retrieving a unique entity
        //if yes check if we already have the entity in the
        //repository or not
        $key = $context->query->getKey();
        if ($key) {
            $context->data = $this->find($key, false);
            if ($context->data) {
                return false;
            }
        }
    }
protected function _beforeRepositoryFetch(AnCommandContext $context)
    {
        //check if the query is retrieving a unique entity
        //if yes check if we already have the entity in the
        //repository or not
        $key = $context->query->getKey();
        if ($key) {
            $context->data = $this->find($key, false);
            if ($context->data) {
                return false;
            }
        }
    }
protected function _beforeRepositoryFetch ( AnCommandContext $ context ) { //check if the query is retrieving a unique entity //if yes check if we already have the entity in the //repository or not $ key = $ context -> query -> getKey ( ) ; if ( $ key ) { $ context -> data = $ this -> find ( $ key , false ) ; if ( $ context -> data ) { return false ; } } }
If a query is unique then repository tries to search existing entities.

@param AnCommandContext $context Context

@return bool
If a query is unique then repository tries to search existing entities .