/
Task.php
42 lines (34 loc) · 1.03 KB
/
Task.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
<?php
namespace Concrete\Core\Package\ItemCategory;
use Concrete\Core\Entity\Automation\Task as TaskEntity;
use Concrete\Core\Entity\Package;
use Concrete\Core\Support\Facade\Application;
use Doctrine\ORM\EntityManager;
defined('C5_EXECUTE') or die('Access Denied.');
class Task extends AbstractCategory
{
public function getItemCategoryDisplayName()
{
return t('Tasks');
}
public function getItemName($task)
{
return $task->getController()->getName();
}
public function getPackageItems(Package $package)
{
$app = Application::getFacadeApplication();
$em = $app->make(EntityManager::class);
$repo = $em->getRepository(TaskEntity::class);
return $repo->findBy(['package' => $package]);
}
public function removeItem($item)
{
if ($item instanceof TaskEntity) {
$app = Application::getFacadeApplication();
$em = $app->make(EntityManager::class);
$em->remove($item);
$em->flush();
}
}
}