private static function activate($extension, ReportingChain $chain)
    {
        if ($extension['is_active'] == 0) {
            ExtensionDataHelper::prepareMigrationTask(
                $extension,
                $chain,
                ExtensionsManager::MIGRATE_TYPE_UP,
                ExtensionsManager::EXTENSION_ACTIVATE_DEFERRED_GROUP
            );
            $activationTask = ExtensionDataHelper::buildTask(
                [
                    realpath(Yii::getAlias('@app') . '/yii'),
                    'extension/activate',
                    $extension['composer_name'],
                ],
                ExtensionsManager::EXTENSION_ACTIVATE_DEFERRED_GROUP
            );
            $chain->addTask($activationTask);
        } else {
            $dummyTask = ExtensionDataHelper::buildTask(
                [
                    realpath(Yii::getAlias('@app') . '/yii'),
                    'extension/dummy',
                    'Extension already activated!',
                ],
                ExtensionsManager::EXTENSION_DUMMY_DEFERRED_GROUP
            );
            $chain->addTask($dummyTask);
        }
    }

private
static
function
activate
(
$
extension
,
ReportingChain
$
chain
)
{
if
(
$
extension
[
'is_active'
]
==
0
)
{
ExtensionDataHelper
::
prepareMigrationTask
(
$
extension
,
$
chain
,
ExtensionsManager
::
MIGRATE_TYPE_UP
,
ExtensionsManager
::
EXTENSION_ACTIVATE_DEFERRED_GROUP
)
;
$
activationTask
=
ExtensionDataHelper
::
buildTask
(
[
realpath
(
Yii
::
getAlias
(
'@app'
)
.
'/yii'
)
,
'extension/activate'
,
$
extension
[
'composer_name'
]
,
]
,
ExtensionsManager
::
EXTENSION_ACTIVATE_DEFERRED_GROUP
)
;
$
chain
->
addTask
(
$
activationTask
)
;
}
else
{
$
dummyTask
=
ExtensionDataHelper
::
buildTask
(
[
realpath
(
Yii
::
getAlias
(
'@app'
)
.
'/yii'
)
,
'extension/dummy'
,
'Extension already activated!'
,
]
,
ExtensionsManager
::
EXTENSION_DUMMY_DEFERRED_GROUP
)
;
$
chain
->
addTask
(
$
dummyTask
)
;
}
}

Adds activation task into ReportingChain if Extension is not active

@param array $extension
@param ReportingChain $chain


private static function uninstall($extension, ReportingChain $chain)
    {
        $module = ExtensionsManager::module();
        if (true === $module->extensionIsCore($extension['composer_name'])) {
            $dummyTask = ExtensionDataHelper::buildTask(
                [
                    realpath(Yii::getAlias('@app') . '/yii'),
                    'extension/dummy',
                    '--no-interaction',
                    '-o',
                    'You are unable to uninstall core extensions!',
                ],
                ExtensionsManager::EXTENSION_DUMMY_DEFERRED_GROUP
            );
            $chain->addTask($dummyTask);
        } else {
            self::deactivate($extension, $chain);
            $uninstallTask = ExtensionDataHelper::buildTask(
                [
                    $module->composerPath,
                    'remove',
                    $extension['composer_name'],
                    '--no-ansi',
                    '--no-interaction',
                    "--working-dir={$module->getLocalExtensionsPath()}",
                    $module->verbose == 1 ? '-vvv' : '',
                ],
                ExtensionsManager::COMPOSER_UNINSTALL_DEFERRED_GROUP
            );
            $chain->addTask($uninstallTask);
        }
    }

Adds uninstall task into ReportingChain

@param $extension
@param ReportingChain $chain


private static function runTask($command, $groupName)
    {
        $task = ExtensionDataHelper::buildTask($command, $groupName);
        if ($task->registerTask()) {
            DeferredHelper::runImmediateTask($task->model()->id);
            Yii::$app->response->format = Response::FORMAT_JSON;
            return [
                'queueItemId' => $task->model()->id,
            ];
        } else {
            throw new ServerErrorHttpException("Unable to start task");
        }
    }

private
static
function
runTask
(
$
command
,
$
groupName
)
{
$
task
=
ExtensionDataHelper
::
buildTask
(
$
command
,
$
groupName
)
;
if
(
$
task
->
registerTask
(
)
)
{
DeferredHelper
::
runImmediateTask
(
$
task
->
model
(
)
->
id
)
;
Yii
::
$
app
->
response
->
format
=
Response
::
FORMAT_JSON
;
return
[
'queueItemId'
=>
$
task
->
model
(
)
->
id
,
]
;
}
else
{
throw
new
ServerErrorHttpException
(
"Unable to start task"
)
;
}
}

Runs separated ReportingTask

@param $command
@param $groupName
@return array
@throws ServerErrorHttpException


public function clientGetByName($name)
  {
    foreach($this->clientList() as $client)
    {
      if($client["client_nickname"] == $name) return $client;
    }

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

public
function
clientGetByName
(
$
name
)
{
foreach
(
$
this
->
clientList
(
)
as
$
client
)
{
if
(
$
client
[
"client_nickname"
]
==
$
name
)
return
$
client
;
}
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid clientID"
,
0x200
)
;
}

Returns the TeamSpeak3_Node_Client object matching the given name.

@param  integer $name
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return TeamSpeak3_Node_Client

Returns the TeamSpeak3_Node_Client object matching the given name .


public function iconDownload()
  {
    if($this->iconIsLocal("channel_icon_id") || $this["channel_icon_id"] == 0) return;

    $download = $this->getParent()->transferInitDownload(rand(0x0000, 0xFFFF), 0, $this->iconGetName("channel_icon_id"));
    $transfer = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::factory("filetransfer://" . $download["host"] . ":" . $download["port"]);

    return $transfer->download($download["ftkey"], $download["size"]);
  }

public function iconDownload ( ) { if ( $ this -> iconIsLocal ( "channel_icon_id" ) || $ this [ "channel_icon_id" ] == 0 ) return ; $ download = $ this -> getParent ( ) -> transferInitDownload ( rand ( 0x0000 , 0xFFFF ) , 0 , $ this -> iconGetName ( "channel_icon_id" ) ) ; $ transfer = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: factory ( "filetransfer://" . $ download [ "host" ] . ":" . $ download [ "port" ] ) ; return $ transfer -> download ( $ download [ "ftkey" ] , $ download [ "size" ] ) ; }

Downloads and returns the channels icon file content.

@return TeamSpeak3_Helper_String

Downloads and returns the channels icon file content .


public function message($msg, $cpw = null)
  {
    if($this->getId() != $this->getParent()->whoamiGet("client_channel_id"))
    {
      $this->getParent()->clientMove($this->getParent()->whoamiGet("client_id"), $this->getId(), $cpw);
    }

    $this->execute("sendtextmessage", array("msg" => $msg, "target" => $this->getId(), "targetmode" => \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::TEXTMSG_CHANNEL));
  }

public function message ( $ msg , $ cpw = null ) { if ( $ this -> getId ( ) != $ this -> getParent ( ) -> whoamiGet ( "client_channel_id" ) ) { $ this -> getParent ( ) -> clientMove ( $ this -> getParent ( ) -> whoamiGet ( "client_id" ) , $ this -> getId ( ) , $ cpw ) ; } $ this -> execute ( "sendtextmessage" , array ( "msg" => $ msg , "target" => $ this -> getId ( ) , "targetmode" => \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: TEXTMSG_CHANNEL ) ) ; }

Sends a text message to all clients in the channel.

@param  string $msg
@param  string $cpw
@return void

Sends a text message to all clients in the channel .


public function delete($force = FALSE)
  {
    $this->getParent()->channelDelete($this->getId(), $force);

    unset($this);
  }

public function delete ( $ force = FALSE ) { $ this -> getParent ( ) -> channelDelete ( $ this -> getId ( ) , $ force ) ; unset ( $ this ) ; }

Deletes the channel.

@param  boolean $force
@return void


public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
    {
        $header = array('typ' => 'JWT', 'alg' => $alg);
        if ($keyId !== null) {
            $header['kid'] = $keyId;
        }
        if ( isset($head) && is_array($head) ) {
            $header = array_merge($head, $header);
        }
        $segments = array();
        $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($header));
        $segments[] = JWT::urlsafeB64Encode(JWT::jsonEncode($payload));
        $signing_input = implode('.', $segments);

        $signature = JWT::sign($signing_input, $key, $alg);
        $segments[] = JWT::urlsafeB64Encode($signature);

        return implode('.', $segments);
    }

public static function encode ( $ payload , $ key , $ alg = 'HS256' , $ keyId = null , $ head = null ) { $ header = array ( 'typ' => 'JWT' , 'alg' => $ alg ) ; if ( $ keyId !== null ) { $ header [ 'kid' ] = $ keyId ; } if ( isset ( $ head ) && is_array ( $ head ) ) { $ header = array_merge ( $ head , $ header ) ; } $ segments = array ( ) ; $ segments [ ] = JWT :: urlsafeB64Encode ( JWT :: jsonEncode ( $ header ) ) ; $ segments [ ] = JWT :: urlsafeB64Encode ( JWT :: jsonEncode ( $ payload ) ) ; $ signing_input = implode ( '.' , $ segments ) ; $ signature = JWT :: sign ( $ signing_input , $ key , $ alg ) ; $ segments [ ] = JWT :: urlsafeB64Encode ( $ signature ) ; return implode ( '.' , $ segments ) ; }

Converts and signs a PHP object or array into a JWT string.

@param object|array  $payload    PHP object or array
@param string        $key        The secret key.
If the algorithm used is asymmetric, this is the private key
@param string        $alg        The signing algorithm.
Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
@param array         $head       An array with header elements to attach

@return string A signed JWT

@uses jsonEncode
@uses urlsafeB64Encode

Converts and signs a PHP object or array into a JWT string .


public static function sign($msg, $key, $alg = 'HS256')
    {
        if (empty(self::$supported_algs[$alg])) {
            throw new DomainException('Algorithm not supported');
        }
        list($function, $algorithm) = self::$supported_algs[$alg];
        switch($function) {
            case 'hash_hmac':
                return hash_hmac($algorithm, $msg, $key, true);
            case 'openssl':
                $signature = '';
                $success = openssl_sign($msg, $signature, $key, $algorithm);
                if (!$success) {
                    throw new DomainException("OpenSSL unable to sign data");
                } else {
                    return $signature;
                }
        }
    }

public
static
function
sign
(
$
msg
,
$
key
,
$
alg
=
'HS256'
)
{
if
(
empty
(
self
::
$
supported_algs
[
$
alg
]
)
)
{
throw
new
DomainException
(
'Algorithm not supported'
)
;
}
list
(
$
function
,
$
algorithm
)
=
self
::
$
supported_algs
[
$
alg
]
;
switch
(
$
function
)
{
case
'hash_hmac'
:
return
hash_hmac
(
$
algorithm
,
$
msg
,
$
key
,
true
)
;
case
'openssl'
:
$
signature
=
''
;
$
success
=
openssl_sign
(
$
msg
,
$
signature
,
$
key
,
$
algorithm
)
;
if
(
!
$
success
)
{
throw
new
DomainException
(
"OpenSSL unable to sign data"
)
;
}
else
{
return
$
signature
;
}
}
}

Sign a string with a given key and algorithm.

@param string            $msg    The message to sign
@param string|resource   $key    The secret key
@param string            $alg    The signing algorithm.
Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'

@return string An encrypted message

@throws DomainException Unsupported algorithm was specified

Sign a string with a given key and algorithm .


