Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Front/default/profile/notifications.php (1 issue)

Labels
Severity
1
<?php
2
3
use Ffcms\Templex\Url\Url;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Url. 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
5
/** @var \Ffcms\Templex\Template\Template $this */
6
/** @var \Apps\Model\Front\Profile\EntityNotificationsList $model */
7
/** @var array $pagination */
8
/** @var string $type */
9
10
$this->layout('_layouts/default', [
11
    'title' => __('My notifications'),
12
    'breadcrumbs' => [
13
        Url::to('main/index') => __('Home'),
14
        Url::to('profile/show', [\App::$User->identity()->getId()]) => __('Profile'),
15
        __('My notifications')
16
    ]
17
]);
18
?>
19
<?php $this->start('body') ?>
20
<h1><?= __('Notifications') ?></h1>
21
<hr />
22
<div class="row">
23
    <div class="col-md-12">
24
        <div class="float-right">
25
            <?= $this->listing('ul', ['class' => 'list-inline'])
26
                ->li(['link' => ['profile/notifications', ['all']], 'text' => __('All')], ['class' => 'list-inline-item'])
27
                ->li(['link' => ['profile/notifications', ['unread']], 'text' => __('Unread')], ['class' => 'list-inline-item'])
28
                ->display()
29
            ?>
30
        </div>
31
    </div>
32
</div>
33
<?php
34
if (!$model->items || count($model->items) < 1) {
35
    echo '<p class="alert alert-warning">' . __('No notifications available') . '</p>';
36
    $this->stop();
37
    return;
38
}
39
?>
40
<?php foreach ($model->items as $item): ?>
41
    <div class="notice<?= $item['new'] ? ' notice-new' : ''; ?>">
42
        <span class="badge badge-info"><?= $item['date'] ?></span> <?= $item['text'] ?>
43
    </div>
44
<?php endforeach; ?>
45
46
<?= $this->bootstrap()->pagination(['profile/notifications'], ['class' => 'pagination justify-content-center'])
47
    ->size($pagination['total'], $pagination['page'], $pagination['step'])
48
    ->display()
49
?>
50
<?php $this->stop() ?>
51