Skip to content

Commit

Permalink
Merge branch '1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Musiał committed Apr 11, 2017
2 parents 331acc6 + 06a6d9e commit d66e56a
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 25 deletions.
9 changes: 6 additions & 3 deletions Client/YooChooseNotifier.php
Expand Up @@ -9,6 +9,7 @@
use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\ContentTypeService;
use eZ\Publish\API\Repository\LocationService;
use Guzzle\Http\Message\Response;
use GuzzleHttp\ClientInterface as GuzzleClient;
use GuzzleHttp\Exception\RequestException;
use InvalidArgumentException;
Expand Down Expand Up @@ -405,9 +406,11 @@ private function notifyGuzzle6(array $events)
)
);

if (isset($this->logger)) {
$this->logger->debug('Got asynchronously ' . $promise->getState() . ' from YooChoose notification POST');
}
$promise->wait();

$promise->then(function (Response $response) {
$this->log(sprintf('Got asynchronously %s from YooChoose notification POST', $response->getStatusCode()), 'debug');
});
}

/**
Expand Down
40 changes: 20 additions & 20 deletions Resources/config/services.yml
Expand Up @@ -39,25 +39,25 @@ services:

# The configured eZ Publish Platform legacy search engine - enable lines below only if you're using legacy bridge.

# ez_recommendation.legacy.search_engine:
# class: ezpSearchEngine
# factory_class: EzSystems\RecommendationBundle\eZ\Publish\LegacySearch\LegacySearchFactory
# factory_method: build
# arguments: ["@ezpublish_legacy.kernel"]

# ez_recommendation.legacy.recommendation_search_engine:
# class: EzSystems\RecommendationBundle\eZ\Publish\LegacySearch\RecommendationLegacySearchEngine
# arguments:
# - "@ez_recommendation.client.yoochoose_notifier"
# - "@ez_recommendation.legacy.search_engine"

# ez_recommendation.legacy.search_configuration_mapper:
# class: EzSystems\RecommendationBundle\eZ\Publish\LegacySearch\ConfigurationMapper
# arguments:
# - "@ez_recommendation.legacy.recommendation_search_engine"
# - "@ezpublish.siteaccess"
# tags:
# - { name: kernel.event_subscriber }
# ez_recommendation.legacy.search_engine:
# class: ezpSearchEngine
# factory_class: EzSystems\RecommendationBundle\eZ\Publish\LegacySearch\LegacySearchFactory
# factory_method: build
# arguments: ["@ezpublish_legacy.kernel"]
#
# ez_recommendation.legacy.recommendation_search_engine:
# class: EzSystems\RecommendationBundle\eZ\Publish\LegacySearch\RecommendationLegacySearchEngine
# arguments:
# - "@ez_recommendation.client.yoochoose_notifier"
# - "@ez_recommendation.legacy.search_engine"
#
# ez_recommendation.legacy.search_configuration_mapper:
# class: EzSystems\RecommendationBundle\eZ\Publish\LegacySearch\ConfigurationMapper
# arguments:
# - "@ez_recommendation.legacy.recommendation_search_engine"
# - "@ezpublish.siteaccess"
# tags:
# - { name: kernel.event_subscriber }

ez_recommendation.twig.extension:
class: "%ez_recommendation.twig.extension.class%"
Expand Down Expand Up @@ -154,6 +154,7 @@ services:
- '@ezpublish.config.resolver.core'
- '@ezpublish.image_alias.imagine.alias_generator'
- '@ezpublish.fieldtype.ezrichtext.converter.output.xhtml5.core'
- "@?ezpublish.fieldtype.ezxmltext.converter.html5"

ez_recommendation.rest.visitor.generator:
class: "%ez_recommendation.rest.visitor.generator.class%"
Expand All @@ -176,4 +177,3 @@ services:
- [setApiEndpoint, ["%ez_recommendation.api_endpoint%"]]
tags:
- { name: ez_recommendation.rest.response_type, type: export }

23 changes: 21 additions & 2 deletions Rest/Field/TypeValue.php
Expand Up @@ -11,6 +11,7 @@
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\Field;
use eZ\Bundle\EzPublishCoreBundle\FieldType\RichText\Converter\Html5 as RichHtml5;
use eZ\Publish\Core\FieldType\XmlText\Converter\Html5 as XmlHtml5;
use Symfony\Component\HttpFoundation\RequestStack;

class TypeValue
Expand All @@ -27,22 +28,28 @@ class TypeValue
/** @var \eZ\Bundle\EzPublishCoreBundle\FieldType\RichText\Converter\Html5 */
private $richHtml5Converter;

/** @var \eZ\Publish\Core\FieldType\XmlText\Converter\Html5 */
private $xmlHtml5Converter;

/**
* @param \Symfony\Component\HttpFoundation\RequestStack $request
* @param \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\ConfigResolver $configResolver
* @param \eZ\Bundle\EzPublishCoreBundle\Imagine\AliasGenerator $imageVariationService
* @param \eZ\Bundle\EzPublishCoreBundle\FieldType\RichText\Converter\Html5 $richHtml5Converter
* @param \eZ\Publish\Core\FieldType\XmlText\Converter\Html5 $xmlHtml5Converter
*/
public function __construct(
RequestStack $request,
ConfigResolver $configResolver,
ImageVariationService $imageVariationService,
RichHtml5 $richHtml5Converter
RichHtml5 $richHtml5Converter,
XmlHtml5 $xmlHtml5Converter = null
) {
$this->request = $request;
$this->configResolver = $configResolver;
$this->imageVariationService = $imageVariationService;
$this->richHtml5Converter = $richHtml5Converter;
$this->xmlHtml5Converter = $xmlHtml5Converter;
}

/**
Expand All @@ -69,7 +76,19 @@ public function __call($fieldName, $args)
*/
public function ezxmltext(Field $field)
{
return '<![CDATA[' . $this->richHtml5Converter->convert($field->value->xml) . ']]>';
return '<![CDATA[' . $this->xmlHtml5Converter->convert($field->value->xml) . ']]>';
}

/**
* Method for parsing ezrichtext field.
*
* @param \eZ\Publish\API\Repository\Values\Content\Field $field
*
* @return string
*/
public function ezrichtext(Field $field)
{
return '<![CDATA[' . $this->richHtml5Converter->convert($field->value->xml)->saveHTML() . ']]>';
}

/**
Expand Down
6 changes: 6 additions & 0 deletions eZ/Publish/LegacySearch/RecommendationLegacySearchEngine.php
Expand Up @@ -111,6 +111,12 @@ public function updateNodeSection($nodeID, $sectionID)

public function updateNodeVisibility($nodeID, $action)
{
if ($action == 'hide') {
$this->recommendationClient->hideLocation($nodeID);
} elseif ($action == 'show') {
$this->recommendationClient->unhideLocation($nodeID);
}

if (method_exists($this->legacySearchEngine, 'updateNodeVisibility')) {
return $this->legacySearchEngine->updateNodeVisibility($nodeID, $action);
}
Expand Down

0 comments on commit d66e56a

Please sign in to comment.