public function getArticleSwitches($article) { $switches = array(); foreach ($this->switches as $switch) { try { if ($article->getData($switch)) { $switches[] = $switch; } } catch (\Exception $e) { /*just ignore if switch don't exists*/ } } }