public static function jsonDecode($input)
    {
        if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
            /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
             * to specify that large ints (like Steam Transaction IDs) should be treated as
             * strings, rather than the PHP default behaviour of converting them to floats.
             */
            $obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
        } else {
            /** Not all servers will support that, however, so for older versions we must
             * manually detect large ints in the JSON string and quote them (thus converting
             *them to strings) before decoding, hence the preg_replace() call.
             */
            $max_int_length = strlen((string) PHP_INT_MAX) - 1;
            $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
            $obj = json_decode($json_without_bigints);
        }

        if (function_exists('json_last_error') && $errno = json_last_error()) {
            JWT::handleJsonError($errno);
        } elseif ($obj === null && $input !== 'null') {
            throw new DomainException('Null result with non-null input');
        }
        return $obj;
    }

Decode a JSON string into a PHP object.

@param string $input JSON string

@return object Object representation of JSON string

@throws DomainException Provided string was invalid JSON

Decode a JSON string into a PHP object .


public function commit()
    {
        $data = <<<PHP
<?php
/*
 * ! WARNING !
 *
 * This file is auto-generated.
 * Please don't modify it by-hand or all your changes can be lost.
 */
{$this->append}
return
PHP;
        $data .= VarDumper::export($this->configuration);
        $data .= ";\n\n";

        $result = file_put_contents($this->filename, $data, LOCK_EX) !== false;
        if ($result) {
            if (function_exists('opcache_invalidate')) {
                opcache_invalidate($this->filename, true);
            }
            if (function_exists('apc_delete_file')) {
                @apc_delete_file($this->filename);
            }
        }
        return $result;
    }

Writes all configuration to application configuration file
@return bool result, true if success


public function bootstrap($app)
    {
        $app->i18n->translations['extensions-manager'] = [
            'class' => 'yii\i18n\PhpMessageSource',
            'basePath' => __DIR__ . DIRECTORY_SEPARATOR . 'messages',
        ];
        DeferredQueueEvent::on(
            DeferredController::className(),
            DeferredController::EVENT_DEFERRED_QUEUE_COMPLETE,
            [DeferredQueueCompleteHandler::className(), 'handleEvent']
        );
        if ($app instanceof \yii\console\Application) {
            $app->controllerMap['extension'] = ExtensionController::className();
            $app->on(Application::EVENT_BEFORE_ACTION, function () {
                $module = ExtensionsManager::module();
                if ($module->autoDiscoverMigrations === true) {
                    if (isset(Yii::$app->params['yii.migrations']) === false) {
                        Yii::$app->params['yii.migrations'] = [];
                    }
                    /** @var array $extensions */
                    $extensions = $module->getExtensions();
                    foreach ($extensions as $name => $ext) {
                        if ($ext['composer_type'] === Extension::TYPE_DOTPLANT
                            && $module->discoverDotPlantMigrations === false
                        ) {
                            continue;
                        }
                        $extData = ComposerInstalledSet::get()->getInstalled($ext['composer_name']);
                        $packageMigrations = ExtensionDataHelper::getInstalledExtraData(
                            $extData,
                            'migrationPath',
                            true
                        );
                        $packagePath = '@vendor/' . $ext['composer_name'];
                        foreach ($packageMigrations as $migrationPath) {
                            Yii::$app->params['yii.migrations'][] = "$packagePath/$migrationPath";
                        }
                    }
                }
            });
        }
    }

public
function
bootstrap
(
$
app
)
{
$
app
->
i18n
->
translations
[
'extensions-manager'
]
=
[
'class'
=>
'yii\i18n\PhpMessageSource'
,
'basePath'
=>
__DIR__
.
DIRECTORY_SEPARATOR
.
'messages'
,
]
;
DeferredQueueEvent
::
on
(
DeferredController
::
className
(
)
,
DeferredController
::
EVENT_DEFERRED_QUEUE_COMPLETE
,
[
DeferredQueueCompleteHandler
::
className
(
)
,
'handleEvent'
]
)
;
if
(
$
app
instanceof
\
yii
\
console
\
Application
)
{
$
app
->
controllerMap
[
'extension'
]
=
ExtensionController
::
className
(
)
;
$
app
->
on
(
Application
::
EVENT_BEFORE_ACTION
,
function
(
)
{
$
module
=
ExtensionsManager
::
module
(
)
;
if
(
$
module
->
autoDiscoverMigrations
===
true
)
{
if
(
isset
(
Yii
::
$
app
->
params
[
'yii.migrations'
]
)
===
false
)
{
Yii
::
$
app
->
params
[
'yii.migrations'
]
=
[
]
;
}
/** @var array $extensions */
$
extensions
=
$
module
->
getExtensions
(
)
;
foreach
(
$
extensions
as
$
name
=>
$
ext
)
{
if
(
$
ext
[
'composer_type'
]
===
Extension
::
TYPE_DOTPLANT
&&
$
module
->
discoverDotPlantMigrations
===
false
)
{
continue
;
}
$
extData
=
ComposerInstalledSet
::
get
(
)
->
getInstalled
(
$
ext
[
'composer_name'
]
)
;
$
packageMigrations
=
ExtensionDataHelper
::
getInstalledExtraData
(
$
extData
,
'migrationPath'
,
true
)
;
$
packagePath
=
'@vendor/'
.
$
ext
[
'composer_name'
]
;
foreach
(
$
packageMigrations
as
$
migrationPath
)
{
Yii
::
$
app
->
params
[
'yii.migrations'
]
[
]
=
"$packagePath/$migrationPath"
;
}
}
}
}
)
;
}
}

Bootstrap method to be called during application bootstrap stage.

@param Application $app the application currently running

Bootstrap method to be called during application bootstrap stage .


public function copy($name = null, $tcgid = 0, $type = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR)
  {
    return $this->getParent()->channelGroupCopy($this->getId(), $name, $tcgid, $type);
  }

public function copy ( $ name = null , $ tcgid = 0 , $ type = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: GROUP_DBTYPE_REGULAR ) { return $ this -> getParent ( ) -> channelGroupCopy ( $ this -> getId ( ) , $ name , $ tcgid , $ type ) ; }

Creates a copy of the channel group and returns the new groups ID.

@param  string  $name
@param  integer $tcgid
@param  integer $type
@return integer

Creates a copy of the channel group and returns the new groups ID .


public function message($msg)
  {
    foreach($this as $client)
    {
      try
      {
        $this->execute("sendtextmessage", array("msg" => $msg, "target" => $client, "targetmode" => \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::TEXTMSG_CLIENT));
      }
      catch(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception $e)
      {
        /* ERROR_client_invalid_id */
        if($e->getCode() != 0x0200) throw $e;
      }
    }
  }

public
function
message
(
$
msg
)
{
foreach
(
$
this
as
$
client
)
{
try
{
$
this
->
execute
(
"sendtextmessage"
,
array
(
"msg"
=>
$
msg
,
"target"
=>
$
client
,
"targetmode"
=>
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
TEXTMSG_CLIENT
)
)
;
}
catch
(
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
$
e
)
{
/* ERROR_client_invalid_id */
if
(
$
e
->
getCode
(
)
!=
0x0200
)
throw
$
e
;
}
}
}

Sends a text message to all clients residing in the channel group on the virtual server.

@param  string $msg
@return void

Sends a text message to all clients residing in the channel group on the virtual server .


protected function formClassName(): string
    {
        if ($this->formClassName)
        {
            return $this->formClassName;
        }

        $entityClassName = $this->entityClassName();
        $this->formClassName = substr(str_replace('/Form/', '/Entity/', $entityClassName), 0, -4);

        return $this->formClassName;
    }

protected function formClassName ( ) : string { if ( $ this -> formClassName ) { return $ this -> formClassName ; } $ entityClassName = $ this -> entityClassName ( ) ; $ this -> formClassName = substr ( str_replace ( '/Form/' , '/Entity/' , $ entityClassName ) , 0 , - 4 ) ; return $ this -> formClassName ; }

Get Form class name for this controller

Override this method if necessary

@return string


