Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.php-cs-fixer.cache
4 changes: 2 additions & 2 deletions capone/src/Hooks/AddBootMenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public function addBootMenuItem()
if (!$dmi) {
return;
}
$exists = self::getClass('PXEMenuOptionsManager')
$exists = (new \FOG\Managers\PXEMenuOptionsManager())
->exists('fog.capone', '', 'name');
$args = trim("mode=capone shutdown=$shutdown");
$entry = self::getClass('PXEMenuOptions')
$entry = (new \FOG\Items\PXEMenuOptions())
->set('name', 'fog.capone')
->load('name');
if (!$exists) {
Expand Down
6 changes: 3 additions & 3 deletions capone/src/Hooks/AddCaponeAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function customizeDT($arguments)
return;
}
$arguments['columns'] = [];
foreach (self::getClass('CaponeManager')
foreach ((new \FOG\Plugins\Capone\Managers\CaponeManager())
->getColumns() as $common => &$real
) {
switch ($common) {
Expand Down Expand Up @@ -139,7 +139,7 @@ public function customizeDT($arguments)
. 'sub=edit&id='
. $d
. '">'
. self::getClass('Image', $d)->get('name')
. (new \FOG\Items\Image($d))->get('name')
. '</a>';
}
];
Expand All @@ -152,7 +152,7 @@ public function customizeDT($arguments)
}
unset($real);
}
foreach (self::getClass('OSManager')
foreach ((new \FOG\Managers\OSManager())
->getColumns() as $common => &$real
) {
$arguments['columns'][] = [
Expand Down
2 changes: 1 addition & 1 deletion capone/src/Managers/CaponeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function seedSettings()
$category
]
];
$SettingManager = self::getClass('SettingManager');
$SettingManager = new \FOG\Managers\SettingManager();
$toInsert = [];
foreach ($settings as $setting) {
if (!$SettingManager->exists($setting[0], '', 'name')) {
Expand Down
8 changes: 4 additions & 4 deletions capone/src/Pages/CaponeManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function _addFields()
{
$image = filter_input(INPUT_POST, 'image');
$key = filter_input(INPUT_POST, 'key');
$imageSelector = self::getClass('ImageManager')
$imageSelector = (new \FOG\Managers\ImageManager())
->buildSelectBox($image);

$labelClass = 'col-sm-3 col-form-label';
Expand Down Expand Up @@ -149,7 +149,7 @@ function (&$serverFault) {
_('The image associated does not have a valid OS!')
);
}
$Capone = self::getClass('Capone')
$Capone = (new \FOG\Plugins\Capone\Items\Capone())
->set('imageID', $imageID)
->set('osID', $osID)
->set('key', $key);
Expand Down Expand Up @@ -180,7 +180,7 @@ public function caponeGeneral()
filter_input(INPUT_POST, 'key') ?:
$this->obj->get('key')
);
$imageSelector = self::getClass('ImageManager')
$imageSelector = (new \FOG\Managers\ImageManager())
->buildSelectBox($image);

$labelClass = 'col-sm-3 col-form-label';
Expand Down Expand Up @@ -348,7 +348,7 @@ public function globalsettings()
$actionType
);

$dmiSelector = self::getClass('DMIKeyManager')->buildSelectBox(
$dmiSelector = (new \FOG\Managers\DMIKeyManager())->buildSelectBox(
$dmifield, // Match
'dmifield', // Name of form element
'name', // Sort by
Expand Down
6 changes: 3 additions & 3 deletions helloworld/src/Pages/HelloWorldManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ function (&$serverFault) {
if (empty($name)) {
throw new \Exception(_('Please enter a name'));
}
$exists = self::getClass('HelloWorldManager')
$exists = (new \FOG\Plugins\HelloWorld\Managers\HelloWorldManager())
->exists($name);
if ($exists) {
throw new \Exception(
_('An entry already exists with this name!')
);
}
$HelloWorld = self::getClass('HelloWorld')
$HelloWorld = (new \FOG\Plugins\HelloWorld\Items\HelloWorld())
->set('name', $name)
->set('description', $description);
if (!$HelloWorld->save()) {
Expand Down Expand Up @@ -278,7 +278,7 @@ public function helloworldGeneralPost()
if (empty($name)) {
throw new \Exception(_('Please enter a name'));
}
$exists = self::getClass('HelloWorldManager')
$exists = (new \FOG\Plugins\HelloWorld\Managers\HelloWorldManager())
->exists($name);
if ($name != $this->obj->get('name')
&& $exists
Expand Down
2 changes: 1 addition & 1 deletion ldap/src/Hooks/LDAPPluginHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function checkAddUser($arguments)
$displayName = '';
$ldapAPI = 0;
foreach ($items as $ldap) {
$LDAP = self::getClass('LDAP', $ldap->id);
$LDAP = new \FOG\Plugins\LDAP\Items\LDAP($ldap->id);
$matched = $LDAP->authLDAP($user, $pass);
if (false === $matched) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion ldap/src/Items/LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ public function destroy($key = 'id')
'id'
);
foreach ($groupIds as $groupId) {
self::getClass('LDAPGroup', (int)$groupId)->destroy();
(new \FOG\Plugins\LDAP\Items\LDAPGroup((int)$groupId))->destroy();
}
}
return parent::destroy($key);
Expand Down
2 changes: 1 addition & 1 deletion ldap/src/Items/LDAPGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static function serverLinkCell($serverID)
if (!$serverID) {
return \FOG\Router\Route::EMPTY_CELL;
}
$name = self::getClass('LDAP', $serverID)->get('name');
$name = (new \FOG\Plugins\LDAP\Items\LDAP($serverID))->get('name');
// A group outliving its server should still list, not fatal.
if (!$name) {
return \FOG\Router\Route::EMPTY_CELL;
Expand Down
24 changes: 12 additions & 12 deletions ldap/src/Managers/LDAPManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function seedSettings()
$category
]
];
$SettingManager = self::getClass('SettingManager');
$SettingManager = new \FOG\Managers\SettingManager();
$toInsert = [];
foreach ($settings as $setting) {
if (!$SettingManager->exists($setting[0], '', 'name')) {
Expand Down Expand Up @@ -754,16 +754,16 @@ function () {
// Rewriting a step that anyone has already applied is invisible
// to them. Only ever append.
function () {
return self::getClass('LDAPGroupManager')->install();
return (new \FOG\Plugins\LDAP\Managers\LDAPGroupManager())->install();
},
// 6
function () {
return self::getClass('LDAPGroupRoleAssociationManager')
return (new \FOG\Plugins\LDAP\Managers\LDAPGroupRoleAssociationManager())
->install();
},
// 7
function () {
return self::getClass('LDAPGroupUserGroupAssociationManager')
return (new \FOG\Plugins\LDAP\Managers\LDAPGroupUserGroupAssociationManager())
->install();
},
// 8
Expand All @@ -782,16 +782,16 @@ function () {
// outrun the copy.
// 10
function () {
return self::getClass('LDAPGroupManager')->install();
return (new \FOG\Plugins\LDAP\Managers\LDAPGroupManager())->install();
},
// 11
function () {
return self::getClass('LDAPGroupRoleAssociationManager')
return (new \FOG\Plugins\LDAP\Managers\LDAPGroupRoleAssociationManager())
->install();
},
// 12
function () {
return self::getClass('LDAPGroupUserGroupAssociationManager')
return (new \FOG\Plugins\LDAP\Managers\LDAPGroupUserGroupAssociationManager())
->install();
},
// 13
Expand All @@ -814,7 +814,7 @@ function () {
'DROP TABLE IF EXISTS `LDAPGroupMap`',
// 17
function () {
return self::getClass('LDAPUserGrantManager')->install();
return (new \FOG\Plugins\LDAP\Managers\LDAPUserGrantManager())->install();
},
// 18
function () {
Expand Down Expand Up @@ -1009,10 +1009,10 @@ public function uninstall()
// Associations first, then the groups they point at: dropping the
// groups first would leave association rows referencing ids that no
// longer exist if either drop failed part way.
self::getClass('LDAPUserGrantManager')->uninstall();
self::getClass('LDAPGroupRoleAssociationManager')->uninstall();
self::getClass('LDAPGroupUserGroupAssociationManager')->uninstall();
self::getClass('LDAPGroupManager')->uninstall();
(new \FOG\Plugins\LDAP\Managers\LDAPUserGrantManager())->uninstall();
(new \FOG\Plugins\LDAP\Managers\LDAPGroupRoleAssociationManager())->uninstall();
(new \FOG\Plugins\LDAP\Managers\LDAPGroupUserGroupAssociationManager())->uninstall();
(new \FOG\Plugins\LDAP\Managers\LDAPGroupManager())->uninstall();
return parent::uninstall();
}
}
6 changes: 3 additions & 3 deletions ldap/src/Pages/LDAPGroupManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function (&$serverFault) {
_('That group is already defined for this server!')
);
}
$LDAPGroup = self::getClass('LDAPGroup')
$LDAPGroup = (new \FOG\Plugins\LDAP\Items\LDAPGroup())
->set('name', $name)
->set('serverID', $serverID);
if (!$LDAPGroup->save()) {
Expand Down Expand Up @@ -602,7 +602,7 @@ private static function _ownerID()
public function getRoleFeedList()
{
return $this->_feedList(
self::getClass('Role', self::_ownerID()),
new \FOG\Items\Role(self::_ownerID()),
'ldapgrouproleassociation',
'ldapGroupRoleAssoc',
'`ldapGroupRoleAssoc`.`lgraGroupID`',
Expand All @@ -618,7 +618,7 @@ public function getRoleFeedList()
public function getUserGroupFeedList()
{
return $this->_feedList(
self::getClass('UserGroup', self::_ownerID()),
new \FOG\Items\UserGroup(self::_ownerID()),
'ldapgroupusergroupassociation',
'ldapGroupUserGroupAssoc',
'`ldapGroupUserGroupAssoc`.`lgugGroupID`',
Expand Down
8 changes: 4 additions & 4 deletions ldap/src/Pages/LDAPManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,14 @@ function (&$serverFault) {
// these to reach an LDAPS directory on this server's terms.
$tls = self::_tlsFromPost();
$nested = self::_nestedFromPost($tls);
$exists = self::getClass('LDAPManager')
$exists = (new \FOG\Plugins\LDAP\Managers\LDAPManager())
->exists($ldap);
if ($exists) {
throw new \Exception(
_('An LDAP server already exists with this name!')
);
}
$LDAP = self::getClass('LDAP')
$LDAP = (new \FOG\Plugins\LDAP\Items\LDAP())
->set('name', $ldap)
->set('description', $description)
->set('address', $address)
Expand Down Expand Up @@ -1217,7 +1217,7 @@ public function ldapGeneral()
[
'fields' => &$fields,
'buttons' => &$buttons,
'LDAP' => self::getClass('LDAP')
'LDAP' => new \FOG\Plugins\LDAP\Items\LDAP()
]
);
$rendered = self::formFields($fields);
Expand Down Expand Up @@ -1317,7 +1317,7 @@ public function ldapGeneralPost()
// reach an LDAPS directory on this server's terms.
$tls = self::_tlsFromPost();
$nested = self::_nestedFromPost($tls);
$exists = self::getClass('LDAPManager')
$exists = (new \FOG\Plugins\LDAP\Managers\LDAPManager())
->exists($ldap);
if ($ldap != $this->obj->get('name')
&& $exists
Expand Down
4 changes: 2 additions & 2 deletions location/src/Hooks/AddLocationAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function addPluginItems($arguments)
if ($locID < 1) {
break;
}
$location = \FOG\Router\Route::getClass('location', $locID);
$location = new \FOG\Plugins\Location\Items\Location($locID);
if (!$location->isValid()) {
break;
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public function addPluginItems($arguments)
}
$hosts = [];
foreach ($hostIDs as $hid) {
$host = \FOG\Router\Route::getClass('host', $hid);
$host = new \FOG\Items\Host($hid);
if (!$host->isValid()) {
continue;
}
Expand Down
20 changes: 10 additions & 10 deletions location/src/Hooks/AddLocationHost.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function hostLocation($obj)
(int)filter_input(INPUT_POST, 'location') ?:
$location
);
$locationSelector = self::getClass('LocationManager')
$locationSelector = (new \FOG\Plugins\Location\Managers\LocationManager())
->buildSelectBox($locationID, 'location');

$fields = [
Expand Down Expand Up @@ -203,15 +203,15 @@ public function hostLocationPost($obj)
'locationassociation',
['hostID' => $hosts]
);
if (self::getClass('Location', $locationID)->isValid()) {
if ((new \FOG\Plugins\Location\Items\Location($locationID))->isValid()) {
foreach ((array)$hosts as $ind => &$hostID) {
$insert_values[] = [$hostID, $locationID];
unset($hostID);
}
}
}
if (count($insert_values) > 0) {
self::getClass('LocationAssociationManager')
(new \FOG\Plugins\Location\Managers\LocationAssociationManager())
->insertBatch(
$insert_fields,
$insert_values
Expand All @@ -235,10 +235,10 @@ public function hostAddLocationRegister($arguments)
return;
}
$locationID = (int)($_POST['location'] ?? 0);
if (!self::getClass('Location', $locationID)->isValid()) {
if (!(new \FOG\Plugins\Location\Items\Location($locationID))->isValid()) {
return;
}
self::getClass('LocationAssociationManager')
(new \FOG\Plugins\Location\Managers\LocationAssociationManager())
->insertBatch(
['hostID', 'locationID'],
[[$obj->get('id'), $locationID]]
Expand Down Expand Up @@ -305,7 +305,7 @@ public function hostAddLocationField($arguments)
return;
}
$locationID = (int)filter_input(INPUT_POST, 'location');
$locationSelector = self::getClass('LocationManager')
$locationSelector = (new \FOG\Plugins\Location\Managers\LocationManager())
->buildSelectBox($locationID, 'location');

$arguments['fields'][
Expand Down Expand Up @@ -349,7 +349,7 @@ public function massEditFields($arguments)

$arguments['fields']['location'] = [
'label' => _('Host Location'),
'input' => self::getClass('LocationManager')->buildSelectBox(
'input' => (new \FOG\Plugins\Location\Managers\LocationManager())->buildSelectBox(
'',
'value[location]',
'name',
Expand Down Expand Up @@ -391,7 +391,7 @@ private function _sharedLocation(array $hostIDs)
)['location'];

if (!empty($info['uniform']) && '' !== (string)$info['value']) {
$item = self::getClass('Location', (int)$info['value']);
$item = new \FOG\Plugins\Location\Items\Location((int)$info['value']);
if ($item->isValid()) {
$info['value'] = $item->get('name');
}
Expand Down Expand Up @@ -440,7 +440,7 @@ function ($id) {
// an instruction to clear: silently turning it into one would
// strip the location off every selected host.
if ($itemID < 1
|| !self::getClass('Location', $itemID)->isValid()
|| !(new \FOG\Plugins\Location\Items\Location($itemID))->isValid()
) {
throw new \Exception(_('Invalid Location selected'));
}
Expand All @@ -460,7 +460,7 @@ function ($id) {
foreach ($hostIDs as $hostID) {
$insert_values[] = [$hostID, $itemID];
}
self::getClass('LocationAssociationManager')
(new \FOG\Plugins\Location\Managers\LocationAssociationManager())
->insertBatch(['hostID', 'locationID'], $insert_values);
}
}
6 changes: 3 additions & 3 deletions location/src/Hooks/AddLocationImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function getLocationNames($host)
);
$names = [];
foreach ((array)$locationIDs as $locationID) {
$Location = self::getClass('Location', $locationID);
$Location = new \FOG\Plugins\Location\Items\Location($locationID);
if ($Location->isValid()) {
$names[] = $Location->get('name');
}
Expand Down Expand Up @@ -173,8 +173,8 @@ public function applyLocation($host, $ids)
['hostID' => $hostID]
);
$locationID = array_shift($ids);
if (self::getClass('Location', $locationID)->isValid()) {
self::getClass('LocationAssociationManager')
if ((new \FOG\Plugins\Location\Items\Location($locationID))->isValid()) {
(new \FOG\Plugins\Location\Managers\LocationAssociationManager())
->insertBatch(
['hostID', 'locationID'],
[[$hostID, $locationID]]
Expand Down
Loading