Proposes connection tuning parameters

@param AMQPReader $args
175190
protected function connection_tune($args)
    {
        $v = $args->read_short();
        if ($v) {
            $this->channel_max = $v;
        }

        $v = $args->read_long();
        if ($v) {
            $this->frame_max = $v;
        }

        // use server proposed value if not set
        if ($this->heartbeat === null) {
            $this->heartbeat = $args->read_short();
        }

        $this->x_tune_ok($this->channel_max, $this->frame_max, $this->heartbeat);
    }
1206564
public function getAMQPConnection(array $options)
    {
        if (!class_exists(AMQPStreamConnection::class)) {
            throw new \DomainException('Please install php-amqplib/php-amqplib first.');
        }

        $defaultOptions = [
            'host' => 'localhost',
            'port' => 5672,
            'user' => 'guest',
            'password' => 'guest',
        ];

        $options = array_merge($defaultOptions, $options);

        return new AMQPStreamConnection(
            $options['host'],
            $options['port'],
            $options['user'],
            $options['password']
        );
    }
342749
private function setCallable( $args ) {
		$route      = array_shift( $args );
		$RealParams = array();

		// Before Middleware
		if ( is_array( $args[0] ) && isset( $args[0][0] ) ) {
			$this->middleware['before'] = array_shift( $args );
		}

		if ( ! is_callable( $args[0] ) && ! is_string( $args[0] ) && ! is_array( $args[0] ) ) {
			$controller               = array_shift( $args );
			$RealParams['controller'] = $controller;
		}

		//if ($route == '/' && count( $this->route->_getParams() ) <= 0 ) {
		if ( preg_match(
			'/(^\\/$)|(^\\/(\\?(\\w|\\d|\\=|\\&|\\-|\\.|_|\\/){0,}){0,}$)/',
			$route . $this->route->getParamStr(),
			$matches, PREG_OFFSET_CAPTURE
		) ) {
			//$this->callable = array_pop($args);
			$callFunc = array_pop( $args );
			$params   = array();

			if ( is_array( $callFunc ) ) {
				$keys   = array_keys( $callFunc );
				$params = $callFunc[ $keys[0] ];

				if ( ! is_array( $params ) ) {
					$params = array( $params );
				}

				$callFunc = $keys[0];
			}

			$callFunc           = $this->createCallbackFromString( $callFunc, $params );
			$this->callable     = Closure::bind( $callFunc, $this, get_class() );
			$this->RoutedStatus = TRUE;
		} else {
			$RoutePattern = str_replace( '/', '\\/', $route );
			/**
			 * ID: Konversi route kedalam pattern parameter optional
			 * EN: Convert route in optional parameter pattern
			 */
			$RoutePattern = preg_replace( '/\\\\\\/\\(:\\w+\\)/', '(\\/\\\\w+){0,}', $RoutePattern, - 1 );
			/**
			 * ID: Konversi route kedalam pattern parameter wajib
			 * EN: Cover route in required parameter pattern
			 */
			$RoutePattern = preg_replace( '/:\\w+/', '([\\w+|\\=|\\-|\\_|\\.]){1,}', $RoutePattern, - 1 );
			$RoutePattern = str_replace( '\\/\\w++', '(((\/){0,}\\w+){0,})', $RoutePattern );

			if ( $route != '/' &&
			     preg_match(
				     '/(^' . $RoutePattern . '$)|((^' . $RoutePattern . ')+(\\?(\\w|\\d|\\=|\\&|\\-|\\.|_|\\/){0,}){0,}$)/',
				     $this->route->getParamStr(),
				     $matches,
				     PREG_OFFSET_CAPTURE
			     )
			) {
				$callFunc = array_shift( $args );
				$params   = array();

				if ( is_array( $callFunc ) ) {
					$keys   = array_keys( $callFunc );
					$params = $callFunc[ $keys[0] ];

					if ( ! is_array( $params ) ) {
						$params = array( $params );
					}

					$callFunc = $keys[0];
				}

				$callFunc = $this->createCallbackFromString( $callFunc, $params );
				//$this->callable = array_pop($args);
				$this->callable     = Closure::bind( $callFunc, $this, get_class() );
				$this->RoutedStatus = TRUE;
				$p                  = explode( '/', $route );

				while ( list( $key, $value ) = each( $p ) ) {

					if ( substr( trim( $value ), - 1 ) == '+' ) {

						if ( isset( $matches[2][0] ) && ! empty( $matches[2][0] ) ) {
							$RealParams[ $value ] = explode( '/', substr( $matches[2][0], 1 ) );
						} elseif ( isset( $matches[7][0] ) && ! empty( $matches[7][0] ) ) {
							$RealParams[ $value ] = explode( '/', substr( $matches[7][0] ), 1 );
						} else {
							$RealParams[ $value ] = array();
						}

					} elseif ( substr( trim( $value, '/' ), 0, 1 ) == ':' ) {
						$getpos               = ( strpos( $this->route->_getParams( $key ), '?' ) > 0 ) ? strpos( $this->route->_getParams( $key ), '?' ) : strlen( $this->route->_getParams( $key ) );
						$RealParams[ $value ] = substr( $this->route->_getParams( $key ), 0, $getpos );
					} elseif ( substr( trim( $value, '/' ), 0, 2 ) == '(:' && substr( trim( $value, '/' ), - 1, 1 ) == ')' ) {

						if ( $this->route->_getParams( $key ) != NULL ) {
							$getpos               = ( strpos( $this->route->_getParams( $key ), '?' ) > 0 ) ? strpos( $this->route->_getParams( $key ), '?' ) : strlen( $this->route->_getParams( $key ) );
							$RealParams[ $value ] = substr( $this->route->_getParams( $key ), 0, $getpos );
						}

					}

				}

			}

		}

		Route::$destination = $route;
		$this->route->setParams( $RealParams );

		//print_r($args);

		// After Middleware
		if ( count( $args ) > 0 && is_array( $args[0] ) ) {
			$this->middleware['after'] = array_shift( $args );
		}

	}
