Преглед на файлове

Merge branch 'feature/v0.9.8.2/mining' into stable/v0.9.8.2

Bastien Sevajol преди 11 години
родител
ревизия
4e5f0eaf5a

+ 1 - 0
app/AppKernel.php Целия файл

@@ -33,6 +33,7 @@ class AppKernel extends Kernel
33 33
             new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
34 34
             new Shtumi\UsefulBundle\ShtumiUsefulBundle(),
35 35
             new FOS\FacebookBundle\FOSFacebookBundle(),
36
+            new Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle(),
36 37
             
37 38
             new Muzich\CoreBundle\MuzichCoreBundle(),
38 39
             new Muzich\UserBundle\MuzichUserBundle(),

+ 2 - 0
app/autoload.php Целия файл

@@ -1,6 +1,7 @@
1 1
 <?php
2 2
 
3 3
 use Doctrine\Common\Annotations\AnnotationRegistry;
4
+use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
4 5
 
5 6
 $loader = include __DIR__.'/../vendor/autoload.php';
6 7
 
@@ -12,5 +13,6 @@ if (!function_exists('intl_get_error_code')) {
12 13
 }
13 14
 
14 15
 AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
16
+AnnotationDriver::registerAnnotationClasses();
15 17
 
16 18
 return $loader;

+ 3 - 3
app/bootstrap.php.cache Целия файл

@@ -327,11 +327,11 @@ protected $name;
327 327
 protected $startTime;
328 328
 protected $classes;
329 329
 protected $errorReportingLevel;
330
-const VERSION ='2.2.3';
331
-const VERSION_ID ='20203';
330
+const VERSION ='2.2.4';
331
+const VERSION_ID ='20204';
332 332
 const MAJOR_VERSION ='2';
333 333
 const MINOR_VERSION ='2';
334
-const RELEASE_VERSION ='3';
334
+const RELEASE_VERSION ='4';
335 335
 const EXTRA_VERSION ='';
336 336
 public function __construct($environment, $debug)
337 337
 {

+ 10 - 2
composer.json Целия файл

@@ -7,7 +7,7 @@
7 7
     },
8 8
     "require": {
9 9
         "php": ">=5.3.3",
10
-        "symfony/symfony": "v2.2.3",
10
+        "symfony/symfony": "v2.2.4",
11 11
         "doctrine/orm": "2.3.4",
12 12
         "doctrine/doctrine-bundle": "v1.2.0",
13 13
         "twig/extensions": "1.0.*@dev",
@@ -35,7 +35,15 @@
35 35
         "sonata-project/admin-bundle": "2.2.2",
36 36
         "sonata-project/jquery-bundle": "1.8.*@dev",
37 37
         "sonata-project/block-bundle": "2.2.3",
38
-        "friendsofsymfony/facebook-bundle": "dev-master"
38
+        "friendsofsymfony/facebook-bundle": "dev-master",
39
+        
40
+        "doctrine/mongodb-odm-bundle": "v3.0.0-BETA4",
41
+        "doctrine/mongodb-odm": "1.0.0-BETA9",
42
+        "symfony/options-resolver": "v2.2.4",
43
+        "symfony/doctrine-bridge": "v2.2.4",
44
+        "doctrine/mongodb": "1.0.0-BETA1"
45
+        
46
+        
39 47
     },
