Entries filter on language

+ updated deps
This commit is contained in:
Jeremy Benoist 2015-09-23 07:55:55 +02:00
parent 0d3bafdfdf
commit d4ebe5c5dc
8 changed files with 255 additions and 65 deletions

221
composer.lock generated
View file

@ -285,16 +285,16 @@
}, },
{ {
"name": "doctrine/dbal", "name": "doctrine/dbal",
"version": "v2.5.1", "version": "v2.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/dbal.git", "url": "https://github.com/doctrine/dbal.git",
"reference": "628c2256b646ae2417d44e063bce8aec5199d48d" "reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/628c2256b646ae2417d44e063bce8aec5199d48d", "url": "https://api.github.com/repos/doctrine/dbal/zipball/01dbcbc5cd0a913d751418e635434a18a2f2a75c",
"reference": "628c2256b646ae2417d44e063bce8aec5199d48d", "reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -352,20 +352,20 @@
"persistence", "persistence",
"queryobject" "queryobject"
], ],
"time": "2015-01-12 21:52:47" "time": "2015-09-16 16:29:33"
}, },
{ {
"name": "doctrine/doctrine-bundle", "name": "doctrine/doctrine-bundle",
"version": "v1.5.1", "version": "v1.5.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/DoctrineBundle.git", "url": "https://github.com/doctrine/DoctrineBundle.git",
"reference": "8c5cedb4f2f7ebb66a963ae46ad9daa1e31cee01" "reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/8c5cedb4f2f7ebb66a963ae46ad9daa1e31cee01", "url": "https://api.github.com/repos/doctrine/DoctrineBundle/zipball/d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3",
"reference": "8c5cedb4f2f7ebb66a963ae46ad9daa1e31cee01", "reference": "d63be7eb9a95d46720f7d6badac4e5bc2bcff2e3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -392,7 +392,7 @@
"type": "symfony-bundle", "type": "symfony-bundle",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.5.x-dev" "dev-master": "1.6.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -430,7 +430,7 @@
"orm", "orm",
"persistence" "persistence"
], ],
"time": "2015-08-12 15:52:00" "time": "2015-08-31 14:47:06"
}, },
{ {
"name": "doctrine/doctrine-cache-bundle", "name": "doctrine/doctrine-cache-bundle",
@ -948,12 +948,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git", "url": "https://github.com/FriendsOfSymfony/FOSUserBundle.git",
"reference": "6b7bb04c6d507bb5356bf70b2d1bc30ce64ffc60" "reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/6b7bb04c6d507bb5356bf70b2d1bc30ce64ffc60", "url": "https://api.github.com/repos/FriendsOfSymfony/FOSUserBundle/zipball/d5b28c367d393f9d9fbc48c4138b2a74d51c0c83",
"reference": "6b7bb04c6d507bb5356bf70b2d1bc30ce64ffc60", "reference": "d5b28c367d393f9d9fbc48c4138b2a74d51c0c83",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1007,7 +1007,7 @@
"keywords": [ "keywords": [
"User management" "User management"
], ],
"time": "2015-09-07 08:53:52" "time": "2015-09-15 13:15:07"
}, },
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
@ -1267,16 +1267,16 @@
}, },
{ {
"name": "j0k3r/graby", "name": "j0k3r/graby",
"version": "1.0.0-alpha.1", "version": "1.0.0-alpha.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/j0k3r/graby.git", "url": "https://github.com/j0k3r/graby.git",
"reference": "9d4f62aa83a7cd563fe3ca9fcc4b176d7e1d264c" "reference": "9cc399bbe70f12b302ea65e604a80ea738042599"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/j0k3r/graby/zipball/9d4f62aa83a7cd563fe3ca9fcc4b176d7e1d264c", "url": "https://api.github.com/repos/j0k3r/graby/zipball/9cc399bbe70f12b302ea65e604a80ea738042599",
"reference": "9d4f62aa83a7cd563fe3ca9fcc4b176d7e1d264c", "reference": "9cc399bbe70f12b302ea65e604a80ea738042599",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1289,6 +1289,7 @@
"neitanod/forceutf8": "^1.4", "neitanod/forceutf8": "^1.4",
"php": ">=5.4", "php": ">=5.4",
"simplepie/simplepie": "^1.3.1", "simplepie/simplepie": "^1.3.1",
"smalot/pdfparser": "~0.9.24",
"symfony/options-resolver": "^2.6.6" "symfony/options-resolver": "^2.6.6"
}, },
"type": "library", "type": "library",
@ -1314,20 +1315,20 @@
} }
], ],
"description": "Graby helps you extract article content from web pages", "description": "Graby helps you extract article content from web pages",
"time": "2015-09-13 10:07:45" "time": "2015-09-17 11:43:10"
}, },
{ {
"name": "j0k3r/graby-site-config", "name": "j0k3r/graby-site-config",
"version": "1.0.2", "version": "1.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/j0k3r/graby-site-config.git", "url": "https://github.com/j0k3r/graby-site-config.git",
"reference": "9ad65e69bb21397dfededd420e1d4ab22006993c" "reference": "1b0ac25687aa33785c5d9d8ede92b26f757354f5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/j0k3r/graby-site-config/zipball/9ad65e69bb21397dfededd420e1d4ab22006993c", "url": "https://api.github.com/repos/j0k3r/graby-site-config/zipball/1b0ac25687aa33785c5d9d8ede92b26f757354f5",
"reference": "9ad65e69bb21397dfededd420e1d4ab22006993c", "reference": "1b0ac25687aa33785c5d9d8ede92b26f757354f5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1350,20 +1351,20 @@
} }
], ],
"description": "Graby site config files", "description": "Graby site config files",
"time": "2015-09-13 10:26:25" "time": "2015-09-17 17:32:42"
}, },
{ {
"name": "j0k3r/php-readability", "name": "j0k3r/php-readability",
"version": "v1.0.4", "version": "v1.0.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/j0k3r/php-readability.git", "url": "https://github.com/j0k3r/php-readability.git",
"reference": "c5a4a490e155fa20809c9bbcf3e318defbb7a261" "reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/j0k3r/php-readability/zipball/c5a4a490e155fa20809c9bbcf3e318defbb7a261", "url": "https://api.github.com/repos/j0k3r/php-readability/zipball/1830dc45d4fccfe09d2d107ab59890f07adc35c4",
"reference": "c5a4a490e155fa20809c9bbcf3e318defbb7a261", "reference": "1830dc45d4fccfe09d2d107ab59890f07adc35c4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1413,7 +1414,7 @@
"extraction", "extraction",
"html" "html"
], ],
"time": "2015-08-24 09:10:54" "time": "2015-09-20 19:05:55"
}, },
{ {
"name": "jdorn/sql-formatter", "name": "jdorn/sql-formatter",
@ -2058,20 +2059,20 @@
}, },
{ {
"name": "neitanod/forceutf8", "name": "neitanod/forceutf8",
"version": "v1.4", "version": "v1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/neitanod/forceutf8.git", "url": "https://github.com/neitanod/forceutf8.git",
"reference": "28d50d579179abac1f6a55b03c6d9d3f6573867c" "reference": "1b577b9430cb7bd20d8dd7435f36120b85880ace"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/neitanod/forceutf8/zipball/28d50d579179abac1f6a55b03c6d9d3f6573867c", "url": "https://api.github.com/repos/neitanod/forceutf8/zipball/1b577b9430cb7bd20d8dd7435f36120b85880ace",
"reference": "28d50d579179abac1f6a55b03c6d9d3f6573867c", "reference": "1b577b9430cb7bd20d8dd7435f36120b85880ace",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.2.0" "php": ">=5.3.0"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@ -2088,7 +2089,7 @@
], ],
"description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.", "description": "PHP Class Encoding featuring popular Encoding::toUTF8() function --formerly known as forceUTF8()-- that fixes mixed encoded strings.",
"homepage": "https://github.com/neitanod/forceutf8", "homepage": "https://github.com/neitanod/forceutf8",
"time": "2014-09-24 14:59:43" "time": "2015-01-02 13:36:36"
}, },
{ {
"name": "nelmio/api-doc-bundle", "name": "nelmio/api-doc-bundle",
@ -2685,6 +2686,49 @@
], ],
"time": "2012-10-30 17:54:03" "time": "2012-10-30 17:54:03"
}, },
{
"name": "smalot/pdfparser",
"version": "v0.9.25",
"source": {
"type": "git",
"url": "https://github.com/smalot/pdfparser.git",
"reference": "31590f7938a22f1c7fc4fb292611e3742a62ebaa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/smalot/pdfparser/zipball/31590f7938a22f1c7fc4fb292611e3742a62ebaa",
"reference": "31590f7938a22f1c7fc4fb292611e3742a62ebaa",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"tecnickcom/tcpdf": ">=6.0.050"
},
"require-dev": {
"atoum/atoum": "dev-master"
},
"type": "library",
"autoload": {
"psr-0": {
"Smalot\\PdfParser\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-3.0"
],
"authors": [
{
"name": "Sebastien MALOT",
"email": "sebastien@malot.fr",
"homepage": "http://www.malot.fr",
"role": "Developer"
}
],
"description": "Pdf parser library. Can read and extract information from pdf file.",
"homepage": "http://www.pdfparser.org",
"time": "2015-09-18 08:29:33"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v5.4.1", "version": "v5.4.1",
@ -3109,6 +3153,69 @@
], ],
"time": "2015-08-02 12:30:27" "time": "2015-08-02 12:30:27"
}, },
{
"name": "tecnickcom/tcpdf",
"version": "6.2.12",
"source": {
"type": "git",
"url": "https://github.com/tecnickcom/TCPDF.git",
"reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/2f732eaa91b5665274689b1d40b285a7bacdc37f",
"reference": "2f732eaa91b5665274689b1d40b285a7bacdc37f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"classmap": [
"fonts",
"config",
"include",
"tcpdf.php",
"tcpdf_parser.php",
"tcpdf_import.php",
"tcpdf_barcodes_1d.php",
"tcpdf_barcodes_2d.php",
"include/tcpdf_colors.php",
"include/tcpdf_filters.php",
"include/tcpdf_font_data.php",
"include/tcpdf_fonts.php",
"include/tcpdf_images.php",
"include/tcpdf_static.php",
"include/barcodes/datamatrix.php",
"include/barcodes/pdf417.php",
"include/barcodes/qrcode.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPLv3"
],
"authors": [
{
"name": "Nicola Asuni",
"email": "info@tecnick.com",
"homepage": "http://nicolaasuni.tecnick.com"
}
],
"description": "TCPDF is a PHP class for generating PDF documents and barcodes.",
"homepage": "http://www.tcpdf.org/",
"keywords": [
"PDFD32000-2008",
"TCPDF",
"barcodes",
"datamatrix",
"pdf",
"pdf417",
"qrcode"
],
"time": "2015-09-12 10:08:34"
},
{ {
"name": "twig/extensions", "name": "twig/extensions",
"version": "v1.3.0", "version": "v1.3.0",
@ -3163,16 +3270,16 @@
}, },
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.21.2", "version": "v1.22.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "ddce1136beb8db29b9cd7dffa8ab518b978c9db3" "reference": "79249fc8c9ff62e41e217e0c630e2e00bcadda6a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ddce1136beb8db29b9cd7dffa8ab518b978c9db3", "url": "https://api.github.com/repos/twigphp/Twig/zipball/79249fc8c9ff62e41e217e0c630e2e00bcadda6a",
"reference": "ddce1136beb8db29b9cd7dffa8ab518b978c9db3", "reference": "79249fc8c9ff62e41e217e0c630e2e00bcadda6a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3185,7 +3292,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.21-dev" "dev-master": "1.22-dev"
} }
}, },
"autoload": { "autoload": {
@ -3220,7 +3327,7 @@
"keywords": [ "keywords": [
"templating" "templating"
], ],
"time": "2015-09-09 05:28:51" "time": "2015-09-22 13:59:32"
}, },
{ {
"name": "willdurand/hateoas", "name": "willdurand/hateoas",
@ -3655,16 +3762,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "2.2.2", "version": "2.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c" "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2d7c03c0e4e080901b8f33b2897b0577be18a13c", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c", "reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3713,7 +3820,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-08-04 03:42:39" "time": "2015-09-14 06:51:16"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -3846,16 +3953,16 @@
}, },
{ {
"name": "phpunit/php-token-stream", "name": "phpunit/php-token-stream",
"version": "1.4.6", "version": "1.4.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git", "url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b" "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3ab72c62e550370a6cd5dc873e1a04ab57562f5b", "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b", "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3891,20 +3998,20 @@
"keywords": [ "keywords": [
"tokenizer" "tokenizer"
], ],
"time": "2015-08-16 08:51:00" "time": "2015-09-15 10:49:45"
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "4.8.6", "version": "4.8.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "2246830f4a1a551c67933e4171bf2126dc29d357" "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2246830f4a1a551c67933e4171bf2126dc29d357", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/73fad41adb5b7bc3a494bb930d90648df1d5e74b",
"reference": "2246830f4a1a551c67933e4171bf2126dc29d357", "reference": "73fad41adb5b7bc3a494bb930d90648df1d5e74b",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3963,7 +4070,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2015-08-24 04:09:38" "time": "2015-09-20 12:56:44"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",

View file

@ -192,7 +192,7 @@ class EntryController extends Controller
throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
} }
$form = $this->get('form.factory')->create(new EntryFilterType()); $form = $this->get('form.factory')->create(new EntryFilterType($repository, $this->getUser()));
if ($request->query->has($form->getName())) { if ($request->query->has($form->getName())) {
// manually bind values from the request // manually bind values from the request

View file

@ -19,6 +19,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry1->setUrl('http://0.0.0.0'); $entry1->setUrl('http://0.0.0.0');
$entry1->setTitle('test title entry1'); $entry1->setTitle('test title entry1');
$entry1->setContent('This is my content /o/'); $entry1->setContent('This is my content /o/');
$entry1->setLanguage('en');
$manager->persist($entry1); $manager->persist($entry1);
@ -28,6 +29,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry2->setUrl('http://0.0.0.0'); $entry2->setUrl('http://0.0.0.0');
$entry2->setTitle('test title entry2'); $entry2->setTitle('test title entry2');
$entry2->setContent('This is my content /o/'); $entry2->setContent('This is my content /o/');
$entry2->setLanguage('fr');
$manager->persist($entry2); $manager->persist($entry2);
@ -37,6 +39,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry3->setUrl('http://0.0.0.0'); $entry3->setUrl('http://0.0.0.0');
$entry3->setTitle('test title entry3'); $entry3->setTitle('test title entry3');
$entry3->setContent('This is my content /o/'); $entry3->setContent('This is my content /o/');
$entry3->setLanguage('en');
$tag1 = new Tag($this->getReference('bob-user')); $tag1 = new Tag($this->getReference('bob-user'));
$tag1->setLabel('foo'); $tag1->setLabel('foo');
@ -54,6 +57,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry4->setUrl('http://0.0.0.0'); $entry4->setUrl('http://0.0.0.0');
$entry4->setTitle('test title entry4'); $entry4->setTitle('test title entry4');
$entry4->setContent('This is my content /o/'); $entry4->setContent('This is my content /o/');
$entry4->setLanguage('en');
$tag1 = new Tag($this->getReference('admin-user')); $tag1 = new Tag($this->getReference('admin-user'));
$tag1->setLabel('foo'); $tag1->setLabel('foo');
@ -72,6 +76,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry5->setTitle('test title entry5'); $entry5->setTitle('test title entry5');
$entry5->setContent('This is my content /o/'); $entry5->setContent('This is my content /o/');
$entry5->setStarred(true); $entry5->setStarred(true);
$entry5->setLanguage('fr');
$manager->persist($entry5); $manager->persist($entry5);
@ -82,6 +87,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry6->setTitle('test title entry6'); $entry6->setTitle('test title entry6');
$entry6->setContent('This is my content /o/'); $entry6->setContent('This is my content /o/');
$entry6->setArchived(true); $entry6->setArchived(true);
$entry6->setLanguage('de');
$manager->persist($entry6); $manager->persist($entry6);

View file

@ -6,9 +6,26 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
use Doctrine\ORM\EntityRepository;
use Wallabag\CoreBundle\Entity\User;
class EntryFilterType extends AbstractType class EntryFilterType extends AbstractType
{ {
private $user;
private $repository;
/**
* Repository & user are used to get a list of language entries for this user
*
* @param EntityRepository $entryRepository
* @param User $user
*/
public function __construct(EntityRepository $entryRepository, User $user)
{
$this->repository = $entryRepository;
$this->user = $user;
}
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
@ -53,7 +70,11 @@ class EntryFilterType extends AbstractType
return $filterQuery->createCondition($expression); return $filterQuery->createCondition($expression);
}, },
)); ))
->add('language', 'filter_choice', array(
'choices' => $this->repository->findDistinctLanguageByUser($this->user->getId()),
))
;
} }
public function getName() public function getName()

