Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KunstmaanAdminBundle]: use addHtmlContent for domcrawler #1502

Merged
merged 1 commit into from
Apr 23, 2017
Merged
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
16 changes: 4 additions & 12 deletions src/Kunstmaan/AdminBundle/Form/MediaTokenTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@ class MediaTokenTransformer implements DataTransformerInterface
*/
public function transform($content)
{
$html = utf8_encode("<!DOCTYPE html>
<html>
<body>
".$content."
</body>
</html>");

$crawler = new Crawler($html);
$crawler = new Crawler();
$crawler->addHtmlContent($content);

$crawler->filter('img')->each(
function (Crawler $node, $i) {
Expand All @@ -47,10 +41,8 @@ function (Crawler $node, $i) {
*/
public function reverseTransform($content)
{
// All on one line because of HTML parsing and empty lines.
$html = utf8_encode("<!DOCTYPE html><html><body>".$content."</body></html>");

$crawler = new Crawler($html);
$crawler = new Crawler();
$crawler->addHtmlContent($content);

// Get all img tags and parse the token.
$crawler->filter('img')->each(
Expand Down