2498
public function preUpdate(LifecycleEventArgs $args) : void
    {
        $entity = $args->getEntity();

        if ($entity instanceof UpdatedInterface) {
            $entity->setUpdatedAt(new \DateTime());
        }
    }
1016796
public function beforeFetch(&$args) {
        $model = &$args[0];
        $select = &$args[1];
        if (!$model->isCmsContext()) {
            return;
        }
        // Sanity check: this project might be spawned without the is_editable column,
        // it was added to Snippet at May 1 2013.
        if ($this->getFieldConfiguration('is_editable')) {
            $select->where('is_editable = ?', 1);
        }
    }
199780
public function connect() {
        $readWriteTimeout = max($this->read_timeout, $this->write_timeout); //?
        try {
            $this->connection = new AMQPStreamConnection(
                $this->host,
                $this->port,
                $this->login,
                $this->password,
                $this->vhost,
                false,                      //insist
                'AMQPLAIN',                 //login method
                null,                       //login response
                'en_US',                    //locale
                $this->connect_timeout,     // connect_timeout
                $readWriteTimeout,          // read_write_timeout
                null,                       // context
                $this->keepalive,           // keepalive
                $this->heartbeat            // heartbeat configuration
            );

            //Several exception types might be thrown
        } catch (Exception $e){
            throw new AMQPConnectionException($e->getMessage(), $e->getCode(), $e->getPrevious());
        }
    }
524491
public function preUpdate(LifecycleEventArgs $args)
    {
        $entity = $args->getObject();
        $em = $args->getObjectManager();
        $uow = $em->getUnitOfWork();

        if ($entity instanceof ContentRoute) {
            $template = $this->templates[$entity->getTemplateName()];
            $changeset = $uow->getEntityChangeSet($entity);
            if (isset($changeset['templateName']) && $args->hasChangedField('templateName')) {
                $entity->setTemplate($template['template']);
                $entity->setController($template['controller']);

                $uow->recomputeSingleEntityChangeSet(
                    $em->getClassMetadata('NetworkingInitCmsBundle:ContentRoute'),
                    $entity
                );
            }
        }
    }
