Skip to content

Commit

Permalink
Merge pull request #71 from chihiro-adachi/1.0.2
Browse files Browse the repository at this point in the history
html_entity_decodeを使っている箇所を修正
  • Loading branch information
matsuoshi committed Jun 15, 2021
2 parents 2c3d93f + 133ae36 commit 0474b0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
25 changes: 8 additions & 17 deletions Event/ProductReviewEventLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,16 @@ public function onRenderProductsDetailBefore(FilterResponseEvent $event)

$response = $event->getResponse();

// Source
$html = $response->getContent();
// insert dom
$document = \DOMDocument::loadHTML($response->getContent());
$xpath = new \DOMXPath($document);
$itemDetail = $xpath->query('//div[@id="item_detail"]', $document)->item(0);

// Crawler
$crawler = new Crawler($html);
$oldElement = $crawler
->filter('#item_detail')->last();
$newNode = \DOMDocument::loadHTML('<?xml encoding="utf-8" ?><html>'.$twig.'</html>')->getElementsByTagName('html')->item(0);
$itemDetail->appendChild($document->importNode($newNode, true));

$oldHtml = $oldElement->html();

$oldHtml = html_entity_decode($oldHtml, ENT_NOQUOTES, 'UTF-8');

$newHtml = $oldHtml.$twig;

$html = $this->getHtml($crawler);

$html = str_replace($oldHtml, $newHtml, $html);

$response->setContent($html);
$crawler = new Crawler($document);
$response->setContent('<!doctype html>'.$crawler->html());
$event->setResponse($response);
}

Expand Down
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 商品レビュープラグイン
code: ProductReview
version: 1.0.1
version: 1.0.2
service:
- ProductReviewServiceProvider
orm.path:
Expand Down

0 comments on commit 0474b0e

Please sign in to comment.