public function getAction(int $id)
    {
        try {
            $em = $this->getDoctrine()->getManager();
            $entity = $em->getRepository($this->entityClassName())->find($id);
            if ($entity) {
                return $entity;
            }
            return FOSView::create('Not Found', Response::HTTP_NO_CONTENT);
        } catch (\Exception $e) {
            return FOSView::create($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
        }
    }

public
function
getAction
(
int
$
id
)
{
try
{
$
em
=
$
this
->
getDoctrine
(
)
->
getManager
(
)
;
$
entity
=
$
em
->
getRepository
(
$
this
->
entityClassName
(
)
)
->
find
(
$
id
)
;
if
(
$
entity
)
{
return
$
entity
;
}
return
FOSView
::
create
(
'Not Found'
,
Response
::
HTTP_NO_CONTENT
)
;
}
catch
(
\
Exception
$
e
)
{
return
FOSView
::
create
(
$
e
->
getMessage
(
)
,
Response
::
HTTP_INTERNAL_SERVER_ERROR
)
;
}
}

Get a Product entity

@ApiDoc

@View(serializerEnableMaxDepthChecks=true)

@param int $id

@return FOSView|object


public function cgetAction(ParamFetcherInterface $paramFetcher)
    {
        try {
            $offset = $paramFetcher->get('offset');
            $limit = $paramFetcher->get('limit');
            $order_by = $paramFetcher->get('order_by');
            $filters = !is_null($paramFetcher->get('filters')) ? $paramFetcher->get('filters') : array();

            $em = $this->getDoctrine()->getManager();
            $entities = $em->getRepository($this->entityClassName())
                ->findBy($filters, $order_by, $limit, $offset);

            if ($entities) {
                return $entities;
            }

            return FOSView::create('Not Found', Response::HTTP_NO_CONTENT);
        } catch (\Exception $e) {
            return FOSView::create($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
        }
    }

public
function
cgetAction
(
ParamFetcherInterface
$
paramFetcher
)
{
try
{
$
offset
=
$
paramFetcher
->
get
(
'offset'
)
;
$
limit
=
$
paramFetcher
->
get
(
'limit'
)
;
$
order_by
=
$
paramFetcher
->
get
(
'order_by'
)
;
$
filters
=
!
is_null
(
$
paramFetcher
->
get
(
'filters'
)
)
$
paramFetcher
->
get
(
'filters'
)
:
array
(
)
;
$
em
=
$
this
->
getDoctrine
(
)
->
getManager
(
)
;
$
entities
=
$
em
->
getRepository
(
$
this
->
entityClassName
(
)
)
->
findBy
(
$
filters
,
$
order_by
,
$
limit
,
$
offset
)
;
if
(
$
entities
)
{
return
$
entities
;
}
return
FOSView
::
create
(
'Not Found'
,
Response
::
HTTP_NO_CONTENT
)
;
}
catch
(
\
Exception
$
e
)
{
return
FOSView
::
create
(
$
e
->
getMessage
(
)
,
Response
::
HTTP_INTERNAL_SERVER_ERROR
)
;
}
}

Get all Product entities.

@ApiDoc

@View(serializerEnableMaxDepthChecks=true)

@param ParamFetcherInterface $paramFetcher

@return array|FOSView

@QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing notes.")
@QueryParam(name="limit", requirements="\d+", default="20", description="How many notes to return.")
@QueryParam(name="order_by", nullable=true, map=true, description="Order by fields. Must be an array ie. &order_by[name]=ASC&order_by[description]=DESC")
@QueryParam(name="filters", nullable=true, map=true, description="Filter by fields. Must be an array ie. &filters[id]=3")


public function postAction(Request $request)
    {
        /**
         * @var $em ApiEntityManager
         */
        $em = $this->getDoctrine()->getManager();

        $data = json_decode($request->getContent(), true);
        $entity = $em->createEntity($this->entityClassName());

        $form = $this->createForm($this->formClassName(), $entity, [
            "method" => $request->getMethod(),
        ]);

        $form->submit($data);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();

            return $entity;
        }

        return FOSView::create([
            'errors' => $form->getErrors()
        ], Response::HTTP_INTERNAL_SERVER_ERROR);
    }

/**
         * @var $em ApiEntityManager
         */

Create a Product entity.

@ApiDoc

@View(statusCode=201, serializerEnableMaxDepthChecks=true)

@param Request $request

@return object


public function putAction(Request $request, int $id)
    {
        try {
            $em = $this->getDoctrine()->getManager();

            $entity = $em->getRepository($this->entityClassName())->find($id);

            $data = json_decode($request->getContent(), true);

            $request->setMethod('PATCH'); //Treat all PUTs as PATCH
            $form = $this->createForm($this->formClassName(), $entity, [
                "method" => $request->getMethod(),
            ]);

            $form->submit($data);

            if ($form->isValid()) {
                $em->flush();

                return $entity;
            }

            return FOSView::create(array('errors' => $form->getErrors()), Response::HTTP_INTERNAL_SERVER_ERROR);
        } catch (\Exception $e) {
            return FOSView::create($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
        }
    }

public
function
putAction
(
Request
$
request
,
int
$
id
)
{
try
{
$
em
=
$
this
->
getDoctrine
(
)
->
getManager
(
)
;
$
entity
=
$
em
->
getRepository
(
$
this
->
entityClassName
(
)
)
->
find
(
$
id
)
;
$
data
=
json_decode
(
$
request
->
getContent
(
)
,
true
)
;
$
request
->
setMethod
(
'PATCH'
)
;
//Treat all PUTs as PATCH
$
form
=
$
this
->
createForm
(
$
this
->
formClassName
(
)
,
$
entity
,
[
"method"
=>
$
request
->
getMethod
(
)
,
]
)
;
$
form
->
submit
(
$
data
)
;
if
(
$
form
->
isValid
(
)
)
{
$
em
->
flush
(
)
;
return
$
entity
;
}
return
FOSView
::
create
(
array
(
'errors'
=>
$
form
->
getErrors
(
)
)
,
Response
::
HTTP_INTERNAL_SERVER_ERROR
)
;
}
catch
(
\
Exception
$
e
)
{
return
FOSView
::
create
(
$
e
->
getMessage
(
)
,
Response
::
HTTP_INTERNAL_SERVER_ERROR
)
;
}
}

Update a Product entity.

@ApiDoc

@View(serializerEnableMaxDepthChecks=true)

@param Request $request
@param int $id

@return object


public function deleteAction(Request $request, int $id)
    {
        try {
            $em = $this->getDoctrine()->getManager();

            $entity = $em->getRepository($this->entityClassName())->find($id);
            $em->remove($entity);
            $em->flush();

            return null;
        } catch (\Exception $e) {
            return FOSView::create($e->getMessage(), Response::HTTP_INTERNAL_SERVER_ERROR);
        }
    }

public function deleteAction ( Request $ request , int $ id ) { try { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ em -> getRepository ( $ this -> entityClassName ( ) ) -> find ( $ id ) ; $ em -> remove ( $ entity ) ; $ em -> flush ( ) ; return null ; } catch ( \ Exception $ e ) { return FOSView :: create ( $ e -> getMessage ( ) , Response :: HTTP_INTERNAL_SERVER_ERROR ) ; } }

Delete a Product entity.

@ApiDoc

@View(statusCode=204)

@param Request $request
@param int $id

@return null|FOSView


protected static function readFile($path)
    {
        // Workaround for https://github.com/kherge-php/file-manager/pull/2
        $error = null;
        set_error_handler(function ($severity, $message, $filename, $lineno) use (&$error) {
            $error = new \ErrorException($message, 0, $severity, $filename, $lineno);
        }, E_WARNING);

        try {
            $file = new File($path, 'r');
        } finally {
            restore_error_handler();
        }

        if ($error) {
            // @codeCoverageIgnoreStart
            throw new ResourceException(
                "The file \"$path\" could not be opened.",
                $error
            );
            // @codeCoverageIgnoreEnd
        }

        return $file->read();
    }

Reads entire file into a string.

@param string $path the file path

@return string the read data

@throws ResourceException


protected static function parse($json, $assoc = false)
    {
        $falgs = JsonParser::DETECT_KEY_CONFLICTS;

        if ($assoc) {
            $falgs |= JsonParser::PARSE_TO_ASSOC;
        }

        $parser = new JsonParser();

        return $parser->parse($json, $falgs);
    }

protected static function parse ( $ json , $ assoc = false ) { $ falgs = JsonParser :: DETECT_KEY_CONFLICTS ; if ( $ assoc ) { $ falgs |= JsonParser :: PARSE_TO_ASSOC ; } $ parser = new JsonParser ( ) ; return $ parser -> parse ( $ json , $ falgs ) ; }

Converts JSON encoded string into a PHP variable.

@param string $json  JSON string
@param bool   $assoc returned objects will be converted into associative arrays

@return mixed the value encoded in json in appropriate PHP type

@throws ParsingException

@SuppressWarnings(PHPMD.BooleanArgumentFlag)

Converts JSON encoded string into a PHP variable .


public static function call($path, $assoc = false)
    {
        return self::parse(BomUtil::removeBom(self::readFile($path)), $assoc);
    }

public static function call ( $ path , $ assoc = false ) { return self :: parse ( BomUtil :: removeBom ( self :: readFile ( $ path ) ) , $ assoc ) ; }

Read and decode a JSON file.

@see http://php.net/manual/en/function.json-decode.php json_decode documentation

@param string $path  the file path
@param bool   $assoc returned objects will be converted into associative arrays

@return mixed the value encoded in json in appropriate PHP type

@throws ResourceException
@throws ParsingException

@SuppressWarnings(PHPMD.BooleanArgumentFlag)
@SuppressWarnings(PHPMD.StaticAccess)


protected function normalizeId(string $value): string
    {
        if (strstr($value, '[')) {
            if ('[]' == substr($value, -2)) {
                $value = substr($value, 0, strlen($value) - 2);
            }
            $value = trim($value, ']');
            $value = str_replace('][', '-', $value);
            $value = str_replace('[', '-', $value);
        }
        return $value;
    }

protected function normalizeId ( string $ value ) : string { if ( strstr ( $ value , '[' ) ) { if ( '[]' == substr ( $ value , - 2 ) ) { $ value = substr ( $ value , 0 , strlen ( $ value ) - 2 ) ; } $ value = trim ( $ value , ']' ) ; $ value = str_replace ( '][' , '-' , $ value ) ; $ value = str_replace ( '[' , '-' , $ value ) ; } return $ value ; }

Normalize an ID

@param  string $value
@return string


protected function cleanAttributes(array $input, array $valid): array
    {
        foreach ($input as $key => $value) {
            if (preg_match('/^data-(.+)/', $key) || in_array($key, $valid)) {
                continue;
            }
            unset($input[$key]);
        }
        return $input;
    }

protected function cleanAttributes ( array $ input , array $ valid ) : array { foreach ( $ input as $ key => $ value ) { if ( preg_match ( '/^data-(.+)/' , $ key ) || in_array ( $ key , $ valid ) ) { continue ; } unset ( $ input [ $ key ] ) ; } return $ input ; }

Cleans array of attributes based on valid input.

@param array $input
@param array $valid
@return array

Cleans array of attributes based on valid input .


public function setValue($value)
    {
        if ($this->element) {
            $this->element->SetLabel($value);
        }

        $this->value = $value;
    }

public function setValue ( $ value ) { if ( $ this -> element ) { $ this -> element -> SetLabel ( $ value ) ; } $ this -> value = $ value ; }

Set the label value

@param string $value


public function add(ElementInterface $element)
    {
        $id = $element->id;

        if ($id === null) $id = $this->generateId();

        $element->id = $id;

        $this->checkId($id);

        $this->objects[] = $element;

        if (count($this->objects) === 1) {
            array_unshift($this->objects, 'pseudo');
            unset($this->objects[0]);
        }

        $this->ids[array_search($element, $this->objects, true)] = $id;
    }

public function add ( ElementInterface $ element ) { $ id = $ element -> id ; if ( $ id === null ) $ id = $ this -> generateId ( ) ; $ element -> id = $ id ; $ this -> checkId ( $ id ) ; $ this -> objects [ ] = $ element ; if ( count ( $ this -> objects ) === 1 ) { array_unshift ( $ this -> objects , 'pseudo' ) ; unset ( $ this -> objects [ 0 ] ) ; } $ this -> ids [ array_search ( $ element , $ this -> objects , true ) ] = $ id ; }

Add an element to the collection

@param ElementInterface $element


public function getTopLevelWindow()
    {
        foreach ($this->objects as $object) {
            if ($object instanceof Frame
            or $object instanceof Dialog) {
                return $object;
            }
        }
    }

public function getTopLevelWindow ( ) { foreach ( $ this -> objects as $ object ) { if ( $ object instanceof Frame or $ object instanceof Dialog ) { return $ object ; } } }

Get the top-level window element

@return ElementInterface


public function remove($element)
    {
        $trueId = $this->getTrueId($element);

        $this->objects[$trueId]->destroy();

        unset($this->objects[$trueId]);
        unset($this->ids[$trueId]);
    }

public function remove ( $ element ) { $ trueId = $ this -> getTrueId ( $ element ) ; $ this -> objects [ $ trueId ] -> destroy ( ) ; unset ( $ this -> objects [ $ trueId ] ) ; unset ( $ this -> ids [ $ trueId ] ) ; }

Remove the element from the collection

@return void


public function getElementById($id)
    {
        $id = $this->getTrueId($id);

        if ($id === false) {
            // Throw something
            return;
        }

        return $this->objects[$id];
    }

public
function
getElementById
(
$
id
)
{
$
id
=
$
this
->
getTrueId
(
$
id
)
;
if
(
$
id
===
false
)
{
// Throw something
return
;
}
return
$
this
->
objects
[
$
id
]
;
}

Get an element by its ID

@param  string|int $id
@return ElementInterface


public function loadState($statePath)
    {
        $filename = Yii::getAlias($statePath . $this->stateFilename() . '.php');
        if (is_readable($filename) === true) {
            $this->loadAttributesFromState(
                include($filename)
            );
            return true;
        } else {
            return false;
        }
    }

public function loadState ( $ statePath ) { $ filename = Yii :: getAlias ( $ statePath . $ this -> stateFilename ( ) . '.php' ) ; if ( is_readable ( $ filename ) === true ) { $ this -> loadAttributesFromState ( include ( $ filename ) ) ; return true ; } else { return false ; } }

Loads state from file
@param string $statePath Path where model state files are stored.
@return bool result


public function saveState($statePath)
    {
        $filename = Yii::getAlias($statePath . $this->stateFilename() . '.php');
        $writer = new ApplicationConfigWriter([
            'filename' => $filename,
        ]);
        $writer->configuration = $this->getAttributesForStateSaving();
        $result =  $writer->commit();
        return $result;
    }

public function saveState ( $ statePath ) { $ filename = Yii :: getAlias ( $ statePath . $ this -> stateFilename ( ) . '.php' ) ; $ writer = new ApplicationConfigWriter ( [ 'filename' => $ filename , ] ) ; $ writer -> configuration = $ this -> getAttributesForStateSaving ( ) ; $ result = $ writer -> commit ( ) ; return $ result ; }

Saves state to file
@param string $statePath Path where model state files are stored.
@return bool


public function setDataType($type)
    {
        $types = array('integer', 'string', 'string');

        $shorthand = array('int', 'varchar', 'text');

        $index = array_search($type, $shorthand);

        $this->type = $index === false ? $type : $types[$index];

        return $this;
    }

public function setDataType ( $ type ) { $ types = array ( 'integer' , 'string' , 'string' ) ; $ shorthand = array ( 'int' , 'varchar' , 'text' ) ; $ index = array_search ( $ type , $ shorthand ) ; $ this -> type = $ index === false ? $ type : $ types [ $ index ] ; return $ this ; }

Sets the data type.

@param  string $type
@return self


function onChannelCreated($command)
	{
		$channelId = $command->getResult();
		$channel = $this->server->request('channelinfo cid='.$channelId)->toList();
		$channel['cid'] = $channelId;
		new Channel($channel, $this->getChannelPermissionList($channel));
	}

function
onChannelCreated
(
$
command
)
{
$
channelId
=
$
command
->
getResult
(
)
;
$
channel
=
$
this
->
server
->
request
(
'channelinfo cid='
.
$
channelId
)
->
toList
(
)
;
$
channel
[
'cid'
]
=
$
channelId
;
new
Channel
(
$
channel
,
$
this
->
getChannelPermissionList
(
$
channel
)
)
;
}

and no event is launched when needed join power is modified...

and no event is launched when needed join power is modified ...


public static function getLocalizedVersionedDataField($data, $type, $field)
    {
        $string = '';
        $langId = Yii::$app->language;
        if (false === empty($data['package']['versions'][self::$currentVersion]['extra'][$type][$field . '_' . $langId])) {
            $string = $data['package']['versions'][self::$currentVersion]['extra'][$type][$field . '_' . $langId];
        } elseif (false === empty($data['package']['versions'][self::$currentVersion]['extra'][$type][$field])) {
            $string = $data['package']['versions'][self::$currentVersion]['extra'][$type][$field];
        } elseif (false === empty($data['package']['versions'][self::$currentVersion][$field])) {
            $string = $data['package']['versions'][self::$currentVersion][$field];
        } elseif (false === empty($data['package'][$field])) {
            $string = $data['package'][$field];
        }
        return $string;
    }

public static function getLocalizedVersionedDataField ( $ data , $ type , $ field ) { $ string = '' ; $ langId = Yii :: $ app -> language ; if ( false === empty ( $ data [ 'package' ] [ 'versions' ] [ self :: $ currentVersion ] [ 'extra' ] [ $ type ] [ $ field . '_' . $ langId ] ) ) { $ string = $ data [ 'package' ] [ 'versions' ] [ self :: $ currentVersion ] [ 'extra' ] [ $ type ] [ $ field . '_' . $ langId ] ; } elseif ( false === empty ( $ data [ 'package' ] [ 'versions' ] [ self :: $ currentVersion ] [ 'extra' ] [ $ type ] [ $ field ] ) ) { $ string = $ data [ 'package' ] [ 'versions' ] [ self :: $ currentVersion ] [ 'extra' ] [ $ type ] [ $ field ] ; } elseif ( false === empty ( $ data [ 'package' ] [ 'versions' ] [ self :: $ currentVersion ] [ $ field ] ) ) { $ string = $ data [ 'package' ] [ 'versions' ] [ self :: $ currentVersion ] [ $ field ] ; } elseif ( false === empty ( $ data [ 'package' ] [ $ field ] ) ) { $ string = $ data [ 'package' ] [ $ field ] ; } return $ string ; }

Fetching localized data from defined field according to package current version
@param $data
@param $type
@param string $field
@return string


public static function getLocalizedDataField($data, $type, $field)
    {
        $string = '';
        $langId = Yii::$app->language;
        if (false === empty($data['extra'][$type][$field . '_' . $langId])) {
            $string = $data['extra'][$type][$field . '_' . $langId];
        } elseif (false === empty($data['extra'][$type][$field])) {
            $string = $data['extra'][$type][$field];
        } elseif (false === empty($data[$field])) {
            $string = $data[$field];
        }
        return $string;
    }

public static function getLocalizedDataField ( $ data , $ type , $ field ) { $ string = '' ; $ langId = Yii :: $ app -> language ; if ( false === empty ( $ data [ 'extra' ] [ $ type ] [ $ field . '_' . $ langId ] ) ) { $ string = $ data [ 'extra' ] [ $ type ] [ $ field . '_' . $ langId ] ; } elseif ( false === empty ( $ data [ 'extra' ] [ $ type ] [ $ field ] ) ) { $ string = $ data [ 'extra' ] [ $ type ] [ $ field ] ; } elseif ( false === empty ( $ data [ $ field ] ) ) { $ string = $ data [ $ field ] ; } return $ string ; }

Fetching localized data from defined field from for example installed.json file
data who has no 'versions' array inside
@param $data
@param $type
@param string $field
@return string

Fetching localized data from defined field from for example installed . json file data who has no versions array inside


public static function getOtherPackageVersionedData($data, $key, $asArray = true)
    {
        $out = [];
        if (false === empty($data['package']['versions'][self::$currentVersion][$key])) {
            $out = $data['package']['versions'][self::$currentVersion][$key];
        }
        if (true === $asArray) {
            $out = is_array($out) ? $out : [$out];
        } else {
            $out = is_array($out) ? implode(', ', $out) : $out;
        }
        return $out;
    }

public
static
function
getOtherPackageVersionedData
(
$
data
,
$
key
,
$
asArray
=
true
)
{
$
out
=
[
]
;
if
(
false
===
empty
(
$
data
[
'package'
]
[
'versions'
]
[
self
::
$
currentVersion
]
[
$
key
]
)
)
{
$
out
=
$
data
[
'package'
]
[
'versions'
]
[
self
::
$
currentVersion
]
[
$
key
]
;
}
if
(
true
===
$
asArray
)
{
$
out
=
is_array
(
$
out
)
$
out
:
[
$
out
]
;
}
else
{
$
out
=
is_array
(
$
out
)
implode
(
', '
,
$
out
)
:
$
out
;
}
return
$
out
;
}

Fetching data from defined field according to package current version
@param $data
@param $key
@param bool $asArray
@return array


public static function getOtherPackageData($data, $key, $asArray = false)
    {
        $out = null;
        if (false === empty($data[$key])) {
            $out = $data[$key];
        }
        if (true === $asArray) {
            $out = is_array($out) ? $out : [$out];
        } else {
            $out = is_array($out) ? implode(', ', $out) : $out;
        }
        return $out;
    }

public
static
function
getOtherPackageData
(
$
data
,
$
key
,
$
asArray
=
false
)
{
$
out
=
;
if
(
false
===
empty
(
$
data
[
$
key
]
)
)
{
$
out
=
$
data
[
$
key
]
;
}
if
(
true
===
$
asArray
)
{
$
out
=
is_array
(
$
out
)
$
out
:
[
$
out
]
;
}
else
{
$
out
=
is_array
(
$
out
)
implode
(
', '
,
$
out
)
:
$
out
;
}
return
$
out
;
}

Fetching data from defined field from for example installed.json file
data who has no 'versions' array inside
@param $data
@param $key
@param bool $asArray
@return array | string

Fetching data from defined field from for example installed . json file data who has no versions array inside


public static function humanizeReadme($data)
    {
        $readme = '';
        $data = Json::decode($data);
        if (false === empty($data['content'])) {
            $content = base64_decode(str_replace('\n', '', $data['content']));
            $parser = new GithubMarkdown();
            $readme = $parser->parse($content);
        }
        return $readme;
    }

public static function humanizeReadme ( $ data ) { $ readme = '' ; $ data = Json :: decode ( $ data ) ; if ( false === empty ( $ data [ 'content' ] ) ) { $ content = base64_decode ( str_replace ( '\n' , '' , $ data [ 'content' ] ) ) ; $ parser = new GithubMarkdown ( ) ; $ readme = $ parser -> parse ( $ content ) ; } return $ readme ; }

Humanizes github Readme.md file content
We adopt github retrieves Readme.md as json string where "content" field contains base64 encoded markdown
@param $data
@return string

Humanizes github Readme . md file content We adopt github retrieves Readme . md as json string where content field contains base64 encoded markdown


public static function prepareMigrationTask(
        array $ext,
        ReportingChain $chain,
        $way = ExtensionsManager::MIGRATE_TYPE_UP,
        $group
    ) {

        if ($ext['composer_type'] == Extension::TYPE_DOTPLANT) {
            $extData = ComposerInstalledSet::get()->getInstalled($ext['composer_name']);
            $packageMigrations = ExtensionDataHelper::getInstalledExtraData($extData, 'migrationPath', true);
            $packagePath = '@vendor' . '/' . $ext['composer_name'] . '/';
            foreach ($packageMigrations as $migrationPath) {
                $migrateTask = self::buildTask(
                    [
                        realpath(Yii::getAlias('@app') . '/yii'),
                        'migrate/' . $way,
                        '--migrationPath=' . $packagePath . $migrationPath,
                        '--color=0',
                        '--interactive=0',
                        '--disableLookup=true',
                        (ExtensionsManager::MIGRATE_TYPE_DOWN == $way ? 68888 : ''),
                    ],
                    $group
                );
                $chain->addTask($migrateTask);
            }
        }
    }

public static function prepareMigrationTask ( array $ ext , ReportingChain $ chain , $ way = ExtensionsManager :: MIGRATE_TYPE_UP , $ group ) { if ( $ ext [ 'composer_type' ] == Extension :: TYPE_DOTPLANT ) { $ extData = ComposerInstalledSet :: get ( ) -> getInstalled ( $ ext [ 'composer_name' ] ) ; $ packageMigrations = ExtensionDataHelper :: getInstalledExtraData ( $ extData , 'migrationPath' , true ) ; $ packagePath = '@vendor' . '/' . $ ext [ 'composer_name' ] . '/' ; foreach ( $ packageMigrations as $ migrationPath ) { $ migrateTask = self :: buildTask ( [ realpath ( Yii :: getAlias ( '@app' ) . '/yii' ) , 'migrate/' . $ way , '--migrationPath=' . $ packagePath . $ migrationPath , '--color=0' , '--interactive=0' , '--disableLookup=true' , ( ExtensionsManager :: MIGRATE_TYPE_DOWN == $ way ? 68888 : '' ) , ] , $ group ) ; $ chain -> addTask ( $ migrateTask ) ; } } }

Prepares migration command

@param array $ext
@param ReportingChain $chain
@param string $way
@param $group


public static function buildTask($command, $groupName)
    {
        $groupConfig = [
            'email_notification' => 0,
            'allow_parallel_run' => 0,
            'group_notifications' => 0,
            'run_last_command_only' => 0,
        ];
        if (null === $group = DeferredGroup::findOne(['name' => $groupName])) {
            $group = new DeferredGroup();
            $group->loadDefaultValues();
            $group->setAttributes($groupConfig);
            $group->name = $groupName;
            $group->save();
        }
        if ((int)$group->group_notifications !== 0) {
            // otherwise DeferredController 'deferred-queue-complete' event will not trigger
            // and we'll unable to write config
            $group->setAttributes($groupConfig);
            $group->save(array_keys($groupConfig));
        }
        $task = new ReportingTask();
        $task->model()->deferred_group_id = $group->id;
        $task->cliCommand(DeferredHelper::getPhpBinary(), $command);
        return $task;
    }

Builds ReportingTask and places it into certain group. Also if group is not exists yet, it will be created
with necessary parameters, such as group_notifications=0.

@param array $command
@param string $groupName
@return ReportingTask

Builds ReportingTask and places it into certain group . Also if group is not exists yet it will be created with necessary parameters such as group_notifications = 0 .


public function match(array $server = [], array $post)
    {
        $requestMethod = $server['REQUEST_METHOD'];
        $requestUri = $server['REQUEST_URI'];

        $restMethod = $this->getRestfullMethod($post);

        // check if REST request is made
        if (null === $restMethod && !in_array($requestMethod, array_keys($this->routes))) {
            return false;
        }

        $method = $restMethod ?: $requestMethod;

        foreach ($this->routes[$method]  as $resource) {
            $args = [];
            $route = key($resource);
            $handler = reset($resource);

            if (preg_match(self::REGVAL, $route)) {
                list($args, , $route) = $this->parseRegexRoute($requestUri, $route);
            }

            if (!preg_match("#^$route$#", $requestUri)) {
                unset($this->routes[$method]);
                continue;
            }

            if (is_string($handler) && strpos($handler, '@')) {
                list($ctrl, $method) = explode('@', $handler);

                return ['controller' => $ctrl, 'method' => $method, 'args' => $args];
            }

            if (empty($args)) {
                return $handler();
            }

            return call_user_func_array($handler, $args);
        }
    }

public
function
match
(
array
$
server
=
[
]
,
array
$
post
)
{
$
requestMethod
=
$
server
[
'REQUEST_METHOD'
]
;
$
requestUri
=
$
server
[
'REQUEST_URI'
]
;
$
restMethod
=
$
this
->
getRestfullMethod
(
$
post
)
;
// check if REST request is made
if
(
===
$
restMethod
&&
!
in_array
(
$
requestMethod
,
array_keys
(
$
this
->
routes
)
)
)
{
return
false
;
}
$
method
=
$
restMethod
:
$
requestMethod
;
foreach
(
$
this
->
routes
[
$
method
]
as
$
resource
)
{
$
args
=
[
]
;
$
route
=
key
(
$
resource
)
;
$
handler
=
reset
(
$
resource
)
;
if
(
preg_match
(
self
::
REGVAL
,
$
route
)
)
{
list
(
$
args
,
,
$
route
)
=
$
this
->
parseRegexRoute
(
$
requestUri
,
$
route
)
;
}
if
(
!
preg_match
(
"#^$route$#"
,
$
requestUri
)
)
{
unset
(
$
this
->
routes
[
$
method
]
)
;
continue
;
}
if
(
is_string
(
$
handler
)
&&
strpos
(
$
handler
,
'@'
)
)
{
list
(
$
ctrl
,
$
method
)
=
explode
(
'@'
,
$
handler
)
;
return
[
'controller'
=>
$
ctrl
,
'method'
=>
$
method
,
'args'
=>
$
args
]
;
}
if
(
empty
(
$
args
)
)
{
return
$
handler
(
)
;
}
return
call_user_func_array
(
$
handler
,
$
args
)
;
}
}

Match if URL matches a route definition.

@param array $server
@param array $post

Match if URL matches a route definition .


protected function parseRegexRoute($requestUri, $resource)
    {
        $route = preg_replace_callback(self::REGVAL, function ($matches) {
            $patterns = $this->patterns;
            $matches[0] = str_replace(['{', '}'], '', $matches[0]);
            if (in_array($matches[0], array_keys($patterns))) {
                return  $patterns[$matches[0]];
            }
        }, $resource);

        $regUri = explode('/', $resource);
        $args = array_diff(
              array_replace(
                  $regUri,
              explode('/', $requestUri)
            ),
            $regUri
          );

        return [array_values($args), $resource, $route];
    }

protected function parseRegexRoute ( $ requestUri , $ resource ) { $ route = preg_replace_callback ( self :: REGVAL , function ( $ matches ) { $ patterns = $ this -> patterns ; $ matches [ 0 ] = str_replace ( [ '{' , '}' ] , '' , $ matches [ 0 ] ) ; if ( in_array ( $ matches [ 0 ] , array_keys ( $ patterns ) ) ) { return $ patterns [ $ matches [ 0 ] ] ; } } , $ resource ) ; $ regUri = explode ( '/' , $ resource ) ; $ args = array_diff ( array_replace ( $ regUri , explode ( '/' , $ requestUri ) ) , $ regUri ) ; return [ array_values ( $ args ) , $ resource , $ route ] ; }

Regex parser for named routes.

@param [type] $requestUri
@param [type] $resource


protected function checkStrictness(ContainerResult $container, $object): void
    {
        $properties = $this->getProperties();
        foreach ($object as $property => $value) {
            if (array_key_exists($property, $properties) === false) {
                $container->addResult(
                    $this->getInvalidResult(self::PROPERTY_NOT_ALLOWED, [
                        'property' => $property,
                    ]),
                    $property
                );
            }
        }
    }

protected function checkStrictness ( ContainerResult $ container , $ object ) : void { $ properties = $ this -> getProperties ( ) ; foreach ( $ object as $ property => $ value ) { if ( array_key_exists ( $ property , $ properties ) === false ) { $ container -> addResult ( $ this -> getInvalidResult ( self :: PROPERTY_NOT_ALLOWED , [ 'property' => $ property , ] ) , $ property ) ; } } }

Check strictness.

If in strict mode, check if there more than the allowed properties.

@param ContainerResult $container
@param mixed           $object
@return void
@throws TemplateNotFound


public function getProfiler()
  {
    return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Profiler::get(spl_object_hash($this));
  }

public function getProfiler ( ) { return \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Profiler :: get ( spl_object_hash ( $ this ) ) ; }

Returns the profiler timer used for this connection adapter.

@return TeamSpeak3_Helper_Profiler_Timer

Returns the profiler timer used for this connection adapter .


protected function initTransport($options, $transport = '\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Transport\TCP')
  {
    if(!is_array($options))
    {
      throw new Exception("transport parameters must provided in an array");
    }

    $this->transport = new $transport($options);
  }

Loads the transport object object used for the connection adapter and passes a given set
of options.

@param  array  $options
@param  string $transport
@throws Exception
@return void

Loads the transport object object used for the connection adapter and passes a given set of options .


protected function getBlameableAttributes()
    {
        return [
            ActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute],
            ActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute,
        ];
    }

protected function getBlameableAttributes ( ) { return [ ActiveRecord :: EVENT_BEFORE_INSERT => [ $ this -> createdByAttribute , $ this -> updatedByAttribute ] , ActiveRecord :: EVENT_BEFORE_UPDATE => $ this -> updatedByAttribute , ] ; }

Get default attributes for Blameable behavior.
If you need to set a custom attributes, just add a `blameableAttributes` field to your model.
@return array

Get default attributes for Blameable behavior . If you need to set a custom attributes just add a blameableAttributes field to your model .


protected function getTimestampAttributes()
    {
        return [
            ActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute, $this->updatedAtAttribute],
            ActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedAtAttribute,
        ];
    }

