Register this plugin to be responsible for a specific task

@param string $task Task name (only characters [a-z0-9_-] are allowed)
@param string $owner Plugin name that registers this action
162692
public function register_task($task, $owner)
    {
        // tasks are irrelevant in framework mode
        if (!class_exists('rcmail', false)) {
            return true;
        }

        if ($task != asciiwords($task, true)) {
            rcube::raise_error(array('code' => 526, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Invalid task name: $task."
                    ." Only characters [a-z0-9_.-] are allowed"), true, false);
        }
        else if (in_array($task, rcmail::$main_tasks)) {
            rcube::raise_error(array('code' => 526, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Cannot register taks $task;"
                    ." already taken by another plugin or the application itself"), true, false);
        }
        else {
            $this->tasks[$task] = $owner;
            rcmail::$main_tasks[] = $task;
            return true;
        }

        return false;
    }
793218
public function view(UserPolicy $user, Task $task)
    {
        if ($user->canDo('task.task.view') && $user->isAdmin()) {
            return true;
        }

        return $user->id == $task->user_id && get_class($user) === $task->user_type;
    }
418064
public void register(Task task) {
        Optional.ofNullable(task)
                .filter(t -> t.getTask() != null)
                .filter(t -> StringUtils.hasText(t.getName()))
                .ifPresent(t -> checkTaskMap.put(t.getName(), t));
    }
698040
public static function registerTasks(array $tasks)
    {
        // Register Tasks
        foreach ($tasks as $key => $task) {
            $roles = array_key_exists('roles', $task) ? $task['roles'] : null;
            self::registerTask($key, $task['desc'], $task['callback'], $roles);
        }
    }
431093
public function process(ContainerBuilder $container)
    {
        if (!$container->hasDefinition(static::TASK_REGISTRY)) {
            return;
        }

        $registry = $container->getDefinition(static::TASK_REGISTRY);

        foreach ($container->findTaggedServiceIds(static::TASK_TAG) as $id => $tag) {
            $registry->addMethodCall("addTask", [new Reference($id)]);
        }
    }
530869
public function addTask(Task $task)
    {
        if (!isset($this->tasks[$task->uniq])) {
            $this->tasks[$task->uniq] = $task;
            ++$this->tasksCount;
        }
    }
1201193
function setComponent (Component $owner)
  {
    $this->component = $owner;
    $props           = $this->getPropertiesOf (type::content);
    foreach ($props as $name => $value)
      if (!is_null ($value)) {
        /** @var Component $c */
        $c = clone $value;
        $c->attachTo ($owner);
        $this->$name = $c;
      }
    $props = $this->getPropertiesOf (type::collection);
    foreach ($props as $name => $values)
      if (!empty($values))
        $this->$name = Component::cloneComponents ($values, $owner);
  }
90618
public function chown(string $file, string $owner = null, bool $recursive = false) : void
    {
        if ($owner === null) {
            $owner = $this->getUser();
        }

        $this->call('update_chown', [
            'chown_path' => $file,
            'chown_user' => $owner,
            'recursive' => $recursive ? 'Y' : 'N',
        ]);
    }
119268
public static function action($task)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();
        Splash::log()->deb("Admin => ".$task->name." (".$task->desc.")");

        //====================================================================//
        // Initial Response
        $response = self::getEmptyResponse($task);

        switch ($task->name) {
            //====================================================================//
            //  READING OF SERVER OBJECT LIST
            case SPL_F_GET_OBJECTS:
                $response->data = Splash::objects();
                if (false != $response->data) {
                    $response->result = true;
                }

                break;
            //====================================================================//
            //  READING OF SERVER WIDGETS LIST
            case SPL_F_GET_WIDGETS:
                $response->data = Splash::widgets();
                if (false != $response->data) {
                    $response->result = true;
                }

                break;
            //====================================================================//
            //  READING OF SERVER SELFTEST RESULTS
            case SPL_F_GET_SELFTEST:
                $response->result = Splash::selfTest();
                $response->data = $response->result;

                break;
            //====================================================================//
            //  READING OF SERVER INFORMATIONS
            case SPL_F_GET_INFOS:
                $response->data = Splash::informations();
                if (false != $response->data) {
                    $response->result = true;
                }

                break;
            default:
                Splash::log()->err("Admin - Requested task not found => ".$task->name);

                break;
        }

        return $response;
    }
