_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30000 | ReflectionAutowire.getDependencies | train | protected function getDependencies(array $identifiers): array
{
$dependencies = [];
foreach ($identifiers as $index => $identifier) {
$dependencies[$index] = !$identifier->optional || $this->container->has($identifier->key)
? $this->container->get($identifier->key)
... | php | {
"resource": ""
} |
q30001 | ReflectionAutowire.instantiate | train | public function instantiate(string $class, ...$args)
{
$refl = $this->reflection->reflectClass($class);
$dependencyIds = $this->determineDependencies($refl, count($args));
$dependencies = $args + $this->getDependencies($dependencyIds);
return $refl->newInstanceArgs($dependencies);
... | php | {
"resource": ""
} |
q30002 | Collection.toArray | train | public function toArray()
{
if (\is_array($this->data)) {
return $this->data;
}
if ($this->data instanceof \ArrayIterator) {
return iterator_to_array($this->data, false);
}
if ($this->data instanceof \IteratorAggregate) {
return iterator_... | php | {
"resource": ""
} |
q30003 | RemoteObject.newFromJSON | train | public static function newFromJSON($data, $token, $url) {
$object = new RemoteObject($data['name']);
$object->setContentType($data['content_type']);
$object->contentLength = (int) $data['bytes'];
$object->etag = (string) $data['hash'];
$object->lastModified = strtotime($data['last_modified']);
... | php | {
"resource": ""
} |
q30004 | RemoteObject.newFromHeaders | train | public static function newFromHeaders($name, $headers, $token, $url, $cdnUrl = NULL, $cdnSslUrl = NULL) {
$object = new RemoteObject($name);
//$object->allHeaders = $headers;
$object->setHeaders($headers);
//throw new \Exception(print_r($headers, TRUE));
// Fix inconsistant header.
if (isset(... | php | {
"resource": ""
} |
q30005 | RemoteObject.useCDN | train | public function useCDN($url, $sslUrl) {
$this->cdnUrl = $url;
$this->cdnSslUrl = $sslUrl;
return $this;
} | php | {
"resource": ""
} |
q30006 | RemoteObject.url | train | public function url($cached = FALSE, $useSSL = TRUE) {
if ($cached && !empty($this->cdnUrl)) {
return $useSSL ? $this->cdnSslUrl : $this->cdnUrl;
}
return $this->url;
} | php | {
"resource": ""
} |
q30007 | RemoteObject.filterHeaders | train | public function filterHeaders(&$headers) {
$unset = array();
foreach ($headers as $name => $value) {
$lower = strtolower($name);
if (isset($this->reservedHeaders[$lower])) {
$unset[] = $name;
}
}
foreach ($unset as $u) {
unset($headers[$u]);
}
return $this;
} | php | {
"resource": ""
} |
q30008 | RemoteObject.removeHeaders | train | public function removeHeaders($keys) {
foreach ($keys as $key) {
unset($this->allHeaders[$key]);
unset($this->additionalHeaders[$key]);
}
return $this;
} | php | {
"resource": ""
} |
q30009 | RemoteObject.content | train | public function content() {
// XXX: This allows local overwrites. Is this a good idea?
if (!empty($this->content)) {
return $this->content;
}
// Get the object, content included.
$response = $this->fetchObject(TRUE);
$content = $response->content();
// Checksum the content.
// ... | php | {
"resource": ""
} |
q30010 | RemoteObject.stream | train | public function stream($refresh = FALSE) {
// If we're working on local content, return that content wrapped in
// a fake IO stream.
if (!$refresh && isset($this->content)) {
return $this->localFileStream();
}
// Otherwise, we fetch a fresh version from the remote server and
// return it... | php | {
"resource": ""
} |
q30011 | RemoteObject.localFileStream | train | protected function localFileStream() {
$tmp = fopen('php://temp', 'rw');
fwrite($tmp, $this->content(), $this->contentLength());
rewind($tmp);
return $tmp;
} | php | {
"resource": ""
} |
q30012 | RemoteObject.isDirty | train | public function isDirty() {
// If there is no content, the object can't be dirty.
if (!isset($this->content)) {
return FALSE;
}
// Content is dirty iff content is set, and it is
// different from the original content. Note that
// we are using the etag from the original headers.
if (... | php | {
"resource": ""
} |
q30013 | RemoteObject.refresh | train | public function refresh($fetchContent = FALSE) {
// Kill old content.
unset($this->content);
$response = $this->fetchObject($fetchContent);
if ($fetchContent) {
$this->setContent($response->content());
}
return $this;
} | php | {
"resource": ""
} |
q30014 | RemoteObject.fetchObject | train | protected function fetchObject($fetchContent = FALSE) {
$method = $fetchContent ? 'GET' : 'HEAD';
$client = \HPCloud\Transport::instance();
$headers = array(
'X-Auth-Token' => $this->token,
);
if (empty($this->cdnUrl)) {
$response = $client->doRequest($this->url, $method, $headers);
... | php | {
"resource": ""
} |
q30015 | RemoteObject.extractFromHeaders | train | protected function extractFromHeaders($response) {
$this->setContentType($response->header('Content-Type', $this->contentType()));
$this->lastModified = strtotime($response->header('Last-Modified', 0));
$this->etag = $response->header('Etag', $this->etag);
$this->contentLength = (int) $response->header(... | php | {
"resource": ""
} |
q30016 | SwishRouter.routable | train | private function routable() : bool
{
$routesFolder = config('app.dir') . 'routes' . DIRECTORY_SEPARATOR;
if (!file_exists($routesFolder . 'api.php' )) {
$this->exception('Could not find api routes.');
return false;
}
if (!file_exists($routesFolder . 'web.php' )) {
$this->exception(... | php | {
"resource": ""
} |
q30017 | eZFlowOperations.cleanupRemovedItems | train | public static function cleanupRemovedItems()
{
$db = eZDB::instance();
// Find items that have been moved to trash or deleted
$itemArray = array();
$offset = 0;
$limit = 50;
do
{
$items = $db->arrayQuery( 'SELECT node_id FROM ezm_pool', array( 'off... | php | {
"resource": ""
} |
q30018 | Base.buildQuery | train | protected function buildQuery($params, $separator = '&', $noQuotes = true, $subList = false)
{
if (empty($params)) {
return '';
}
//encode both keys and values
$keys = $this->encode(array_keys($params));
$values = $this->encode(array_values($params));
$p... | php | {
"resource": ""
} |
q30019 | Base.encode | train | protected function encode($string)
{
if (is_array($string)) {
foreach ($string as $i => $value) {
$string[$i] = $this->encode($value);
}
return $string;
}
if (is_scalar($string)) {
return str_replace('%7E', '~', rawurlencode($... | php | {
"resource": ""
} |
q30020 | Base.parseString | train | protected function parseString($string)
{
$array = array();
if (strlen($string) < 1) {
return $array;
}
// Separate single string into an array of "key=value" strings
$keyvalue = explode('&', $query_string);
// Separate each "key=value" string into an ... | php | {
"resource": ""
} |
q30021 | Validate.cardNumber | train | public static function cardNumber(Validator $validator, $data, $pattern, $rule)
{
foreach (Validator::getValues($data, $pattern) as $attribute => $value) {
if (null === $value || empty($value)) {
continue;
}
// Strip any non-digits (useful for credit card... | php | {
"resource": ""
} |
q30022 | Application.getConfig | train | public static function getConfig(array $appConfig = []) : array
{
$configs = DEPConfig::$appdir . 'config' . DIRECTORY_SEPARATOR . '*.php';
foreach (\glob($configs) as $config) {
$service = require $config;
if (is_array($service)) {
$path = basename($config);
$name = \substr($pat... | php | {
"resource": ""
} |
q30023 | BlockManager.getHtml | train | final public function getHtml()
{
$result = $this->renderHtml();
if (is_array($result) && array_key_exists('RenderView', $result)) {
$result['RenderView']['options']['block_manager'] = $this;
}
return $result;
} | php | {
"resource": ""
} |
q30024 | BlockManager.toArray | train | public function toArray()
{
if (null === $this->alBlock) {
return array();
}
$content = $this->replaceHtmlCmsActive();
if (null === $content) {
$content = $this->getHtml();
}
$blockManager = array();
$blockManager["HideInEditMode"] = ... | php | {
"resource": ""
} |
q30025 | BlockManager.add | train | protected function add(array $values)
{
$values =
$this->dispatchBeforeOperationEvent(
'\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Block\BeforeBlockAddingEvent',
BlockEvents::BEFORE_ADD_BLOCK,
$values,
'exception_bl... | php | {
"resource": ""
} |
q30026 | BlockManager.edit | train | protected function edit(array $values)
{
$values =
$this->dispatchBeforeOperationEvent(
'\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Block\BeforeBlockEditingEvent',
BlockEvents::BEFORE_EDIT_BLOCK,
$values,
'exceptio... | php | {
"resource": ""
} |
q30027 | Setting.all | train | public function all() {
$query = new \Peyote\Select($this->db_table());
$query->columns('name');
$result = $this->db->fetch($query);
foreach($result as $r) {
$list[] = $r['name'];
}
return $list;
} | php | {
"resource": ""
} |
q30028 | Agent.check | train | public function check($userAgent = null)
{
// was a user agent passed? If not, use the server one
if (empty($userAgent))
{
$userAgent = $this->server['http_user_agent'];
}
// store the user agent
$this->userAgent = $userAgent;
// fetch the data
switch ($this->method)
{
case "browscap":
/... | php | {
"resource": ""
} |
q30029 | Agent.doesAcceptLanguage | train | public function doesAcceptLanguage($language = 'en')
{
return (in_array(strtolower($language), $this->getAcceptLanguages(), true)) ? true : false;
} | php | {
"resource": ""
} |
q30030 | Agent.doesAcceptCharset | train | public function doesAcceptCharset($charset = 'utf-8')
{
return (in_array(strtolower($charset), $this->getAcceptCharsets(), true)) ? true : false;
} | php | {
"resource": ""
} |
q30031 | Responses.registerTaxonomy | train | public function registerTaxonomy() {
$namePlural = __('Topics', 'customer-feedback');
$nameSingular = __('Topic', 'customer-feedback');
$labels = array(
'name' => $namePlural,
'singular_name' => $nameSingular,
'search_items' => sprintf(_... | php | {
"resource": ""
} |
q30032 | Responses.pageMetaBoxContent | train | public function pageMetaBoxContent()
{
global $post;
$parent = get_post_meta($post->ID, 'customer_feedback_page_reference', true);
$parent = get_post($parent);
echo '<p><a href="' . get_permalink($parent) . '">' . $parent->post_title . '</a> (' . get_permalink($parent) . ')</p>';
... | php | {
"resource": ""
} |
q30033 | Responses.addPageSummaryMetaBox | train | public function addPageSummaryMetaBox($postType, $post)
{
$allowedPostTypes = get_field('customer_feedback_posttypes', 'option');
if (!isset($post->ID) || (is_array($allowedPostTypes) && !in_array($postType, $allowedPostTypes))) {
return;
}
$answers = Responses::getResp... | php | {
"resource": ""
} |
q30034 | Responses.renderSummary | train | public function renderSummary($postId, $data)
{
$totalCount = 0;
echo '<table id="customer-feedback-summary" cellspacing="0" cellpadding="0"><tbody>';
foreach ($data['args']['results'] as $count) {
$totalCount += $count;
}
foreach ($data['args']['results'] as $a... | php | {
"resource": ""
} |
q30035 | Responses.listColumns | train | public function listColumns($columns)
{
$columns = array(
'cb' => '<input type="checkbox">',
'title' => __('Page', 'customer-feedback'),
'id' => __('ID', 'customer-feedback'),
'answer' => __('Answer', 'customer-feedback'),
'hasComment' =... | php | {
"resource": ""
} |
q30036 | Responses.listColumnsContent | train | public function listColumnsContent($column, $postId)
{
switch ($column) {
case 'id':
echo $postId;
break;
case 'answer':
if (get_post_meta($postId, 'customer_feedback_answer', true) == 'no') {
echo '<span style="colo... | php | {
"resource": ""
} |
q30037 | Responses.listColumnsSortingQuery | train | public function listColumnsSortingQuery($query)
{
if (!is_admin() || !$query->is_main_query() || $query->get('post_type') != $this->postTypeSlug) {
return;
}
if (!empty($_GET['feedback_topic'])) {
$query->set('tax_query', array(
'relation' => 'AND',
... | php | {
"resource": ""
} |
q30038 | Responses.submitResponse | train | public function submitResponse()
{
$insertedId = 'false';
$postId = (isset($_POST['postid']) && is_numeric($_POST['postid'])) ? $_POST['postid'] : null;
$answer = (isset($_POST['answer']) && strlen($_POST['answer']) > 0) ? $_POST['answer'] : null;
$cookieExpireDays = 5;
$coo... | php | {
"resource": ""
} |
q30039 | Responses.submitComment | train | public function submitComment()
{
$answerId = (isset($_POST['answerid']) && is_numeric($_POST['answerid'])) ? $_POST['answerid'] : null;
$postId = (isset($_POST['postid']) && is_numeric($_POST['postid'])) ? $_POST['postid'] : null;
$comment = (isset($_POST['comment']) && strlen($_POST['comme... | php | {
"resource": ""
} |
q30040 | Namespaces.setCurrentNamespace | train | public function setCurrentNamespace($sNamespace)
{
$this->sDirectory = '';
$this->sExtension = '';
if(key_exists($sNamespace, $this->aDirectories))
{
// Make sure there's only one '/' at the end of the string
$this->sDirectory = rtrim($this->aDirectories[$sNam... | php | {
"resource": ""
} |
q30041 | Response.errors | train | public function errors($errors)
{
$this->success = false;
$this->data['errors'] = $errors instanceof MessageBag
? $errors->toArray()
: $errors;
return $this;
} | php | {
"resource": ""
} |
q30042 | CustomerVarcharRepository.findAllByEntityId | train | public function findAllByEntityId($entityId)
{
// prepare the params
$params = array(ParamNames::ENTITY_ID => $entityId);
// load and return the customer varchar attributes with the passed entity ID
$this->customerVarcharsStmt->execute($params);
return $this->customerVarcha... | php | {
"resource": ""
} |
q30043 | Translator.addResources | train | public function addResources($dirs)
{
$finder = Finder::create()
->files()
->filter(function (\SplFileInfo $file) {
return 2 === substr_count($file->getBasename(), '.') && preg_match('/\.\w+$/', $file->getBasename());
})
->in($dirs)
;
... | php | {
"resource": ""
} |
q30044 | RelationOperator.getViaIds | train | public function getViaIds($select = null)
{
return (new Query())
->from($this->viaTable)
->select(($select ? : array_values($this->relationAttribute)))
->where($this->condition)
;
} | php | {
"resource": ""
} |
q30045 | RelationOperator.deleteViaIds | train | public function deleteViaIds($ids)
{
return !$ids ||
\Yii::$app->db->createCommand()->delete(
$this->viaTable,
array_merge($this->condition, [reset($this->relationAttribute) => $ids])
)->execute();
} | php | {
"resource": ""
} |
q30046 | RelationOperator.addViaIds | train | public function addViaIds($ids, $defaultData = [])
{
if (!$ids) {
return true;
}
foreach ($ids as $key => $id) {
$id = is_array($id)
? $id
: [reset($this->relationAttribute) => $id];
$ids[$key] = array_merge($id, $this->cond... | php | {
"resource": ""
} |
q30047 | RelationOperator.cloneRelation | train | public function cloneRelation(ActiveRecord $target, $except = ['id'])
{
$ids = $this->getViaIds(['*'])->all();
array_walk($ids, function (&$v) use ($except) {
$v = array_diff_key($v, array_flip($except));
});
return (new static($target, $this->relationName))->addViaIds($i... | php | {
"resource": ""
} |
q30048 | RelationOperator.cloneRelations | train | public static function cloneRelations($sources, $clones, $relations = [])
{
if (!is_array($sources)) {
$sources = [$sources];
$clones = [$clones];
}
foreach ($sources as $k => $source) {
foreach ($relations as $j => $name) {
list($name, $ex... | php | {
"resource": ""
} |
q30049 | Twig.add_template_directory | train | public function add_template_directory($directory, $namespace = null) {
if ($this->filesystem_loader === null) {
$this->filesystem_loader = new \Twig_Loader_Filesystem($directory);
}
if ($namespace === null) {
$this->filesystem_loader->addPath($directory);
} else {
$this->filesystem_loader->addPath($d... | php | {
"resource": ""
} |
q30050 | ExposableTypeMap.getType | train | public function getType($classIdentifier)
{
if (array_key_exists($classIdentifier, $this->classIdentifierToTypeNameMap)) {
return $this->classIdentifierToTypeNameMap[$classIdentifier];
} else {
throw new FormatNotSupportedException('There is no target type for class name "' .... | php | {
"resource": ""
} |
q30051 | ResourceFreeListener.onKernelRequest | train | public function onKernelRequest(GetResponseEvent $event)
{
// checks if the backend is secured
$token = $this->securityContext->getToken();
if (null !== $token) {
// Check if the user has already been logged in
$user = $token->getUser();
if (null !== $use... | php | {
"resource": ""
} |
q30052 | PhpMessageSource.loadMessages | train | protected function loadMessages($category, $language)
{
$messageFile = $this->getMessageFilePath($category, $language);
$messages = $this->loadMessagesFromFile($messageFile);
$fallbackLanguage = substr($language, 0, 2);
if ($fallbackLanguage != $language) {
$fallbackMess... | php | {
"resource": ""
} |
q30053 | MySQLDriver.getOne | train | public function getOne($field = null)
{
$row = $this->statement->fetch(PDO::FETCH_ASSOC);
return null === $field ? $row : $row[$field];
} | php | {
"resource": ""
} |
q30054 | MySQLDriver.getModel | train | public function getModel($model)
{
$model = str_replace(':', '\\', $model);
if (!class_exists($model)) {
throw new ModelNotFoundException($model);
}
return new $model($this);
} | php | {
"resource": ""
} |
q30055 | CustomFieldResultLibrary.storeCustomFieldResults | train | public static function storeCustomFieldResults($request, $customFieldGroup, $resource, $objectId, $lang)
{
$customFieldGroup = CustomFieldGroup::find($customFieldGroup);
$customFields = CustomField::getRecords(['lang_026' => $lang, 'group_id_026' => $customFieldGroup->id_025]);
$data... | php | {
"resource": ""
} |
q30056 | TreeColumn.getDataCellValue | train | public function getDataCellValue($model, $key, $index)
{
if ($this->value !== null) {
if (is_string($this->value)) {
return ArrayHelper::getValue($model, $this->value);
} else {
return call_user_func($this->value, $model, $key, $index, $this);
... | php | {
"resource": ""
} |
q30057 | ExtensionGenerator.generateExtension | train | public function generateExtension($namespace, $dir, $themeName, array $templates)
{
$themeBasename = str_replace('Bundle', '', $themeName);
$extensionAlias = Container::underscore($themeBasename);
$templateFiles = array_map(function ($template) { return basename($template["name"], '.html.tw... | php | {
"resource": ""
} |
q30058 | CssParserModelFactor.filter | train | public function filter($node)
{
$ret = array();
$items = $this->_combinator->filter($node, $this->_element->getTagName());
// filters items by element
foreach ($items as $item) {
if ($this->_element->match($item)) {
array_push($ret, $item);
}
... | php | {
"resource": ""
} |
q30059 | Tag.byName | train | public static function byName(
Client $client,
string $name
): self {
$tags = self::byNames(
$client,
[$name],
self::ORDER_NAME,
// null,
false
);
if (count($tags) === 0) {
throw new TagNotFou... | php | {
"resource": ""
} |
q30060 | Tag.byNames | train | public static function byNames(
Client $client,
array $names,
string $orderBy = self::ORDER_NAME,
bool $hideEmpty = true
): array {
if (!self::isValidOrderingMethod($orderBy)) {
throw new InvalidArgumentException('Invalid order method');
}
$query ... | php | {
"resource": ""
} |
q30061 | ServicePluginLoader.setResolverOptions | train | function setResolverOptions($options)
{
if (method_exists($this->_resolver(), 'with'))
$this->_resolver()->with($options);
return $this;
} | php | {
"resource": ""
} |
q30062 | ServicePluginLoader.Loader | train | static function Loader()
{
if (!self::$default_resolver) {
$resolver = new LoaderAggregate;
$resolver->attach(new LoaderMapResource, 100);
self::$default_resolver = $resolver;
}
return self::$default_resolver;
} | php | {
"resource": ""
} |
q30063 | AbstractResource.setTransformer | train | public function setTransformer($transformer)
{
if ($transformer !== null) {
if (!$this->isValidTransformer($transformer)) {
throw new InvalidTransformerException('Transformer must be a callable or implement TransformerInterface');
}
}
$this->transform... | php | {
"resource": ""
} |
q30064 | AbstractResource.isValidTransformer | train | public function isValidTransformer($transformer): bool
{
if ($transformer instanceof TransformerInterface) {
return true;
}
if (\is_callable($transformer)) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q30065 | Collection.paginate | train | public function paginate($perPage, $page = null)
{
if (empty($page)) {
$page = request('page', 1);
}
$offset = ($page * $perPage) - $perPage;
$collection = $this->all();
$newItems = array_slice($collection, $offset, $perPage, true);
return $this->createCh... | php | {
"resource": ""
} |
q30066 | Aes.decrypt | train | public function decrypt($y)
{
$t = ""; // 16-byte block
$x = ""; // returned plain text;
// put a 16-byte block into t
$ysize = strlen($y);
for ($i = 0; $i < $ysize; $i += 16) {
for ($j = 0; $j < 16; $j++) {
if (($i + $j) < $ysize) $t[$j] = $y[$i ... | php | {
"resource": ""
} |
q30067 | Configuration.addSelect2 | train | private function addSelect2(ArrayNodeDefinition $rootNode)
{
$rootNode
->children()
->arrayNode('select2')
->canBeUnset()
->treatNullLike(['enabled' => true])
->treatTrueLike(['enabled' => true])
->ad... | php | {
"resource": ""
} |
q30068 | AbstractSql.getModel | train | public function getModel($table, $name, $value)
{
//get the row
$result = $this->getRow($table, $name, $value);
if (is_null($result)) {
return null;
}
return $this->model()->setTable($table)->set($result);
} | php | {
"resource": ""
} |
q30069 | AbstractSql.loadPDO | train | public static function loadPDO(PDO $connection)
{
$reflection = new ReflectionClass(static::class);
$instance = $reflection->newInstanceWithoutConstructor();
return $instance->connect($connection);
} | php | {
"resource": ""
} |
q30070 | AbstractSql.transaction | train | public function transaction($callback)
{
$connection = $this->getConnection();
$connection->beginTransaction();
if ($callback instanceof Closure) {
$callback = $callback->bindTo($this, get_class($this));
}
if (call_user_func($callback, $this) === false) {
... | php | {
"resource": ""
} |
q30071 | AbstractSql.updateRows | train | public function updateRows($table, array $settings, $filters = null, $bind = true)
{
//build the query
$query = $this->getUpdateQuery($table);
//foreach settings
foreach ($settings as $key => $value) {
//if value is not a vulnerability
if (is_null($value) || ... | php | {
"resource": ""
} |
q30072 | RunAllCommand.execute | train | public function execute(Arguments $args, ConsoleIo $io)
{
$questions = $args->getOption('force') ? Hash::extract($this->questions, '{n}[default=Y]') : $this->questions;
foreach ($questions as $question) {
is_true_or_fail(['question', 'default', 'command'] === array_keys($question), __d(... | php | {
"resource": ""
} |
q30073 | Route.getTarget | train | public function getTarget(Args $args)
{
if (!is_object($this->target) && $this->getClass()) {
$class = $this->getClass();
$targetObject = new $class($args);
if (!$targetObject instanceof Command) {
$command = $this->getCommand();
throw new ... | php | {
"resource": ""
} |
q30074 | PageManager.add | train | protected function add(array $values)
{
$values =
$this->dispatchBeforeOperationEvent(
'\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\BeforePageAddingEvent',
PageEvents::BEFORE_ADD_PAGE,
$values,
array(
... | php | {
"resource": ""
} |
q30075 | PageManager.resetHome | train | protected function resetHome()
{
try {
$page = $this->pageRepository->homePage();
if (null !== $page) {
return $this->pageRepository
->setRepositoryObject($page)
->save(array('IsHome' => 0));
}
... | php | {
"resource": ""
} |
q30076 | IdentityServices.authenticate | train | public function authenticate(array $ops) {
$url = $this->url() . '/tokens';
$envelope = array(
'auth' => $ops,
);
$body = json_encode($envelope);
$headers = array(
'Content-Type' => 'application/json',
'Accept' => self::ACCEPT_TYPE,
'Content-Length' => strlen($body),
);... | php | {
"resource": ""
} |
q30077 | IdentityServices.authenticateAsUser | train | public function authenticateAsUser($username, $password, $tenantId = NULL, $tenantName = NULL) {
$ops = array(
'passwordCredentials' => array(
'username' => $username,
'password' => $password,
),
);
// If a tenant ID is provided, added it to the auth array.
if (!empty($tenan... | php | {
"resource": ""
} |
q30078 | IdentityServices.authenticateAsAccount | train | public function authenticateAsAccount($account, $key, $tenantId = NULL, $tenantName = NULL) {
$ops = array(
'apiAccessKeyCredentials' => array(
'accessKey' => $account,
'secretKey' => $key,
),
);
if (!empty($tenantId)) {
$ops['tenantId'] = $tenantId;
}
elseif (!emp... | php | {
"resource": ""
} |
q30079 | IdentityServices.isExpired | train | public function isExpired() {
$details = $this->tokenDetails();
if (empty($details['expires'])) {
return TRUE;
}
$currentDateTime = new \DateTime('now');
$expireDateTime = new \DateTime($details['expires']);
return $currentDateTime > $expireDateTime;
} | php | {
"resource": ""
} |
q30080 | IdentityServices.serviceCatalog | train | public function serviceCatalog($type = NULL) {
// If no type is specified, return the entire
// catalog.
if (empty($type)) {
return $this->serviceCatalog;
}
$list = array();
foreach ($this->serviceCatalog as $entry) {
if ($entry['type'] == $type) {
$list[] = $entry;
}
... | php | {
"resource": ""
} |
q30081 | IdentityServices.tenants | train | public function tenants($token = NULL) {
$url = $this->url() . '/tenants';
if (empty($token)) {
$token = $this->token();
}
$headers = array(
'X-Auth-Token' => $token,
'Accept' => 'application/json',
//'Content-Type' => 'application/json',
);
$client = \HPCloud\Transpor... | php | {
"resource": ""
} |
q30082 | IdentityServices.rescopeUsingTenantId | train | public function rescopeUsingTenantId($tenantId) {
$url = $this->url() . '/tokens';
$token = $this->token();
$data = array(
'auth' => array(
'tenantId' => $tenantId,
'token' => array(
'id' => $token,
),
),
);
$body = json_encode($data);
$headers = ar... | php | {
"resource": ""
} |
q30083 | IdentityServices.handleResponse | train | protected function handleResponse($response) {
$json = json_decode($response->content(), TRUE);
// print_r($json);
$this->tokenDetails = $json['access']['token'];
$this->userDetails = $json['access']['user'];
$this->serviceCatalog = $json['access']['serviceCatalog'];
return $this;
} | php | {
"resource": ""
} |
q30084 | phoxy.Start | train | public static function Start()
{
global $_SERVER;
if (!phoxy_conf()["is_ajax_request"] && phoxy_conf()["api_csrf_prevent"])
die("Request aborted due API direct CSRF warning");
if (phoxy_conf()["buffered_output"])
ob_start();
global $_GET;
$get_param = phoxy::Config()["get_api_param"]... | php | {
"resource": ""
} |
q30085 | ActiveTheme.getThemeBootstrapVersion | train | public function getThemeBootstrapVersion($themeName = null)
{
if (null === $themeName) {
if (null !== $this->bootstrapVersion) {
return $this->bootstrapVersion;
}
$themeName = $this->getActiveThemeBackend()->getThemeName();
}
$this->boots... | php | {
"resource": ""
} |
q30086 | Deployer.checkTargetFolders | train | protected function checkTargetFolders(array $options)
{
$this->fileSystem->mkdir($options["assetsDir"]);
$this->fileSystem->mkdir($options["configDir"]);
$this->fileSystem->mkdir($options["deployDir"]);
} | php | {
"resource": ""
} |
q30087 | Deployer.savePages | train | protected function savePages(Theme $theme, array $options)
{
$pages = $this->pageTreeCollection->getPages();
$basePages = $this->pageTreeCollection->getBasePages();
$options["type"] = "Pages";
if ( ! $this->doSavePages($pages, $theme, $options)) {
return false;
}... | php | {
"resource": ""
} |
q30088 | Comparator.compare | train | public static function compare($left, $right)
{
if (self::isContainer($left) && self::isContainer($right)) {
$leftFields = self::normalize($left);
$rightFields = self::normalize($right);
if (count($leftFields) !== count($rightFields)) {
return false;
... | php | {
"resource": ""
} |
q30089 | ArgumentsResolver.resolve | train | public function resolve(array $parameters) : array
{
if (!$number = $this->reflection->getNumberOfParameters()) {
return [];
}
$arguments = \array_fill(0, $number, null);
foreach ($this->getParameters() as $pos => $parameter) {
$result = $this->match($parame... | php | {
"resource": ""
} |
q30090 | DeleteSeoListener.onBeforeDeletePageCommit | train | public function onBeforeDeletePageCommit(BeforeDeletePageCommitEvent $event)
{
if ($event->isAborted()) {
return;
}
$pageManager = $event->getContentManager();
$pageRepository = $pageManager->getPageRepository();
try {
$languages = $this->languageRep... | php | {
"resource": ""
} |
q30091 | AjaxFormController.ajaxChoiceListAction | train | public function ajaxChoiceListAction(Request $request, $type)
{
return AjaxChoiceListHelper::generateResponse($request,
$this->get('form.factory')->createBuilder($type, null,
['select2' => ['enabled' => true, 'ajax' => true]]));
} | php | {
"resource": ""
} |
q30092 | BlocksRemover.remove | train | public function remove($idBlock, BlockManagersCollection $blockManagersCollection)
{
$blockManagerInfo = $blockManagersCollection->getManagerInfoByBlockId($idBlock);
$blockManager = $blockManagerInfo['manager'];
// @codeCoverageIgnoreStart
if (null === $blockManager) {
re... | php | {
"resource": ""
} |
q30093 | BlocksRemover.clear | train | public function clear(BlockManagersCollection $blockManagersCollection)
{
// @codeCoverageIgnoreStart
if ($blockManagersCollection->count() == 0) {
return null;
}
// @codeCoverageIgnoreEnd
try {
$result = null;
$this->blockRepository->star... | php | {
"resource": ""
} |
q30094 | StreamWrapper.localFilename | train | public static function localFilename(StreamInterface $stream)
{
self::register();
$uri = 'spiral://' . spl_object_hash($stream);
self::$uris[$uri] = $stream;
return $uri;
} | php | {
"resource": ""
} |
q30095 | StreamWrapper.getResource | train | public static function getResource(StreamInterface $stream)
{
$mode = null;
if ($stream->isReadable()) {
$mode = 'r';
}
if ($stream->isWritable()) {
$mode = !empty($mode) ? 'r+' : 'w';
}
if (empty($mode)) {
throw new WrapperExcept... | php | {
"resource": ""
} |
q30096 | StreamWrapper.releaseUri | train | public static function releaseUri($uri)
{
if ($uri instanceof StreamInterface) {
$uri = 'spiral://' . spl_object_hash($uri);
}
unset(self::$uris[$uri]);
} | php | {
"resource": ""
} |
q30097 | Scope.availableIncludeKeys | train | public function availableIncludeKeys(): array
{
$availableKeys = [];
if (($transformer = $this->transformer()) !== null && ($transformer instanceof TransformerInterface)) {
$availableKeys = $transformer->getAvailableIncludes();
}
return $availableKeys;
} | php | {
"resource": ""
} |
q30098 | Scope.resolvedRelationshipKeys | train | public function resolvedRelationshipKeys(): array
{
$includeMap = $this->includeMap();
$keys = [];
foreach ($this->resolvedIncludeKeys() as $includeKey) {
$relations = $includeMap[$includeKey]['relation'] ?? [];
if (\count($relations) > 0) {
array_pus... | php | {
"resource": ""
} |
q30099 | Scope.filterData | train | public function filterData(array $data)
{
// Filter the sparse field-set if we have a specific list of properties
// defined that we want.
$filterProps = $this->filterProps();
if (!empty($filterProps)) {
$filteredData = array_filter($data, function ($key) use ($filterProp... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.