Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "~4.2",
"illuminate/database": "~4.2",
"illuminate/console": "~4.2",
"illuminate/support": "~5.0",
"illuminate/database": "~5.0",
"illuminate/console": "~5.0",
"doctrine/dbal": "~2.3",
"elasticsearch/elasticsearch": "~1.0",
"nikic/php-parser": "*"
Expand Down
7 changes: 4 additions & 3 deletions src/Iverberk/Larasearch/Commands/PathsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,14 @@ private function writeConfig()
{
if ($this->option('write-config'))
{
$configDir = app_path() . '/config/packages/iverberk/larasearch';
$configFile = base_path() . '/config/larasearch.php';
$configDir = base_path() . '/config';

if (!File::exists($configDir))
if (!File::exists($configFile))
{
if ($this->confirm('It appears that you have not yet published the larasearch config. Would you like to do this now?', false))
{
$this->call('config:publish', ['package' => 'iverberk/larasearch']);
$this->call('vendor:publish', ['package' => 'iverberk/larasearch']);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/Iverberk/Larasearch/Exceptions/ImportException.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ImportException extends Exception {
// Redefine the exception so message isn't optional
public function __construct($message, $code = 0, $errorItems = [])
{
var_dump($errorItems);
// make sure everything is assigned properly
parent::__construct($message, $code);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Iverberk/Larasearch/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function import(Model $model, $relations = [], $batchSize = 750, Callable
*/
public function setName($name)
{
$index_prefix = Config::get('larasearch::elasticsearch.index_prefix', '');
$index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '');
if ($index_prefix && ! Str::startsWith($name, $index_prefix)) $name = $index_prefix . $name;

$this->name = $name;
Expand Down Expand Up @@ -200,7 +200,7 @@ public function exists()
*/
public function aliasExists($alias)
{
$index_prefix = Config::get('larasearch::elasticsearch.index_prefix', '');
$index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '');
if ($index_prefix && ! Str::startsWith($alias, $index_prefix)) $alias = $index_prefix . $alias;

return self::getClient()->indices()->existsAlias(['name' => $alias]);
Expand Down Expand Up @@ -311,7 +311,7 @@ public function bulk($records)
*/
public static function clean($name)
{
$index_prefix = Config::get('larasearch::elasticsearch.index_prefix', '');
$index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '');
if ($index_prefix && ! Str::startsWith($name, $index_prefix)) $name = $index_prefix . $name;

$indices = self::getClient()->indices()->getAliases();
Expand All @@ -332,7 +332,7 @@ public static function clean($name)
*/
public static function getAlias($name)
{
$index_prefix = Config::get('larasearch::elasticsearch.index_prefix', '');
$index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '');
if ($index_prefix && ! Str::startsWith($name, $index_prefix)) $name = $index_prefix . $name;

return self::getClient()->indices()->getAlias(['name' => $name]);
Expand All @@ -344,7 +344,7 @@ public static function getAlias($name)
*/
public static function updateAliases(array $actions)
{
if (isset($actions['actions']) && ($index_prefix = Config::get('larasearch::elasticsearch.index_prefix', '')))
if (isset($actions['actions']) && ($index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '')))
{
foreach ($actions['actions'] as &$action)
{
Expand All @@ -365,7 +365,7 @@ public static function updateAliases(array $actions)
*/
public static function refresh($index)
{
$index_prefix = Config::get('larasearch::elasticsearch.index_prefix', '');
$index_prefix = Config::get('larasearch.elasticsearch.index_prefix', '');
if ($index_prefix && ! Str::startsWith($index, $index_prefix)) $index = $index_prefix . $index;

return self::getClient()->indices()->refresh(['index' => $index]);
Expand All @@ -378,8 +378,8 @@ public static function refresh($index)
*/
private function getDefaultIndexParams()
{
$analyzers = Config::get('larasearch::elasticsearch.analyzers');
$params = Config::get('larasearch::elasticsearch.defaults.index');
$analyzers = Config::get('larasearch.elasticsearch.analyzers');
$params = Config::get('larasearch.elasticsearch.defaults.index');
$mapping = [];

$mapping_options = array_combine(
Expand Down
18 changes: 16 additions & 2 deletions src/Iverberk/Larasearch/LarasearchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Iverberk\Larasearch\Response\Result;
use Monolog\Handler\NullHandler;
use Monolog\Logger;
use ReflectionClass;

class LarasearchServiceProvider extends ServiceProvider {

Expand All @@ -19,7 +20,9 @@ class LarasearchServiceProvider extends ServiceProvider {

public function boot()
{
$this->package('iverberk/larasearch');
$this->publishes([
$this->guessPackagePath() . '/config/config.php' => config_path('larasearch.php'),
]);

$this->bootContainerBindings();
}
Expand Down Expand Up @@ -57,7 +60,7 @@ protected function bindElasticsearch()
{
$this->app->singleton('Elasticsearch', function ($app)
{
return new Client($app->make('config')->get('larasearch::elasticsearch.params'));
return new Client($app->make('config')->get('larasearch.elasticsearch.params'));
});
}

Expand Down Expand Up @@ -148,4 +151,15 @@ public function provides()
return array();
}

/**
* Guess real path of the package.
*
* @return string
*/
public function guessPackagePath()
{
$path = (new ReflectionClass($this))->getFileName();

return realpath(dirname($path).'/../..');
}
}
2 changes: 1 addition & 1 deletion src/Iverberk/Larasearch/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function findAffectedModels(Model $model, $excludeCurrent = false)
// Temporary array to store affected models
$affectedModels = [];

$paths = Config::get('larasearch::reversedPaths.' . get_class($model), []);
$paths = Config::get('larasearch.reversedPaths.' . get_class($model), []);

foreach ((array)$paths as $path)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Iverberk/Larasearch/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function reindex($relations = false, $batchSize = 750, $mapping = [], Cal
$name = $this->config['index']->getName();

$newName = $name . '_' . date("YmdHis");
$relations = $relations ? Config::get('larasearch::paths.' . get_class($model)) : [];
$relations = $relations ? Config::get('larasearch.paths.' . get_class($model)) : [];

Index::clean($name);

Expand Down
4 changes: 2 additions & 2 deletions src/Iverberk/Larasearch/Response/Result.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php namespace Iverberk\Larasearch\Response;

use Illuminate\Support\Contracts\ArrayableInterface;
use Illuminate\Contracts\Support\Arrayable;

class Result implements \ArrayAccess, ArrayableInterface {
class Result implements \ArrayAccess, Arrayable {

/**
* Contains an Elasticsearch hit response
Expand Down
2 changes: 1 addition & 1 deletion src/Iverberk/Larasearch/Traits/TransformableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait TransformableTrait {
*/
public function transform($relations = false)
{
$relations = $relations ? Config::get('larasearch::paths.' . get_class($this)) : [];
$relations = $relations ? Config::get('larasearch.paths.' . get_class($this)) : [];

$doc = $this->load($relations)->toArray();

Expand Down