Issues (106)

1
<?php
2
3
use AbterPhp\Framework\Constant\Event;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Event. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
use AbterPhp\Framework\Constant\Module;
5
use AbterPhp\Framework\Constant\Priorities;
6
use AbterPhp\Website\Bootstrappers;
7
use AbterPhp\Website\Constant\Event as WebsiteEvent;
8
use AbterPhp\Website\Events;
9
10
return [
11
    Module::IDENTIFIER         => 'AbterPhp\Website',
12
    Module::DEPENDENCIES       => ['AbterPhp\Admin'],
13
    Module::ENABLED            => true,
14
    Module::BOOTSTRAPPERS      => [
15
        Bootstrappers\Orm\OrmBootstrapper::class,
16
        Bootstrappers\Validation\ValidatorBootstrapper::class,
17
    ],
18
    Module::CLI_BOOTSTRAPPERS  => [
19
        Bootstrappers\Database\MigrationsBootstrapper::class,
20
    ],
21
    Module::HTTP_BOOTSTRAPPERS => [
22
        Bootstrappers\Http\Views\BuildersBootstrapper::class,
23
        Bootstrappers\Template\Loader\ContentListBootstrapper::class,
24
        Bootstrappers\Template\Loader\PageCategoryBootstrapper::class,
25
    ],
26
    Module::EVENTS             => [
27
        Event::AUTH_READY            => [
28
            /** @see \AbterPhp\Website\Events\Listeners\AuthInitializer::handle */
29
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\AuthInitializer::class)],
30
        ],
31
        Event::TEMPLATE_ENGINE_READY => [
32
            /** @see \AbterPhp\Website\Events\Listeners\TemplateInitializer::handle */
33
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\TemplateInitializer::class)],
34
        ],
35
        Event::NAVIGATION_READY      => [
36
            /** @see \AbterPhp\Website\Events\Listeners\NavigationBuilder::handle */
37
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\NavigationBuilder::class)],
38
        ],
39
        Event::ENTITY_POST_CHANGE    => [
40
            /** @see \AbterPhp\Website\Events\Listeners\PageInvalidator::handle */
41
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\PageInvalidator::class)],
42
        ],
43
        Event::DASHBOARD_READY       => [
44
            /** @see \AbterPhp\Website\Events\Listeners\DashboardBuilder::handle */
45
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\DashboardBuilder::class)],
46
        ],
47
        WebsiteEvent::PAGE_VIEWED    => [
48
            /** @see \AbterPhp\Website\Events\Listeners\DraftPageChecker::handle */
49
            Priorities::NORMAL => [sprintf('%s@handle', Events\Listeners\DraftPageChecker::class)],
50
        ],
51
    ],
52
    Module::ROUTE_PATHS        => [
53
        Priorities::NORMAL       => [
54
            __DIR__ . '/admin-routes.php',
55
            __DIR__ . '/api-routes.php',
56
        ],
57
        Priorities::BELOW_NORMAL => [
58
            __DIR__ . '/website-routes.php',
59
        ],
60
    ],
61
    Module::MIGRATION_PATHS    => [
62
        Priorities::NORMAL => [
63
            realpath(__DIR__ . '/src/Databases/Migrations'),
64
        ],
65
    ],
66
    Module::RESOURCE_PATH      => realpath(__DIR__ . '/resources'),
67
    Module::ASSETS_PATHS       => [
68
        'root'         => realpath(__DIR__ . '/resources/rawassets'),
69
        'website'      => realpath(__DIR__ . '/resources/rawassets'),
70
        'admin-assets' => realpath(__DIR__ . '/resources/rawassets'),
71
    ],
72
];
73