setContext('Vdlp.RssFetcher', 'rssfetcher', 'items'); } // @codingStandardsIgnoreStart /** * @return array * @throws Exception */ public function index_onDelete(): array { foreach ($this->getCheckedIds() as $sourceId) { if (!$source = Item::query()->find($sourceId)) { continue; } $source->delete(); } return $this->listRefresh(); } /** * @return array */ public function index_onPublish(): array { return $this->publishItem(true); } /** * @return array */ public function index_onUnpublish(): array { return $this->publishItem(false); } // @codingStandardsIgnoreEnd /** * @param $publish * @return array */ private function publishItem($publish): array { foreach ($this->getCheckedIds() as $sourceId) { if (!$source = Item::query()->find($sourceId)) { continue; } $source->update(['is_published' => $publish]); } return $this->listRefresh(); } /** * Check checked ID's from POST request. * * @return array */ private function getCheckedIds(): array { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds) ) { return $checkedIds; } return []; } }