_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q234800 | eZPlatformSearch.cleanup | train | public function cleanup()
{
// Indexing is not implemented in eZ Publish 5 legacy search engine
if ( $this->searchHandler instanceof LegacyHandler )
{
$db = eZDB::instance();
$db->begin();
$db->query( "DELETE FROM ezsearch_word" );
$db->query( ... | php | {
"resource": ""
} |
q234801 | eZPlatformSearch.updateNodeSection | train | public function updateNodeSection( $nodeID, $sectionID )
{
$contentObject = eZContentObject::fetchByNodeID( $nodeID );
eZContentOperationCollection::registerSearchObject( $contentObject->attribute( 'id' ) );
} | php | {
"resource": ""
} |
q234802 | eZPlatformSearch.updateNodeVisibility | train | public function updateNodeVisibility( $nodeID, $action )
{
$node = eZContentObjectTreeNode::fetch( $nodeID );
eZContentOperationCollection::registerSearchObject( $node->attribute( 'contentobject_id' ) );
$params = array(
'Depth' => 1,
'DepthOperator' => 'eq',
... | php | {
"resource": ""
} |
q234803 | eZPlatformSearch.swapNode | train | public function swapNode( $nodeID, $selectedNodeID, $nodeIdList = array() )
{
$contentObject1 = eZContentObject::fetchByNodeID( $nodeID );
$contentObject2 = eZContentObject::fetchByNodeID( $selectedNodeID );
eZContentOperationCollection::registerSearchObject( $contentObject1->attribute( 'id... | php | {
"resource": ""
} |
q234804 | eZPlatformSearch.isSearchPartIncomplete | train | function isSearchPartIncomplete( $part )
{
if ( $this->searchHandler instanceof LegacyHandler )
{
$searchEngine = new eZSearchEngine();
return $searchEngine->isSearchPartIncomplete( $part );
}
return false;
} | php | {
"resource": ""
} |
q234805 | eZPlatformSearch.normalizeText | train | public function normalizeText( $text )
{
if ( $this->searchHandler instanceof LegacyHandler )
{
$searchEngine = new eZSearchEngine();
return $searchEngine->normalizeText( $text );
}
return $text;
} | php | {
"resource": ""
} |
q234806 | CassandraClient.getSSLBuilder | train | protected function getSSLBuilder($config)
{
if (empty($config)) {
return null;
}
$ssl = \Cassandra::ssl();
$serverCert = array_get($config, 'server_cert_path');
$clientCert = array_get($config, 'client_cert_path');
$privateKey = array_get($config, 'privat... | php | {
"resource": ""
} |
q234807 | CassandraClient.listTables | train | public function listTables()
{
$tables = $this->keyspace->tables();
$out = [];
foreach ($tables as $table) {
$out[] = ['table_name' => $table->name()];
}
return $out;
} | php | {
"resource": ""
} |
q234808 | CassandraClient.extractPaginationInfo | train | protected function extractPaginationInfo(& $cql)
{
$words = explode(' ', $cql);
$limit = 0;
$offset = 0;
$limitKey = null;
foreach ($words as $key => $word) {
if ('limit' === strtolower($word) && is_numeric($words[$key + 1])) {
$limit = (int)$words... | php | {
"resource": ""
} |
q234809 | PHPUnitPreparer.handleBootstrap | train | protected function handleBootstrap($filename, $syntaxCheck = false)
{
try {
\PHPUnit_Util_Fileloader::checkAndLoad($filename, $syntaxCheck);
} catch (RuntimeException $e) {
\PHPUnit_TextUI_TestRunner::showError($e->getMessage());
}
} | php | {
"resource": ""
} |
q234810 | PopulatorCommand.addSeeder | train | public function addSeeder(AbstractPopulator $seeder)
{
$seeder->setPopulator($this);
$seeder->setDatabase($this->database);
$seeder->setFaker($this->faker);
$this->seeders[] = $seeder;
} | php | {
"resource": ""
} |
q234811 | SmartCropClass.canvasImageScale | train | public function canvasImageScale()
{
$imageOriginalWidth = imagesx($this->oImg);
$imageOriginalHeight = imagesy($this->oImg);
$scale = min($imageOriginalWidth / $this->options ['width'], $imageOriginalHeight / $this->options ['height']);
$this->options ['cropWidth'] = ceil($this->op... | php | {
"resource": ""
} |
q234812 | SmartCropClass.canvasImageResample | train | public function canvasImageResample($width, $height)
{
$oCanvas = imagecreatetruecolor($width, $height);
imagecopyresampled($oCanvas, $this->oImg, 0, 0, 0, 0, $width, $height, imagesx($this->oImg), imagesy($this->oImg));
$this->oImg = $oCanvas;
return $this;
} | php | {
"resource": ""
} |
q234813 | SmartCropClass.analyse | train | public function analyse()
{
$result = [];
$w = $this->w = imagesx($this->oImg);
$h = $this->h = imagesy($this->oImg);
$this->od = new \SplFixedArray ($h * $w * 3);
$this->aSample = new \SplFixedArray ($h * $w);
for ($y = 0; $y < $h; $y++)
{
for ($... | php | {
"resource": ""
} |
q234814 | SmartCropClass.generateCrops | train | public function generateCrops()
{
$w = imagesx($this->oImg);
$h = imagesy($this->oImg);
$results = [];
$minDimension = min($w, $h);
$cropWidth = empty ($this->options ['cropWidth']) ? $minDimension : $this->options ['cropWidth'];
$cropHeight = empty ($this->options ['... | php | {
"resource": ""
} |
q234815 | SmartCropClass.score | train | public function score($output, $crop)
{
$result = [
'detail' => 0,
'saturation' => 0,
'skin' => 0,
'boost' => 0,
'total' => 0
];
$downSample = $this->options ['scoreDownSample'];
$invDownSample = 1 / $downSample;
$o... | php | {
"resource": ""
} |
q234816 | Replacer.swap | train | public function swap(array $replacements)
{
foreach ($replacements as $from => $to) {
$this->replace($from, $this->normalize($to));
}
} | php | {
"resource": ""
} |
q234817 | Replacer.replace | train | protected function replace($from, $to)
{
if ($this->file->getExtension() === 'json') {
$from = addslashes($from);
}
file_put_contents(
$this->file->getRealPath(),
str_replace($from, $to, $this->file->getContents())
);
} | php | {
"resource": ""
} |
q234818 | Repository.delete | train | public function delete(IRow &$row)
{
$res = $this->getTable()->wherePrimary($row->getPrimary())->delete();
$oldValues = [];
if ($row instanceof ActiveRow) {
$oldValues = $row->toArray();
}
if (!$res) {
return false;
}
if ($this->audit... | php | {
"resource": ""
} |
q234819 | Repository.insert | train | public function insert($data)
{
$row = $this->getTable()->insert($data);
if (!$row instanceof IRow) {
return $row;
}
if ($this->auditLogRepository) {
$to = $this->filterValues($this->excludeColumns((array)$data));
$data = [
'versi... | php | {
"resource": ""
} |
q234820 | Repository.filterValues | train | private function filterValues(array $values)
{
foreach ($values as $i => $field) {
if (is_bool($field)) {
$values[$i] = (int) $field;
} elseif ($field instanceof \DateTime) {
$values[$i] = $field->format('Y-m-d H:i:s');
} elseif (!is_scalar... | php | {
"resource": ""
} |
q234821 | AuditHook.bind_manipulation_capture | train | public static function bind_manipulation_capture()
{
$current = DB::get_conn();
if (!$current || !$current->getConnector()->getSelectedDatabase() || @$current->isManipulationLoggingCapture) {
return;
} // If not yet set, or its already captured, just return
$type = get_c... | php | {
"resource": ""
} |
q234822 | AuditHook.onAfterPublish | train | public function onAfterPublish(&$original)
{
$member = Security::getCurrentUser();
if (!$member || !$member->exists()) {
return false;
}
$effectiveViewerGroups = '';
if ($this->owner->CanViewType === 'OnlyTheseUsers') {
$originalViewerGroups = $origin... | php | {
"resource": ""
} |
q234823 | AuditHook.onAfterUnpublish | train | public function onAfterUnpublish()
{
$member = Security::getCurrentUser();
if (!$member || !$member->exists()) {
return false;
}
$this->getAuditLogger()->info(sprintf(
'"%s" (ID: %s) unpublished %s "%s" (ID: %s)',
$member->Email ?: $member->Title,... | php | {
"resource": ""
} |
q234824 | AuditHook.afterMemberLoggedIn | train | public function afterMemberLoggedIn()
{
$this->getAuditLogger()->info(sprintf(
'"%s" (ID: %s) successfully logged in',
$this->owner->Email ?: $this->owner->Title,
$this->owner->ID
));
} | php | {
"resource": ""
} |
q234825 | AuditHook.authenticationFailed | train | public function authenticationFailed($data)
{
// LDAP authentication uses a "Login" POST field instead of Email.
$login = isset($data['Login'])
? $data['Login']
: (isset($data[Email::class]) ? $data[Email::class] : '');
if (empty($login)) {
return $this->... | php | {
"resource": ""
} |
q234826 | Renamer.replace | train | public function replace(array $replacements)
{
foreach ($this->files() as $file) {
(new Replacer($file))->swap($replacements);
}
} | php | {
"resource": ""
} |
q234827 | Renamer.files | train | public function files()
{
$files = (new Finder)->files();
foreach ($this->ignoredFiles as $name) {
$files->notName($name);
}
foreach ($this->searchedFiles as $name) {
$files->name($name);
}
return $files->exclude($this->ignoredDirectories)->... | php | {
"resource": ""
} |
q234828 | EnhancedUser.hasRoleById | train | public function hasRoleById(int $roleId): bool
{
if (isset($this->roles[$roleId])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q234829 | EnhancedUser.hasRoleByName | train | public function hasRoleByName(string $roleName): bool
{
if (\in_array($roleName, \array_column($this->roles, 'name'), true)) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q234830 | View.update | train | public function update(SplSubject $subject)
{
if ($subject instanceof Model) {
$this->data = \array_merge($this->data, $subject->get());
}
} | php | {
"resource": ""
} |
q234831 | RefreshToken.createNewRefreshToken | train | public static function createNewRefreshToken(
int $ttl,
TokenOwnerInterface $owner = null,
Client $client = null,
$scopes = null
): RefreshToken {
return static::createNew($ttl, $owner, $client, $scopes);
} | php | {
"resource": ""
} |
q234832 | NotificationFormatter.prepare | train | public function prepare() {
$object_type = $this->getObjectType();
$object_link = elgg_view('output/url', array(
'text' => $this->object->getDisplayName(),
'href' => elgg_http_add_url_query_elements($this->object->getURL(), array(
'active_tab' => 'comments',
)),
));
if ($this->author->guid == $t... | php | {
"resource": ""
} |
q234833 | NotificationFormatter.getObjectType | train | public function getObjectType() {
$type = $this->object->getType();
$subtype = $this->object->getSubtype() ? : 'default';
$keys = [
"interactions:$type:$subtype",
$this->object instanceof Comment ? "interactions:comment" : "interactions:post",
];
foreach ($keys as $key) {
if (elgg_language_key_exists... | php | {
"resource": ""
} |
q234834 | NotificationFormatter.getComment | train | protected function getComment() {
$comment_body = elgg_view('output/longtext', array(
'value' => $this->comment->description,
));
// if (elgg_view_exists('output/linkify')) {
// $comment_body = elgg_view('output/linkify', array(
// 'value' => $comment_body
// ));
// }
$comment_body .= elgg_view('outpu... | php | {
"resource": ""
} |
q234835 | ProgressBarFactory.parseProgressBar | train | protected static function parseProgressBar(ProgressBarInterface $progressBar, array $args) {
$progressBar->setAnimated(ArrayHelper::get($args, "animated", false));
$progressBar->setContent(ArrayHelper::get($args, "content"));
$progressBar->setMax(ArrayHelper::get($args, "max", 100));
$p... | php | {
"resource": ""
} |
q234836 | Router.urlHandler | train | public static function urlHandler($hook, $type, $url, $params) {
$entity = elgg_extract('entity', $params);
/* @var ElggEntity $entity */
if ($entity instanceof Comment) {
$container = $entity->getContainerEntity();
if ($container instanceof Comment) {
return $container->getURL();
}
return elgg_... | php | {
"resource": ""
} |
q234837 | Router.iconUrlHandler | train | public static function iconUrlHandler($hook, $type, $url, $params) {
$entity = elgg_extract('entity', $params);
/* @var ElggEntity $entity */
if ($entity instanceof Comment) {
$owner = $entity->getOwnerEntity();
if (!$owner) {
return;
}
return $owner->getIconURL($params);
}
return $url;
} | php | {
"resource": ""
} |
q234838 | AbstractProgressBarTwigExtension.bootstrapProgressBar | train | protected function bootstrapProgressBar(ProgressBarInterface $progressBar) {
$span = static::coreHTMLElement("span", $progressBar->getValue() . "%", ["class" => "sr-only"]);
$attributes = [];
$attributes["class"] = ["progress-bar", ProgressBarRenderer::renderType($progressBar)];
... | php | {
"resource": ""
} |
q234839 | GridTwigExtension.bootstrapGridOffsetFunction | train | public function bootstrapGridOffsetFunction(array $args = []) {
return $this->bootstrapGrid(ArrayHelper::get($args, "lgOffset"), ArrayHelper::get($args, "mdOffset"), ArrayHelper::get($args, "smOffset"), ArrayHelper::get($args, "xsOffset"), ArrayHelper::get($args, "recopyOffset", false), "offset");
} | php | {
"resource": ""
} |
q234840 | GridTwigExtension.bootstrapGridPullFunction | train | public function bootstrapGridPullFunction(array $args = []) {
return $this->bootstrapGrid(ArrayHelper::get($args, "lgPull"), ArrayHelper::get($args, "mdPull"), ArrayHelper::get($args, "smPull"), ArrayHelper::get($args, "xsPull"), ArrayHelper::get($args, "recopyPull", false), "pull");
} | php | {
"resource": ""
} |
q234841 | GridTwigExtension.bootstrapGridPushFunction | train | public function bootstrapGridPushFunction(array $args = []) {
return $this->bootstrapGrid(ArrayHelper::get($args, "lgPush"), ArrayHelper::get($args, "mdPush"), ArrayHelper::get($args, "smPush"), ArrayHelper::get($args, "xsPush"), ArrayHelper::get($args, "recopyPush", false), "push");
} | php | {
"resource": ""
} |
q234842 | GridTwigExtension.bootstrapGridStackedFunction | train | public function bootstrapGridStackedFunction(array $args = []) {
return $this->bootstrapGrid(ArrayHelper::get($args, "lg"), ArrayHelper::get($args, "md"), ArrayHelper::get($args, "sm"), ArrayHelper::get($args, "xs"), ArrayHelper::get($args, "recopy", false), "");
} | php | {
"resource": ""
} |
q234843 | ServerOptions.fromArray | train | public static function fromArray(array $options = []): self
{
return new self(
$options['authorization_code_ttl'] ?? 120,
$options['access_token_ttl'] ?? 3600,
$options['refresh_token_ttl'] ?? 86400,
$options['rotate_refresh_tokens'] ?? false,
$opt... | php | {
"resource": ""
} |
q234844 | SSHKeys.add | train | public function add(array $parameters)
{
if (!array_key_exists('name', $parameters) || !is_string($parameters['name'])) {
throw new \InvalidArgumentException('You need to provide the name of the SSH Key.');
}
if (!array_key_exists('ssh_pub_key', $parameters) || !is_string($param... | php | {
"resource": ""
} |
q234845 | SSHKeys.edit | train | public function edit($sshKeyId, array $parameters)
{
if (!array_key_exists('ssh_pub_key', $parameters) || !is_string($parameters['ssh_pub_key'])) {
throw new \InvalidArgumentException('You need to provide the new public SSH Key.');
}
return $this->processQuery($this->buildQuery(... | php | {
"resource": ""
} |
q234846 | RoutesJavascriptGenerator.make | train | public function make($path, $name, array $options = [])
{
$options += ['middleware' => null, 'prefix' => null];
$parsedRoutes = $this->getParsedRoutes($options['middleware'], $options['prefix']);
$template = $this->file->get(__DIR__ . '/templates/Router.js');
$template = str_repla... | php | {
"resource": ""
} |
q234847 | AbstractBreadcrumbTwigExtension.bootstrapBreadcrumb | train | private function bootstrapBreadcrumb(NavigationNode $node, $last) {
$attributes = true === $node->getActive() && true === $last ? ["class" => "active"] : [];
$content = $this->getTranslator()->trans($node->getId());
$innerHTML = true === $last ? $content : static::coreHTMLElement("a", $conte... | php | {
"resource": ""
} |
q234848 | JsonResponder.respond | train | public function respond(array $data, $status = 200, $code, array $headers = [], $options = 0)
{
return $this->response->json(
array_merge(compact('status', 'code'), $data), $status, $headers, $options
);
} | php | {
"resource": ""
} |
q234849 | Domains.buildRecordsQuery | train | protected function buildRecordsQuery($domain, $id = null, $action = null, array $parameters = array())
{
$parameters = http_build_query(array_merge($parameters, $this->credentials));
$query = sprintf("%s/%s/%s", $this->apiUrl, $domain, DomainsActions::ACTION_RECORDS);
$query = $id ? sprintf... | php | {
"resource": ""
} |
q234850 | Domains.checkParameters | train | protected function checkParameters(array $parameters)
{
if (!array_key_exists('record_type', $parameters)) {
throw new \InvalidArgumentException('You need to provide the record_type.');
}
if (!in_array($parameters['record_type'], array('A', 'CNAME', 'NS', 'TXT', 'MX', 'SRV'))) {... | php | {
"resource": ""
} |
q234851 | Domains.newRecord | train | public function newRecord($domain, array $parameters)
{
$this->checkParameters($parameters);
return $this->processQuery(
$this->buildRecordsQuery($domain, null, RecordsActions::ACTION_ADD, $parameters)
);
} | php | {
"resource": ""
} |
q234852 | Domains.editRecord | train | public function editRecord($domain, $recordId, array $parameters)
{
$this->checkParameters($parameters);
return $this->processQuery(
$this->buildRecordsQuery($domain, $recordId, RecordsActions::ACTION_EDIT, $parameters)
);
} | php | {
"resource": ""
} |
q234853 | Domains.destroyRecord | train | public function destroyRecord($domain, $recordId)
{
return $this->processQuery($this->buildRecordsQuery($domain, $recordId, RecordsActions::ACTION_DESTROY));
} | php | {
"resource": ""
} |
q234854 | AbstractDigitalOcean.buildQuery | train | protected function buildQuery($id = null, $action = null, array $parameters = array())
{
$parameters = http_build_query(array_merge($parameters, $this->credentials));
$query = $id ? sprintf("%s/%s", $this->apiUrl, $id) : $this->apiUrl;
$query = $action ? sprintf("%s/%s/?%s", $query, $action... | php | {
"resource": ""
} |
q234855 | AbstractDigitalOcean.processQuery | train | protected function processQuery($query)
{
if (null === $processed = json_decode($this->adapter->getContent($query))) {
throw new \RuntimeException(sprintf("Impossible to process this query: %s", $query));
}
if ('ERROR' === $processed->status) {
// it looks that the A... | php | {
"resource": ""
} |
q234856 | InteractionsService.deleteRiverObject | train | public static function deleteRiverObject($event, $type, $river) {
$ia = elgg_set_ignore_access(true);
$guid = InteractionsCache::getInstance()->getGuidFromRiverId($river->id);
if ($guid) {
$object = get_entity($guid);
if ($object) {
$object->delete();
}
}
elgg_set_ignore_access($ia);
} | php | {
"resource": ""
} |
q234857 | InteractionsService.createActionableRiverObject | train | public static function createActionableRiverObject(ElggRiverItem $river) {
if (!$river instanceof ElggRiverItem) {
return false;
}
$object = $river->getObjectEntity();
$views = self::getActionableViews();
if (!in_array($river->view, $views)) {
return $object;
}
$access_id = $object->access_id;
... | php | {
"resource": ""
} |
q234858 | InteractionsService.getRiverObject | train | public static function getRiverObject(ElggRiverItem $river) {
if (!$river instanceof ElggRiverItem) {
return false;
}
$object = $river->getObjectEntity();
$views = self::getActionableViews();
if (in_array($river->view, $views)) {
// wrapping this in ignore access so that we do not accidentally crea... | php | {
"resource": ""
} |
q234859 | InteractionsService.getStats | train | public static function getStats($entity) {
if (!$entity instanceof ElggEntity) {
return array();
}
$stats = array(
'comments' => array(
'count' => $entity->countComments()
),
'likes' => array(
'count' => $entity->countAnnotations('likes'),
'state' => (elgg_annotation_exists($entity->guid... | php | {
"resource": ""
} |
q234860 | InteractionsService.getCommentsSort | train | public static function getCommentsSort() {
$user_setting = elgg_get_plugin_user_setting('comments_order', 0, 'hypeInteractions');
$setting = $user_setting ?: elgg_get_plugin_setting('comments_order', 'hypeInteractions');
if ($setting == 'asc') {
$setting = 'time_created::asc';
} else if ($setting == 'desc') ... | php | {
"resource": ""
} |
q234861 | InteractionsService.getLimit | train | public static function getLimit($partial = true) {
if ($partial) {
$limit = elgg_get_plugin_setting('comments_limit', 'hypeInteractions');
return $limit ?: 3;
} else {
$limit = elgg_get_plugin_setting('comments_load_limit', 'hypeInteractions');
return min(max((int) $limit, 20), 200);
}
} | php | {
"resource": ""
} |
q234862 | InteractionsService.calculateOffset | train | public static function calculateOffset($count, $limit, $comment = null) {
$order = self::getCommentsSort();
$style = self::getLoadStyle();
if ($comment instanceof Comment) {
$thread = new Thread($comment);
$offset = $thread->getOffset($limit, $order);
} else if (($order == 'time_created::asc' && $style ... | php | {
"resource": ""
} |
q234863 | InteractionsService.getActionableViews | train | public static function getActionableViews() {
static $views;
if (isset($views)) {
return $views;
}
$views = [];
$plugin = elgg_get_plugin_from_id('hypeInteractions');
$settings = $plugin->getAllSettings();
foreach ($settings as $key => $value) {
if (!$value) {
continue;
}
list ($prefix, ... | php | {
"resource": ""
} |
q234864 | InteractionsService.syncRiverObjectAccess | train | public static function syncRiverObjectAccess($event, $type, $entity) {
if (!$entity instanceof \ElggObject) {
// keep user and group entries as is
return;
}
// need to override access in case comments ended up with ACCESS_PRIVATE
// and to ensure write permissions
$ia = elgg_set_ignore_access(true);
... | php | {
"resource": ""
} |
q234865 | ButtonEnumerator.enumTypes | train | public static function enumTypes() {
return [
ButtonInterface::BUTTON_TYPE_DANGER,
ButtonInterface::BUTTON_TYPE_DEFAULT,
ButtonInterface::BUTTON_TYPE_INFO,
ButtonInterface::BUTTON_TYPE_LINK,
ButtonInterface::BUTTON_TYPE_PRIMARY,
ButtonInter... | php | {
"resource": ""
} |
q234866 | BaseRoutine.generateDocBlock | train | protected function generateDocBlock(array $columns): void
{
$this->codeStore->append('/**');
$this->codeStore->append(' * @todo describe routine', false);
$this->codeStore->append(' * ', false);
$padding = $this->getMaxColumnLength($columns);
$format = sprintf(' * @param p_%%-%ds @todo describe ... | php | {
"resource": ""
} |
q234867 | BaseRoutine.generateMainPart | train | protected function generateMainPart(array $columns): void
{
$this->codeStore->append(sprintf('create procedure %s(', $this->spName));
$padding = $this->getMaxColumnLength($columns);
$offset = mb_strlen($this->codeStore->getLastLine());
$first = true;
foreach ($columns as $column)
{
if... | php | {
"resource": ""
} |
q234868 | BaseRoutine.getMaxColumnLength | train | protected function getMaxColumnLength(array $columns): int
{
$length = 0;
foreach ($columns as $column)
{
$length = max(mb_strlen($column['column_name']), $length);
}
return $length;
} | php | {
"resource": ""
} |
q234869 | Container.delete | train | public function delete(string $id): bool
{
if (\array_key_exists($id, $this->cache)) {
//delete value
unset($this->cache[$id]);
//return function result
return true;
}
return false;
} | php | {
"resource": ""
} |
q234870 | Container.resolve | train | public function resolve(string $class, array $rules = [])
{
//reset tree;
$this->tree = [];
//merge rules passed as parameter with general rules
$this->rules = \array_merge($this->rules, $rules);
//build dependency tree
$this->buildTree($class);
//build obj... | php | {
"resource": ""
} |
q234871 | Container.buildTree | train | private function buildTree(string $class): void
{
$level = 0;
$stack = new SplStack();
while (true) {
//initialize array if not already initialized
if (empty($this->tree[$level][$class])) {
$this->tree[$level][$class] = [];
}
... | php | {
"resource": ""
} |
q234872 | Container.buildObjects | train | private function buildObjects(): void
{
//deep dependency level, start to array end for not use array_reverse
for ($i = \count($this->tree) - 1; $i >= 0; $i--) {
//class
foreach ($this->tree[$i] as $class => $arguments) {
//try to find object in class
... | php | {
"resource": ""
} |
q234873 | Container.buildArguments | train | private function buildArguments(string $class, array $dependency): array
{
//initialize arguments array
$args = [];
//argument required from class
foreach ($dependency as $argValue) {
if (\class_exists((string) $argValue->getType())) {
//add to array of a... | php | {
"resource": ""
} |
q234874 | TableButtonTwigExtension.bootstrapRowButtonDefaultFunction | train | public function bootstrapRowButtonDefaultFunction(array $args = []) {
$editButton = $this->bootstrapRowButtonEditFunction(["href" => ArrayHelper::get($args, "edit_href")]);
$deleteButton = $this->bootstrapRowButtonDeleteFunction(["href" => ArrayHelper::get($args, "delete_href")]);
return imp... | php | {
"resource": ""
} |
q234875 | TableButtonTwigExtension.bootstrapRowButtonDeleteFunction | train | public function bootstrapRowButtonDeleteFunction(array $args = []) {
$txt = $this->getTranslator()->trans("label.delete", [], "WBWBootstrapBundle");
$but = $this->getButtonTwigExtension()->bootstrapButtonDangerFunction(["title" => $txt, "icon" => "g:trash"]);
return $this->getButtonTwigExtensi... | php | {
"resource": ""
} |
q234876 | TableButtonTwigExtension.bootstrapRowButtonEditFunction | train | public function bootstrapRowButtonEditFunction(array $args = []) {
$txt = $this->getTranslator()->trans("label.edit", [], "WBWBootstrapBundle");
$but = $this->getButtonTwigExtension()->bootstrapButtonDefaultFunction(["title" => $txt, "icon" => "g:pencil"]);
return $this->getButtonTwigExtension... | php | {
"resource": ""
} |
q234877 | AbstractAlertTwigExtension.bootstrapAlert | train | protected function bootstrapAlert($content, $dismissible, $class) {
$span = static::coreHTMLElement("span", "×", ["aria-hidden" => "true"]);
$button = static::coreHTMLElement("button", $span, ["class" => "close", "type" => "button", "data-dismiss" => "alert", "aria-label" => "Close"]);
... | php | {
"resource": ""
} |
q234878 | AbstractTypographyTwigExtension.bootstrapHeading | train | protected function bootstrapHeading($size, $content, $description, $class) {
$sizes = [1, 2, 3, 4, 5, 6];
$attributes = [];
$attributes["class"] = [$class];
$element = "h" . (true === in_array($size, $sizes) ? $size : 1);
$secondary = null !== $description ? " <small>" . $d... | php | {
"resource": ""
} |
q234879 | TypographyTwigExtension.bootstrapHeading1Function | train | public function bootstrapHeading1Function(array $args = []) {
return $this->bootstrapHeading(1, ArrayHelper::get($args, "content"), ArrayHelper::get($args, "description"), ArrayHelper::get($args, "class"));
} | php | {
"resource": ""
} |
q234880 | TypographyTwigExtension.bootstrapHeading2Function | train | public function bootstrapHeading2Function(array $args = []) {
return $this->bootstrapHeading(2, ArrayHelper::get($args, "content"), ArrayHelper::get($args, "description"), ArrayHelper::get($args, "class"));
} | php | {
"resource": ""
} |
q234881 | TypographyTwigExtension.bootstrapHeading3Function | train | public function bootstrapHeading3Function(array $args = []) {
return $this->bootstrapHeading(3, ArrayHelper::get($args, "content"), ArrayHelper::get($args, "description"), ArrayHelper::get($args, "class"));
} | php | {
"resource": ""
} |
q234882 | TypographyTwigExtension.bootstrapHeading4Function | train | public function bootstrapHeading4Function(array $args = []) {
return $this->bootstrapHeading(4, ArrayHelper::get($args, "content"), ArrayHelper::get($args, "description"), ArrayHelper::get($args, "class"));
} | php | {
"resource": ""
} |
q234883 | TypographyTwigExtension.bootstrapHeading5Function | train | public function bootstrapHeading5Function(array $args = []) {
return $this->bootstrapHeading(5, ArrayHelper::get($args, "content"), ArrayHelper::get($args, "description"), ArrayHelper::get($args, "class"));
} | php | {
"resource": ""
} |
q234884 | TypographyTwigExtension.bootstrapHeading6Function | train | public function bootstrapHeading6Function(array $args = []) {
return $this->bootstrapHeading(6, ArrayHelper::get($args, "content"), ArrayHelper::get($args, "description"), ArrayHelper::get($args, "class"));
} | php | {
"resource": ""
} |
q234885 | Client.createNewClient | train | public static function createNewClient(string $name, $redirectUris = null): Client
{
if (isset($redirectUris) && is_string($redirectUris)) {
$redirectUris = explode(' ', $redirectUris);
}
if (isset($redirectUris) && is_array($redirectUris)) {
foreach ($redirectUris a... | php | {
"resource": ""
} |
q234886 | Client.generateSecret | train | public function generateSecret()
{
$secret = bin2hex(random_bytes(20));
$this->secret = password_hash($secret, PASSWORD_DEFAULT);
return $secret;
} | php | {
"resource": ""
} |
q234887 | RiverObject.getRiverItem | train | public function getRiverItem() {
if (isset($this->_river_item)) {
return $this->_river_item;
}
$id = $this->river_id;
$items = elgg_get_river(array(
'ids' => $id,
'limit' => 1,
));
$this->_river_item = (is_array($items) && count($items)) ? $items[0] : false;
return $this->_river_item;
} | php | {
"resource": ""
} |
q234888 | NonStatic.nonStatic | train | public static function nonStatic(string $source, ?string $sourceClass = null, ?string $targetClass = null): string
{
// Replace static fields.
$source = preg_replace('/(public|protected|private)\s+static(\s+)\$/i', '${1}${2}$', $source);
// Replace usage of static fields.
$source = preg_replace('/sel... | php | {
"resource": ""
} |
q234889 | CloudinaryWrapper.show | train | public function show($publicId, $options = array())
{
$defaults = $this->config->get('cloudinary::scaling');
$options = array_merge($defaults, $options);
return $this->getCloudinary()->cloudinary_url($publicId, $options);
} | php | {
"resource": ""
} |
q234890 | Route.toArray | train | public function toArray(): array
{
return [
'name' => $this->name,
'method' => $this->method,
'url' => $this->url,
'model' => $this->model,
'view' => $this->view,
'controller' => $this->controller,
'action' => $this->action,... | php | {
"resource": ""
} |
q234891 | ProtectedControllerTrait.protect | train | private function protect(Authentication $authentication, int $httpResponseCode = 403): void
{
if (($this->authentication = $authentication->isLogged()) === false) {
\http_response_code($httpResponseCode);
throw new AuthenticationException('');
}
} | php | {
"resource": ""
} |
q234892 | ProtectedControllerTrait.protectWithRedirect | train | private function protectWithRedirect(Authentication $authentication, string $location): void
{
if (($this->authentication = $authentication->isLogged()) === false) {
\header('Location: '.$location);
throw new AuthenticationException('');
}
} | php | {
"resource": ""
} |
q234893 | FormButtonTwigExtension.bootstrapFormButtonDefaultFunction | train | public function bootstrapFormButtonDefaultFunction(array $args = []) {
$cancelButton = $this->bootstrapFormButtonCancelFunction(["href" => ArrayHelper::get($args, "cancel_href")]);
$submitButton = $this->bootstrapFormButtonSubmitFunction();
// Return the HTML.
return implode(" ", [$can... | php | {
"resource": ""
} |
q234894 | FormButtonTwigExtension.bootstrapFormButtonSubmitFunction | train | public function bootstrapFormButtonSubmitFunction() {
$txt = $this->getTranslator()->trans("label.submit", [], "WBWBootstrapBundle");
$but = $this->getButtonTwigExtension()->bootstrapButtonPrimaryFunction(["content" => $txt, "title" => $txt, "icon" => "g:ok"]);
return $this->getButtonTwigExten... | php | {
"resource": ""
} |
q234895 | Router.validate | train | public function validate(string $requestUri, string $requestMethod): bool
{
$route = $this->findRoute($this->filterUri($requestUri), $requestMethod);
if ($route instanceof Route) {
$this->buildValidRoute($route);
return true;
}
$this->buildErrorRoute();
... | php | {
"resource": ""
} |
q234896 | Router.findRoute | train | private function findRoute(string $uri, string $method): RouteInterface
{
$matches = [];
$route = new NullRoute();
foreach ($this->routes as $value) {
$urlMatch = \preg_match('`^'.\preg_replace($this->matchTypes, $this->types, $value->url).'/?$`', $uri, $matches);
$m... | php | {
"resource": ""
} |
q234897 | Router.buildValidRoute | train | private function buildValidRoute(Route $route): void
{
//add to route array the passed uri for param check when call
$matches = $this->routeMatches;
//route match and there is a subpattern with action
if (\count($matches) > 1) {
//assume that subpattern rapresent action
... | php | {
"resource": ""
} |
q234898 | Router.buildParam | train | private function buildParam(Route $route): array
{
$param = [];
$url = \explode('/', $route->url);
$matches = \explode('/', $this->routeMatches[0]);
$rawParam = \array_diff($matches, $url);
foreach ($rawParam as $key => $value) {
$paramName = \strtr($url[$key],... | php | {
"resource": ""
} |
q234899 | Router.buildErrorRoute | train | private function buildErrorRoute(): void
{
//check if there is a declared route for errors, if no exit with false
if (($key = \array_search($this->badRoute, \array_column($this->routes->getArrayCopy(), 'name'), true)) === false) {
$this->route = new NullRoute();
return;
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.