AfterUpdate callback

@param Array $args
@return Void
963754
public function afterUpdate(array &$args) {
        // Check if an email address was changed. If so, send a validation email
        $data = $args[2];
        if (array_key_exists('email', $data) && $this->_validateEmail) {
            $this->_onEmailChange($data['email'], 'update');
        }
    }
755488
public function handleUpdate(Args $args)
    {
        $flags = $args->isOptionSet('force')
            ? DiscoveryManager::OVERRIDE | DiscoveryManager::IGNORE_TYPE_NOT_FOUND
                | DiscoveryManager::IGNORE_TYPE_NOT_ENABLED
            : DiscoveryManager::OVERRIDE;

        $descriptorToUpdate = $this->getBindingByUuidPrefix($args->getArgument('uuid'));
        $bindingToUpdate = $descriptorToUpdate->getBinding();

        if (!$descriptorToUpdate->getContainingModule() instanceof RootModule) {
            throw new RuntimeException(sprintf(
                'Can only update bindings in the module "%s".',
                $this->modules->getRootModuleName()
            ));
        }

        if ($bindingToUpdate instanceof ResourceBinding) {
            $updatedBinding = $this->getUpdatedResourceBinding($args, $bindingToUpdate);
        } elseif ($bindingToUpdate instanceof ClassBinding) {
            $updatedBinding = $this->getUpdatedClassBinding($args, $bindingToUpdate);
        } else {
            throw new RuntimeException(sprintf(
                'Cannot update bindings of type %s.',
                get_class($bindingToUpdate)
            ));
        }

        $updatedDescriptor = new BindingDescriptor($updatedBinding);

        if ($this->bindingsEqual($descriptorToUpdate, $updatedDescriptor)) {
            throw new RuntimeException('Nothing to update.');
        }

        $this->discoveryManager->addRootBindingDescriptor($updatedDescriptor, $flags);

        return 0;
    }
1298412
public function update( array $args ) {

		$wp = $args ? reset( $args ) : NULL;

		if ( ! $wp instanceof \WP ) {
			return new NullLog();
		}

		$error = [];
		isset( $wp->query_vars[ 'error' ] ) and $error[] = $wp->query_vars[ 'error' ];
		is_404() and $error[] = '404 Page not found';

		if ( empty( $error ) ) {
			return new NullLog();
		}

		$url     = filter_var( add_query_arg( [] ), FILTER_SANITIZE_URL );
		$message = "Error on frontend request for url {$url}.";
		$context = [
			'error'        => $error,
			'query_vars'   => $wp->query_vars,
			'matched_rule' => $wp->matched_rule,
		];

		return new Debug( $message, Channels::HTTP, $context );
	}
592202
public function beforeUpdate(array &$args) {
        $data = &$args[1];
        foreach ($data as $key => $value) {
            /**
             * Save the current file value.
             * If it differs from the given value, it will be cleared
             * by afterUpdate.
             */
            if (in_array($key, $this->_fields)) {
                $this->_newValues[$key] = $value;
                if (!$this->_affectedRows) {
                    $model = $args[0];
                    $where = $args[2];
                    $affectedRows = $model->fetchAll($where);
                    $this->_affectedRows = $affectedRows;
                }
            }
        }
    }
286001
protected function initService(array $args = null) {
		if ($args === null) {
			return call_user_func($this->callback);
		}
		
		return call_user_func_array($this->callback, $args);
	}
1244854
public function init($args)
    {
        if (empty($args)) {
            return;
        }

        // Special case
        if (is_bool($args) && $args) {
            $args = $this->available;
        }

        // Iterate on all
        foreach ($args as $plugin => $settings) {
            $plugin = strtolower($plugin);

            if (!array_key_exists($plugin, $this->available)) {
                continue;
            }

            $plugin = str_replace('_', '-', $plugin);

            $function = Helpers::toFunctionFormat($plugin);
            $function = 'plugin'.ucfirst($function);
            $this->$function($settings);
        }
    }
