public static function makeKey($type) { $dir = static::checkDir($type); $key = Inflector::quickRandom(9); $check = STORAGE_PATH . DS . 'project' . DS . $dir . DS . $key . '.' . Inflector::lower($type); if (File::exists($check)) { return static::makeKey($type); } return $key; }
private static function _makeKey($keyLength = 9) { $key = Inflector::quickRandom($keyLength); if (!Arrays::in($key, static::$keys)) { static::$keys[] = $key; return $key; } else { return static::_makeKey($keyLength); } }
public static function makeKey() { $key = Inflector::quickRandom(9); $check = STORAGE_PATH . DS . 'articles' . DS . $key . '.message'; if (File::exists($check)) { return static::makeKey(); } return $key; }
public static function makeView($campaign, $user) { $dirStatsViews = STORAGE_PATH . DS . 'newsletters' . DS . 'stats' . DS . 'views'; $dirCampaign = $dirStatsViews . DS . $campaign->getId(); if (!is_dir($dirCampaign)) { mkdir($dirCampaign, 0777); } $dirUser = $dirCampaign . DS . $user->getId(); if (!is_dir($dirUser)) { mkdir($dirUser, 0777); } $count = glob($dirUser . DS . '*.count', GLOB_NOSORT); if (!count($count)) { $key = Inflector::quickRandom(9); $newCount = $dirUser . DS . $key . '.count'; $initialize = new viewCount(); $initialize->setId($key); $initialize->setCampaign($campaign->getId()); $initialize->setUser($user->getId()); $initialize->setCount(0); $initialize->setDates(array()); $serialize = serialize($initialize); File::delete($newCount); File::put($newCount, $serialize); return $initialize; } else { return static::getObject(current($count)); } }