protected function getTimestampAttributes ( ) { return [ ActiveRecord :: EVENT_BEFORE_INSERT => [ $ this -> createdAtAttribute , $ this -> updatedAtAttribute ] , ActiveRecord :: EVENT_BEFORE_UPDATE => $ this -> updatedAtAttribute , ] ; }

Get default attributes for Timestamp behavior.
If you need to set a custom attributes, just add a `timestampAttributes` field to your model.
@return array

Get default attributes for Timestamp behavior . If you need to set a custom attributes just add a timestampAttributes field to your model .


public function evaluateAttributesInternal($event)
    {
        if (empty($event->data['attributes']) === false) {
            $methodName = $event->data['methodName'];
            $value = $this->$methodName($event);
            foreach ((array) $event->data['attributes'] as $attribute) {
                if (is_string($attribute)) {
                    $this->$attribute = $value;
                }
            }
        }
    }

public function evaluateAttributesInternal ( $ event ) { if ( empty ( $ event -> data [ 'attributes' ] ) === false ) { $ methodName = $ event -> data [ 'methodName' ] ; $ value = $ this -> $ methodName ( $ event ) ; foreach ( ( array ) $ event -> data [ 'attributes' ] as $ attribute ) { if ( is_string ( $ attribute ) ) { $ this -> $ attribute = $ value ; } } } }

