-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDashboardController.php
More file actions
77 lines (63 loc) · 2.34 KB
/
Copy pathDashboardController.php
File metadata and controls
77 lines (63 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Created by PhpStorm.
* User: splancon
* Date: 21/01/14
* Time: 15:02
*/
namespace Bigfoot\Bundle\CoreBundle\Controller;
use Doctrine\ORM\Query;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
class DashboardController
{
use ContainerAwareTrait;
public function getBoard()
{
/*$user = $this->container->get('security.context')->getToken()->getUser();
$em = $this->container->get('doctrine');
$queryBuilder = $em->getRepository('BigfootCoreBundle:Widget')
->createQueryBuilder('w');
$queryBuilder
->join('w.parameters', 'p')
->Where('p.user = '.$user->getId().' OR '.$queryBuilder->expr()->isNull('p.user'))
->andWhere("p.name='order'")
->orderBy('p.value * 1', 'ASC');
$query = $queryBuilder->getQuery();
$query->setHint(
Query::HINT_CUSTOM_OUTPUT_WALKER,
'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
);
$tmpWidgets = $query->getResult();
$widgets = array();
foreach ($tmpWidgets as $tmpWidget) {
$widgetClass = $tmpWidget->getName();
$widget = new $widgetClass($this->container);
$widget->setTitle($tmpWidget->getTitle());
$widget->setId($tmpWidget->getId());
$queryBuilder = $em->getRepository('BigfootCoreBundle:Widget\Parameter')
->createQueryBuilder('p');
$queryBuilder
->Where('p.user = '.$user->getId().' OR '.$queryBuilder->expr()->isNull('p.user'))
->andWhere("p.widget = " . $tmpWidget->getId())
->orderBy('p.user', 'DESC');
$query = $queryBuilder->getQuery();
$params = $query->getResult();
foreach ($params as $param) {
if (!$widget->hasParam($param->getName())) {
$widget->setParam($param->getName(), $param->getValue());
}
}
$widgets[] = $widget;
}
usort($widgets, array(__CLASS__, 'sortWidgets'));
return $widgets;*/
return array();
}
static function sortWidgets($w1, $w2)
{
if ($w1->getParam('order') == $w2->getParam('order')) {
return 0;
}
return ($w1->getParam('order') < $w2->getParam('order')) ? -1 : 1;
}
}