40 48
     "scripts": {
41 49
         "post-install-cmd": [

+ 244 - 42
composer.lock Целия файл

@@ -3,7 +3,7 @@
3 3
         "This file locks the dependencies of your project to a known state",
4 4
         "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
5 5
     ],
6
-    "hash": "0a6ed902bb57e0f8c4f106273cf613f0",
6
+    "hash": "66af7e69e293a353ab3fb2c45f07a831",
7 7
     "packages": [
8 8
         {
9 9
             "name": "cedriclombardot/admingenerator-generator-bundle",
@@ -191,12 +191,12 @@
191 191
             "source": {
192 192
                 "type": "git",
193 193
                 "url": "https://github.com/doctrine/data-fixtures.git",
194
-                "reference": "6924952026b77ff492da559b04ad166d25c611cb"
194
+                "reference": "b4a135c7db56ecc4602b54a2184368f440cac33e"
195 195
             },
196 196
             "dist": {
197 197
                 "type": "zip",
198
-                "url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/6924952026b77ff492da559b04ad166d25c611cb",
199
-                "reference": "6924952026b77ff492da559b04ad166d25c611cb",
198
+                "url": "https://api.github.com/repos/doctrine/data-fixtures/zipball/b4a135c7db56ecc4602b54a2184368f440cac33e",
199
+                "reference": "b4a135c7db56ecc4602b54a2184368f440cac33e",
200 200
                 "shasum": ""
201 201
             },
202 202
             "require": {
@@ -238,7 +238,7 @@
238 238
             "keywords": [
239 239
                 "database"
240 240
             ],
241
-            "time": "2013-04-11 23:14:04"
241
+            "time": "2013-07-10 17:04:07"
242 242
         },
243 243
         {
244 244
             "name": "doctrine/dbal",
@@ -380,12 +380,12 @@
380 380
             "source": {
381 381
                 "type": "git",
382 382
                 "url": "https://github.com/doctrine/DoctrineFixturesBundle.git",
383
-                "reference": "512fc0fa1d0ce7bdcc6a0a91812eb531f20e0828"
383
+                "reference": "8070624b47f7f171db4c9e4134436db7de51244c"
384 384
             },
385 385
             "dist": {
386 386
                 "type": "zip",
387
-                "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/512fc0fa1d0ce7bdcc6a0a91812eb531f20e0828",
388
-                "reference": "512fc0fa1d0ce7bdcc6a0a91812eb531f20e0828",
387
+                "url": "https://api.github.com/repos/doctrine/DoctrineFixturesBundle/zipball/8070624b47f7f171db4c9e4134436db7de51244c",
388
+                "reference": "8070624b47f7f171db4c9e4134436db7de51244c",
389 389
                 "shasum": ""
390 390
             },
391 391
             "require": {
@@ -429,7 +429,206 @@
429 429
                 "Fixture",
430 430
                 "persistence"
431 431
             ],
432
-            "time": "2013-06-21 10:31:45"
432
+            "time": "2013-07-18 09:26:47"
433
+        },
434
+        {
435
+            "name": "doctrine/mongodb",
436
+            "version": "1.0.0-BETA1",
437
+            "source": {
438
+                "type": "git",
439
+                "url": "https://github.com/doctrine/mongodb.git",
440
+                "reference": "1.0.0-BETA1"
441
+            },
442
+            "dist": {
443
+                "type": "zip",
444
+                "url": "https://api.github.com/repos/doctrine/mongodb/zipball/1.0.0-BETA1",
445
+                "reference": "1.0.0-BETA1",
446
+                "shasum": ""
447
+            },
448
+            "require": {
449
+                "doctrine/common": ">=2.1.0",
450
+                "ext-mongo": "*",
451
+                "php": ">=5.3.2",
452
+                "symfony/console": ">=2.0",
453
+                "symfony/yaml": ">=2.0"
454
+            },
455
+            "type": "library",
456
+            "autoload": {
457
+                "psr-0": {
458
+                    "Doctrine\\MongoDB": "lib/"
459
+                }
460
+            },
461
+            "notification-url": "https://packagist.org/downloads/",
462
+            "license": [
463
+                "MIT"
464
+            ],
465
+            "authors": [
466
+                {
467
+                    "name": "Bulat Shakirzyanov",
468
+                    "email": "mallluhuct@gmail.com",
469
+                    "homepage": "http://avalanche123.com"
470
+                },
471
+                {
472
+                    "name": "Jonathan H. Wage",
473
+                    "email": "jonwage@gmail.com",
474
+                    "homepage": "http://www.jwage.com/"
475
+                },
476
+                {
477
+                    "name": "Kris Wallsmith",
478
+                    "email": "kris.wallsmith@gmail.com",
479
+                    "homepage": "http://kriswallsmith.net/"
480
+                }
481
+            ],
482
+            "description": "Doctrine MongoDB Abstraction Layer",
483
+            "homepage": "http://www.doctrine-project.org",
484
+            "keywords": [
485
+                "mongodb",
486
+                "persistence"
487
+            ],
488
+            "time": "2012-08-02 18:00:59"
489
+        },
490
+        {
491
+            "name": "doctrine/mongodb-odm",
492
+            "version": "1.0.0-BETA9",
493
+            "source": {
494
+                "type": "git",
495
+                "url": "https://github.com/doctrine/mongodb-odm.git",
496
+                "reference": "1.0.0-BETA9"
497
+            },
498
+            "dist": {
499
+                "type": "zip",
500
+                "url": "https://api.github.com/repos/doctrine/mongodb-odm/zipball/1.0.0-BETA9",
501
+                "reference": "1.0.0-BETA9",
502
+                "shasum": ""
503
+            },
504
+            "require": {
505
+                "doctrine/common": ">=2.2.0,<2.5-dev",
506
+                "doctrine/mongodb": "1.0.*",
507
+                "php": ">=5.3.2",
508
+                "symfony/console": ">=2.0,<3.0"
509
+            },
510
+            "require-dev": {
511
+                "symfony/yaml": ">=2.0,<3.0"
512
+            },
513
+            "suggest": {
514
+                "symfony/yaml": "Enables the YAML metadata mapping driver"
515
+            },
516
+            "type": "library",
517
+            "extra": {
518
+                "branch-alias": {
519
+                    "dev-master": "1.0.x-dev"
520
+                }
521
+            },
522
+            "autoload": {
523
+                "psr-0": {
524
+                    "Doctrine\\ODM\\MongoDB": "lib/"
525
+                }
526
+            },
527
+            "notification-url": "https://packagist.org/downloads/",
528
+            "license": [
529
+                "MIT"
530
+            ],
531
+            "authors": [
532
+                {
533
+                    "name": "Bulat Shakirzyanov",
534
+                    "email": "mallluhuct@gmail.com",
535
+                    "homepage": "http://avalanche123.com"
536
+                },
537
+                {
538
+                    "name": "Jonathan H. Wage",
539
+                    "email": "jonwage@gmail.com",
540
+                    "homepage": "http://www.jwage.com/"
541
+                },
542
+                {
543
+                    "name": "Kris Wallsmith",
544
+                    "email": "kris.wallsmith@gmail.com",
545
+                    "homepage": "http://kriswallsmith.net/"
546
+                },
547
+                {
548
+                    "name": "Jeremy Mikola",
549
+                    "email": "jmikola@gmail.com",
550
+                    "homepage": "http://jmikola.net"
551
+                }
552
+            ],
553
+            "description": "Doctrine MongoDB Object Document Mapper",
554
+            "homepage": "http://www.doctrine-project.org",
555
+            "keywords": [
556
+                "database",
557
+                "mongodb",
558
+                "odm",
559
+                "persistence"
560
+            ],
561
+            "time": "2013-06-06 19:15:45"
562
+        },
563
+        {
564
+            "name": "doctrine/mongodb-odm-bundle",
565
+            "version": "v3.0.0-BETA4",
566
+            "target-dir": "Doctrine/Bundle/MongoDBBundle",
567
+            "source": {
568
+                "type": "git",
569
+                "url": "https://github.com/doctrine/DoctrineMongoDBBundle.git",
570
+                "reference": "v3.0.0-BETA4"
571
+            },
572
+            "dist": {
573
+                "type": "zip",
574
+                "url": "https://api.github.com/repos/doctrine/DoctrineMongoDBBundle/zipball/v3.0.0-BETA4",
575
+                "reference": "v3.0.0-BETA4",
576
+                "shasum": ""
577
+            },
578
+            "require": {
579
+                "doctrine/mongodb-odm": ">=1.0-beta5,<1.1",
580
+                "php": ">=5.3.2",
581
+                "symfony/doctrine-bridge": ">=2.1,<2.3-dev",
582
+                "symfony/framework-bundle": ">=2.1,<2.3-dev",
583
+                "symfony/options-resolver": ">=2.1,<2.3-dev"
584
+            },
585
+            "require-dev": {
586
+                "doctrine/data-fixtures": "@dev",
587
+                "symfony/form": ">=2.1,<2.3-dev",
588
+                "symfony/yaml": ">=2.1,<2.3-dev"
589
+            },
590
+            "suggest": {
591
+                "doctrine/data-fixtures": "Load data fixtures"
592
+            },
593
+            "type": "symfony-bundle",
594
+            "extra": {
595
+                "branch-alias": {
596
+                    "dev-master": "3.0-dev"
597
+                }
598
+            },
599
+            "autoload": {
600
+                "psr-0": {
601
+                    "Doctrine\\Bundle\\MongoDBBundle": ""
602
+                }
603
+            },
604
+            "notification-url": "https://packagist.org/downloads/",
605
+            "license": [
606
+                "MIT"
607
+            ],
608
+            "authors": [
609
+                {
610
+                    "name": "Bulat Shakirzyanov",
611
+                    "email": "mallluhuct@gmail.com",
612
+                    "homepage": "http://avalanche123.com"
613
+                },
614
+                {
615
+                    "name": "Jonathan H. Wage",
616
+                    "email": "jonwage@gmail.com",
617
+                    "homepage": "http://www.jwage.com/"
618
+                },
619
+                {
620
+                    "name": "Kris Wallsmith",
621
+                    "email": "kris@symfony.com"
622
+                }
623
+            ],
624
+            "description": "Symfony2 Doctrine MongoDB Bundle",
625
+            "homepage": "http://www.doctrine-project.org",
626
+            "keywords": [
627
+                "mongodb",
628
+                "persistence",
629
+                "symfony"
630
+            ],
631
+            "time": "2013-03-18 18:12:08"
433 632
         },
434 633
         {
435 634
             "name": "doctrine/orm",
@@ -756,12 +955,12 @@
756 955
             "source": {
757 956
                 "type": "git",
758 957
                 "url": "https://github.com/Gregwar/ImageBundle.git",
759
-                "reference": "ae746b296768cc63c7f3478446dc5bf5d36812d4"
958
+                "reference": "c0f86ad2095e084bb899d22304581d14c02d3da6"
760 959
             },
761 960
             "dist": {
762 961
                 "type": "zip",
763
-                "url": "https://api.github.com/repos/Gregwar/ImageBundle/zipball/ae746b296768cc63c7f3478446dc5bf5d36812d4",
764
-                "reference": "ae746b296768cc63c7f3478446dc5bf5d36812d4",
962
+                "url": "https://api.github.com/repos/Gregwar/ImageBundle/zipball/c0f86ad2095e084bb899d22304581d14c02d3da6",
963
+                "reference": "c0f86ad2095e084bb899d22304581d14c02d3da6",
765 964
                 "shasum": ""
766 965
             },
767 966
             "require": {
@@ -791,7 +990,7 @@
791 990
                 "Symfony2",
792 991
                 "image"
793 992
             ],
794
-            "time": "2013-06-02 20:38:56"
993
+            "time": "2013-07-23 15:16:28"
795 994
         },
796 995
         {
797 996
             "name": "jdorn/sql-formatter",
@@ -983,7 +1182,7 @@
983 1182
                 {
984 1183
                     "name": "Johannes M. Schmitt",
985 1184
                     "email": "schmittjoh@gmail.com",
986
-                    "homepage": "https://github.com/schmittjoh",
1185
+                    "homepage": "http://jmsyst.com",
987 1186
                     "role": "Developer of wrapped JMSSerializerBundle"
988 1187
                 }
989 1188
             ],
@@ -1034,7 +1233,7 @@
1034 1233
                 {
1035 1234
                     "name": "Johannes M. Schmitt",
1036 1235
                     "email": "schmittjoh@gmail.com",
1037
-                    "homepage": "https://github.com/schmittjoh",
1236
+                    "homepage": "http://jmsyst.com",
1038 1237
                     "role": "Developer of wrapped JMSSerializerBundle"
1039 1238
                 }
1040 1239
             ],
@@ -1138,7 +1337,7 @@
1138 1337
                 {
1139 1338
                     "name": "Johannes M. Schmitt",
1140 1339
                     "email": "schmittjoh@gmail.com",
1141
-                    "homepage": "https://github.com/schmittjoh",
1340
+                    "homepage": "http://jmsyst.com",
1142 1341
                     "role": "Developer of wrapped JMSSerializerBundle"
1143 1342
                 }
1144 1343
             ],
@@ -1339,26 +1538,26 @@
1339 1538
         },