638267
public function postConnect(ConnectionEventArgs $args)
    {
        $db = $args->getConnection();
        $platform = $args->getDatabasePlatform();
        $platformName = $platform->getName();

        if ($platformName === 'sqlite') {
            $db->query('PRAGMA synchronous = OFF');
        } elseif ($platformName === 'mysql') {
            /** @see http://docs.doctrine-project.org/en/latest/cookbook/mysql-enums.html */
            $platform->registerDoctrineTypeMapping('enum', 'string');

            // Set database character set & collation as configured
            $charset = $this->config->get('general/database/charset');
            $collation = $this->config->get('general/database/collate');
            $db->executeQuery('SET NAMES ? COLLATE ?', [$charset, $collation], [PDO::PARAM_STR]);

            // Increase group_concat_max_len to 100000. By default, MySQL
            // sets this to a low value – 1024 – which causes issues with
            // certain Bolt content types – particularly repeaters – where
            // the outcome of a GROUP_CONCAT() query will be more than 1024 bytes.
            // See also: http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_group_concat_max_len
            $groupConcatMaxLen = $this->config->get('general/database/group_concat_max_len', 100000);
            $db->executeQuery('SET SESSION group_concat_max_len = ?', [$groupConcatMaxLen], [PDO::PARAM_INT]);
        } elseif ($platformName === 'postgresql') {
            /** @see https://github.com/doctrine/dbal/pull/828 */
            $db->executeQuery("SET NAMES 'utf8'");
        }
    }
864418
public function evaluateArgs(array $args) : void
    {
        array_shift($args);

        if (count($args) < 2) {
            $this->out->red("Not enough arguments: expects 2, got ".(count($args) - 1).".");
            return;
        }

        $this->setName($args[0]);
        $this->setLocation($args[1]);
        if (isset($args[2])) {
            $this->additionalArgs(array_slice($args, 2, count($args)));
        }

        return;
    }
275412
public function setConfig($arg1, $arg2 = null)
    {
        if (is_array($arg1)) {
            $this->config = $arg1;
        } else {
            $this->config[$arg1] = $arg2;
        }
        
        return $this;
    }
1292882
public function preUpdate(PreUpdateEventArgs $args)
    {
        $entity = $args->getObject();

        /** @var object $entity */
        if (true === in_array(EditableEntityTrait::class, class_uses($entity))) {
            $entity->setUpdated(new DateTime());
        }
    }
12357
public function preFlush(PreFlushEventArgs $args)
    {
        $uow = $args->getEntityManager()->getUnitOfWork();
        $result = $uow->getIdentityMap();
        if(isset($result[$this->targetClass])) {
            foreach ($result[$this->targetClass] as $entity) {
                $this->updateEntity($entity);
            }
        }
    }
321167
def establish_connection(self):
        """"""
        conninfo = self.connection
        if not conninfo.hostname:
            raise KeyError("Missing hostname for AMQP connection.")
        if conninfo.userid is None:
            raise KeyError("Missing user id for AMQP connection.")
        if conninfo.password is None:
            raise KeyError("Missing password for AMQP connection.")
        if not conninfo.port:
            conninfo.port = self.default_port
        conn = amqp.Connection(host=conninfo.hostname,
                               port=conninfo.port,
                               userid=conninfo.userid,
                               password=conninfo.password,
                               virtual_host=conninfo.virtual_host)
        return conn
1153465
public function beforeInsert(array &$args) {
        $data  = &$args[1];

        $auth = Garp_Auth::getInstance();
        if ($auth->isLoggedIn()) {
            $userData = $auth->getUserData();
            $data[self::_AUTHOR_COLUMN] = $userData['id'];
        }
    }
919054
public function beforeInsert(&$args) {
        $model = $args[0];
        $data = &$args[1];
        foreach ($this->_relationConfig as $foreignModel => $modelRelationConfig) {
            $foreignKey = $modelRelationConfig[self::FOREIGN_KEY_COLUMN_KEY];
            // only act if the foreign key column is filled
            if (!empty($data[$foreignKey])) {
                $maxWeight = $this->findHighestWeight($model, $data[$foreignKey], $modelRelationConfig);
                $data[$modelRelationConfig[self::WEIGHT_COLUMN_KEY]] = ($maxWeight+1);
            }
        }
    }
587779
public function beforeFetch(array &$args) {
        $model = $args[0];
        $select = &$args[1];
        if (!$model->isCmsContext()) {
            return;
        }
        if (!Garp_Auth::getInstance()->isAllowed(get_class($model), 'fetch')
            && Garp_Auth::getInstance()->isAllowed(get_class($model), 'fetch_own')
        ) {
            $currentUserData = Garp_Auth::getInstance()->getUserData();
            $currentUserId   = $currentUserData['id'];
            $select->where(self::_AUTHOR_COLUMN . ' = ?', $currentUserId);
        }
    }
278536
public function beforeUpdate(array &$args) {
        $data = &$args[1];
        $data[$this->_fields['modifiedField']] = date(self::DATE_FORMAT);
    }