/
IpAccessControlCategory.php
67 lines (59 loc) · 2.11 KB
/
IpAccessControlCategory.php
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
<?php
namespace Concrete\Core\Package\ItemCategory;
use Concrete\Core\Entity\Package;
use Concrete\Core\Entity\Permission\IpAccessControlCategory as Entity;
use Concrete\Core\Support\Facade\Application;
use Doctrine\ORM\EntityManagerInterface;
use Concrete\Core\Entity\Permission\IpAccessControlCategory as IpAccessControlCategoryEntity;
defined('C5_EXECUTE') or die('Access Denied.');
class IpAccessControlCategory extends AbstractCategory
{
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\ItemCategory\ItemInterface::getItemCategoryDisplayName()
*/
public function getItemCategoryDisplayName()
{
return t('IP Access Control Categories');
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\ItemCategory\ItemInterface::getItemName()
*
* @param \Concrete\Core\Entity\Permission\IpAccessControlCategory $ipAccessControlCategory
*/
public function getItemName($ipAccessControlCategory)
{
return $ipAccessControlCategory->getDisplayName();
}
/**
* @param \Concrete\Core\Entity\Package $package
*
* @return \Concrete\Core\Entity\Permission\IpAccessControlCategory[]
*/
public function getPackageItems(Package $package)
{
$app = Application::getFacadeApplication();
$em = $app->make(EntityManagerInterface::class);
$repo = $em->getRepository(IpAccessControlCategoryEntity::class);
return $repo->findBy(['package' => $package]);
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Package\ItemCategory\AbstractCategory::removeItem()
*
* @param \Concrete\Core\Entity\Permission\IpAccessControlCategory|mixed $ipAccessControlCategory
*/
public function removeItem($ipAccessControlCategory)
{
if ($ipAccessControlCategory instanceof Entity && $ipAccessControlCategory->getIpAccessControlCategoryID() !== null) {
$app = Application::getFacadeApplication();
$em = $app->make(EntityManagerInterface::class);
$em->remove($ipAccessControlCategory);
$em->flush($ipAccessControlCategory);
}
}
}