1340 1539
         {
1341 1540
             "name": "monolog/monolog",
1342
-            "version": "1.5.0",
1541
+            "version": "1.6.0",
1343 1542
             "source": {
1344 1543
                 "type": "git",
1345 1544
                 "url": "https://github.com/Seldaek/monolog.git",
1346
-                "reference": "1.5.0"
1545
+                "reference": "1.6.0"
1347 1546
             },
1348 1547
             "dist": {
1349 1548
                 "type": "zip",
1350
-                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1.5.0",
1351
-                "reference": "1.5.0",
1549
+                "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1.6.0",
1550
+                "reference": "1.6.0",
1352 1551
                 "shasum": ""
1353 1552
             },
1354 1553
             "require": {
1355 1554
                 "php": ">=5.3.0",
1356
-                "psr/log": ">=1.0,<2.0"
1555
+                "psr/log": "~1.0"
1357 1556
             },
1358 1557
             "require-dev": {
1359 1558
                 "doctrine/couchdb": "dev-master",
1360 1559
                 "mlehner/gelf-php": "1.0.*",
1361
-                "raven/raven": "0.3.*"
1560
+                "raven/raven": "0.5.*"
1362 1561
             },
1363 1562
             "suggest": {
1364 1563
                 "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
@@ -1370,7 +1569,7 @@
1370 1569
             "type": "library",
1371 1570
             "extra": {
1372 1571
                 "branch-alias": {
1373
-                    "dev-master": "1.4.x-dev"
1572
+                    "dev-master": "1.6.x-dev"
1374 1573
                 }
1375 1574
             },
1376 1575
             "autoload": {
@@ -1397,7 +1596,7 @@
1397 1596
                 "logging",
1398 1597
                 "psr-3"
1399 1598
             ],
1400
-            "time": "2013-04-23 10:09:48"
1599
+            "time": "2013-07-28 22:38:30"
1401 1600
         },
1402 1601
         {
1403 1602
             "name": "pagerfanta/pagerfanta",
@@ -1420,7 +1619,7 @@
1420 1619
                 "doctrine/mongodb-odm": "*",
1421 1620
                 "doctrine/orm": "2.*",
1422 1621
                 "mandango/mandango": "*",
1423
-                "propel/propel1": ">=1.6,<2.0",
1622
+                "propel/propel1": "~1.6",
1424 1623
                 "solarium/solarium": "dev-develop"
1425 1624
             },
1426 1625
             "suggest": {
@@ -1696,12 +1895,12 @@
1696 1895
             "source": {
1697 1896
                 "type": "git",
1698 1897
                 "url": "https://github.com/shtumi/ShtumiUsefulBundle.git",
1699
-                "reference": "fc6cef6a071d903749dfcff38884f9c240f9e6cf"
1898
+                "reference": "c48ef1a7c1ff8c2b9db73f9c1a69f63e1f6bcbef"
1700 1899
             },
1701 1900
             "dist": {
1702 1901
                 "type": "zip",
1703
-                "url": "https://api.github.com/repos/shtumi/ShtumiUsefulBundle/zipball/fc6cef6a071d903749dfcff38884f9c240f9e6cf",
1704
-                "reference": "fc6cef6a071d903749dfcff38884f9c240f9e6cf",
1902
+                "url": "https://api.github.com/repos/shtumi/ShtumiUsefulBundle/zipball/c48ef1a7c1ff8c2b9db73f9c1a69f63e1f6bcbef",
1903
+                "reference": "c48ef1a7c1ff8c2b9db73f9c1a69f63e1f6bcbef",
1705 1904
                 "shasum": ""
1706 1905
             },
1707 1906
             "require": {
@@ -1734,7 +1933,7 @@
1734 1933
                 "daterange",
1735 1934
                 "shtumi"
1736 1935
             ],
1737
-            "time": "2013-04-08 08:10:20"
1936
+            "time": "2013-07-20 18:33:09"
1738 1937
         },
1739 1938
         {
1740 1939
             "name": "sonata-project/admin-bundle",
@@ -2324,23 +2523,23 @@
2324 2523
         },
2325 2524
         {
2326 2525
             "name": "symfony/symfony",
2327
-            "version": "v2.2.3",
2526
+            "version": "v2.2.4",
2328 2527
             "source": {
2329 2528
                 "type": "git",
2330 2529
                 "url": "https://github.com/symfony/symfony.git",
2331
-                "reference": "v2.2.3"
2530
+                "reference": "v2.2.4"
2332 2531
             },
2333 2532
             "dist": {
2334 2533
                 "type": "zip",
2335
-                "url": "https://api.github.com/repos/symfony/symfony/zipball/v2.2.3",
2336
-                "reference": "v2.2.3",
2534
+                "url": "https://api.github.com/repos/symfony/symfony/zipball/v2.2.4",
2535
+                "reference": "v2.2.4",
2337 2536
                 "shasum": ""
2338 2537
             },
2339 2538
             "require": {
2340
-                "doctrine/common": ">=2.2,<3.0",
2539
+                "doctrine/common": "~2.2",
2341 2540
                 "php": ">=5.3.3",
2342
-                "psr/log": ">=1.0,<2.0",
2343
-                "twig/twig": ">=1.11.0,<2.0"
2541
+                "psr/log": "~1.0",
2542
+                "twig/twig": "~1.11"
2344 2543
             },
2345 2544
             "replace": {
2346 2545
                 "symfony/browser-kit": "self.version",
@@ -2380,9 +2579,9 @@
2380 2579
             },
2381 2580
             "require-dev": {
2382 2581
                 "doctrine/data-fixtures": "1.0.*",
2383
-                "doctrine/dbal": ">=2.2,<3.0",
2384
-                "doctrine/orm": ">=2.2,<3.0,>=2.2.3",
2385
-                "monolog/monolog": ">=1.3,<2.0",
2582
+                "doctrine/dbal": "~2.2",
2583
+                "doctrine/orm": "~2.2,>=2.2.3",
2584
+                "monolog/monolog": "~1.3",
2386 2585
                 "propel/propel1": "1.6.*"
2387 2586
             },
2388 2587
             "type": "library",
@@ -2419,7 +2618,7 @@
2419 2618
             "keywords": [
2420 2619
                 "framework"
2421 2620
             ],
2422
-            "time": "2013-06-19 12:09:49"
2621
+            "time": "2013-07-15 12:28:01"
2423 2622
         },
2424 2623
         {
2425 2624
             "name": "twig/extensions",
@@ -2534,7 +2733,7 @@
2534 2733
             },
2535 2734
             "require": {
2536 2735
                 "pagerfanta/pagerfanta": "1.0.*",
2537
-                "symfony/framework-bundle": ">=2.1,<3.0"
2736
+                "symfony/framework-bundle": "~2.1"
2538 2737
             },
2539 2738
             "type": "symfony-bundle",
2540 2739
             "extra": {
@@ -2585,7 +2784,10 @@
2585 2784
         "pagerfanta/pagerfanta": 20,
2586 2785
         "shtumi/useful-bundle": 20,
2587 2786
         "sonata-project/jquery-bundle": 20,
2588
-        "friendsofsymfony/facebook-bundle": 20
2787
+        "friendsofsymfony/facebook-bundle": 20,
2788
+        "doctrine/mongodb-odm-bundle": 10,
2789
+        "doctrine/mongodb-odm": 10,
2790
+        "doctrine/mongodb": 10
2589 2791
     },
2590 2792
     "platform": {
2591 2793
         "php": ">=5.3.3"

BIN
composer.phar Целия файл


+ 193 - 0
src/Muzich/CoreBundle/Command/MineTagsDataCommand.php Целия файл

@@ -0,0 +1,193 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Command;
4
+
5
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
+use Symfony\Component\Console\Input\InputInterface;
7
+use Symfony\Component\Console\Input\InputOption;
8
+use Symfony\Component\Console\Output\OutputInterface;
9
+use Muzich\CoreBundle\Mining\Tag\TagMiner;
10
+use Doctrine\ORM\QueryBuilder;
11
+use Muzich\CoreBundle\Entity\User;
12
+
13
+class MineTagsDataCommand extends ContainerAwareCommand
14
+{
15
+  
16
+  const MINE_DIFFUSION = 'diffusion';
17
+  const MINE_FAVORITE = 'favorite';
18
+  const MINE_PLAYLIST = 'playlist';
19
+  const MINE_TAGS = 'tags';
20
+  
21
+  static $mine_types = array(
22
+    self::MINE_DIFFUSION,
23
+    self::MINE_FAVORITE,
24
+    self::MINE_PLAYLIST,
25
+    self::MINE_TAGS
26
+  );
27
+  
28
+  protected $em;
29
+  protected $tag_miner;
30
+  protected $input;
31
+  protected $output;
32
+  protected $progress;
33
+  protected $users_mineds = array();
34
+  
35
+  protected function configure()
36
+  {
37
+    $this
38
+      ->setName('mining:tags')
39
+      ->setDescription('Mine tags data')
40
+      ->addOption('all', null, InputOption::VALUE_NONE, 'Selectionne tous les utilisateurs')
41
+      ->addOption(self::MINE_DIFFUSION, null, InputOption::VALUE_NONE, 'Ne traite que les diffusions')
42
+      ->addOption(self::MINE_FAVORITE, null, InputOption::VALUE_NONE, 'Ne traite que les favoris')
43
+      ->addOption(self::MINE_PLAYLIST, null, InputOption::VALUE_NONE, 'Ne traite que les playlists')
44
+      ->addOption(self::MINE_TAGS, null, InputOption::VALUE_NONE, 'Ne traite que les tags')
45
+    ;
46
+  }
47
+  
48
+  /** @return TagMiner */
49
+  protected function getTagMiner()
50
+  {
51
+    return $this->tag_miner;
52
+  }
53
+  
54
+  /** @return \Doctrine\ORM\EntityManager */
55
+  protected function getEntityManager()
56
+  {
57
+    return $this->em;
58
+  }
59
+
60
+  protected function init(InputInterface $input, OutputInterface $output)
61
+  {
62
+    $this->em = $this->getContainer()->get('doctrine')->getEntityManager();
63
+    $this->tag_miner = $this->getContainer()->get('muzich.mining.tag.miner');
64
+    
65
+    // Experimental
66
+    $this->tag_miner->setLogger($this);
67
+    
68
+    $this->progress = $this->getHelperSet()->get('progress');
69
+    $this->input = $input;
70
+    $this->output = $output;
71
+  }
72
+  
73
+  protected function execute(InputInterface $input, OutputInterface $output)
74
+  {
75
+    $this->init($input, $output);
76
+    
77
+    if ($this->canIMineThat(self::MINE_DIFFUSION))
78
+      $this->mineDiffusions();
79
+    
80
+    if ($this->canIMineThat(self::MINE_FAVORITE))
81
+      $this->mineFavorites();
82
+    
83
+    if ($this->canIMineThat(self::MINE_PLAYLIST))
84
+      $this->minePlaylists();
85
+    
86
+    if ($this->canIMineThat(self::MINE_TAGS))
87
+      $this->mineTags();
88
+    
89
+    $this->output->writeln('<info>Terminé !</info>');
90
+  }
91
+  
92
+  /** @return QueryBuilder */
93
+  protected function getUserQueryBuilder()
94
+  {
95
+    $user_query_builder = $this->getEntityManager()->createQueryBuilder()
96
+      ->from('MuzichCoreBundle:User', 'user');
97
+    $this->tag_miner->adaptQueryBuilderSelectorsForUser($user_query_builder, 'user');
98
+    
99
+    return $user_query_builder;
100
+  }
101
+  
102
+  protected function mineDiffusions()
103
+  {
104
+    $users = $this->getUsersToProceed(User::DATA_DIFF_UPDATED);
105
+    $this->output->writeln('<info>Diffusions: '.count($users).' utilisateurs</info>');
106
+    $this->progress->start($this->output, count($users));
107
+    $this->getTagMiner()->mineDiffusionTagsForUsers($users);
108
+    $this->addUsersToUsersMineds($users);
109
+  }
110
+  
111
+  protected function mineFavorites()
112
+  {
113
+    $users = $this->getUsersToProceed(User::DATA_FAV_UPDATED);
114
+    $this->output->writeln('<info>Favoris: '.count($users).' utilisateurs</info>');
115
+    $this->progress->start($this->output, count($users));
116
+    $this->getTagMiner()->mineFavoriteTagsForUsers($users);
117
+    $this->addUsersToUsersMineds($users);
118
+  }
119
+  
120
+  protected function minePlaylists()
121
+  {
122
+    $users = $this->getUsersToProceed(User::DATA_PLAY_UPDATED);
123
+    $this->output->writeln('<info>Playlists: '.count($users).' utilisateurs</info>');
124
+    $this->progress->start($this->output, count($users));
125
+    $this->getTagMiner()->minePlaylistTagsForUsers($users);
126
+    $this->addUsersToUsersMineds($users);
127
+  }
128
+  
129
+  protected function mineTags()
130
+  {
131
+    $this->output->writeln('<info>Tags: '.count($this->users_mineds).' utilisateurs</info>');
132
+    $this->progress->start($this->output, count($this->users_mineds));
133
+    $this->getTagMiner()->mineTagsForUsers($this->users_mineds);
134
+  }
135
+  
136
+  protected function getUsersToProceed($condition)
137
+  {
138
+    $users_query_builder = $this->getUserQueryBuilder();
139
+    if (!$this->input->getOption('all'))
140
+    {
141
+      $users_query_builder->andWhere('user.datas NOT LIKE :condition OR user.datas IS NULL');
142
+      $users_query_builder->setParameter('condition', '%"'.$condition.'":false%');
143
+    }
144
+    
145
+    return $users_query_builder->getQuery()->getResult();
146
+  }
147
+  
148
+  protected function canIMineThat($mine_type_asked)
149
+  {
150
+    $mine_type_specified = false;
151
+    foreach (self::$mine_types as $mine_type)
152
+    {
153
+      if ($this->input->getOption($mine_type))
154
+        $mine_type_specified = true;
155
+    }
156
+    
157
+    if (!$mine_type_specified)
158
+      return true;
159
+    
160
+    if ($this->input->getOption($mine_type_asked))
161
+      return true;
162
+    
163
+    return false;
164
+  }
165
+  
166
+  public function logUserProceed()
167
+  {
168
+    $this->progress->advance();
169
+  }
170
+  
171
+  public function logSavingInDatabase()
172
+  {
173
+    $this->output->writeln('');
174
+    $this->output->writeln('<info>Saving in database ...</info>');
175
+  }
176
+  
177
+  protected function addUsersToUsersMineds($users_to_add)
178
+  {
179
+    foreach ($users_to_add as $user_to_add)
180
+    {
181
+      $found = false;
182
+      foreach ($this->users_mineds as $user_mined)
183
+      {
184
+        if ($user_mined->getId() == $user_to_add->getId())
185
+          $found = true;
186
+      }
187
+      
188
+      if (!$found)
189
+        $this->users_mineds[] = $user_to_add;
190
+    }
191
+  }
192
+  
193
+}

+ 0 - 135
src/Muzich/CoreBundle/Command/TagOrderCommand.php Целия файл

@@ -1,135 +0,0 @@
1
-<?php
2
-
3
-namespace Muzich\CoreBundle\Command;
4
-
5
-use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
-use Symfony\Component\Console\Input\InputArgument;
7
-use Symfony\Component\Console\Input\InputInterface;
8
-use Symfony\Component\Console\Input\InputOption;
9
-use Symfony\Component\Console\Output\OutputInterface;
10
-
11
-use Muzich\CoreBundle\Entity\User;
12
-use Muzich\CoreBundle\Searcher\ElementSearcher;
13
-use Muzich\CoreBundle\lib\Tag as TagLib;
14
-
15
-class TagOrderCommand extends ContainerAwareCommand
16
-{
17
-  protected function configure()
18
-  {
19
-    $this
20
-      ->setName('tagengine:order')
21
-      ->setDescription('Ordonne la liste des tags sur les pages utilisateurs')
22
-      ->addOption('force', null, InputOption::VALUE_NONE, 'Forcer les opérations sur tous les utilisateurs')
23
-    ;
24
-  }
25
-  
26
-  protected function execute(InputInterface $input, OutputInterface $output)
27
-  {
28
-    $doctrine = $this->getContainer()->get('doctrine');
29
-    $em = $doctrine->getEntityManager();
30
-    $tag_lib = new TagLib();
31
-
32
-    $output->writeln('#');
33
-    $output->writeln('## Script d\'ordonance des listes de tags sur les pages'
34
-      .' utilisateurs ##');
35
-    $output->writeln('#');
36
-
37
-    // Premier point on récupère les utilisateurs qui ont mis a jour leurs 
38
-    // favoris
39
-    $output->writeln('<info>Gestion de l\'ordre des tags sur les pages de '
40
-      .'partages favoris</info>');
41
- 
42
-    if ($input->getOption('force'))
43
-    {
44
-      $users = $em->createQuery("SELECT u FROM MuzichCoreBundle:User u")
45
-        ->getResult()
46
-      ;
47
-    }
48
-    else
49
-    {
50
-      $users = $em->createQuery(
51
-          "SELECT u FROM MuzichCoreBundle:User u"
52
-          . " WHERE u.datas LIKE :favupd"
53
-        )->setParameter('favupd', '%"'.User::DATA_FAV_UPDATED.'":true%')
54
-        ->getResult()
55
-      ;
56
-    }
57
-    
58
-    if (count($users))
59
-    {
60
-      $output->writeln('<info>Traitement de '.count($users).' utilisateurs</info>');
61
-      foreach ($users as $user)
62
-      {
63
-        // On récupère ses éléments favoris
64
-        $search_object = new ElementSearcher();
65
-        $search_object->init(array(
66
-          'user_id'  => $user->getId(),
67
-          'favorite' => true
68
-        ));
69
-        $elements_favorite = $search_object->getElements($doctrine, $user->getId());
70
-        
71
-        // On récupère la nouvelle liste de tags ordonnés
72
-        $tags_ordered = $tag_lib->getOrderedTagsWithElements($elements_favorite);
73
-        // On enregistre ça en base
74
-        $user->setData(User::DATA_TAGS_ORDER_PAGE_FAV, $tags_ordered);
75
-        $user->setData(User::DATA_FAV_UPDATED, false);
76
-        $em->persist($user);
77
-        $em->flush();
78
-      }
79
-    
80
-    }
81
-    else
82
-    {
83
-      $output->writeln('<info>Aucun utilisateur a traiter</info>');
84
-    }
85
-    
86
-    // Deuxième point on récupère les utilisateurs qui ont mis a jour leurs 
87
-    // diffusion
88
-    $output->writeln('<info>Gestion de l\'ordre des tags sur les diffusions</info>');
89
- 
90
-    if ($input->getOption('force'))
91
-    {
92
-      $users = $em->createQuery("SELECT u FROM MuzichCoreBundle:User u")
93
-        ->getResult()
94
-      ;
95
-    }
96
-    else
97
-    {
98
-      $users = $em->createQuery(
99
-          "SELECT u FROM MuzichCoreBundle:User u"
100
-          . " WHERE u.datas LIKE :favupd"
101
-        )->setParameter('favupd', '%"'.User::DATA_DIFF_UPDATED.'":true%')
102
-        ->getResult()
103
-      ;
104
-    }
105
-    
106
-    if (count($users))
107
-    {
108
-      $output->writeln('<info>Traitement de '.count($users).' utilisateurs</info>');
109
-      foreach ($users as $user)
110
-      {
111
-        // On récupère ses éléments diffusés
112
-        $search_object = new ElementSearcher();
113
-        $search_object->init(array(
114
-          'user_id'  => $user->getId()
115
-        ));
116
-        $elements_diffused = $search_object->getElements($doctrine, $user->getId());
117
-        
118
-        // On récupère la nouvelle liste de tags ordonnés
119
-        $tags_ordered = $tag_lib->getOrderedTagsWithElements($elements_diffused);
120
-        // On enregistre ça en base
121
-        $user->setData(User::DATA_TAGS_ORDER_DIFF, $tags_ordered);
122
-        $user->setData(User::DATA_DIFF_UPDATED, false);
123
-        $em->persist($user);
124
-        $em->flush();
125
-      }
126
-    
127
-    }
128
-    else
129
-    {
130
-      $output->writeln('<info>Aucun utilisateur a traiter</info>');
131
-    }
132
-    
133
-    $output->writeln('<info>Terminé !</info>');
134
-  }
135
-}

+ 0 - 4
src/Muzich/CoreBundle/Controller/ElementController.php Целия файл

@@ -218,10 +218,6 @@ class ElementController extends Controller
218 218
       $em->persist($element->getOwner());
219 219
       $em->remove($element);
220 220
       
221
-      /**
222
-      * Bug lors des tests: L'user n'est pas 'lié' a celui en base par doctrine.
223
-      * Docrine le voit si on faire une requete directe.
224
-      */
225 221
       $user = $this->getUser();
226 222
       
227 223
       // On signale que cet user a modifié ses diffusions

+ 57 - 0
src/Muzich/CoreBundle/Document/EntityTags.php Целия файл

@@ -0,0 +1,57 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Document;
3
+
4
+use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
5
+
6
+/**
7
+ * @MongoDB\MappedSuperclass
8
+ */
9
+class EntityTags
10
+{
11
+  
12
+  const TYPE_USER = 'User';
13
+  const TYPE_GROUP = 'Group';
14
+  const TYPE_PLAYLIST = 'Playlist';
15
+  
16
+  /**
17
+   * @MongoDB\Id
18
+   */
19
+  protected $id;
20
+
21
+  /**
22
+   * @MongoDB\Int
23
+   * @MongoDB\Index(unique=true) 
24
+   */
25
+  protected $ref;
26
+
27
+  /**
28
+   * @MongoDB\Collection
29
+   */
30
+  protected $tags;
31
+
32
+  public function getId()
33
+  {
34
+    return $this->id;
35
+  }
36
+
37
+  public function getRef()
38
+  {
39
+    return $this->ref;
40
+  }
41
+
42
+  public function setRef($ref)
43
+  {
44
+    $this->ref = (int)$ref;
45
+  }
46
+
47
+  public function getTags()
48
+  {
49
+    return $this->tags;
50
+  }
51
+  
52
+  public function setTags($tags)
53
+  {
54
+    $this->tags = $tags;
55
+  }
56
+  
57
+}

+ 13 - 0
src/Muzich/CoreBundle/Document/GroupTags.php Целия файл

@@ -0,0 +1,13 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Document;
3
+
4
+use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
5
+use Muzich\CoreBundle\Document\EntityTags;
6
+
7
+/**
8
+ * @MongoDB\Document
9
+ */
10
+class GroupTags extends EntityTags
11
+{
12
+
13
+}

+ 13 - 0
src/Muzich/CoreBundle/Document/PlaylistTags.php Целия файл

@@ -0,0 +1,13 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Document;
3
+
4
+use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
5
+use Muzich\CoreBundle\Document\EntityTags;
6
+
7
+/**
8
+ * @MongoDB\Document
9
+ */
10
+class PlaylistTags extends EntityTags
11
+{
12
+
13
+}

+ 67 - 0
src/Muzich/CoreBundle/Document/UserTags.php Целия файл

@@ -0,0 +1,67 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Document;
3
+
4
+use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
5
+use Muzich\CoreBundle\Document\EntityTags;
6
+
7
+/**
8
+ * @MongoDB\Document
9
+ */
10
+class UserTags extends EntityTags
11
+{
12
+
13
+  /**
14
+   * @MongoDB\Collection
15
+   */
16
+  protected $element_diffusion_tags;
17
+
18
+  /**
19
+   * @MongoDB\Collection
20
+   */
21
+  protected $element_favorite_tags;
22
+
23
+  /**
24
+   * @MongoDB\Collection
25
+   */
26
+  protected $element_playlist_tags;
27
+  
28
+  public function getElementDiffusionTags()
29
+  {
30
+    if (!$this->element_diffusion_tags)
31
+      return array();
32
+      
33
+    return $this->element_diffusion_tags;
34
+  }
35
+  
36
+  public function setElementDiffusionTags($tags)
37
+  {
38
+    $this->element_diffusion_tags = $tags;
39
+  }
40
+  
41
+  public function getElementFavoriteTags()
42
+  {
43
+    if (!$this->element_favorite_tags)
44
+      return array();
45
+      
46
+    return $this->element_favorite_tags;
47
+  }
48
+  
49
+  public function setElementFavoriteTags($tags)
50
+  {
51
+    $this->element_favorite_tags = $tags;
52
+  }
53
+  
54
+  public function getElementPlaylistTags()
55
+  {
56
+    if (!$this->element_playlist_tags)
57
+      return array();
58
+      
59
+    return $this->element_playlist_tags;
60
+  }
61
+  
62
+  public function setElementPlaylistTags($tags)
63
+  {
64
+    $this->element_playlist_tags = $tags;
65
+  }
66
+  
67
+}

+ 45 - 23
src/Muzich/CoreBundle/Entity/User.php Целия файл

@@ -25,29 +25,9 @@ use Muzich\CoreBundle\Managers\UserPrivacy as PrivacyManager;
25 25
 class User extends BaseUser
26 26
 {
27 27
   
28
-  /**
29
-   * Data ordre des tags de sa page favoris
30
-   * @var string 
31
-   */
32
-  const DATA_TAGS_ORDER_PAGE_FAV = "data_tags_order_page_fav";
33
-  
34
-  /**
35
-   * Data ordre des tags de ses diffusions
36
-   * @var string 
37
-   */
38
-  const DATA_TAGS_ORDER_DIFF     = "data_tags_order_diff";
39
-  
40
-  /**
41
-   * Data, les favoris ont ils été modifiés
42
-   * @var string 
43
-   */
44
-  const DATA_FAV_UPDATED         = "data_fav_updated";
45
-  
46
-  /**
47
-   * Data, les favoris ont ils été modifiés
48
-   * @var string 
49
-   */
50
-  const DATA_DIFF_UPDATED        = "data_diff_updated";
28
+  const DATA_FAV_UPDATED = "data_fav_updated";
29
+  const DATA_DIFF_UPDATED = "data_diff_updated";
30
+  const DATA_PLAY_UPDATED = "data_play_updated";
51 31
   
52 32
   const HELP_TOUR_HOME = "home";
53 33
   
@@ -375,6 +355,20 @@ class User extends BaseUser
375 355
   {
376 356
     return $this->elements_favorites;
377 357
   }
358
+  
359
+  public function getElementsFavoritesElements()
360
+  {
361
+    if (!$this->elements_favorites)
362
+      return new ArrayCollection();
363
+    
364
+    $elements = array();
365
+    foreach ($this->elements_favorites as $element_favorite)
366
+    {
367
+      $elements[] = $element_favorite->getElement();
368
+    }
369
+    
370
+    return $elements;
371
+  }
378 372
 
379 373
   /**
380 374
    * Add elements
@@ -904,6 +898,19 @@ class User extends BaseUser
904 898
     return json_decode($this->tags_favorites_quick, true);
905 899
   }
906 900
   
901
+  public function getTagsFavoritesQuickIds()
902
+  {
903
+    $tags_favorites_ids = array();
904
+    $tags_favorites_data = $this->getTagsFavoritesQuick();
905
+    
906
+    foreach ($tags_favorites_data as $tag_id => $tag_name)
907
+    {
908
+      $tags_favorites_ids[] = $tag_id;
909
+    }
910
+    
911
+    return $tags_favorites_ids;
912
+  }
913
+  
907 914
   /**
908 915
    * 
909 916
    * @param array $tags_favorites_quick (id => name)
@@ -1285,4 +1292,19 @@ class User extends BaseUser
1285 1292
     return $privacy_manager->set(PrivacyManager::CONF_FAVORITES_PUBLIC, $public);
1286 1293
   }
1287 1294
   
1295
+  public function setDataFavoriteNoMoreUpdated()
1296
+  {
1297
+    $this->setData(self::DATA_FAV_UPDATED, false);
1298
+  }
1299
+  
1300
+  public function setDataDiffusionsNoMoreUpdated()
1301
+  {
1302
+    $this->setData(self::DATA_DIFF_UPDATED, false);
1303
+  }
1304
+  
1305
+  public function setDataPlaylistNoMoreUpdated()
1306
+  {
1307
+    $this->setData(self::DATA_PLAY_UPDATED, false);
1308
+  }
1309
+  
1288 1310
 }

+ 19 - 0
src/Muzich/CoreBundle/Managers/PlaylistManager.php Целия файл

@@ -255,6 +255,25 @@ class PlaylistManager
255 255
       ->findById($playlist->getElementsIds());
256 256
   }
257 257
   
258
+  public function getElementsOfPlaylists($playlists)
259
+  {
260
+    $elements_ids = array();
261
+    
262
+    foreach ($playlists as $playlist)
263
+    {
264
+      foreach ($playlist->getElementsIds() as $element_id)
265
+      {
266
+        $elements_ids[] = $element_id;
267
+      }
268
+    }
269
+    $elements_ids = array_unique($elements_ids);
270
+    if ($elements_ids)
271
+      return $this->entity_manager->getRepository('MuzichCoreBundle:Element')
272
+      ->findById($elements_ids);
273
+    
274
+    return array();
275
+  }
276
+  
258 277
   public function addPrivateLinks(Playlist $playlist, User $user, $links, Container $container)
259 278
   {
260 279
     // Pour le moment on le fait ici car le ElementManager est mal pensé.

+ 39 - 0
src/Muzich/CoreBundle/Mining/Tag/Tag.php Целия файл

@@ -0,0 +1,39 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Mining\Tag;
3
+
4
+use Doctrine\ORM\EntityManager;
5
+use Doctrine\Bundle\MongoDBBundle\ManagerRegistry as MongoManagerRegistry;
6
+use Doctrine\ODM\MongoDB\DocumentRepository;
7
+use Doctrine\ODM\MongoDB\DocumentManager;
8
+
9
+class Tag
10
+{
11
+  
12
+  protected $doctrine_entity_manager;
13
+  protected $mongo_manager_registry;
14
+  
15
+  public function __construct(EntityManager $doctrine_entity_manager, MongoManagerRegistry $mongo_manager_registry)
16
+  {
17
+    $this->doctrine_entity_manager = $doctrine_entity_manager;
18
+    $this->mongo_manager_registry = $mongo_manager_registry;
19
+  }
20
+  
21
+  /** @return EntityManager */
22
+  protected function getDoctrineEntityManager()
23
+  {
24
+    return $this->doctrine_entity_manager;
25
+  }
26
+  
27
+  /** @return DocumentRepository */
28
+  protected function getMongoRepository($repository)
29
+  {
30
+    return $this->mongo_manager_registry->getRepository($repository);
31
+  }
32
+  
33
+  /** @return DocumentManager */
34
+  protected function getMongoManager()
35
+  {
36
+    return $this->mongo_manager_registry->getManager();
37
+  }
38
+  
39
+}

+ 39 - 0
src/Muzich/CoreBundle/Mining/Tag/TagData.php Целия файл

@@ -0,0 +1,39 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Mining\Tag;
3
+
4
+use Muzich\CoreBundle\Mining\Tag\Tag as Base;
5
+use Muzich\CoreBundle\Entity\User;
6
+
7
+class TagData extends Base
8
+{
9
+  
10
+  public function getTagOrderForFavorites(User $user)
11
+  {
12
+    $user_tags = $this->getUserTagsTags($user, 'element_favorite_tags');
13
+    
14
+   if (count($tags_ordereds = $user_tags->getElementFavoriteTags()))
15
+     return $tags_ordereds;
16
+   
17
+   return array();
18
+  }
19
+  
20
+  public function getTagOrderForDiffusions(User $user)
21
+  {
22
+    $user_tags = $this->getUserTagsTags($user, 'element_diffusion_tags');
23
+    
24
+   if (count($tags_ordereds = $user_tags->getElementDiffusionTags()))
25
+     return $tags_ordereds;
26
+   
27
+   return array();
28
+  }
29
+  
30
+  protected function getUserTagsTags(User $user, $field)
31
+  {
32
+    return $this->getMongoManager()->createQueryBuilder('MuzichCoreBundle:UserTags')
33
+      ->select($field)
34
+      ->field('ref')->equals((int)$user->getId())
35
+      ->getQuery()->getSingleResult()
36
+    ;
37
+  }
38
+  
39
+}

+ 205 - 0
src/Muzich/CoreBundle/Mining/Tag/TagMiner.php Целия файл

@@ -0,0 +1,205 @@
1
+<?php
2
+namespace Muzich\CoreBundle\Mining\Tag;
3
+
4
+use Doctrine\ORM\EntityManager;
5
+use Doctrine\Bundle\MongoDBBundle\ManagerRegistry as MongoManagerRegistry;
6
+use Muzich\CoreBundle\Document\EntityTags;
7
+use Muzich\CoreBundle\Document\UserTags;
8
+use Muzich\CoreBundle\Document\GroupTags;
9
+use Muzich\CoreBundle\Document\PlaylistTags;
10
+use Doctrine\ORM\QueryBuilder;
11
+use Muzich\CoreBundle\lib\Tag as TagOrderer;
12
+use Muzich\CoreBundle\lib\TagScorer;
13
+use Muzich\CoreBundle\Entity\User;
14
+use Muzich\CoreBundle\Managers\PlaylistManager;
15
+
16
+use Muzich\CoreBundle\Mining\Tag\Tag as Base;
17
+
18
+class TagMiner extends Base
19
+{
20
+  
21
+  protected $tag_scorer;
22
+  protected $tag_orderer;
23
+  protected $logger_parent;
24
+  
25
+  public function __construct(EntityManager $doctrine_entity_manager, MongoManagerRegistry $mongo_manager_registry)
26
+  {
27
+    parent::__construct($doctrine_entity_manager, $mongo_manager_registry);
28
+    $this->tag_scorer = new TagScorer();
29
+    $this->tag_orderer = new TagOrderer();
30
+  }
31
+  
32
+  /** @return TagScorer */
33
+  protected function getTagsScorer()
34
+  {
35
+    return $this->tag_scorer;
36
+  }
37
+  
38
+  /** @return TagOrderer */
39
+  protected function getTagOrderer()
40
+  {
41
+    return $this->tag_orderer;
42
+  }
43
+  
44
+  // Experimental
45
+  public function setLogger($parent)
46
+  {
47
+    $this->logger_parent = $parent;
48
+  }
49
+  
50
+  // Experimental
51
+  protected function log($action_name)
52
+  {
53
+    $action_name_complete = 'log'.ucfirst($action_name);
54
+    
55
+    if ($this->logger_parent)
56
+      $this->logger_parent->$action_name_complete();
57
+  }
58
+  
59
+  /** 
60
+   * @param QueryBuilder $query_builder
61
+   * @param string $user_alias
62
+   */
63
+  public function adaptQueryBuilderSelectorsForUser(QueryBuilder $query_builder, $user_alias = 'user')
64
+  {
65
+    // Adapt query builder to necessary data in mining
66
+    $query_builder->leftJoin($user_alias.'.elements', 'element_owned');
67
+    $query_builder->leftJoin('element_owned.tags', 'element_owned_tags');
68
+    
69
+    $query_builder->leftJoin($user_alias.'.elements_favorites', 'element_favorite');
70
+    $query_builder->leftJoin('element_favorite.element', 'element_favorite_element');
71
+    
72
+    $query_builder->select($user_alias.', element_owned, element_owned_tags, element_favorite');
73
+    
74
+  }
75
+  
76
+  /**
77
+   * @param array $users
78
+   */
79
+  public function mineForUsers($users, $mining_action, $user_action = null)
80
+  {
81
+    if (count($users))
82
+    {
83
+      foreach ($users as $user)
84
+      {
85
+        $user_tags = $this->getEntityTagsDocument($user->getId(), EntityTags::TYPE_USER);
86
+
87
+        $this->log('userProceed');
88
+        $this->$mining_action($user_tags, $user);
89
+        if ($user_action)
90
+          $user->$user_action();
91
+
92
+        $this->getMongoManager()->persist($user_tags);
93
+        $this->getDoctrineEntityManager()->persist($user);
94
+      }
95
+      
96
+      $this->log('savingInDatabase');
97
+      $this->getMongoManager()->flush();
98
+      $this->getDoctrineEntityManager()->flush();
99
+    }
100
+  }
101
+  
102
+  public function mineDiffusionTagsForUsers($users)
103
+  {
104
+    $this->mineForUsers($users, 'orderUserDiffusionsTags', 'setDataDiffusionsNoMoreUpdated');
105
+  }
106
+  
107
+  public function mineFavoriteTagsForUsers($users)
108
+  {
109
+    $this->mineForUsers($users, 'orderUserFavoritesTags', 'setDataFavoriteNoMoreUpdated');
110
+  }
111
+  
112
+  public function minePlaylistTagsForUsers($users)
113
+  {
114
+    $this->mineForUsers($users, 'orderUserPlaylistsTags', 'setDataPlaylistNoMoreUpdated');
115
+  }
116
+  
117
+  public function mineTagsForUsers($users)
118
+  {
119
+    $this->mineForUsers($users, 'orderUserTags');
120
+  }
121
+  
122
+  /** @return EntityTags */
123
+  protected function getEntityTagsDocument($ref, $type)
124
+  {
125
+    if (!($user_tags = $this->getMongoManager()->createQueryBuilder('MuzichCoreBundle:'.$type.'Tags')
126
+      ->field('ref')->equals((int)$ref)
127
+      ->getQuery()->getSingleResult()
128
+    ))
129
+    {
130
+      $user_tags = $this->getObjectTypeTags($type);
131
+      $user_tags->setRef($ref);
132
+    }
133
+    
134
+    return $user_tags;
135
+  }
136
+  
137
+  /** @return EntityTags */
138
+  protected function getObjectTypeTags($type)
139
+  {
140
+    switch ($type)
141
+    {
142
+      case EntityTags::TYPE_USER:
143
+        return new UserTags();
144
+      break;
145
+      case EntityTags::TYPE_GROUP:
146
+        return new GroupTags();
147
+      break;
148
+      case EntityTags::TYPE_PLAYLIST:
149
+        return new PlaylistTags();
150
+      break;
151
+    }
152
+  }
153
+  
154
+  protected function orderUserDiffusionsTags(EntityTags $user_tags, User $user)
155
+  {
156
+    $tags_ids_ordereds = $this->getTagOrderer()->getOrderedTagsWithElements($user->getElements());
157
+    $user_tags->setElementDiffusionTags($tags_ids_ordereds);
158
+  }
159
+  
160
+  protected function orderUserFavoritesTags(EntityTags $user_tags, User $user)
161
+  {
162
+    $tags_ids_ordereds = $this->getTagOrderer()->getOrderedTagsWithElements($user->getElementsFavoritesElements());
163
+    $user_tags->setElementFavoriteTags($tags_ids_ordereds);
164
+  }
165
+  
166
+  protected function orderUserPlaylistsTags(EntityTags $user_tags, User $user)
167
+  {
168
+    $playlist_manager = new PlaylistManager($this->getDoctrineEntityManager());
169
+    $tags_ids_ordereds = $this->getTagOrderer()->getOrderedTagsWithElements($playlist_manager->getElementsOfPlaylists($this->getUserPlaylists($user)));
170
+    $user_tags->setElementPlaylistTags($tags_ids_ordereds);
171
+  }
172
+  
173
+  protected function getUserPlaylists(User $user)
174
+  {
175
+    $playlists = $user->getPlaylistsOwneds();
176
+    foreach ($user->getPickedsPlaylists() as $picked_playlist)
177
+    {
178
+      $found = false;
179
+      foreach ($playlists as $playlist)
180
+      {
181
+        if ($playlist->getId() == $picked_playlist->getId())
182
+        {
183
+          $found = true;
184
+        }
185
+      }
186
+      
187
+      if (!$found)
188
+        $playlists[] = $picked_playlist;
189
+    }
190
+    
191
+    return $playlists;
192
+  }
193
+  
194
+  protected function orderUserTags(EntityTags $user_tags, User $user)
195
+  {
196
+    $all_tags_ordered = $this->getTagsScorer()->scoreEntireOrderedTagsIds(array(
197
+      $user_tags->getElementDiffusionTags(),
198
+      $user_tags->getElementFavoriteTags(),
199
+      $user_tags->getElementPlaylistTags()
200
+    ), $user->getTagsFavoritesQuickIds());
201
+    
202
+    $user_tags->setTags($all_tags_ordered);
203
+  }
204
+  
205
+}

+ 24 - 0
src/Muzich/CoreBundle/lib/Controller.php Целия файл

@@ -531,6 +531,18 @@ class Controller extends BaseController
531 531
     return $this->getDoctrine()->getManager();
532 532
   }
533 533
   
534
+  /** @return Doctrine\ODM\MongoDB\DocumentManager */
535
+  public function getMongoManager()
536
+  {
537
+    return $this->get('doctrine_mongodb')->getManager();
538
+  }
539
+  
540
+  /** @return Doctrine\ODM\MongoDB\DocumentRepository */
541
+  public function getMongoRepository($repository)
542
+  {
543
+    return $this->get('doctrine_mongodb')->getRepository($repository);
544
+  }
545
+  
534 546
   /**
535 547
    *
536 548
    * @param object $entity 
@@ -723,4 +735,16 @@ class Controller extends BaseController
723 735
     return $this->container->get('muzich_user_manager');
724 736
   }
725 737
   
738
+  /** @return \Muzich\CoreBundle\Mining\Tag\TagMiner */
739
+  protected function getMineTagMiner()
740
+  {
741
+    return $this->container->get('muzich.mining.tag.miner');
742
+  }
743
+  
744
+  /** @return \Muzich\CoreBundle\Mining\Tag\TagData */
745
+  protected function getMineTagData()
746
+  {
747
+    return $this->container->get('muzich.mining.tag.data');
748
+  }
749
+  
726 750
 }

