示例#1
0
 public function all()
 {
     $minCharacters = 3;
     $search = $this->_getRequest()->query->get('search');
     if ($search && strlen($search) >= $minCharacters) {
         $cache = new AppsSearchCache($search);
         $apps = $cache->retrieve();
         // Highlight
         $types = [];
         foreach ($apps as $k => $app) {
             $apps[$k]->name = preg_replace('/(' . preg_quote($search) . ')/i', '<b>$0</b>', $apps[$k]->name);
             $types[] = $app->type;
         }
     } else {
         $cache = new AppsLatestCache();
         $apps = $cache->retrieve();
         $search = null;
         $types = [];
     }
     $cache = new AppsCountCache();
     $count = $cache->retrieve();
     $this->layout()->setData('title', 'Apps');
     return new AppListView($apps, $count, $search, $minCharacters, $types);
 }