]> Raphaël G. Git Repositories - airbundle/blob - RapsysAirBundle.php
Update fields to choose calendar
[airbundle] / RapsysAirBundle.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle;
13
14 use Symfony\Component\DependencyInjection\Container;
15 use Symfony\Component\HttpKernel\Bundle\Bundle;
16
17 class RapsysAirBundle extends Bundle {
18 /**
19 * Return bundle alias
20 *
21 * @return string The bundle alias
22 */
23 public static function getAlias(): string {
24 //With namespace
25 if ($npos = strrpos(static::class, '\\')) {
26 //Set name pos
27 $npos++;
28 //Without namespace
29 } else {
30 $npos = 0;
31 }
32
33 //With trailing bundle
34 if (substr(static::class, -strlen('Bundle'), strlen('Bundle')) === 'Bundle') {
35 //Set bundle pos
36 $bpos = strlen(static::class) - $npos - strlen('Bundle');
37 //Without bundle
38 } else {
39 //Set bundle pos
40 $bpos = strlen(static::class) - $npos;
41 }
42
43 //Return underscored lowercase bundle alias
44 return Container::underscore(substr(static::class, $npos, $bpos));
45 }
46 }