+ 57 - 0
src/Muzich/CoreBundle/lib/TagScorer.php Целия файл

@@ -0,0 +1,57 @@
1
+<?php
2
+
3
+namespace Muzich\CoreBundle\lib;
4
+
5
+class TagScorer
6
+{
7
+  
8
+  protected function scoreOrderedsTagsIds($ordered_tags)
9
+  {
10
+    $tags_ordered_by_score = array();
11
+    $score_max = count($ordered_tags);
12
+    
13
+    foreach ($ordered_tags as $tag_id)
14
+    {
15
+      $tags_ordered_by_score[(int)$score_max] = $tag_id;
16
+      $score_max -= 1;
17
+    }
18
+    
19
+    return $tags_ordered_by_score;
20
+  }
21
+  
22
+  public function scoreEntireOrderedTagsIds($ordereds_elements_tags_ids, $favoriteds_tags)
23
+  {
24
+    $tags_score = array();
25
+    
26
+    foreach ($ordereds_elements_tags_ids as $ordereds_tags_ids)
27
+    {
28
+      $scored_tags_ids = $this->scoreOrderedsTagsIds($ordereds_tags_ids);
29
+      foreach ($scored_tags_ids as $score_tag => $tag_id)
30
+      {
31
+        if (!array_key_exists($tag_id, $tags_score))
32
+          $tags_score[$tag_id] = 0;
33
+        
34
+        $tags_score[$tag_id] += $score_tag;
35
+      }
36
+    }
37
+    
38
+    foreach ($favoriteds_tags as $favorite_tag_id)
39
+    {
40
+      if (!array_key_exists($favorite_tag_id, $tags_score))
41
+        $tags_score[$favorite_tag_id] = 0;
42
+        
43
+      $tags_score[$favorite_tag_id] += 5;
44
+    }
45
+        
46
+    arsort($tags_score);
47
+    
48
+    $oredered_tags_ids_without_score = array();
49
+    foreach ($tags_score as $tag_id => $tag_score)
50
+    {
51
+      $oredered_tags_ids_without_score[] = $tag_id;
52
+    }
53
+    
54
+    return $oredered_tags_ids_without_score;
55
+  }
56
+  
57
+}