Evaluates the attribute value and assigns it to the current attributes.
@param Event $event

Evaluates the attribute value and assigns it to the current attributes .


public function BaseActionsInfoTraitInit()
    {
        /** @var ActiveRecord|self $this */
        foreach ($this->blameableAttributes as $eventName => $attributes) {
            $this->on(
                $eventName,
                [$this, 'evaluateAttributesInternal'],
                [
                    'attributes' => $attributes,
                    'methodName' => 'getBlameableValue',
                ]
            );
        }
        foreach ($this->timestampAttributes as $eventName => $attributes) {
            $this->on(
                $eventName,
                [$this, 'evaluateAttributesInternal'],
                [
                    'attributes' => $attributes,
                    'methodName' => 'getTimestampValue',
                ]
            );
        }
    }

public
function
BaseActionsInfoTraitInit
(
)
{
/** @var ActiveRecord|self $this */
foreach
(
$
this
->
blameableAttributes
as
$
eventName
=>
$
attributes
)
{
$
this
->
on
(
$
eventName
,
[
$
this
,
'evaluateAttributesInternal'
]
,
[
'attributes'
=>
$
attributes
,
'methodName'
=>
'getBlameableValue'
,
]
)
;
}
foreach
(
$
this
->
timestampAttributes
as
$
eventName
=>
$
attributes
)
{
$
this
->
on
(
$
eventName
,
[
$
this
,
'evaluateAttributesInternal'
]
,
[
'attributes'
=>
$
attributes
,
'methodName'
=>
'getTimestampValue'
,
]
)
;
}
}

Init a trait.
There is an event attaching here.

Init a trait . There is an event attaching here .


public function before_request( &$url, &$headers, &$data )
	{
		// generate a date string
		$date            = new \DateTime('NOW', new \DateTimeZone("GMT"));
		$headers['Date'] = $date->format("D, d M Y H:i:s \G\M\T");

		// build up the data to be signed
		$request_data = $headers['Date']."\n".$url."\n";
		if( !empty($data) )
		{
			$request_data .= http_build_query($data);
		}

		// get a signature for our request

		// private key is in hex form, needs to be converted into PrivateKey Object
		$generator   = EccFactory::getNistCurves()->generator256();
		$private_key = new PrivateKey($this->math_adapter, $generator, $this->math_adapter->hexDec($this->private_key));

		$hash         = $this->math_adapter->hexDec(hash("sha256", $request_data));
		$signer       = EccFactory::getSigner();
		$randomK      = RandomGeneratorFactory::getRandomGenerator()->generate($private_key->getPoint()->getOrder());
		$signatureObj = $signer->sign($private_key, $hash, $randomK);
		$signature    = $this->math_adapter->decHex($signatureObj->getR()).$this->math_adapter->decHex($signatureObj->getS());

		// apply the HTTP headers and send the request
		$headers['X-Service']   = $this->service_name;
		$headers['X-Signature'] = $signature;

		if( $this->debug )
		{
			echo "\n\nRequest Data\n\n";

			echo "URL:\n";
			var_dump($url);

			echo "HEADERS:\n";
			var_dump($headers);

			echo "DATA:\n";
			var_dump($data);
		}
	}

before_request
Hook for PHP Requests

@param $url
@param $headers
@param $data


public function after_request( \Requests_Response &$return )
	{
		$headers   = $return->headers;
		$url       = $return->url;
		$data      = $return->body;
		$signature = $headers['x-signature'];

		if( $this->debug )
		{
			echo "\n\nResponse Data:\n";
			var_dump($return);
		}

		// Check if signature header exists, if not the request failed
		if( !isset($headers['x-signature']) or $headers['x-signature'] == '' )
		{
			throw new \Exception('Request Failed');
		}

		// build up the data to be signed
		$request_data = $this->service_name."\n".$headers['date']."\n".$url."\n";
		if( !empty($data) )
		{
			$request_data .= trim($data);
		}

		// try and validate the signature

		// ------------------------------------
		$generator = EccFactory::getNistCurves()->generator256();

		$order_len  = strlen($this->math_adapter->decHex($generator->getOrder()));
		$x          = $this->math_adapter->hexDec(substr($this->public_key, 0, $order_len));
		$y          = $this->math_adapter->hexDec(substr($this->public_key, $order_len));
		$point      = new Point($this->math_adapter, EccFactory::getNistCurves()->curve256(), $x, $y, $generator->getOrder());
		$public_key = new PublicKey($this->math_adapter, $generator, $point);

		$r         = $this->math_adapter->hexDec(substr($signature, 0, $order_len));
		$s         = $this->math_adapter->hexDec(substr($signature, $order_len));
		$signature = new Signature($r, $s);

		$signer     = EccFactory::getSigner();
		$check_hash = $this->math_adapter->hexDec(hash("sha256", $request_data));
		$result     = $signer->verify($public_key, $signature, $check_hash);
		// ------------------------------------

		//$result = \ECDSA::validate($request_data, $signature, $this->public_key);

		// if signature validation failed, throw exception
		if( $result !== TRUE )
		{
			throw new \Exception('Signature Does Not Validate!');
		}
	}

