ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCronManagerTableFilterMediator Class Reference
+ Collaboration diagram for ilCronManagerTableFilterMediator:

Public Member Functions

 __construct (private readonly ilCronJobCollection $items, private readonly Factory $uiFactory, private readonly ilUIService $uiService, private readonly ilLanguage $lng)
 
 filter (string $action)
 
 filteredJobs (Standard $filter)
 

Private Attributes

const FILTER_PROPERTY_NAME_TITLE = 'title'
 
const FILTER_PROPERTY_NAME_COMPONENT = 'component'
 
const FILTER_PROPERTY_NAME_SCHEDULE = 'schedule'
 
const FILTER_PROPERTY_NAME_STATUS = 'status'
 
const FILTER_PROPERTY_NAME_RESULT = 'result'
 
const FILTER_STATUS_ACTIVE = 1
 
const FILTER_STATUS_INACTIVE = 2
 

Detailed Description

Definition at line 25 of file class.ilCronManagerTableFilterMediator.php.

Constructor & Destructor Documentation

◆ __construct()

ilCronManagerTableFilterMediator::__construct ( private readonly ilCronJobCollection  $items,
private readonly Factory  $uiFactory,
private readonly ilUIService  $uiService,
private readonly ilLanguage  $lng 
)

Definition at line 36 of file class.ilCronManagerTableFilterMediator.php.

41  {
42  }

Member Function Documentation

◆ filter()

ilCronManagerTableFilterMediator::filter ( string  $action)

Definition at line 44 of file class.ilCronManagerTableFilterMediator.php.

References ilCronJobEntity\getComponent(), ilCronJobEntity\isPlugin(), ILIAS\Repository\lng(), ILIAS\Cron\Schedule\SCHEDULE_TYPE_YEARLY, ilCronJobResult\STATUS_CRASHED, ilCronJobResult\STATUS_FAIL, ilCronJobResult\STATUS_INVALID_CONFIGURATION, ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, and ilCronJobResult\STATUS_RESET.

44  : Standard
45  {
46  $componentOptions = array_unique(
47  array_map(function (ilCronJobEntity $entity): string {
48  if ($entity->isPlugin()) {
49  return $this->lng->txt('cmps_plugin') . '/' . $entity->getComponent();
50  }
51 
52  return $entity->getComponent();
53  }, $this->items->toArray())
54  );
55  asort($componentOptions);
56 
57  $title = $this->uiFactory->input()->field()->text($this->lng->txt('title'));
58  $components = $this->uiFactory->input()->field()->select(
59  $this->lng->txt('cron_component'),
60  array_combine($componentOptions, $componentOptions)
61  );
62  $schedule = $this->uiFactory->input()->field()->select(
63  $this->lng->txt('cron_schedule'),
64  [
65  CronJobScheduleType::SCHEDULE_TYPE_DAILY->value => $this->lng->txt('cron_schedule_daily'),
66  CronJobScheduleType::SCHEDULE_TYPE_WEEKLY->value => $this->lng->txt('cron_schedule_weekly'),
67  CronJobScheduleType::SCHEDULE_TYPE_MONTHLY->value => $this->lng->txt('cron_schedule_monthly'),
68  CronJobScheduleType::SCHEDULE_TYPE_QUARTERLY->value => $this->lng->txt('cron_schedule_quarterly'),
69  CronJobScheduleType::SCHEDULE_TYPE_YEARLY->value => $this->lng->txt('cron_schedule_yearly'),
70  CronJobScheduleType::SCHEDULE_TYPE_IN_MINUTES->value => sprintf($this->lng->txt('cron_schedule_in_minutes'), 'x'),
71  CronJobScheduleType::SCHEDULE_TYPE_IN_HOURS->value => sprintf($this->lng->txt('cron_schedule_in_hours'), 'x'),
72  CronJobScheduleType::SCHEDULE_TYPE_IN_DAYS->value => sprintf($this->lng->txt('cron_schedule_in_days'), 'x')
73  ]
74  );
75  $status = $this->uiFactory->input()->field()->select(
76  $this->lng->txt('cron_status'),
77  [
78  self::FILTER_STATUS_ACTIVE => $this->lng->txt('cron_status_active'),
79  self::FILTER_STATUS_INACTIVE => $this->lng->txt('cron_status_inactive'),
80  ]
81  );
82  $result = $this->uiFactory->input()->field()->select(
83  $this->lng->txt('cron_result'),
84  [
86  'cron_result_status_invalid_configuration'
87  ),
89  'cron_result_status_no_action'
90  ),
91  ilCronJobResult::STATUS_OK => $this->lng->txt(
92  'cron_result_status_ok'
93  ),
94  ilCronJobResult::STATUS_CRASHED => $this->lng->txt(
95  'cron_result_status_crashed'
96  ),
97  ilCronJobResult::STATUS_RESET => $this->lng->txt(
98  'cron_result_status_reset'
99  ),
100  ilCronJobResult::STATUS_FAIL => $this->lng->txt(
101  'cron_result_status_fail'
102  ),
103  ]
104  );
105 
106  $fields = [
107  self::FILTER_PROPERTY_NAME_TITLE => $title,
108  self::FILTER_PROPERTY_NAME_COMPONENT => $components,
109  self::FILTER_PROPERTY_NAME_SCHEDULE => $schedule,
110  self::FILTER_PROPERTY_NAME_STATUS => $status,
111  self::FILTER_PROPERTY_NAME_RESULT => $result,
112  ];
113 
114  return $this->uiService->filter()->standard(
115  'cron_job_adm_table',
116  $action,
117  $fields,
118  array_fill(0, count($fields), true),
119  true,
120  true
121  );
122  }
final const STATUS_INVALID_CONFIGURATION
This describes a standard filter.
Definition: Standard.php:26
final const STATUS_NO_ACTION
+ Here is the call graph for this function:

