Example #1
0
 /**
  * Return count of records from module storage
  * 
  * @param array $options
  * @return int
  */
 public static function getCountFromModuleStorage($options = [])
 {
     $classPath = explode('\\', get_called_class());
     $count = 0;
     if (empty($options['appType'])) {
         $appType = App::$cur->type;
     } else {
         $appType = $options['appType'];
     }
     if (!empty(static::$storage['options']['share'])) {
         $moduleConfig = Config::share($classPath[0]);
     } else {
         $moduleConfig = Config::module($classPath[0], strpos(static::$storage['type'], 'system') !== false);
     }
     if (!empty($moduleConfig['storage'][$appType][$classPath[1]])) {
         $items = $moduleConfig['storage'][$appType][$classPath[1]];
         if (empty($options['where'])) {
             return count($items);
         }
         foreach ($items as $key => $item) {
             if (!empty($options['where'])) {
                 if (Model::checkWhere($item, $options['where'])) {
                     $count++;
                 }
             } else {
                 $count++;
             }
         }
     }
     return $count;
 }