after_request
Hook for PHP Requests

@param \Requests_Response $return

@throws


public function read($length = 4096)
  {
    $this->connect();
    $this->waitForReadyRead();

    $data = @fread($this->stream, $length);

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);

    if($data === FALSE)
    {
      throw new Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
    }

    return new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String($data);
  }

public
function
read
(
$
length
=
4096
)
{
$
this
->
connect
(
)
;
$
this
->
waitForReadyRead
(
)
;
$
data
=
@
fread
(
$
this
->
stream
,
$
length
)
;
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
Signal
::
getInstance
(
)
->
emit
(
strtolower
(
$
this
->
getAdapterType
(
)
)
.
"DataRead"
,
$
data
)
;
if
(
$
data
===
FALSE
)
{
throw
new
Exception
(
"connection to server '"
.
$
this
->
config
[
"host"
]
.
":"
.
$
this
->
config
[
"port"
]
.
"' lost"
)
;
}
return
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
String
(
$
data
)
;
}

Reads data from the stream.

@param  integer $length
@throws Exception
@return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String


public function send($data)
  {
    $this->connect();

    @stream_socket_sendto($this->stream, $data);

    \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataSend", $data);
  }

public function send ( $ data ) { $ this -> connect ( ) ; @ stream_socket_sendto ( $ this -> stream , $ data ) ; \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ Signal :: getInstance ( ) -> emit ( strtolower ( $ this -> getAdapterType ( ) ) . "DataSend" , $ data ) ; }

Writes data to the stream.

@param  string $data
@return void


public function actionRestore($fileName = null)
    {
        try {
            $this->stdout(\Yii::t('skeeks/dbDumper', "The installation process is running the database")."\n");
            \Yii::$app->dbDumper->restore($fileName);
            $this->stdout(\Yii::t('skeeks/dbDumper', "Dump successfully installed")."\n", Console::FG_GREEN);
        } catch (\Exception $e) {
            $this->stdout(\Yii::t('skeeks/dbDumper',
                    "In the process of restoring the dump occurred error").": {$e->getMessage()}\n", Console::FG_RED);
        }
    }

Restore from the file dump
@param null $fileName The path to the dump file


public function actionDump()
    {
        try {
            $result = \Yii::$app->dbDumper->dump();
            $this->stdout(\Yii::t('skeeks/dbDumper', "Dump the database was created successfully").": {$result}\n",
                Console::FG_GREEN);
            $removed = \Yii::$app->dbDumper->clear();
            if ($removed > 0) {
                $this->stdout(\Yii::t('skeeks/dbDumper', "Removed old dumps").": {$removed}\n", Console::FG_GREEN);
            }

        } catch (\Exception $e) {
            $this->stdout(\Yii::t('skeeks/dbDumper', "During the dump error occurred").": {$e->getMessage()}\n",
                Console::FG_RED);
        }
    }


function initMenu($icon, $pluginId = null)
	{
		$id = explode('\\', $pluginId);

		$this->menu[$pluginId] = array('name' => end($id), 'icon' => $icon, 'buttons' => array());

		if($this->loaded)
			$this->refreshMenubar();
	}

function initMenu ( $ icon , $ pluginId = null ) { $ id = explode ( '\\' , $ pluginId ) ; $ this -> menu [ $ pluginId ] = array ( 'name' => end ( $ id ) , 'icon' => $ icon , 'buttons' => array ( ) ) ; if ( $ this -> loaded ) $ this -> refreshMenubar ( ) ; }

initializes the menu for a specific plugin


function addButton($name, $callback, $admin = false, $pluginId = null)
	{
		if(!isset($this->menu[$pluginId]))
			$this->initMenu(Icons128x128_1::DefaultIcon, $pluginId);

		$this->menu[$pluginId]['buttons'][] = array('name' => $name, 'callback' => $callback, 'admin' => $admin);

		if($this->loaded)
			$this->refreshMenubar();
	}

function addButton ( $ name , $ callback , $ admin = false , $ pluginId = null ) { if ( ! isset ( $ this -> menu [ $ pluginId ] ) ) $ this -> initMenu ( Icons128x128_1 :: DefaultIcon , $ pluginId ) ; $ this -> menu [ $ pluginId ] [ 'buttons' ] [ ] = array ( 'name' => $ name , 'callback' => $ callback , 'admin' => $ admin ) ; if ( $ this -> loaded ) $ this -> refreshMenubar ( ) ; }


public function fire()
    {
        $handle = popen(PHP_BINDIR.'/pecl install wxwidgets 2>&1', 'r');

        while ( ! feof($handle)) {
            $this->output->write(fread($handle, 2048));
        }
    }

public
function
fire
(
)
{
$
handle
=
popen
(
PHP_BINDIR
.
'/pecl install wxwidgets 2>&1'
,
'r'
)
;
while
(
!
feof
(
$
handle
)
)
{
$
this
->
output
->
write
(
fread
(
$
handle
,
2048
)
)
;
}
}


public function populateColumnsWithLongestValue()
    {
        $query = DB::table($this->name);
        foreach ($this->columns as $column) {
            if ($column->isNumeric()) {
                $query->addSelect(DB::raw('MAX(`' . $column->name . '`) as `' . $column->name . '`'));
            }
            if ($column->isTextual()) {
                $query->addSelect(DB::raw('MAX(LENGTH(`' . $column->name . '`)) as `' . $column->name . '`'));
            }
        }
        $result = $query->first();
        foreach ($this->columns as $column) {
            $columnName = $column->name;
            if (isset($result->$columnName)) {
                $column->setMaxValue($result->$columnName);
            }
        }
    }

public
function
populateColumnsWithLongestValue
(
)
{
$
query
=
DB
::
table
(
$
this
->
name
)
;
foreach
(
$
this
->
columns
as
$
column
)
{
if
(
$
column
->
isNumeric
(
)
)
{
$
query
->
addSelect
(
DB
::
raw
(
'MAX(`'
.
$
column
->
name
.
'`) as `'
.
$
column
->
name
.
'`'
)
)
;
}
if
(
$
column
->
isTextual
(
)
)
{
$
query
->
addSelect
(
DB
::
raw
(
'MAX(LENGTH(`'
.
$
column
->
name
.
'`)) as `'
.
$
column
->
name
.
'`'
)
)
;
}
}
$
result
=
$
query
->
first
(
)
;
foreach
(
$
this
->
columns
as
$
column
)
{
$
columnName
=
$
column
->
name
;
if
(
isset
(
$
result
->
$
columnName
)
)
{
$
column
->
setMaxValue
(
$
result
->
$
columnName
)
;
}
}
}

Go through each column and find the largest value of that field


public function populateNumericColumnsWithLongestValue()
    {
        $query = DB::table($this->name);
        foreach ($this->columns as $column) {
            if ($column->isNumeric()) {
                $query->addSelect(DB::raw('MIN(`' . $column->name . '`) as `' . $column->name . '`'));
            }
        }
        $result = $query->first();
        foreach ($this->columns as $column) {
            $columnName = $column->name;
            if (isset($result->$columnName)) {
                $column->setMinValue($result->$columnName);
            }
        }
    }

public
function
populateNumericColumnsWithLongestValue
(
)
{
$
query
=
DB
::
table
(
$
this
->
name
)
;
foreach
(
$
this
->
columns
as
$
column
)
{
if
(
$
column
->
isNumeric
(
)
)
{
$
query
->
addSelect
(
DB
::
raw
(
'MIN(`'
.
$
column
->
name
.
'`) as `'
.
$
column
->
name
.
'`'
)
)
;
}
}
$
result
=
$
query
->
first
(
)
;
foreach
(
$
this
->
columns
as
$
column
)
{
$
columnName
=
$
column
->
name
;
if
(
isset
(
$
result
->
$
columnName
)
)
{
$
column
->
setMinValue
(
$
result
->
$
columnName
)
;
}
}
}

Go through each column and find the lowest value of that field


public function transform($json)
    {
        if (!is_string($json)) {
            throw new \InvalidArgumentException('$json variable is not a string.');
        }
        $assocArrayJson = json_decode($json, true);

        return $this->checkDecodedJson($assocArrayJson);
    }

public
function
transform
(
$
json
)
{
if
(
!
is_string
(
$
json
)
)
{
throw
new
\
InvalidArgumentException
(
'$json variable is not a string.'
)
;
}
$
assocArrayJson
=
json_decode
(
$
json
,
true
)
;
return
$
this
->
checkDecodedJson
(
$
assocArrayJson
)
;
}

Transform Json to Associative Array.

@param string $json

@return array


public function register(Application $app)
    {
        $app['doctrine_orm.configuration'] = $app->share(function ($app) {
            $configuration = new Configuration();

            $mCache = isset($app['doctrine_orm.metadata_cache']) ? $app['doctrine_orm.metadata_cache'] : new Cache();
            $qCache = isset($app['doctrine_orm.query_cache']) ? $app['doctrine_orm.query_cache'] : new Cache();
            $rCache = isset($app['doctrine_orm.result_cache']) ? $app['doctrine_orm.result_cache'] : new Cache();

            $annotation = boolval($app['doctrine_orm.simple_annotation_reader']);
            $driverImpl = $configuration->newDefaultAnnotationDriver($app['doctrine_orm.entities_path'], $annotation);

            $configuration->setMetadataCacheImpl($mCache);
            $configuration->setMetadataDriverImpl($driverImpl);
            $configuration->setQueryCacheImpl($qCache);
            $configuration->setResultCacheImpl($rCache);
            $configuration->setProxyDir($app['doctrine_orm.proxies_path']);
            $configuration->setProxyNamespace($app['doctrine_orm.proxies_namespace']);
            $configuration->setAutogenerateProxyClasses(false);

            if (isset($app['doctrine_orm.autogenerate_proxy_classes'])) {
                $configuration->setAutogenerateProxyClasses($app['doctrine_orm.autogenerate_proxy_classes']);
            } else {
                $configuration->setAutogenerateProxyClasses(true);
            }

            return $configuration;
        });

        $app['doctrine_orm.connection'] = $app->share(function ($app) {
            return DriverManager::getConnection(
                $app['doctrine_orm.connection_parameters'],
                $app['doctrine_orm.configuration'],
                new EventManager()
            );
        });

        $app['doctrine_orm.em'] = $app->share(function ($app) {
            return EntityManager::create(
                $app['doctrine_orm.connection'],
                $app['doctrine_orm.configuration'],
                $app['doctrine_orm.connection']->getEventManager()
            );
        });

    }

Register ORM on Application

@param Application $app


public function setFile(string $name, FilePathInterface $filePath): void
    {
        $this->rawContent = '';
        $this->files[$name] = $filePath;
    }

public function setFile ( string $ name , FilePathInterface $ filePath ) : void { $ this -> rawContent = '' ; $ this -> files [ $ name ] = $ filePath ; }

Sets a file to upload.

@since 1.0.0

@param string            $name     The name.
@param FilePathInterface $filePath The file path.


public function setPostField(string $name, string $value): void
    {
        $this->rawContent = '';
        $this->postFields[$name] = $value;
    }

public function setPostField ( string $ name , string $ value ) : void { $ this -> rawContent = '' ; $ this -> postFields [ $ name ] = $ value ; }

Sets a post field.

@since 1.0.0

@param string $name  The name.
@param string $value The value.


public function setRawContent(string $rawContent): void
    {
        $this->postFields = [];
        $this->files = [];
        $this->rawContent = $rawContent;
    }

public function setRawContent ( string $ rawContent ) : void { $ this -> postFields = [ ] ; $ this -> files = [ ] ; $ this -> rawContent = $ rawContent ; }

Sets the raw content.

@since 1.0.0

@param string $rawContent The raw content.


public function resolve($abstract, $parameters = array())
    {
        $concrete = $this->getConcrete($abstract);

        // We're ready to instantiate an instance of the concrete type registered for
        // the binding. This will instantiate the types, as well as resolve any of
        // its "nested" dependencies recursively until all have gotten resolved.
        if ($this->isBuildable($concrete, $abstract)) {
            $object = $this->build($concrete, $parameters);
        } else {
            $object = $this->resolve($concrete, $parameters);
        }

        $this->dispatchEvent(Events::CLASS_RESOLVED, new ClassResolvedEvent($object));

        return $object;
    }

Instantiate a concrete instance of the given type.

@param string $abstract
@param array $parameters

@return mixed

Instantiate a concrete instance of the given type .


public function bind($abstract, $concrete, $protect = false)
    {
        if ($protect) {
            $concrete = $this->container->protect($concrete);
        }

        $this->container[$abstract] = $concrete;
    }

public function bind ( $ abstract , $ concrete , $ protect = false ) { if ( $ protect ) { $ concrete = $ this -> container -> protect ( $ concrete ) ; } $ this -> container [ $ abstract ] = $ concrete ; }

Bind an abstract definition to a concrete implementation.

@param string $abstract
@param string|\Closure $concrete
@param bool $protect

Bind an abstract definition to a concrete implementation .


protected function getConcrete($abstract)
    {
        // If we don't have a registered resolver or concrete for the type, we'll just
        // assume each type is a concrete name and will attempt to resolve it as is
        // since the container should be able to resolve concretes automatically.
        if (!is_scalar($abstract)) {
            return $abstract;
        }

        if (!isset($this->container[$abstract])) {
            if ($this->missingLeadingSlash($abstract) && isset($this->container['\\' . $abstract])) {
                $abstract = '\\' . $abstract;
            }

            return $abstract;
        }

        return $this->container[$abstract];
    }

Get the concrete type for a given abstract.

@param string $abstract

@return mixed $concrete

Get the concrete type for a given abstract .


protected function dispatchEvent($name, Event $event)
    {
        if ($this->dispatcher) {
            $this->dispatcher->dispatch($name, $event);
        }
    }

protected function dispatchEvent ( $ name , Event $ event ) { if ( $ this -> dispatcher ) { $ this -> dispatcher -> dispatch ( $ name , $ event ) ; } }

Relay events to all listeners.

@param string $name
@param Event $event


public function channelSpacerGetType($cid)
  {
    $channel = $this->channelGetById($cid);

    if(!$this->channelIsSpacer($channel))
    {
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid channel flags", 0x307);
    }

    switch($channel["channel_name"]->section("]", 1))
    {
      case "___":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_SOLIDLINE;

      case "---":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHLINE;

      case "...":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DOTLINE;

      case "-.-":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHDOTLINE;

      case "-..":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHDOTDOTLINE;

      default:
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_CUSTOM;
    }
  }

public
function
channelSpacerGetType
(
$
cid
)
{
$
channel
=
$
this
->
channelGetById
(
$
cid
)
;
if
(
!
$
this
->
channelIsSpacer
(
$
channel
)
)
{
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid channel flags"
,
0x307
)
;
}
switch
(
$
channel
[
"channel_name"
]
->
section
(
"]"
,
1
)
)
{
case
"___"
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_SOLIDLINE
;
case
"---"
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DASHLINE
;
case
"..."
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DOTLINE
;
case
"-.-"
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DASHDOTLINE
;
case
"-.."
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_DASHDOTDOTLINE
;
default
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_CUSTOM
;
}
}

Returns the possible type of a channel spacer.

@param  integer $cid
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return integer

Returns the possible type of a channel spacer .


public function channelSpacerGetAlign($cid)
  {
    $channel = $this->channelGetById($cid);

    if(!$this->channelIsSpacer($channel) || !preg_match("/\[(.*)spacer.*\]/", $channel, $matches) || !isset($matches[1]))
    {
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid channel flags", 0x307);
    }

    switch($matches[1])
    {
      case "*":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_REPEAT;

      case "c":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_CENTER;

      case "r":
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_RIGHT;

      default:
        return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_LEFT;
    }
  }

public
function
channelSpacerGetAlign
(
$
cid
)
{
$
channel
=
$
this
->
channelGetById
(
$
cid
)
;
if
(
!
$
this
->
channelIsSpacer
(
$
channel
)
||
!
preg_match
(
"/\[(.*)spacer.*\]/"
,
$
channel
,
$
matches
)
||
!
isset
(
$
matches
[
1
]
)
)
{
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid channel flags"
,
0x307
)
;
}
switch
(
$
matches
[
1
]
)
{
case
"*"
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_REPEAT
;
case
"c"
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_CENTER
;
case
"r"
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_RIGHT
;
default
:
return
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
SPACER_ALIGN_LEFT
;
}
}

Returns the possible alignment of a channel spacer.

@param  integer $cid
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return integer

Returns the possible alignment of a channel spacer .


public function channelPermAssign($cid, $permid, $permvalue)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("channeladdperm", array("cid" => $cid, $permident => $permid, "permvalue" => $permvalue));
  }

public function channelPermAssign ( $ cid , $ permid , $ permvalue ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "channeladdperm" , array ( "cid" => $ cid , $ permident => $ permid , "permvalue" => $ permvalue ) ) ; }

Adds a set of specified permissions to a channel. Multiple permissions can be added by
providing the two parameters of each permission.

@param  integer $cid
@param  integer $permid
@param  integer $permvalue
@return void

Adds a set of specified permissions to a channel . Multiple permissions can be added by providing the two parameters of each permission .


public function channelPermRemove($cid, $permid)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("channeldelperm", array("cid" => $cid, $permident => $permid));
  }

public function channelPermRemove ( $ cid , $ permid ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "channeldelperm" , array ( "cid" => $ cid , $ permident => $ permid ) ) ; }

Removes a set of specified permissions from a channel. Multiple permissions can be removed at once.

@param  integer $cid
@param  integer $permid
@return void

Removes a set of specified permissions from a channel . Multiple permissions can be removed at once .


public function channelClientPermAssign($cid, $cldbid, $permid, $permvalue)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("channelclientaddperm", array("cid" => $cid, "cldbid" => $cldbid, $permident => $permid, "permvalue" => $permvalue));
  }

public function channelClientPermAssign ( $ cid , $ cldbid , $ permid , $ permvalue ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "channelclientaddperm" , array ( "cid" => $ cid , "cldbid" => $ cldbid , $ permident => $ permid , "permvalue" => $ permvalue ) ) ; }

Adds a set of specified permissions to a client in a specific channel. Multiple permissions can be added by
providing the two parameters of each permission.

@param  integer $cid
@param  integer $cldbid
@param  integer $permid
@param  integer $permvalue
@return void

Adds a set of specified permissions to a client in a specific channel . Multiple permissions can be added by providing the two parameters of each permission .


public function channelClientPermRemove($cid, $cldbid, $permid)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("channelclientdelperm", array("cid" => $cid, "cldbid" => $cldbid, $permident => $permid));
  }

public function channelClientPermRemove ( $ cid , $ cldbid , $ permid ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "channelclientdelperm" , array ( "cid" => $ cid , "cldbid" => $ cldbid , $ permident => $ permid ) ) ; }

Removes a set of specified permissions from a client in a specific channel. Multiple permissions can be removed at once.

@param  integer $cid
@param  integer $cldbid
@param  integer $permid
@return void

Removes a set of specified permissions from a client in a specific channel . Multiple permissions can be removed at once .


public function channelFileList($cid, $cpw = "", $path = "/", $recursive = FALSE)
  {
    $files = $this->execute("ftgetfilelist", array("cid" => $cid, "cpw" => $cpw, "path" => $path))->toArray();
    $count = count($files);

    for($i = 0; $i < $count; $i++)
    {
      $files[$i]["cid"]  = $files[0]["cid"];
      $files[$i]["path"] = $files[0]["path"];
      $files[$i]["src"]  = new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String($cid ? $files[$i]["path"] : "/");

      if(!$files[$i]["src"]->endsWith("/"))
      {
        $files[$i]["src"]->append("/");
      }

      $files[$i]["src"]->append($files[$i]["name"]);

      if($recursive && $files[$i]["type"] == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::FILE_TYPE_DIRECTORY)
      {
        $files = array_merge($files, $this->channelFileList($cid, $cpw, $path . $files[$i]["name"], $recursive));
      }
    }

    uasort($files, array(__CLASS__, "sortFileList"));

    return $files;
  }

public function channelFileList ( $ cid , $ cpw = "" , $ path = "/" , $ recursive = FALSE ) { $ files = $ this -> execute ( "ftgetfilelist" , array ( "cid" => $ cid , "cpw" => $ cpw , "path" => $ path ) ) -> toArray ( ) ; $ count = count ( $ files ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ files [ $ i ] [ "cid" ] = $ files [ 0 ] [ "cid" ] ; $ files [ $ i ] [ "path" ] = $ files [ 0 ] [ "path" ] ; $ files [ $ i ] [ "src" ] = new \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ Helper \ String ( $ cid ? $ files [ $ i ] [ "path" ] : "/" ) ; if ( ! $ files [ $ i ] [ "src" ] -> endsWith ( "/" ) ) { $ files [ $ i ] [ "src" ] -> append ( "/" ) ; } $ files [ $ i ] [ "src" ] -> append ( $ files [ $ i ] [ "name" ] ) ; if ( $ recursive && $ files [ $ i ] [ "type" ] == \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: FILE_TYPE_DIRECTORY ) { $ files = array_merge ( $ files , $ this -> channelFileList ( $ cid , $ cpw , $ path . $ files [ $ i ] [ "name" ] , $ recursive ) ) ; } } uasort ( $ files , array ( __CLASS__ , "sortFileList" ) ) ; return $ files ; }

Returns a list of files and directories stored in the specified channels file repository.

@param  integer $cid
@param  string  $cpw
@param  string  $path
@param  boolean $recursive
@return array

Returns a list of files and directories stored in the specified channels file repository .


public function clientGetById($clid)
  {
    if(!array_key_exists((string) $clid, $this->clientList()))
    {
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid clientID", 0x200);
    }

    return $this->clientList[intval((string) $clid)];
  }

public
function
clientGetById
(
$
clid
)
{
if
(
!
array_key_exists
(
(
string
)
$
clid
,
$
this
->
clientList
(
)
)
)
{
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid clientID"
,
0x200
)
;
}
return
$
this
->
clientList
[
intval
(
(
string
)
$
clid
)
]
;
}

Returns the TeamSpeak3_Node_Client object matching the given ID.

@param  integer $clid
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Client

Returns the TeamSpeak3_Node_Client object matching the given ID .


public function clientGetByUid($uid)
  {
    foreach($this->clientList() as $client)
    {
      if($client["client_unique_identifier"] == $uid) return $client;
    }

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

public
function
clientGetByUid
(
$
uid
)
{
foreach
(
$
this
->
clientList
(
)
as
$
client
)
{
if
(
$
client
[
"client_unique_identifier"
]
==
$
uid
)
return
$
client
;
}
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid clientID"
,
0x200
)
;
}

Returns the TeamSpeak3_Node_Client object matching the given unique identifier.

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

Returns the TeamSpeak3_Node_Client object matching the given unique identifier .


public function clientMove($clid, $cid, $cpw = null)
  {
    $this->clientListReset();

    $this->execute("clientmove", array("clid" => $clid, "cid" => $cid, "cpw" => $cpw));

    if($clid == $this->whoamiGet("client_id"))
    {
      $this->getParent()->whoamiSet("client_channel_id", $cid);
    }
  }

public function clientMove ( $ clid , $ cid , $ cpw = null ) { $ this -> clientListReset ( ) ; $ this -> execute ( "clientmove" , array ( "clid" => $ clid , "cid" => $ cid , "cpw" => $ cpw ) ) ; if ( $ clid == $ this -> whoamiGet ( "client_id" ) ) { $ this -> getParent ( ) -> whoamiSet ( "client_channel_id" , $ cid ) ; } }

Moves a client to another channel.

@param  integer $clid
@param  integer $cid
@param  string  $cpw
@return void


public function clientKick($clid, $reasonid = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::KICK_CHANNEL, $reasonmsg = null)
  {
    $this->clientListReset();

    $this->execute("clientkick", array("clid" => $clid, "reasonid" => $reasonid, "reasonmsg" => $reasonmsg));
  }

public function clientKick ( $ clid , $ reasonid = \ ManiaLivePlugins \ Standard \ TeamSpeak \ TeamSpeak3 \ TeamSpeak3 :: KICK_CHANNEL , $ reasonmsg = null ) { $ this -> clientListReset ( ) ; $ this -> execute ( "clientkick" , array ( "clid" => $ clid , "reasonid" => $ reasonid , "reasonmsg" => $ reasonmsg ) ) ; }

Kicks one or more clients from their currently joined channel or from the server.

@param  integer $clid
@param  integer $reasonid
@param  string  $reasonmsg
@return void

Kicks one or more clients from their currently joined channel or from the server .


public function clientPermRemove($cldbid, $permid)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("clientdelperm", array("cldbid" => $cldbid, $permident => $permid));
  }

public function clientPermRemove ( $ cldbid , $ permid ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "clientdelperm" , array ( "cldbid" => $ cldbid , $ permident => $ permid ) ) ; }

Removes a set of specified permissions from a client. Multiple permissions can be removed at once.

@param integer $cldbid
@param integer $permid
@return void

Removes a set of specified permissions from a client . Multiple permissions can be removed at once .


public function serverGroupGetById($sgid)
  {
    if(!array_key_exists((string) $sgid, $this->serverGroupList()))
    {
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid groupID", 0xA00);
    }

    return $this->sgroupList[intval((string) $sgid)];
  }

public
function
serverGroupGetById
(
$
sgid
)
{
if
(
!
array_key_exists
(
(
string
)
$
sgid
,
$
this
->
serverGroupList
(
)
)
)
{
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid groupID"
,
0xA00
)
;
}
return
$
this
->
sgroupList
[
intval
(
(
string
)
$
sgid
)
]
;
}

Returns the TeamSpeak3_Node_Servergroup object matching the given ID.

@param  integer $sgid
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Servergroup

Returns the TeamSpeak3_Node_Servergroup object matching the given ID .


public function serverGroupGetByName($name, $type = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR)
  {
    foreach($this->serverGroupList() as $group)
    {
      if($group["name"] == $name && $group["type"] == $type) return $group;
    }

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

public
function
serverGroupGetByName
(
$
name
,
$
type
=
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
GROUP_DBTYPE_REGULAR
)
{
foreach
(
$
this
->
serverGroupList
(
)
as
$
group
)
{
if
(
$
group
[
"name"
]
==
$
name
&&
$
group
[
"type"
]
==
$
type
)
return
$
group
;
}
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid groupID"
,
0xA00
)
;
}

Returns the TeamSpeak3_Node_Servergroup object matching the given name.

@param  string  $name
@param  integer $type
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Servergroup

Returns the TeamSpeak3_Node_Servergroup object matching the given name .


public function serverGroupPermAssign($sgid, $permid, $permvalue, $permnegated = FALSE, $permskip = FALSE)
  {
    $permident = (is_numeric($permid)) ? "permid" : "permsid";

    $this->execute("servergroupaddperm", array("sgid" => $sgid, $permident => $permid, "permvalue" => $permvalue, "permnegated" => $permnegated, "permskip" => $permskip));
  }

public function serverGroupPermAssign ( $ sgid , $ permid , $ permvalue , $ permnegated = FALSE , $ permskip = FALSE ) { $ permident = ( is_numeric ( $ permid ) ) ? "permid" : "permsid" ; $ this -> execute ( "servergroupaddperm" , array ( "sgid" => $ sgid , $ permident => $ permid , "permvalue" => $ permvalue , "permnegated" => $ permnegated , "permskip" => $ permskip ) ) ; }

Adds a set of specified permissions to the server group specified. Multiple permissions
can be added by providing the four parameters of each permission in separate arrays.

@param  integer $sgid
@param  integer $permid
@param  integer $permvalue
@param  integer $permnegated
@param  integer $permskip
@return void

Adds a set of specified permissions to the server group specified . Multiple permissions can be added by providing the four parameters of each permission in separate arrays .


public function serverGroupGetProfiles()
  {
    $profiles = array();

    foreach($this->serverGroupList() as $sgid => $sgroup)
    {
      if($sgroup["type"] != \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR) continue;

      $profiles[$sgid] = array(
        "b_permission_modify_power_ignore" => 0,
        "i_group_needed_member_add_power" => 0,
        "i_group_member_add_power" => 0,
        "i_group_needed_member_remove_power" => 0,
        "i_group_member_remove_power" => 0,
        "i_needed_modify_power_count" => 0,
        "i_needed_modify_power_total" => 0,
        "i_permission_modify_power" => 0,
        "i_group_needed_modify_power" => 0,
        "i_group_modify_power" => 0,
        "i_client_needed_modify_power" => 0,
        "i_client_modify_power" => 0,
        "b_virtualserver_servergroup_create" => 0,
        "b_virtualserver_servergroup_delete" => 0,
        "b_client_ignore_bans" => 0,
        "b_client_ignore_antiflood" => 0,
        "b_group_is_permanent" => 0,
        "i_client_needed_ban_power" => 0,
        "i_client_needed_kick_power" => 0,
        "i_client_needed_move_power" => 0,
        "i_client_talk_power" => 0,
        "__sgid" => $sgid,
        "__name" => $sgroup->toString(),
        "__node" => $sgroup,
      );

      try
      {
        $perms = $this->serverGroupPermList($sgid, TRUE);
        $grant = isset($perms["i_permission_modify_power"]) ? $perms["i_permission_modify_power"]["permvalue"] : null;
      }
      catch(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception $e)
      {
        /* ERROR_database_empty_result */
        if($e->getCode() != 0x501) throw $e;

        $perms = array();
        $grant = null;
      }

      foreach($perms as $permsid => $perm)
      {
        if(in_array($permsid, array_keys($profiles[$sgid])))
        {
          $profiles[$sgid][$permsid] = $perm["permvalue"];
        }
        elseif(\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory($permsid)->startsWith("i_needed_modify_power_"))
        {
          if(!$grant || $perm["permvalue"] > $grant) continue;

          $profiles[$sgid]["i_needed_modify_power_total"] = $profiles[$sgid]["i_needed_modify_power_total"]+$perm["permvalue"];
          $profiles[$sgid]["i_needed_modify_power_count"]++;
        }
      }
    }

    array_multisort($profiles, SORT_DESC);

    return $profiles;
  }

public
function
serverGroupGetProfiles
(
)
{
$
profiles
=
array
(
)
;
foreach
(
$
this
->
serverGroupList
(
)
as
$
sgid
=>
$
sgroup
)
{
if
(
$
sgroup
[
"type"
]
!=
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
GROUP_DBTYPE_REGULAR
)
continue
;
$
profiles
[
$
sgid
]
=
array
(
"b_permission_modify_power_ignore"
=>
0
,
"i_group_needed_member_add_power"
=>
0
,
"i_group_member_add_power"
=>
0
,
"i_group_needed_member_remove_power"
=>
0
,
"i_group_member_remove_power"
=>
0
,
"i_needed_modify_power_count"
=>
0
,
"i_needed_modify_power_total"
=>
0
,
"i_permission_modify_power"
=>
0
,
"i_group_needed_modify_power"
=>
0
,
"i_group_modify_power"
=>
0
,
"i_client_needed_modify_power"
=>
0
,
"i_client_modify_power"
=>
0
,
"b_virtualserver_servergroup_create"
=>
0
,
"b_virtualserver_servergroup_delete"
=>
0
,
"b_client_ignore_bans"
=>
0
,
"b_client_ignore_antiflood"
=>
0
,
"b_group_is_permanent"
=>
0
,
"i_client_needed_ban_power"
=>
0
,
"i_client_needed_kick_power"
=>
0
,
"i_client_needed_move_power"
=>
0
,
"i_client_talk_power"
=>
0
,
"__sgid"
=>
$
sgid
,
"__name"
=>
$
sgroup
->
toString
(
)
,
"__node"
=>
$
sgroup
,
)
;
try
{
$
perms
=
$
this
->
serverGroupPermList
(
$
sgid
,
TRUE
)
;
$
grant
=
isset
(
$
perms
[
"i_permission_modify_power"
]
)
$
perms
[
"i_permission_modify_power"
]
[
"permvalue"
]
:
;
}
catch
(
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
$
e
)
{
/* ERROR_database_empty_result */
if
(
$
e
->
getCode
(
)
!=
0x501
)
throw
$
e
;
$
perms
=
array
(
)
;
$
grant
=
;
}
foreach
(
$
perms
as
$
permsid
=>
$
perm
)
{
if
(
in_array
(
$
permsid
,
array_keys
(
$
profiles
[
$
sgid
]
)
)
)
{
$
profiles
[
$
sgid
]
[
$
permsid
]
=
$
perm
[
"permvalue"
]
;
}
elseif
(
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Helper
\
String
::
factory
(
$
permsid
)
->
startsWith
(
"i_needed_modify_power_"
)
)
{
if
(
!
$
grant
||
$
perm
[
"permvalue"
]
>
$
grant
)
continue
;
$
profiles
[
$
sgid
]
[
"i_needed_modify_power_total"
]
=
$
profiles
[
$
sgid
]
[
"i_needed_modify_power_total"
]
+
$
perm
[
"permvalue"
]
;
$
profiles
[
$
sgid
]
[
"i_needed_modify_power_count"
]
++
;
}
}
}
array_multisort
(
$
profiles
,
SORT_DESC
)
;
return
$
profiles
;
}

Returns an ordered array of regular server groups available based on a pre-defined
set of rules.

@return array

Returns an ordered array of regular server groups available based on a pre - defined set of rules .


public function channelGroupGetById($cgid)
  {
    if(!array_key_exists((string) $cgid, $this->channelGroupList()))
    {
      throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid groupID", 0xA00);
    }

    return $this->cgroupList[intval((string) $cgid)];
  }

public
function
channelGroupGetById
(
$
cgid
)
{
if
(
!
array_key_exists
(
(
string
)
$
cgid
,
$
this
->
channelGroupList
(
)
)
)
{
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid groupID"
,
0xA00
)
;
}
return
$
this
->
cgroupList
[
intval
(
(
string
)
$
cgid
)
]
;
}

Returns the TeamSpeak3_Node_Channelgroup object matching the given ID.

@param  integer $cgid
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Channelgroup

Returns the TeamSpeak3_Node_Channelgroup object matching the given ID .


public function channelGroupGetByName($name, $type = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR)
  {
    foreach($this->channelGroupList() as $group)
    {
      if($group["name"] == $name && $group["type"] == $type) return $group;
    }

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

public
function
channelGroupGetByName
(
$
name
,
$
type
=
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
TeamSpeak3
::
GROUP_DBTYPE_REGULAR
)
{
foreach
(
$
this
->
channelGroupList
(
)
as
$
group
)
{
if
(
$
group
[
"name"
]
==
$
name
&&
$
group
[
"type"
]
==
$
type
)
return
$
group
;
}
throw
new
\
ManiaLivePlugins
\
Standard
\
TeamSpeak
\
TeamSpeak3
\
Adapter
\
ServerQuery
\
Exception
(
"invalid groupID"
,
0xA00
)
;
}

Returns the TeamSpeak3_Node_Channelgroup object matching the given name.

@param  string  $name
@param  integer $type
@throws \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception
@return Channelgroup

Returns the TeamSpeak3_Node_Channelgroup object matching the given name .