Ver Fonte

Drepecate some code

Thomas Rabaix há 11 anos atrás
pai
commit
ba17aa0d5a

+ 5 - 49
Export/Exporter.php

@@ -11,56 +11,12 @@
 
 namespace Sonata\AdminBundle\Export;
 
-use Exporter\Source\SourceIteratorInterface;
 use Symfony\Component\HttpFoundation\StreamedResponse;
+use Sonata\CoreBundle\Exporter\Exporter as BaseExporter;
 
-use Exporter\Writer\XlsWriter;
-use Exporter\Writer\XmlWriter;
-use Exporter\Writer\JsonWriter;
-use Exporter\Writer\CsvWriter;
-
-class Exporter
+/**
+ * @deprecated
+ */
+class Exporter extends BaseExporter
 {
-    /**
-     * @throws \RuntimeException
-     *
-     * @param string                  $format
-     * @param string                  $filename
-     * @param SourceIteratorInterface $source
-     *
-     * @return StreamedResponse
-     */
-    public function getResponse($format, $filename, SourceIteratorInterface $source)
-    {
-        switch ($format) {
-            case 'xls':
-                $writer      = new XlsWriter('php://output');
-                $contentType = 'application/vnd.ms-excel';
-                break;
-            case 'xml':
-                $writer      = new XmlWriter('php://output');
-                $contentType = 'text/xml';
-                break;
-            case 'json':
-                $writer      = new JsonWriter('php://output');
-                $contentType = 'application/json';
-                break;
-            case 'csv':
-                $writer      = new CsvWriter('php://output', ',', '"', "", true, true);
-                $contentType = 'text/csv';
-                break;
-            default:
-                throw new \RuntimeException('Invalid format');
-        }
-
-        $callback = function() use ($source, $writer) {
-            $handler = \Exporter\Handler::create($source, $writer);
-            $handler->export();
-        };
-
-        return new StreamedResponse($callback, 200, array(
-            'Content-Type'        => $contentType,
-            'Content-Disposition' => sprintf('attachment; filename=%s', $filename)
-        ));
-    }
 }

+ 0 - 10
Tests/Twig/Extension/SonataAdminExtensionTest.php

@@ -159,16 +159,6 @@ class SonataAdminExtensionTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue('Data'));
     }
 
-    public function testSlugify()
-    {
-        $this->assertEquals($this->twigExtension->slugify('test'), 'test');
-        $this->assertEquals($this->twigExtension->slugify('S§!@@#$#$alut'), 's-alut');
-        $this->assertEquals($this->twigExtension->slugify('Symfony2'), 'symfony2');
-        $this->assertEquals($this->twigExtension->slugify('test'), 'test');
-        $this->assertEquals($this->twigExtension->slugify('c\'est bientôt l\'été'), 'c-est-bientot-l-ete');
-        $this->assertEquals($this->twigExtension->slugify(urldecode('%2Fc\'est+bientôt+l\'été')), 'c-est-bientot-l-ete');
-    }
-
     /**
      * @dataProvider getRenderListElementTests
      */

+ 0 - 30
Twig/Extension/SonataAdminExtension.php

@@ -54,7 +54,6 @@ class SonataAdminExtension extends \Twig_Extension
             'render_view_element'     => new \Twig_Filter_Method($this, 'renderViewElement', array('is_safe' => array('html'))),
             'render_relation_element' => new \Twig_Filter_Method($this, 'renderRelationElement'),
             'sonata_urlsafeid'        => new \Twig_Filter_Method($this, 'getUrlsafeIdentifier'),
-            'sonata_slugify'          => new \Twig_Filter_Method($this, 'slugify'),
         );
     }
 
@@ -232,33 +231,4 @@ class SonataAdminExtension extends \Twig_Extension
 
         return $admin->getUrlsafeIdentifier($model);
     }
-
-    /**
-     * Slugify a text
-     *
-     * @param $text
-     *
-     * @return string
-     */
-    public function slugify($text)
-    {
-        // replace non letter or digits by -
-        $text = preg_replace('~[^\\pL\d]+~u', '-', $text);
-
-        // trim
-        $text = trim($text, '-');
-
-        // transliterate
-        if (function_exists('iconv')) {
-            $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
-        }
-
-        // lowercase
-        $text = strtolower($text);
-
-        // remove unwanted characters
-        $text = preg_replace('~[^-\w]+~', '', $text);
-
-        return $text;
-    }
 }