PageFactory.php
1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace AC\Admin;
use AC;
use AC\Asset\Location;
use AC\DefaultColumnsRepository;
use AC\Deprecated\Hooks;
use AC\IntegrationRepository;
use AC\ListScreenRepository\Storage;
use AC\Renderable;
class PageFactory implements PageFactoryInterface {
/**
* @var Storage
*/
protected $storage;
/**
* @var Location\Absolute
*/
protected $location;
/**
* @var MenuFactoryInterface
*/
protected $menu_factory;
public function __construct( Storage $storage, Location\Absolute $location, MenuFactoryInterface $menu_factory ) {
$this->storage = $storage;
$this->location = $location;
$this->menu_factory = $menu_factory;
}
/**
* @param string $slug
*
* @return Renderable|null
*/
public function create( $slug ) {
switch ( $slug ) {
case Page\Help::NAME :
return new Page\Help( new Hooks(), $this->location, new View\Menu( $this->menu_factory->create( $slug ) ) );
case Page\Settings::NAME :
$page = new Page\Settings( new View\Menu( $this->menu_factory->create( $slug ) ), $this->location );
$page->add_section( new Section\General( [ new Section\Partial\ShowEditButton() ] ) )
->add_section( new Section\Restore(), 40 );
if ( ! ac_is_pro_active() ) {
$page->add_section( new Section\ProCta(), 50 );
}
return $page;
case Page\Addons::NAME :
return new Page\Addons(
$this->location,
new IntegrationRepository(),
new View\Menu( $this->menu_factory->create( $slug ) )
);
case Page\Columns::NAME :
return new Page\Columns(
$this->location,
new DefaultColumnsRepository(),
new Section\Partial\Menu(),
$this->storage,
new View\Menu( $this->menu_factory->create( $slug ) ),
new Preference\ListScreen()
);
}
return null;
}
}