◆ filteredJobs()

ilCronManagerTableFilterMediator::filteredJobs ( Standard  $filter)

Definition at line 124 of file class.ilCronManagerTableFilterMediator.php.

References ilCronJobCollection\filter(), ilCronJobEntity\getComponent(), ilCronJobEntity\getEffectiveScheduleType(), ilCronJobEntity\getEffectiveTitle(), ilCronJobEntity\getJobResultStatus(), ilCronJobEntity\getJobStatus(), ilCronJobEntity\isPlugin(), ILIAS\Repository\lng(), and ilStr\strIPos().

125  {
126  $filterValues = $this->uiService->filter()->getData($filter);
127 
128  return $this->items->filter(function (ilCronJobEntity $entity) use ($filterValues): bool {
129  if (
130  isset($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) &&
131  is_string($filterValues[self::FILTER_PROPERTY_NAME_TITLE]) &&
132  $filterValues[self::FILTER_PROPERTY_NAME_TITLE] !== ''
133  ) {
134  $titleFilterValue = $filterValues[self::FILTER_PROPERTY_NAME_TITLE];
135  if (ilStr::strIPos($entity->getEffectiveTitle(), $titleFilterValue) === false) {
136  return false;
137  }
138  }
139 
140  if (
141  isset($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) &&
142  is_string($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT]) &&
143  $filterValues[self::FILTER_PROPERTY_NAME_COMPONENT] !== ''
144  ) {
145  $component = $entity->getComponent();
146  if ($entity->isPlugin()) {
147  $component = $this->lng->txt('cmps_plugin') . '/' . $component;
148  }
149 
150  if ($filterValues[self::FILTER_PROPERTY_NAME_COMPONENT] !== $component) {
151  return false;
152  }
153  }
154 
155  if (
156  isset($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) &&
157  is_string($filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE]) &&
158  $filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE] !== ''
159  ) {
160  if ((int) $filterValues[self::FILTER_PROPERTY_NAME_SCHEDULE] !== $entity->getEffectiveScheduleType()->value) {
161  return false;
162  }
163  }
164 
165  if (
166  isset($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) &&
167  is_string($filterValues[self::FILTER_PROPERTY_NAME_STATUS]) &&
168  $filterValues[self::FILTER_PROPERTY_NAME_STATUS] !== ''
169  ) {
170  if (
171  (int) $filterValues[self::FILTER_PROPERTY_NAME_STATUS] === self::FILTER_STATUS_ACTIVE &&
172  !$entity->getJobStatus()
173  ) {
174  return false;
175  } elseif (
176  (int) $filterValues[self::FILTER_PROPERTY_NAME_STATUS] === self::FILTER_STATUS_INACTIVE &&
177  $entity->getJobStatus()
178  ) {
179  return false;
180  }
181  }
182 
183  if (
184  isset($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) &&
185  is_string($filterValues[self::FILTER_PROPERTY_NAME_RESULT]) &&
186  $filterValues[self::FILTER_PROPERTY_NAME_RESULT] !== ''
187  ) {
188  if ((int) $filterValues[self::FILTER_PROPERTY_NAME_RESULT] !== $entity->getJobResultStatus()) {
189  return false;
190  }
191  }
192 
193  return true;
194  });
195  }
static strIPos(string $a_haystack, string $a_needle, int $a_offset=0)
Definition: class.ilStr.php:54
filter(callable $callable)
Returns all the elements of this collection that satisfy the predicate $callable. ...
+ Here is the call graph for this function:

Field Documentation

◆ FILTER_PROPERTY_NAME_COMPONENT

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_COMPONENT = 'component'
private

Definition at line 28 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_PROPERTY_NAME_RESULT

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_RESULT = 'result'
private

Definition at line 31 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_PROPERTY_NAME_SCHEDULE

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_SCHEDULE = 'schedule'
private

Definition at line 29 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_PROPERTY_NAME_STATUS

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_STATUS = 'status'
private

Definition at line 30 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_PROPERTY_NAME_TITLE

const ilCronManagerTableFilterMediator::FILTER_PROPERTY_NAME_TITLE = 'title'
private

Definition at line 27 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_STATUS_ACTIVE

const ilCronManagerTableFilterMediator::FILTER_STATUS_ACTIVE = 1
private

Definition at line 33 of file class.ilCronManagerTableFilterMediator.php.

◆ FILTER_STATUS_INACTIVE

const ilCronManagerTableFilterMediator::FILTER_STATUS_INACTIVE = 2
private

Definition at line 34 of file class.ilCronManagerTableFilterMediator.php.


The documentation for this class was generated from the following file: