Conditions | 5 |
Paths | 5 |
Total Lines | 36 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
37 | public function getUserAvartar(UserInterface $user = null, $filter = '70x70', array $runtimeConfig = array()) |
||
38 | { |
||
39 | if (!$user) { |
||
40 | return; |
||
41 | } |
||
42 | |||
43 | if ($avatar = $user->getProfilePicture()) { |
||
44 | if (preg_match('/\/\//', $avatar)) { |
||
45 | return $avatar; |
||
46 | } |
||
47 | |||
48 | if (empty($runtimeConfig)) { |
||
49 | $runtimeConfig = array( |
||
50 | 'thumbnail' => array( |
||
51 | "size" => explode('x', $filter), |
||
52 | "mode" => 'inset', |
||
53 | ) |
||
54 | ); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * We must to define `sizing` filter first! |
||
59 | * eg. |
||
60 | * |
||
61 | * liip_imagine: |
||
62 | * filter_sets: |
||
63 | * sizing: |
||
64 | * data_loader: cmf_media_doctrine_phpcr |
||
65 | * filters: |
||
66 | * thumbnail: { size: [200, 200], mode: inset } |
||
67 | */ |
||
68 | return $this->cacheManager->getBrowserPath($avatar, 'sizing', $runtimeConfig); |
||
69 | } |
||
70 | |||
71 | return; |
||
72 | } |
||
73 | |||
82 |