+ 4 - 2
src/Muzich/FavoriteBundle/Controller/FavoriteController.php Целия файл

@@ -176,8 +176,7 @@ class FavoriteController extends Controller
176 176
     
177 177
     // Organisation des tags en fonction de leurs utilisation
178 178
     $tag_lib = new TagLib();
179
-    $tags = $tag_lib->sortTagWithOrderedReference($tags, 
180
-      $user->getData(User::DATA_TAGS_ORDER_PAGE_FAV, array()));
179
+    $tags = $tag_lib->sortTagWithOrderedReference($tags, $this->getMineTagData()->getTagOrderForFavorites($user));
181 180
     
182 181
     $tags_id = array();
183 182
     foreach ($tags as $tag)
@@ -218,6 +217,9 @@ class FavoriteController extends Controller
218 217
         ->getTags($viewed_user->getId(), $this->getUserId(true))      
219 218
       ;
220 219
 
220
+      $tag_lib = new TagLib();
221
+      $tags = $tag_lib->sortTagWithOrderedReference($tags, $this->getMineTagData()->getTagOrderForFavorites($viewed_user));
222
+      
221 223
       $tags_id = array();
222 224
       foreach ($tags as $tag)
223 225
       {

+ 1 - 2
src/Muzich/HomeBundle/Controller/ShowController.php Целия файл

@@ -34,8 +34,7 @@ class ShowController extends Controller
34 34
     
35 35
     // Organisation des tags en fonction de leurs utilisation
36 36
     $tag_lib = new TagLib();
37
-    $tags = $tag_lib->sortTagWithOrderedReference($tags, 
38
-    $viewed_user->getData(User::DATA_TAGS_ORDER_DIFF, array()));
37
+    $tags = $tag_lib->sortTagWithOrderedReference($tags, $this->getMineTagData()->getTagOrderForDiffusions($viewed_user));
39 38
     
40 39
     $tags_id = array();
41 40
     foreach ($tags as $tag)

+ 9 - 0
src/Muzich/PlaylistBundle/Controller/EditController.php Целия файл

@@ -8,6 +8,7 @@ use Muzich\CoreBundle\Security\Context as SecurityContext;
8 8
 use Muzich\CoreBundle\Propagator\EventElement;
9 9
 use Muzich\CoreBundle\Form\Playlist\PrivateLinksForm;
10 10
 use Muzich\CoreBundle\Entity\Playlist;
11
+use Muzich\CoreBundle\Entity\User;
11 12
 
12 13
 class EditController extends Controller
13 14
 {
@@ -40,6 +41,7 @@ class EditController extends Controller
40 41
       return $this->jsonNotFoundResponse();
41 42
     
42 43
     $playlist_manager->removePlaylistElementWithIndex($playlist, $index);
44
+    $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
43 45
     
44 46
     $event = new EventElement($this->container);
45 47
     $event->removedFromPlaylist($element, $this->getUser(), $playlist);
@@ -77,6 +79,7 @@ class EditController extends Controller
77 79
       return $this->jsonNotFoundResponse();
78 80
     
79 81
     $playlist_manager->addElementToPlaylist($element, $playlist);
82
+    $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
80 83
     
81 84
     $event = new EventElement($this->container);
82 85
     $event->addedToPlaylist($element, $this->getUser(), $playlist);
@@ -102,6 +105,7 @@ class EditController extends Controller
102 105
       
103 106
       $event = new EventElement($this->container);
104 107
       $event->addedToPlaylist($element, $this->getUser(), $form->getData());
108
+      $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
105 109
 
106 110
       $this->persist($element);
107 111
       $this->flush();
@@ -133,6 +137,7 @@ class EditController extends Controller
133 137
     
134 138
     $event = new EventElement($this->container);
135 139
     $event->addedToPlaylist($element, $this->getUser(), $new_playlist);
140
+    $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
136 141
     
137 142
     $this->persist($element);
138 143
     $this->flush();
@@ -149,6 +154,7 @@ class EditController extends Controller
149 154
       throw $this->createNotFoundException();
150 155
     
151 156
     $this->getPlaylistManager()->deletePlaylist($playlist);
157
+    $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
152 158
     $this->flush();
153 159
     $this->setFlash('success', 'playlist.delete.success');
154 160
     
@@ -166,6 +172,7 @@ class EditController extends Controller
166 172
       throw $this->createNotFoundException();
167 173
     
168 174
     $playlist_manager->removePickedPlaylistToUser($this->getUser(), $playlist);
175
+    $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
169 176
     $this->flush();
170 177
     $this->setFlash('success', 'playlist.delete.success');
171 178
     
@@ -190,6 +197,7 @@ class EditController extends Controller
190 197
       throw $this->createNotFoundException();
191 198
     }
192 199
     $this->getPlaylistManager()->addPickedPlaylistToUser($this->getUser(), $playlist);
200
+    $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
193 201
     $this->flush();
194 202
     
195 203
     if ($this->getRequest()->isXmlHttpRequest())
@@ -212,6 +220,7 @@ class EditController extends Controller
212 220
       if ($playlist_form->isValid())
213 221
       {
214 222
         $this->persist($playlist_form->getData());
223
+        $this->getUser()->setData(User::DATA_PLAY_UPDATED, true);
215 224
         $this->flush();
216 225
         
217 226
         $this->setFlash('success', $this->trans('playlist.create.success', array(), 'flash'));