_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q7000 | Slim.get | train | protected function get($place, $args=array()){
$sep = isset($args['seperator']) ? $args['seperator'] : ' ';
$content = '';
if(isset($this->content[$place])){
foreach($this->content[$place] as $item){
if($this->options['debug']===true){
$content.='<!--Skinny:Place: '.$place.'-->';
}
switch($it... | php | {
"resource": ""
} |
q7001 | Application.configureIO | train | protected function configureIO()
{
if ($this->consoleInput->hasParameterOption(['--ansi'], true))
{
$this->consoleOutput->setDecorated(true);
}
elseif ($this->consoleInput->hasParameterOption(['--no-ansi'], true))
{
$this->consoleOutput->setDecorated(false);
}
if ($this->consoleInput->hasParameter... | php | {
"resource": ""
} |
q7002 | Application.findNamespace | train | public function findNamespace(string $namespace): string
{
$allNamespaces = $this->getNamespaces();
$expr = preg_replace_callback(
'{([^:]+|)}',
function ($matches)
{
return preg_quote($matches[1]) . '[^:]*';
},
$namespace
);
$namespaces = preg_grep('{^' . $expr . '}', $allNamespaces);
... | php | {
"resource": ""
} |
q7003 | Application.getAllCommands | train | public function getAllCommands(string $namespace = ''): array
{
$this->initCommands();
if ($namespace === '')
{
$commands = $this->commands;
if (!$this->commandLoader)
{
return $commands;
}
foreach ($this->commandLoader->getNames() as $name)
{
if (!isset($commands[$name]))
{
... | php | {
"resource": ""
} |
q7004 | Application.getDefaultInputDefinition | train | protected function getDefaultInputDefinition(): InputDefinition
{
return new InputDefinition(
[
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display the help information'),
new InputOption('--quiet', '-q', In... | php | {
"resource": ""
} |
q7005 | Application.getHelperSet | train | public function getHelperSet(): HelperSet
{
if (!$this->helperSet)
{
$this->helperSet = $this->getDefaultHelperSet();
}
return $this->helperSet;
} | php | {
"resource": ""
} |
q7006 | Application.getLongVersion | train | public function getLongVersion(): string
{
$name = $this->getName();
if ($name === '')
{
$name = 'Joomla Console Application';
}
if ($this->getVersion() !== '')
{
return sprintf('%s <info>%s</info>', $name, $this->getVersion());
}
return $name;
} | php | {
"resource": ""
} |
q7007 | Application.hasCommand | train | public function hasCommand(string $name): bool
{
$this->initCommands();
// If command is already registered, we're good
if (isset($this->commands[$name]))
{
return true;
}
// If there is no loader, we can't look for a command there
if (!$this->commandLoader)
{
return false;
}
return $this-... | php | {
"resource": ""
} |
q7008 | Application.initCommands | train | private function initCommands()
{
if ($this->initialised)
{
return;
}
$this->initialised = true;
foreach ($this->getDefaultCommands() as $command)
{
$this->addCommand($command);
}
} | php | {
"resource": ""
} |
q7009 | Role.extendCreate | train | protected function extendCreate(ValidatorResolver $validator)
{
$name = Keyword::make($validator->getData()['name']);
$validator->after(function (ValidatorResolver $v) use ($name) {
if ($this->isRoleNameAlreadyUsed($name)) {
$v->errors()->add('name', trans('orchestra/con... | php | {
"resource": ""
} |
q7010 | Role.extendUpdate | train | protected function extendUpdate(ValidatorResolver $validator)
{
$name = Keyword::make($validator->getData()['name']);
$validator->after(function (ValidatorResolver $v) use ($name) {
if ($this->isRoleNameGuest($name)) {
$v->errors()->add('name', trans('orchestra/control::... | php | {
"resource": ""
} |
q7011 | Role.isRoleNameAlreadyUsed | train | protected function isRoleNameAlreadyUsed(Keyword $name): bool
{
$roles = Foundation::acl()->roles()->get();
return $name->searchIn($roles) !== false;
} | php | {
"resource": ""
} |
q7012 | ReportExtension.decorateSubreportsDataSource | train | protected function decorateSubreportsDataSource(): void
{
$builder = $this->getContainerBuilder();
$subreports = $builder->findByTag(self::TAG_CACHE);
foreach ($subreports as $service => $tag) {
$serviceDef = $builder->getDefinition($service);
// Validate datasource class
if (!is_subclass_of((string) ... | php | {
"resource": ""
} |
q7013 | ViewElement.evaluate | train | public function evaluate(Context $context, $expression) {
if(is_numeric($expression)) {
$expression = (string)$expression;
}
if(! isset($context->view->lexers[$expression]) ) {
$lexer = new Lexer($expression);
$context->view->lexers[$expression] = & $lexer;
$lexer->parse($context);
} else {
$lexe... | php | {
"resource": ""
} |
q7014 | Html.el | train | public static function el($name = NULL, $attrs = NULL)
{
$el = new static;
$parts = explode(' ', (string)$name, 2);
$el->setName($parts[0]);
if (is_array($attrs)) {
$el->attrs = $attrs;
} elseif ($attrs !== NULL) {
$el->setText($attrs);
}
if (isset($parts[1])) {
$matches = preg_match_all('#([... | php | {
"resource": ""
} |
q7015 | Html.setName | train | public function setName($name, $isEmpty = NULL)
{
if ($name !== NULL && !is_string($name)) {
throw new InvalidArgumentException(sprintf('Name must be string or NULL, %s given.', gettype($name)));
}
$this->name = $name;
$this->isEmpty = $isEmpty === NULL ? isset(static::$emptyElements[$name]) : (bool)$isEmp... | php | {
"resource": ""
} |
q7016 | Html.appendAttribute | train | public function appendAttribute($name, $value, $option = TRUE)
{
if (is_array($value)) {
$prev = isset($this->attrs[$name]) ? (array)$this->attrs[$name] : [];
$this->attrs[$name] = $value + $prev;
} elseif ((string)$value === '') {
$tmp = &$this->attrs[$name]; // appending empty value? -> ignore, but ens... | php | {
"resource": ""
} |
q7017 | Html.getAttribute | train | public function getAttribute($name)
{
return isset($this->attrs[$name]) ? $this->attrs[$name] : NULL;
} | php | {
"resource": ""
} |
q7018 | Html.href | train | public function href($path, $query = NULL)
{
if ($query) {
$query = http_build_query($query, '', '&');
if ($query !== '') {
$path .= '?' . $query;
}
}
$this->attrs['href'] = $path;
return $this;
} | php | {
"resource": ""
} |
q7019 | Html.setHtml | train | public function setHtml($html)
{
if (is_array($html)) {
throw new InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html)));
}
$this->removeChildren();
$this->children[] = (string)$html;
return $this;
} | php | {
"resource": ""
} |
q7020 | Html.getHtml | train | public function getHtml()
{
$s = '';
foreach ($this->children as $child) {
if (is_object($child)) {
$s .= $child->render();
} else {
$s .= $child;
}
}
return $s;
} | php | {
"resource": ""
} |
q7021 | Html.setText | train | public function setText($text)
{
if (!is_array($text) && !$text instanceof self) {
$text = htmlspecialchars((string)$text, ENT_NOQUOTES, 'UTF-8');
}
return $this->setHtml($text);
} | php | {
"resource": ""
} |
q7022 | Html.create | train | public function create($name, $attrs = NULL)
{
$this->insert(NULL, $child = static::el($name, $attrs));
return $child;
} | php | {
"resource": ""
} |
q7023 | Html.insert | train | public function insert($index, $child, $replace = FALSE)
{
if ($child instanceof self || is_scalar($child)) {
if ($index === NULL) { // append
$this->children[] = $child;
} else { // insert or replace
array_splice($this->children, (int)$index, $replace ? 1 : 0, [$child]);
}
} else {
throw new... | php | {
"resource": ""
} |
q7024 | Html.render | train | public function render($indent = NULL)
{
$s = $this->startTag();
if (!$this->isEmpty) {
// add content
if ($indent !== NULL) {
$indent++;
}
foreach ($this->children as $child) {
if (is_object($child)) {
$s .= $child->render($indent);
} else {
$s .= $child;
}
}
// add e... | php | {
"resource": ""
} |
q7025 | Html.startTag | train | public function startTag()
{
if ($this->name) {
return '<' . $this->name . $this->attributes() . (static::$xhtml && $this->isEmpty ? ' />' : '>');
} else {
return '';
}
} | php | {
"resource": ""
} |
q7026 | Html.attributes | train | public function attributes()
{
if (!is_array($this->attrs)) {
return '';
}
$s = '';
$attrs = $this->attrs;
foreach ($attrs as $key => $value) {
if ($value === NULL || $value === FALSE) {
continue;
} elseif ($value === TRUE) {
if (static::$xhtml) {
$s .= ' ' . $key . '="' . $key . '"'... | php | {
"resource": ""
} |
q7027 | Request.request | train | protected function request($method, $endpoint, $options = [])
{
return $this->unwrapResponse($this->getHttpClient($this->getBaseOptions())->{$method}($endpoint, $options));
} | php | {
"resource": ""
} |
q7028 | SubscriptionManager.subscribe | train | public function subscribe($id, string $channel, $args, Request $request, \DateTime $expireAt = null): void
{
$this->convertNodes($args);
$this->pubSubHandler->sub(
$channel,
$id,
[
'channel' => $channel,
'arguments' => $args,
... | php | {
"resource": ""
} |
q7029 | SubscriptionManager.convertNodes | train | private function convertNodes(array &$data): void
{
array_walk_recursive(
$data,
function (&$value) {
if ($value instanceof NodeInterface) {
$value = IDEncoder::encode($value);
}
}
);
} | php | {
"resource": ""
} |
q7030 | SubscriptionManager.sendRequest | train | private function sendRequest(Request $originRequest, SubscriptionMessage $message, OutputInterface $output, bool $debug = false): void
{
$host = $originRequest->getHost();
$port = $originRequest->getPort();
$path = $originRequest->getPathInfo();
$handle = fsockopen($originRequest->i... | php | {
"resource": ""
} |
q7031 | TextDescriptor.describe | train | public function describe(OutputInterface $output, $object, array $options = [])
{
$this->output = $output;
switch (true)
{
case $object instanceof Application:
$this->describeJoomlaApplication($object, $options);
break;
case $object instanceof AbstractCommand:
$this->describeConsoleCommand($... | php | {
"resource": ""
} |
q7032 | TextDescriptor.describeConsoleCommand | train | private function describeConsoleCommand(AbstractCommand $command, array $options)
{
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
$this->writeText('<comment>Usage:</comment>', $options);
foreach (array_merge([$command->getSynopsis(true)], $command->... | php | {
"resource": ""
} |
q7033 | TextDescriptor.describeJoomlaApplication | train | private function describeJoomlaApplication(Application $app, array $options)
{
$describedNamespace = $options['namespace'] ?? '';
$description = new ApplicationDescription($app, $describedNamespace);
$version = $app->getLongVersion();
if ($version !== '')
{
$this->writeText("$version\n\n", $optio... | php | {
"resource": ""
} |
q7034 | TextDescriptor.getColumnWidth | train | private function getColumnWidth(array $commands): int
{
$widths = [];
foreach ($commands as $command)
{
if ($command instanceof AbstractCommand)
{
$widths[] = StringHelper::strlen($command->getName());
foreach ($command->getAliases() as $alias)
{
$widths[] = StringHelper::strlen($alias);... | php | {
"resource": ""
} |
q7035 | TokensTable.findValidToken | train | public function findValidToken(Query $query, array $options)
{
$options += [
'token' => null,
'expires >' => new DateTimeImmutable(),
'status' => false
];
return $query->where($options);
} | php | {
"resource": ""
} |
q7036 | TokensTable.setStatus | train | public function setStatus($id, $status)
{
if (!is_numeric($status)) {
throw new Exception('Status argument must be an integer');
}
$entity = $this->findById($id)->firstOrFail();
$entity->status = $status;
$this->save($entity);
return $entity;
} | php | {
"resource": ""
} |
q7037 | ThemesController.activate | train | public function activate(Processor $processor, $type, $id)
{
return $processor->activate($this, $type, $id);
} | php | {
"resource": ""
} |
q7038 | ThemesController.themeHasActivated | train | public function themeHasActivated($type, $id)
{
$message = \trans('orchestra/control::response.themes.update', [
'type' => Str::title($type),
]);
return $this->redirectWithMessage(
\handles("orchestra::control/themes/{$type}"), $message
);
} | php | {
"resource": ""
} |
q7039 | TagFigDictionary.fig_dictionary | train | private function fig_dictionary(Context $context) {
//If a @source attribute is specified,
//it means that when the target (view's language) is the same as @source,
//then don't bother loading dictionary file, nor translating: just render the tag's children.
$file = $this->dicFile;
... | php | {
"resource": ""
} |
q7040 | Json.decode | train | public static function decode($json, $assoc = false)
{
if ($json instanceof Response) {
return json_decode($json->getContent(), $assoc);
}
return json_decode($json, $assoc);
} | php | {
"resource": ""
} |
q7041 | ConfigurationValidator.validate | train | public function validate($data)
{
$this->validator->reset();
$this->validator->check($data, $this->schema());
if (!$this->validator->isValid()) {
throw new InvalidConfigurationException(
$this->validator->getErrors()
);
}
} | php | {
"resource": ""
} |
q7042 | ClassUtils.applyNamingConvention | train | public static function applyNamingConvention(string $namespace, string $path, ?string $node, string $name, ?string $suffix = null)
{
if (null === $node) {
return sprintf('%s\%s\%s%s', $namespace, $path, ucfirst($name), $suffix);
}
return sprintf('%s\%s\%s\%s%s', $namespace, $pat... | php | {
"resource": ""
} |
q7043 | Skinny.insertTemplatePF | train | public static function insertTemplatePF ($parser, $template, $spot=''){
//process additional arguments into a usable array
$params = array();
//sanitize the template name
$template = preg_replace('/[^A-Za-z0-9_\-]/', '_', $template);
//this will be stripped out, assuming the skin is based on Skinny.... | php | {
"resource": ""
} |
q7044 | Skinny.getSkin | train | public static function getSkin($context, &$skin){
//there's probably a better way to check for this...
if(!isset($_GET['useskin'])){
$key = $GLOBALS['wgDefaultSkin'];
if( self::$pageSkin ){
$key = new self::$pageSkin;
}
$key = \Skin::normalizeKey( $key );
$skinNames = \S... | php | {
"resource": ""
} |
q7045 | Role.table | train | public function table($model)
{
return $this->table->of('control.roles', function (TableGrid $table) use ($model) {
// attach Model and set pagination option to true.
$table->with($model)->paginate(true);
$table->sortable();
$table->searchable(['name']);
... | php | {
"resource": ""
} |
q7046 | Role.addEditButton | train | protected function addEditButton(Eloquent $role)
{
$link = handles("orchestra::control/roles/{$role->id}/edit");
$text = trans('orchestra/foundation::label.edit');
$attributes = ['class' => 'btn btn-xs btn-label btn-warning'];
return app('html')->link($link, $text, $attributes);
... | php | {
"resource": ""
} |
q7047 | Role.form | train | public function form(Eloquent $model)
{
return $this->form->of('control.roles', function (FormGrid $form) use ($model) {
$form->resource($this, 'orchestra::control/roles', $model);
$form->hidden('id');
$form->fieldset(function (Fieldset $fieldset) {
$fiel... | php | {
"resource": ""
} |
q7048 | VCardReader.SaveFile | train | public function SaveFile($Key, $Index = 0, $TargetPath = '')
{
if (!isset($this->Data[$Key]))
{
return false;
}
if (!isset($this->Data[$Key][$Index]))
{
return false;
}
// Returing false if it is an image URL
if (stripos($this->Data[$Key][$Index]['Value'], 'uri:') === 0)
{
return false;
}... | php | {
"resource": ""
} |
q7049 | VCardReader.ParseStructuredValue | train | private static function ParseStructuredValue($Text, $Key)
{
$Text = array_map('trim', explode(';', $Text));
$Result = array();
$Ctr = 0;
foreach (self::$Spec_StructuredElements[$Key] as $Index => $StructurePart)
{
$Result[$StructurePart] = isset($Text[$Index]) ? $Text[$Index] : null;
}
return $Resul... | php | {
"resource": ""
} |
q7050 | RawReportFormat.prepareReport | train | public static function prepareReport(Report $report)
{
$contents = Report::getReportFileContents($report->getFullPath());
$report->content = $contents;
return $report;
} | php | {
"resource": ""
} |
q7051 | Client.call | train | public function call(string $method, array $arguments): ResponseInterface
{
try {
return $this->__soapCall($method, $arguments, null, $this->getHeader());
} catch (\Exception $e) {
$exception = new ClientException($e->getMessage(), $e->getCode(), $e);
if ($this->... | php | {
"resource": ""
} |
q7052 | Client.getHeader | train | protected function getHeader(): \SoapHeader
{
if ($this->header) {
return $this->header;
}
return $this->header = new \SoapHeader(static::NAMESPACE, 'UserCredentials', [
'userid' => $this->login,
'password' => $this->password,
]);
} | php | {
"resource": ""
} |
q7053 | Clock.read | train | public function read(): ?TimePoint
{
try {
$datetime = new DateTime($this->current, $this->timezone);
} catch (BaseException $e) {
return null;
}
return $this->fromDateTime($datetime);
} | php | {
"resource": ""
} |
q7054 | Clock.fromString | train | public function fromString($input, $format = null): ?TimePoint
{
if ($format === null) {
$formats = [
'Y-m-d\TH:i:sP', // RFC 3339
'Y-m-d\TH:i:s.uP', // RFC 3339 with fractional seconds
'Y-m-d\TH:i:sO', // ISO 8601
... | php | {
"resource": ""
} |
q7055 | Clock.inRange | train | public function inRange(TimePoint $expiration, TimePoint $creation = null, $skew = null): bool
{
$now = $this->read();
if ($skew !== null) {
if ($creation instanceof TimePoint) {
$creation = $creation->modify(sprintf('-%s', $skew));
}
$expiration... | php | {
"resource": ""
} |
q7056 | UsersTable.validateActivationKey | train | public function validateActivationKey($email, $activationKey)
{
$query = $this->findByEmailAndActivationKey($email, $activationKey);
if ($query->Count() > 0) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q7057 | UsersTable.activateUser | train | public function activateUser($email, $activationKey)
{
if ($this->validateActivationKey($email, $activationKey)) {
$user = $this->findByEmailAndActivationKey($email, $activationKey)->first();
if ($user->active == 0) {
$user->active = 1;
$user->activat... | php | {
"resource": ""
} |
q7058 | FunctionFactory.lookup | train | public final function lookup($funcName) {
if(isset(self::$functions[$funcName])) {
return self::$functions[$funcName];
}
//The assign-and-return is acceptable because isset(null) returns false.
return (self::$functions[$funcName] = $this->create($funcName));
} | php | {
"resource": ""
} |
q7059 | ControlledError.create | train | public static function create($code, $message = null, $category = null)
{
return new class($message, $code, $category) extends ControlledError
{
/**
* @var string
*/
protected $category;
/**
* @param string $message
... | php | {
"resource": ""
} |
q7060 | ViewElementTag.parseAttributes | train | protected function parseAttributes($figNamespace, array $attributes)
{
// A fig:call attribute on a tag, indicates that all the other attributes
// are arguments for the macro. They all are considered as expressions,
// and therefore there is no need to search for adhoc inside.
if (!... | php | {
"resource": ""
} |
q7061 | ViewElementTag.buildXMLAttributesString | train | private function buildXMLAttributesString(Context $context) {
$result = '';
$matches = null;
$attributes = $this->attributes;
$runtimeAttributes = $context->getRuntimeAttributes();
foreach($runtimeAttributes as $attributeName=>$runtimeAttr) {
$attributes[$attributeName] = $runtimeAttr;
}
foreach($at... | php | {
"resource": ""
} |
q7062 | ViewElementTag.evalAttribute | train | protected function evalAttribute(Context $context, $name) {
$expression = $this->getAttribute($name, false);
if($expression) {
return $this->evaluate($context, $expression);
}
return false;
} | php | {
"resource": ""
} |
q7063 | ViewElementTag.applyOutputFilter | train | private function applyOutputFilter(Context $context, $buffer) {
//TODO: Currently the filtering works only on non-slot tags.
//If applied on a slot tag, the transform is made on the special placeholder /==SLOT=.../
//rather than the future contents of the slot.
if($this->figFilter) {
$filterClass = $this->fi... | php | {
"resource": ""
} |
q7064 | ViewElementTag.replaceLastChild_cdata | train | private function replaceLastChild_cdata(ViewElementCData $cdata)
{
$n = count($this->children);
if ( ($n > 1) && ($this->children[$n - 2] instanceof ViewElementCData) ) {
// Group the last-but-one cdata with this new cdata
$this->children[$n - 2]->outputBuffer .= $cdata->outp... | php | {
"resource": ""
} |
q7065 | ApplicationDescription.inspectApplication | train | private function inspectApplication()
{
$this->commands = [];
$this->namespaces = [];
$all = $this->application->getAllCommands($this->namespace ? $this->application->findNamespace($this->namespace) : '');
foreach ($this->sortCommands($all) as $namespace => $commands)
{
$names = [];
/** @var Abstr... | php | {
"resource": ""
} |
q7066 | ApplicationDescription.sortCommands | train | private function sortCommands(array $commands): array
{
$namespacedCommands = [];
$globalCommands = [];
foreach ($commands as $name => $command)
{
$key = $this->extractNamespace($name, 1);
if (!$key)
{
$globalCommands[self::GLOBAL_NAMESPACE][$name] = $command;
}
else
{
$namespac... | php | {
"resource": ""
} |
q7067 | PluginConfigAnnotation.getConfig | train | public function getConfig(): array
{
$ref = new \ReflectionClass(get_class($this));
$properties = $ref->getProperties();
$config = [];
//set default values
foreach ($properties as $property) {
$value = $property->getValue($this);
if (null !== $value) ... | php | {
"resource": ""
} |
q7068 | Shipment.getTrackingUrl | train | public function getTrackingUrl()
{
if (!isset($this->parcelnumber)) {
throw new RuntimeException("Shipment has no parcel number.");
}
return sprintf(Api::TRACKING_URL, $this->parcelnumber);
} | php | {
"resource": ""
} |
q7069 | SolrQueryBuilder.addFilter | train | public function addFilter($query, $value = null) {
if ($value) {
$query = "$query:$value";
}
$this->filters[$query] = $query;
return $this;
} | php | {
"resource": ""
} |
q7070 | SolrQueryBuilder.removeFilter | train | public function removeFilter($query, $value = null) {
if ($value) {
$query = "$query:$value";
}
unset($this->filters[$query]);
return $this;
} | php | {
"resource": ""
} |
q7071 | SolrQueryBuilder.restrictNearPoint | train | public function restrictNearPoint($point, $field, $radius) {
$this->addFilter("{!geofilt}");
$this->params['sfield'] = $field;
$this->params['pt'] = $point;
$this->params['d'] = $radius;
return $this;
} | php | {
"resource": ""
} |
q7072 | Router.toRoute | train | public function toRoute($name, array $args = [], $code = 307)
{
$to = $this->getRoute($name, $args);
header("location: {$to}", true, $code);
exit;
} | php | {
"resource": ""
} |
q7073 | Router.crud | train | public function crud($pattern, $callback, array $params = [])
{
if (!is_string($callback)) {
throw new \Exception('Crud callbacks must be a string to a controller class');
}
if (!empty($params['name'])) {
$name = $params['name'];
}
$pattern = rtrim(... | php | {
"resource": ""
} |
q7074 | Router.group | train | public function group(array $params, $callback)
{
$prefix = trim($this->getParam($params, 'prefix'), '/');
$before = $this->getParam($params, 'before');
$after = $this->getParam($params, 'after');
if ($prefix) {
$this->prefixes[] = $prefix;
$this->prefix ... | php | {
"resource": ""
} |
q7075 | Router.getMatch | train | public function getMatch($method = null, $path = null)
{
$method = $method ?: $this->getRequestMethod();
$path = $path ?: $this->getRequestPath();
$method = strtoupper($method);
$methodNotAllowed = null;
foreach ($this->routes as $pattern => $methods) {
preg_... | php | {
"resource": ""
} |
q7076 | Router.dispatch | train | public function dispatch($method = null, $path = null)
{
$match = $this->getMatch($method, $path);
foreach ($match->before as $filter) {
if (empty($filter)) {
continue;
}
$response = $this->executeCallback($this->getFilterCallback($filter), $match... | php | {
"resource": ""
} |
q7077 | Router.executeCallback | train | public function executeCallback($cb, array $args = [], $filter = false)
{
if ($cb instanceof Closure) {
return call_user_func_array($cb, $args);
}
if (is_string($cb) && strpos($cb, "@") !== false) {
$cb = explode('@', $cb);
}
if (is_array($cb) && cou... | php | {
"resource": ""
} |
q7078 | Router.getRoute | train | public function getRoute($name, array $args = [])
{
if (!isset($this->names[$name])) {
return null;
}
$route = $this->callbacks[$this->names[$name]];
if (strpos($route->pattern, '(') === false) {
// If we don't have any route parameters, just return the patt... | php | {
"resource": ""
} |
q7079 | Router.regexifyPattern | train | protected function regexifyPattern($pattern)
{
preg_match_all('/(\/?)\(:([^)]*)\)(\??)/', $pattern, $regExPatterns, PREG_SET_ORDER, 0);
$pattern = preg_quote($pattern, '/');
foreach ($regExPatterns as $regExPattern) {
if (!empty($regExPattern[2]) && key_exists($regExPattern[2],... | php | {
"resource": ""
} |
q7080 | Router.getRouteObject | train | protected function getRouteObject($pattern, $method)
{
foreach (['REDIRECT', $method, 'ANY'] as $verb) {
if (array_key_exists($verb, $this->routes[$pattern])) {
$index = $this->routes[$pattern][$verb];
return $this->callbacks[$index];
}
}
... | php | {
"resource": ""
} |
q7081 | Router.getMatchArgs | train | protected function getMatchArgs(array $match)
{
// Remove the first element, the matching regex
array_shift($match);
// Iterate through the arguments and remove any unwanted slashes
foreach ($match as &$arg) {
$arg = trim($arg, '/');
}
return $match;
... | php | {
"resource": ""
} |
q7082 | Router.storeRoute | train | protected function storeRoute(array $methods, array $route)
{
$this->callbacks[] = (object)$route;
$index = count($this->callbacks) - 1;
if (!isset($this->routes[$route['pattern']])) {
$this->routes[$route['pattern']] = [];
}
if ($route['name']) {
... | php | {
"resource": ""
} |
q7083 | Log.interpolate | train | protected function interpolate($message, $context = array())
{
$replace = array();
foreach ($context as $key => $value) {
$replace['{' . $key . '}'] = $value;
}
return strtr($message, $replace);
} | php | {
"resource": ""
} |
q7084 | CRUDExtensionResolverPlugin.resolveInterfaceExtension | train | protected function resolveInterfaceExtension(InterfaceDefinition $definition, Endpoint $endpoint): void
{
$bundleNamespace = ClassUtils::relatedBundleNamespace($definition->getClass());
$extensionClass = ClassUtils::applyNamingConvention($bundleNamespace, 'Extension', null, $definition->getName().'E... | php | {
"resource": ""
} |
q7085 | CRUDExtensionResolverPlugin.resolveObjectRealInterfaceExtensions | train | protected function resolveObjectRealInterfaceExtensions(ClassAwareDefinitionInterface $definition): void
{
$class = $definition->getClass();
if (class_exists($class)) {
$refClass = new \ReflectionClass($definition->getClass());
if ($interfaces = $refClass->getInterfaceNames(... | php | {
"resource": ""
} |
q7086 | Apache_Solr_Service.getHttpTransport | train | public function getHttpTransport()
{
// lazy load a default if one has not be set
if ($this->_httpTransport === false)
{
require_once(dirname(__FILE__) . '/HttpTransport/FileGetContents.php');
$this->_httpTransport = new Apache_Solr_HttpTransport_FileGetContents();
}
return $this->_httpTransport;
} | php | {
"resource": ""
} |
q7087 | TranslatorChain.add | train | public function add(TranslatorInterface $translator)
{
$hash = spl_object_hash($translator);
$this->translators[$hash] = $translator;
return $this;
} | php | {
"resource": ""
} |
q7088 | TranslatorChain.remove | train | public function remove(TranslatorInterface $translator)
{
$hash = spl_object_hash($translator);
unset($this->translators[$hash]);
return $this;
} | php | {
"resource": ""
} |
q7089 | View.loadFile | train | public function loadFile($filename) {
$this->filename = $filename;
// If a cache directory was specified,
// try to load from it
if ($this->cachePath) {
if (! $this->templatesRoot) {
$this->templatesRoot = dirname($filename);
}
$cacheFile = $this->makeCacheFilename($thi... | php | {
"resource": ""
} |
q7090 | View.parse | train | public function parse() {
if($this->bParsed) {
return;
}
if ($this->replacements) {
// We cannot rely of html_entity_decode,
// because it would replace & and < as well,
// whereas we need to keep them unmodified.
// We must do it manually, with a modifie... | php | {
"resource": ""
} |
q7091 | View.makeCacheFilename | train | private function makeCacheFilename($cachePath, $templatesRoot, $filename, $mkdir = false)
{
// If the template filename is relative (ie. not starting by / and not specifying a scheme)
// then we first prefis it with the current working directory. And then we continue as if
// absolute.
... | php | {
"resource": ""
} |
q7092 | View.render | train | public function render() {
if(! $this->bParsed) {
$this->parse();
}
if (! $this->rootNode) {
throw new XMLParsingException('No template file loaded', 0);
}
$context = new Context($this);
// DOCTYPE
// The doctype is necessarily on the root tag, declared as an attribute, example:
... | php | {
"resource": ""
} |
q7093 | View.setCachePath | train | public function setCachePath($path, $templatesRoot = null) {
// Suppress the trailing slash
$this->cachePath = preg_replace('#/+$#', '', $path);
$this->templatesRoot = preg_replace('#/+$#', '', $templatesRoot);
} | php | {
"resource": ""
} |
q7094 | View.cdataHandler | train | private function cdataHandler($xmlParser, $cdata) {
//Last element in stack = parent element of the CDATA.
$currentElement = $this->stack[count($this->stack)-1];
$currentElement->appendCDataChild($cdata);
// hhvm invokes several cdata chunks if they contain \n
$this->previousCData .= $cdata;
} | php | {
"resource": ""
} |
q7095 | Feed.getParameter | train | public function getParameter($paramName) {
if(isset($this->params[$paramName])) {
return $this->params[$paramName];
}
return null;
} | php | {
"resource": ""
} |
q7096 | BaseGateway.getState | train | protected function getState($key)
{
if (!Yii::$app->has('session')) {
return null;
}
/* @var \yii\web\Session $session */
$session = Yii::$app->get('session');
$key = $this->getStateKeyPrefix() . $key;
$value = $session->get($key);
return $value;
... | php | {
"resource": ""
} |
q7097 | BaseGateway.removeState | train | protected function removeState($key)
{
if (!Yii::$app->has('session')) {
return true;
}
/* @var \yii\web\Session $session */
$session = Yii::$app->get('session');
$key = $this->getStateKeyPrefix() . $key;
$session->remove($key);
return true;
} | php | {
"resource": ""
} |
q7098 | CashAddress.pubKeyHashFromKey | train | public static function pubKeyHashFromKey($prefix, $publicKey)
{
$length = strlen($publicKey);
if ($length === 33) {
if ($publicKey[0] !== "\x02" && $publicKey[0] !== "\x03") {
throw new CashAddressException("Invalid public key");
}
} else if ($length =... | php | {
"resource": ""
} |
q7099 | Utility.replaceParameters | train | static function replaceParameters(array $paramsInfo, array $params): array {
if(\count($params) !== \count($paramsInfo)) {
throw new \Plasma\Exception('Insufficient amount of parameters passed, expected '.\count($paramsInfo).', got '.\count($params));
}
$realParams = array()... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.