606135
void registerTaskStarted(Task task) {
        synchronized (m_activeTasks) {
            String mapKey = createMapKey(task.getTenant(), task.getTaskID());
            if (m_activeTasks.put(mapKey, task) != null) {
                m_logger.warn("Task {} registered as started but was already running", mapKey);
            }
        }
    }
1040980
void registerTaskEnded(Task task) {
        synchronized (m_activeTasks) {
            String mapKey = createMapKey(task.getTenant(), task.getTaskID());
            if (m_activeTasks.remove(mapKey) == null) {
                m_logger.warn("Task {} registered as ended but was not running", mapKey);
            }
        }
    }
296861
public void setOwner(ListenerOwner owner)
    {
        super.setOwner(owner);
        if (owner == null)
            return;
        try   {     // Open this table and move to the control record
            if (!this.getOwner().isOpen())
                this.getOwner().open();     // Open the control file
            if (this.getOwner().getEditMode() == Constants.EDIT_NONE)
                this.doNewRecord(true);     // Read the control file
        } catch (DBException e)   {
            return;
        }
    }
26000
public function updateTenancy(Authenticatable $user, TenantParticipantContract $owner, TenantParticipantContract $creator)
    {
        $this->user          = $user;
        $this->tenantOwner   = $owner;
        $this->tenantCreator = $creator;

        return $this;
    }
576377
public static function action($task)
    {
        //====================================================================//
        // Stack Trace
        Splash::log()->trace();
        Splash::log()->deb("Widgets => ".$task->name);
        //====================================================================//
        // Initial Response
        $response = self::getEmptyResponse($task);

        //====================================================================//
        // Execute Requested Task
        //====================================================================//
        switch ($task->name) {
            //====================================================================//
            //  READING OF SERVER WIDGETS LIST
            case SPL_F_WIDGET_LIST:
                $response->data = Splash::widgets();

                break;
            //====================================================================//
            //  READING A WIDGET DEFINITION
            case SPL_F_WIDGET_DEFINITION:
                $response->data = Splash::widget($task->params->type)->description();

                break;
            //====================================================================//
            //  READING A WIDGET CONTENTS
            case SPL_F_WIDGET_GET:
                $response->data = Splash::widget($task->params->type)->get($task->params->params);

                break;
            default:
                Splash::log()->err(
                    "Info Router - Requested task was not found => ".$task->name." (".$task->desc.")"
                );

                break;
        }

        //====================================================================//
        // Task results post treatment
        if (false != $response->data) {
            $response->result = true;
        }

        return $response;
    }
1237014
function registerTask(Task, name, options) {
  if (this.tasks[name]) {
    log.error(new Error('Task "' + name + '" is already registered.'));
    return;
  }
  if (!Task || !Task.prototype || typeof Task.prototype.run !== 'function') {
    log.error(new Error('Task "' + name + '" should implement "run" method.'));
    return;
  }
  this.tasks[name] = new Task(options || []);
}
196196
protected function execute(callable $task)
	{
		if ($this->beingDestroyed) {
			throw new \RuntimeException(self::ERROR_BEING_DESTROY);
		}
		
		$this->taskQueue->enqueue($task);
		
		if ($this->idleQueue->isEmpty() && ($this->size + $this->beingCreatedSize) < $this->maxSize) {
			$this->newResource();
		}
		
		$this->taskDequeue();
	}
159698
public function changeOwner($owner)
    {
        $request = new ChangeOwnerRequest($this->groupId, $owner);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }