StateKey.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\CatalogSearch\Model\Layer\Search;
  8. use Magento\Catalog\Model\Layer\StateKeyInterface;
  9. /**
  10. * Catalog search state key for layered navigation.
  11. */
  12. class StateKey extends \Magento\Catalog\Model\Layer\Category\StateKey implements StateKeyInterface
  13. {
  14. /**
  15. * @var \Magento\Search\Model\QueryFactory
  16. */
  17. protected $queryFactory;
  18. /**
  19. * @param \Magento\Store\Model\StoreManagerInterface $storeManager
  20. * @param \Magento\Customer\Model\Session $customerSession
  21. * @param \Magento\Search\Model\QueryFactory $queryFactory
  22. */
  23. public function __construct(
  24. \Magento\Store\Model\StoreManagerInterface $storeManager,
  25. \Magento\Customer\Model\Session $customerSession,
  26. \Magento\Search\Model\QueryFactory $queryFactory
  27. ) {
  28. $this->queryFactory = $queryFactory;
  29. parent::__construct($storeManager, $customerSession);
  30. }
  31. /**
  32. * @inheritdoc
  33. */
  34. public function toString($category)
  35. {
  36. return 'Q_' . $this->queryFactory->get()->getId()
  37. . '_' . \Magento\Catalog\Model\Layer\Category\StateKey::toString($category);
  38. }
  39. }