public function delete()
    {
        $this->record['status'] = 'deleted';
        DB::table($this->table)->where('ID', $this->id)->update([
            'status' => $this->record['status'],
        ]);
    }

public function delete ( ) { $ this -> record [ 'status' ] = 'deleted' ; DB :: table ( $ this -> table ) -> where ( 'ID' , $ this -> id ) -> update ( [ 'status' => $ this -> record [ 'status' ] , ] ) ; }

Delete the job from the queue.

@return void


public function getClassMetadata($className)
    {
        try{
            return $this->entityManager->getClassMetadata($className);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function getClassMetadata ( $ className ) { try { return $ this -> entityManager -> getClassMetadata ( $ className ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Returns the ORM metadata descriptor for a class.

The class name must be the fully-qualified class name without a leading backslash
(as it is returned by get_class($obj)) or an aliased class name.

Examples:
MyProject\Domain\User
sales:PriceRequest

Internal note: Performance-sensitive method.

@param string $className

@return \Doctrine\ORM\Mapping\ClassMetadata

Returns the ORM metadata descriptor for a class .


public function flush($entity = null)
    {
        try{
            return $this->entityManager->flush($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function flush ( $ entity = null ) { try { return $ this -> entityManager -> flush ( $ entity ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Flushes all changes to objects that have been queued up to now to the database.
This effectively synchronizes the in-memory state of managed objects with the
database.

If an entity is explicitly passed to this method only this entity and
the cascade-persist semantics + scheduled inserts/removals are synchronized.

@param null|object|array $entity

@return void

@throws \Doctrine\ORM\OptimisticLockException If a version check on an entity that
makes use of optimistic locking fails.

Flushes all changes to objects that have been queued up to now to the database . This effectively synchronizes the in - memory state of managed objects with the database .


public function find($entityName, $id, $lockMode = null, $lockVersion = null)
    {
        try{
            return $this->entityManager->find($entityName, $id, $lockMode, $lockVersion);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function find ( $ entityName , $ id , $ lockMode = null , $ lockVersion = null ) { try { return $ this -> entityManager -> find ( $ entityName , $ id , $ lockMode , $ lockVersion ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Finds an Entity by its identifier.

@param string       $entityName  The class name of the entity to find.
@param mixed        $id          The identity of the entity to find.
@param integer|null $lockMode    One of the \Doctrine\DBAL\LockMode::* constants
or NULL if no specific lock mode should be used
during the search.
@param integer|null $lockVersion The version of the entity to find when using
optimistic locking.

@return object|null The entity instance or NULL if the entity can not be found.

@throws OptimisticLockException
@throws ORMInvalidArgumentException
@throws TransactionRequiredException
@throws ORMException


public function clear($entityName = null)
    {
        try{
            return $this->entityManager->clear($entityName);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function clear ( $ entityName = null ) { try { return $ this -> entityManager -> clear ( $ entityName ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Clears the EntityManager. All entities that are currently managed
by this EntityManager become detached.

@param string|null $entityName if given, only entities of this type will get detached

@return void

Clears the EntityManager . All entities that are currently managed by this EntityManager become detached .


public function remove($entity)
    {
        try{
            return $this->entityManager->remove($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function remove ( $ entity ) { try { return $ this -> entityManager -> remove ( $ entity ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Removes an entity instance.

A removed entity will be removed from the database at or before transaction commit
or as a result of the flush operation.

@param object $entity The entity instance to remove.

@return void

@throws ORMInvalidArgumentException


public function refresh($entity)
    {
        try{
            return $this->entityManager->refresh($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function refresh ( $ entity ) { try { return $ this -> entityManager -> refresh ( $ entity ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Refreshes the persistent state of an entity from the database,
overriding any local changes that have not yet been persisted.

@param object $entity The entity to refresh.

@return void

@throws ORMInvalidArgumentException

Refreshes the persistent state of an entity from the database overriding any local changes that have not yet been persisted .


public function getRepository($entityName)
    {
        try{
            return $this->entityManager->getRepository($entityName);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function getRepository ( $ entityName ) { try { return $ this -> entityManager -> getRepository ( $ entityName ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Gets the repository for an entity class.

@param string $entityName The name of the entity.

@return \Doctrine\ORM\EntityRepository The repository class.

Gets the repository for an entity class .


public function contains($entity)
    {
        try{
            return $this->entityManager->contains($entity);
        } catch(ORMException $e) {
            if (!$this->entityManager->isOpen()) {
                $this->resetEntityManager();
            }
            throw $e;
        }
    }

public function contains ( $ entity ) { try { return $ this -> entityManager -> contains ( $ entity ) ; } catch ( ORMException $ e ) { if ( ! $ this -> entityManager -> isOpen ( ) ) { $ this -> resetEntityManager ( ) ; } throw $ e ; } }

Determines whether an entity instance is managed in this EntityManager.

@param object $entity

@return boolean TRUE if this EntityManager currently manages the given entity, FALSE otherwise.

Determines whether an entity instance is managed in this EntityManager .


public static function create($conn, Configuration $config, EventManager $eventManager = null)
    {
        try{
            return self::getEntityManager()->create($conn, $config, $eventManager);
        } catch(ORMException $e) {
            if (!self::getEntityManager()->isOpen()) {
                self::resetEntityManager();
            }
            throw $e;
        }
    }

public static function create ( $ conn , Configuration $ config , EventManager $ eventManager = null ) { try { return self :: getEntityManager ( ) -> create ( $ conn , $ config , $ eventManager ) ; } catch ( ORMException $ e ) { if ( ! self :: getEntityManager ( ) -> isOpen ( ) ) { self :: resetEntityManager ( ) ; } throw $ e ; } }

Factory method to create EntityManager instances.

@param mixed         $conn         An array with the connection parameters or an existing Connection instance.
@param Configuration $config       The Configuration instance to use.
@param EventManager  $eventManager The EventManager instance to use.

@return EntityManager The created EntityManager.

@throws \InvalidArgumentException
@throws ORMException

Factory method to create EntityManager instances .


public function processXcdr(XcdrListenerInterface $listener, array$options = array())
    {
        $xcdrRequest = new XcdrRequest($listener, $options);
        $schema = $xcdrRequest->getSchema();

        ini_set("soap.wsdl_cache_enabled", "0");

        $soapServer = new \SoapServer(null, array(
            'uri' => $schema,
            'soap_version' => SOAP_1_2,
        ));

        $soapServer->setObject($xcdrRequest);

        try {
            ob_start();
            $soapServer->handle();
        } catch (\Exception $e) {
            return array(
                'status' => 'error',
                'type' => 'soap_fault',
                'code' => $e->getCode(),
                'message' => $e->getMessage(),
                'class' => get_class($this)
            );
        }

        $result = $this->filterResponse(ob_get_clean(), $schema, 'xcdr');

        return array(
            'status' => 'success',
            'result' => $result
        );
    }

public function processXcdr ( XcdrListenerInterface $ listener , array $ options = array ( ) ) { $ xcdrRequest = new XcdrRequest ( $ listener , $ options ) ; $ schema = $ xcdrRequest -> getSchema ( ) ; ini_set ( "soap.wsdl_cache_enabled" , "0" ) ; $ soapServer = new \ SoapServer ( null , array ( 'uri' => $ schema , 'soap_version' => SOAP_1_2 , ) ) ; $ soapServer -> setObject ( $ xcdrRequest ) ; try { ob_start ( ) ; $ soapServer -> handle ( ) ; } catch ( \ Exception $ e ) { return array ( 'status' => 'error' , 'type' => 'soap_fault' , 'code' => $ e -> getCode ( ) , 'message' => $ e -> getMessage ( ) , 'class' => get_class ( $ this ) ) ; } $ result = $ this -> filterResponse ( ob_get_clean ( ) , $ schema , 'xcdr' ) ; return array ( 'status' => 'success' , 'result' => $ result ) ; }


public function performMerge(array $ancestor, array $local, array $remote)
    {
        // Returning a new Array for now. Can return the modified ancestor as well.
        $merged = [];
        foreach ($ancestor as $key => $value) {
            // Checks if the value contains an array itself.
            if (is_array($value) && array_key_exists($key, $local) && array_key_exists($key, $remote)) {
                $merged[$key] = $this->performMerge(
                    $value,
                    $local[$key],
                    $remote[$key]
                );
            } else {
                if (array_key_exists($key, $local) && array_key_exists($key, $remote)) {
                    $merged[$key] = $this->merge(
                        $ancestor[$key],
                        $local[$key],
                        $remote[$key],
                        $key
                    );
                } elseif (array_key_exists($key, $local)) {
                    if ($ancestor[$key] != $local[$key]) {
                        throw new ConflictException("A conflict has occured");
                    }
                } elseif (array_key_exists($key, $remote)) {
                    if ($ancestor[$key] != $remote[$key]) {
                        throw new ConflictException("A conflict has occured");
                    }
                } else {
                    unset($merged[$key]);
                }
            }
        }
        return $merged;
    }

Perform merge on associative array

@param array $ancestor
@param array $local
@param array $remote

@return array


protected function merge($x, $y, $z, $key)
    {
        // Convert the value into array.
        $ancestor = (strpos($x, PHP_EOL) !== false ? explode(PHP_EOL, $x) : array($x));
        $local = (strpos($y, PHP_EOL) !== false ? explode(PHP_EOL, $y) : array($y));
        $remote = (strpos($z, PHP_EOL) !== false ? explode(PHP_EOL, $z) : array($z));

        // Count number of lines in value or elements in new formed array.
        $count_ancestor = count($ancestor);
        $count_remote = count($remote);
        $count_local = count($local);

        // If number of lines is different in all 3 values.
        // For example : addition in remote and removal in local node.
        //
        // Else get the value of number of lines in updated node.
        // For example : Addition of 2 lines in local.
        // Suppose: $count_ancestor = 2 and $count_remote = 2
        // then, $count_local would be 4 now.
        if ($count_ancestor != $count_local
            && $count_local!= $count_remote
            && $count_ancestor != $count_remote
        ) {
            $merged = $this->linesAddedRemovedAndModified(
                $ancestor,
                $local,
                $remote,
                $count_ancestor,
                $count_local,
                $count_remote
            );
        } else {
            // Store the updated count value in a variable $count.
            if ($count_ancestor == $count_local) {
                $count = $count_remote;
            } else {
                $count = $count_local;
            }
            // If $count > $count_ancestor, that means lines have been added.
            // Otherwise, lines has been removed or modified.
            if ($count > $count_ancestor) {
                $merged = $this->linesAddedOrModified(
                    $ancestor,
                    $local,
                    $remote,
                    $count,
                    $count_remote,
                    $count_ancestor,
                    $count_local
                );
            } else {
                $merged = $this->linesRemovedOrModified(
                    $ancestor,
                    $local,
                    $remote,
                    $count_ancestor,
                    $count_local,
                    $count_remote
                );
            }
        }
        // Convert returned array back to string.
        $merged[$key] = implode(PHP_EOL, $merged);
        return $merged[$key];
    }

Function to perform merge. Do not call it directly.

@param string $x
@param string $y
@param string $z
@param mixed $key

@return mixed
@throws Exception

Function to perform merge . Do not call it directly .


protected function linesAddedOrModified(
        array $ancestor,
        array $local,
        array $remote,
        $count,
        $count_remote,
        $count_ancestor,
        $count_local
    ) {
        $merged = [];
        $counter = 0;
        // For all ancestors lines, it will check local and remote
        // and make sure only one of them has been edited.
        // Otherwise, throw an Exception.
        foreach ($ancestor as $key => $value) {
            $counter = $counter + 1;
            if ($ancestor[$key] == $local[$key]) {
                $merged[$key] = $remote[$key];
            } elseif ($ancestor[$key] == $remote[$key]
                || $local[$key] == $remote[$key]) {
                $merged[$key] = $local[$key];
            } else {
                throw new ConflictException("A conflict has occured");
            }
        }
        // Once done with ancestor lines, we have hunk of
        // lines added. We will add them as they are.
        // If the lines are added in both remote and local,
        // We will make sure they are same or throw exception.
        for ($i = $count_ancestor; $i < $count; $i++) {
            if ($count_ancestor == $count_remote) {
                $merged[$i] == $local[$i];
            } elseif ($count_ancestor == $count_local) {
                $merged[$i] = $remote[$i];
            } elseif ($count_local == $count_remote) {
                if ($local[$i] == $remote[$i]) {
                    $merged[$i] = $local[$i];
                } else {
                    throw new ConflictException("A conflict has occured");
                }
            }
        }
        return $merged;
    }

Handles the addition of lines.

@param array $ancestor
@param array $local
@param array $remote
@param $count
@param $count_remote
@param $count_ancestor
@param $count_local

@return array
@throws Exception


protected function linesRemovedOrModified(
        array $ancestor,
        array $local,
        array $remote,
        $count_ancestor,
        $count_local,
        $count_remote
    ) {
        $merged = [];
        $count_array = [$count_ancestor, $count_local, $count_remote];
        sort($count_array);
        $mincount = min($count_local, $count_ancestor, $count_remote);

        // First for loop compares all 3 nodes and returns updated node.
        for ($key = 0; $key < $mincount; $key++) {
            if ($ancestor[$key] == $local[$key]) {
                $merged[$key] = $remote[$key];
            } elseif ($ancestor[$key] == $remote[$key]
                || $local[$key] == $remote[$key]) {
                $merged[$key] = $local[$key];
            } else {
                throw new ConflictException("A conflict has occured");
            }
        }

        for ($key = $mincount; $key < $count_array[1]; $key++) {
            if ($mincount == $count_local && $ancestor[$key] != $remote[$key]) {
                throw new ConflictException("A whole new conflict arised");
            } elseif ($mincount == $count_remote
                && $ancestor[$key] != $local[$key]) {
                throw new ConflictException("A whole new conflict arised");
            }
        }
        return $merged;
    }

Handles removal or modification of lines

@param array $ancestor
@param array $local
@param array $remote
@param int $count_ancestor
@param int $count_local
@param int $count_remote

@return array
@throws Exception
@internal param int $count


public function NotifyXcdrRecord($msgHeader, $format, $type, $cdr)
    {
        $this->msgHeader = $msgHeader;
        $this->registrationID = $msgHeader->registrationID;
        $this->transactionID = $msgHeader->transactionID;
        $this->cdrFormat = $format;
        $this->cdrType = $type;
        $this->cdrRecord = $cdr;

        $response = $this->listener->processRecord($this, null);

        if (!$this->isValid()) return;
        return $response;
    }

public function NotifyXcdrRecord ( $ msgHeader , $ format , $ type , $ cdr ) { $ this -> msgHeader = $ msgHeader ; $ this -> registrationID = $ msgHeader -> registrationID ; $ this -> transactionID = $ msgHeader -> transactionID ; $ this -> cdrFormat = $ format ; $ this -> cdrType = $ type ; $ this -> cdrRecord = $ cdr ; $ response = $ this -> listener -> processRecord ( $ this , null ) ; if ( ! $ this -> isValid ( ) ) return ; return $ response ; }


public function register( PimpleContainer $container ) {
		$container['wp'] = $container->factory( function() {
			return isset( $GLOBALS['wp'] ) ? $GLOBALS['wp'] : null;
		} );

		$container['wpdb'] = $container->factory( function() {
			return isset( $GLOBALS['wpdb'] ) ? $GLOBALS['wpdb'] : null;
		} );

		$container['wp_query'] = $container->factory( function() {
			return isset( $GLOBALS['wp_query'] ) ? $GLOBALS['wp_query'] : null;
		} );

		$container['wp_rewrite'] = $container->factory( function() {
			return isset( $GLOBALS['wp_rewrite'] ) ? $GLOBALS['wp_rewrite'] : null;
		} );

		$container['wp_filesystem'] = $container->factory( function() {
			if ( ! function_exists( 'WP_Filesystem' ) ) {
				require_once ABSPATH . '/wp-admin/includes/file.php';
			}

			if ( ! isset( $GLOBALS['wp_filesystem'] ) ) {
				WP_Filesystem();
			}

			return $GLOBALS['wp_filesystem'];
		} );

		$container['wp_object_cache'] = $container->factory( function() {
			if ( ! isset( $GLOBALS['wp_object_cache'] ) && function_exists( 'wp_cache_init' ) ) {
				wp_cache_init();
			}

			return isset( $GLOBALS['wp_object_cache'] ) ? $GLOBALS['wp_object_cache'] : null;
		} );
	}

public function register ( PimpleContainer $ container ) { $ container [ 'wp' ] = $ container -> factory ( function ( ) { return isset ( $ GLOBALS [ 'wp' ] ) ? $ GLOBALS [ 'wp' ] : null ; } ) ; $ container [ 'wpdb' ] = $ container -> factory ( function ( ) { return isset ( $ GLOBALS [ 'wpdb' ] ) ? $ GLOBALS [ 'wpdb' ] : null ; } ) ; $ container [ 'wp_query' ] = $ container -> factory ( function ( ) { return isset ( $ GLOBALS [ 'wp_query' ] ) ? $ GLOBALS [ 'wp_query' ] : null ; } ) ; $ container [ 'wp_rewrite' ] = $ container -> factory ( function ( ) { return isset ( $ GLOBALS [ 'wp_rewrite' ] ) ? $ GLOBALS [ 'wp_rewrite' ] : null ; } ) ; $ container [ 'wp_filesystem' ] = $ container -> factory ( function ( ) { if ( ! function_exists ( 'WP_Filesystem' ) ) { require_once ABSPATH . '/wp-admin/includes/file.php' ; } if ( ! isset ( $ GLOBALS [ 'wp_filesystem' ] ) ) { WP_Filesystem ( ) ; } return $ GLOBALS [ 'wp_filesystem' ] ; } ) ; $ container [ 'wp_object_cache' ] = $ container -> factory ( function ( ) { if ( ! isset ( $ GLOBALS [ 'wp_object_cache' ] ) && function_exists ( 'wp_cache_init' ) ) { wp_cache_init ( ) ; } return isset ( $ GLOBALS [ 'wp_object_cache' ] ) ? $ GLOBALS [ 'wp_object_cache' ] : null ; } ) ; }

Register a number of WordPress globals in the container.

@param  PimpleContainer $container The container instance.

@return void

Register a number of WordPress globals in the container .


protected function applyConfigs(Container $app, $config)
    {
        foreach ($config as $varName => $options) {
            if (isset($options[self::CONFIG_KEY_DEFAULT])) {
                if (isset($app[$varName]) === false) {
                    $app[$varName] = $options[self::CONFIG_KEY_DEFAULT];
                }
            }

            if (isset($options[self::CONFIG_KEY_REQUIRED])) {
                if ($options[self::CONFIG_KEY_REQUIRED]) {
                    \Dotenv::required($app['env.options']['prefix'].'_'.strtoupper($varName));
                }
            }

            if (isset($options[self::CONFIG_KEY_ALLOWED])) {
                \Dotenv::required(
                    $app['env.options']['prefix'].'_'.strtoupper($varName),
                    $options[self::CONFIG_KEY_ALLOWED]
                );
            }

            if (isset($options[self::CONFIG_KEY_CAST])) {
                switch ($options[self::CONFIG_KEY_CAST]) {
                    case self::CAST_TYPE_INT:
                        $app[$varName] = (int)$app[$varName];
                        break;
                    case self::CAST_TYPE_FLOAT:
                        $app[$varName] = (float)$app[$varName];
                        break;
                    case self::CAST_TYPE_BOOLEAN:
                        $app[$varName] = filter_var(($app[$varName]), FILTER_VALIDATE_BOOLEAN);
                        break;
                    default: //string
                        break;
                }
            }

        }

    }

protected function applyConfigs ( Container $ app , $ config ) { foreach ( $ config as $ varName => $ options ) { if ( isset ( $ options [ self :: CONFIG_KEY_DEFAULT ] ) ) { if ( isset ( $ app [ $ varName ] ) === false ) { $ app [ $ varName ] = $ options [ self :: CONFIG_KEY_DEFAULT ] ; } } if ( isset ( $ options [ self :: CONFIG_KEY_REQUIRED ] ) ) { if ( $ options [ self :: CONFIG_KEY_REQUIRED ] ) { \ Dotenv :: required ( $ app [ 'env.options' ] [ 'prefix' ] . '_' . strtoupper ( $ varName ) ) ; } } if ( isset ( $ options [ self :: CONFIG_KEY_ALLOWED ] ) ) { \ Dotenv :: required ( $ app [ 'env.options' ] [ 'prefix' ] . '_' . strtoupper ( $ varName ) , $ options [ self :: CONFIG_KEY_ALLOWED ] ) ; } if ( isset ( $ options [ self :: CONFIG_KEY_CAST ] ) ) { switch ( $ options [ self :: CONFIG_KEY_CAST ] ) { case self :: CAST_TYPE_INT : $ app [ $ varName ] = ( int ) $ app [ $ varName ] ; break ; case self :: CAST_TYPE_FLOAT : $ app [ $ varName ] = ( float ) $ app [ $ varName ] ; break ; case self :: CAST_TYPE_BOOLEAN : $ app [ $ varName ] = filter_var ( ( $ app [ $ varName ] ) , FILTER_VALIDATE_BOOLEAN ) ; break ; default : //string break ; } } } }

applies config options to expected vars

@param Container $app
@param $config


protected function addEnvVarsToApp(Container $app)
    {
        $hasPrefix = function ($elem) use ($app) {
            return strpos($elem, $app['env.options']['prefix'].'_') !== false;
        };
        $arrayFilterKeys = function ($input, $callback) {
            if (!is_array($input)) {
                trigger_error(
                    'array_filter_key() expects parameter 1 to be array, '.gettype($input).' given',
                    E_USER_WARNING
                );

                return null;
            }

            if (empty($input)) {
                return $input;
            }

            $filteredKeys = array_filter(array_keys($input), $callback);
            if (empty($filteredKeys)) {
                return array();
            }

            $input = array_intersect_key(array_flip($filteredKeys), $input);

            return $input;
        };

        $envVars = $arrayFilterKeys($_ENV, $hasPrefix);
        $envVars = array_merge($arrayFilterKeys($_SERVER, $hasPrefix), $envVars);
        foreach ($envVars as $envVar => $empty) {
            $var = \Dotenv::findEnvironmentVariable($envVar);
            if ($var) {
                $key = strtolower(str_replace($app['env.options']['prefix'].'_', '', $envVar));
                $app[$key] = $var;
            }
        }
    }

collect vars and sets them to the DIC

@param Container $app


public function pop($queue = null) {
        if ($queue === null) { $queue = $this->queue; }
        $query = DB::table($this->table)->where('queue_name', $queue)
            ->where('status', 'pending')
            ->where('fireon', '<', time())
            ->orderBy('fireon', 'asc');
        if ($query->count() == 0) {return null;}
        $record = $query->first();
        return new Jobs\MysqlJob($this->container, $record->ID, $record);
    }

public function pop ( $ queue = null ) { if ( $ queue === null ) { $ queue = $ this -> queue ; } $ query = DB :: table ( $ this -> table ) -> where ( 'queue_name' , $ queue ) -> where ( 'status' , 'pending' ) -> where ( 'fireon' , '<' , time ( ) ) -> orderBy ( 'fireon' , 'asc' ) ; if ( $ query -> count ( ) == 0 ) { return null ; } $ record = $ query -> first ( ) ; return new Jobs \ MysqlJob ( $ this -> container , $ record -> ID , $ record ) ; }

Pop the next job off of the queue.

@param  string  $queue
@return \Illuminate\Queue\Jobs\Job|null


private function insertJobRecord($payload, $time, $queue)
    {
        if (!$time instanceof DateTime) {
            throw new ErrorException('An explicit DateTime value $time is required. ');
        }
        $jobId = DB::table($this->table)->insertGetId([
            'queue_name' => $queue,
            'payload'  => $payload,
            'status'   => 'pending',
            'attempts' => 1,
            'fireon'   => $time->getTimestamp(),
        ]);
        return $jobId;
    }

Insert a job record into database.

@param  string   $payload Payload string.
@param  DateTime $time    Exact firing time of the job.
@param  string   $queue   Queue name of the job.
@return int               ID of new record inserted.


private function requestXcdrSetAttribute($result, $schema)
    {
        $msgHeader = $result['msgHeader'];

        $soapObjectXML = '<format>DETAIL</format>
                        <msgHeader>
				<transactionID>' . $msgHeader->transactionID . '</transactionID>
                                <registrationID>' . $msgHeader->registrationID . '</registrationID>
			</msgHeader>'
        ;

        $soapXML = new \SoapVar($soapObjectXML, XSD_ANYXML, null, null, null, $schema);

        try {
            $result = $this->soapClient->RequestXcdrSetAttribute($soapXML);
        } catch (SoapTimeoutException $e) {
            return array(
                'status' => 'error',
                'type' => 'soap_fault',
                'message' => 'XCDR Soap Client Timeout. ' . $e->getMessage(),
                'class' => get_class($this)
            );
        } catch (\Exception $e) {
            return array(
                'status' => 'error',
                'type' => 'exception',
                'message' => 'XCDR Soap Client Exception. ' . $e->getMessage(),
                'class' => get_class($this)
            );
        }

        if (is_soap_fault($result)) {
            return array(
                'status' => 'error',
                'type' => 'soap_fault',
                'code' => $result->faultcode,
                'message' => $result->faultstring,
                'class' => get_class($this)
            );
        }

        return array(
            'status' => 'success',
            'result' => $result
        );
    }

'</transactionID>
                                <registrationID>'

Cisco IOS XCDRProvider Set Attribute Request


public function convert($string, $delimiter = '_')
    {
        $func = create_function('$c', 'return strtoupper($c[1]);');

        return preg_replace_callback('/[\s]+(.)/', $func, str_replace($delimiter, ' ', $string));
    }

public
function
convert
(
$
string
,
$
delimiter
=
'_'
)
{
$
func
=
create_function
(
'$c'
,
'return strtoupper($c[1]);'
)
;
return
preg_replace_callback
(
'/[\s]+(.)/'
,
$
func
,
str_replace
(
$
delimiter
,
' '
,
$
string
)
)
;
}

convert string to camelcase

@param string $string
@param string $delimiter
@return string


final public function create($record = null, string $alias = null): Record
    {
        $record = Record::parse($record);

        foreach ($this->getParents() as $relationship => $parent) {
            /** @var DataMapper $parent */
            $create = $parent->create($record);
            $record->set($relationship, $create->get($parent->getPrimaryKey()));
            $record->import($create->all());
        }

        $action = coalesce($alias, Action::CREATE);

        if (!$this->before($action, $record)) {
            throw new SimplesHookError(get_class($this), $action, 'before');
        }
        if (!$record->get($this->hashKey)) {
            $record->set($this->hashKey, $this->hashKey());
        }

        $create = $this->configureRecord(Action::CREATE, $record);
        $fields = $create->keys();
        $values = $create->values();

        foreach ($this->createKeys as $type => $timestampsKey) {
            $fields[] = $timestampsKey;
            $values[] = $this->getTimestampValue($type);
        }

        $created = $this
            ->source($this->getCollection())
            ->fields($fields)
            ->register($values);

        $this->reset();

        if ($this->getPrimaryKey()) {
            $record->set($this->getPrimaryKey(), $created);
        }
        $record->merge($create->all());

        if (!$this->after($action, $record)) {
            throw new SimplesHookError(get_class($this), $action, 'after');
        }
        return $record;
    }

final
public
function
create
(
$
record
=
,
string
$
alias
=
)
:
Record
{
$
record
=
Record
::
parse
(
$
record
)
;
foreach
(
$
this
->
getParents
(
)
as
$
relationship
=>
$
parent
)
{
/** @var DataMapper $parent */
$
create
=
$
parent
->
create
(
$
record
)
;
$
record
->
set
(
$
relationship
,
$
create
->
get
(
$
parent
->
getPrimaryKey
(
)
)
)
;
$
record
->
import
(
$
create
->
all
(
)
)
;
}
$
action
=
coalesce
(
$
alias
,
Action
::
CREATE
)
;
if
(
!
$
this
->
before
(
$
action
,
$
record
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'before'
)
;
}
if
(
!
$
record
->
get
(
$
this
->
hashKey
)
)
{
$
record
->
set
(
$
this
->
hashKey
,
$
this
->
hashKey
(
)
)
;
}
$
create
=
$
this
->
configureRecord
(
Action
::
CREATE
,
$
record
)
;
$
fields
=
$
create
->
keys
(
)
;
$
values
=
$
create
->
values
(
)
;
foreach
(
$
this
->
createKeys
as
$
type
=>
$
timestampsKey
)
{
$
fields
[
]
=
$
timestampsKey
;
$
values
[
]
=
$
this
->
getTimestampValue
(
$
type
)
;
}
$
created
=
$
this
->
source
(
$
this
->
getCollection
(
)
)
->
fields
(
$
fields
)
->
register
(
$
values
)
;
$
this
->
reset
(
)
;
if
(
$
this
->
getPrimaryKey
(
)
)
{
$
record
->
set
(
$
this
->
getPrimaryKey
(
)
,
$
created
)
;
}
$
record
->
merge
(
$
create
->
all
(
)
)
;
if
(
!
$
this
->
after
(
$
action
,
$
record
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'after'
)
;
}
return
$
record
;
}

Method with the responsibility of create a record of model
@param array|Record $record (null)
@param string $alias ('create')
@return Record
@throws SimplesHookError
@throws SimplesRecordReadonlyError
@throws SimplesRunTimeError


final public function read($record = null, string $alias = null, $trash = false, $clean = false): Collection
    {
        $record = Record::parse(coalesce($record, []));

        $action = coalesce($alias, Action::READ);

        if (!$this->before($action, $record)) {
            throw new SimplesHookError(get_class($this), $action, 'before');
        }

        $filters = [];
        $values = [];
        if (!$record->isEmpty()) {
            $filters = $this->parseFilterFields($record->all());
            $values = $this->parseFilterValues($filters);
        }

        if ($this->destroyKeys) {
            $filters[] = $this->getDestroyFilter($this->destroyKeys['at'], $trash);
        }

        $fields = $this->getActionFields(Action::READ, false);
        if ($clean) {
            $fields = $this->clear($fields);
        }

        $order = is_array($this->order) ? $this->order : [$this->order];

        $where = off($this->getClauses(), 'where', []);
        if ($where) {
            $filters = array_merge($filters, $where);
            $values = array_merge($values, off($this->getClauses(), 'values', []));
        }

        $array = $this
            ->source($this->getCollection())
            ->relation($this->parseReadRelations($this->fields))
            ->fields($fields)
            ->order($order)
            ->where($filters)// TODO: needs review
            ->recover($values);

        $this->reset();

        $after = $this->after($action, $record, $array);
        if (!is_array($after)) {
            throw new SimplesHookError(get_class($this), $action, 'after');
        }
        $array = $after;

        return Collection::make($array);
    }

final
public
function
read
(
$
record
=
,
string
$
alias
=
,
$
trash
=
false
,
$
clean
=
false
)
:
Collection
{
$
record
=
Record
::
parse
(
coalesce
(
$
record
,
[
]
)
)
;
$
action
=
coalesce
(
$
alias
,
Action
::
READ
)
;
if
(
!
$
this
->
before
(
$
action
,
$
record
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'before'
)
;
}
$
filters
=
[
]
;
$
values
=
[
]
;
if
(
!
$
record
->
isEmpty
(
)
)
{
$
filters
=
$
this
->
parseFilterFields
(
$
record
->
all
(
)
)
;
$
values
=
$
this
->
parseFilterValues
(
$
filters
)
;
}
if
(
$
this
->
destroyKeys
)
{
$
filters
[
]
=
$
this
->
getDestroyFilter
(
$
this
->
destroyKeys
[
'at'
]
,
$
trash
)
;
}
$
fields
=
$
this
->
getActionFields
(
Action
::
READ
,
false
)
;
if
(
$
clean
)
{
$
fields
=
$
this
->
clear
(
$
fields
)
;
}
$
order
=
is_array
(
$
this
->
order
)
$
this
->
order
:
[
$
this
->
order
]
;
$
where
=
off
(
$
this
->
getClauses
(
)
,
'where'
,
[
]
)
;
if
(
$
where
)
{
$
filters
=
array_merge
(
$
filters
,
$
where
)
;
$
values
=
array_merge
(
$
values
,
off
(
$
this
->
getClauses
(
)
,
'values'
,
[
]
)
)
;
}
$
array
=
$
this
->
source
(
$
this
->
getCollection
(
)
)
->
relation
(
$
this
->
parseReadRelations
(
$
this
->
fields
)
)
->
fields
(
$
fields
)
->
order
(
$
order
)
->
where
(
$
filters
)
// TODO: needs review
->
recover
(
$
values
)
;
$
this
->
reset
(
)
;
$
after
=
$
this
->
after
(
$
action
,
$
record
,
$
array
)
;
if
(
!
is_array
(
$
after
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'after'
)
;
}
$
array
=
$
after
;
return
Collection
::
make
(
$
array
)
;
}

Read records with the filters informed
@param array|Record $record (null)
@param string $alias ('read')
@param bool $trash (false)
@param bool $clean (false)
@return Collection
@throws SimplesHookError
@throws SimplesRunTimeError
@throws Exception


final public function update($record = null, string $alias = null, bool $trash = false): Record
    {
        $record = Record::parse($record);

        foreach ($this->getParents() as $parent) {
            /** @var DataMapper $parent */
            $record->import($parent->update($record)->all());
        }

        $action = coalesce($alias, Action::UPDATE);

        $previous = $this->previous($record, $this->hashKey, $trash);

        if ($previous->isEmpty()) {
            throw new SimplesResourceError([$this->getHashKey() => $record->get($this->getHashKey())]);
        }

        if (!$this->before($action, $record, $previous)) {
            throw new SimplesHookError(get_class($this), $action, 'before');
        }

        $record->setPrivate($this->getHashKey());

        $update = $this->configureRecord(Action::UPDATE, $record, $previous, !$trash);
        $fields = $update->keys();
        $values = $update->values();

        foreach ($this->updateKeys as $type => $timestampsKey) {
            $fields[] = $timestampsKey;
            $values[] = $this->getTimestampValue($type);
        }

        $filter = new Filter($this->get($this->getPrimaryKey()), $record->get($this->getPrimaryKey()));

        $updated = $this
            ->source($this->getCollection())
            ->fields($fields)
            ->where([$filter])// TODO: needs review
            ->change($values, [$filter->getValue()]);

        $this->reset();

        if (!$updated) {
            throw new SimplesActionError(get_class($this), $action);
        }
        $record->setPublic($this->getHashKey());
        $record = $previous->merge($record->all());

        if (!$this->after($action, $record)) {
            throw new SimplesHookError(get_class($this), $action, 'after');
        }
        return $record;
    }

final
public
function
update
(
$
record
=
,
string
$
alias
=
,
bool
$
trash
=
false
)
:
Record
{
$
record
=
Record
::
parse
(
$
record
)
;
foreach
(
$
this
->
getParents
(
)
as
$
parent
)
{
/** @var DataMapper $parent */
$
record
->
import
(
$
parent
->
update
(
$
record
)
->
all
(
)
)
;
}
$
action
=
coalesce
(
$
alias
,
Action
::
UPDATE
)
;
$
previous
=
$
this
->
previous
(
$
record
,
$
this
->
hashKey
,
$
trash
)
;
if
(
$
previous
->
isEmpty
(
)
)
{
throw
new
SimplesResourceError
(
[
$
this
->
getHashKey
(
)
=>
$
record
->
get
(
$
this
->
getHashKey
(
)
)
]
)
;
}
if
(
!
$
this
->
before
(
$
action
,
$
record
,
$
previous
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'before'
)
;
}
$
record
->
setPrivate
(
$
this
->
getHashKey
(
)
)
;
$
update
=
$
this
->
configureRecord
(
Action
::
UPDATE
,
$
record
,
$
previous
,
!
$
trash
)
;
$
fields
=
$
update
->
keys
(
)
;
$
values
=
$
update
->
values
(
)
;
foreach
(
$
this
->
updateKeys
as
$
type
=>
$
timestampsKey
)
{
$
fields
[
]
=
$
timestampsKey
;
$
values
[
]
=
$
this
->
getTimestampValue
(
$
type
)
;
}
$
filter
=
new
Filter
(
$
this
->
get
(
$
this
->
getPrimaryKey
(
)
)
,
$
record
->
get
(
$
this
->
getPrimaryKey
(
)
)
)
;
$
updated
=
$
this
->
source
(
$
this
->
getCollection
(
)
)
->
fields
(
$
fields
)
->
where
(
[
$
filter
]
)
// TODO: needs review
->
change
(
$
values
,
[
$
filter
->
getValue
(
)
]
)
;
$
this
->
reset
(
)
;
if
(
!
$
updated
)
{
throw
new
SimplesActionError
(
get_class
(
$
this
)
,
$
action
)
;
}
$
record
->
setPublic
(
$
this
->
getHashKey
(
)
)
;
$
record
=
$
previous
->
merge
(
$
record
->
all
(
)
)
;
if
(
!
$
this
->
after
(
$
action
,
$
record
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'after'
)
;
}
return
$
record
;
}

Update the record given
@param array|Record $record (null)
@param string $alias ('update')
@param bool $trash (false)
@return Record
@throws SimplesActionError
@throws SimplesHookError
@throws SimplesResourceError
@throws SimplesRunTimeError


final public function destroy($record = null, string $alias = null): Record
    {
        $record = Record::parse($record);

        foreach ($this->getParents() as $parent) {
            /** @var DataMapper $parent */
            $record->import($parent->destroy($record)->all());
        }

        $action = coalesce($alias, Action::DESTROY);

        $previous = $this->previous($record, $this->hashKey);

        if ($previous->isEmpty()) {
            throw new SimplesResourceError([$this->getHashKey() => $record->get($this->getHashKey())]);
        }

        if (!$this->before($action, $record, $previous)) {
            throw new SimplesHookError(get_class($this), $action, 'before');
        }

        $filter = new Filter($this->get($this->getPrimaryKey()), $record->get($this->getPrimaryKey()));
        $filters = [$filter];

        if ($this->destroyKeys) {
            $fields = [];
            $values = [];
            foreach ($this->destroyKeys as $type => $deletedKey) {
                $fields[] = $deletedKey;
                $values[] = $this->getTimestampValue($type);
            }

            $removed = $this
                ->source($this->getCollection())
                ->fields($fields)
                ->where($filters)// TODO: needs review
                ->change($values, [$filter->getValue()]);
        }

        if (!isset($removed)) {
            $removed = $this
                ->source($this->getCollection())
                ->where($filters)// TODO: needs review
                ->remove([$record->get($this->getPrimaryKey())]);
        }

        $this->reset();

        if (!$removed) {
            throw new SimplesActionError(get_class($this), $action);
        }
        $record = $previous->merge($record->all());

        if (!$this->after($action, $record)) {
            throw new SimplesHookError(get_class($this), $action, 'after');
        }
        return $record;
    }

final
public
function
destroy
(
$
record
=
,
string
$
alias
=
)
:
Record
{
$
record
=
Record
::
parse
(
$
record
)
;
foreach
(
$
this
->
getParents
(
)
as
$
parent
)
{
/** @var DataMapper $parent */
$
record
->
import
(
$
parent
->
destroy
(
$
record
)
->
all
(
)
)
;
}
$
action
=
coalesce
(
$
alias
,
Action
::
DESTROY
)
;
$
previous
=
$
this
->
previous
(
$
record
,
$
this
->
hashKey
)
;
if
(
$
previous
->
isEmpty
(
)
)
{
throw
new
SimplesResourceError
(
[
$
this
->
getHashKey
(
)
=>
$
record
->
get
(
$
this
->
getHashKey
(
)
)
]
)
;
}
if
(
!
$
this
->
before
(
$
action
,
$
record
,
$
previous
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'before'
)
;
}
$
filter
=
new
Filter
(
$
this
->
get
(
$
this
->
getPrimaryKey
(
)
)
,
$
record
->
get
(
$
this
->
getPrimaryKey
(
)
)
)
;
$
filters
=
[
$
filter
]
;
if
(
$
this
->
destroyKeys
)
{
$
fields
=
[
]
;
$
values
=
[
]
;
foreach
(
$
this
->
destroyKeys
as
$
type
=>
$
deletedKey
)
{
$
fields
[
]
=
$
deletedKey
;
$
values
[
]
=
$
this
->
getTimestampValue
(
$
type
)
;
}
$
removed
=
$
this
->
source
(
$
this
->
getCollection
(
)
)
->
fields
(
$
fields
)
->
where
(
$
filters
)
// TODO: needs review
->
change
(
$
values
,
[
$
filter
->
getValue
(
)
]
)
;
}
if
(
!
isset
(
$
removed
)
)
{
$
removed
=
$
this
->
source
(
$
this
->
getCollection
(
)
)
->
where
(
$
filters
)
// TODO: needs review
->
remove
(
[
$
record
->
get
(
$
this
->
getPrimaryKey
(
)
)
]
)
;
}
$
this
->
reset
(
)
;
if
(
!
$
removed
)
{
throw
new
SimplesActionError
(
get_class
(
$
this
)
,
$
action
)
;
}
$
record
=
$
previous
->
merge
(
$
record
->
all
(
)
)
;
if
(
!
$
this
->
after
(
$
action
,
$
record
)
)
{
throw
new
SimplesHookError
(
get_class
(
$
this
)
,
$
action
,
'after'
)
;
}
return
$
record
;
}

Remove the given record of database
@param array|Record $record (null)
@param string $alias ('destroy')
@return Record
@throws SimplesActionError
@throws SimplesHookError
@throws SimplesResourceError
@throws SimplesRunTimeError


final public function recycle($record = null): Record
    {
        if (!$this->destroyKeys) {
            throw new SimplesValidationError(
                ['destroyKeys' => 'requires'],
                "Recycle needs the `destroyKeys`"
            );
        }

        $record = Record::parse($record);
        foreach ($this->destroyKeys as $deletedKey) {
            $record->set($deletedKey, __NULL__);
        }

        return $this->update($record, 'recycle', true);
    }

final
public
function
recycle
(
$
record
=
)
:
Record
{
if
(
!
$
this
->
destroyKeys
)
{
throw
new
SimplesValidationError
(
[
'destroyKeys'
=>
'requires'
]
,
"Recycle needs the `destroyKeys`"
)
;
}
$
record
=
Record
::
parse
(
$
record
)
;
foreach
(
$
this
->
destroyKeys
as
$
deletedKey
)
{
$
record
->
set
(
$
deletedKey
,
__NULL__
)
;
}
return
$
this
->
update
(
$
record
,
'recycle'
,
true
)
;
}

Recycle a destroyed record
@param array|Record $record (null)
@return Record
@throws SimplesActionError
@throws SimplesHookError
@throws SimplesResourceError
@throws SimplesRunTimeError
@throws SimplesValidationError


final public function count(Record $record): int
    {
        $alias = 'count';
        $collection = $this->getCollection();
        $name = $this->getPrimaryKey();
        $type = Field::AGGREGATOR_COUNT;
        $options = ['alias' => $alias];
        $fields = [Field::make($collection, $name, $type, $options)];

        $this->reset();

        $count = $this
            ->fields($fields)
            ->limit(null)
            ->read($record, null, false)
            ->current();

        $this->reset();

        if (!$count->has($alias)) {
            throw new SimplesActionError(get_class($this), $alias);
        }

        return (int)$count->get($alias);
    }

final public function count ( Record $ record ) : int { $ alias = 'count' ; $ collection = $ this -> getCollection ( ) ; $ name = $ this -> getPrimaryKey ( ) ; $ type = Field :: AGGREGATOR_COUNT ; $ options = [ 'alias' => $ alias ] ; $ fields = [ Field :: make ( $ collection , $ name , $ type , $ options ) ] ; $ this -> reset ( ) ; $ count = $ this -> fields ( $ fields ) -> limit ( null ) -> read ( $ record , null , false ) -> current ( ) ; $ this -> reset ( ) ; if ( ! $ count -> has ( $ alias ) ) { throw new SimplesActionError ( get_class ( $ this ) , $ alias ) ; } return ( int ) $ count -> get ( $ alias ) ; }

Get total of records based on filters
@param Record $record
@return int
@throws Exception
@throws SimplesActionError
@throws SimplesHookError
@throws SimplesRunTimeError


public function proxy( Container $container, $key ) {
		if ( isset( $this->proxies[ $key ] ) ) {
			return $this->proxies[ $key ];
		}

		$this->proxies[ $key ] = new Proxy( $container, $key );

		return $this->proxies[ $key ];
	}

public function proxy ( Container $ container , $ key ) { if ( isset ( $ this -> proxies [ $ key ] ) ) { return $ this -> proxies [ $ key ] ; } $ this -> proxies [ $ key ] = new Proxy ( $ container , $ key ) ; return $ this -> proxies [ $ key ] ; }

Get a proxy object for a given container entry.

@param  Container $container Container instance.
@param  string    $key       Container key.

@return Proxy

Get a proxy object for a given container entry .


public function close():Log{

		if(!empty($this->logOutputInterfaces)){
			foreach($this->logOutputInterfaces as $instanceName => $instance){
				unset($this->logOutputInterfaces[$instanceName]);
			}
		}

		return $this;
	}

public function close ( ) : Log { if ( ! empty ( $ this -> logOutputInterfaces ) ) { foreach ( $ this -> logOutputInterfaces as $ instanceName => $ instance ) { unset ( $ this -> logOutputInterfaces [ $ instanceName ] ) ; } } return $ this ; }

closes all remaining logger instances

@return \chillerlan\Logger\Log


protected function loadWidgets()
    {
        $widgets_folder = apply_filters('potter_widgets_folder', $this->widgetsFolder);

        $pattern = $this->themeDIR . $widgets_folder . "/*.php";

        foreach (glob($pattern) as $file): // Load File
            require_once($file);

            $widget = basename($file, '.php');

            // Register
            if (class_exists($widget)):
                $this->widgets->push($widget);
            endif;
        endforeach;
    }

protected
function
loadWidgets
(
)
{
$
widgets_folder
=
apply_filters
(
'potter_widgets_folder'
,
$
this
->
widgetsFolder
)
;
$
pattern
=
$
this
->
themeDIR
.
$
widgets_folder
.
"/*.php"
;
foreach
(
glob
(
$
pattern
)
as
$
file
)
:
// Load File
require_once
(
$
file
)
;
$
widget
=
basename
(
$
file
,
'.php'
)
;
// Register
if
(
class_exists
(
$
widget
)
)
:
$
this
->
widgets
->
push
(
$
widget
)
;
endif
;
endforeach
;
}


private function loadThemeOptions()
    {
        $file = cleanURI($this->themeDIR . 'app/ThemeOptions.php');
        $file = apply_filters('potter_autoload_themeoptions', $file);

        $class = $this->loadFile($file);

        if (!$class):
            $class = new OptionsEmpty();
            add_action('admin_menu', array($this, 'remove_ot_theme_options_page'), 999);
        endif;

        $this->optionsInstance = $class;
    }

private function loadThemeOptions ( ) { $ file = cleanURI ( $ this -> themeDIR . 'app/ThemeOptions.php' ) ; $ file = apply_filters ( 'potter_autoload_themeoptions' , $ file ) ; $ class = $ this -> loadFile ( $ file ) ; if ( ! $ class ) : $ class = new OptionsEmpty ( ) ; add_action ( 'admin_menu' , array ( $ this , 'remove_ot_theme_options_page' ) , 999 ) ; endif ; $ this -> optionsInstance = $ class ; }


function onXmlRpcEliteBeginTurn($content)
	{
		$this->postTwitterMessage(sprintf("Turn #%d: %s attack", $content->TurnNumber, $this->formatForTwitter($content->AttackingPlayer->Name)));
	}

function
onXmlRpcEliteBeginTurn
(
$
content
)
{
$
this
->
postTwitterMessage
(
sprintf
(
"Turn #%d: %s attack"
,
$
content
->
TurnNumber
,
$
this
->
formatForTwitter
(
$
content
->
AttackingPlayer
->
Name
)
)
)
;
}


public function addChild(ElementInterface $child)
    {
        if ($child instanceof Menu) {
            $this->element->setMenu($child);
        }

        $this->children[] = $child;
    }

public function addChild ( ElementInterface $ child ) { if ( $ child instanceof Menu ) { $ this -> element -> setMenu ( $ child ) ; } $ this -> children [ ] = $ child ; }

Add a child element

@param ElementInterface $child


public function store(CreatePermissionRequest $request)
    {
        $input = $request->all();

        $permission = $this->permissionRepository->create([
            'name' => $input['name'],
        ]);

        foreach ($input['roles'] as $role) {
            $permission->roles()->attach($role);
        }

        Flash::success(trans('l5starter::messages.create.success'));

        return redirect(route('admin.permissions.index'));
    }

public function store ( CreatePermissionRequest $ request ) { $ input = $ request -> all ( ) ; $ permission = $ this -> permissionRepository -> create ( [ 'name' => $ input [ 'name' ] , ] ) ; foreach ( $ input [ 'roles' ] as $ role ) { $ permission -> roles ( ) -> attach ( $ role ) ; } Flash :: success ( trans ( 'l5starter::messages.create.success' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; }

Store a newly created Permission in storage.

@param CreatePermissionRequest $request

@return Response

Store a newly created Permission in storage .


public function edit($id)
    {
        $permission = $this->permissionRepository->findWithoutFail($id);

        if (empty($permission)) {
            Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.permissions.index'));
        }

        return view('permissions::edit')->with([
            'roles' => $this->roleRepository->all(),
            'permission' => $permission,
        ]);
    }

public function edit ( $ id ) { $ permission = $ this -> permissionRepository -> findWithoutFail ( $ id ) ; if ( empty ( $ permission ) ) { Flash :: error ( trans ( 'l5starter::messages.404_not_found' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; } return view ( 'permissions::edit' ) -> with ( [ 'roles' => $ this -> roleRepository -> all ( ) , 'permission' => $ permission , ] ) ; }

Show the form for editing the specified Permission.

@param  int $id

@return Response

Show the form for editing the specified Permission .


public function update($id, UpdatePermissionRequest $request)
    {
        $permission = $this->permissionRepository->findWithoutFail($id);

        if (empty($permission)) {
            Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.permissions.index'));
        }

        $input = $request->all();

        $permission = $this->permissionRepository->update([
            'name' => $input['name'],
        ], $id);

        $roles = [];

        if (!empty($input['roles'])) {
            foreach ($input['roles'] as $role) {
                $roles[$role] = $role;
            }
        }

        $permission->roles()->sync($roles);

        Flash::success(trans('l5starter::messages.update.success'));

        return redirect(route('admin.permissions.index'));
    }

public function update ( $ id , UpdatePermissionRequest $ request ) { $ permission = $ this -> permissionRepository -> findWithoutFail ( $ id ) ; if ( empty ( $ permission ) ) { Flash :: error ( trans ( 'l5starter::messages.404_not_found' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; } $ input = $ request -> all ( ) ; $ permission = $ this -> permissionRepository -> update ( [ 'name' => $ input [ 'name' ] , ] , $ id ) ; $ roles = [ ] ; if ( ! empty ( $ input [ 'roles' ] ) ) { foreach ( $ input [ 'roles' ] as $ role ) { $ roles [ $ role ] = $ role ; } } $ permission -> roles ( ) -> sync ( $ roles ) ; Flash :: success ( trans ( 'l5starter::messages.update.success' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; }

Update the specified Permission in storage.

@param  int $id
@param UpdatePermissionRequest $request

@return Response

Update the specified Permission in storage .


public function destroy($id)
    {
        $permission = $this->permissionRepository->findWithoutFail($id);

        if (empty($permission)) {
            Flash::error(trans('l5starter::messages.404_not_found'));

            return redirect(route('admin.permissions.index'));
        }

        $this->permissionRepository->delete($id);

        Flash::success(trans('l5starter::messages.delete.success'));

        return redirect(route('admin.permissions.index'));
    }

public function destroy ( $ id ) { $ permission = $ this -> permissionRepository -> findWithoutFail ( $ id ) ; if ( empty ( $ permission ) ) { Flash :: error ( trans ( 'l5starter::messages.404_not_found' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; } $ this -> permissionRepository -> delete ( $ id ) ; Flash :: success ( trans ( 'l5starter::messages.delete.success' ) ) ; return redirect ( route ( 'admin.permissions.index' ) ) ; }

Remove the specified Permission from storage.

@param  int $id

@return Response

Remove the specified Permission from storage .


public function setAdapter(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\AbstractAdapter $adapter)
  {
    $this->adapter = $adapter;
  }

public function setAdapter ( \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Adapter \ AbstractAdapter $ adapter ) { $ this -> adapter = $ adapter ; }

Sets the \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\AbstractAdapter object using this transport.

@param  \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\AbstractAdapter $adapter
@return void

Sets the \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Adapter \ AbstractAdapter object using this transport .


public function getAdapterType()
  {
    if($this->adapter instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\AbstractAdapter)
    {
      $string = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory(get_class($this->adapter));

      return $string->substr($string->findLast("\\"))->replace(array("\\", " "), "")->toString();
    }

    return "Unknown";
  }

public
function
getAdapterType
(
)
{
if
(
$
this
->
adapter
instanceof
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
AbstractAdapter
)
{
$
string
=
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
String
::
factory
(
get_class
(
$
this
->
adapter
)
)
;
return
$
string
->
substr
(
$
string
->
findLast
(
"\\"
)
)
->
replace
(
array
(
"\\"
,
" "
)
,
""
)
->
toString
(
)
;
}
return
"Unknown"
;
}

Returns the adapter type.

@return string


protected function waitForReadyRead($time = 0)
  {
    if(!$this->isConnected() || $this->config["blocking"]) return;

    do {
      $read = array($this->stream);
      $null = null;

      if($time)
      {
        \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "WaitTimeout", $time, $this->getAdapter());
      }

      $time = $time+$this->config["timeout"];
    } while(@stream_select($read, $null, $null, $this->config["timeout"]) == 0);
  }

protected function waitForReadyRead ( $ time = 0 ) { if ( ! $ this -> isConnected ( ) || $ this -> config [ "blocking" ] ) return ; do { $ read = array ( $ this -> stream ) ; $ null = null ; if ( $ time ) { \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( strtolower ( $ this -> getAdapterType ( ) ) . "WaitTimeout" , $ time , $ this -> getAdapter ( ) ) ; } $ time = $ time + $ this -> config [ "timeout" ] ; } while ( @ stream_select ( $ read , $ null , $ null , $ this -> config [ "timeout" ] ) == 0 ) ; }

Blocks a stream until data is available for reading if the stream is connected
in non-blocking mode.

@param  integer $time
@return void

Blocks a stream until data is available for reading if the stream is connected in non - blocking mode .


public function getChannels($params = array())
    {
        $params = 0 < count($params) ? '?'.http_build_query($params) : '';
        $response = $this->getClient()->get(self::ENDPOINT.'channels'.$params);
        $data = $this->jsonResponse($response);

        return $this->setFactory((new ChannelFactory()))->getFactory()->createList($data);
    }

public function getChannels ( $ params = array ( ) ) { $ params = 0 < count ( $ params ) ? '?' . http_build_query ( $ params ) : '' ; $ response = $ this -> getClient ( ) -> get ( self :: ENDPOINT . 'channels' . $ params ) ; $ data = $ this -> jsonResponse ( $ response ) ; return $ this -> setFactory ( ( new ChannelFactory ( ) ) ) -> getFactory ( ) -> createList ( $ data ) ; }

Search channels.

@param array $params

@return ChannelList


public function getGames($params = array())
    {
        $params = 0 < count($params) ? '?'.http_build_query($params) : '';
        $response = $this->getClient()->get(self::ENDPOINT.'games'.$params);
        $data = $this->jsonResponse($response);

        return $this->setFactory((new GameFactory()))->getFactory()->createList($data);
    }

public function getGames ( $ params = array ( ) ) { $ params = 0 < count ( $ params ) ? '?' . http_build_query ( $ params ) : '' ; $ response = $ this -> getClient ( ) -> get ( self :: ENDPOINT . 'games' . $ params ) ; $ data = $ this -> jsonResponse ( $ response ) ; return $ this -> setFactory ( ( new GameFactory ( ) ) ) -> getFactory ( ) -> createList ( $ data ) ; }

Search games.

@param array $params

@return GameList


public static function asArray($data, $default = null)
    {
        $json = is_string($data) ? $data : json_encode($data);

        $array = json_decode($json, true) ?? null;

        $array = $array ? filter_var_array($array) : false;

        return $array !== false ? $array : $default;
    }

public static function asArray ( $ data , $ default = null ) { $ json = is_string ( $ data ) ? $ data : json_encode ( $ data ) ; $ array = json_decode ( $ json , true ) ?? null ; $ array = $ array ? filter_var_array ( $ array ) : false ; return $ array !== false ? $ array : $ default ; }

Parameter return as array.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public static function asObject($data, $default = null)
    {
        $json = is_string($data) ? $data : json_encode($data);

        $object = json_decode($json);

        return is_object($object) ? $object : $default;
    }

public static function asObject ( $ data , $ default = null ) { $ json = is_string ( $ data ) ? $ data : json_encode ( $ data ) ; $ object = json_decode ( $ json ) ; return is_object ( $ object ) ? $ object : $ default ; }

Parameter return as object.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public static function asJson($data, $default = null)
    {
        $json = is_string($data) ? $data : json_encode($data);

        return $json !== false ? $json : $default;
    }

public static function asJson ( $ data , $ default = null ) { $ json = is_string ( $ data ) ? $ data : json_encode ( $ data ) ; return $ json !== false ? $ json : $ default ; }

Parameter return as JSON.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public static function asString($data, $default = null)
    {
        $string = filter_var(
            $data ?? [],
            FILTER_SANITIZE_STRING,
            FILTER_FLAG_NO_ENCODE_QUOTES
        );

        return $string !== false ? $string : $default;
    }

public static function asString ( $ data , $ default = null ) { $ string = filter_var ( $ data ?? [ ] , FILTER_SANITIZE_STRING , FILTER_FLAG_NO_ENCODE_QUOTES ) ; return $ string !== false ? $ string : $ default ; }

Parameter return as string.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public static function asInteger($data, $default = null)
    {
        $int = filter_var($data ?? '', FILTER_VALIDATE_INT);

        return $int !== false ? $int : $default;
    }

public static function asInteger ( $ data , $ default = null ) { $ int = filter_var ( $ data ?? '' , FILTER_VALIDATE_INT ) ; return $ int !== false ? $ int : $ default ; }

Parameter return as integer.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public static function asFloat($data, $default = null)
    {
        $float = filter_var($data ?? '', FILTER_VALIDATE_FLOAT);

        return $float !== false ? $float : $default;
    }

public static function asFloat ( $ data , $ default = null ) { $ float = filter_var ( $ data ?? '' , FILTER_VALIDATE_FLOAT ) ; return $ float !== false ? $ float : $ default ; }

Parameter return as float.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public static function asBoolean($data, $default = null)
    {
        $boolean = filter_var($data ?? [], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

        return ! is_null($boolean) ? $boolean : $default;
    }

public static function asBoolean ( $ data , $ default = null ) { $ boolean = filter_var ( $ data ?? [ ] , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ; return ! is_null ( $ boolean ) ? $ boolean : $ default ; }

Parameter return as boolean.

@param mixed $data    → data to convert
@param mixed $default → default value in error case

@return mixed → value, null or customized return value


public function generate(\ReflectionClass $originalClass, string $realClassName, string $originalClassName) : string
    {
        $position = \strrpos($realClassName, '\\');
        $namespace = \substr($realClassName, 0, $position);
        $className = \substr($realClassName, $position + 1);

        $visiblePropertyMap = [];
        $hiddenPropertyMap = [];

        foreach ($this->findAllInstanceProperties($originalClass) as $property) {
            $declaringClassName = $property->getDeclaringClass()->getName();

            if ($property->isPrivate() || $property->isProtected()) {
                $hiddenPropertyMap[$declaringClassName][] = $property->getName();
            } else {
                $visiblePropertyMap[] = $property->getName();
            }
        }

        return <<<EOT
<?php

namespace {$namespace};

use Zend\Hydrator\HydratorInterface;

/**
 * This is a generated hydrator for the {$originalClassName} class
 */
class {$className} implements HydratorInterface
{
    private \$hydrateCallbacks = [];
    private \$extractCallbacks = [];

    public function __construct()
    {
        {$this->createContructor($visiblePropertyMap, $hiddenPropertyMap)}
    }

    public function hydrate(array \$data, \$object)
    {
        {$this->createHydrateMethod($visiblePropertyMap, $hiddenPropertyMap)}
    }

    public function extract(\$object)
    {
        {$this->createExtractMethod($visiblePropertyMap, $hiddenPropertyMap)}
    }
}
EOT;
    }

Generates an hydrator class

@return string


private function findAllInstanceProperties(\ReflectionClass $class = null)
    {
        if (! $class) {
            return [];
        }

        return \array_values(\array_merge(
            $this->findAllInstanceProperties($class->getParentClass() ?: null), // of course PHP is shit.
            \array_values(\array_filter(
                $class->getProperties(),
                function (\ReflectionProperty $property) : bool {
                    return ! $property->isStatic();
                }
            ))
        ));
    }

private
function
findAllInstanceProperties
(
\
ReflectionClass
$
class
=
)
{
if
(
!
$
class
)
{
return
[
]
;
}
return
\
array_values
(
\
array_merge
(
$
this
->
findAllInstanceProperties
(
$
class
->
getParentClass
(
)
:
)
,
// of course PHP is shit.
\
array_values
(
\
array_filter
(
$
class
->
getProperties
(
)
,
function
(
\
ReflectionProperty
$
property
)
:
bool
{
return
!
$
property
->
isStatic
(
)
;
}
)
)
)
)
;
}

Find all class properties recursively using class hierarchy without
removing name redefinitions

@param \ReflectionClass $class

@return \ReflectionProperty[]


private function createContructor(array $visiblePropertyMap, array $hiddenPropertyMap) : string
    {
        $content = [];

        // Create a set of closures that will be called to hydrate the object.
        // Array of closures in a naturally indexed array, ordered, which will
        // then be called in order in the hydrate() and extract() methods.
        foreach ($hiddenPropertyMap as $className => $propertyNames) {
            // Hydrate closures
            $content[] = "\$this->hydrateCallbacks[] = \\Closure::bind(function (\$object, \$values) {";
            foreach ($propertyNames as $propertyName) {
                $content[] = "    if (isset(\$values['" . $propertyName . "']) || \$object->" . $propertyName . " !== null && \\array_key_exists('" . $propertyName . "', \$values)) {";
                $content[] = "        \$object->" . $propertyName . " = \$values['" . $propertyName . "'];";
                $content[] = "    }";
            }
            $content[] = '}, null, ' . \var_export($className, true) . ');' . "\n";

            // Extract closures
            $content[] = "\$this->extractCallbacks[] = \\Closure::bind(function (\$object, &\$values) {";
            foreach ($propertyNames as $propertyName) {
                $content[] = "    \$values['" . $propertyName . "'] = \$object->" . $propertyName . ";";
            }
            $content[] = '}, null, ' . \var_export($className, true) . ');' . "\n";
        }

        return \implode("\n", \array_map(
            function ($line) {
                return "        " . $line;
            }, $content
        ));
    }

Generate code for the hydrator constructor

@param string[][] $visiblePropertyMap
@param string[] $hiddenPropertyMap

@return string


private function createHydrateMethod(array $visiblePropertyMap, array $hiddenPropertyMap) : string
    {
        $content = [];

        foreach ($visiblePropertyMap as $propertyName) {
            $content[] = "if (isset(\$data['" . $propertyName . "']) || \$object->" . $propertyName . " !== null && \\array_key_exists('" . $propertyName . "', \$data)) {";
            $content[] = "    \$object->" . $propertyName . " = \$data['" . $propertyName . "'];";
            $content[] = "}";
        }
        $index = 0;
        foreach ($hiddenPropertyMap as $className => $propertyNames) {
            $content[] = "\$this->hydrateCallbacks[" . ($index++) . "]->__invoke(\$object, \$data);";
        }

        $content[] = "return \$object;";

        return \implode("\n", \array_map(
            function ($line) {
                return "        " . $line;
            }, $content
        ));
    }

private
function
createHydrateMethod
(
array
$
visiblePropertyMap
,
array
$
hiddenPropertyMap
)
:
string
{
$
content
=
[
]
;
foreach
(
$
visiblePropertyMap
as
$
propertyName
)
{
$
content
[
]
=
"if (isset(\$data['"
.
$
propertyName
.
"']) || \$object->"
.
$
propertyName
.
" !== null && \\array_key_exists('"
.
$
propertyName
.
"', \$data)) {"
;
$
content
[
]
=
"    \$object->"
.
$
propertyName
.
" = \$data['"
.
$
propertyName
.
"'];"
;
$
content
[
]
=
"}"
;
}
$
index
=
0
;
foreach
(
$
hiddenPropertyMap
as
$
className
=>
$
propertyNames
)
{
$
content
[
]
=
"\$this->hydrateCallbacks["
.
(
$
index
++
)
.
"]->__invoke(\$object, \$data);"
;
}
$
content
[
]
=
"return \$object;"
;
return
\
implode
(
"\n"
,
\
array_map
(
function
(
$
line
)
{
return
"        "
.
$
line
;
}
,
$
content
)
)
;
}

Generate code for the hydrate method

@param string[][] $visiblePropertyMap
@param string[] $hiddenPropertyMap

@return string


public static function updateConfig()
    {
        /** @var ExtensionsManager $module */
        $module = ExtensionsManager::module();
        $extensions = $module->getExtensions();
        $installed = ComposerInstalledSet::get(true)->getInstalled();
        $fileName = Yii::getAlias($module->extensionsStorage);
        $writer = new ApplicationConfigWriter(['filename' => $fileName]);
        $config = self::rebuldConfig($installed);
        if (false === empty($extensions)) {
            $toAdd = array_udiff($config, $extensions, [self::className(), 'arraysCompareCallback']);
            $toRemove = array_udiff($extensions, $config, [self::className(), 'arraysCompareCallback']);
            foreach ($toRemove as $name => $ext) {
                if (true === isset($extensions[$name])) {
                    unset($extensions[$name]);
                }
            }
            $config = array_merge($extensions, $toAdd);
        }
        $writer->addValues($config);
        return $writer->commit();
    }

public
static
function
updateConfig
(
)
{
/** @var ExtensionsManager $module */
$
module
=
ExtensionsManager
::
module
(
)
;
$
extensions
=
$
module
->
getExtensions
(
)
;
$
installed
=
ComposerInstalledSet
::
get
(
true
)
->
getInstalled
(
)
;
$
fileName
=
Yii
::
getAlias
(
$
module
->
extensionsStorage
)
;
$
writer
=
new
ApplicationConfigWriter
(
[
'filename'
=>
$
fileName
]
)
;
$
config
=
self
::
rebuldConfig
(
$
installed
)
;
if
(
false
===
empty
(
$
extensions
)
)
{
$
toAdd
=
array_udiff
(
$
config
,
$
extensions
,
[
self
::
className
(
)
,
'arraysCompareCallback'
]
)
;
$
toRemove
=
array_udiff
(
$
extensions
,
$
config
,
[
self
::
className
(
)
,
'arraysCompareCallback'
]
)
;
foreach
(
$
toRemove
as
$
name
=>
$
ext
)
{
if
(
true
===
isset
(
$
extensions
[
$
name
]
)
)
{
unset
(
$
extensions
[
$
name
]
)
;
}
}
$
config
=
array_merge
(
$
extensions
,
$
toAdd
)
;
}
$
writer
->
addValues
(
$
config
)
;
return
$
writer
->
commit
(
)
;
}

Calculates differences between @vengor/composer/installed.json and ExtensionsManager::$extensionsStorage
and writes new ExtensionsManager::$extensionsStorage
@return bool Result, true if success


public static function checkLocalStorage($dir, $data)
    {
        $fn = $dir . '/composer.json';
        $created = true;
        if (true === FileHelper::createDirectory($dir)) {
            if (false === file_exists($fn)) {
                $created = file_put_contents(
                    $fn,
                    Json::encode($data, JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)
                );
            }
            if (false === $created) {
                Yii::$app->session->setFlash(
                    'error',
                    Yii::t('extensions-manager', 'Unable to create local composer.json file')
                );
            }
        } else {
            Yii::$app->session->setFlash(
                'error',
                Yii::t('extensions-manager', 'Unable to create folder to store local composer.json file')
            );
            $created = false;
        }
        return $created;
    }

Checks and creates if necessary and possible folder to store and local composer.json

@param string $dir
@param array $data
@return bool|int
@throws \yii\base\Exception

Checks and creates if necessary and possible folder to store and local composer . json


public function findOneByAttribute(string $attribute, $value): ?Page
    {
        $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);
        /** @var Page $page */
        foreach ($iterator as $page) {
            if ($page->getAttribute($attribute) === $value) {
                return $page;
            }
        }
        return null;
    }

public
function
findOneByAttribute
(
string
$
attribute
,
$
value
)
:
Page
{
$
iterator
=
new
\
RecursiveIteratorIterator
(
$
this
,
\
RecursiveIteratorIterator
::
SELF_FIRST
)
;
/** @var Page $page */
foreach
(
$
iterator
as
$
page
)
{
if
(
$
page
->
getAttribute
(
$
attribute
)
===
$
value
)
{
return
$
page
;
}
}
return
;
}

Find a single child by attribute

@param string $attribute
@param mixed $value
@return Page|null


public function findByAttribute(string $attribute, $value): array
    {
        $result = [];
        $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);

        /** @var Page $page */
        foreach ($iterator as $page) {
            if ($page->getAttribute($attribute) == $value) {
                $result[] = $page;
            }
        }
        return $result;
    }

public
function
findByAttribute
(
string
$
attribute
,
$
value
)
:
array
{
$
result
=
[
]
;
$
iterator
=
new
\
RecursiveIteratorIterator
(
$
this
,
\
RecursiveIteratorIterator
::
SELF_FIRST
)
;
/** @var Page $page */
foreach
(
$
iterator
as
$
page
)
{
if
(
$
page
->
getAttribute
(
$
attribute
)
==
$
value
)
{
$
result
[
]
=
$
page
;
}
}
return
$
result
;
}

Find all children by attribute

@param string $attribute
@param mixed $value
@return array


public function findOneByOption(string $option, $value): ?Page
    {
        $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);
        /** @var Page $page */
        foreach ($iterator as $page) {
            if ($page->getOption($option) == $value) {
                return $page;
            }
        }
        return null;
    }

public
function
findOneByOption
(
string
$
option
,
$
value
)
:
Page
{
$
iterator
=
new
\
RecursiveIteratorIterator
(
$
this
,
\
RecursiveIteratorIterator
::
SELF_FIRST
)
;
/** @var Page $page */
foreach
(
$
iterator
as
$
page
)
{
if
(
$
page
->
getOption
(
$
option
)
==
$
value
)
{
return
$
page
;
}
}
return
;
}

Finds a single child by option.

@param string $option
@param mixed $value
@return Page|null


public function findByOption(string $option, $value): array
    {
        $result = [];
        $iterator = new \RecursiveIteratorIterator($this, \RecursiveIteratorIterator::SELF_FIRST);
        /** @var Page $page */
        foreach ($iterator as $page) {
            if ($page->getOption($option) == $value) {
                $result[] = $page;
            }
        }
        return $result;
    }

public
function
findByOption
(
string
$
option
,
$
value
)
:
array
{
$
result
=
[
]
;
$
iterator
=
new
\
RecursiveIteratorIterator
(
$
this
,
\
RecursiveIteratorIterator
::
SELF_FIRST
)
;
/** @var Page $page */
foreach
(
$
iterator
as
$
page
)
{
if
(
$
page
->
getOption
(
$
option
)
==
$
value
)
{
$
result
[
]
=
$
page
;
}
}
return
$
result
;
}

Finds all children by option.

@param string $option
@param mixed $value
@return array


public function register($binding)
    {
        if ( ! extension_loaded('wxwidgets')) {
            if ( ! @dl('wxwidgets.'.PHP_SHLIB_SUFFIX)) {
                echo 'wxWidgets extension not installed or dynamically loaded extensions are not enabled'.PHP_EOL;
                exit(1);
            }
        }

        switch ($binding) {
            case 'view.viewparser':
                $this->registerViewParser();
            break;

            case 'wx':
                $this->registerWx();
            break;

            case 'launcher':
                $this->registerLauncher();
            break;

            case 'giml.collection':
                $this->registerGimlCollection();
            break;

            default:
                $this->registerGimlCollection();
                $this->registerViewParser();
                $this->registerWx();
                $this->registerLauncher();
            break;
        }
    }

Register the specified binding into the container

@param  string $binding
@return void


protected function registerViewParser()
    {
        $this->container->bind('view.viewparser', function() {
            return new ViewParser(
                $this->container['giml.reader'],
                $this->container['giml.collection'],
                new NamespaceElementFactory('Encore\Wx\Element')
            );
        });
    }

protected function registerViewParser ( ) { $ this -> container -> bind ( 'view.viewparser' , function ( ) { return new ViewParser ( $ this -> container [ 'giml.reader' ] , $ this -> container [ 'giml.collection' ] , new NamespaceElementFactory ( 'Encore\Wx\Element' ) ) ; } ) ; }


protected function registerLauncher()
    {
        $this->container->bind('launcher', function() {
            wxInitAllImageHandlers();
            \wxApp::SetInstance($this->container['wx']);
            wxEntry();
        });
    }

protected function registerLauncher ( ) { $ this -> container -> bind ( 'launcher' , function ( ) { wxInitAllImageHandlers ( ) ; \ wxApp :: SetInstance ( $ this -> container [ 'wx' ] ) ; wxEntry ( ) ; } ) ; }

Register the WxWidgets launcher

@return void


protected function driver($name, $data = array())
    {
        if (in_array($name, $this->mysql) === true) {
            $dsn = (string) 'mysql:host=%s;dbname=%s';

            $dsn = sprintf($dsn, $data['hostname'], $data['database']);

            $pdo = new \PDO($dsn, $data['username'], $data['password']);

            return new MySQLDriver($pdo, (string) $data['database']);
        }

        if (in_array($name, $this->sqlite)) {
            return new SQLiteDriver(new \PDO($data['hostname']));
        }

        $message = 'Database driver "%s" not found.';

        $message = sprintf($message, (string) $name);

        throw new DriverNotFoundException($message);
    }

protected
function
driver
(
$
name
,
$
data
=
array
(
)
)
{
if
(
in_array
(
$
name
,
$
this
->
mysql
)
===
true
)
{
$
dsn
=
(
string
)
'mysql:host=%s;dbname=%s'
;
$
dsn
=
sprintf
(
$
dsn
,
$
data
[
'hostname'
]
,
$
data
[
'database'
]
)
;
$
pdo
=
new
\
PDO
(
$
dsn
,
$
data
[
'username'
]
,
$
data
[
'password'
]
)
;
return
new
MySQLDriver
(
$
pdo
,
(
string
)
$
data
[
'database'
]
)
;
}
if
(
in_array
(
$
name
,
$
this
->
sqlite
)
)
{
return
new
SQLiteDriver
(
new
\
PDO
(
$
data
[
'hostname'
]
)
)
;
}
$
message
=
'Database driver "%s" not found.'
;
$
message
=
sprintf
(
$
message
,
(
string
)
$
name
)
;
throw
new
DriverNotFoundException
(
$
message
)
;
}

Returns the Driver instance from the configuration.

@param  string $name
@param  array  $data
@return \Rougin\Describe\Driver\DriverInterface

@throws \Rougin\Describe\Exceptions\DriverNotFoundException

Returns the Driver instance from the configuration .


protected function getInvalidResult(string $code, array $parameters = null): ResultInterface
    {
        $templates = $this->getTemplates();
        if (array_key_exists($code, $templates) === false) {
            throw new TemplateNotFound($code);
        }

        return new InvalidResult($code, $templates[$code], $parameters ?? []);
    }

protected function getInvalidResult ( string $ code , array $ parameters = null ) : ResultInterface { $ templates = $ this -> getTemplates ( ) ; if ( array_key_exists ( $ code , $ templates ) === false ) { throw new TemplateNotFound ( $ code ) ; } return new InvalidResult ( $ code , $ templates [ $ code ] , $ parameters ?? [ ] ) ; }

Create invalid result.

When template can not be found, an exception will be thrown.

@param string $code
@param array  $parameters
@return ResultInterface
@throws TemplateNotFound


public static function start($name = "default")
  {
    if(array_key_exists($name, self::$timers))
    {
      self::$timers[$name]->start();
    }
    else
    {
      self::$timers[$name] = new Profiler\Timer($name);
    }
  }

public static function start ( $ name = "default" ) { if ( array_key_exists ( $ name , self :: $ timers ) ) { self :: $ timers [ $ name ] -> start ( ) ; } else { self :: $ timers [ $ name ] = new Profiler \ Timer ( $ name ) ; } }

Starts a timer.

@param  string $name
@return void


public function subscribe($signal, $callback)
  {
    if(empty($this->sigslots[$signal]))
    {
      $this->sigslots[$signal] = array();
    }

    $index = md5(serialize($callback));

    if(!array_key_exists($index, $this->sigslots[$signal]))
    {
      $this->sigslots[$signal][$index] = new Signal\Handler($signal, $callback);
    }

    return $this->sigslots[$signal][$index];
  }

public function subscribe ( $ signal , $ callback ) { if ( empty ( $ this -> sigslots [ $ signal ] ) ) { $ this -> sigslots [ $ signal ] = array ( ) ; } $ index = md5 ( serialize ( $ callback ) ) ; if ( ! array_key_exists ( $ index , $ this -> sigslots [ $ signal ] ) ) { $ this -> sigslots [ $ signal ] [ $ index ] = new Signal \ Handler ( $ signal , $ callback ) ; } return $ this -> sigslots [ $ signal ] [ $ index ] ; }

Subscribes to a signal and returns the signal handler.

@param  string $signal
@param  mixed  $callback
@return Signal\Handler

Subscribes to a signal and returns the signal handler .


public function unsubscribe($signal, $callback = null)
  {
    if(!$this->hasHandlers($signal))
    {
      return;
    }

    if($callback !== null)
    {
      $index = md5(serialize($callback));

      if(!array_key_exists($index, $this->sigslots[$signal]))
      {
        return;
      }

      unset($this->sigslots[$signal][$index]);
    }
    else
    {
      unset($this->sigslots[$signal]);
    }
  }

public function unsubscribe ( $ signal , $ callback = null ) { if ( ! $ this -> hasHandlers ( $ signal ) ) { return ; } if ( $ callback !== null ) { $ index = md5 ( serialize ( $ callback ) ) ; if ( ! array_key_exists ( $ index , $ this -> sigslots [ $ signal ] ) ) { return ; } unset ( $ this -> sigslots [ $ signal ] [ $ index ] ) ; } else { unset ( $ this -> sigslots [ $ signal ] ) ; } }

Unsubscribes from a signal.

@param  string $signal
@param  mixed  $callback
@return void


protected function getValue($value, $type)
    {
        switch ($type) {
            case self::ATTRIBUTE_TYPE_USER:
                return $this->getUsername($value);
            case self::ATTRIBUTE_TYPE_DATE:
                return date('Y-m-d h:i:s', $value);
            default:
                return $value;
        }
    }

protected
function
getValue
(
$
value
,
$
type
)
{
switch
(
$
type
)
{
case
self
::
ATTRIBUTE_TYPE_USER
:
return
$
this
->
getUsername
(
$
value
)
;
case
self
::
ATTRIBUTE_TYPE_DATE
:
return
date
(
'Y-m-d h:i:s'
,
$
value
)
;
default
:
return
$
value
;
}
}

Get pretty value by type
@param mixed $value
@param string $type
@return mixed


protected function keys($row, Column $column)
    {
        switch ($row->Key) {
            case 'PRI':
                $column->setPrimary(true);

                break;

            case 'MUL':
                $column->setForeign(true);

                break;

            case 'UNI':
                $column->setUnique(true);

                break;
        }

        return $column;
    }

protected function keys ( $ row , Column $ column ) { switch ( $ row -> Key ) { case 'PRI' : $ column -> setPrimary ( true ) ; break ; case 'MUL' : $ column -> setForeign ( true ) ; break ; case 'UNI' : $ column -> setUnique ( true ) ; break ; } return $ column ; }

Sets the key of a column.

@param  mixed                   $row
@param  \Rougin\Describe\Column $column
@return \Rougin\Describe\Column


protected function query($table, $query, $columns = array())
    {
        $result = $this->pdo->prepare($query);

        $result->execute();

        $result->setFetchMode(\PDO::FETCH_OBJ);

        while ($row = $result->fetch()) {
            $column = $this->column(new Column, $table, $row);

            array_push($columns, $column);
        }

        if (empty($columns) === true) {
            $message = 'Table "' . $table . '" does not exists!';

            throw new TableNotFoundException($message);
        }

        return $columns;
    }

protected
function
query
(
$
table
,
$
query
,
$
columns
=
array
(
)
)
{
$
result
=
$
this
->
pdo
->
prepare
(
$
query
)
;
$
result
->
execute
(
)
;
$
result
->
setFetchMode
(
\
PDO
::
FETCH_OBJ
)
;
while
(
$
row
=
$
result
->
fetch
(
)
)
{
$
column
=
$
this
->
column
(
new
Column
,
$
table
,
$
row
)
;
array_push
(
$
columns
,
$
column
)
;
}
if
(
empty
(
$
columns
)
===
true
)
{
$
message
=
'Table "'
.
$
table
.
'" does not exists!'
;
throw
new
TableNotFoundException
(
$
message
)
;
}
return
$
columns
;
}

Returns the list of columns based on a query.

@param  string $table
@param  string $query
@param  array  $columns
@return \Rougin\Describe\Column[]

Returns the list of columns based on a query .


protected function properties($row, Column $column)
    {
        $increment = $row->Extra === 'auto_increment';

        $column->setAutoIncrement($increment);

        $column->setNull($row->{'Null'} === 'YES');

        return $column;
    }

protected function properties ( $ row , Column $ column ) { $ increment = $ row -> Extra === 'auto_increment' ; $ column -> setAutoIncrement ( $ increment ) ; $ column -> setNull ( $ row -> { 'Null' } === 'YES' ) ; return $ column ; }

Sets the properties of a column.

@param  mixed                   $row
@param  \Rougin\Describe\Column $column
@return \Rougin\Describe\Column


protected function strip($table)
    {
        $exists = strpos($table, '.') !== false;

        $updated = substr($table, strpos($table, '.') + 1);

        return $exists ? $updated : $table;
    }

protected function strip ( $ table ) { $ exists = strpos ( $ table , '.' ) !== false ; $ updated = substr ( $ table , strpos ( $ table , '.' ) + 1 ) ; return $ exists ? $ updated : $ table ; }

Strips the table schema from the table name.

@param  string $table
@return string

Strips the table schema from the table name .


public function serverSelect($sid, $virtual = null)
  {
    if($this->whoami !== null && $this->serverSelectedId() == $sid) return;

    $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
    $getargs = func_get_args();

    $this->execute("use", array("sid" => $sid, $virtual ? "-virtual" : null));

    if($sid != 0 && $this->predefined_query_name !== null)
    {
      $this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
    }

    $this->whoamiReset();

    $this->setStorage("_server_use", array(__FUNCTION__, $getargs));

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerselected", $this);
  }

public function serverSelect ( $ sid , $ virtual = null ) { if ( $ this -> whoami !== null && $ this -> serverSelectedId ( ) == $ sid ) return ; $ virtual = ( $ virtual !== null ) ? $ virtual : $ this -> start_offline_virtual ; $ getargs = func_get_args ( ) ; $ this -> execute ( "use" , array ( "sid" => $ sid , $ virtual ? "-virtual" : null ) ) ; if ( $ sid != 0 && $ this -> predefined_query_name !== null ) { $ this -> execute ( "clientupdate" , array ( "client_nickname" => ( string ) $ this -> predefined_query_name ) ) ; } $ this -> whoamiReset ( ) ; $ this -> setStorage ( "_server_use" , array ( __FUNCTION__ , $ getargs ) ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyServerselected" , $ this ) ; }

Selects a virtual server by ID to allow further interaction.

@param  integer $sid
@param  boolean $virtual
@return void

Selects a virtual server by ID to allow further interaction .


public function serverSelectByPort($port, $virtual = null)
  {
    if($this->whoami !== null && $this->serverSelectedPort() == $port) return;

    $virtual = ($virtual !== null) ? $virtual : $this->start_offline_virtual;
    $getargs = func_get_args();

    $this->execute("use", array("port" => $port, $virtual ? "-virtual" : null));

    if($port != 0 && $this->predefined_query_name !== null)
    {
      $this->execute("clientupdate", array("client_nickname" => (string) $this->predefined_query_name));
    }

    $this->whoamiReset();

    $this->setStorage("_server_use", array(__FUNCTION__, $getargs));

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerselected", $this);
  }

public function serverSelectByPort ( $ port , $ virtual = null ) { if ( $ this -> whoami !== null && $ this -> serverSelectedPort ( ) == $ port ) return ; $ virtual = ( $ virtual !== null ) ? $ virtual : $ this -> start_offline_virtual ; $ getargs = func_get_args ( ) ; $ this -> execute ( "use" , array ( "port" => $ port , $ virtual ? "-virtual" : null ) ) ; if ( $ port != 0 && $ this -> predefined_query_name !== null ) { $ this -> execute ( "clientupdate" , array ( "client_nickname" => ( string ) $ this -> predefined_query_name ) ) ; } $ this -> whoamiReset ( ) ; $ this -> setStorage ( "_server_use" , array ( __FUNCTION__ , $ getargs ) ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyServerselected" , $ this ) ; }

Selects a virtual server by UDP port to allow further interaction.

@param  integer $port
@param  boolean $virtual
@return void

Selects a virtual server by UDP port to allow further interaction .


public function serverGetPortById($sid)
  {
    if(!array_key_exists((string) $sid, $this->serverList()))
    {
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid serverID", 0x400);
    }

    return $this->serverList[intval((string) $sid)]["virtualserver_port"];
  }

public
function
serverGetPortById
(
$
sid
)
{
if
(
!
array_key_exists
(
(
string
)
$
sid
,
$
this
->
serverList
(
)
)
)
{
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid serverID"
,
0x400
)
;
}
return
$
this
->
serverList
[
intval
(
(
string
)
$
sid
)
]
[
"virtualserver_port"
]
;
}

Returns the port of a virtual server matching the given ID.

@param  integer $sid
@return integer

Returns the port of a virtual server matching the given ID .


public function serverGetByName($name)
  {
    foreach($this->serverList() as $server)
    {
      if($server["virtualserver_name"] == $name) return $server;
    }

    throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid serverID", 0x400);
  }

public
function
serverGetByName
(
$
name
)
{
foreach
(
$
this
->
serverList
(
)
as
$
server
)
{
if
(
$
server
[
"virtualserver_name"
]
==
$
name
)
return
$
server
;
}
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid serverID"
,
0x400
)
;
}

Returns the first TeamSpeak3_Node_Server object matching the given name.

@param  string $name
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Server

Returns the first TeamSpeak3_Node_Server object matching the given name .


public function serverGetByUid($uid)
  {
    foreach($this->serverList() as $server)
    {
      if($server["virtualserver_unique_identifier"] == $uid) return $server;
    }

    throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid serverID", 0x400);
  }

public
function
serverGetByUid
(
$
uid
)
{
foreach
(
$
this
->
serverList
(
)
as
$
server
)
{
if
(
$
server
[
"virtualserver_unique_identifier"
]
==
$
uid
)
return
$
server
;
}
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid serverID"
,
0x400
)
;
}

Returns the first TeamSpeak3_Node_Server object matching the given unique identifier.

@param  string $uid
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Server

Returns the first TeamSpeak3_Node_Server object matching the given unique identifier .


public function serverCreate(array $properties = array())
  {
    $this->serverListReset();

    $detail = $this->execute("servercreate", $properties)->toList();
    $server = new Server($this, array("virtualserver_id" => intval($detail["sid"])));

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServercreated", $this, $detail["sid"]);
    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyTokencreated", $server, $detail["token"]);

    return $detail;
  }

public function serverCreate ( array $ properties = array ( ) ) { $ this -> serverListReset ( ) ; $ detail = $ this -> execute ( "servercreate" , $ properties ) -> toList ( ) ; $ server = new Server ( $ this , array ( "virtualserver_id" => intval ( $ detail [ "sid" ] ) ) ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyServercreated" , $ this , $ detail [ "sid" ] ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyTokencreated" , $ server , $ detail [ "token" ] ) ; return $ detail ; }

Creates a new virtual server using given properties and returns an assoc
array containing the new ID and initial admin token.

@param  array $properties
@return array

Creates a new virtual server using given properties and returns an assoc array containing the new ID and initial admin token .


public function serverDelete($sid)
  {
    $this->serverListReset();

    $this->execute("serverdelete", array("sid" => $sid));

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerdeleted", $this, $sid);
  }

public function serverDelete ( $ sid ) { $ this -> serverListReset ( ) ; $ this -> execute ( "serverdelete" , array ( "sid" => $ sid ) ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyServerdeleted" , $ this , $ sid ) ; }

Deletes the virtual server specified by ID.

@param  integer $sid
@return void

Deletes the virtual server specified by ID .


public function serverStart($sid)
  {
    if($sid == $this->serverSelectedId())
    {
      $this->serverDeselect();
    }

    $this->execute("serverstart", array("sid" => $sid));
    $this->serverListReset();

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServerstarted", $this, $sid);
  }

public function serverStart ( $ sid ) { if ( $ sid == $ this -> serverSelectedId ( ) ) { $ this -> serverDeselect ( ) ; } $ this -> execute ( "serverstart" , array ( "sid" => $ sid ) ) ; $ this -> serverListReset ( ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyServerstarted" , $ this , $ sid ) ; }

Starts the virtual server specified by ID.

@param  integer $sid
@return void

Starts the virtual server specified by ID .


public function serverStopProcess()
  {
    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyServershutdown", $this);

    $this->execute("serverprocessstop");
  }

public function serverStopProcess ( ) { \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( "notifyServershutdown" , $ this ) ; $ this -> execute ( "serverprocessstop" ) ; }

Stops the entire TeamSpeak 3 Server instance by shutting down the process.

@return void

Stops the entire TeamSpeak 3 Server instance by shutting down the process .


public function permissionList()
  {
    if($this->permissionList === null)
    {
      $this->permissionList = $this->request("permissionlist")->toAssocArray("permname");
    }

    return $this->permissionList;
  }

public function permissionList ( ) { if ( $ this -> permissionList === null ) { $ this -> permissionList = $ this -> request ( "permissionlist" ) -> toAssocArray ( "permname" ) ; } return $ this -> permissionList ; }

Returns a list of permissions available on the server instance.

@return array

Returns a list of permissions available on the server instance .


public function permissionFind($permid)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    return $this->execute("permfind", array($permident => $permid))->toArray();
  }

public function permissionFind ( $ permid ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; return $ this -> execute ( "permfind" , array ( $ permident => $ permid ) ) -> toArray ( ) ; }

Returns the IDs of all clients, channels or groups using the permission with the
specified ID.

@param  integer $permid
@return array

Returns the IDs of all clients channels or groups using the permission with the specified ID .