Skip to content

Instantly share code, notes, and snippets.

@pspanja
Last active February 9, 2017 08:20
Show Gist options
  • Save pspanja/759ae8c836740932c03605696271a4ba to your computer and use it in GitHub Desktop.
Save pspanja/759ae8c836740932c03605696271a4ba to your computer and use it in GitHub Desktop.
RepositoryDomainMapperFactory for additional SearchService with Legacy search engine
<?php
namespace ClientName\Bundle\ProjectBundle\ApiLoader;
use eZ\Publish\Core\Base\Container\ApiLoader\FieldTypeCollectionFactory;
use eZ\Publish\Core\Repository\Helper\DomainMapper;
use eZ\Publish\Core\Repository\Helper\FieldTypeRegistry;
use eZ\Publish\SPI\Persistence;
use Symfony\Component\DependencyInjection\ContainerAware;
class RepositoryDomainMapperFactory extends ContainerAware
{
/**
* @var \eZ\Publish\SPI\Persistence\Content\Handler
*/
protected $contentHandler;
/**
* @var \eZ\Publish\SPI\Persistence\Content\Location\Handler
*/
protected $locationHandler;
/**
* @var \eZ\Publish\SPI\Persistence\Content\Type\Handler
*/
protected $contentTypeHandler;
/**
* @var \eZ\Publish\SPI\Persistence\Content\Language\Handler
*/
protected $contentLanguageHandler;
/**
* @var \eZ\Publish\Core\Base\Container\ApiLoader\FieldTypeCollectionFactory
*/
protected $fieldTypeCollectionFactory;
/**
* @param \eZ\Publish\SPI\Persistence\Content\Handler $contentHandler
* @param \eZ\Publish\SPI\Persistence\Content\Location\Handler $locationHandler
* @param \eZ\Publish\SPI\Persistence\Content\Type\Handler $contentTypeHandler
* @param \eZ\Publish\SPI\Persistence\Content\Language\Handler $contentLanguageHandler
* @param \eZ\Publish\Core\Base\Container\ApiLoader\FieldTypeCollectionFactory $fieldTypeCollectionFactory
*/
public function __construct(
Persistence\Content\Handler $contentHandler,
Persistence\Content\Location\Handler $locationHandler,
Persistence\Content\Type\Handler $contentTypeHandler,
Persistence\Content\Language\Handler $contentLanguageHandler,
FieldTypeCollectionFactory $fieldTypeCollectionFactory
) {
$this->contentHandler = $contentHandler;
$this->locationHandler = $locationHandler;
$this->contentTypeHandler = $contentTypeHandler;
$this->contentLanguageHandler = $contentLanguageHandler;
$this->fieldTypeCollectionFactory = $fieldTypeCollectionFactory;
}
/**
* @return \eZ\Publish\Core\Repository\Helper\DomainMapper
*/
public function buildService()
{
return new DomainMapper(
$this->contentHandler,
$this->locationHandler,
$this->contentTypeHandler,
$this->contentLanguageHandler,
new FieldTypeRegistry(
$this->fieldTypeCollectionFactory->getFieldTypes()
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment