_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q264600 | JsonDecodeFile.parse | test | 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);
} | php | {
"resource": ""
} |
q264601 | JsonDecodeFile.call | test | public static function call($path, $assoc = false)
{
return self::parse(BomUtil::removeBom(self::readFile($path)), $assoc);
} | php | {
"resource": ""
} |
q264602 | AbstractNavigationRenderer.normalizeId | test | 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;
} | php | {
"resource": ""
} |
q264603 | AbstractNavigationRenderer.cleanAttributes | test | 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;
} | php | {
"resource": ""
} |
q264604 | Label.setValue | test | public function setValue($value)
{
if ($this->element) {
$this->element->SetLabel($value);
}
$this->value = $value;
} | php | {
"resource": ""
} |
q264605 | Collection.add | test | 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;
} | php | {
"resource": ""
} |
q264606 | Collection.getTopLevelWindow | test | public function getTopLevelWindow()
{
foreach ($this->objects as $object) {
if ($object instanceof Frame
or $object instanceof Dialog) {
return $object;
}
}
} | php | {
"resource": ""
} |
q264607 | Collection.remove | test | public function remove($element)
{
$trueId = $this->getTrueId($element);
$this->objects[$trueId]->destroy();
unset($this->objects[$trueId]);
unset($this->ids[$trueId]);
} | php | {
"resource": ""
} |
q264608 | Collection.getElementById | test | public function getElementById($id)
{
$id = $this->getTrueId($id);
if ($id === false) {
// Throw something
return;
}
return $this->objects[$id];
} | php | {
"resource": ""
} |
q264609 | BaseConfigurationModel.loadState | test | 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;
}
} | php | {
"resource": ""
} |
q264610 | BaseConfigurationModel.saveState | test | 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;
} | php | {
"resource": ""
} |
q264611 | Column.setDataType | test | 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;
} | php | {
"resource": ""
} |
q264612 | Connection.onChannelCreated | test | function onChannelCreated($command)
{
$channelId = $command->getResult();
$channel = $this->server->request('channelinfo cid='.$channelId)->toList();
$channel['cid'] = $channelId;
new Channel($channel, $this->getChannelPermissionList($channel));
} | php | {
"resource": ""
} |
q264613 | ExtensionDataHelper.getLocalizedVersionedDataField | test | 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;
} | php | {
"resource": ""
} |
q264614 | ExtensionDataHelper.getLocalizedDataField | test | 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;
} | php | {
"resource": ""
} |
q264615 | ExtensionDataHelper.getOtherPackageVersionedData | test | 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;
} | php | {
"resource": ""
} |
q264616 | ExtensionDataHelper.getOtherPackageData | test | 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;
} | php | {
"resource": ""
} |
q264617 | ExtensionDataHelper.humanizeReadme | test | 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;
} | php | {
"resource": ""
} |
q264618 | ExtensionDataHelper.prepareMigrationTask | test | 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);
}
}
} | php | {
"resource": ""
} |
q264619 | ExtensionDataHelper.buildTask | test | 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;
} | php | {
"resource": ""
} |
q264620 | Router.match | test | 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);
}
} | php | {
"resource": ""
} |
q264621 | Router.parseRegexRoute | test | 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];
} | php | {
"resource": ""
} |
q264622 | PropertiesValidator.checkStrictness | test | 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
);
}
}
} | php | {
"resource": ""
} |
q264623 | AbstractAdapter.getProfiler | test | public function getProfiler()
{
return \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Profiler::get(spl_object_hash($this));
} | php | {
"resource": ""
} |
q264624 | AbstractAdapter.initTransport | test | 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);
} | php | {
"resource": ""
} |
q264625 | BaseActionsInfoTrait.getBlameableAttributes | test | protected function getBlameableAttributes()
{
return [
ActiveRecord::EVENT_BEFORE_INSERT => [$this->createdByAttribute, $this->updatedByAttribute],
ActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedByAttribute,
];
} | php | {
"resource": ""
} |
q264626 | BaseActionsInfoTrait.getTimestampAttributes | test | protected function getTimestampAttributes()
{
return [
ActiveRecord::EVENT_BEFORE_INSERT => [$this->createdAtAttribute, $this->updatedAtAttribute],
ActiveRecord::EVENT_BEFORE_UPDATE => $this->updatedAtAttribute,
];
} | php | {
"resource": ""
} |
q264627 | BaseActionsInfoTrait.evaluateAttributesInternal | test | 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;
}
}
}
} | php | {
"resource": ""
} |
q264628 | BaseActionsInfoTrait.BaseActionsInfoTraitInit | test | 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',
]
);
}
} | php | {
"resource": ""
} |
q264629 | CoreAuthHandler.before_request | test | 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);
}
} | php | {
"resource": ""
} |
q264630 | CoreAuthHandler.after_request | test | 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!');
}
} | php | {
"resource": ""
} |
q264631 | UDP.read | test | 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);
} | php | {
"resource": ""
} |
q264632 | UDP.send | test | 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);
} | php | {
"resource": ""
} |
q264633 | MysqlController.actionRestore | test | 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);
}
} | php | {
"resource": ""
} |
q264634 | MysqlController.actionDump | test | 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);
}
} | php | {
"resource": ""
} |
q264635 | Menubar.initMenu | test | function initMenu($icon, $pluginId = null)
{
$id = explode('\\', $pluginId);
$this->menu[$pluginId] = array('name' => end($id), 'icon' => $icon, 'buttons' => array());
if($this->loaded)
$this->refreshMenubar();
} | php | {
"resource": ""
} |
q264636 | Menubar.addButton | test | 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();
} | php | {
"resource": ""
} |
q264637 | Install.fire | test | public function fire()
{
$handle = popen(PHP_BINDIR.'/pecl install wxwidgets 2>&1', 'r');
while ( ! feof($handle)) {
$this->output->write(fread($handle, 2048));
}
} | php | {
"resource": ""
} |
q264638 | Table.populateColumnsWithLongestValue | test | 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);
}
}
} | php | {
"resource": ""
} |
q264639 | Table.populateNumericColumnsWithLongestValue | test | 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);
}
}
} | php | {
"resource": ""
} |
q264640 | JsonTransformer.transform | test | 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);
} | php | {
"resource": ""
} |
q264641 | DoctrineORMServiceProvider.register | test | 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()
);
});
} | php | {
"resource": ""
} |
q264642 | PageFetcherRequest.setFile | test | public function setFile(string $name, FilePathInterface $filePath): void
{
$this->rawContent = '';
$this->files[$name] = $filePath;
} | php | {
"resource": ""
} |
q264643 | PageFetcherRequest.setPostField | test | public function setPostField(string $name, string $value): void
{
$this->rawContent = '';
$this->postFields[$name] = $value;
} | php | {
"resource": ""
} |
q264644 | PageFetcherRequest.setRawContent | test | public function setRawContent(string $rawContent): void
{
$this->postFields = [];
$this->files = [];
$this->rawContent = $rawContent;
} | php | {
"resource": ""
} |
q264645 | ClassResolver.resolve | test | 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;
} | php | {
"resource": ""
} |
q264646 | ClassResolver.bind | test | public function bind($abstract, $concrete, $protect = false)
{
if ($protect) {
$concrete = $this->container->protect($concrete);
}
$this->container[$abstract] = $concrete;
} | php | {
"resource": ""
} |
q264647 | ClassResolver.getConcrete | test | 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];
} | php | {
"resource": ""
} |
q264648 | ClassResolver.dispatchEvent | test | protected function dispatchEvent($name, Event $event)
{
if ($this->dispatcher) {
$this->dispatcher->dispatch($name, $event);
}
} | php | {
"resource": ""
} |
q264649 | Server.channelSpacerGetType | test | 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;
}
} | php | {
"resource": ""
} |
q264650 | Server.channelSpacerGetAlign | test | 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;
}
} | php | {
"resource": ""
} |
q264651 | Server.channelPermAssign | test | public function channelPermAssign($cid, $permid, $permvalue)
{
$permident = (is_numeric($permid)) ? "permid" : "permsid";
$this->execute("channeladdperm", array("cid" => $cid, $permident => $permid, "permvalue" => $permvalue));
} | php | {
"resource": ""
} |
q264652 | Server.channelPermRemove | test | public function channelPermRemove($cid, $permid)
{
$permident = (is_numeric($permid)) ? "permid" : "permsid";
$this->execute("channeldelperm", array("cid" => $cid, $permident => $permid));
} | php | {
"resource": ""
} |
q264653 | Server.channelClientPermAssign | test | 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));
} | php | {
"resource": ""
} |
q264654 | Server.channelClientPermRemove | test | public function channelClientPermRemove($cid, $cldbid, $permid)
{
$permident = (is_numeric($permid)) ? "permid" : "permsid";
$this->execute("channelclientdelperm", array("cid" => $cid, "cldbid" => $cldbid, $permident => $permid));
} | php | {
"resource": ""
} |
q264655 | Server.channelFileList | test | 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;
} | php | {
"resource": ""
} |
q264656 | Server.clientGetById | test | 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)];
} | php | {
"resource": ""
} |
q264657 | Server.clientGetByUid | test | 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);
} | php | {
"resource": ""
} |
q264658 | Server.clientMove | test | 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);
}
} | php | {
"resource": ""
} |
q264659 | Server.clientKick | test | 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));
} | php | {
"resource": ""
} |
q264660 | Server.clientPermRemove | test | public function clientPermRemove($cldbid, $permid)
{
$permident = (is_numeric($permid)) ? "permid" : "permsid";
$this->execute("clientdelperm", array("cldbid" => $cldbid, $permident => $permid));
} | php | {
"resource": ""
} |
q264661 | Server.serverGroupGetById | test | 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)];
} | php | {
"resource": ""
} |
q264662 | Server.serverGroupGetByName | test | 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);
} | php | {
"resource": ""
} |
q264663 | Server.serverGroupPermAssign | test | 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));
} | php | {
"resource": ""
} |
q264664 | Server.serverGroupGetProfiles | test | 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;
} | php | {
"resource": ""
} |
q264665 | Server.channelGroupGetById | test | 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)];
} | php | {
"resource": ""
} |
q264666 | Server.channelGroupGetByName | test | 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);
} | php | {
"resource": ""
} |
q264667 | Server.channelGroupPermAssign | test | public function channelGroupPermAssign($cgid, $permid, $permvalue)
{
$permident = (is_numeric($permid)) ? "permid" : "permsid";
$this->execute("channelgroupaddperm", array("cgid" => $cgid, $permident => $permid, "permvalue" => $permvalue));
} | php | {
"resource": ""
} |
q264668 | Server.permReset | test | public function permReset()
{
$token = $this->request("permreset")->toList();
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("notifyTokencreated", $this, $token["token"]);
return $token["token"];
} | php | {
"resource": ""
} |
q264669 | Server.iconUpload | test | public function iconUpload($data)
{
$crc = crc32($data);
$size = strlen($data);
$upload = $this->transferInitUpload(rand(0x0000, 0xFFFF), 0, "/icon_" . $crc, $size);
$transfer = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::factory("filetransfer://" . $upload["host"] . ":" . $upload["port"]);
$transfer->upload($upload["ftkey"], $upload["seekpos"], $data);
return $crc;
} | php | {
"resource": ""
} |
q264670 | Server.snapshotCreate | test | public function snapshotCreate($mode = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SNAPSHOT_STRING)
{
$snapshot = $this->request("serversnapshotcreate")->toString(FALSE);
switch($mode)
{
case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SNAPSHOT_BASE64:
return $snapshot->toBase64();
break;
case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SNAPSHOT_HEXDEC:
return $snapshot->toHex();
break;
default:
return (string) $snapshot;
break;
}
} | php | {
"resource": ""
} |
q264671 | Server.logView | test | public function logView($limitcount = 30, $comparator = null, $timestamp = null)
{
return $this->execute("logview", array("limitcount" => $limitcount, "comparator" => $comparator, "timestamp" => $timestamp))->toArray();
} | php | {
"resource": ""
} |
q264672 | Server.logAdd | test | public function logAdd($logmsg, $loglevel = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::LOGLEVEL_INFO)
{
$this->execute("logadd", array("logmsg" => $logmsg, "loglevel" => $loglevel));
} | php | {
"resource": ""
} |
q264673 | Server.sortClientList | test | protected static function sortClientList(Client $a, Client $b)
{
if(get_class($a) != get_class($b))
{
return 0;
/* workaround for PHP bug #50688 */
throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid parameter", 0x602);
}
if(!$a instanceof Client)
{
return 0;
/* workaround for PHP bug #50688 */
throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("convert error", 0x604);
}
if($a->getProperty("client_talk_power", 0) != $b->getProperty("client_talk_power", 0))
{
return ($a->getProperty("client_talk_power", 0) > $b->getProperty("client_talk_power", 0)) ? -1 : 1;
}
if($a->getProperty("client_is_talker", 0) != $b->getProperty("client_is_talker", 0))
{
return ($a->getProperty("client_is_talker", 0) > $b->getProperty("client_is_talker", 0)) ? -1 : 1;
}
return strcmp(strtolower($a["client_nickname"]), strtolower($b["client_nickname"]));
} | php | {
"resource": ""
} |
q264674 | Server.sortGroupList | test | protected static function sortGroupList(AbstractNode $a, AbstractNode $b)
{
if(get_class($a) != get_class($b))
{
return 0;
/* workaround for PHP bug #50688 */
throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid parameter", 0x602);
}
if(!$a instanceof Servergroup && !$a instanceof Channelgroup)
{
return 0;
/* workaround for PHP bug #50688 */
throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("convert error", 0x604);
}
if($a->getProperty("sortid", 0) != $b->getProperty("sortid", 0))
{
return ($a->getProperty("sortid", 0) < $b->getProperty("sortid", 0)) ? -1 : 1;
}
return ($a->getId() < $b->getId()) ? -1 : 1;
} | php | {
"resource": ""
} |
q264675 | Server.sortFileList | test | protected static function sortFileList(array $a, array $b)
{
if(!array_key_exists("src", $a) || !array_key_exists("src", $b))
{
return 0;
throw new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Adapter\ServerQuery\Exception("invalid parameter", 0x602);
}
return strcmp(strtolower($a["src"]), strtolower($b["src"]));
} | php | {
"resource": ""
} |
q264676 | Servergroup.copy | test | public function copy($name = null, $tsgid = 0, $type = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_DBTYPE_REGULAR)
{
return $this->getParent()->serverGroupCopy($this->getId(), $name, $tsgid, $type);
} | php | {
"resource": ""
} |
q264677 | AbstractNode.iconGetName | test | public function iconGetName($key)
{
$iconid = ($this[$key] < 0) ? (pow(2, 32))-($this[$key]*-1) : $this[$key];
return new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String("/icon_" . $iconid);
} | php | {
"resource": ""
} |
q264678 | AbstractNode.getClass | test | public function getClass($prefix = "ts3_")
{
if($this instanceof Channel && $this->isSpacer())
{
return $prefix . "spacer";
}
elseif($this instanceof Client && $this["client_type"])
{
return $prefix . "query";
}
return $prefix . \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory(get_class($this))->section("_", 2)->toLower();
} | php | {
"resource": ""
} |
q264679 | AbstractNode.getViewer | test | public function getViewer(ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Viewer\ViewerInterface $viewer)
{
$html = $viewer->fetchObject($this);
$iterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $node)
{
$siblings = array();
for($level = 0; $level < $iterator->getDepth(); $level++)
{
$siblings[] = ($iterator->getSubIterator($level)->hasNext()) ? 1 : 0;
}
$siblings[] = (!$iterator->getSubIterator($level)->hasNext()) ? 1 : 0;
$html .= $viewer->fetchObject($node, $siblings);
}
return $html;
} | php | {
"resource": ""
} |
q264680 | AbstractNode.filterList | test | protected function filterList(array $nodes = array(), array $rules = array())
{
if(!empty($rules))
{
foreach($nodes as $node)
{
if(!$node instanceof AbstractNode) continue;
$props = $node->getInfo(FALSE);
$props = array_intersect_key($props, $rules);
$match = TRUE;
foreach($props as $key => $val)
{
if($val instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String)
{
$match = $val->contains($rules[$key], TRUE);
}
else
{
$match = $val == $rules[$key];
}
if($match === FALSE)
{
unset($nodes[$node->getId()]);
}
}
}
}
return $nodes;
} | php | {
"resource": ""
} |
q264681 | HydratorFactory.writeFile | test | private function writeFile(string $filename, string $content)
{
$directory = \dirname($filename);
if (!\is_writable($directory)) {
throw new \RuntimeException(\sprintf('Cache directory "%s" is not writable.', $directory));
}
$tmpFile = \tempnam($directory, \basename($filename));
if (false === @\file_put_contents($tmpFile, $content)) {
throw new \RuntimeException(\sprintf('Could not write file "%s".', $tmpFile));
}
if (!@\rename($tmpFile, $filename)) {
throw new \RuntimeException(\sprintf('Could not write file "%s".', $filename));
}
@\chmod($filename, 0666 & ~\umask());
} | php | {
"resource": ""
} |
q264682 | HydratorFactory.getHydratorClass | test | public function getHydratorClass() : string
{
$originalClassName = $this->configuration->getHydratedClassName();
$realClassName = $this->generateClassName($originalClassName);
if (!class_exists($realClassName)) {
$directory = $directory = $this->configuration->getGeneratedClassesTargetDir();
$targetFile = $directory . '/' . \str_replace("\\", "_", $realClassName) . '.php';
if (@include_once $targetFile) {
return $realClassName;
}
$generator = $this->configuration->getHydratorGenerator();
$phpClassCode = $generator->generate(new \ReflectionClass($originalClassName), $realClassName, $originalClassName);
$this->writeFile($targetFile, $phpClassCode);
require_once $targetFile;
}
return $realClassName;
} | php | {
"resource": ""
} |
q264683 | TCP.connect | test | public function connect()
{
if($this->stream !== null) return;
$host = strval($this->config["host"]);
$port = strval($this->config["port"]);
$address = "tcp://" . $host . ":" . $port;
$timeout = intval($this->config["timeout"]);
$this->stream = @stream_socket_client($address, $errno, $errstr, $timeout);
if($this->stream === FALSE)
{
throw new Exception(utf8_encode($errstr), $errno);
}
@stream_set_timeout($this->stream, $timeout);
@stream_set_blocking($this->stream, $this->config["blocking"] ? 1 : 0);
} | php | {
"resource": ""
} |
q264684 | TCP.disconnect | test | public function disconnect()
{
if($this->stream === null) return;
fclose($this->stream);
$this->stream = null;
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "Disconnected");
} | php | {
"resource": ""
} |
q264685 | TCP.readLine | test | public function readLine($token = "\n", $useCR = false)
{
$this->connect();
$line = \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String::factory("");
while(!$line->endsWith($token) && !($useCR && $line->endsWith("\r"))) // FUUUUUUU carriage return
{
$this->waitForReadyRead();
$data = @fgets($this->stream, 4096);
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
if($data === FALSE)
{
if($line->count())
{
$line->append($token);
}
else
{
throw new Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
}
}
else
{
$line->append($data);
}
}
return $line->trim();
} | php | {
"resource": ""
} |
q264686 | CrudOptionsFallbackAbstractFactory.canCreate | test | public function canCreate(ContainerInterface $container, $requestedName)
{
$fqcn = $this->getFQCN($requestedName);
if ($fqcn === false) {
return false;
}
return \class_exists($fqcn);
} | php | {
"resource": ""
} |
q264687 | RoleController.store | test | public function store(CreateRoleRequest $request)
{
$input = $request->all();
$role = $this->roleRepository->create([
'name' => $input['name'],
]);
foreach ($input['permissions'] as $permission) {
$role->permissions()->attach($permission);
}
\Flash::success(trans('l5starter::messages.create.success'));
return redirect(route('admin.roles.index'));
} | php | {
"resource": ""
} |
q264688 | RoleController.update | test | public function update($id, UpdateRoleRequest $request)
{
$role = $this->roleRepository->findWithoutFail($id);
if (empty($role)) {
\Flash::error(trans('l5starter::messages.404_not_found'));
return redirect(route('admin.roles.index'));
}
$input = $request->all();
$role = $this->roleRepository->update([
'name' => $input['name'],
], $id);
$permissions = [];
if (!empty($input['permissions'])) {
foreach ($input['permissions'] as $permission) {
$permissions[$permission] = $permission;
}
}
$role->permissions()->sync($permissions);
\Flash::success(trans('l5starter::messages.update.success'));
return redirect(route('admin.roles.index'));
} | php | {
"resource": ""
} |
q264689 | RoleController.destroy | test | public function destroy($id)
{
$role = $this->roleRepository->findWithoutFail($id);
if (empty($role)) {
\Flash::error(trans('l5starter::messages.404_not_found'));
return redirect(route('admin.roles.index'));
}
$this->roleRepository->delete($id);
\Flash::success(trans('l5starter::messages.delete.success'));
return redirect(route('admin.roles.index'));
} | php | {
"resource": ""
} |
q264690 | Client.get | test | public function get($resource, $headers = array())
{
return $this->getGuzzle()->request(
'GET',
$this->getUrl().$resource,
['headers' => array_merge($this->getHeaders(), $headers)]
);
} | php | {
"resource": ""
} |
q264691 | Html.getCorpusClass | test | protected function getCorpusClass()
{
$extras = "";
if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Channel && $this->currObj->isSpacer())
{
switch($this->currObj->spacerGetType())
{
case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_SOLIDLINE:
$extras .= " solidline";
break;
case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHLINE:
$extras .= " dashline";
break;
case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHDOTLINE:
$extras .= " dashdotline";
break;
case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DASHDOTDOTLINE:
$extras .= " dashdotdotline";
break;
case (string) \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_DOTLINE:
$extras .= " dotline";
break;
}
switch($this->currObj->spacerGetAlign())
{
case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_CENTER:
$extras .= " center";
break;
case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_RIGHT:
$extras .= " right";
break;
case \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_LEFT:
$extras .= " left";
break;
}
}
return "corpus " . $this->currObj->getClass(null) . $extras;
} | php | {
"resource": ""
} |
q264692 | Html.getCorpusIcon | test | protected function getCorpusIcon()
{
if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Channel && $this->currObj->isSpacer()) return;
return $this->getImage($this->currObj->getIcon() . ".png");
} | php | {
"resource": ""
} |
q264693 | Html.getCorpusName | test | protected function getCorpusName()
{
if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Channel && $this->currObj->isSpacer())
{
if($this->currObj->spacerGetType() != \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_CUSTOM) return;
$string = $this->currObj["channel_name"]->section("]", 1);
if($this->currObj->spacerGetAlign() == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::SPACER_ALIGN_REPEAT)
{
$string->resize(30, $string);
}
return htmlspecialchars($string);
}
if($this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Client)
{
$before = array();
$behind = array();
foreach($this->currObj->memberOf() as $group)
{
if($group->getProperty("namemode") == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_NAMEMODE_BEFORE)
{
$before[] = "[" . htmlspecialchars($group["name"]) . "]";
}
elseif($group->getProperty("namemode") == \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\TeamSpeak3::GROUP_NAMEMODE_BEHIND)
{
$behind[] = "[" . htmlspecialchars($group["name"]) . "]";
}
}
return implode("", $before) . " " . htmlspecialchars($this->currObj) . " " . implode("", $behind);
}
return htmlspecialchars($this->currObj);
} | php | {
"resource": ""
} |
q264694 | Html.getSuffixFlag | test | protected function getSuffixFlag()
{
if(!$this->currObj instanceof \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Node\Client) return;
if($this->flagpath && $this->currObj["client_country"])
{
return $this->getImage($this->currObj["client_country"]->toLower() . ".png", $this->currObj["client_country"], null, FALSE, TRUE);
}
} | php | {
"resource": ""
} |
q264695 | FileTransfer.init | test | protected function init($ftkey)
{
if(strlen($ftkey) != 32)
{
throw new FileTransfer\Exception("invalid file transfer key format");
}
$this->getProfiler()->start();
$this->getTransport()->send($ftkey);
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferHandshake", $this);
} | php | {
"resource": ""
} |
q264696 | FileTransfer.upload | test | public function upload($ftkey, $seek, $data)
{
$this->init($ftkey);
$size = strlen($data);
$seek = intval($seek);
$pack = 4096;
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferUploadStarted", $ftkey, $seek, $size);
for(;$seek < $size;)
{
$rest = $size-$seek;
$pack = $rest < $pack ? $rest : $pack;
$buff = substr($data, $seek, $pack);
$seek = $seek+$pack;
$this->getTransport()->send($buff);
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferUploadProgress", $ftkey, $seek, $size);
}
$this->getProfiler()->stop();
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferUploadFinished", $ftkey, $seek, $size);
if($seek < $size)
{
throw new FileTransfer\Exception("incomplete file upload (" . $seek . " of " . $size . " bytes)");
}
} | php | {
"resource": ""
} |
q264697 | FileTransfer.download | test | public function download($ftkey, $size, $passthru = FALSE)
{
$this->init($ftkey);
if($passthru)
{
return $this->passthru($size);
}
$buff = new \ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\String("");
$size = intval($size);
$pack = 4096;
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);
for($seek = 0;$seek < $size;)
{
$rest = $size-$seek;
$pack = $rest < $pack ? $rest : $pack;
$data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
$seek = $seek+$pack;
$buff->append($data);
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
}
$this->getProfiler()->stop();
\ManiaLivePlugins\Standard\TeamSpeak\TeamSpeak3\Helper\Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);
if(strlen($buff) != $size)
{
throw new FileTransfer\Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
}
return $buff;
} | php | {
"resource": ""
} |
q264698 | Application.getSessionContext | test | public function getSessionContext()
{
if (!$this->_sessionContext) {
$this->_sessionContext = new SessionContext();
$this->_sessionContext->retrieveSessionObjects();
}
return $this->_sessionContext;
} | php | {
"resource": ""
} |
q264699 | Application.getTypeManager | test | public function getTypeManager()
{
if (!$this->_typeManager) {
$this->_typeManager = new TypeManager();
/* @var $localeInfoService localeInfoService */
$localeInfoService = Openbizx::getService(LOCALEINFO_SERVICE);
$localeInfo = $localeInfoService->getLocaleInfo();
if ($localeInfo) {
$this->_typeManager->setLocaleInfo($localeInfo);
}
}
return $this->_typeManager;
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.