-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAcfConfigLegacy.php
More file actions
71 lines (62 loc) · 1.58 KB
/
Copy pathAcfConfigLegacy.php
File metadata and controls
71 lines (62 loc) · 1.58 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
<?php namespace ProcessWire;
/**
* AcfConfigLegacy (AcfConfig module)
*
* Admin Custom Files (ProcessWire 3.x)
* Copyright (C) 2018 by Martijn Geerts
* Licensed under GNU/GPL v2, see LICENSE.TXT
*
*/
class AcfConfigLegacy extends AcfConfig implements Module {
/**
* Ready (optional)
*
* - You can use this ready method or leave it out.
* - Ready gets called before self::jsConfig
*/
public function ready() {}
/**
* Required jsConfig method
*
* @return array
*/
public function jsConfig() {
/** @var User */
$user = $this->wire('user');
/** @var User */
$config = $this->wire('config');
/** @var array */
$roles = explode("|", $user->roles->implode('|', 'name'));
$process = $this->wire('process');
$data = array(
'process' => $process->className(),
'host' => $config->httpHost,
'adminTheme' => $this->admin_theme,
'user' => array(
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'roles' => $roles,
)
);
if ($process->className() == 'ProcessPageEdit') {
$page = $this->editPage;
$data['page'] = array(
'id' => $page->id,
'name' => $page->name,
'path' => $page->path,
'parentID' => $page->parentID,
'numChildren' => $page->numChildren,
'created' => $page->created,
'modified' => $page->modified,
'createdUser' => $page->createdUser->name,
'modifiedUser' => $page->modifiedUser->name,
);
$data['template'] = $page->template->get('name');
if ($page->id) {
$data['fields'] = explode("|", $page->fields->implode('|', 'name'));
}
}
return $data;
}
}