Skip to content

Commit

Permalink
Made compatible with Omeka 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Nov 17, 2019
1 parent a7ea6e5 commit a901575
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions config/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ author_link = "https://github.com/biblibre"
module_link = "https://github.com/biblibre/omeka-s-module-Solr"
support_link = "https://github.com/biblibre/omeka-s-module-Solr/issues"
configurable = false
version = "3.5.10"
omeka_version_constraint = "^1.2.0"
version = "3.5.10.1"
omeka_version_constraint = "^1.2.0 || ^2.0.0"
23 changes: 13 additions & 10 deletions src/Api/Adapter/SolrMappingAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,25 @@ public function hydrate(Request $request, EntityInterface $entity,

public function buildQuery(QueryBuilder $qb, array $query)
{
$isOldOmeka = \Omeka\Module::VERSION < 2;
$alias = $isOldOmeka ? $this->getEntityClass() : 'omeka_root';
$expr = $qb->expr();

if (isset($query['solr_node_id'])) {
$alias = $this->createAlias();
$qb->innerJoin(
$this->getEntityClass() . '.solrNode',
$alias
);
$qb->andWhere($expr->eq(
$alias . '.id',
$this->createNamedParameter($qb, $query['solr_node_id']))
);
$nodeAlias = $this->createAlias();
$qb
->innerJoin(
$alias . '.solrNode',
$nodeAlias
)
->andWhere($expr->eq(
$nodeAlias . '.id',
$this->createNamedParameter($qb, $query['solr_node_id']))
);
}
if (isset($query['resource_name'])) {
$qb->andWhere($expr->eq(
$this->getEntityClass() . '.resourceName',
$alias . '.resourceName',
$this->createNamedParameter($qb, $query['resource_name'])
));
}
Expand Down

0 comments on commit a901575

Please sign in to comment.