How to use freeze method of Freezer class

Best Phake code snippet using Freezer.freeze

Handler.php

Source:Handler.php Github

copy

Full Screen

...51 /**52 * Handler constructor.53 *54 * @param Plugin $plugin plugin55 * @param UserHandler $handler freezer handler56 */57 public function __construct(Plugin $plugin, UserHandler $handler)58 {59 $this->plugin = $plugin;60 $this->handler = $handler;61 }62 /**63 * config64 *65 * @param null|string $field field66 * @param null|mixed $default default67 *68 * @return mixed69 */70 public function config($field = null, $default = null)71 {72 $config = $this->plugin->config();73 return array_get($config, $field, $default);74 }75 /**76 * choose77 *78 * @param string $action action79 *80 * @return Collection81 */82 public function choose($action = 'freeze')83 {84 $users = new Collection();85 if ($action === 'freeze') {86 $duration = $this->config('timer');87 $eventDate = Carbon::now()->subDays($duration);88 $users = $this->handler->where([89 ['login_at', '<>', null],90 ['login_at', '<', $eventDate]91 ])->orWhere([92 ['login_at', null],93 ['created_at', '<', $eventDate]94 ])->get();95 } elseif ($action === 'notify') {96 $duration = $this->config('notify_timer');97 $eventDate = Carbon::now()->subDays($duration);98 $candidates = User::where([99 ['login_at', '<>', null],100 ['login_at', '<', $eventDate]101 ])->orWhere([102 ['login_at', null],103 ['created_at', '<', $eventDate]104 ])->with(105 [106 'freezeLogs' => function ($q) {107 return $q->orderBy('created_at', 'desc');108 }109 ]110 )->get();111 foreach ($candidates as $user) {112 $latestLog = $user->freezeLogs->first();113 if (data_get($latestLog, 'action') !== 'notify') {114 $users->add($user);115 }116 }117 }118 return $users;119 }120 /**121 * notify122 *123 * 휴면처리 대상이 되는 회원에게 예고 이메일 전송하는 잡을 생성하여 Queue에 추가한다.124 *125 * @param null $users users126 *127 * @return int128 */129 public function notify($users = null)130 {131 $freezeType = $this->config('freeze_type', 'freeze');132 $size = $this->config('queue_size', 1);133 $queue = $this->config('queue.notify', 'sync');134 if ($users === null) {135 $users = $this->choose('notify');136 }137 $user_ids = [];138 foreach ($users as $user) {139 $user_ids[] = $user->id;140 if (count($user_ids) === $size) {141 $this->dispatch((new NotifyJob($user_ids, $freezeType))->onQueue($queue));142 $user_ids = [];143 }144 }145 if (count($user_ids)) {146 $this->dispatch((new NotifyJob($user_ids, $freezeType))->onQueue($queue));147 }148 return $users->count();149 }150 /**151 * freeze152 *153 * 휴면처리 대상이 되는 모든 회원을 조회후 휴면처리 잡(FreezeJob)을 생성하여 Queue에 추가한다.154 *155 * @param null $users users156 *157 * @return int158 */159 public function freeze($users = null)160 {161 $freezeType = $this->config('freeze_type', 'freeze');162 $size = $this->config('queue_size', 1);163 $queue = $this->config('queue.freeze', 'sync');164 if ($users === null) {165 $users = $this->choose('freeze');166 }167 $user_ids = [];168 foreach ($users as $user) {169 $user_ids[] = $user->id;170 if (count($user_ids) === $size) {171 $this->dispatch((new FreezeJob($user_ids, $freezeType))->onQueue($queue));172 $user_ids = [];173 }174 }175 if (count($user_ids)) {176 $this->dispatch((new FreezeJob($user_ids, $freezeType))->onQueue($queue));177 }178 return $users->count();179 }180 /**181 * freeze user182 *183 * @param array|string $user_ids user id or user ids184 *185 * @return void186 * @throws \Exception187 */188 public function freezeUser($user_ids)189 {190 if (is_string($user_ids)) {191 $user_ids = [$user_ids];192 }193 $users = $this->handler->findMany($user_ids);194 foreach ($users as $user) {195 try {196 $this->moveData('freeze', $user->id);197 $this->sendEmail($user, 'freeze');198 } catch (\Exception $e) {199 $this->logging($user->id, 'freeze', ['message' => $e->getMessage()], 'failed');200 throw $e;201 }202 $this->logging($user->id, 'freeze', $user->toArray(), 'successed');203 }204 }205 /**206 * delete user207 *208 * @param array|string $user_ids user id or user ids209 *210 * @return void211 * @throws \Exception212 */213 public function deleteUser($user_ids)214 {215 if (is_string($user_ids)) {216 $user_ids = [$user_ids];217 }218 $users = $this->handler->findMany($user_ids);219 foreach ($users as $user) {220 try {221 $this->handler->leave($user->id);222 $this->sendEmail($user, 'delete');223 } catch (\Exception $e) {224 $this->logging($user->id, 'delete', ['message' => $e->getMessage()], 'failed');225 throw $e;226 }227 $this->logging($user->id, 'delete');228 }229 }230 /**231 * notify user232 *233 * @param array|string $user_ids user id or user ids234 *235 * @return void236 * @throws \Exception237 */238 public function notifyUser($user_ids)239 {240 if (is_string($user_ids)) {241 $user_ids = [$user_ids];242 }243 $users = $this->handler->findMany($user_ids);244 foreach ($users as $user) {245 try {246 $this->sendEmail($user, 'notify');247 } catch (\Exception $e) {248 $this->logging($user->id, 'notify', ['message' => $e->getMessage()], 'failed');249 throw $e;250 }251 $this->logging($user->id, 'notify');252 }253 }254 /**255 * unfreeze256 *257 * @param string $user_id user id258 *259 * @return void260 * @throws \Exception261 */262 public function unfreeze($user_id)263 {264 try {265 $this->moveData('recovery', $user_id);266 $user = $this->handler->find($user_id);267 $this->sendEmail($user, 'unfreeze');268 } catch (\Exception $e) {269 $this->logging($user_id, 'unfreeze', ['message' => $e->getMessage()], 'failed');270 throw $e;271 }272 $this->logging($user->id, 'unfreeze');273 }274 /**275 * move data276 *277 * @param string $type type278 * @param string $user_id user id279 *280 * @return void281 */282 protected function moveData($type, $user_id)283 {284 if ($type === 'freeze') {285 $origin = 'origin';286 $target = 'target';287 } else {288 $origin = 'target';289 $target = 'origin';290 }291 // copy user table292 $table = ['origin' => 'user', 'target' => 'freezer_user'];293 $user = DB::table($table[$origin])->find($user_id);294 if ($type !== 'freeze') {295 $loginId = $user->login_id;296 if ($user->login_id === null) {297 $loginId = strtok($user->email, '@');298 }299 $user->login_id = $this->generateLoginId($table[$target], $loginId);300 }301 DB::table($table[$origin])->delete($user_id);302 DB::table($table[$target])->insert((array) $user);303 // copy user_account table304 $table = ['origin' => 'user_account', 'target' => 'freezer_user_account'];305 $accounts = DB::table($table[$origin])->where('user_id', $user_id)->get();306 DB::table($table[$origin])->where('user_id', $user_id)->delete();307 foreach ($accounts as $account) {308 DB::table($table[$target])->insert((array) $account);309 }310 // copy user_email table311 $table = ['origin' => 'user_email', 'target' => 'freezer_user_email'];312 $emails = DB::table($table[$origin])->where('user_id', $user_id)->get();313 DB::table($table[$origin])->where('user_id', $user_id)->delete();314 foreach ($emails as $email) {315 DB::table($table[$target])->insert((array) $email);316 }317 // copy user_group_user318 $table = ['origin' => 'user_group_user', 'target' => 'freezer_user_group_user'];319 $group_users = DB::table($table[$origin])->where('user_id', $user_id)->get();320 DB::table($table[$origin])->where('user_id', $user_id)->delete();321 foreach ($group_users as $group) {322 DB::table($table[$target])->insert((array) $group);323 }324 $table = ['origin' => 'user_term_agrees', 'target' => 'freezer_user_term_agrees'];325 $userAgreeData = DB::table($table[$origin])->where('user_id', $user_id)->get();326 DB::table($table[$origin])->where('user_id', $user_id)->delete();327 foreach ($userAgreeData as $data) {328 DB::table($table[$target])->insert((array) $data);329 }330 }331 /**332 * logging333 *334 * @param string $user_id user id335 * @param string $action action336 * @param array $content content337 * @param string $result result338 *339 * @return void340 */341 protected function logging($user_id, $action, $content = [], $result = 'successd')342 {343 // type = freeze, delete, unfreeze, notify344 $log = new Log();345 $log->user_id = $user_id;346 $log->action = $action;347 $log->result = $result;348 $log->content = $content;349 $log->save();350 }351 /**352 * send email353 *354 * @param \Xpressengine\User\Models\User $user user355 * @param string $type type356 *357 * @return void358 */359 protected function sendEmail($user, $type)360 {361 $subject = $this->config("email.$type.subject");362 $content = $this->config("email.$type.content");363 $content = $content($user, $type, $this->config());364 // type = freeze, delete, unfreeze, notify365 $view = $this->plugin->view('views.email');366 $emailAddr = $user->email;367// if ($emailAddr) {368// app('mailer')->to($emailAddr)->queue(new Common($view, $subject, compact('content')));369// }370 (new class($type, $emailAddr, $subject, $content) {371 use Notifiable;372 protected $type;373 protected $email;374 protected $title;375 protected $contents;376 protected $subjectResolver;377 /**378 * constructor.379 *380 * @param string $type type381 * @param string $email email382 * @param string $title title383 * @param string $contents contents384 * @param callable|null $subjectResolver resolver385 */386 public function __construct($type, $email, $title, $contents, callable $subjectResolver = null)387 {388 $this->type = $type;389 $this->email = $email;390 $this->title = $title;391 $this->contents = $contents;392 $this->subjectResolver = $subjectResolver;393 }394 /**395 * Invoke the instance396 *397 * @return void398 */399 public function __invoke()400 {401 if ($this->subjectResolver != null) {402 Notice::setSubjectResolver($this->subjectResolver);403 }404 $this->notify(new Notice($this->email, $this->title, $this->contents));405 Notice::setSubjectResolverToNull();406 }407 /**408 * Get the notification routing information for the given driver.409 *410 * @param string $driver driver411 * @return mixed412 */413 public function routeNotificationFor($driver)414 {415 return $this->email;416 }417 })();418 }419 /**420 * attempt421 *422 * @param array $credentials credentials423 *424 * @return mixed|null425 */426 public function attempt($credentials = [])427 {428 if (array_has($credentials, 'password')) { // 이메일/비번 로그인429 $email = array_get($credentials, 'email');430 $targetColumn = 'email';431 if (!str_contains($email, '@')) {432 $targetColumn = 'login_id';433 }434 $userInfo = DB::table('freezer_user')->where($targetColumn, $email)->first();435 if ($userInfo !== null) {436 $plain = $credentials['password'];437 if (app('hash')->check($plain, $userInfo->password)) {438 return $userInfo->id;439 }440 }441 } elseif ($credentials instanceof \Laravel\Socialite\AbstractUser) { // 소셜로그인(회원가입)442 $email = $credentials->getEmail();443 $account_id = $credentials->getId();444 // account info가 freeze 되어 있다면 바로 반환445 // email info가 freeze 되어 있다면,446 $accountInfo = DB::table('freezer_user_account')->where('account_id', $account_id)->first();447 if ($accountInfo !== null) {448 return $accountInfo->user_id;449 } elseif ($email !== null) {450 $emailInfo = DB::table('freezer_user_email')->where('address', $email)->first();451 if ($emailInfo !== null) {452 return $emailInfo->user_id;453 }454 }455 } elseif (array_has($credentials, 'display_name')) { // 이름 검사456 $name = array_get($credentials, 'display_name');457 $userInfo = DB::table('freezer_user')->where('display_name', $name)->first();458 if ($userInfo !== null) {459 return $userInfo->id;460 }461 } elseif (array_has($credentials, 'address')) { // 이메일 검사462 $address = array_get($credentials, 'address');463 $emailInfo = DB::table('freezer_user_email')->where('address', $address)->first();464 if ($emailInfo !== null) {465 return $emailInfo->user_id;466 }467 }468 return null;469 }470 /**471 * is password protect target472 *473 * @param User $user user474 *475 * @return bool476 */477 public function isPasswordProtectTarget($user)...

Full Screen

Full Screen

Freezer.php

Source:Freezer.php Github

copy

Full Screen

...43require_once 'Object/Freezer/HashGenerator/NonRecursiveSHA1.php';44require_once 'Object/Freezer/IdGenerator/UUID.php';45require_once 'Object/Freezer/Util.php';46/**47 * This class provides the low-level functionality required to store ("freeze")48 * PHP objects to and retrieve ("thaw") PHP objects from an object store.49 *50 * @package Object_Freezer51 * @author Sebastian Bergmann <sb@sebastian-bergmann.de>52 * @copyright 2008-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>53 * @license http://www.opensource.org/licenses/bsd-license.php BSD License54 * @version Release: 1.0.055 * @link http://github.com/sebastianbergmann/php-object-freezer/56 * @since Class available since Release 1.0.057 */58class Object_Freezer59{60 /**61 * @var boolean62 */63 protected $autoload = TRUE;64 /**65 * @var array66 */67 protected $blacklist = array();68 /**69 * @var Object_Freezer_IdGenerator70 */71 protected $idGenerator;72 /**73 * @var Object_Freezer_HashGenerator74 */75 protected $hashGenerator;76 /**77 * Constructor.78 *79 * @param Object_Freezer_IdGenerator $idGenerator80 * @param Object_Freezer_HashGenerator $hashGenerator81 * @param array $blacklist82 * @param boolean $useAutoload83 * @throws InvalidArgumentException84 */85 public function __construct(Object_Freezer_IdGenerator $idGenerator = NULL, Object_Freezer_HashGenerator $hashGenerator = NULL, array $blacklist = array(), $useAutoload = TRUE)86 {87 // Use Object_Freezer_IdGenerator_UUID by default.88 if ($idGenerator === NULL) {89 $idGenerator = new Object_Freezer_IdGenerator_UUID;90 }91 // Use Object_Freezer_HashGenerator_NonRecursiveSHA1 by default.92 if ($hashGenerator === NULL) {93 $hashGenerator = new Object_Freezer_HashGenerator_NonRecursiveSHA1(94 $idGenerator95 );96 }97 $this->setIdGenerator($idGenerator);98 $this->setHashGenerator($hashGenerator);99 $this->setBlacklist($blacklist);100 $this->setUseAutoload($useAutoload);101 }102 /**103 * Freezes an object.104 *105 * If the object has not been frozen before, the attribute106 * __php_object_freezer_uuid will be added to it.107 *108 * In the example below, we freeze an object of class A. As this object109 * aggregates an object of class B, the object freezer has to freeze two110 * objects in total.111 *112 * <code>113 * <?php114 * require_once 'Object/Freezer.php';115 *116 * class A117 * {118 * protected $b;119 *120 * public function __construct()121 * {122 * $this->b = new B;123 * }124 * }125 *126 * class B127 * {128 * protected $foo = 'bar';129 * }130 *131 * $freezer = new Object_Freezer;132 * var_dump($freezer->freeze(new A));133 * ?>134 * </code>135 *136 * Below is the output of the code example above.137 *138 * <code>139 * array(2) {140 * ["root"]=>141 * string(36) "32246c35-f47b-4fbc-a2ad-ed14e520865e"142 * ["objects"]=>143 * array(2) {144 * ["32246c35-f47b-4fbc-a2ad-ed14e520865e"]=>145 * array(3) {146 * ["className"]=>147 * string(1) "A"148 * ["isDirty"]=>149 * bool(true)150 * ["state"]=>151 * array(2) {152 * ["b"]=>153 * string(57)154 * "__php_object_freezer_3cd682bf-8eba-4fec-90e2-ebe98aa07ab7"155 * ["__php_object_freezer_hash"]=>156 * string(40) "8b80da9c38c0c41c829cbbefbca9b18aa67ff607"157 * }158 * }159 * ["3cd682bf-8eba-4fec-90e2-ebe98aa07ab7"]=>160 * array(3) {161 * ["className"]=>162 * string(1) "B"163 * ["isDirty"]=>164 * bool(true)165 * ["state"]=>166 * array(2) {167 * ["foo"]=>168 * string(3) "bar"169 * ["__php_object_freezer_hash"]=>170 * string(40) "e04e935f09f2d526258d8a16613c5bce31e84e87"171 * }172 * }173 * }174 * }175 * </code>176 *177 * The reference to the object of class B that the object of class A had178 * before it was frozen has been replaced with the UUID of the frozen179 * object of class B180 * (__php_object_freezer_3cd682bf-8eba-4fec-90e2-ebe98aa07ab7).181 *182 * The result array's "root" element contains the UUID for the now frozen183 * object of class A (32246c35-f47b-4fbc-a2ad-ed14e520865e).184 *185 * @param object $object The object that is to be frozen.186 * @param array $objects Only used internally.187 * @return array The frozen object(s).188 * @throws InvalidArgumentException189 */190 public function freeze($object, array &$objects = array())191 {192 // Bail out if a non-object was passed.193 if (!is_object($object)) {194 throw Object_Freezer_Util::getInvalidArgumentException(1, 'object');195 }196 // The object has not been frozen before, generate a new UUID and197 // store it in the "special" __php_object_freezer_uuid attribute.198 if (!isset($object->__php_object_freezer_uuid)) {199 $object->__php_object_freezer_uuid = $this->idGenerator->getId();200 }201 $isDirty = $this->isDirty($object, TRUE);202 $uuid = $object->__php_object_freezer_uuid;203 if (!isset($objects[$uuid])) {204 $objects[$uuid] = array(205 'className' => get_class($object),206 'isDirty' => $isDirty,207 'state' => array()208 );209 // Iterate over the attributes of the object.210 foreach (Object_Freezer_Util::readAttributes($object) as $k => $v) {211 if ($k !== '__php_object_freezer_uuid') {212 if (is_array($v)) {213 $this->freezeArray($v, $objects);214 }215 else if (is_object($v) &&216 !in_array(get_class($v), $this->blacklist)) {217 // Freeze the aggregated object.218 $this->freeze($v, $objects);219 // Replace $v with the aggregated object's UUID.220 $v = '__php_object_freezer_' .221 $v->__php_object_freezer_uuid;222 }223 else if (is_resource($v)) {224 $v = NULL;225 }226 // Store the attribute in the object's state array.227 $objects[$uuid]['state'][$k] = $v;228 }229 }230 }231 return array('root' => $uuid, 'objects' => $objects);232 }233 /**234 * Freezes an array.235 *236 * @param array $array The array that is to be frozen.237 * @param array $objects Only used internally.238 */239 protected function freezeArray(array &$array, array &$objects)240 {241 foreach ($array as &$value) {242 if (is_array($value)) {243 $this->freezeArray($value, $objects);244 }245 else if (is_object($value)) {246 $tmp = $this->freeze($value, $objects);247 $value = '__php_object_freezer_' . $tmp['root'];248 unset($tmp);249 }250 }251 }252 /**253 * Thaws an object.254 *255 * <code>256 * <?php257 * require_once 'Object/Freezer.php';258 *259 * require_once 'A.php';260 * require_once 'B.php';261 *262 * $freezer = new Object_Freezer;263 *264 * var_dump(265 * $freezer->thaw(266 * array(267 * 'root' => '32246c35-f47b-4fbc-a2ad-ed14e520865e',268 * 'objects' => array(269 * '32246c35-f47b-4fbc-a2ad-ed14e520865e' => array(270 * 'className' => 'A',271 * 'isDirty' => FALSE,272 * 'state' => array(273 * 'b' =>274 * '__php_object_freezer_3cd682bf-8eba-4fec-90e2-ebe98aa07ab7',275 * ),276 * ),277 * '3cd682bf-8eba-4fec-90e2-ebe98aa07ab7' => array(278 * 'className' => 'B',279 * 'isDirty' => FALSE,280 * 'state' => array(281 * 'foo' => 'bar',282 * )283 * )284 * )285 * )286 * )287 * );288 * ?>289 * </code>290 *291 * Below is the output of the code example above.292 *293 * <code>294 * object(A)#3 (2) {295 * ["b":protected]=>296 * object(B)#5 (2) {297 * ["foo":protected]=>298 * string(3) "bar"299 * ["__php_object_freezer_uuid"]=>300 * string(36) "3cd682bf-8eba-4fec-90e2-ebe98aa07ab7"301 * }302 * ["__php_object_freezer_uuid"]=>303 * string(36) "32246c35-f47b-4fbc-a2ad-ed14e520865e"304 * }305 * </code>306 *307 * @param array $frozenObject The frozen object that should be thawed.308 * @param string $root The UUID of the object that should be309 * treated as the root object when multiple310 * objects are present in $frozenObject.311 * @param array $objects Only used internally.312 * @return object The thawed object.313 * @throws RuntimeException314 */315 public function thaw(array $frozenObject, $root = NULL, array &$objects = array())316 {317 // Bail out if one of the required classes cannot be found.318 foreach ($frozenObject['objects'] as $object) {319 if (!class_exists($object['className'], $this->useAutoload)) {320 throw new RuntimeException(321 sprintf(322 'Class "%s" could not be found.', $object['className']323 )324 );325 }326 }327 // By default, we thaw the root object and (recursively)328 // its aggregated objects.329 if ($root === NULL) {330 $root = $frozenObject['root'];331 }332 // Thaw object (if it has not been thawed before).333 if (!isset($objects[$root])) {334 $className = $frozenObject['objects'][$root]['className'];335 $state = $frozenObject['objects'][$root]['state'];336 // Use a trick to create a new object of a class337 // without invoking its constructor.338 $objects[$root] = unserialize(339 sprintf('O:%d:"%s":0:{}', strlen($className), $className)340 );341 // Handle aggregated objects.342 $this->thawArray($state, $frozenObject, $objects);343 $reflector = new ReflectionObject($objects[$root]);344 foreach ($state as $name => $value) {345 if (strpos($name, '__php_object_freezer') !== 0) {346 $attribute = $reflector->getProperty($name);347 $attribute->setAccessible(TRUE);348 $attribute->setValue($objects[$root], $value);349 }350 }351 // Store UUID.352 $objects[$root]->__php_object_freezer_uuid = $root;353 // Store hash.354 if (isset($state['__php_object_freezer_hash'])) {355 $objects[$root]->__php_object_freezer_hash =356 $state['__php_object_freezer_hash'];357 }358 }359 return $objects[$root];360 }361 /**362 * Thaws an array.363 *364 * @param array $array The array that is to be thawed.365 * @param array $frozenObject The frozen object structure from which to366 * thaw.367 * @param array $objects Only used internally.368 */369 protected function thawArray(array &$array, array $frozenObject, array &$objects)370 {371 foreach ($array as &$value) {372 if (is_array($value)) {373 $this->thawArray($value, $frozenObject, $objects);374 }375 else if (is_string($value) &&376 strpos($value, '__php_object_freezer') === 0) {377 $aggregatedObjectId = str_replace(378 '__php_object_freezer_', '', $value379 );380 if (isset($frozenObject['objects'][$aggregatedObjectId])) {381 $value = $this->thaw(382 $frozenObject, $aggregatedObjectId, $objects383 );384 }385 }386 }387 }388 /**389 * Returns the Object_Freezer_IdGenerator implementation used390 * to generate object identifiers.391 *392 * @return Object_Freezer_IdGenerator393 */394 public function getIdGenerator()395 {396 return $this->idGenerator;397 }398 /**399 * Sets the Object_Freezer_IdGenerator implementation used400 * to generate object identifiers.401 *402 * @param Object_Freezer_IdGenerator $idGenerator403 */404 public function setIdGenerator(Object_Freezer_IdGenerator $idGenerator)405 {406 $this->idGenerator = $idGenerator;407 }408 /**409 * Returns the Object_Freezer_HashGenerator implementation used410 * to generate hash objects.411 *412 * @return Object_Freezer_HashGenerator413 */414 public function getHashGenerator()415 {416 return $this->hashGenerator;417 }418 /**419 * Sets the Object_Freezer_HashGenerator implementation used420 * to generate hash objects.421 *422 * @param Object_Freezer_HashGenerator $hashGenerator423 */424 public function setHashGenerator(Object_Freezer_HashGenerator $hashGenerator)425 {426 $this->hashGenerator = $hashGenerator;427 }428 /**429 * Returns the blacklist of class names for which aggregates objects are430 * not frozen.431 *432 * @return array433 */434 public function getBlacklist()435 {436 return $this->blacklist;437 }438 /**439 * Sets the blacklist of class names for which aggregates objects are440 * not frozen.441 *442 * @param array $blacklist443 * @throws InvalidArgumentException444 */445 public function setBlacklist(array $blacklist)446 {447 $this->blacklist = $blacklist;448 }449 /**450 * Returns the flag that controls whether or not __autoload()451 * should be invoked.452 *453 * @return boolean454 */455 public function getUseAutoload()456 {457 return $this->useAutoload;458 }459 /**460 * Sets the flag that controls whether or not __autoload()461 * should be invoked.462 *463 * @param boolean $flag464 * @throws InvalidArgumentException465 */466 public function setUseAutoload($flag)467 {468 // Bail out if a non-boolean was passed.469 if (!is_bool($flag)) {470 throw Object_Freezer_Util::getInvalidArgumentException(471 1, 'boolean'472 );473 }474 $this->useAutoload = $flag;475 }476 /**477 * Checks whether an object is dirty, ie. if its SHA1 hash is still valid.478 *479 * Returns TRUE when the object's __php_object_freezer_hash attribute is no480 * longer valid or does not exist.481 * Returns FALSE when the object's __php_object_freezer_hash attribute is482 * still valid.483 *484 * @param object $object The object that is to be checked.485 * @param boolean $rehash Whether or not to rehash dirty objects.486 * @return boolean487 * @throws InvalidArgumentException488 */489 public function isDirty($object, $rehash = FALSE)490 {491 // Bail out if a non-object was passed.492 if (!is_object($object)) {493 throw Object_Freezer_Util::getInvalidArgumentException(1, 'object');494 }495 // Bail out if a non-boolean was passed.496 if (!is_bool($rehash)) {497 throw Object_Freezer_Util::getInvalidArgumentException(498 2, 'boolean'499 );500 }501 $isDirty = TRUE;502 $hash = $this->hashGenerator->getHash($object);503 if (isset($object->__php_object_freezer_hash) &&504 $object->__php_object_freezer_hash == $hash) {505 $isDirty = FALSE;506 }507 if ($isDirty && $rehash) {508 $object->__php_object_freezer_hash = $hash;509 }510 return $isDirty;511 }512}...

Full Screen

Full Screen

FreezeCommand.php

Source:FreezeCommand.php Github

copy

Full Screen

...33 * The console command name.34 *35 * @var string36 */37 protected $name = 'freezer:freeze';38 /**39 * The console command description.40 *41 * @var string42 */43 protected $description = 'freeze the users who have not logged in for a long time. ';44 /**45 * @var Handler46 */47 protected $handler;48 /**49 * FreezeCommand constructor.50 *51 * @param Handler $handler freezer handler52 */53 public function __construct(Handler $handler)54 {55 parent::__construct();56 $this->handler = $handler;57 }58 /**59 * Execute the console command.60 *61 * @return void62 */63 public function handle()64 {65 $type = $this->handler->config('freeze_type', 'freeze');66 $typeTitle = ['freeze' => 'frozen', 'delete' => 'deleted'][$type];67 $users = $this->handler->choose();68 $count = $users->count();69 $now = Carbon::now();70 if ($count === 0) {71 $this->warn("[{$now->format('Y.m.d H:i:s')}] No users to be frozen.");72 return;73 }74 if ($this->input->isInteractive() && $this->confirm(75 // 총 x명의 회원을 휴면처리 하려고 합니다. 실행하시겠습니까?76 "$count users will be $typeTitle. Do you want to execute it?"77 ) === false) {78 $this->warn('Process is canceled by you.');79 return null;80 }81 $count = $this->handler->freeze($users);82 $this->warn("[{$now->format('Y.m.d H:i:s')}] $count users ware $typeTitle." . PHP_EOL);83 }84}...

Full Screen

Full Screen

freeze

Using AI Code Generation

copy

Full Screen

1require_once 'Freezer.php';2$freezer = new Freezer();3$freezer->freeze();4require_once 'Freezer.php';5$freezer = new Freezer();6$freezer->freeze();7require_once 'Freezer.php';8$freezer = new Freezer();9$freezer->freeze();10require_once 'Freezer.php';11$freezer = new Freezer();12$freezer->freeze();13require_once 'Freezer.php';14$freezer = new Freezer();15$freezer->freeze();16require_once 'Freezer.php';17$freezer = new Freezer();18$freezer->freeze();19require_once 'Freezer.php';20$freezer = new Freezer();21$freezer->freeze();22require_once 'Freezer.php';23$freezer = new Freezer();24$freezer->freeze();

Full Screen

Full Screen

freeze

Using AI Code Generation

copy

Full Screen

1require_once('Freezer.php');2$freezer = new Freezer();3$freezer->freeze();4require_once('Freezer.php');5$freezer = new Freezer();6$freezer->defrost();

Full Screen

Full Screen

freeze

Using AI Code Generation

copy

Full Screen

1require_once 'Freezer.php';2$freezer = new Freezer();3$freezer->freeze();4require_once 'Freezer.php';5$freezer = new Freezer();6$freezer->defrost();7require_once 'Freezer.php';8$freezer = new Freezer();9$freezer->setTemperature();10require_once 'Freezer.php';11$freezer = new Freezer();12$freezer->getTemperature();13require_once 'Freezer.php';14$freezer = new Freezer();15$freezer->isFrozen();16require_once 'Freezer.php';17$freezer = new Freezer();18$freezer->isDefrosted();19require_once 'Freezer.php';20$freezer = new Freezer();21$freezer->isDefrosting();22require_once 'Freezer.php';23$freezer = new Freezer();24$freezer->isFrozenSolid();25require_once 'Freezer.php';26$freezer = new Freezer();27$freezer->isFrozenLiquid();28require_once 'Freezer.php';29$freezer = new Freezer();30$freezer->isFrozenGas();31require_once 'Freezer.php';32$freezer = new Freezer();33$freezer->isDefrostedSolid();34require_once 'Freezer.php';35$freezer = new Freezer();36$freezer->isDefrostedLiquid();37require_once 'Freezer.php';38$freezer = new Freezer();39$freezer->isDefrostedGas();40require_once 'Freezer.php';41$freezer = new Freezer();

Full Screen

Full Screen

freeze

Using AI Code Generation

copy

Full Screen

1include 'Freezer.php';2$freezer = new Freezer();3$freezer->freeze();4include 'Freezer.php';5$freezer = new Freezer();6$freezer->freeze();

Full Screen

Full Screen

freeze

Using AI Code Generation

copy

Full Screen

1require_once('Freezer.php');2$freezer = new Freezer();3$freezer->freeze();4public function freeze() {5 $this->freezeSystem();6 $this->createBackup();7 $this->createFreezeFile();8 $this->displayFreezeMessage();9 $this->sendEmail();10}11private function freezeSystem() {12 $this->freezeFile = fopen($this->freezeFilePath, 'w');13 fwrite($this->freezeFile, '');14 fclose($this->freezeFile);15}16private function createBackup() {17 $this->backupFile = fopen($this->backupFilePath, 'w');18 fwrite($this->backupFile, '');19 fclose($this->backupFile);20}21private function createFreezeFile() {22 $this->freezeFile = fopen($this->freezeFilePath, 'w');23 fwrite($this->freezeFile, '');24 fclose($this->freezeFile);25}26private function displayFreezeMessage() {27 echo $this->freezeMessage;28}29private function sendEmail() {30 mail($this->email, $this->emailSubject, $this->emailBody);31}32require_once('Thawer.php');33$thawer = new Thawer();34$thawer->thaw();35public function thaw() {36 $this->thawSystem();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in Freezer

Trigger freeze code on LambdaTest Cloud Grid

Execute automation tests with freeze on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful