Skip to content

Commit

Permalink
Merge branch '5.0'
Browse files Browse the repository at this point in the history
* 5.0:
  update changelog
  [KunstmaanNodeSearchBundle] use hosts in useVersion6 check (#2075)
  [MediaBundle] add return to load function (#2076)
  [MenuBundle] Fix menu item sorting issue with multiple menus (#2072)
  • Loading branch information
Devolicious committed Aug 21, 2018
2 parents 0585db0 + 9f31937 commit d16be7e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG-5.X.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 5.0.9 / 2018-08-21

* [MediaBundle] add return to load function [#2076](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2076) ([@bakie](https://github.com/bakie))
* [KunstmaanNodeSearchBundle] use hosts in useVersion6 check [#2075](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2075) ([@bakie](https://github.com/bakie))
* [MenuBundle] Fix menu item sorting issue with multiple menus [#2072](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2072) ([@acrobat](https://github.com/acrobat))


## 5.0.8 / 2018-08-07

* [AdminList] Fix admin list empty url [#2071](https://github.com/Kunstmaan/KunstmaanBundlesCMS/pull/2071) ([@dannyvw](https://github.com/dannyvw))
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"white-october/pagerfanta-bundle": "~1.0",
"kunstmaan/google-api-custom": "~1.0",
"ddeboer/data-import-bundle": "~0.1",
"gedmo/doctrine-extensions": "~2.3",
"gedmo/doctrine-extensions": "^2.4.34",
"doctrine/doctrine-fixtures-bundle": "~2.2",
"stof/doctrine-extensions-bundle": "~1.1",
"liip/imagine-bundle": "~1.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class BackgroundFilterLoader extends \Liip\ImagineBundle\Imagine\Filter\Loader\B
*/
public function load(ImageInterface $image, array $options = array())
{
parent::load($image, $options);
return parent::load($image, $options);
}
}
1 change: 1 addition & 0 deletions src/Kunstmaan/MenuBundle/Entity/BaseMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ abstract class BaseMenuItem extends AbstractEntity
* @ORM\ManyToOne(targetEntity="Kunstmaan\MenuBundle\Entity\Menu", inversedBy="items")
* @ORM\JoinColumn(name="menu_id", referencedColumnName="id")
* @Assert\NotNull()
* @Gedmo\TreeRoot(identifierMethod="getMenu")
*/
protected $menu;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* @var bool
*/
private $useElasticSearchVersion6;


/**
* Configuration constructor.
* @param bool $useElasticSearchVersion6
*/
public function __construct($useElasticSearchVersion6)
{
$this->useElasticSearchVersion6 = $useElasticSearchVersion6;
}

/**
* {@inheritDoc}
*/
Expand All @@ -36,13 +51,13 @@ public function getConfigTreeBuilder()
'boolean',
'binary',
];
if (!ElasticSearchUtil::useVersion6()) {
if (!$this->useElasticSearchVersion6) {
$types[] = 'string';
}

$properties->children()->scalarNode('type')->beforeNormalization()->ifNotInArray($types)->thenInvalid('type must be one of: ' . implode(', ', $types));

if (ElasticSearchUtil::useVersion6()) {
if ($this->useElasticSearchVersion6) {
$properties->children()->booleanNode('fielddata');
$properties->children()->booleanNode('doc_values');
$properties->children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
*/
class KunstmaanNodeSearchExtension extends Extension implements PrependExtensionInterface
{
/**
* @var bool
*/
private $useElasticSearchVersion6;

/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$configuration = new Configuration($this->useElasticSearchVersion6);
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
Expand Down Expand Up @@ -49,7 +54,9 @@ public function load(array $configs, ContainerBuilder $container)
*/
public function prepend(ContainerBuilder $container)
{
if (ElasticSearchUtil::useVersion6()) {
$this->useElasticSearchVersion6 = ElasticSearchUtil::useVersion6(array($container->getParameter('kunstmaan_search.hostname').':'.$container->getParameter('searchport')));

if ($this->useElasticSearchVersion6) {
$mapping = [
'mapping' => [
'root_id' => [
Expand Down
12 changes: 8 additions & 4 deletions src/Kunstmaan/NodeSearchBundle/Helper/ElasticSearchUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ final class ElasticSearchUtil
private static $esClientInfo;

/**
* @var array $hosts
*
* @return bool
*/
public static function useVersion6()
public static function useVersion6($hosts = array())
{
if (PHP_MAJOR_VERSION < 7) {
return false;
}

$info = self::getESVersionInfo();
$info = self::getESVersionInfo($hosts);

if (null !== $info) {
$versionParts = explode('.', $info['version']['number']);
Expand All @@ -35,13 +37,15 @@ public static function useVersion6()
}

/**
* @var array $hosts
*
* @return array
*/
private static function getESVersionInfo()
private static function getESVersionInfo($hosts)
{
try {
if (null === self::$esClientInfo) {
$client = ClientBuilder::create()->build();
$client = ClientBuilder::create()->setHosts($hosts)->build();
self::$esClientInfo = $client->info();
}
} catch (NoNodesAvailableException $e) {
Expand Down

0 comments on commit d16be7e

Please sign in to comment.