View file

@ -134,4 +134,31 @@ class EntryRepository extends EntityRepository
return $qb->getQuery()->getResult(); return $qb->getQuery()->getResult();
} }
/**
* Find distinct language for a given user.
* Used to build the filter language list.
*
* @param int $userId User id
*
* @return array
*/
public function findDistinctLanguageByUser($userId)
{
$results = $this->createQueryBuilder('e')
->select('e.language')
->where('e.user = :userId')->setParameter('userId', $userId)
->andWhere('e.language IS NOT NULL')
->groupBy('e.language')
->orderBy('e.language', ' ASC')
->getQuery()
->getResult();
$languages = array();
foreach ($results as $result) {
$languages[$result['language']] = $result['language'];
}
return $languages;
}
} }

View file

@ -71,6 +71,14 @@
<label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label> <label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
</div> </div>
</div> </div>
<div id="filter-language" class="filter-group">
<label for="entry_filter_language">{% trans %}Language{% endtrans %}</label>
<div class="input-field ">
{{ form_widget(form.language) }}
</div>
</div>
<div id="filter-reading-time" class="filter-group"> <div id="filter-reading-time" class="filter-group">
<div class=""> <div class="">
<label>{% trans %}Reading time in minutes{% endtrans %}</label> <label>{% trans %}Reading time in minutes{% endtrans %}</label>

View file

@ -121,14 +121,12 @@
<label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label> <label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
</div> </div>
<div class="input-field col s6"> <div class="col s12">
{{ form_widget(form.isArchived) }} <label>{% trans %}Language{% endtrans %}</label>
<label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>
</div> </div>
<div class="input-field col s6"> <div class="input-field col s12">
{{ form_widget(form.isStarred) }} {{ form_widget(form.language) }}
<label for="entry_filter_isStarred">{% trans %}Starred{% endtrans %}</label>
</div> </div>
<div class="col s12"> <div class="col s12">

View file

@ -382,4 +382,27 @@ class EntryControllerTest extends WallabagCoreTestCase
$crawler = $client->submit($form); $crawler = $client->submit($form);
$this->assertCount(1, $crawler->filter('div[class=entry]')); $this->assertCount(1, $crawler->filter('div[class=entry]'));
} }
public function testFilterOnLanguage()
{
$this->logInAs('admin');
$client = $this->getClient();
$crawler = $client->request('GET', '/unread/list');
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
'entry_filter[language]' => 'de',
);
$crawler = $client->submit($form, $data);
$this->assertCount(1, $crawler->filter('div[class=entry]'));
$form = $crawler->filter('button[id=submit-filter]')->form();
$data = array(
'entry_filter[language]' => 'en',
);
$crawler = $client->submit($form, $data);
$this->assertCount(2, $crawler->filter('div[class=entry]'));
}
} }