This initializes the plugin.

This function is called by Sabre\DAV\Server, after
addPlugin is called.

This method should set up the required event subscriptions.

@param DAV\Server $server
432114
public function initialize(DAV\Server $server)
    {
        $this->server = $server;

        if (is_null($this->server->getPlugin('sharing'))) {
            throw new \LogicException('The generic "sharing" plugin must be loaded before the caldav sharing plugin. Call $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); before this one.');
        }

        array_push(
            $this->server->protectedProperties,
            '{'.Plugin::NS_CALENDARSERVER.'}invite',
            '{'.Plugin::NS_CALENDARSERVER.'}allowed-sharing-modes',
            '{'.Plugin::NS_CALENDARSERVER.'}shared-url'
        );

        $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}share'] = 'Sabre\\CalDAV\\Xml\\Request\\Share';
        $this->server->xml->elementMap['{'.Plugin::NS_CALENDARSERVER.'}invite-reply'] = 'Sabre\\CalDAV\\Xml\\Request\\InviteReply';

        $this->server->on('propFind', [$this, 'propFindEarly']);
        $this->server->on('propFind', [$this, 'propFindLate'], 150);
        $this->server->on('propPatch', [$this, 'propPatch'], 40);
        $this->server->on('method:POST', [$this, 'httpPost']);
    }
597820
public function attach(ServerObserver $observer)
    {
        if ($this->state) {
            throw new \Error("Cannot attach observers after the server has started");
        }

        $this->observers->attach($observer);
    }
885321
public function bindSwooleServerEvents($server)
    {
        $bindersMap = $this->getBinders();

        foreach ($bindersMap as $event => $handler) {
            $server->on($event, $handler);
        }

        return $this;
    }
1052911
public function initialize($instance, ServiceLocatorInterface $serviceLocator)
    {
        if ($instance instanceof EventManagerAwareInterface)
            if ($instance->getEventManager() instanceof EventManagerInterface) {
                $instance->getEventManager()->setSharedManager(
                    $serviceLocator->get('SharedEventManager')
                );
            } else {
                $instance->setEventManager($serviceLocator->get('EventManager'));
            }

        if ($instance instanceof ServiceManagerAwareInterface)
            $instance->setServiceManager($serviceLocator);

        if ($instance instanceof ServiceLocatorAwareInterface)
            $instance->setServiceLocator($serviceLocator);
    }
894196
public function setCasServer($server)
    {
        $this->casServer = $server;
        $this->guzzleClient = new Client(['base_uri' => $server, 'cookies' => true]);
    }
68777
public function init()
    {
        parent::init();

        self::$plugin = $this;

        $this->_setPluginComponents();
        $this->_setLogging();
        $this->_registerCpRoutes();
        $this->_registerEventHandlers();
    }
861150
public function init($server = null)
    {
        $server = $server ?: $_SERVER;

        $this->set('args', array());
        if (isset($server['argv'])) {
            // first argument is script name.
            $args = $server['argv'];
            $script = array_shift($args);
            $this->script_name = $script;

            // parse options.
            foreach ($args as $arg) {
                // is long option
                // --foo
                //   => foo=true
                // --foo=bar
                //   => foo=bar
                if (preg_match('/^--(..+)/', $arg, $matches)) {
                    $option = explode('=', $matches[1]);
                    $key = array_shift($option);
                    $value = $option ? join('=', $option) : true;
                    $this->add($key, $value);
                }

                // is short option
                // -abc
                //   => option.a=true, option.b=true, option.c=true
                // -abc=foo
                //   => option.a=true, option.b=true, option.c=foo
                elseif (preg_match('/^-(.+)/', $arg, $matches)) {
                    $option = $matches[1];
                    for ($i = 0; $i < strlen($option); $i++) {
                        $j = $i + 1;
                        $key = $option[$i];
                        if (isset($option[$j]) && $option[$j] === '=') {
                            $value = substr($option, $j + 1);
                            $this->set('option.' . $key, $value);
                            break;
                        } else {
                            $value = true;
                            $this->set('option.' . $key, $value);
                        }
                    }
                }
                // is else to args.
                else {
                    $this->add('args', $arg);
                }
            }
        }
    }
383768
private void configureServer(ServerBartender server)
  {
    // XXX: mixing server/client
    
    ServerNetwork serverNet = _serverMap.get(server.getId());
    
    if (serverNet == null) {
      serverNet = new ServerNetwork(_system, server);
      
      configServer(serverNet, server);

      serverNet.init();
      
      _serverMap.put(server.getId(), serverNet);
    }
  }
