jqh 4 роки тому
батько
коміт
4d8a062d8c
2 змінених файлів з 0 додано та 69 видалено
  1. 0 1
      composer.json
  2. 0 68
      src/Http/Middleware/Pjax.php

+ 0 - 1
composer.json

@@ -13,7 +13,6 @@
     ],
     "require": {
         "php": ">=7.1.0",
-        "symfony/dom-crawler": "~3.1|~4.0|~5.0",
         "laravel/framework": "~5.5|~6.0|~7.0|~8.0",
         "spatie/eloquent-sortable": "3.*|4.*"
     },

+ 0 - 68
src/Http/Middleware/Pjax.php

@@ -6,7 +6,6 @@ use Closure;
 use Dcat\Admin\Admin;
 use Illuminate\Http\Request;
 use Illuminate\Support\MessageBag;
-use Symfony\Component\DomCrawler\Crawler;
 use Symfony\Component\HttpFoundation\Response;
 
 class Pjax
@@ -64,73 +63,6 @@ class Pjax
         return back()->withInput()->withErrors($error, 'exception');
     }
 
-    /**
-     * Prepare the PJAX-specific response content.
-     *
-     * @param Response $response
-     * @param string   $container
-     *
-     * @return $this
-     */
-    protected function filterResponse(Response $response, $container)
-    {
-        $crawler = new Crawler($response->getContent());
-
-        $response->setContent(
-            $this->makeTitle($crawler).
-            $this->fetchContents($crawler, $container)
-        );
-
-        return $this;
-    }
-
-    /**
-     * Prepare an HTML title tag.
-     *
-     * @param Crawler $crawler
-     *
-     * @return string
-     */
-    protected function makeTitle($crawler)
-    {
-        $pageTitle = $crawler->filter('head > title')->html();
-
-        return "<title>{$pageTitle}</title>";
-    }
-
-    /**
-     * Fetch the PJAX-specific HTML from the response.
-     *
-     * @param Crawler $crawler
-     * @param string  $container
-     *
-     * @return string
-     */
-    protected function fetchContents($crawler, $container)
-    {
-        $content = $crawler->filter($container);
-
-        if (! $content->count()) {
-            abort(422);
-        }
-
-        return $this->decodeUtf8HtmlEntities($content->html());
-    }
-
-    /**
-     * Decode utf-8 characters to html entities.
-     *
-     * @param string $html
-     *
-     * @return string
-     */
-    protected function decodeUtf8HtmlEntities($html)
-    {
-        return preg_replace_callback('/(&#[0-9]+;)/', function ($html) {
-            return mb_convert_encoding($html[1], 'UTF-8', 'HTML-ENTITIES');
-        }, $html);
-    }
-
     /**
      * Set the PJAX-URL header to the current uri.
      *