Bind the process to the server.

@param \Lawoole\Server\Server $server
345744
public function bind(Server $server)
    {
        if ($this->isBound()) {
            throw new LogicException('Process can be bound to server only once.');
        }

        $this->server = $server;

        $this->dispatchEvent('Bind', $server, $this);
    }
1174425
def set_server(self, server_pos, key, value):
        """"""
        self.servers.set_server(server_pos, key, value)
122711
public void bind(Handler<AsyncResult<Void>> completion) {
        logger.info("Starting server {}", name);
        context = vertx.getOrCreateContext();
        bind(port, completion);
    }
621267
public function initialize(DAV\Server $server)
    {
        $this->server = $server;
        $this->server->on('method:GET', [$this, 'httpGetEarly'], 90);
        $this->server->on('method:GET', [$this, 'httpGet'], 200);
        $this->server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel'], 200);
        if ($this->enablePost) {
            $this->server->on('method:POST', [$this, 'httpPOST']);
        }
    }
207035
public function onManagerStop(Server $server): void
    {
        $this->fire(ServerEvent::MANAGER_STOPPED, $server);
        $this->log("The manager process stopped. (PID {$server->manager_pid})");

        ServerUtil::removePidFile($this->pidFile);
    }
616452
public function initialize(Server $server)
    {
        $this->server = $server;
        $server->on('beforeMethod:*', [$this, 'beforeMethod']);
        $server->on('beforeCreateFile', [$this, 'beforeCreateFile']);
    }
799226
protected function configureServer($server, array $config)
    {
        if ($handler = $this->parseEventHandler($config)) {
            $server->setEventHandler($handler);
        }

        if (isset($config['listens']) && $config['listens']) {
            $this->configureServerSockets($server, $config['listens']);
        }

        if (isset($config['processes']) && $config['processes']) {
            $this->configureProcesses($server, $config['processes']);
        }

        return $server;
    }
865372
public function execute(Server $server)
    {
        $inTransaction = isset($this->options['session']) && $this->options['session']->isInTransaction();
        if ($inTransaction && isset($this->options['writeConcern'])) {
            throw UnsupportedException::writeConcernNotSupportedInTransaction();
        }

        $options = ['ordered' => $this->options['ordered']];

        if (
            ! empty($this->options['bypassDocumentValidation']) &&
            \MongoDB\server_supports_feature($server, self::$wireVersionForDocumentLevelValidation)
        ) {
            $options['bypassDocumentValidation'] = $this->options['bypassDocumentValidation'];
        }

        $bulk = new Bulk($options);
        $insertedIds = [];

        foreach ($this->documents as $i => $document) {
            $insertedIds[$i] = $bulk->insert($document);
        }

        $writeResult = $server->executeBulkWrite($this->databaseName . '.' . $this->collectionName, $bulk, $this->createOptions());

        return new InsertManyResult($writeResult, $insertedIds);
    }
771393
public function initialize(Server $server)
    {
        $this->server = $server;
        $server->on('method:POST', [$this, 'httpPost']);
        $server->on('propFind', [$this, 'propFind']);
        $server->on('propPatch', [$this, 'propPatch']);
        $server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
        $server->on('beforeUnbind', [$this, 'beforeUnbind']);
        $server->on('schedule', [$this, 'scheduleLocalDelivery']);
        $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);

        $ns = '{'.self::NS_CALDAV.'}';

        /*
         * This information ensures that the {DAV:}resourcetype property has
         * the correct values.
         */
        $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns.'schedule-outbox';
        $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns.'schedule-inbox';

        /*
         * Properties we protect are made read-only by the server.
         */
        array_push($server->protectedProperties,
            $ns.'schedule-inbox-URL',
            $ns.'schedule-outbox-URL',
            $ns.'calendar-user-address-set',
            $ns.'calendar-user-type',
            $ns.'schedule-default-calendar-URL'
        );
    }
532726
public function initialize(Server $server)
    {
        $this->server = $server;
        $server->on('method:GET', [$this, 'httpGet']);
        $server->on('method:OPTIONS', [$this, 'httpOptions']);
        $server->on('method:HEAD', [$this, 'httpHead']);
        $server->on('method:DELETE', [$this, 'httpDelete']);
        $server->on('method:PROPFIND', [$this, 'httpPropFind']);
        $server->on('method:PROPPATCH', [$this, 'httpPropPatch']);
        $server->on('method:PUT', [$this, 'httpPut']);
        $server->on('method:MKCOL', [$this, 'httpMkcol']);
        $server->on('method:MOVE', [$this, 'httpMove']);
        $server->on('method:COPY', [$this, 'httpCopy']);
        $server->on('method:REPORT', [$this, 'httpReport']);

        $server->on('propPatch', [$this, 'propPatchProtectedPropertyCheck'], 90);
        $server->on('propPatch', [$this, 'propPatchNodeUpdate'], 200);
        $server->on('propFind', [$this, 'propFind']);
        $server->on('propFind', [$this, 'propFindNode'], 120);
        $server->on('propFind', [$this, 'propFindLate'], 200);

        $server->on('exception', [$this, 'exception']);
    }
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);
                }
            }
        }
    }
1033621
public function initialize(DAV\Server $server)
    {
        if ($this->allowUnauthenticatedAccess) {
            $authPlugin = $server->getPlugin('auth');
            if (!$authPlugin) {
                throw new \Exception('The Auth plugin must be loaded before the ACL plugin if you want to allow unauthenticated access.');
            }
            $authPlugin->autoRequireLogin = false;
        }

        $this->server = $server;
        $server->on('propFind', [$this, 'propFind'], 20);
        $server->on('beforeMethod:*', [$this, 'beforeMethod'], 20);
        $server->on('beforeBind', [$this, 'beforeBind'], 20);
        $server->on('beforeUnbind', [$this, 'beforeUnbind'], 20);
        $server->on('propPatch', [$this, 'propPatch']);
        $server->on('beforeUnlock', [$this, 'beforeUnlock'], 20);
        $server->on('report', [$this, 'report']);
        $server->on('method:ACL', [$this, 'httpAcl']);
        $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
        $server->on('getPrincipalByUri', function ($principal, &$uri) {
            $uri = $this->getPrincipalByUri($principal);

            // Break event chain
            if ($uri) {
                return false;
            }
        });

        array_push($server->protectedProperties,
            '{DAV:}alternate-URI-set',
            '{DAV:}principal-URL',
            '{DAV:}group-membership',
            '{DAV:}principal-collection-set',
            '{DAV:}current-user-principal',
            '{DAV:}supported-privilege-set',
            '{DAV:}current-user-privilege-set',
            '{DAV:}acl',
            '{DAV:}acl-restrictions',
            '{DAV:}inherited-acl-set',
            '{DAV:}owner',
            '{DAV:}group'
        );

        // Automatically mapping nodes implementing IPrincipal to the
        // {DAV:}principal resourcetype.
        $server->resourceTypeMapping['Sabre\\DAVACL\\IPrincipal'] = '{DAV:}principal';

        // Mapping the group-member-set property to the HrefList property
        // class.
        $server->xml->elementMap['{DAV:}group-member-set'] = 'Sabre\\DAV\\Xml\\Property\\Href';
        $server->xml->elementMap['{DAV:}acl'] = 'Sabre\\DAVACL\\Xml\\Property\\Acl';
        $server->xml->elementMap['{DAV:}acl-principal-prop-set'] = 'Sabre\\DAVACL\\Xml\\Request\\AclPrincipalPropSetReport';
        $server->xml->elementMap['{DAV:}expand-property'] = 'Sabre\\DAVACL\\Xml\\Request\\ExpandPropertyReport';
        $server->xml->elementMap['{DAV:}principal-property-search'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalPropertySearchReport';
        $server->xml->elementMap['{DAV:}principal-search-property-set'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalSearchPropertySetReport';
        $server->xml->elementMap['{DAV:}principal-match'] = 'Sabre\\DAVACL\\Xml\\Request\\PrincipalMatchReport';
    }
453865
public function setUp(Server $server, $type)
    {
        $server->registerHandler($this->backend->getUserLibraryInstance()->generateTypeHandler());
        if(($user = $this->backend->getUserLibraryInstance()->getUserLoggedIn()) != null){
            $server->registerHandler($user->generateTypeHandler());
        }
        $server->registerHandler($this->backend->getPageOrderInstance()->generateTypeHandler());
        if(($page = $this->backend->getPageOrderInstance()->getCurrentPage()) != null){
            $server->registerHandler($page->generateTypeHandler());
        }
        $server->registerHandler($this->backend->getLoggerInstance()->generateTypeHandler());
        $server->registerHandler($this->backend->getUpdaterInstance()->generateTypeHandler());
        $server->registerHandler($this->backend->getSiteInstance()->generateTypeHandler());
        $server->registerHandler($this->backend->getFileLibraryInstance()->generateTypeHandler());
        $server->registerHandler(new PostGetFilesArrayAccessTypeHandlerImpl());
        $server->registerHandler(new ParserTypeHandlerImpl());




    }
970773
private function processServerVariables(array $server)
    {
        foreach ($server as $key => $value) {
            $this->server[$key] = $value;

            if (strpos($key, 'HTTP_') === 0) {
                $key = str_replace('_', '-', substr($key, 5));

                $this->headers[$key] = $value;
            }
        }

        $uri     = $server['REQUEST_URI'];
        $uriPath = parse_url($uri, PHP_URL_PATH);

        $this->server['REQUEST_URI']      = $uri;
        $this->server['REQUEST_URI_PATH'] = $uriPath;

        $this->isEncrypted = !(empty($server['HTTPS']) || strcasecmp($server['HTTPS'], 'off') === 0);

        $this->server['SERVER_PROTOCOL'] = substr($server['SERVER_PROTOCOL'], -3);

        if (isset($server['CONTENT_LENGTH'])) {
            $this->headers['CONTENT-LENGTH'] = $server['CONTENT_LENGTH'];
        }

        if (isset($server['CONTENT_TYPE'])) {
            $this->headers['CONTENT-TYPE'] = $server['CONTENT_TYPE'];
        }
    }
188191
public function initialize(Server $server)
    {
        $this->server = $server;

        $server->xml->elementMap['{DAV:}share-resource'] = 'Sabre\\DAV\\Xml\\Request\\ShareResource';

        array_push(
            $server->protectedProperties,
            '{DAV:}share-mode'
        );

        $server->on('method:POST', [$this, 'httpPost']);
        $server->on('propFind', [$this, 'propFind']);
        $server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);
        $server->on('onHTMLActionsPanel', [$this, 'htmlActionsPanel']);
        $server->on('onBrowserPostAction', [$this, 'browserPostAction']);
    }
386522
public function server(array $server)
    {
        foreach ((array) $server as $key => $value)
        {
            $string = strtolower(substr($key, 5));

            $key = str_replace('_', '-', $string);

            if (strpos($key, 'HTTP_') === 0)
            {
                $this->headers[$key] = $value;
            }
        }
    }
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})");
    }