_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q245300 | ModelToLabelListener.drawLegend | validation | private function drawLegend(ModelToLabelEvent $event)
{
$model = $event->getModel();
$metaModel = $this->getMetaModelFromModel($model);
if (is_array($legend = StringUtil::deserialize($model->getProperty('legendtitle')))) {
foreach ([$metaModel->getActiveLanguage(), $metaModel->getFallbackLanguage()] as $language) {
if (array_key_exists($language, $legend) && !empty($legend[$language])) {
$legend = $legend[$language];
break;
}
}
}
if (empty($legend)) {
$legend = 'legend';
}
$event
->setLabel('<div class="field_heading cte_type %s"><strong>%s</strong></div>
<div class="dca_palette">%s%s</div>')
->setArgs([
$model->getProperty('published') ? 'published' : 'unpublished',
$this->trans('dcatypes.legend'),
$legend,
$model->getProperty('legendhide') ? ':hide' : ''
]);
} | php | {
"resource": ""
} |
q245301 | DifferentValuesException.compare | validation | public static function compare($expected, $actual, $strict = true)
{
try {
self::calculateDiff($expected, $actual, $strict);
} catch (\Exception $exception) {
$instance = new DifferentValuesException(
$expected,
$actual,
$strict,
'The values differ.',
0,
$exception
);
throw $instance;
}
} | php | {
"resource": ""
} |
q245302 | DifferentValuesException.getLongMessage | validation | public function getLongMessage($glue = ' ')
{
$messages = array();
$exception = $this;
do {
$messages[] = $exception->getMessage();
} while (null !== ($exception = $exception->getPrevious()));
return implode($glue, $messages);
} | php | {
"resource": ""
} |
q245303 | DifferentValuesException.isEmptyArrayEquivalent | validation | private static function isEmptyArrayEquivalent($expected, $actual)
{
return (gettype($expected) == 'string')
&& ((gettype($actual) == 'array') || (gettype($actual) == 'NULL'))
&& empty($actual)
&& empty($expected);
} | php | {
"resource": ""
} |
q245304 | DifferentValuesException.calculateArrayDiff | validation | private static function calculateArrayDiff($expected, $actual, $strict)
{
if (count($expected) !== count($actual)) {
throw new \LogicException(
sprintf(
'Array element count mismatch. Found %s, expected %s.',
count($actual),
count($expected)
),
self::ARRAY_COUNT_MISMATCH
);
}
reset($actual);
foreach ($expected as $key => $value) {
if ($key !== key($actual)) {
throw new \LogicException(
sprintf(
'Array key mismatch. Found %s, expected %s.',
key($actual),
$key
),
self::ARRAY_KEY_MISMATCH
);
}
try {
self::calculateDiff($value, current($actual), $strict);
} catch (\Exception $exception) {
throw new \LogicException(
sprintf(
'Array value mismatch for key %s.',
key($actual)
),
self::ARRAY_VALUE_MISMATCH,
$exception
);
}
next($actual);
}
} | php | {
"resource": ""
} |
q245305 | DifferentValuesException.calculateDiff | validation | private static function calculateDiff($expected, $actual, $strict)
{
if ($expected === $actual) {
return;
}
if (gettype($expected) !== gettype($actual)) {
// Only exception of the rule: array values are transported as empty string.
if (!$strict && self::isEmptyArrayEquivalent($expected, $actual)) {
return;
}
throw new \LogicException(
sprintf(
'Encountered type %s expected %s (Found %s, expected %s)',
gettype($actual),
gettype($expected),
var_export($actual, true),
var_export($expected, true)
),
self::TYPE_MISMATCH
);
}
if (is_array($expected)) {
self::calculateArrayDiff($expected, $actual, $strict);
}
throw new \LogicException(
sprintf(
'Found %s expected %s',
var_export($actual, true),
var_export($expected, true)
),
self::VALUE_MISMATCH
);
} | php | {
"resource": ""
} |
q245306 | WithChildren.getReferencedAttributes | validation | public function getReferencedAttributes()
{
$arrAttributes = array();
foreach ($this->arrChildren as $objSetting) {
$arrAttributes = array_merge($arrAttributes, $objSetting->getReferencedAttributes());
}
return $arrAttributes;
} | php | {
"resource": ""
} |
q245307 | DisableMandatoryListener.handle | validation | public function handle(BuildWidgetEvent $event)
{
$environment = $event->getEnvironment();
if (($environment->getDataDefinition()->getName() !== 'tl_metamodel_dcasetting')
|| ($event->getProperty()->getName() !== 'mandatory')
|| (null === $event->getModel()->getId())) {
return;
}
$model = $event->getModel();
$metaModel = $this->getMetaModelFromModel($model);
$attribute = $metaModel->getAttributeById($model->getProperty('attr_id'));
if (null === $attribute) {
return;
}
if ($attribute->get('isunique')) {
Message::addInfo(
$this->translator->trans(
'tl_metamodel_dcasetting.mandatory_for_unique_attr',
[],
'contao_tl_metamodel_dcasetting'
)
);
$extra = $event->getProperty()->getExtra();
$extra['disabled'] = true;
$event->getProperty()->setExtra($extra);
$model->setProperty('mandatory', true);
}
} | php | {
"resource": ""
} |
q245308 | Simple.get | validation | public function get($strName)
{
return isset($this->arrBase[$strName]) ? $this->arrBase[$strName] : null;
} | php | {
"resource": ""
} |
q245309 | ServiceContainerInitializer.configure | validation | public function configure(MetaModelsServiceContainer $serviceContainer)
{
$serviceContainer
->setEventDispatcher(function () {
return $this->container->get('event_dispatcher');
})
->setDatabase(function () {
return $this->container->get('cca.legacy_dic.contao_database_connection');
})
->setAttributeFactory(function () {
return $this->container->get('metamodels.attribute_factory');
})
->setFactory(function () {
return $this->container->get('metamodels.factory');
})
->setFilterFactory(function () {
return $this->container->get('metamodels.filter_setting_factory');
})
->setRenderSettingFactory(function () {
return $this->container->get('metamodels.render_setting_factory');
})
->setCache(function () {
return $this->container->get('metamodels.cache');
});
return $serviceContainer;
} | php | {
"resource": ""
} |
q245310 | LanguageOptionsListener.handle | validation | public function handle(GetOptionsEvent $event)
{
if (!$this->wantToHandle($event)) {
return;
}
$event->setOptions(array_flip(array_filter(array_flip(System::getLanguages()), function ($langCode) {
// Disable >2 char long language codes for the moment.
return (strlen($langCode) == 2);
})));
} | php | {
"resource": ""
} |
q245311 | AddAssetListener.getStylesheets | validation | public function getStylesheets(GetOptionsEvent $event)
{
if (!$this->wantToHandle($event)
|| ($event->getPropertyName() !== 'additionalCss')
|| ($event->getSubPropertyName() !== 'file')) {
return;
}
$event->setOptions($this->scanFiles('css'));
} | php | {
"resource": ""
} |
q245312 | AddAssetListener.getJavascripts | validation | public function getJavascripts(GetOptionsEvent $event)
{
if (($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_rendersettings')
|| ($event->getPropertyName() !== 'additionalJs')
|| ($event->getSubPropertyName() !== 'file')) {
return;
}
$event->setOptions($this->scanFiles('js'));
} | php | {
"resource": ""
} |
q245313 | AddAssetListener.scanFiles | validation | private function scanFiles($extension)
{
$files = [];
foreach (Finder::create()->in($this->uploadPath)->name('*.' . $extension)->getIterator() as $item) {
$files[] = 'files/' . Path::normalize($item->getRelativePathname());
}
return $files;
} | php | {
"resource": ""
} |
q245314 | ViewCombinations.getUser | validation | public function getUser()
{
static $authenticated;
if (!isset($authenticated)) {
$authenticated = true;
$this->authenticateUser();
}
return $this->user;
} | php | {
"resource": ""
} |
q245315 | ViewCombinations.resolve | validation | protected function resolve()
{
$factory = $this->container->getFactory();
$names = $factory->collectNames();
foreach ($names as $name) {
$this->information[$name] = array
(
self::COMBINATION => null,
self::INPUTSCREEN => null,
self::RENDERSETTING => null,
self::MODELID => null,
);
}
$found = $this->getPaletteCombinationRows();
if (!$found) {
$found = array();
}
// Clean any undefined.
foreach (array_keys($this->information) as $tableName) {
if (empty($this->information[$tableName][self::COMBINATION])
|| empty($this->information[$tableName][self::COMBINATION]['dca_id'])
|| empty($this->information[$tableName][self::COMBINATION]['view_id'])
) {
unset($this->information[$tableName]);
}
}
$this->fetchInputScreenDetails();
} | php | {
"resource": ""
} |
q245316 | ViewCombinations.setTableMapping | validation | protected function setTableMapping($modelId, $tableName)
{
$this->information[$tableName][self::MODELID] = $modelId;
$this->tableMap[$modelId] = $tableName;
} | php | {
"resource": ""
} |
q245317 | ViewCombinations.getMetaModelName | validation | protected function getMetaModelName($nameOrId)
{
return isset($this->tableMap[$nameOrId]) ? $this->tableMap[$nameOrId] : $nameOrId;
} | php | {
"resource": ""
} |
q245318 | ViewCombinations.getPaletteCombinationRows | validation | protected function getPaletteCombinationRows()
{
$combinations = $this->getCombinationsFromDatabase();
$success = array();
// No combinations present, nothing to resolve.
if (!$combinations) {
return array_keys($this->information);
}
foreach ($combinations as $combination) {
/** @noinspection PhpUndefinedFieldInspection */
$modelId = $combination->pid;
$modelName = $this->tableNameFromId($modelId);
// Already a combination present, continue with next one.
if (!empty($this->information[$modelName][self::COMBINATION])) {
continue;
}
/** @noinspection PhpUndefinedFieldInspection */
$this->information[$modelName][self::MODELID] = $modelId;
/** @noinspection PhpUndefinedFieldInspection */
$this->information[$modelName][self::COMBINATION] = array(
'dca_id' => $combination->dca_id,
'view_id' => $combination->view_id
);
$this->setTableMapping($modelId, $modelName);
$success[] = $modelId;
}
return $success;
} | php | {
"resource": ""
} |
q245319 | ViewCombinations.fetchInputScreenDetails | validation | protected function fetchInputScreenDetails()
{
$inputScreenIds = array();
foreach ($this->information as $info) {
$inputScreenIds[] = $info[self::COMBINATION]['dca_id'];
}
if (!$inputScreenIds) {
return;
}
$statement = $this->connection->query(
sprintf(
'SELECT * FROM tl_metamodel_dca WHERE id IN (%s)',
implode(',', $inputScreenIds)
)
);
while ($inputScreens = $statement->fetch(\PDO::FETCH_OBJ)) {
/** @noinspection PhpUndefinedFieldInspection */
$screenId = $inputScreens->id;
/** @noinspection PhpUndefinedFieldInspection */
$metaModelId = $inputScreens->pid;
$metaModelName = $this->tableNameFromId($metaModelId);
$propertyRows = $this->connection
->prepare('SELECT * FROM tl_metamodel_dcasetting WHERE pid=? AND published=1 ORDER BY sorting ASC');
$propertyRows->bindValue(1, $screenId);
$propertyRows->execute();
$conditions = $this->connection->prepare('
SELECT cond.*, setting.attr_id AS setting_attr_id
FROM tl_metamodel_dcasetting_condition AS cond
LEFT JOIN tl_metamodel_dcasetting AS setting
ON (cond.settingId=setting.id)
LEFT JOIN tl_metamodel_dca AS dca
ON (setting.pid=dca.id)
WHERE dca.id=? AND setting.published=1 AND cond.enabled=1
ORDER BY sorting ASC
');
$conditions->bindValue(1, $screenId);
$conditions->execute();
$groupSort = $this->connection->prepare('
SELECT *
FROM tl_metamodel_dca_sortgroup
WHERE pid=?
ORDER BY sorting ASC
');
$groupSort->bindValue(1, $screenId);
$groupSort->execute();
$inputScreen = array(
'row' => $inputScreens->row(),
'properties' => $propertyRows->fetchAll(\PDO::FETCH_ASSOC),
'conditions' => $conditions->fetchAll(\PDO::FETCH_ASSOC),
'groupSort' => $groupSort->fetchAll(\PDO::FETCH_ASSOC)
);
$this->information[$metaModelName][self::INPUTSCREEN] = $inputScreen;
$this->information[$metaModelName][self::MODELID] = $metaModelId;
$parentTable = $inputScreen['row']['ptable'];
if ($parentTable && !$this->isInputScreenStandalone($metaModelName)) {
$this->parentMap[$parentTable][] = $this->information[$metaModelName][self::MODELID];
$this->childMap[$metaModelName] = $parentTable;
}
}
} | php | {
"resource": ""
} |
q245320 | ViewCombinations.buildInputScreen | validation | protected function buildInputScreen($metaModel)
{
$metaModelName = $this->getMetaModelName($metaModel);
$inputScreen = $this->information[$metaModelName][self::INPUTSCREEN];
if (!is_object($inputScreen)) {
$inputScreen = $this->information[$metaModelName][self::INPUTSCREEN] = new InputScreen(
$this->container,
$inputScreen['row'],
$inputScreen['properties'],
$inputScreen['conditions'],
$inputScreen['groupSort']
);
}
return $inputScreen;
} | php | {
"resource": ""
} |
q245321 | ViewCombinations.isInputScreenStandalone | validation | protected function isInputScreenStandalone($metaModel)
{
$information = $this->information[$metaModel];
$inputScreen = isset($information[self::INPUTSCREEN]) ? $information[self::INPUTSCREEN] : null;
if (!is_object($inputScreen)) {
return ($inputScreen['row']['rendertype'] == 'standalone');
}
/** @var IInputScreen $inputScreen */
return $inputScreen->isStandalone();
} | php | {
"resource": ""
} |
q245322 | ViewCombinations.getRenderSetting | validation | public function getRenderSetting($metaModel)
{
$metaModelName = $this->getMetaModelName($metaModel);
return isset($this->information[$metaModelName][self::COMBINATION]['view_id'])
? $this->information[$metaModelName][self::COMBINATION]['view_id']
: null;
} | php | {
"resource": ""
} |
q245323 | ViewCombinations.getInputScreen | validation | public function getInputScreen($metaModel)
{
$inputScreen = $this->getInputScreenDetails($metaModel);
return $inputScreen ? $inputScreen->getId() : null;
} | php | {
"resource": ""
} |
q245324 | ViewCombinations.getStandaloneInputScreens | validation | public function getStandaloneInputScreens()
{
$result = array();
foreach (array_keys($this->information) as $modelName) {
if ($this->isInputScreenStandalone($modelName)) {
$result[] = $this->getInputScreenDetails($modelName);
}
}
return $result;
} | php | {
"resource": ""
} |
q245325 | ViewCombinations.getParentOf | validation | public function getParentOf($metaModel)
{
$metaModelName = $this->getMetaModelName($metaModel);
return isset($this->childMap[$metaModelName]) ? $this->childMap[$metaModelName] : null;
} | php | {
"resource": ""
} |
q245326 | BreadcrumbStoreFactory.createStore | validation | public function createStore()
{
$request = $this->requestStack->getCurrentRequest();
return new BreadcrumbStore($this->iconBuilder, $this->translator, $request ? $request->getUri() : '');
} | php | {
"resource": ""
} |
q245327 | FilterParamWidgetListener.handle | validation | public function handle(BuildWidgetEvent $event)
{
if (!$this->wantToHandle($event) || ($event->getProperty()->getName() !== 'filterparams')) {
return;
}
$model = $event->getModel();
$objFilterSettings = $this->settingFactory->createCollection($model->getProperty('filter'));
$extra = $event->getProperty()->getExtra();
$extra['subfields'] = $objFilterSettings->getParameterDCA();
$event->getProperty()->setExtra($extra);
} | php | {
"resource": ""
} |
q245328 | Stringify.transformDSLTermToString | validation | protected function transformDSLTermToString($dslTerm) {
$string = "";
if (is_array($dslTerm)) {
$key = key($dslTerm);
$value = $dslTerm[$key];
if (is_string($key))
$string .= "$key:";
}
else
$value = $dslTerm;
/**
* If a specific key is used as key in the array
* this should translate to searching in a specific field (field:term)
*/
if (strpos($value, " ") !== false)
$string .= '"' . $value . '"';
else
$string .= $value;
return $string;
} | php | {
"resource": ""
} |
q245329 | Stringify.transformDSLSortToString | validation | protected function transformDSLSortToString($dslSort) {
$string = "";
if (is_array($dslSort)) {
foreach ($dslSort as $sort) {
if (is_array($sort)) {
$field = key($sort);
$info = current($sort);
}
else
$field = $sort;
$string .= "&sort=" . $field;
if (isset($info)) {
if (is_string($info) && $info == "desc")
$string .= ":reverse";
elseif (is_array($info) && array_key_exists("reverse", $info) && $info['reverse'])
$string .= ":reverse";
}
}
}
return $string;
} | php | {
"resource": ""
} |
q245330 | Base.buildUrl | validation | protected function buildUrl($path = false, array $options = array()) {
$isAbsolute = (is_array($path) ? $path[0][0] : $path[0]) === '/';
$url = $isAbsolute || null === $this->index ? '' : "/" . $this->index;
if ($path && is_array($path) && count($path) > 0)
$url .= "/" . implode("/", array_filter($path));
if (substr($url, -1) == "/")
$url = substr($url, 0, -1);
if (count($options) > 0)
$url .= "?" . http_build_query($options, '', '&');
return $url;
} | php | {
"resource": ""
} |
q245331 | Bulk.delete | validation | public function delete($id=false, $index, $type, array $options = array()) {
$params = array( '_id' => $id,
'_index' => $index,
'_type' => $type);
foreach ($options as $key => $value) {
$params['_' . $key] = $value;
}
$operation = array(
array('delete' => $params)
);
$this->operations[] = $operation;
return $this;
} | php | {
"resource": ""
} |
q245332 | Bulk.createPayload | validation | public function createPayload()
{
$payloads = array();
foreach ($this->operations as $operation) {
foreach ($operation as $partial) {
$payloads[] = json_encode($partial);
}
}
return join("\n", $payloads)."\n";
} | php | {
"resource": ""
} |
q245333 | Query.term | validation | public function term($term, $field=false) {
$this->term = ($field)
? array($field => $term)
: $term;
return $this;
} | php | {
"resource": ""
} |
q245334 | Query.wildcard | validation | public function wildcard($val, $field=false) {
$this->wildcard = ($field)
? array($field => $val)
: $val;
return $this;
} | php | {
"resource": ""
} |
q245335 | Builder.query | validation | public function query(array $options=array()) {
if (!($this->query instanceof Query))
$this->query = new Query($options);
return $this->query;
} | php | {
"resource": ""
} |
q245336 | HTTP.call | validation | protected function call($url, $method="GET", $payload=null) {
$conn = $this->ch;
$protocol = "http";
$requestURL = $protocol . "://" . $this->host . $url;
curl_setopt($conn, CURLOPT_URL, $requestURL);
curl_setopt($conn, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($conn, CURLOPT_PORT, $this->port);
curl_setopt($conn, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($conn, CURLOPT_FORBID_REUSE , 0) ;
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json';
curl_setopt($conn, CURLOPT_HTTPHEADER, $headers);
if (is_array($payload) && count($payload) > 0)
curl_setopt($conn, CURLOPT_POSTFIELDS, json_encode($payload)) ;
else
curl_setopt($conn, CURLOPT_POSTFIELDS, $payload);
// cURL opt returntransfer leaks memory, therefore OB instead.
ob_start();
curl_exec($conn);
$response = ob_get_clean();
if ($response !== false) {
$data = json_decode($response, true);
if (!$data) {
$data = array('error' => $response, "code" => curl_getinfo($conn, CURLINFO_HTTP_CODE));
}
}
else {
/**
* cUrl error code reference can be found here:
* http://curl.haxx.se/libcurl/c/libcurl-errors.html
*/
$errno = curl_errno($conn);
switch ($errno)
{
case CURLE_UNSUPPORTED_PROTOCOL:
$error = "Unsupported protocol [$protocol]";
break;
case CURLE_FAILED_INIT:
$error = "Internal cUrl error?";
break;
case CURLE_URL_MALFORMAT:
$error = "Malformed URL [$requestURL] -d " . json_encode($payload);
break;
case CURLE_COULDNT_RESOLVE_PROXY:
$error = "Couldnt resolve proxy";
break;
case CURLE_COULDNT_RESOLVE_HOST:
$error = "Couldnt resolve host";
break;
case CURLE_COULDNT_CONNECT:
$error = "Couldnt connect to host [{$this->host}], ElasticSearch down?";
break;
case CURLE_OPERATION_TIMEDOUT:
$error = "Operation timed out on [$requestURL]";
break;
default:
$error = "Unknown error";
if ($errno == 0) {
$error .= ". Non-cUrl error";
} else {
$errstr = curl_error($conn);
$error .= " ($errstr)";
}
break;
}
$exception = new HTTPException($error);
$exception->payload = $payload;
$exception->port = $this->port;
$exception->protocol = $protocol;
$exception->host = $this->host;
$exception->method = $method;
throw $exception;
}
return $data;
} | php | {
"resource": ""
} |
q245337 | RangeQuery.build | validation | public function build() {
$built = array();
if ($this->fieldname) {
$built[$this->fieldname] = array();
foreach (array("from","to","includeLower","includeUpper", "boost") as $opt) {
if ($this->$opt !== null)
$built[$this->fieldname][$opt] = $this->$opt;
}
if (count($built[$this->fieldname]) == 0)
throw new \ElasticSearch\Exception("Empty RangeQuery cant be created");
}
return $built;
} | php | {
"resource": ""
} |
q245338 | Mapping.field | validation | public function field($field, $config = array()) {
if (is_string($config)) $config = array('type' => $config);
$this->properties[$field] = $config;
return $this;
} | php | {
"resource": ""
} |
q245339 | Mapping.config | validation | public function config($key, $value = null) {
if (is_array($key))
$this->config = $key + $this->config;
else {
if ($value !== null) $this->config[$key] = $value;
if (!isset($this->config[$key]))
throw new \Exception("Configuration key `type` is not set");
return $this->config[$key];
}
} | php | {
"resource": ""
} |
q245340 | Client.setIndex | validation | public function setIndex($index) {
if (is_array($index))
$index = implode(",", array_filter($index));
$this->index = $index;
$this->transport->setIndex($index);
return $this;
} | php | {
"resource": ""
} |
q245341 | Client.setType | validation | public function setType($type) {
if (is_array($type))
$type = implode(",", array_filter($type));
$this->type = $type;
$this->transport->setType($type);
return $this;
} | php | {
"resource": ""
} |
q245342 | Client.map | validation | public function map($mapping, array $config = array()) {
if (is_array($mapping)) $mapping = new Mapping($mapping);
$mapping->config($config);
try {
$type = $mapping->config('type');
}
catch (\Exception $e) {} // No type is cool
if (isset($type) && !$this->passesTypeConstraint($type)) {
throw new Exception("Cant create mapping due to type constraint mismatch");
}
return $this->request('_mapping', 'PUT', $mapping->export(), true);
} | php | {
"resource": ""
} |
q245343 | Client.request | validation | public function request($path, $method = 'GET', $payload = false, $verbose=false) {
$response = $this->transport->request($this->expandPath($path), $method, $payload);
return ($verbose || !isset($response['_source']))
? $response
: $response['_source'];
} | php | {
"resource": ""
} |
q245344 | Client.search | validation | public function search($query, array $options = array()) {
$start = microtime(true);
$result = $this->transport->search($query, $options);
$result['time'] = microtime(true) - $start;
return $result;
} | php | {
"resource": ""
} |
q245345 | Client.parseDsn | validation | protected static function parseDsn($dsn) {
$parts = parse_url($dsn);
$protocol = $parts['scheme'];
$servers = $parts['host'] . ':' . $parts['port'];
if (isset($parts['path'])) {
$path = explode('/', $parts['path']);
list($index, $type) = array_values(array_filter($path));
}
return compact('protocol', 'servers', 'index', 'type');
} | php | {
"resource": ""
} |
q245346 | Client.beginBulk | validation | public function beginBulk() {
if (!$this->bulk) {
$this->bulk = $this->createBulk($this);
}
return $this->bulk;
} | php | {
"resource": ""
} |
q245347 | Client.commitBulk | validation | public function commitBulk() {
if ($this->bulk && $this->bulk->count()) {
$result = $this->bulk->commit();
$this->bulk = null;
return $result;
}
} | php | {
"resource": ""
} |
q245348 | Aoe_TemplateHints_Model_Observer.showHints | validation | public function showHints() {
if (is_null($this->showHints)) {
$this->showHints = false;
if (Mage::helper('core')->isDevAllowed()) {
if (Mage::getSingleton('core/cookie')->get('ath') || Mage::app()->getRequest()->get('ath')) {
$this->showHints = true;
}
}
}
return $this->showHints;
} | php | {
"resource": ""
} |
q245349 | Aoe_TemplateHints_Helper_Data.getSkinFileContent | validation | public function getSkinFileContent($file) {
$package = Mage::getSingleton('core/design_package');
$areaBackup = $package->getArea();
$path = $package
->setArea('frontend')
->getFilename($file, array('_type' => 'skin'));
$content = file_get_contents($path);
$package->setArea($areaBackup);
return $content;
} | php | {
"resource": ""
} |
q245350 | Aoe_TemplateHints_Model_Adminhtml_System_Config_Source_HintRenderer.toOptionArray | validation | public function toOptionArray() {
$options = array();
$options[] = array(
'value'=> 'aoe_templatehints/renderer_comment',
'label'=> Mage::helper('aoe_templatehints')->__('Comments')
);
$options[] = array(
'value'=> 'aoe_templatehints/renderer_opentip',
'label'=> Mage::helper('aoe_templatehints')->__('Popups')
);
$options[] = array(
'value'=> 'aoe_templatehints/renderer_tipOnly',
'label'=> Mage::helper('aoe_templatehints')->__('Popups (border initially invisible)')
);
Mage::dispatchEvent('aoetemplatehints_hintrenderer_options', array('options' => &$options));
return $options;
} | php | {
"resource": ""
} |
q245351 | Aoe_TemplateHints_Model_Renderer_Comment.arrayToTabList | validation | protected function arrayToTabList(array $array, array $skipKeys=array(), $indentationLevel = 1) {
$output = '';
foreach($array as $key => $value) {
if (in_array($key, $skipKeys, true)) {
continue;
}
$output .= $this->tabsForIndentation($indentationLevel);
if (!is_array($value)) {
if (!is_int($key)) {
$output .= ucfirst($key) . ":\n";
$output .= $this->tabsForIndentation($indentationLevel+1);
}
$output .= $value . "\n";
}
else {
$output .= ucfirst($key) . ":\n";
$output .= $this->arrayToTabList($value, $skipKeys, $indentationLevel+1);
}
}
return $output;
} | php | {
"resource": ""
} |
q245352 | Aoe_TemplateHints_Helper_ClassInfo.findFileAndLine | validation | public function findFileAndLine($className) {
$result = false;
$fullPath = $this->searchFullPath($this->getFileFromClassName($className));
if ($fullPath) {
$result = array('file' => $fullPath, 'line' => 0);
$lineNumber = $this->getLineNumber($fullPath, '/class\s+'.$className.'/');
if ($lineNumber) {
$result['line'] = $lineNumber;
}
}
return $result;
} | php | {
"resource": ""
} |
q245353 | Aoe_TemplateHints_Helper_ClassInfo.searchFullPath | validation | public function searchFullPath($filename) {
$paths = explode(PATH_SEPARATOR, get_include_path());
foreach ($paths as $path) {
$fullPath = $path . DIRECTORY_SEPARATOR . $filename;
if (file_exists($fullPath)) {
return $fullPath;
}
}
return false;
} | php | {
"resource": ""
} |
q245354 | Aoe_TemplateHints_Helper_BlockInfo.getBlockInfo | validation | public function getBlockInfo(Mage_Core_Block_Abstract $block, $fullInfo=true) {
$info = array(
'name' => $block->getNameInLayout(),
'alias' => $block->getBlockAlias(),
);
if (!$fullInfo) {
return $info;
}
$info['class'] = get_class($block);
if ($this->getRemoteCallEnabled()) {
$fileAndLine = Mage::helper('aoe_templatehints/classInfo')->findFileAndLine($info['class']);
if ($fileAndLine) {
$url = sprintf($this->getRemoteCallUrlTemplate(), $fileAndLine['file'], $fileAndLine['line']);
$info['class'] = sprintf($this->getRemoteCallLinkTemplate(),
$url,
$info['class']
);
}
}
$info['module'] = $block->getModuleName();
if ($block instanceof Mage_Cms_Block_Block) {
$info['cms-blockId'] = $block->getBlockId();
}
if ($block instanceof Mage_Cms_Block_Page) {
$info['cms-pageId'] = $block->getPage()->getIdentifier();
}
$templateFile = $block->getTemplateFile();
if ($templateFile) {
$info['template'] = $templateFile;
if ($this->getRemoteCallEnabled()) {
$url = sprintf($this->getRemoteCallUrlTemplate(), Mage::getBaseDir('design') . DS . $templateFile, 0);
$info['template'] = sprintf($this->getRemoteCallLinkTemplate(),
$url,
$templateFile
);
}
}
// cache information
$info['cache-status'] = self::TYPE_NOTCACHED;
$cacheLifeTime = $block->getCacheLifetime();
if (!is_null($cacheLifeTime)) {
$info['cache-lifetime'] = (intval($cacheLifeTime) == 0) ? 'forever' : intval($cacheLifeTime) . ' sec';
$info['cache-key'] = $block->getCacheKey();
$info['cache-key-info'] = is_array($block->getCacheKeyInfo())
? implode(', ', $block->getCacheKeyInfo())
: $block->getCacheKeyInfo()
;
$info['tags'] = implode(',', $block->getCacheTags());
$info['cache-status'] = self::TYPE_CACHED;
} elseif ($this->isWithinCachedBlock($block)) {
$info['cache-status'] = self::TYPE_IMPLICITLYCACHED; // not cached, but within cached
}
$info['methods'] = $this->getClassMethods(get_class($block));
return $info;
} | php | {
"resource": ""
} |
q245355 | Aoe_TemplateHints_Helper_BlockInfo.getRemoteCallEnabled | validation | public function getRemoteCallEnabled() {
if (is_null($this->remoteCallEnabled)) {
$this->remoteCallEnabled = Mage::getStoreConfigFlag('dev/aoe_templatehints/enablePhpstormRemoteCall');
}
return $this->remoteCallEnabled;
} | php | {
"resource": ""
} |
q245356 | Aoe_TemplateHints_Helper_BlockInfo.getRemoteCallUrlTemplate | validation | public function getRemoteCallUrlTemplate() {
if (is_null($this->remoteCallUrlTemplate)) {
$this->remoteCallUrlTemplate = Mage::getStoreConfig('dev/aoe_templatehints/remoteCallUrlTemplate');
}
return $this->remoteCallUrlTemplate;
} | php | {
"resource": ""
} |
q245357 | Aoe_TemplateHints_Helper_BlockInfo.getBlockPath | validation | public function getBlockPath(Mage_Core_Block_Abstract $block) {
$blockPath = array();
$step = $block->getParentBlock();
$i = 0;
while ($i++ < 20 && $step instanceof Mage_Core_Block_Abstract) {
$blockPath[] = $this->getBlockInfo($step, false);
$step = $step->getParentBlock();
}
return $blockPath;
} | php | {
"resource": ""
} |
q245358 | Aoe_TemplateHints_Helper_BlockInfo.isWithinCachedBlock | validation | public function isWithinCachedBlock(Mage_Core_Block_Abstract $block) {
$step = $block;
$i = 0;
while ($i++ < 20 && $step instanceof Mage_Core_Block_Abstract) {
if (!is_null($step->getCacheLifetime())) {
return true;
}
$step = $step->getParentBlock();
}
return false;
} | php | {
"resource": ""
} |
q245359 | Type.getType | validation | public static function getType($name)
{
if ( ! isset(self::$_typeObjects[$name])) {
if ( ! isset(self::$_typesMap[$name])) {
throw TypeException::unknownType($name);
}
self::$_typeObjects[$name] = new self::$_typesMap[$name]();
}
return self::$_typeObjects[$name];
} | php | {
"resource": ""
} |
q245360 | Type.addType | validation | public static function addType($name, $className)
{
if (isset(self::$_typesMap[$name])) {
throw TypeException::typeExists($name);
}
self::$_typesMap[$name] = $className;
} | php | {
"resource": ""
} |
q245361 | Type.overrideType | validation | public static function overrideType($name, $className)
{
if ( ! isset(self::$_typesMap[$name])) {
throw TypeException::typeNotFound($name);
}
self::$_typesMap[$name] = $className;
} | php | {
"resource": ""
} |
q245362 | ProxyFactory.getProxy | validation | public function getProxy($className, $identifier)
{
$fqn = ClassUtils::generateProxyClassName($className, $this->proxyNamespace);
if ( ! class_exists($fqn, false)) {
$fileName = $this->getProxyFileName($className);
if ($this->autoGenerate) {
$this->generateProxyClass($this->dm->getClassMetadata($className), $fileName, self::$proxyClassTemplate);
}
require $fileName;
}
if ( ! $this->dm->getMetadataFactory()->hasMetadataFor($fqn)) {
$this->dm->getMetadataFactory()->setMetadataFor($fqn, $this->dm->getClassMetadata($className));
}
return new $fqn($this->dm, $identifier);
} | php | {
"resource": ""
} |
q245363 | ProxyFactory.getProxyFileName | validation | private function getProxyFileName($className, $baseDir = null)
{
$proxyDir = $baseDir ?: $this->proxyDir;
return $proxyDir . DIRECTORY_SEPARATOR . '__CG__' . str_replace('\\', '', $className) . '.php';
} | php | {
"resource": ""
} |
q245364 | ProxyFactory.generateProxyClasses | validation | public function generateProxyClasses(array $classes, $toDir = null)
{
$proxyDir = $toDir ?: $this->proxyDir;
$proxyDir = rtrim($proxyDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
foreach ($classes as $class) {
/* @var $class ClassMetadata */
if ($class->isMappedSuperclass) {
continue;
}
$proxyFileName = $this->getProxyFileName($class->name, $toDir);
$this->generateProxyClass($class, $proxyFileName, self::$proxyClassTemplate);
}
} | php | {
"resource": ""
} |
q245365 | ProxyFactory.generateProxyClass | validation | private function generateProxyClass($class, $fileName, $template)
{
$methods = $this->generateMethods($class);
$sleepImpl = $this->generateSleep($class);
$placeholders = array(
'<namespace>',
'<proxyClassName>', '<className>',
'<methods>', '<sleepImpl>'
);
$className = ltrim($class->name, '\\');
$proxyClassName = ClassUtils::generateProxyClassName($class->name, $this->proxyNamespace);
$parts = explode('\\', strrev($proxyClassName), 2);
$proxyClassNamespace = strrev($parts[1]);
$proxyClassName = strrev($parts[0]);
$replacements = array(
$proxyClassNamespace,
$proxyClassName,
$className,
$methods,
$sleepImpl
);
$template = str_replace($placeholders, $replacements, $template);
file_put_contents($fileName, $template, LOCK_EX);
} | php | {
"resource": ""
} |
q245366 | ProxyFactory.generateMethods | validation | private function generateMethods(ClassMetadata $class)
{
$methods = '';
foreach ($class->reflClass->getMethods() as $method) {
/* @var $method \ReflectionMethod */
if ($method->isConstructor() || strtolower($method->getName()) == "__sleep") {
continue;
}
if ($method->isPublic() && ! $method->isFinal() && ! $method->isStatic()) {
$methods .= PHP_EOL . ' public function ';
if ($method->returnsReference()) {
$methods .= '&';
}
$methods .= $method->getName() . '(';
$firstParam = true;
$parameterString = $argumentString = '';
foreach ($method->getParameters() as $param) {
if ($firstParam) {
$firstParam = false;
} else {
$parameterString .= ', ';
$argumentString .= ', ';
}
// We need to pick the type hint class too
if (($paramClass = $param->getClass()) !== null) {
$parameterString .= '\\' . $paramClass->getName() . ' ';
} else if ($param->isArray()) {
$parameterString .= 'array ';
}
if ($param->isPassedByReference()) {
$parameterString .= '&';
}
$parameterString .= '$' . $param->getName();
$argumentString .= '$' . $param->getName();
if ($param->isDefaultValueAvailable()) {
$parameterString .= ' = ' . var_export($param->getDefaultValue(), true);
}
}
$methods .= $parameterString . ')';
$methods .= PHP_EOL . ' {' . PHP_EOL;
$methods .= ' $this->__load();' . PHP_EOL;
$methods .= ' return parent::' . $method->getName() . '(' . $argumentString . ');';
$methods .= PHP_EOL . ' }' . PHP_EOL;
}
}
return $methods;
} | php | {
"resource": ""
} |
q245367 | Configuration.getDocumentNamespace | validation | public function getDocumentNamespace($documentNamespaceAlias)
{
if ( ! isset($this->attributes['documentNamespaces'][$documentNamespaceAlias])) {
throw CouchDBException::unknownDocumentNamespace($documentNamespaceAlias);
}
return trim($this->attributes['documentNamespaces'][$documentNamespaceAlias], '\\');
} | php | {
"resource": ""
} |
q245368 | Configuration.newDefaultAnnotationDriver | validation | public function newDefaultAnnotationDriver($paths = array())
{
$reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader();
$reader->addNamespace('Doctrine\ODM\CouchDB\Mapping\Annotations');
return new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
} | php | {
"resource": ""
} |
q245369 | ClassMetadataFactory.loadMetadata | validation | protected function loadMetadata($className)
{
if (class_exists($className)) {
return parent::loadMetadata($className);
}
throw MappingException::classNotFound($className);
} | php | {
"resource": ""
} |
q245370 | DocumentManager.createQuery | validation | public function createQuery($designDocName, $viewName)
{
$designDoc = $this->config->getDesignDocument($designDocName);
if ($designDoc) {
$designDoc = new $designDoc['className']($designDoc['options']);
}
$query = new ODMQuery($this->couchDBClient->getHttpClient(), $this->couchDBClient->getDatabase(), $designDocName, $viewName, $designDoc);
$query->setDocumentManager($this);
return $query;
} | php | {
"resource": ""
} |
q245371 | DocumentManager.createNativeQuery | validation | public function createNativeQuery($designDocName, $viewName)
{
$designDoc = $this->config->getDesignDocument($designDocName);
if ($designDoc) {
$designDoc = new $designDoc['className']($designDoc['options']);
}
$query = new Query($this->couchDBClient->getHttpClient(), $this->couchDBClient->getDatabase(), $designDocName, $viewName, $designDoc);
return $query;
} | php | {
"resource": ""
} |
q245372 | DocumentManager.createLuceneQuery | validation | public function createLuceneQuery($designDocName, $viewName)
{
$luceneHandlerName = $this->config->getLuceneHandlerName();
$designDoc = $this->config->getDesignDocument($designDocName);
if ($designDoc) {
$designDoc = new $designDoc['className']($designDoc['options']);
}
$query = new ODMLuceneQuery($this->couchDBClient->getHttpClient(),
$this->couchDBClient->getDatabase(), $luceneHandlerName, $designDocName,
$viewName, $designDoc
);
$query->setDocumentManager($this);
return $query;
} | php | {
"resource": ""
} |
q245373 | DocumentManager.clear | validation | public function clear($objectName = null)
{
if ($objectName === null) {
// Todo: Do a real delegated clear?
$this->unitOfWork = new UnitOfWork($this);
} else {
//TODO
throw new CouchDBException("DocumentManager#clear(\$objectName) not yet implemented.");
}
} | php | {
"resource": ""
} |
q245374 | DocumentManager.initializeObject | validation | public function initializeObject($obj)
{
if ($obj instanceof PersistentCollection) {
$obj->initialize();
} else if ($obj instanceof Proxy\Proxy) {
$obj->__doctrineLoad__();
}
} | php | {
"resource": ""
} |
q245375 | AESGCM.encryptAndAppendTag | validation | public static function encryptAndAppendTag($K, $IV, $P = null, $A = null, $tag_length = 128)
{
return implode(self::encrypt($K, $IV, $P, $A, $tag_length));
} | php | {
"resource": ""
} |
q245376 | AESGCM.decryptWithAppendedTag | validation | public static function decryptWithAppendedTag($K, $IV, $Ciphertext = null, $A = null, $tag_length = 128)
{
$tag_length_in_bits = $tag_length / 8;
$C = mb_substr($Ciphertext, 0, -$tag_length_in_bits, '8bit');
$T = mb_substr($Ciphertext, -$tag_length_in_bits, null, '8bit');
return self::decrypt($K, $IV, $C, $A, $T);
} | php | {
"resource": ""
} |
q245377 | Curl.getParams | validation | public function getParams(array $params)
{
$r = '';
ksort($params);
foreach ($params as $key => $value) {
$r .= '&' . $key . '=' . rawurlencode($value);
}
unset($params, $key, $value);
return trim($r, '&');
} | php | {
"resource": ""
} |
q245378 | Curl.processHeaders | validation | protected function processHeaders($headers)
{
$out = array();
$headers = explode("\r\n", trim($headers));
foreach ($headers as $header) {
if (strpos($header, ':') !== false) {
$tmp = explode(':', $header);
$out[reset($tmp)] = end($tmp);
} else {
if (!isset($out['http-code'])) {
$out['http-code'] = $header;
}
}
}
unset($headers, $header, $tmp);
return $out;
} | php | {
"resource": ""
} |
q245379 | SingleUserAuth.postMedia | validation | public function postMedia($call, $filename)
{
$this->resetCallState();
$this->call = $call;
$this->method = 'POST';
$this->withMedia = true;
$mimeBoundary = sha1($call . microtime());
$params = array(
'post' => $this->buildMultipart($mimeBoundary, $filename),
'headers' => $this->buildUploadMediaHeader($mimeBoundary),
);
$response = $this->curl->send($this->getUrl(), $params);
$obj = json_decode($response['body']);
if (!$obj || !isset($obj->token_type) || $obj->token_type != 'bearer') {
$this->findExceptions($response);
}
$this->headers = $response['headers'];
$this->withMedia = null;
unset($call, $filename, $mimeBoundary, $params, $obj);
return $this->serializer->format($response['body']);
} | php | {
"resource": ""
} |
q245380 | SingleUserAuth.getOauthParameters | validation | protected function getOauthParameters()
{
$time = time();
return array(
'oauth_consumer_key' => $this->getConsumerKey(),
'oauth_nonce' => trim(base64_encode($time), '='),
'oauth_signature_method' => 'HMAC-SHA1',
'oauth_timestamp' => $time,
'oauth_token' => $this->getAccessToken(),
'oauth_version' => '1.0'
);
} | php | {
"resource": ""
} |
q245381 | SingleUserAuth.getRequestString | validation | protected function getRequestString()
{
$params = array_merge($this->getParams, $this->postParams, $this->getOauthParameters());
$params = $this->curl->getParams($params);
return rawurlencode($params);
} | php | {
"resource": ""
} |
q245382 | SingleUserAuth.getSignatureBaseString | validation | protected function getSignatureBaseString()
{
$method = strtoupper($this->method);
$url = rawurlencode($this->getUrl());
return $method . '&' . $url . '&' . $this->getRequestString();
} | php | {
"resource": ""
} |
q245383 | SingleUserAuth.getOauthString | validation | protected function getOauthString()
{
$oauth = array_merge($this->getOauthParameters(), array('oauth_signature' => $this->calculateSignature()));
ksort($oauth);
$values = array();
foreach ($oauth as $key => $value) {
$values[] = $key . '="' . rawurlencode($value) . '"';
}
$oauth = implode(', ', $values);
unset($values, $key, $value);
return $oauth;
} | php | {
"resource": ""
} |
q245384 | AuthAbstract.getHeaders | validation | public function getHeaders($key = null)
{
if ($key === null) {
return $this->headers;
}
if (isset($this->headers[$key])) {
return $this->headers[$key];
}
return false;
} | php | {
"resource": ""
} |
q245385 | AuthAbstract.get | validation | public function get($call, array $getParams = null)
{
$this->resetCallState();
$this->call = $call;
$this->method = 'GET';
if ($getParams !== null && is_array($getParams)) {
$this->getParams = $getParams;
}
$response = $this->getResponse();
$response['body'] = $this->findExceptions($response);
$this->headers = $response['headers'];
unset($call, $getParams);
return $this->serializer->format($response['body']);
} | php | {
"resource": ""
} |
q245386 | AuthAbstract.validateCredentials | validation | protected function validateCredentials($credentials)
{
$credentials = array_filter($credentials);
$keys = array_keys($credentials);
$diff = array_diff($this->requiredCredentials, $keys);
if (!empty($diff)) {
throw new MissingCredentialsException('Missing Credentials: ' . implode($diff, ', '));
}
unset($credentials, $keys, $diff);
} | php | {
"resource": ""
} |
q245387 | AuthAbstract.getUrl | validation | protected function getUrl()
{
$domain = $this->urls['domain'];
$apiVersion = $this->urls['api'];
$jsonExt = '.json';
if (isset($this->withMedia) && $this->withMedia === true) {
$domain = $this->urls['upload'];
}
if ($this->call === 'oauth/request_token' || $this->call === 'oauth/access_token') {
$apiVersion = '';
$jsonExt = '';
}
return $domain . $apiVersion . $this->call . $jsonExt;
} | php | {
"resource": ""
} |
q245388 | AuthAbstract.getResponse | validation | protected function getResponse()
{
$url = $this->getUrl();
$params = array(
'get' => $this->getParams,
'post' => $this->postParams,
'headers' => $this->buildRequestHeader(),
);
return $this->curl->send($url, $params);
} | php | {
"resource": ""
} |
q245389 | AuthAbstract.findExceptions | validation | protected function findExceptions($response)
{
$response = $response['body'];
$data = json_decode($response, true);
if (isset($response[0]) && $response[0] !== '{' && $response[0] !== '[' && !$data) {
if (strpos($response, 'oauth_token=') !== false) {
parse_str($response, $data);
}
if (empty($data) || !is_array($data)) {
throw new TwitterException($response, 0);
}
return json_encode($data);
}
if (!empty($data['errors']) || !empty($data['error'])) {
if (!empty($data['errors'])) {
$data = current($data['errors']);
}
if (empty($data['message']) && !empty($data['error'])) {
$data['message'] = $data['error'];
}
if (!isset($data['code']) || empty($data['code'])) {
$data['code'] = 0;
}
throw new TwitterException($data['message'], $data['code']);
}
unset($data);
return $response;
} | php | {
"resource": ""
} |
q245390 | AuthAbstract.buildMultipart | validation | protected function buildMultipart($mimeBoundary, $filename)
{
$binary = $this->getBinaryFile($filename);
$details = pathinfo($filename);
$type = $this->supportedMimes($details['extension']);
$data = '--' . $mimeBoundary . static::EOL;
$data .= 'Content-Disposition: form-data; name="media"; filename="' . $details['basename'] . '"' . static::EOL;
$data .= 'Content-Type: application/octet-stream' . static::EOL . static::EOL;
$data .= $binary . static::EOL;
$data .= '--' . $mimeBoundary . '--' . static::EOL . static::EOL;
unset($mimeBoundary, $filename, $binary, $details, $type);
return $data;
} | php | {
"resource": ""
} |
q245391 | AuthAbstract.getBinaryFile | validation | protected function getBinaryFile($filename)
{
if (!file_exists($filename)) {
throw new FileNotFoundException;
}
if (!is_readable($filename)) {
throw new FileNotReadableException;
}
ob_start();
readfile($filename);
$binary = ob_get_contents();
ob_end_clean();
unset($filename);
return $binary;
} | php | {
"resource": ""
} |
q245392 | AuthAbstract.resetCallState | validation | protected function resetCallState()
{
$this->call = null;
$this->method = null;
$this->withMedia = null;
$this->getParams = array();
$this->postParams = array();
$this->headers = null;
} | php | {
"resource": ""
} |
q245393 | ApplicationOnlyAuth.getBearerToken | validation | public function getBearerToken()
{
$url = $this->getBearerTokenUrl();
$params = array(
'post' => array('grant_type' => 'client_credentials'),
'headers' => $this->buildBearerTokenHeader(),
);
$response = $this->curl->send($url, $params);
$obj = json_decode($response['body']);
if (!$obj || !isset($obj->token_type) || $obj->token_type != 'bearer') {
$this->findExceptions($response);
}
$this->bearerToken = rawurldecode($obj->access_token);
unset($url, $params, $response, $obj);
return $this->bearerToken;
} | php | {
"resource": ""
} |
q245394 | ApplicationOnlyAuth.invalidateBearerToken | validation | public function invalidateBearerToken()
{
$url = $this->getInvalidateBearerTokenUrl();
$bearerToken = $this->bearerToken;
if ($bearerToken === null) {
$bearerToken = $this->getBearerToken();
}
$params = array(
'post' => array('access_token' => $bearerToken),
'headers' => $this->buildBearerTokenHeader(),
);
$response = $this->curl->send($url, $params);
$obj = json_decode($response['body']);
if (!$obj || !isset($obj->access_token) || $obj->access_token != $bearerToken) {
$this->findExceptions($response);
}
unset($url, $bearerToken, $params, $response, $obj);
return true;
} | php | {
"resource": ""
} |
q245395 | ApplicationOnlyAuth.getBearerTokenCredentials | validation | protected function getBearerTokenCredentials()
{
$signingKey = rawurlencode($this->getConsumerKey()) . ':' . rawurlencode($this->getConsumerSecret());
return base64_encode($signingKey);
} | php | {
"resource": ""
} |
q245396 | ApplicationOnlyAuth.buildRequestHeader | validation | protected function buildRequestHeader()
{
$bearerToken = $this->bearerToken;
if ($this->bearerToken === null) {
$bearerToken = $this->getBearerToken();
}
return array(
'Authorization: Bearer ' . rawurlencode($bearerToken),
'Expect:'
);
} | php | {
"resource": ""
} |
q245397 | Scheduler.every | validation | function every($interval, Job $job)
{
$expression = new SimpleExpression($interval);
$this->add($expression, $job);
return $this;
} | php | {
"resource": ""
} |
q245398 | Scheduler.cron | validation | function cron($expression, Job $job)
{
$expression = new CronExpression($expression);
$this->add($expression, $job);
return $this;
} | php | {
"resource": ""
} |
q245399 | Scheduler.run | validation | function run()
{
$now = new DateTime('now');
$sleep = min(array_map(
function($entry) use ($now) {
list($expression, $job) = $entry;
return $expression->getNextRunDate($now)->getTimestamp();
},
$this->entries
));
time_sleep_until($sleep);
$scheduled = 0;
foreach ($this->entries as $entry) {
list($expression, $job) = $entry;
if ($expression->isDue($now)) {
$this->queue->push($job);
$scheduled += 1;
}
}
$this->queue->flush();
return $scheduled;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.