Merges with other events.

@param EventsInterface $source The data source

@return null|array If the source was passed returns
null, source data otherwise
343115
public function merge(EventsInterface $source = null)
    {
        if (null === $source) {
            return $this->events;
        }
        $this->events = array_merge($this->events, $source->merge());
    }
539173
protected function mergeEvents($events) {
        $result = array();
        foreach ($events as $event) {
            /* @var $event \ManiaScript\Builder\Event\Custom */
            if ($event->getInline()) {
                $code = $event->getCode() . PHP_EOL;
            } else {
                $code = $this->buildHandlerFunctionCall($event) . PHP_EOL;
            }
            if (!isset($result[$event->getName()])) {
                 $result[$event->getName()] = '';
            }
            $result[$event->getName()] .= $code;
        }
        return $result;
    }
467738
public final static function merge(string $source, array $Values){
		return self::encode(array_merge(self::decode($source), $Values));
	}
1192541
public function handle(EventInterface $event)
    {
        $headers = $this->headersfactory->headers();
        $this->publisher->publish($this->serializer->serialize($event), $event->getName(), $headers);
    }
338614
protected function pullTriggers(EventInterface $event)
    {
        $event->stopPropagation(false);

        foreach ($this->getTriggers($event) as $trigger) {
            $trigger($event);

            if ($event->propagationIsStopped()) {
                break;
            }
        }

        return $event;
    }
1106622
public function get(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        $redirectUrl = $event->getConfig()['indexRedirect'];

        if ($redirectUrl) {
            $response->setStatusCode(307);
            $response->headers->set('Location', $redirectUrl);
            return;
        }

        $response->setStatusCode(200, 'Hell Yeah');

        $baseUrl = $request->getSchemeAndHttpHost() . $request->getBaseUrl();

        $model = new Model\ArrayModel();
        $model->setData([
            'site' => 'http://imbo.io',
            'source' => 'https://github.com/imbo/imbo',
            'issues' => 'https://github.com/imbo/imbo/issues',
            'docs' => 'http://docs.imbo.io',
        ]);

        $response->setModel($model);

        // Prevent caching
        $response->setMaxAge(0)
                 ->setPrivate();
        $response->headers->addCacheControlDirective('no-store');
    }
787136
protected function prepEventForDispatch(EventInterface $event)
    {
        // automagically inject attributes from injectors
        $attributes = $this->getValuesFromAttributeInjectors();
        $e = clone $event; // we don't want to manipulate the original event
        foreach ($attributes as $k => $v) {
            if (!$e->hasAttribute($k)) {
                $e->setAttribute($k, $v);
            }
        }
        return $e;
    }
1258445
public function process(EventInterface $event)
    {
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }

        $options = $optionsProvider->getOptions($pane);
        if ($options->getType() == 'search') {
            $this->error(self::ReorderSearch);
            return $this->redirect($event);
        }
        if ($options->getRoot() == 'trash') {
            $this->error(self::ReorderTrash);
            return $this->redirect($event);
        }
        if ($options->getOrderBy() != 'natural') {
            $this->error(self::UnmanagedOrder);
            return $this->redirect($event);
        }

        $posNew = $event->getParam('position');
        $posOld = $event->getParam('old_position');
        if (empty($posNew) || empty($posOld)) {
            return;
        }
        $positions = array_diff_assoc($posNew, $posOld);
            foreach ($positions as $id => $position) {
                try {
                    $mapper->beginTransaction();
                    $tid = $mapper->getTransactionIdentifier();
                    $this->mapper->reorder($id, $position, $tid);
                    $mapper->commit();
                } catch (UnavailableSourceException $e) {
                    $mapper->rollBack();
                    $this->setValue($id)->error(self::SourceNotFound);
                } catch (UnavailableDestinationException $e) {
                    $mapper->rollBack();
                    $this->error(self::DestinationNotFound);

                    // the destination is not available for all elements
                    break;
                } catch (Exception $e) {
                    $mapper->rollBack();
                    if (DEBUG_MODE) {
                        throw new DebugException(
                            $translator->translate('Error: ') . $e->getMessage(),
                            $e->getCode(),
                            $e
                        );
                    }
                    $meta = $mapper->findMetaById($id);
                    $name = isset($meta['title']) ? $meta['title'] : $id;
                    $this->setValue($name)->error(self::UnexpectedError);
                    break;
                }
            }

        return $this->redirect($event);
    }
1372915
public function merge(&$source)
  {
    if ( $source instanceof Registry ){
      // Load the variables into the registry's default namespace
      foreach($source->toArray() as $k => $v){
        if ( $v !== null && $v !== '' ){
          $this->data->{$k} = $v;
        }
      }
      return true;
    }
    return false;
  }
