ConcatHandler.php 1012 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Indexer\Handler;
  7. use Magento\Framework\Indexer\HandlerInterface;
  8. use Magento\Framework\App\ResourceConnection\SourceProviderInterface;
  9. class ConcatHandler implements HandlerInterface
  10. {
  11. /**
  12. * @var \Magento\Framework\DB\ConcatExpression
  13. */
  14. protected $concatExpression;
  15. /**
  16. * @param \Zend_Db_Expr $concatExpression
  17. */
  18. public function __construct(
  19. \Zend_Db_Expr $concatExpression
  20. ) {
  21. $this->concatExpression = $concatExpression;
  22. }
  23. /**
  24. * Prepare SQL for field and add it to collection
  25. *
  26. * @param SourceProviderInterface $source
  27. * @param string $alias
  28. * @param array $fieldInfo
  29. * @return void
  30. */
  31. public function prepareSql(SourceProviderInterface $source, $alias, $fieldInfo)
  32. {
  33. $source->getSelect()->columns([$fieldInfo['name'] => $this->concatExpression]);
  34. }
  35. }