diff --git a/lib/Byng/Pimcore/Elasticsearch/ElasticsearchPlugin.php b/lib/Byng/Pimcore/Elasticsearch/ElasticsearchPlugin.php index e5c6f66..25c94ed 100644 --- a/lib/Byng/Pimcore/Elasticsearch/ElasticsearchPlugin.php +++ b/lib/Byng/Pimcore/Elasticsearch/ElasticsearchPlugin.php @@ -82,6 +82,18 @@ public static function install() if (self::isInstalled()) { return true; } + $configPath = new ConfigFilePath(); + + if (!is_writable($configPath->getDirectory())) { + throw new \RuntimeException(sprintf( + "Unable to write to config directory: '%s'", + $configPath->getDirectory() + )); + } + + if (!copy(new ConfigDistFilePath(), $configPath)) { + throw new \RuntimeException("Unable to create a config file: " . $configPath); + } $config = self::loadConfig(); @@ -102,21 +114,21 @@ public static function install() } $client->indices()->putMapping($indexParams + [ - "type" => $assetConfig->get("typeName"), - "body" => [ - "asset" => [ - "properties" => [ - $assetConfig->get("typeName") => [ - "properties" => [ - $assetConfig->get("bodyContent")->get("propertyName") => [ - "type" => "attachment" + "type" => $assetConfig->get("typeName"), + "body" => [ + "asset" => [ + "properties" => [ + $assetConfig->get("typeName") => [ + "properties" => [ + $assetConfig->get("bodyContent")->get("propertyName") => [ + "type" => "attachment" + ] ] ] ] ] ] - ] - ]); + ]); } /** @var Zend_Config $pageConfig */ @@ -131,20 +143,7 @@ public static function install() } } - $configPath = new ConfigFilePath(); - - if (!is_writable($configPath->getDirectory())) { - throw new \RuntimeException(sprintf( - "Unable to write to config directory: '%s'", - $configPath->getDirectory() - )); - } - - if (copy(new ConfigDistFilePath(), $configPath)) { - return true; - } - - throw new \RuntimeException("Unable to create a config file: " . $configPath); + return true; } /**