Skip to content

Commit

Permalink
Fixed check of visibility for url with argument "is_public" without v…
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Jan 18, 2021
1 parent 6a398aa commit fbb4687
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/Api/ManagerDelegator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php declare(strict_types=1);

namespace Search\Api;

// use Search\Mvc\Controller\Plugin\ApiSearch;
Expand Down Expand Up @@ -31,20 +32,27 @@ public function search($resource, array $data = [], array $options = [])
// ApiSearch is set static to avoid a loop during init of Api Manager.
/** @var \Search\Mvc\Controller\Plugin\ApiSearch $apiSearch */
static $apiSearch;

// Waiting for fix https://github.com/omeka/omeka-s/pull/1671.
// The same in module AdvancedSearchPlus.
if (isset($data['is_public']) && $data['is_public'] === '') {
$data['is_public'] = null;
}

if (empty($options['index']) && empty($data['index'])) {
return parent::search($resource, $data, $options);
}

if (is_null($apiSearch)) {
$apiSearch = $this->controllerPlugins->get('apiSearch');
}

return $apiSearch($resource, $data, $options);
}

/**
* @param ControllerPluginManager $controllerPlugins
*/
public function setControllerPlugins(ControllerPluginManager $controllerPlugins): void
public function setControllerPlugins(ControllerPluginManager $controllerPlugins)
{
$this->controllerPlugins = $controllerPlugins;
return $this;
}
}
4 changes: 2 additions & 2 deletions src/Service/ApiManagerDelegatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __invoke(ContainerInterface $serviceLocator, $name, callable $ca
// $apiSearch = $serviceLocator->get('ControllerPluginManager')->get('apiSearch');
// $manager->setApiSearch($apiSearch);
$controllerPlugins = $serviceLocator->get('ControllerPluginManager');
$manager->setControllerPlugins($controllerPlugins);
return $manager;
return $manager
->setControllerPlugins($controllerPlugins);
}
}

0 comments on commit fbb4687

Please sign in to comment.