[SearchEngine] Add code documentation

This commit is contained in:
Romain Neutron
2012-10-30 16:17:48 +01:00
parent ca29ab9f86
commit 5be95d55fc
11 changed files with 436 additions and 52 deletions

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2012 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\SearchEngine\SphinxSearch;
use Alchemy\Phrasea\SearchEngine\AbstractConfigurationPanel;
@@ -19,11 +28,17 @@ class ConfigurationPanel extends AbstractConfigurationPanel
$this->searchEngine = $engine;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'sphinx-search';
}
/**
* {@inheritdoc}
*/
public function get(Application $app, Request $request)
{
$configuration = $this->getConfiguration();
@@ -38,6 +53,9 @@ class ConfigurationPanel extends AbstractConfigurationPanel
return $app['twig']->render('admin/search-engine/sphinx-search.html.twig', $params);
}
/**
* {@inheritdoc}
*/
public function post(Application $app, Request $request)
{
$configuration = $this->getConfiguration();
@@ -61,6 +79,9 @@ class ConfigurationPanel extends AbstractConfigurationPanel
return $app->redirect($app['url_generator']->generate('admin_searchengine_get'));
}
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
$configuration = @json_decode(file_get_contents($this->getConfigPathFile()), true);
@@ -96,6 +117,9 @@ class ConfigurationPanel extends AbstractConfigurationPanel
return $configuration;
}
/**
* {@inheritdoc}
*/
public function saveConfiguration(array $configuration)
{
file_put_contents($this->getConfigPathFile(), json_encode($configuration));
@@ -103,6 +127,11 @@ class ConfigurationPanel extends AbstractConfigurationPanel
return $this;
}
/**
* Returns all the charset Sphinx Search supports
*
* @return array An array of charsets
*/
public function getAvailableCharsets()
{
if (null !== $this->charsets) {
@@ -127,6 +156,13 @@ class ConfigurationPanel extends AbstractConfigurationPanel
return $this->charsets;
}
/**
* Generates Sphinx Search configuration depending on the service configuration
*
* @param array $databoxes The databoxes to index
* @param array $configuration The configuration
* @return string The sphinx search configuration
*/
public function generateSphinxConf(array $databoxes, array $configuration)
{
$defaults = array(