161241
public function mergeEventListeners($eventListeners)
    {
        if ($eventListeners instanceof EventManagerInterface) {
            $eventListeners = $eventListeners->getEventListeners();
        }

        foreach (((array) $eventListeners) as $eventName => $listeners) {
            $queue = [];
            if (isset($this->eventListeners[$eventName])) {
                $innerListeners = clone $this->eventListeners[$eventName];
                $innerListeners->setExtractFlags(ListenerQueue::EXTR_DATA);
                foreach ($innerListeners as $callback) {
                    $queue[] = $callback;
                }
            }
            $listeners = clone $listeners;
            $listeners->setExtractFlags(ListenerQueue::EXTR_BOTH);
            foreach ($listeners as $listener) {
                if (!in_array($listener['data'], $queue)) {
                    $this->attach($eventName, $listener['data'], $listener['priority']);
                }
            }
        }

        return true;
    }
1001697
public function subscribe(EventInterface $event) {
        $resources = Resource::getAllResources();

        if ($this->params['additionalResources']) {
            $resources = array_merge($resources, $this->params['additionalResources']);
        }

        $events = [];
        foreach ($resources as $resource) {
            $events[$resource] = ['checkAccess' => 500];
        }

        $manager = $event->getManager();
        $manager->addCallbacks($event->getHandler(), $events);
    }
1014098
public function process(EventInterface $event)
    {
        $events = $this->getEventManager();
        $mapper = $this->getMapper();
        $optionsProvider = $this->getOptionsProvider();
        $translator = $this->getTranslator();
        $pane = $event->getParam('pane');
        if (! $optionsProvider->hasIdentifier($pane)) {
            return;
        }
        $ids = $event->getParam('id');
        if (empty($ids)) {
            return;
        }
        $options = $optionsProvider->getOptions($pane);
        if ($options->getRoot() == 'site') {
            $this->error(self::DeleteFromSite);
            return $this->redirect($event);
        }
        foreach ($ids as $id) {
            try {
                $mapper->beginTransaction();
                $tid = $mapper->getTransactionIdentifier();
                $events->trigger(
                    __FUNCTION__ . '.delete.pre',
                    null,
                    [
                        'content' => $id,
                        'tid' => $tid,
                    ]
                );
                $mapper->delete($id, $tid);
                $mapper->commit();
            } catch (UnavailableSourceException $e) {
                $mapper->rollBack();
                $this->setValue($id)->error(self::SourceNotFound);
            } catch (Exception $e) {
                if (DEBUG_MODE) {
                    throw new DebugException(
                        $translator->translate('Error: ') . $e->getMessage(),
                        $e->getCode(),
                        $e
                    );
                }
                $meta = $mapper->findMetaById($id);
                $name = isset($meta['title']) ? $meta['title'] : $id;
                $this->setValue($name)->error(self::UnexpectedError);
            }
        }

        return $this->redirect($event, 'sc-admin/file/delete');
    }
816510
public function put(EventInterface $event) {
        $request = $event->getRequest();
        $metadata = json_decode($request->getContent(), true);

        $event->getManager()
            ->trigger('db.metadata.delete')
            ->trigger('db.metadata.update', [
                'metadata' => $metadata,
            ]);

        $model = new Model\Metadata();
        $model->setData($metadata);

        $event->getResponse()->setModel($model);
    }
91473
protected function mergeStorage(StorageInterface $storage)
    {
        foreach ($storage->all() as $id => $object) {
            $this->stack->getScope('global')->add($object);
        }
    }
665686
public function loadImage(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();

        $event->getDatabase()->load(
            $request->getUser(),
            $request->getImageIdentifier(),
            $response->getModel()
        );
    }
44293
public function convertSource(SourceInterface $source): void
    {
        $converters = $source->data()->get('converters');
        if (!$converters || !is_array($converters)) {
            $converters = ['null'];
        }

        foreach ($converters as $converter) {
            $this->eventDispatcher->dispatch(
                Sculpin::EVENT_BEFORE_CONVERT,
                new ConvertEvent($source, $converter, $this->formatterManager->defaultFormatter())
            );
            $this->converter($converter)->convert(new SourceConverterContext($source));
            $this->eventDispatcher->dispatch(
                Sculpin::EVENT_AFTER_CONVERT,
                new ConvertEvent($source, $converter, $this->formatterManager->defaultFormatter())
            );
        }
    }
155240
public function handle(EventInterface $event)
    {

        try {
            // load the application server instance
            /** @var \AppserverIo\Psr\ApplicationServer\ApplicationServerInterface $applicationServer */
            $applicationServer = $this->getApplicationServer();

            // write a log message that the event has been invoked
            $applicationServer->getSystemLogger()->info($event->getName());

            // load the service instance and prepare the filesystem
            /** @var \AppserverIo\Appserver\Core\Api\ContainerService $service */
            $service = $applicationServer->newService('AppserverIo\Appserver\Core\Api\ContainerService');
            $service->prepareFileSystem();

        } catch (\Exception $e) {
            $applicationServer->getSystemLogger()->error($e->__toString());
        }
    }