]> Raphaƫl G. Git Repositories - userbundle/blob - RapsysUserBundle.php
Set mail as last field as it may be empty
[userbundle] / RapsysUserBundle.php
1 <?php
2
3 namespace Rapsys\UserBundle;
4
5 use Symfony\Component\DependencyInjection\Container;
6 use Symfony\Component\HttpKernel\Bundle\Bundle;
7
8 class RapsysUserBundle extends Bundle {
9 /**
10 * Return bundle alias
11 *
12 * @return string The bundle alias
13 */
14 public function getAlias(): string {
15 //With namespace
16 if ($npos = strrpos(static::class, '\\')) {
17 //Set name pos
18 $npos++;
19 //Without namespace
20 } else {
21 $npos = 0;
22 }
23
24 //With trailing bundle
25 if (substr(static::class, -strlen('Bundle'), strlen('Bundle')) === 'Bundle') {
26 //Set bundle pos
27 $bpos = strlen(static::class) - $npos - strlen('Bundle');
28 //Without bundle
29 } else {
30 //Set bundle pos
31 $bpos = strlen(static::class) - $npos;
32 }
33
34 //Return underscored lowercase bundle alias
35 return Container::underscore(substr(static::class, $npos, $bpos));
36 }
37 }