1038532
protected function createListenServers(Server $server): void
    {
        $this->fire(ServerEvent::PORT_CREATE, $this);

        foreach ($this->attachedListeners as $name => $cb) {
            $info = '';

            if ($cb instanceof \Closure) {
                $port = $cb($server, $this);
            } else {
                /**
                 * @var ServerInterface       $this
                 * @var PortListenerInterface $cb
                 */
                $port = $cb->attachTo($this, $server);
            }

            if ($port) {
                $type = $port->type === SWOOLE_SOCK_TCP ? 'tcp' : 'udp';
                $info = "(<cyan>$type://{$port->host}:{$port->port}</cyan>)";
            }

            $this->log("Attach the port listen server <info>$name</info>$info to the main server");
        }

        $this->attachedListeners = []; // reset.
        $this->fire(ServerEvent::PORT_CREATED, [$this]);
    }
1182524
public function listen(Server $server, SwoolePort $swoolePort = null)
    {
        if ($this->isBound()) {
            throw new LogicException('The server socket can be bound to server only once.');
        }

        if ($swoolePort == null) {
            // If the passed Swoole port is null, that means we are calling this
            // method directly, so here we need to call the server method "listen"
            // to do the actual binding.
            return $server->listen($this);
        }

        $this->server = $server;
        $this->swoolePort = $swoolePort;

        $this->swoolePort->set($this->options);

        $this->registerEventCallbacks($this->serverSocketEvents);

        $this->dispatchEvent('Bind', $server, $this);
    }
215781
public function onStart(SwooleServer $server)
    {
        @cli_set_process_title($this->name . ': master process/reactor threads; port=' . $this->swoolePort);
        // Send SIGTERM to master pid to shutdown service
        $this->pid = $server->master_pid;
        // Send SIGUSR1 to master pid to reload workers
        $this->managerPid = $server->manager_pid;

        $this->startCommandHandler();

        $this->updateServiceInfo('current', [
            'pid' => $this->pid,
            'manager_pid' => $this->managerPid,
            'port' => $this->swoolePort,
        ]);
        $this->cliOutput('info', "pid = {$this->pid}; port = {$this->swoolePort}");
        $this->cliOutput('info', 'Service started.');
    }
2774
public function setup($page, $context) {
        // This only requires execution once per request.
        static $jsinitialised = false;
        if ($jsinitialised) {
            return;
        }
        $jsinitialised = true;

        // Set up the media manager so that media plugins requiring JS are initialised.
        $mediamanager = core_media_manager::instance($page);
    }
624805
public function init() {
		// Registration class runs Filter::add($this) in __construct.
		$registration = new \Boldgrid\Library\Library\Registration();

		// Update class runs Filter::add($this) in __construct.
		$update = new \Boldgrid\Library\Library\Update();

		// PostNewKey class runs Filter::add($this) in __construct.
		$postNewKey = new \Boldgrid\Library\Library\Key\PostNewKey();

		$pluginChecker = new \Boldgrid\Library\Library\Plugin\Checker();
		$pluginChecker->run();

		Configs::setItem( 'menu-external', new Menu\External() );
		Configs::setItem( 'menu-reseller', new Menu\Reseller() );
		Configs::setItem( 'page-connect', new Page\Connect() );
		Configs::setItem( 'assets', new Asset() );
		new Editor();
	}
945072
protected function configureServerSockets($server, array $serverSockets)
    {
        foreach ($serverSockets as $config) {
            $serverSocket = $this->createServerSocket($config);

            if ($handler = $this->parseEventHandler($config)) {
                $serverSocket->setEventHandler($handler);
            }

            $server->listen($serverSocket);
        }
    }
784171
public function onManagerStart(Server $server): void
    {
        // $server->manager_pid;
        $this->fire(ServerEvent::MANAGER_STARTED, $server);

        // file_put_contents($this->pidFile, ',' . $server->manager_pid, FILE_APPEND);
        ServerUtil::createPidFile($server->manager_pid, $this->pidFile);
        ProcessUtil::setTitle("{$this->name}: manager");

        $this->log("The <comment>manager</comment> process success started. (PID:{$server->manager_pid})");
    }
735988
public function handle(AbstractServer $server): void
    {
        parent::handle($server); // TODO: Change the autogenerated stub

        /* @var TaskContract $object */
        $object = $this->data['object'];
        /* @var array $params */
        $params = $this->data['params'];

        try {
            $result = $object->handle($server, ...$params);

            $this->server->finish($result);
        } catch (\Throwable $exception) {
            if (method_exists($object, 'failed')) {
                $object->failed($exception);
            }

            throw $exception;
        }
    }
1104572
private function setServer()
    {
        if (isset($_SERVER)) {
            foreach ($_SERVER as $k => $v) {
                $this->log->debug("[ SERVER Params ]" . $k . ": " . $v, []);
                $this->server->$k = $v;
                $this->parameters["server"][$k] = $v;
            }
            unset($_SERVER);
        }
    }