_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q7400 | Utility.getRoute | train | public function getRoute()
{
/** @var Http $req */
$req = $this->context->getRequest();
if (isset($this->map[$req->getControllerName()])) | php | {
"resource": ""
} |
q7401 | Retriever.getPaymentMethods | train | public function getPaymentMethods()
{
$this->quote->setStoreId($this->storeManager->getStore()->getId());
$export = [];
$paymentMethods = $this->paymentModel->getAvailableMethods($this->quote);
foreach ($paymentMethods as $method) {
$export[] = [
| php | {
"resource": ""
} |
q7402 | Builder.buildHttpRedirect | train | public function buildHttpRedirect()
{
if (!is_null($this->http)) {
return $this->http;
}
$builder = new ShopgateBuilder($this->initConfig());
$userAgent = $this->header->getHttpUserAgent();
try {
$this->http = $builder->buildHttpRedirect($userAgent, $this->request->getParams(), $_COOKIE);
} catch (\ShopgateMerchantApiException $e) {
$this->logger->error('HTTP > oAuth access token for store not set: | php | {
"resource": ""
} |
q7403 | Builder.buildJsRedirect | train | public function buildJsRedirect()
{
if (!is_null($this->js)) {
return $this->js;
}
$builder = new ShopgateBuilder($this->initConfig());
try {
$this->js = $builder->buildJsRedirect($this->request->getParams(), $_COOKIE);
} catch (\ShopgateMerchantApiException $e) {
$this->logger->error('JS > oAuth access token for store not set: ' | php | {
"resource": ""
} |
q7404 | Pagination.prepare | train | public function prepare(OptionList $objOptions = null): OptionList
{
if (is_null($objOptions)) {
$objOptions = new OptionList;
}
// Page
if ('post' == $this->options->get('method')) {
$requestBody = $this->serverRequest->getParsedBody();
if (is_array($requestBody) && !empty($requestBody[$this->getParam()])) {
$this->page = intval($requestBody[$this->getParam()]);
} else {
$this->page = 1;
}
} else {
$queryParams = $this->serverRequest->getQueryParams();
if (is_array($queryParams) && !empty($queryParams[$this->getParam()])) {
$this->page = intval($queryParams[$this->getParam()]);
} else {
$this->page = 1;
}
}
// Nb per page | php | {
"resource": ""
} |
q7405 | Pagination.handle | train | public function handle($mixed): Pagination
{
if ($mixed instanceof Collection) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max(count($mixed), 1) / max($this->nb_per_page, 1));
} else {
if ($mixed instanceof \Countable) {
$this->mixed = $mixed;
$this->nb_pages = ceil(max(count($mixed), 1) / max($this->nb_per_page, 1));
} else {
if (is_int($mixed)) {
$this->mixed = $mixed;
| php | {
"resource": ""
} |
q7406 | Pagination.canBeShowed | train | public function canBeShowed(): bool
{
return ($this->mixed instanceof Collection || $this->mixed | php | {
"resource": ""
} |
q7407 | Pagination.getParam | train | public function getParam(): string
{
if ($this->options->is_null('param')) {
$this->options->set('param', | php | {
"resource": ""
} |
q7408 | Pagination.getHttpQueryString | train | public function getHttpQueryString(array $moreQuery = null): string
{
$queries = [];
if (!(is_null($this->page) || 1 == $this->page)) {
$queries[$this->getParam()] = $this->page;
}
if (!empty($moreQuery)) {
| php | {
"resource": ""
} |
q7409 | StateMachineAbstract.parseYAML | train | protected function parseYAML()
{
try {
$yaml = $this->configuration;
$yaml_fixed = [];
$yaml_fixed['class'] = $yaml['class'];
foreach ($yaml['states'] as $key => $value) {
if ($value['type'] != \Mothership\StateMachine\StatusInterface::TYPE_INITIAL && $value['type'] != \Mothership\StateMachine\StatusInterface::TYPE_EXCEPTION) {
$state = [
'name' => $key,
'type' => $value['type'],
'transitions_from' => $value['transitions_from'],
'transitions_to' => $value['transitions_to'],
];
$yaml_fixed['states'][] = $state;
| php | {
"resource": ""
} |
q7410 | StateMachineAbstract.initWorkflow | train | protected function initWorkflow()
{
$className = $this->workflowConfiguration['class']['name'];
if (!class_exists($className, true)) {
throw new StateMachineException('The class ' . $className . ' does not exist!', 100);
}
try {
| php | {
"resource": ""
} |
q7411 | StateMachineAbstract.renderGraph | train | public function renderGraph($outputPath = './workflow.png', $stopAfterExecution = true)
{
/*
* This example is based on http://martin-thoma.com/how-to-draw-a-finite-state-machine/
* Feel free to tweak the rendering output. I have decided do use the most simple
* implementation over the fancy stuff to avoid additional complexity.
*/
$template
= '
digraph finite_state_machine {
rankdir=LR;
size="%d"
node [shape = doublecircle]; start;
node [shape = circle];
%s
}
';
$pattern = ' %s -> %s [ label = "%s" ];';
$_transitions = [];
foreach ($this->workflowConfiguration['states'] as $state) {
if (array_key_exists('transitions_from', $state)) {
$transitions_from = $state['transitions_from'];
foreach ($transitions_from as $from) {
if (is_array($from)) {
$_transitions[] = sprintf(
$pattern,
$from['status'],
$state['name'],
'<< IF '
. $this->convertToStringCondition($from['result']) . ' >>' . $state['name']
);
| php | {
"resource": ""
} |
q7412 | StateMachineAbstract.run | train | public function run(array $args = [], $enableLog = false)
{
try {
return $this->workflow->run($args, $enableLog);
} catch (WorkflowException $ex) {
| php | {
"resource": ""
} |
q7413 | Generic.generate | train | public function generate($pageTitle)
{
return [
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_SITENAME => $this->getSiteName(),
Shopgate_Helper_Redirect_TagsGenerator::SITE_PARAMETER_DESKTOP_URL | php | {
"resource": ""
} |
q7414 | CURLFactory.getInstance | train | public static function getInstance($method, CURLConfiguration $configuration = null, $resourcePath = null) {
// Check the configuration.
if (null === $configuration) {
$configuration = new CURLConfiguration();
}
// Switch into $method.
switch ($method) {
case self::HTTP_METHOD_DELETE:
return new CURLDeleteRequest($configuration, $resourcePath);
case self::HTTP_METHOD_GET:
return new CURLGetRequest($configuration, $resourcePath);
case self::HTTP_METHOD_HEAD:
return new CURLHeadRequest($configuration, $resourcePath);
case self::HTTP_METHOD_OPTIONS:
return new CURLOptionsRequest($configuration, $resourcePath);
| php | {
"resource": ""
} |
q7415 | ARC2.createGraph | train | public function createGraph(NamedNode $graph, array $options = [])
{
if (false === isset($this->getGraphs()[$graph->getUri()])) {
// table names
$g2t = $this->configuration['table-prefix'].'_g2t';
$id2val = $this->configuration['table-prefix'].'_id2val';
/*
* for id2val table
*/
$query = 'INSERT INTO '.$id2val.' (val) VALUES("'.$graph->getUri().'")';
$this->store->queryDB($query, $this->store->getDBCon());
$usedId = $this->store->getDBCon()->insert_id;
/*
* for | php | {
"resource": ""
} |
q7416 | ARC2.getRowCount | train | public function getRowCount($tableName)
{
$result = $this->store->queryDB(
'SELECT COUNT(*) as count FROM '.$tableName,
$this->store->getDBCon() | php | {
"resource": ""
} |
q7417 | ARC2.openConnection | train | protected function openConnection()
{
// set standard values
$this->configuration = array_merge([
'host' => 'localhost',
'database' => '',
'username' => '',
'password' => '',
'table-prefix' => 'saft_',
], $this->configuration);
/*
* check for missing connection credentials
*/
if ('' == $this->configuration['database']) {
throw new \Exception('ARC2: Field database is not set.');
} elseif ('' == $this->configuration['username']) {
throw new \Exception('ARC2: Field username is not set.');
} elseif ('' == $this->configuration['host']) {
throw new \Exception('ARC2: Field host is | php | {
"resource": ""
} |
q7418 | SgProfiler.start | train | public function start($identifier = null)
{
$this->loadProfile($identifier); | php | {
"resource": ""
} |
q7419 | SgProfiler.loadProfile | train | protected function loadProfile($identifier = null)
{
if (!$identifier) {
$identifier = 'generic';
}
if (isset($this->profiles[$identifier])) {
$this->currentProfile = $this->profiles[$identifier];
} else {
| php | {
"resource": ""
} |
q7420 | SgProfiler.debug | train | public function debug($message = "%s seconds")
{
| php | {
"resource": ""
} |
q7421 | AbstractTextTranslator.weeks | train | public function weeks($weeks)
{
return sprintf($this->formatPattern, | php | {
"resource": ""
} |
q7422 | AbstractTextTranslator.months | train | public function months($months)
{
return sprintf($this->formatPattern, | php | {
"resource": ""
} |
q7423 | AbstractTextTranslator.years | train | public function years($years)
{
return sprintf($this->formatPattern, | php | {
"resource": ""
} |
q7424 | TimeSlot.leftJoinWithout | train | public function leftJoinWithout() {
// Sort and count the time slots.
$buffer = TimeSlotHelper::merge($this->getTimeSlots());
$number = count($buffer);
// Check the time slots count.
if (0 === $number) {
return [$this];
}
// Initialize the output.
$output = [$this];
// Handle each time slot.
for ($i = 0; $i < | php | {
"resource": ""
} |
q7425 | TimeSlot.removeTimeSlot | train | public function removeTimeSlot(TimeSlot $timeSlot) {
for ($i = count($this->timeSlots) - 1; 0 <= $i; --$i) {
if (true !== TimeSlotHelper::equals($timeSlot, $this->timeSlots[$i])) {
| php | {
"resource": ""
} |
q7426 | Config.setConfigDirectory | train | private function setConfigDirectory(string $dirName): void
{
$dirName = realpath($this->getDirectory(Config::DIR_ROOT) . $dirName);
if (is_dir($dirName)) {
$this->configDirectory = $dirName;
} else {
if ($dirName !== false) {
| php | {
"resource": ""
} |
q7427 | Retriever.getCustomerGroups | train | public function getCustomerGroups()
{
$groups = [];
/** @var GroupInterface $customerGroup */
foreach ($this->customerGroupCollection->getItems() as $customerGroup) {
$group = [];
$group['id'] = $customerGroup->getId();
$group['name'] = $customerGroup->getCode();
$group['is_default'] = intval($customerGroup->getId() == GroupInterface::NOT_LOGGED_IN_ID);
$matchingTaxClasses =
| php | {
"resource": ""
} |
q7428 | AbstractValidator.create_error_message | train | protected function create_error_message( $message_name, $value ) {
$message = $this->get_message_template( $message_name );
if ( ! is_scalar( $value ) ) {
$value = $this->get_value_as_string( $value );
}
// replacing the placeholder for the %value%
$message = str_replace( '%value%', $value, $message );
// replacing the | php | {
"resource": ""
} |
q7429 | AbstractValidator.get_value_as_string | train | protected function get_value_as_string( $value ) {
if ( is_object( $value ) && ! in_array( '__toString', get_class_methods( $value ) ) ) {
$value = get_class( $value ) . ' object';
| php | {
"resource": ""
} |
q7430 | ZypioSNMP.addOid | train | public function addOid( $oid, $type = STRING, $value= NULL, $allowed = [] ){
$this->tree[$oid] = [ 'type' => | php | {
"resource": ""
} |
q7431 | Image.resize | train | public function resize($props = array(), $coords = null) {
$croppable = elgg_extract('croppable', $props, false);
$width = elgg_extract('w', $props);
$height = elgg_extract('h', $props);
if (is_array($coords) && $croppable) {
$master_width = elgg_extract('master_width', $coords, self::MASTER);
$master_height = elgg_extract('master_height', $coords, self::MASTER);
$x1 = elgg_extract('x1', $coords, 0);
$y1 = elgg_extract('y1', $coords, 0);
$x2 = elgg_extract('x2', $coords, self::MASTER);
$y2 = elgg_extract('y2', $coords, self::MASTER);
// scale to master size and then | php | {
"resource": ""
} |
q7432 | Image.save | train | public function save($path, $quality = array()) {
$ext = pathinfo($path, PATHINFO_EXTENSION);
$jpeg_quality = elgg_extract('jpeg_quality', $quality);
$png_quality = elgg_extract('png_quality', $quality);
$png_filter = elgg_extract('png_filter', | php | {
"resource": ""
} |
q7433 | CMySQLConnector.clearStats | train | private function clearStats()
{
$this->queries_executed = 0;
$this->queries_released = 0;
$this->queries_erroneous = 0;
$this->sentences_executed = 0;
$this->sentences_erroneous = 0;
$this->inserts_executed = 0;
$this->inserts_erroneous = 0;
| php | {
"resource": ""
} |
q7434 | CMySQLConnector.enqueueStatement | train | public function enqueueStatement(CNabuDBAbstractStatement $statement)
{
if ($statement instanceof CMySQLStatement) {
$hash = $statement->getHash();
if (!is_array($this->statements) || count($this->statements) === 0) {
$this->statements | php | {
"resource": ""
} |
q7435 | CMySQLConnector.dequeueStatement | train | public function dequeueStatement(CNabuDBAbstractStatement $statement)
{
if ($statement instanceof CMySQLStatement) {
$hash = $statement->getHash();
if ($hash !== null | php | {
"resource": ""
} |
q7436 | CMySQLConnector.clearLeadingAndTrailingSpaces | train | private function clearLeadingAndTrailingSpaces(string $sentence) : string
{
if ($this->trailing_optimization) {
$sentence = preg_replace('/^\\s+/', '', $sentence);
$sentence = preg_replace('/\\s+$/', | php | {
"resource": ""
} |
q7437 | UserCredentialAuthenticationLdapTrait.initializeLdap | train | public function initializeLdap() {
//initialize from parent
$this->initialize();
//validate ldap settings
$ldapSettings = $this->_passwordAuthenticationPlatformSettings;
if(
!(array_key_exists('ldap_account_suffix', $ldapSettings))
||!(array_key_exists('ad_password', $ldapSettings))
|| !(array_key_exists('ad_username', $ldapSettings))
|| !(array_key_exists('base_dn', $ldapSettings))
|| !(array_key_exists('cn_identifier', $ldapSettings))
|| !(array_key_exists('domain_controllers', $ldapSettings))
|| !(array_key_exists('group_attribute', $ldapSettings))
|| !(array_key_exists('group_cn_identifier', $ldapSettings))
|| !(array_key_exists('ldap_server_type', $ldapSettings))
|| !(array_key_exists('network_timeout', $ldapSettings))
|| !(array_key_exists('port', $ldapSettings))
|| | php | {
"resource": ""
} |
q7438 | UserCredentialAuthenticationLdapTrait.initializeLdapAuthenticationHandler | train | protected function initializeLdapAuthenticationHandler() {
$ldapSettings = $this->_passwordAuthenticationPlatformSettings;
$ldapAuthenticationHandler = new MultiotpWrapper();
$ldapAuthenticationHandler->SetLdapServerPassword($this->getCurrentPassword());
$ldapAuthenticationHandler->SetLdapBindDn($this->getCurrentUsername());
$ldapAuthenticationHandler->SetLdapAccountSuffix($ldapSettings['ldap_account_suffix']);
$ldapAuthenticationHandler->SetLdapBaseDn($ldapSettings['base_dn']);
$ldapAuthenticationHandler->SetLdapCnIdentifier($ldapSettings['cn_identifier']);
$ldapAuthenticationHandler->SetLdapDomainControllers($ldapSettings['domain_controllers']);
$ldapAuthenticationHandler->SetLdapGroupAttribute($ldapSettings['group_attribute']);
$ldapAuthenticationHandler->SetLdapGroupCnIdentifier($ldapSettings['group_cn_identifier']);
$ldapAuthenticationHandler->SetLdapServerType($ldapSettings['ldap_server_type']);
$ldapAuthenticationHandler->SetLdapNetworkTimeout($ldapSettings['network_timeout']); | php | {
"resource": ""
} |
q7439 | Observer.execute | train | public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->redirect->isAllowed()) {
$this->session->unsetScript();
return;
} | php | {
"resource": ""
} |
q7440 | Observer.getRedirects | train | private function getRedirects()
{
$httpWithJsBackup = [
$this->httpRedirect,
| php | {
"resource": ""
} |
q7441 | AbstractTriplePatternStore.getStatement | train | protected function getStatement(Query $queryObject)
{
$queryParts = $queryObject->getQueryParts();
$tupleInformaton = null;
$tupleType = null;
/*
* Use triple pattern
*/
if (true === isset($queryParts['triple_pattern'])) {
$tupleInformation = $queryParts['triple_pattern'];
$tupleType = 'triple';
/*
* Use quad pattern
*/
} elseif (true === isset($queryParts['quad_pattern'])) {
$tupleInformation = $queryParts['quad_pattern'];
$tupleType = 'quad';
/*
* Neither triple nor quad information
*/
} else {
throw new \Exception(
'Neither triple nor quad information available in given query object: '.$queryObject->getQuery()
);
}
if (1 > count($tupleInformation)) {
throw new \Exception('Query contains more than one triple- respectivly quad pattern.');
}
/*
* Triple
*/
if ('triple' == $tupleType) {
$subject = $this->createNodeByValueAndType($tupleInformation[0]['s'], $tupleInformation[0]['s_type']);
$predicate = $this->createNodeByValueAndType($tupleInformation[0]['p'], $tupleInformation[0]['p_type']);
$object = $this->createNodeByValueAndType($tupleInformation[0]['o'], $tupleInformation[0]['o_type']);
$graph = null;
| php | {
"resource": ""
} |
q7442 | AbstractTriplePatternStore.getStatements | train | protected function getStatements(Query $queryObject)
{
$queryParts = $queryObject->getQueryParts();
$statementArray = [];
// if only triples, but no quads
if (true === isset($queryParts['triple_pattern'])
&& false === isset($queryParts['quad_pattern'])) {
foreach ($queryParts['triple_pattern'] as $pattern) {
/**
* Create Node instances for S, P and O to build a Statement instance later on.
*/
$s = $this->createNodeByValueAndType($pattern['s'], $pattern['s_type']);
$p = $this->createNodeByValueAndType($pattern['p'], $pattern['p_type']);
$o = $this->createNodeByValueAndType($pattern['o'], $pattern['o_type']);
$g = null;
$statementArray[] = $this->statementFactory->createStatement($s, $p, $o, $g);
}
// if only quads, but not triples
} elseif (false === isset($queryParts['triple_pattern'])
&& true === isset($queryParts['quad_pattern'])) {
foreach ($queryParts['quad_pattern'] as $pattern) {
/**
* Create Node instances for S, P and O to build a Statement instance later on.
*/
| php | {
"resource": ""
} |
q7443 | ValidatorFactory.create | train | public function create( $type, array $properties = [ ] ) {
// If type is already an instance of validator, and no properties provided, we just return it as is
if ( $type instanceof ValidatorInterface && ! $properties ) {
return $type;
}
// If an instance of validator is given alongside some properties, we extract the class so a new instance
// will be created with given properties
if ( $type instanceof ValidatorInterface ) {
$type = get_class( $type );
}
// From now on, we expect a string, if not, let's just throw an exception
if ( ! is_string( $type ) ) {
throw new Exception\InvalidArgumentException(
sprintf( 'Validator identifier must be in a string, %s given.', gettype( $type ) )
);
}
// If `$type` is the fully qualified name of a validator class, just use it
if ( is_subclass_of( $type, ValidatorInterface::class, TRUE ) ) {
return new $type( $properties );
}
| php | {
"resource": ""
} |
q7444 | ControllerFinder.parseNamespace | train | private function parseNamespace($filePath): string
{
preg_match('/namespace(.*);/', | php | {
"resource": ""
} |
q7445 | Integration.getServiceProvider | train | public static function getServiceProvider() {
if (is_callable('_elgg_services')) {
return _elgg_services();
}
global $CONFIG;
if (!isset($CONFIG)) {
$path = self::getRootPath() . '/engine/settings.php';
if (!is_file($path)) {
$path = self::getRootPath() | php | {
"resource": ""
} |
q7446 | Integration.getElggVersion | train | public static function getElggVersion() {
if (isset(self::$version)) {
return self::$version;
}
if (is_callable('elgg_get_version')) {
return elgg_get_version(true);
} else {
$path = self::getRootPath() . | php | {
"resource": ""
} |
q7447 | MultiotpXmlParser.Parse | train | function Parse()
{
//Create the parser resource
$this->parser = xml_parser_create();
//Set the handlers
xml_set_object($this->parser, $this);
xml_set_element_handler($this->parser, 'StartElement', 'EndElement');
xml_set_character_data_handler($this->parser, 'CharacterData');
//Error handling
if (!xml_parse($this->parser, $this->xml))
$this->HandleError(xml_get_error_code($this->parser), | php | {
"resource": ""
} |
q7448 | MultiotpXmlParser.HandleError | train | function HandleError($code, $line, $col, $byte_index = 0)
{
$sample_size = 80;
$sample_start = $byte_index - ($sample_size / 2);
if ($sample_start < 0) {
$sample_start = 0;
}
trigger_error('XML Parsing Error at '.$line.':'.$col. (($byte_index != 0)?' (byte index: '.$byte_index.')':''). '. Error '.$code.': '.xml_error_string($code). ' check sample which starts at | php | {
"resource": ""
} |
q7449 | MultiotpXmlParser.StartElement | train | function StartElement($parser, $name, $attrs = array())
{
//Make the name of the tag lower case
$name = strtolower($name);
//Check to see if tag is root-level
if (count($this->stack) == 0)
{
//If so, set the document as the current tag
$this->document = new MultiotpXMLTag($name, $attrs);
//And start out the stack with the document tag
$this->stack = array('document');
}
//If it isn't root level, use the stack to find the parent
else
{
//Get the name which points to the current direct parent, relative to $this
$parent = $this->GetStackLocation(); | php | {
"resource": ""
} |
q7450 | MultiotpXMLTag.AddChild | train | function AddChild($name, $attrs, $parents, $cleanTagName = true)
{
//If the tag is a reserved name, output an error
if(in_array($name, array('tagChildren', 'tagAttrs', 'tagParents', 'tagData', 'tagName')))
{
trigger_error('You have used a reserved name as the name of an XML tag. Please consult the documentation (http://www.criticaldevelopment.net/xml/) and rename the tag named "'.$name.'" to something other than a reserved name.', E_USER_ERROR);
return;
}
//Create the child object itself
$child = new MultiotpXMLTag($name, $attrs, $parents);
//If the cleanTagName feature is on, replace colons and dashes with underscores
if($cleanTagName)
| php | {
"resource": ""
} |
q7451 | MultiotpXMLTag.GetXML | train | function GetXML()
{
//Start a new line, indent by the number indicated in $this->parents, add a <, and add the name of the tag
$out = "\n".str_repeat("\t", $this->tagParents).'<'.$this->tagName;
//For each attribute, add attr="value"
foreach($this->tagAttrs as $attr => $value)
$out .= ' '.$attr.'="'.$value.'"';
//If there are no children and it contains no data, end it off with a />
if(empty($this->tagChildren) && empty($this->tagData))
$out .= " />";
//Otherwise...
else
{
//If there are children
if(!empty($this->tagChildren))
{
//Close off the start tag
$out .= '>';
//For each child, call the GetXML function (this will ensure that all children are added recursively)
foreach($this->tagChildren as $child)
| php | {
"resource": ""
} |
q7452 | MultiotpXMLTag.DeleteChildren | train | function DeleteChildren()
{
//Loop through all child tags
for($x = 0; $x < count($this->tagChildren); $x ++)
{
//Do this recursively
$this->tagChildren[$x]->DeleteChildren();
| php | {
"resource": ""
} |
q7453 | Redirect.isTypeJavaScript | train | public function isTypeJavaScript()
{
$redirectType = $this->coreConfig->getConfigByPath(SgCoreInterface::PATH_REDIRECT_TYPE);
| php | {
"resource": ""
} |
q7454 | LocalFileController.view | train | public function view($id)
{
$file = LocalFile::getByIdentifier($id);
$response = response($file->getContents(), 200)->withHeaders([
'Content-Type' => | php | {
"resource": ""
} |
q7455 | LocalFileController.download | train | public function download($id)
{
$file = LocalFile::getByIdentifier($id);
return | php | {
"resource": ""
} |
q7456 | QueryFactoryImpl.createInstanceByQueryString | train | public function createInstanceByQueryString($query)
{
switch ($this->rdfHelpers->getQueryType($query)) {
case 'askQuery':
return new AskQueryImpl($query, $this->rdfHelpers);
case 'constructQuery':
return new ConstructQueryImpl($query, $this->rdfHelpers);
case 'describeQuery':
return new DescribeQueryImpl($query, $this->rdfHelpers);
case 'graphQuery':
return new GraphQueryImpl($query, $this->rdfHelpers);
case 'selectQuery':
| php | {
"resource": ""
} |
q7457 | Model.toFullArray | train | public function toFullArray(): array
{
//convert the obj to array in order to conver to json
$result = get_object_vars($this);
| php | {
"resource": ""
} |
q7458 | TwigExtension.getApp | train | public function getApp(): App
{
if (!is_null($this->getTemplateEngine()->getApp())) {
return $this->getTemplateEngine()->getApp();
} else {
| php | {
"resource": ""
} |
q7459 | TwigExtension.filterDateFormat | train | public function filterDateFormat($datetime, string $pattern = 'dd/MM/yyyy', string $locale = null): string
{
if (empty($locale)) {
| php | {
"resource": ""
} |
q7460 | TwigExtension.functionPath | train | public function functionPath(string $name, array $parameters = []): string
{
| php | {
"resource": ""
} |
q7461 | TwigExtension.functionPreload | train | public function functionPreload(string $link, array $parameters = []): string
{
$push = !(!empty($parameters['nopush']) && $parameters['nopush'] == true);
if (!$push || !in_array(md5($link), $this->h2pushCache)) {
$header = sprintf('Link: <%s>; rel=preload', $link);
// as
if (!empty($parameters['as'])) {
$header = sprintf('%s; as=%s', $header, $parameters['as']);
}
// type
| php | {
"resource": ""
} |
q7462 | BaseAsset.run | train | private function run($type) {
//getting the defined array of assets
//this method will define in the children classes
$this->init();
//making the base path of public dir
$this->getTarget();
//duplication check
if ($type == 'del') {
return Asset::delAsset($this->name);
}
//find all of them between patterns and folders
$this->boot();
//check for those that have to copy to their cache folders
foreach ($this->loop as $kind => $contents) {
if ( ! empty($contents)) {
foreach ($contents as $index => $content) {
if ( ! $this->isPublic($this->baseDir . $content)) {
$index = $this->baseDir . $content;
$this->copy[$kind][$index] = public_path() . $this->target . $content;
} else {
$this->target = '';
}
$this->destination[$kind][] = $this->target . $content;
}
}
}
//remove the ignored items from all other kinds
| php | {
"resource": ""
} |
q7463 | BaseAsset.getTarget | train | private function getTarget() {
$this->name = str_replace('Asset', '', class_basename(static::class));
$name = $this->name;
if ( ! empty($this->cacheFolder)) {
$name = $this->cacheFolder;
}
| php | {
"resource": ""
} |
q7464 | Fix.getDefaultMethod | train | private function getDefaultMethod($price, $cost = null)
{
$method = $this->rateMethodFactory->create();
$method->setData('carrier', $this->getCarrierCode());
$method->setData('carrier_title', 'Shopgate');
$method->setData('method', $this->method);
| php | {
"resource": ""
} |
q7465 | FitTransformer.fill | train | public function fill($image) {
$fill = $this->getConfig('fill');
$r = $fill[0];
$g = $fill[1];
| php | {
"resource": ""
} |
q7466 | DateTimeHelper.getWeekNumberToApply | train | public static function getWeekNumberToApply(DateTime $date, DateTime $startDate, $weekCount, $weekOffset = 1) {
// Check the week arguments.
if ($weekCount <= 0 || $weekOffset <= 0 || $weekCount < $weekOffset) {
return -1;
}
// Calculate.
| php | {
"resource": ""
} |
q7467 | DateTimeHelper.translateWeekday | train | public static function translateWeekday($date, $locale = "en") {
// Initialize.
$template = __DIR__ . "/../Resources/translations/messages.%locale%.yml";
$filename = str_replace("%locale%", $locale, $template);
// Check if the filename exists.
| php | {
"resource": ""
} |
q7468 | FilteredBacktraceReporter.getBacktrace | train | public function getBacktrace($exception = null)
{
$backtrace = parent::getBacktrace($exception);
foreach ($backtrace as $index => $backtraceCall) {
$functionName = $this->buildFunctionName($backtraceCall);
foreach ($this->filteredFunctions as $pattern) {
if (preg_match('/'.$pattern.'/', $functionName)) | php | {
"resource": ""
} |
q7469 | DateTimeAgo.get | train | public function get(DateTime $date, DateTime $reference_date = null )
{
if (is_null($reference_date)) {
$reference_date = new DateTime();
}
| php | {
"resource": ""
} |
q7470 | DateTimeAgo.getText | train | public function getText(DateInterval $diff, $date)
{
if ($this->now($diff)) {
return $this->text_translator->now();
}
if ($this->minutes($diff)) {
return $this->text_translator->minutes($this->minutes($diff));
}
if ($this->hours($diff)) {
return $this->text_translator->hours($this->hours($diff));
}
if ($this->days($diff)) {
return $this->text_translator->days($this->days($diff));
}
if ($this->text_translator->supportsWeeks() && $this->weeks($diff)) {
return $this->text_translator->weeks($this->weeks($diff));
}
if ($this->text_translator->supportsMonths() && | php | {
"resource": ""
} |
q7471 | DateTimeAgo.daily | train | public function daily($diff)
{
if (($diff->y == 0) && ($diff->m == 0) && (($diff->d == 0) || (($diff->d == 1) && ($diff->h == | php | {
"resource": ""
} |
q7472 | DateTimeAgo.hourly | train | public function hourly($diff)
{
if ($this->daily($diff) && ($diff->d == 0) && (($diff->h == 0) || (($diff->h == 1) && | php | {
"resource": ""
} |
q7473 | DateTimeAgo.days | train | public function days(DateInterval $diff)
{
if ($diff->days <= | php | {
"resource": ""
} |
q7474 | DateTimeAgo.weeks | train | public function weeks(DateInterval $diff)
{
if ($diff->days < | php | {
"resource": ""
} |
q7475 | DateTimeAgo.months | train | public function months(DateInterval $diff)
{
if ($diff->days >= 365) {
return FALSE;
| php | {
"resource": ""
} |
q7476 | CookieMonster.addClassOption | train | protected function addClassOption($name, $value)
{
$value = trim($value);
if (substr($value, 0, 1) == '.' || substr($value, 0, 1) == '#') {
$value = substr($value, 1);
}
| php | {
"resource": ""
} |
q7477 | CookieMonster.addContentOption | train | protected function addContentOption($name, $value)
{
$value = trim($value);
if (!empty($value) && is_string($value)) {
| php | {
"resource": ""
} |
q7478 | CookieMonster.addCookieBoolOption | train | protected function addCookieBoolOption($name, $value)
{
if ($value === true || $value === false) {
| php | {
"resource": ""
} |
q7479 | CookieMonster.addCookieIntOption | train | protected function addCookieIntOption($name, $value)
{
$value = trim($value);
if ($value !== null && $value !== '' && is_numeric($value)) {
| php | {
"resource": ""
} |
q7480 | CookieMonster.addCookieOption | train | protected function addCookieOption($name, $value)
{
if (is_string($value)) {
$value = preg_replace("~^;? ?$name=~", '', trim($value));
if ($value !== | php | {
"resource": ""
} |
q7481 | CookieMonster.addParamsOption | train | protected function addParamsOption($name, $value)
{
if (is_array($value) && | php | {
"resource": ""
} |
q7482 | CookieMonster.addStyle | train | protected function addStyle($what, $value)
{
if (is_array($value) && count($value)) {
$type = 'inner';
switch ($what) {
case 0:
$type = 'outer';
break;
case 2:
$type = 'button';
break;
| php | {
"resource": ""
} |
q7483 | CookieMonster.checkContent | train | protected function checkContent()
{
if (is_array($this->content) && count($this->content)) {
foreach ($this->content as $name => $value) {
switch ($name) {
case 'category':
case 'mainMessage':
case 'buttonMessage':
case 'language':
$this->addContentOption($name, $value);
| php | {
"resource": ""
} |
q7484 | CookieMonster.checkCookie | train | protected function checkCookie()
{
if (is_array($this->cookie) && count($this->cookie)) {
foreach ($this->cookie as $name => $value) {
switch ($name) {
case 'domain':
case 'path':
$this->addCookieOption($name, $value);
break;
case 'max-age':
case 'expires': | php | {
"resource": ""
} |
q7485 | CookieMonster.initCookie | train | protected function initCookie()
{
$cookieOptions = Json::encode(
array_merge(
$this->cookieOptions,
[
'classOuter' => str_replace(' ', '.', $this->classOptions['classOuter']),
'classInner' => str_replace(' ', '.', $this->classOptions['classInner']),
| php | {
"resource": ""
} |
q7486 | CookieMonster.prepareViewParams | train | protected function prepareViewParams()
{
$outerStyle = [];
$innerStyle = [];
$buttonStyle = [];
foreach ($this->outerStyle as $name => $value) {
$outerStyle[] = $name . ':' . $value;
}
foreach ($this->innerStyle as $name => $value) {
$innerStyle[] = $name . ':' . $value;
}
foreach ($this->buttonStyle as $name => $value) {
$buttonStyle[] = $name . ':' . $value;
}
return [
'content' => $this->contentOptions,
'outerHtmlOptions' => array_merge(
$this->outerHtml,
[
'style' => implode(';', $outerStyle),
'class' => $this->classOptions['classOuter']
]
),
'innerHtmlOptions' => array_merge(
$this->innerHtml,
[
'style' => | php | {
"resource": ""
} |
q7487 | CookieMonster.replaceStyle | train | protected function replaceStyle($what, $value)
{
if (is_array($value) && count($value)) {
$type = 'inner';
switch ($what) {
case 0:
$type = 'outer';
break;
case 2:
$type = 'button';
break;
}
foreach ($value as $name => $set) {
if (isset($this->{$type . 'Style'}[$name])) | php | {
"resource": ""
} |
q7488 | CookieMonster.setDefaults | train | protected function setDefaults()
{
if (!isset($this->contentOptions['category'])
|| (isset($this->contentOptions['category'])
&& empty($this->contentOptions['category']))) {
$this->contentOptions['category'] = 'app';
}
if (!isset($this->contentOptions['mainParams'])) {
$this->contentOptions['mainParams'] = [];
}
if (!isset($this->contentOptions['buttonParams'])) {
$this->contentOptions['buttonParams'] = [];
}
if (!isset($this->contentOptions['language'])) {
$this->contentOptions['language'] = null;
}
if (!isset($this->contentOptions['mainMessage'])) {
$this->contentOptions['mainMessage'] = 'We use cookies on our websites to | php | {
"resource": ""
} |
q7489 | CookieMonster.setHtmlOptions | train | protected function setHtmlOptions($what, $value)
{
if (is_array($value) && count($value)) {
$type = 'inner';
switch ($what) {
case 0:
$type = 'outer';
break;
case 2:
$type = 'button';
break;
} | php | {
"resource": ""
} |
q7490 | CookieMonster.setMode | train | protected function setMode()
{
$this->outerStyle = [
'display' => 'none',
'z-index' => 10000,
'position' => 'fixed',
'background-color' => '#fff',
'font-size' => '12px',
'color' => '#000'
];
$this->innerStyle = ['margin' => '10px'];
$this->buttonStyle = ['margin-left' => '10px'];
switch ($this->mode) {
case 'bottom':
$this->outerStyle = array_merge(
$this->outerStyle,
[
'bottom' => 0,
'left' => 0,
'width' => '100%',
'box-shadow' => '0 -2px 2px #000',
]
); | php | {
"resource": ""
} |
q7491 | CookieMonster.setCookieView | train | protected function setCookieView($value)
{
$value = trim($value);
if (!empty($value)) {
| php | {
"resource": ""
} |
q7492 | CMySQLDescriptor.buildFieldReplacement | train | public function buildFieldReplacement(array $field_descriptor, $alias = false)
{
if ($alias === false) {
$alias = $field_descriptor['name'];
}
switch ($field_descriptor['data_type']) {
case 'int':
$retval = "%d$alias\$d";
break;
case 'float':
case 'double':
$retval = "%F$alias\$d";
break;
| php | {
"resource": ""
} |
q7493 | CMySQLDescriptor.buildFieldValue | train | public function buildFieldValue($field_descriptor, $value)
{
if ($value === null) {
$retval = 'NULL';
} elseif ($value === false) {
$retval = 'false';
} elseif ($value === true) {
$retval = 'true';
} else {
if (!is_array($value)) {
$value = array($value);
}
switch ($field_descriptor['data_type']) {
case 'int':
$retval = $this->nb_connector->buildSentence('%d', $value);
break;
case 'float':
case 'double':
$retval = $this->nb_connector->buildSentence('%F', $value);
break;
| php | {
"resource": ""
} |
q7494 | PandaSigner.signParams | train | public function signParams($method, $path, array $params = array())
{
$params = $this->completeParams($params);
// generate the signature
| php | {
"resource": ""
} |
q7495 | PandaSigner.signature | train | public function signature($method, $path, array $params = array())
{
$params = $this->completeParams($params);
ksort($params);
if (isset($params['file'])) {
unset($params['file']);
}
$canonicalQueryString = str_replace(
array('+', '%5B', '%5D'),
array('%20', '[', ']'),
http_build_query($params, '', '&')
);
$stringToSign = sprintf(
"%s\n%s\n%s\n%s",
| php | {
"resource": ""
} |
q7496 | PandaSigner.getInstance | train | public static function getInstance($cloudId, Account $account)
{
$signer = new | php | {
"resource": ""
} |
q7497 | BatchResult.getItems | train | public function getItems() {
$batch = $this->getBatch();
$items = array();
foreach ($batch | php | {
"resource": ""
} |
q7498 | BatchResult.export | train | public function export(array $params = array()) {
$result = array(
'type' => 'list',
'count' => $this->getCount(),
'limit' => elgg_extract('limit', $this->options, elgg_get_config('default_limit')),
'offset' => elgg_extract('offset', $this->options, 0),
'items' => array(),
);
| php | {
"resource": ""
} |
q7499 | BatchResult.prepareBatchOptions | train | protected function prepareBatchOptions(array $options = array()) {
if (!in_array($this->getter, array(
'elgg_get_entities',
'elgg_get_entities_from_metadata',
'elgg_get_entities_from_relationship',
))) {
return $options;
}
$sort = elgg_extract('sort', $options);
unset($options['sort']);
if (!is_array($sort)) {
return $options;
}
$dbprefix = elgg_get_config('dbprefix');
$order_by = array();
foreach ($sort as $field => $direction) {
$field = sanitize_string($field);
$direction = strtoupper(sanitize_string($direction));
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
switch ($field) {
case 'alpha' :
if (elgg_extract('types', $options) == 'user') {
$options['joins']['ue'] = "JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid";
$order_by[] = "ue.name {$direction}";
} else if (elgg_extract('types', $options) == 'group') {
$options['joins']['ge'] = "JOIN {$dbprefix}groups_entity ge ON ge.guid = | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.