Tracks specific resource change by provided callback.

@param ResourceInterface|string $resource   resource to track
@param callable                 $callback   callback to call on change
@param integer                  $eventsMask event types bitmask
500597
public function trackByListener($resource, $callback, $eventsMask = FilesystemEvent::ALL)
    {
        $this->track($trackingId = md5((string) $resource.$eventsMask), $resource, $eventsMask);
        $this->addListener($trackingId, $callback);
    }
1136699
public function bind(string $event, callable $callback) {
        // We can't bind to something that isn't callable
        if (!is_callable($callback)) {
            return false;
        }

        if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
            $this->bindings[$event] = [];
        }

        // Check if this event is already registered
        $signature = $this->hash($callback);
        if (array_key_exists($signature, $this->bindings[$event])) {
            return $signature;
        }

        $this->bindings[$event][$signature] = $callback;
        return $signature;
    }
322590
public function call($callback, array $parameters = array())
    {
        $this->events[] = $event = new CallbackEvent($this->mutex, $callback, $parameters);

        return $event;
    }
558692
public static function use(string $name, callable $callback)
    {
        $resource = static::getResource($name);
        $result = null;
        try{
            $result = call_user_func($callback, $resource, $resource->getInstance());
        }
        finally{
            static::releaseResource($resource);
        }
        return $result;
    }
83676
public function onDelete(DeleteResourceEvent $event)
    {
        $ds = DIRECTORY_SEPARATOR;

        /** @var File $resource */
        $resource = $event->getResource();
        $workspace = $resource->getResourceNode()->getWorkspace();
        $hashName = $resource->getHashName();

        $archiveFile = $this->filesDir.$ds.'webresource'.$ds.$workspace->getUuid().$ds.$hashName;
        $webResourcesPath = $this->uploadDir.$ds.'webresource'.$ds.$workspace->getUuid().$ds.$hashName;

        if (file_exists($archiveFile)) {
            $event->setFiles([$archiveFile]);
        }
        if (file_exists($webResourcesPath)) {
            try {
                $this->deleteFiles($webResourcesPath);
            } catch (\Exception $e) {
            }
        }
        $this->om->remove($resource);
        $event->stopPropagation();
    }
435067
public function registerCallback($event, $callback)
    {
        $this->checkEventType($event);
        $this->events[$event][] = $callback;
    }
99289
public function onLoad(LoadResourceEvent $event)
    {
        /** @var Path $path */
        $path = $event->getResource();

        $event->setData([
            'path' => $this->serializer->serialize($path),
            'userEvaluation' => $this->serializer->serialize(
                $this->userProgressionManager->getUpdatedResourceUserEvaluation($path)
            ),
        ]);
        $event->stopPropagation();
    }
1017781
protected function onUpdate(callable $callback, $entityClass = null)
    {
        $this->checkIfInitialized();

        return $this->processEntities($this->uow->getScheduledEntityUpdates(), self::OPERATION_UPDATE, $callback, $entityClass);
    }
47367
public function addLifecycleCallback($callback, $event)
    {
        if (!isset(Event::$lifecycleCallbacks[$event])) {
            throw new MappingException(sprintf(
                '%s is not a valid lifecycle callback event',
                $event
            ));
        }
        $this->lifecycleCallbacks[$event][] = $callback;
    }
1355559
public function on($event, $callback) {
		if (!is_callable($callback)) {
			throw new ListenException(var_export($callback, true) . " is not callback");
		}
		$this->callback[$event] = $callback;
	}
571875
public function setCallback(callable $callback): EventObserver
    {
        $this->callback = $callback;
        $this->id = $this->getId($callback);

        return $this;
    }
394999
public function onNodeNewLabels(ResourceEvent $event)
    {
        $event->ignoreDefaultChan();
        foreach ($event->getArgument('new_labels') as $labelId) {
            $event->addResourceChanId('label', $labelId);
        }
    }
967090
public function resourceFilterByFn(\Closure $callback)
    {
        $this->filterJSFiles($callback);
        $this->filterJSInline($callback);
        $this->filterCSSFiles($callback);
        $this->filterCSSInline($callback);
    }
569795
public function logChangeSet(ResourceNode $node)
    {
        $uow = $this->om->getUnitOfWork();
        $uow->computeChangeSets();
        $changeSet = $uow->getEntityChangeSet($node);

        if (count($changeSet) > 0) {
            $this->dispatcher->dispatch(
                'log',
                'Log\LogResourceUpdate',
                array($node, $changeSet)
            );
        }
    }
572706
public function register(string $name, $callback) : Event
    {
        if (is_null($name)) {
            throw new \RuntimeException(sprintf('Event name cannot be empty in %s', __FUNCTION__));
        }

        if (is_null($callback)) {
            throw new \RuntimeException(sprintf('Empty parameter passed as callback in %s function', __FUNCTION__));
        }

        if (!isset($this->events[$name])) {
            $this->events[$name] = [];
        }

        if (!in_array($callback, $this->events[$name])) {
            $this->events[$name][] = $callback;
        }

        return $this;
    }
625671
private function createResource(callable $callback)
	{
		// Turn off error reporting while we try to initiate the request
		$level = error_reporting(0);
		$resource = call_user_func($callback);
		error_reporting($level);

		// If the resource could not be created, then grab the last error and
		// throw an exception.
		if (!is_resource($resource)) {
			$message = 'Error creating resource: ';
			foreach ((array) error_get_last() as $key => $value) {
				$message .= "[{$key}] {$value} ";
			}
			throw new \Exception(trim($message));
		}

		return $resource;
	}
886816
public function dispatchUntil(ActionEvent $event, callable $callback): void
    {
        foreach ($this->getListeners($event) as $listenerHandler) {
            $listener = $listenerHandler->getActionEventListener();
            $listener($event);

            if ($event->propagationIsStopped()) {
                return;
            }
            if ($callback($event) === true) {
                return;
            }
        }
    }