283457
public function update( $args, $assoc_args ) {
		$updates = $this->get_translation_updates();

		if ( empty( $updates ) ) {
			WP_CLI::success( 'Translations are up to date.' );

			return;
		}

		if ( empty( $args ) ) {
			$args = array( null ); // Used for core.
		}

		$upgrader      = 'WP_CLI\\LanguagePackUpgrader';
		$results       = array();
		$num_to_update = 0;

		foreach ( $args as $slug ) {
			// Gets a list of all languages.
			$all_languages = $this->get_all_languages( $slug );

			$updates_per_type = array();

			// Formats the updates list.
			foreach ( $updates as $update ) {
				if ( null !== $slug && $update->slug !== $slug ) {
					continue;
				}

				$name = 'WordPress'; // Core.

				if ( 'plugin' === $update->type ) {
					$plugins     = get_plugins( '/' . $update->slug );
					$plugin_data = array_shift( $plugins );
					$name        = $plugin_data['Name'];
				} elseif ( 'theme' === $update->type ) {
					$theme_data = wp_get_theme( $update->slug );
					$name       = $theme_data['Name'];
				}

				// Gets the translation data.
				$translation = wp_list_filter( $all_languages, array( 'language' => $update->language ) );
				$translation = (object) reset( $translation );

				$update->Type    = ucfirst( $update->type );
				$update->Name    = $name;
				$update->Version = $update->version;

				if ( isset( $translation->english_name ) ) {
					$update->Language = $translation->english_name;
				}

				if ( ! isset( $updates_per_type[ $update->type ] ) ) {
					$updates_per_type[ $update->type ] = array();
				}
				$updates_per_type[ $update->type ][] = $update;
			}

			$obj_type          = rtrim( $this->obj_type, 's' );
			$available_updates = isset( $updates_per_type[ $obj_type ] ) ? $updates_per_type[ $obj_type ] : null;

			if ( ! is_array( $available_updates ) ) {
				continue;
			}

			$num_to_update += count( $available_updates );

			if ( ! Utils\get_flag_value( $assoc_args, 'dry-run' ) ) {
				// Update translations.
				foreach ( $available_updates as $update ) {
					WP_CLI::line( "Updating '{$update->Language}' translation for {$update->Name} {$update->Version}..." );

					$result = Utils\get_upgrader( $upgrader )->upgrade( $update );

					$results[] = $result;
				}
			}
		}

		// Only preview which translations would be updated.
		if ( Utils\get_flag_value( $assoc_args, 'dry-run' ) ) {
			$update_count = count( $updates );

			WP_CLI::line(
				sprintf(
					'Found %d translation %s that would be processed:',
					$update_count,
					WP_CLI\Utils\pluralize( 'update', $update_count )
				)
			);

			Utils\format_items( 'table', $updates, array( 'Type', 'Name', 'Version', 'Language' ) );

			return;
		}

		$num_updated = count( array_filter( $results ) );

		$line = sprintf( "Updated $num_updated/$num_to_update %s.", WP_CLI\Utils\pluralize( 'translation', $num_updated ) );

		if ( $num_to_update === $num_updated ) {
			WP_CLI::success( $line );
		} elseif ( $num_updated > 0 ) {
			WP_CLI::warning( $line );
		} else {
			WP_CLI::error( $line );
		}
	}
935447
public function onFlush(EventArgs $args)
    {
        $ea = $this->getEventAdapter($args);
        $om = $ea->getObjectManager();
        $uow = $om->getUnitOfWork();
        // check all scheduled updates
        $all = array_merge($ea->getScheduledObjectInsertions($uow), $ea->getScheduledObjectUpdates($uow));
        foreach ($all as $object) {
            $meta = $om->getClassMetadata(get_class($object));
            if (!$config = $this->getConfiguration($om, $meta->name)) {
                continue;
            }
            $changeSet = $ea->getObjectChangeSet($uow, $object);
            $needChanges = false;

            if ($uow->isScheduledForInsert($object) && isset($config['create'])) {
                foreach ($config['create'] as $field) {
                    list(, $new) = $changeSet[$field];
                    if ($new === null) { // let manual values
                        $needChanges = true;
                        $this->updateField($object, $ea, $meta, $field);
                    }
                }
            }

            if (isset($config['update'])) {
                foreach ($config['update'] as $field) {
                    $isInsertAndNull = $uow->isScheduledForInsert($object) && $changeSet[$field][1] === null;
                    if (!isset($changeSet[$field]) || $isInsertAndNull) { // let manual values
                        $needChanges = true;
                        $this->updateField($object, $ea, $meta, $field);
                    }
                }
            }

            if (!$uow->isScheduledForInsert($object) && isset($config['change'])) {
                foreach ($config['change'] as $options) {
                    if (isset($changeSet[$options['field']])) {
                        continue; // value was set manually
                    }

                    if (!is_array($options['trackedField'])) {
                        $singleField = true;
                        $trackedFields = array($options['trackedField']);
                    } else {
                        $singleField = false;
                        $trackedFields = $options['trackedField'];
                    }

                    foreach ($trackedFields as $tracked) {
                        $trackedChild = null;
                        $parts = explode('.', $tracked);
                        if (isset($parts[1])) {
                            if (isset($changeSet[$tracked])) {
                                $changes = $changeSet[$tracked];
                                if ($changes[0] != $changes[1]) {
                                    $needChanges = true;
                                    $this->updateField($object, $ea, $meta, $options['field']);
                                    continue;
                                }
                            }

                            $tracked = $parts[0];
                            $trackedChild = $parts[1];
                        }

                        if (isset($changeSet[$tracked])) {
                            $changes = $changeSet[$tracked];
                            if (isset($trackedChild)) {
                                $changingObject = $changes[1];
                                if (!is_object($changingObject)) {
                                    throw new UnexpectedValueException(
                                        "Field - [{$field}] is expected to be object in class - {$meta->name}"
                                    );
                                }
                                $objectMeta = $om->getClassMetadata(get_class($changingObject));
                                $om->initializeObject($changingObject);
                                $value = $objectMeta->getReflectionProperty($trackedChild)->getValue($changingObject);
                            } else {
                                $value = $changes[1];
                            }

                            if (($singleField && in_array($value, (array) $options['value'])) || $options['value'] === null) {
                                $needChanges = true;
                                $this->updateField($object, $ea, $meta, $options['field']);
                            }
                        }
                    }
                }
            }

            if ($needChanges) {
                $ea->recomputeSingleObjectChangeSet($uow, $meta, $object);
            }
        }
    }
885281
public function handleUpdate(Args $args)
    {
        $name = $args->getArgument('name');
        $descriptorToUpdate = $this->discoveryManager->getRootTypeDescriptor($name);
        $bindingParams = $descriptorToUpdate->getType()->getParameters();
        $description = $descriptorToUpdate->getDescription();
        $paramDescriptions = $descriptorToUpdate->getParameterDescriptions();

        $this->parseParamDescriptions($args, $paramDescriptions);
        $this->parseParams($args, $bindingParams);
        $this->parseUnsetParams($args, $bindingParams, $paramDescriptions);

        if ($args->isOptionSet('description')) {
            $description = $args->getOption('description');
        }

        $updatedDescriptor = new BindingTypeDescriptor(
            new BindingType($name, $bindingParams),
            $description,
            $paramDescriptions
        );

        if ($this->typesEqual($descriptorToUpdate, $updatedDescriptor)) {
            throw new RuntimeException('Nothing to update.');
        }

        $this->discoveryManager->addRootTypeDescriptor($updatedDescriptor, DiscoveryManager::OVERRIDE);

        return 0;
    }
176838
public function postUpdate(LifecycleEventArgs $args)
    {
        if ($args->getObject() instanceof BlockInterface) {
            $this->getService($args)->postUpdate($args->getObject());
        }
    }
592182
public function setCallArgument($arg)
    {
        $this->call_argument = $arg;
        $this->args =[
            $this->call_function,
            $this->call_argument
        ];
    }
39688
public function executeOne(...$args)
    {
        if ($this->isEmpty()) {
            return false;
        }
        $cb = $this->shift();
        if ($cb) {
            $cb(...$args);
            if ($cb instanceof CallbackWrapper) {
                $cb->cancel();
            }
        }
        return true;
    }
285134
public function after_upload($cb, $args = '')
    {
        if (is_callable($cb)) {
            $this->upload_callback      = $cb;
            $this->upload_callback_args = $args;
        } else {
            /* some sort of error... */
        }

        return $this;
    }
876117
public function onFlush(OnFlushEventArgs $args): void
    {
        $token = $this->getTokenStorage()->getToken();

        if (!$this->getPermissionManager()->isEnabled()
                || null === $token || $token instanceof ConsoleToken) {
            return;
        }

        $uow = $args->getEntityManager()->getUnitOfWork();
        $createEntities = $uow->getScheduledEntityInsertions();
        $updateEntities = $uow->getScheduledEntityUpdates();
        $deleteEntities = $uow->getScheduledEntityDeletions();

        $this->postResetPermissions = array_merge($createEntities, $updateEntities, $deleteEntities);
        $this->getPermissionManager()->preloadPermissions($this->postResetPermissions);

        $this->checkAllScheduledByAction($createEntities, 'create');
        $this->checkAllScheduledByAction($updateEntities, 'update');
        $this->checkAllScheduledByAction($deleteEntities, 'delete');
    }
124675
public function afterUpdate()
    {
        //only clean and change custom fields if they are been sent
        if (!empty($this->customFields)) {
            //replace old custom with new
            $allCustomFields = $this->getAllCustomFields();
            if (is_array($allCustomFields)) {
                foreach ($this->customFields as $key => $value) {
                    $allCustomFields[$key] = $value;
                }
            }

            //set
            $this->setCustomFields($allCustomFields);
            //clean old
            $this->cleanCustomFields($this->getId());
            //save new
            $this->saveCustomFields();
        }
    }
1318884
public function onFlush(OnFlushEventArgs $args): void
    {
        // Get the entity manager and unit of work.
        $em = $args->getEntityManager();
        $uow = $em->getUnitOfWork();

        // Check insertions for new events.
        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            foreach ($this->getInvitations($entity) as $invitation) {
                $em->persist($invitation);
                $uow->computeChangeset($em->getClassMetadata(Invitation::class), $invitation);
            }
        }

        // Check updates for updated events.
        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            foreach ($this->getInvitations($entity) as $invitation) {
                $em->persist($invitation);
                $uow->computeChangeset($em->getClassMetadata(Invitation::class), $invitation);
            }
        }
    }
1312491
public function updates( $args, $assoc_args ) {

    require_once dirname( __FILE__ ) . '/../modules/updates.php';
    $site_info = Seravo\Updates::seravo_admin_get_site_info();

    if ( $site_info['seravo_updates'] === true ) {
      WP_CLI::success( 'Seravo Updates: enabled' );
    } elseif ( $site_info['seravo_updates'] === true ) {
      WP_CLI::success('Seravo Updates: disabled' );
    } else {
      WP_CLI::error( 'Seravo API failed to return information about updates.' );
    }

  }