_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q265300 | Result.getSettingsAsArray | test | public function getSettingsAsArray($groups = null, $flag = null)
{
return $this->getFilteredAsArray($this->settings, $groups, $flag);
} | php | {
"resource": ""
} |
q265301 | Result.getCachableSettingsAsArray | test | public function getCachableSettingsAsArray($groups = null, $flag = null)
{
return $this->getFilteredAsArray($this->cachable_settings, $groups, $flag);
} | php | {
"resource": ""
} |
q265302 | Result.getFiltered | test | protected function getFiltered(array $all_settings = array(), $groups = null, $flag = null)
{
$settings = array();
foreach ($all_settings as $setting) {
if ($setting->matchesGroup($groups) && $setting->matchesFlag($flag)) {
$settings[] = $setting;
}
}
return $settings;
} | php | {
"resource": ""
} |
q265303 | Result.getFilteredAsArray | test | protected function getFilteredAsArray(array $all_settings, $groups = null, $flag = null)
{
$settings = array();
foreach ($all_settings as $setting) {
if ($setting->matchesGroup($groups) && $setting->matchesFlag($flag)) {
$settings[] = $setting->toArray();
}
}
return $settings;
} | php | {
"resource": ""
} |
q265304 | HTMLTree.render | test | public function render()
{
// preload images
$sHTML = "<script language=\"JavaScript\">\n".
" minus = new Image();\n minus.src = \"".Openbizx::$app->getImageUrl()."/minus.gif\";\n".
" plus = new Image();\n plus.src = \"".Openbizx::$app->getImageUrl()."/plus.gif\";\n".
"</script>\n";
// list all views and highlight the current view
$sHTML .= "<ul class='expanded'>\n";
$sHTML .= $this->renderNodeItems($this->nodesXml);
$sHTML .= "</ul>";
return $sHTML;
} | php | {
"resource": ""
} |
q265305 | HTMLTree.renderNodeItems | test | protected function renderNodeItems(&$nodeItemArray)
{
$sHTML = "";
if (isset($nodeItemArray["ATTRIBUTES"]))
{
$sHTML .= $this->renderSingleNodeItem($nodeItemArray);
}
else
{
foreach ($nodeItemArray as $nodeItem)
{
$sHTML .= $this->renderSingleNodeItem($nodeItem);
}
}
return $sHTML;
} | php | {
"resource": ""
} |
q265306 | HTMLTree.renderSingleNodeItem | test | protected function renderSingleNodeItem(&$nodeItem)
{
$url = $nodeItem["ATTRIBUTES"]["URL"];
$caption = $this->translate($nodeItem["ATTRIBUTES"]["CAPTION"]);
$target = $nodeItem["ATTRIBUTES"]["TARGET"];
//$img = $nodeItem["ATTRIBUTES"]["IMAGE"];
if ($nodeItem["NODE"]) {
$image = "<img src='" . Openbizx::$app->getImageUrl() . "/plus.gif' class='collapsed' onclick='mouseClickHandler(this)'>";
} else {
$image = "<img src='" . Openbizx::$app->getImageUrl() . "/topic.gif'>";
}
if ($target) {
if ($url) {
$sHTML .= "<li class='tree'>$image <a href=\"" . $url . "\" target='$target'>" . $caption . "</a>";
} else {
$sHTML .= "<li class='tree'>$image $caption";
}
} elseif ($url) {
$sHTML .= "<li class='tree'>$image <a href=\"" . $url . "\">" . $caption . "</a>";
} else {
$sHTML .= "<li class='tree'>$image $caption";
}
if ($nodeItem["NODE"])
{
$sHTML .= "\n<ul class='collapsed'>\n";
$sHTML .= $this->renderNodeItems($nodeItem["NODE"]);
$sHTML .= "</ul>";
}
$sHTML .= "</li>\n";
return $sHTML;
} | php | {
"resource": ""
} |
q265307 | BundlesAutoloader.run | test | protected function run()
{
if (! $this->bootstrapped) {
$this->autoloaderCollection = new JsonAutoloaderCollection($this->vendorDir, $this->searchFolders);
$this->retrieveInstalledBundles();
$this->install();
$this->uninstall();
$this->arrangeBundlesForEnvironment();
$this->bootstrapped = true;
}
} | php | {
"resource": ""
} |
q265308 | BundlesAutoloader.register | test | protected function register($environment)
{
if (isset($this->environmentsBundles[$environment])) {
foreach ($this->environmentsBundles[$environment] as $bundle) {
$bundleClass = $bundle->getClass();
if (empty($this->instantiatedBundles) || !in_array($bundleClass, $this->instantiatedBundles)) {
if ( ! class_exists($bundleClass)) {
throw new InvalidAutoloaderException(sprintf("The bundle class %s does not exist. Check the bundle's autoload.json to fix the problem", $bundleClass, get_class($this)));
}
if ( ! in_array($bundle->getName(), $this->bundles)) {
$instantiatedBundle = new $bundleClass;
$this->bundles[$bundle->getName()] = $instantiatedBundle;
$overridedBundles = $bundle->getOverrides();
if ( ! empty($overridedBundles)) {
$this->overridedBundles[$bundle->getName()] = $overridedBundles;
}
$this->instantiatedBundles[] = $bundleClass;
}
}
}
}
} | php | {
"resource": ""
} |
q265309 | BundlesAutoloader.install | test | protected function install()
{
foreach ($this->autoloaderCollection as $dir => $jsonAutoloader) {
$bundleName = $jsonAutoloader->getBundleName();
$this->installPackage($dir, $jsonAutoloader);
unset($this->installedBundles[$bundleName]);
}
} | php | {
"resource": ""
} |
q265310 | Command.initialize | test | protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);
$this->input = $input;
$this->output = $output;
// prepend include_path if demanded
$path = $input->getOption('include-path');
if (!empty($path)) {
ini_set('include_path', $path . PATH_SEPARATOR . ini_get('include_path'));
}
// run given bootstrap file if necessary
$bootstrap_path = $input->getOption('bootstrap');
if (!empty($bootstrap_path)) {
if (!is_readable($bootstrap_path)) {
throw new \InvalidArgumentException('Bootstrap file "' . $bootstrap_path . '" is not readable.');
}
if ($this->input->getOption('verbose')) {
$output->writeln('<comment>Requiring boostrap file from "' . $bootstrap_path . '".</comment>');
}
require $bootstrap_path;
}
// we autoload classes from the current working directory or the specified autoload_dir
$autoload_dir = $input->getOption('autoload-dir');
if (!empty($autoload_dir)) {
if (!is_readable($autoload_dir)) {
throw new \InvalidArgumentException(
'Autoload path "' . $autoload_dir . '" is not readable. Please specify an existing directory.'
);
}
if ($this->input->getOption('verbose')) {
$output->writeln('<comment>Classes will be autoloaded from "' . $autoload_dir . '".</comment>');
}
} else {
if ($this->input->getOption('verbose')) {
$output->writeln(
'<comment>No autoload_dir specified, using "' . $this->getCurrentWorkingDirectory() .
'" to autoload classes from.</comment>'
);
}
}
spl_autoload_register(array($this, 'autoload'));
} | php | {
"resource": ""
} |
q265311 | Command.autoload | test | protected function autoload($class)
{
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$autoload_dir = $this->getInput()->getOption('autoload-dir');
if (empty($autoload_dir)) {
$autoload_dir = $this->getCurrentWorkingDirectory();
}
$file_path = $autoload_dir . DIRECTORY_SEPARATOR . $class . '.php';
if ($this->input->getOption('verbose')) {
$this->output->write('<info>Autoloading</info>: ');
}
if (is_readable($file_path)) {
if ($this->input->getOption('verbose')) {
$this->output->writeln($file_path);
}
include_once($file_path);
} else {
$this->output->writeln('<error>Autoload error: "' . $file_path . '" not found!</error>' . PHP_EOL);
// don't exit here to let other autoloaders get their chance
//throw new \InvalidArgumentException('Could not include unreadable file: ' . $file_path);
}
} | php | {
"resource": ""
} |
q265312 | Helpers.load | test | public static function load($id): bool
{
$loaded = false;
if (isset(static::$files[$id])) {
$loaded = static::$files[$id] === true;
if (! $loaded) {
assert(file_exists(static::$files[$id]));
include static::$files[$id];
$loaded = static::$files[$id] = true;
}
}
return $loaded;
} | php | {
"resource": ""
} |
q265313 | Controller.forward | test | public function forward($route, array $attributes = [], array $query = [])
{
return $this->getKernel()->forward($route, $attributes, $query);
} | php | {
"resource": ""
} |
q265314 | ActiveField.glyphIcon | test | public function glyphIcon($glyphIcon)
{
if (empty($this->parts['{input}'])) {
throw new InternalErrorException('Firstly you must set field type!');
}
if (empty($glyphIcon) || !$this->_glyphIconAllowed) {
$this->parts['{glyphIcon}'] = '';
return $this;
}
$this->parts['{glyphIcon}'] = Html::tag('span', '', ['class' => "glyphicon glyphicon-$glyphIcon form-control-feedback"]);
return $this;
} | php | {
"resource": ""
} |
q265315 | BizDataObj_Abstract.setQueryParameters | test | public function setQueryParameters($paramValues)
{
foreach ($paramValues as $param => $value)
$this->queryParams[$param] = $value;
} | php | {
"resource": ""
} |
q265316 | BizDataObj_Abstract.setLimit | test | public function setLimit($count, $offset = 0)
{
if ($count < 0) {
$count = 0;
}
if ($offset < 0) {
$offset = 0;
}
$this->queryLimit['count'] = $count;
$this->queryLimit['offset'] = $offset;
} | php | {
"resource": ""
} |
q265317 | BizDataObj_Abstract.getDBConnection | test | public function getDBConnection($type = 'default')
{
switch (strtolower($type)) {
case "default":
case "read":
if (isset($this->databaseAliasNameforRead)) {
$dbName = $this->databaseAliasNameforRead;
} else {
$dbName = $this->databaseAliasName;
}
break;
case "write":
if (isset($this->databaseAliasNameforWrite)) {
$dbName = $this->databaseAliasNameforWrite;
} else {
$dbName = $this->databaseAliasName;
}
break;
}
return Openbizx::$app->getDbConnection($dbName);
} | php | {
"resource": ""
} |
q265318 | BizDataObj_Abstract.getProperty | test | public function getProperty($propertyName)
{
$ret = parent::getProperty($propertyName);
if ($ret)
return $ret;
if ($propertyName == "Table")
return $this->table;
if ($propertyName == "SearchRule")
return $this->searchRule;
// get control object if propertyName is "Field[fldname]"
$pos1 = strpos($propertyName, "[");
$pos2 = strpos($propertyName, "]");
if ($pos1 > 0 && $pos2 > $pos1) {
$propType = substr($propertyName, 0, $pos1);
$fieldName = substr($propertyName, $pos1 + 1, $pos2 - $pos1 - 1);
if ($propType == "param") { // get parameter
return $this->parameters->get($fieldName);
}
return $this->getField($fieldName);
}
} | php | {
"resource": ""
} |
q265319 | BizDataObj_Abstract.getRefObject | test | public function getRefObject($objName)
{
// see if there is such object in the ObjReferences
$objRef = $this->objReferences->get($objName);
if (!$objRef)
return null;
// apply association on the object
// $assc = $this->EvaluateExpression($objRef->association);
// get the object instance
$obj = Openbizx::getObject($objName);
$obj->setAssociation($objRef, $this);
return $obj;
} | php | {
"resource": ""
} |
q265320 | BizDataObj_Abstract.setAssociation | test | protected function setAssociation($objRef, $asscObj)
{
$this->association["AsscObjName"] = $asscObj->objectName;
$this->association["Relationship"] = $objRef->relationship;
$this->association["Table"] = $objRef->table;
$this->association["Column"] = $objRef->column;
$this->association["FieldRef"] = $objRef->fieldRef;
$this->association["FieldRefVal"] = $asscObj->getFieldValue($objRef->fieldRef);
$this->association["CondColumn"] = $objRef->condColumn;
$this->association["CondValue"] = $objRef->condValue;
$this->association["Condition"] = $objRef->condition;
if ($objRef->relationship == "M-M" || $objRef->relationship == "Self-Self") {
$this->association["XTable"] = $objRef->xTable;
$this->association["XColumn1"] = $objRef->xColumn1;
$this->association["XColumn2"] = $objRef->xColumn2;
$this->association["XKeyColumn"] = $objRef->xKeyColumn;
$this->association["XDataObj"] = $objRef->xDataObj;
}
} | php | {
"resource": ""
} |
q265321 | DefaultReader.fromDocblock | test | protected function fromDocblock($docblock, array $context=array())
{
$annotations = $this->getParser()->parse($docblock);
$col = $this->getCollection();
$rv = array();
foreach ($annotations as $annot) {
list($name, $positional, $named) = $annot;
if ($obj = $col->create($name, $positional, $named, $context)) {
$rv[] = $obj;
}
}
return $rv;
} | php | {
"resource": ""
} |
q265322 | SqliteConnection.fromMemory | test | public static function fromMemory(string $prefix = ''): SqliteConnection
{
$pdo = new \PDO('sqlite::memory:');
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->exec("PRAGMA foreign_keys = ON");
return new static($pdo, $prefix);
} | php | {
"resource": ""
} |
q265323 | SqliteConnection.fromFile | test | public static function fromFile(string $file, string $prefix = ''): SqliteConnection
{
$pdo = new \PDO('sqlite:' . $file);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->exec("PRAGMA foreign_keys = ON");
return new static($pdo, $prefix);
} | php | {
"resource": ""
} |
q265324 | aModel.getField | test | protected function getField(string $f) : ?iField
{
$r = null;
if ($this->hasField($f)) {
$r = $this->fieldsCollection[strtolower($f)];
}
return $r;
} | php | {
"resource": ""
} |
q265325 | aModel.hasField | test | public function hasField(string $f) : bool
{
return (isset($this->fieldsCollection[strtolower($f)]) === true);
} | php | {
"resource": ""
} |
q265326 | aModel.getFieldNames | test | public function getFieldNames() : array
{
$r = [];
foreach ($this->fieldsCollection as $fieldName => $field) {
$r[] = $field->getName();
}
return $r;
} | php | {
"resource": ""
} |
q265327 | aModel.getInitialDataModel | test | public function getInitialDataModel() : array
{
$r = [];
foreach ($this->fieldsCollection as $fieldName => $field) {
$r[$field->getName()] = $field->getDefault();
}
return $r;
} | php | {
"resource": ""
} |
q265328 | ChildCrudController.authorizeIndex | test | protected function authorizeIndex(Request $request)
{
$this->authorizeCrudRequest(Action::INDEX, null, $this->getParent($request));
} | php | {
"resource": ""
} |
q265329 | ChildCrudController.authorizeCreate | test | protected function authorizeCreate(Request $request)
{
$this->authorizeCrudRequest(Action::CREATE, null, $this->getParent($request));
} | php | {
"resource": ""
} |
q265330 | Nestis.getNestedItem | test | public function getNestedItem($pattern, $object, $default = null)
{
$parts = explode("/", $pattern);
$lastObject = $object;
$nr = 0;
$totalParts = count($parts);
$item = null;
foreach ($parts as $part) {
$item = null;
$nr++;
$found = false;
if ($part == '') {
return $default;
}
try {
if (is_object($lastObject)) {
$mthd = 'get' . ucfirst($part);
$mthdIs = 'is' . ucfirst($part);
if (substr($part, 0, 2) == '::') {
$reflect = new \ReflectionObject($lastObject);
$props = $reflect->getStaticProperties();
$nm = substr($part, 2);
if (isset($props[$nm])) {
$prop = $reflect->getProperty($nm);
if ($prop->isPublic()) {
$item = $lastObject::$$nm;
}
}
} elseif (is_callable([$lastObject, $mthd])) {
$item = $lastObject->$mthd();
} elseif (is_callable([$lastObject, $mthdIs])) {
$item = $lastObject->$mthdIs();
} elseif (is_callable([$lastObject, $part])) {
$item = $lastObject->$part();
} else {
$reflect = new \ReflectionObject($lastObject);
$prop = $reflect->getProperty($part);
if ($prop->isPublic()) {
$item = $lastObject->$part;
}
}
$found = true;
} elseif (is_array($lastObject)) {
if (array_key_exists($part, $lastObject)) {
$item = $lastObject[$part];
$found = true;
}
}
} catch (\Exception $e) {
return $default;
}
if ((!is_null($item) && !is_object($item) && !is_array($item) && $nr < $totalParts) || !$found) {
//its a string,boolean or integer , but we're not at the end of the list so we can't find the end
return $default;
}
$lastObject = $item;
}
return $item;
} | php | {
"resource": ""
} |
q265331 | UserAgent.init | test | public function init()
{
$device = '';
$style = '';
if (!isset($_SERVER['HTTP_USER_AGENT'])) {
return;
}
if (stristr($_SERVER['HTTP_USER_AGENT'], 'ipad')) {
$device = "ipad";
$style = "touch";
} else if (stristr($_SERVER['HTTP_USER_AGENT'], 'iphone')
|| strstr($_SERVER['HTTP_USER_AGENT'], 'ipod')) {
$device = "iphone";
$style = "touch";
} else if (stristr($_SERVER['HTTP_USER_AGENT'], 'blackberry')) {
$device = "blackberry";
$style = "touch";
} else if (stristr($_SERVER['HTTP_USER_AGENT'], 'android')) {
$device = "android";
$style = "touch";
}
$this->_userAgent = $device;
$this->_style = $style;
if ($device != '' && $style == 'touch') {
$this->_isTouch = true;
$this->_device = 'mobile';
} else {
$this->_isTouch = false;
$this->_device = 'desktop';
}
} | php | {
"resource": ""
} |
q265332 | Config.getExportImplementor | test | public function getExportImplementor()
{
$export = new Parameters($this->config->get('export', array()));
return $export->get(self::PARAM_CLASS, 'Environaut\Export\Export');
} | php | {
"resource": ""
} |
q265333 | Config.getReportImplementor | test | public function getReportImplementor()
{
$report = new Parameters($this->config->get('report', array()));
return $report->get(self::PARAM_CLASS, 'Environaut\Report\Report');
} | php | {
"resource": ""
} |
q265334 | Config.getRunnerImplementor | test | public function getRunnerImplementor()
{
$runner = new Parameters($this->config->get('runner', array()));
return $runner->get(self::PARAM_CLASS, 'Environaut\Runner\Runner');
} | php | {
"resource": ""
} |
q265335 | Config.getCacheImplementor | test | public function getCacheImplementor()
{
$cache = new Parameters($this->config->get('cache', array()));
return $cache->get(self::PARAM_CLASS, 'Environaut\Cache\Cache');
} | php | {
"resource": ""
} |
q265336 | BizDataObj_SQLHelper.buildUpdateSQL | test | public function buildUpdateSQL($dataObj)
{
// generate column value pairs. ignore those whose inputValue=fieldValue
$sqlFlds = $dataObj->bizRecord->getToSaveFields('UPDATE');
$colval_pairs = null;
foreach ($sqlFlds as $field) {
$col = $field->column;
// ignore empty vallue for Date or Datetime
if (($field->value == "" && $field->oldValue == "") && ($field->type == "Date" || $field->type == "Datetime"))
continue;
if ($field->valueOnUpdate != "") // ignore ValueOnUpdate field first
continue;
if ($field->isLobField()) // take care of blob/clob type later
continue;
// ignore the column where old value is same as new value; set the column only if new value is diff than the old value
if ($field->oldValue == $field->value)
continue;
$_val = $field->getSqlValue();
$colval_pairs[$col] = $_val; //($_val===null || $_val === '') ? "''" : $_val;
}
if ($colval_pairs == null)
return false;
// take care value on update fields only
foreach ($sqlFlds as $field) {
$col = $field->column;
if ($field->valueOnUpdate != "") {
$_val = $field->getValueOnUpdate();
$colval_pairs[$col] = $_val; //($_val===null || $_val === '') ? "''" : $_val;
}
}
$db = $dataObj->getDBConnection('WRITE');
$sql = "";
foreach ($colval_pairs as $col => $val) {
//$queryString = QueryStringParam::formatQueryString("`$col`", "=", $val);
$queryString = "`$col`=" . $db->quote($val);
if ($sql != "") {
$sql .= ", $queryString";
} else {
$sql .= $queryString;
}
}
$sql = "UPDATE `" . $dataObj->mainTableName . "` SET " . $sql;
$whereStr = $dataObj->bizRecord->getKeySearchRule(true, true); // use old value and column name
$sql .= " WHERE " . $whereStr;
// append DataPerm in the WHERE clause
if ($dataObj->dataPermControl == 'Y') {
$svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE);
$hasOwnerField = $this->_hasOwnerField($dataObj);
$dataPermSQLRule = $svcObj->buildSqlRule($dataObj, 'update', $hasOwnerField);
$sqlSearchRule = $this->_convertSqlExpressionWithoutPrefix($dataObj, $dataPermSQLRule);
if ($whereStr != '') {
$sql .= ' AND ' . $sqlSearchRule;
} else {
$sql .= $sqlSearchRule;
}
}
return $sql;
} | php | {
"resource": ""
} |
q265337 | BizDataObj_SQLHelper.buildDeleteSQL | test | public function buildDeleteSQL($dataObj)
{
$sql = "DELETE FROM `" . $dataObj->mainTableName . "`";
$whereStr = $dataObj->bizRecord->getKeySearchRule(false, true); // use cur value and column name
$sql .= " WHERE " . $whereStr;
// append DataPerm in the WHERE clause
if ($dataObj->dataPermControl == 'Y') {
$svcObj = Openbizx::getService(OPENBIZ_DATAPERM_SERVICE);
$hasOwnerField = $this->_hasOwnerField($dataObj);
$dataPermSQLRule = $svcObj->buildSqlRule($dataObj, 'delete', $hasOwnerField);
$sqlSearchRule = $this->_convertSqlExpressionWithoutPrefix($dataObj, $dataPermSQLRule);
if ($whereStr != '') {
$sql .= ' AND ' . $sqlSearchRule;
} else {
$sql .= $sqlSearchRule;
}
}
return $sql;
} | php | {
"resource": ""
} |
q265338 | EditCombobox.getStyle | test | protected function getStyle()
{
$htmlClass = $this->cssClass ? "class='" . $this->cssClass . "' " : "class='editcombobox'";
/*
$width = $this->width ? $this->width : 146;
$this->widthInput = ($width-18).'px';
$this->width = $width.'px';
$style = "position: absolute; width: $this->width; z-index: 1; clip: rect(auto, auto, auto, $this->widthInput);";
*/
if ($this->style)
$style .= $this->style;
if (!isset($style) && !$htmlClass)
return null;
if (isset($style)) {
$formObj = $this->getFormObj();
$style = Expression::evaluateExpression($style, $formObj);
$style = "style='$style'";
}
if ($htmlClass) {
$style = $htmlClass . " " . $style;
}
return $style;
} | php | {
"resource": ""
} |
q265339 | DomElement.getChildNodes | test | public function getChildNodes()
{
$prefix = $this->ownerDocument->getDefaultNamespacePrefix();
if ($prefix) {
return $this->ownerDocument->getXpath()->query(sprintf('child::%s:*', $prefix), $this);
} else {
return $this->ownerDocument->getXpath()->query('child::*', $this);
}
} | php | {
"resource": ""
} |
q265340 | DomElement.getAttributeValue | test | public function getAttributeValue($name, $default_value = null)
{
$value = parent::getAttribute($name);
if ($value === '') {
$value = $default_value;
}
return $value;
} | php | {
"resource": ""
} |
q265341 | DomElement.getAttributes | test | public function getAttributes()
{
$attributes = array();
foreach ($this->ownerDocument->getXpath()->query('@*', $this) as $attribute) {
$attributes[$attribute->localName] = $attribute->nodeValue;
}
return $attributes;
} | php | {
"resource": ""
} |
q265342 | DomElement.getChild | test | public function getChild($name)
{
$query = 'self::node()[count(child::*[local-name() = "%1$s" and namespace-uri() = "%2$s"]) = 1]/*' .
'[local-name() = "%1$s" and namespace-uri() = "%2$s"]';
$node = $this->ownerDocument->getXpath()->query(
sprintf($query, $name, $this->ownerDocument->getDefaultNamespaceUri()),
$this
)->item(0);
return $node;
} | php | {
"resource": ""
} |
q265343 | DomElement.getLiteralValue | test | protected function getLiteralValue($element)
{
$value = $element->getValue();
$trimmed_value = trim($value);
$preserve_whitespace = $element->getAttributeValue('space', 'default') === 'preserve';
$literalize_value = self::literalize($element->getAttributeValue('literalize')) !== false;
if ($literalize_value) {
if ($preserve_whitespace && ($trimmed_value === '' || $value !== $trimmed_value)) {
$value = $value;
} else {
$value = self::literalize($trimmed_value);
}
} elseif (!$preserve_whitespace) {
$value = $trimmed_value;
if ($value === '') {
$value = null;
}
}
return $value;
} | php | {
"resource": ""
} |
q265344 | MenuComposer.cacheIfConfigured | test | private function cacheIfConfigured($closure)
{
if (config('menu.cache.enable')) {
$key = config('menu.cache.key');
$minutes = config('menu.cache.minutes');
return Cache::remember($key, $minutes, function () use ($closure) {
return call_user_func($closure);
});
}
return call_user_func($closure);
} | php | {
"resource": ""
} |
q265345 | Middleware.handle | test | public function handle(array &$arguments, string $callType = Caller::TYPE_DEFAULT)
{
if ($this->isValid()) {
$this->callType = $callType;
$method = $this->getMethod();
$context = $this->getContext();
return $context->$method(...$arguments);
}
} | php | {
"resource": ""
} |
q265346 | Middleware.isValid | test | public function isValid(string $method = null): bool
{
if ($method === null) {
$method = $this->getMethod();
}
return $this->isEnabled() && $this->methodIsCallable($method);
} | php | {
"resource": ""
} |
q265347 | Middleware.isGetter | test | protected function isGetter(): bool
{
$isExternalObject = is_object($this->context) && $this->context instanceof static === false;
return $this->callType === Caller::TYPE_GETTER && $isExternalObject;
} | php | {
"resource": ""
} |
q265348 | Middleware.isSetter | test | protected function isSetter(): bool
{
$isExternalObject = is_object($this->context) && $this->context instanceof static === false;
return $this->callType === Caller::TYPE_SETTER && $isExternalObject;
} | php | {
"resource": ""
} |
q265349 | BaseConnector.prepareCall | test | public function prepareCall( Client $client = null ) {
// Set the default client:
$this->curlClient = null;
$client = null;
$this->log( 'prepare ' . __CLASS__ . ' GuzzleRequest: base_uri(' . $this->getBaseUri() . '), client(' . ( (bool) is_null( $client ) ) . '), timeout(' . $this->getCurlTimeout() . '), ', 'debug');
// Check if baseUri is set or that $client is set (make pass trough client available else set the client self)
if ( $this->getBaseUri() !== null && $client === null ) {
// Initialize the Client:
$this->curlClient = new Client( [
// Base URI is used with relative requests
'base_uri' => $this->getBaseUri(),
// You can set any number of default request options.
'timeout' => 2.0,
] );
} else if ( $client !== null ) {
$this->curlClient = $client;
}
} | php | {
"resource": ""
} |
q265350 | BaseConnector.getResponse | test | public function getResponse( $type = self::RESPONSE_TYPE_JSON ) {
// Check if response is set
if ( $this->response === null ) {
return null;
}
try {
// Get the stream from the response getBody() method returns a stream instead of a string.
$stream = $this->response->getBody();
// Get the body from the stream.
$body = $stream->getContents();
if ( empty( $body ) ) {
return null;
}
switch ( $type ) {
default:
case self::RESPONSE_TYPE_JSON:
return $this->getResponseJSON( $body );
break;
case self::RESPONSE_TYPE_XML:
return (string) $body;
break;
case self::RESPONSE_TYPE_HTML:
return (string) $body;
break;
case self::RESPONSE_TYPE_TEXT:
return (string) $body;
break;
case self::RESPONSE_ORIGINAL:
return $this->response;
break;
}
}
catch ( BadResponseException $exception ) {
return null;
}
catch ( \Exception $exception ) {
return null;
}
} | php | {
"resource": ""
} |
q265351 | BaseConnector.getResponseJSON | test | private function getResponseJSON( $body ) {
try {
return json_decode( (string) $body, true );
}
catch ( \Exception $e ) {
throw new \RuntimeException( 'Invalid JSON ' . $e->getMessage(), 0, $body );
}
} | php | {
"resource": ""
} |
q265352 | SessionContext.saveObjVar | test | public function saveObjVar($objName, $varName, &$value, $stateful = false)
{
if (preg_match('/\./si', $objName)) {
$objName = $this->getNamespace() . '#' . $objName;
}
if (!$stateful) {
$this->_sessObjArr[$objName][$varName] = $value;
} else {
$this->_statefulSessObjArr[$objName][$varName] = $value;
}
} | php | {
"resource": ""
} |
q265353 | SessionContext.loadObjVar | test | public function loadObjVar($objName, $varName, &$value, $stateful = false)
{
//Openbizx::$app->getLog()->log(LOG_ALERT, __METHOD__, ' | name : ' . $varName . ' | value : ' . $value);
//Openbizx::$app->getClientProxy()->showClientAlert( __METHOD__ . ' | name : ' . $varName . ' | value : ' . $value);
if (preg_match('/\./si', $objName)) {
$objName = $this->getNamespace() . '#' . $objName;
}
if (!$stateful) {
if (!$this->_sessObjArr) {
return null;
}
if (isset($this->_sessObjArr[$objName][$varName])) {
$value = $this->_sessObjArr[$objName][$varName];
}
} else {
if (!$this->_statefulSessObjArr) {
return null;
}
if (isset($this->_statefulSessObjArr[$objName][$varName])) {
$value = $this->_statefulSessObjArr[$objName][$varName];
}
}
} | php | {
"resource": ""
} |
q265354 | SessionContext.saveSessionObjects | test | public function saveSessionObjects()
{
// loop all objects (bizview, bizform, bizdataobj) collect their session vars
$allobjs = Openbizx::objectFactory()->getAllObjects();
foreach ($allobjs as $obj) {
if (method_exists($obj, "saveStatefullVars")) {
//after calling $obj->saveStatefullVars SessObjArr and StatefulSessObjArr are filled
$obj->saveStatefullVars($this);
}
// if previous view's object is used in current view, don't discard its session data
if ( isset($obj->objectName) && isset($this->_prevViewObjNames[$obj->objectName]) ) {
unset( $this->_prevViewObjNames[$obj->objectName] );
Openbizx::$app->getLog()->log( LOG_ERR, "SESSION", "unset " . $obj->objectName );
}
}
// discard useless previous view's session objects
//foreach($this->_prevViewObjNames as $objName=>$tmp)
// unset($this->_sessObjArr[$objName]);
$this->_sessObjArr["ViewHist"] = $this->_viewHistory;
$this->setVar(OB_TRANSIENT_DATA_SESSION_INDEX, $this->_sessObjArr);
$this->setVar(OB_STATEFUL_DATA_SESSION_INDEX, $this->_statefulSessObjArr);
} | php | {
"resource": ""
} |
q265355 | SessionContext.clearSessionObjects | test | public function clearSessionObjects($keepObjects = false)
{
if ($keepObjects == false) {
unset($this->_sessObjArr);
$this->_sessObjArr = array();
} else { // add previous view's session object names in to a map
if (isset($this->_sessObjArr)) {
foreach ($this->_sessObjArr as $objName => $sessobj) {
//echo "save sess $objName <br/>";
$this->_prevViewObjNames[$objName] = 1;
}
}
}
} | php | {
"resource": ""
} |
q265356 | SessionContext.saveJSONArray | test | public function saveJSONArray($jsonValue, $jsonName = NULL)
{
$jsonArray = json_decode($jsonValue);
if ((bool) $jsonName) { //If I want save all array in session I send the name of the array in session
$this->setVar($jsonName, $jsonArray);
} else {//I save each value in session
foreach ($jsonArray as $varName => $value) {
$this->setVar($varName, $value);
}
}
} | php | {
"resource": ""
} |
q265357 | SessionContext.setViewHistory | test | public function setViewHistory($formName, $historyInfo)
{
$view = Openbizx::$app->getCurrentViewName();
$view_form = $formName; //$view."_".$formname;
if (!$historyInfo) {
unset($this->_viewHistory[$view_form]);
} else {
$this->_viewHistory[$view_form] = $historyInfo;
}
} | php | {
"resource": ""
} |
q265358 | Timer.tic | test | public function tic($flag = self::RESET_COUNTER)
{
$this->start = microtime(true);
if ($flag) {
$this->count = 0;
}
} | php | {
"resource": ""
} |
q265359 | Timer.toc | test | public function toc($message = '')
{
$this->stop = microtime(true);
++$this->count;
$this->elapsed = ($this->stop - $this->start ) * 1e6 - $this->calib;
print $this;
if ($message) {
print $message . "\n";
}
} | php | {
"resource": ""
} |
q265360 | Timer.tac | test | public function tac($flag = self::ADD_LAP)
{
$this->stop = microtime(true);
if ($flag) {
$this->elapsed = ($this->stop - $this->start) * 1e6
- $this->calib;
} else {
$this->elapsed += ($this->stop - $this->start) * 1e6
- $this->calib;
}
++$this->count;
} | php | {
"resource": ""
} |
q265361 | Timer.reset | test | public function reset()
{
$this->count = 0;
$this->elapsed = 0;
$this->start = 0;
$this->stop = 0;
return $this;
} | php | {
"resource": ""
} |
q265362 | ExecutableCheck.validExecutable | test | public function validExecutable($value)
{
$val = trim($value);
if (empty($val)) {
throw new \InvalidArgumentException(
'Not a valid executable path. Please specify a command (like "ls") or a path (like "/usr/bin/ls").'
);
}
$executable = trim(shell_exec('which ' . $val));
if (!$executable) {
throw new \InvalidArgumentException('Could not find executable: ' . $val);
}
$command = $this->parameters->get('command', $this->getName());
$cli_option = $this->parameters->get('version_parameter', '--version');
$version_mask = $this->parameters->get('version_mask', '/Version/');
if ($version_mask) {
$version_info_raw = trim(shell_exec('cat /dev/null | ' . $executable . ' ' . $cli_option . ' 2>&1'));
if (!preg_match($version_mask, $version_info_raw, $matches, PREG_OFFSET_CAPTURE)) {
throw new \InvalidArgumentException(
'Could not get version information for "' . $command . '" using "' . $executable . '".'
);
}
}
return $executable;
} | php | {
"resource": ""
} |
q265363 | FormHelper.getRedirectPage | test | public function getRedirectPage()
{
// get the control that issues the call
// __this is elementName:eventHandlerName
list($element, $eventHandler) = $this->getInvokingElement();
$eventHandlerName = $eventHandler->objectName;
$redirectPage = $element->getRedirectPage($eventHandlerName); // need to get postaction of eventhandler
$functionType = $element->getFunctionType($eventHandlerName);
switch ($functionType)
{
case "Popup":
$target = "Popup";
break;
default:
$target = "";
}
return array($redirectPage, $target);
} | php | {
"resource": ""
} |
q265364 | FormHelper.processDataException | test | public function processDataException($e)
{
$errorMsg = $e->getMessage();
Openbizx::$app->getLog()->log(LOG_ERR, "DATAOBJ", "DataObj error = ".$errorMsg);
//Openbizx::$app->getClientProxy()->showClientAlert($errorMsg); //showErrorMessage($errorMsg);
//Openbizx::$app->getClientProxy()->showErrorMessage($errorMsg);
$e->no_exit=true;
ErrorHandler::exceptionHandler($e);
} | php | {
"resource": ""
} |
q265365 | DynaView.processURL | test | protected function processURL()
{
// if url has form=...
$paramForm = isset($_GET['form']) ? $_GET['form'] : null;
$paramCForm = isset($_GET['cform']) ? $_GET['cform'] : null;
if (!$paramForm)
return;
// add the form in FormRefs
if ($paramForm)
{
if($this->isInFormRefLibs($paramForm))
{
$xmlArr["ATTRIBUTES"]["NAME"] = $paramForm;
$xmlArr["ATTRIBUTES"]["SUBFORMS"] = $paramCForm ? $paramCForm : "";
$formRef = new FormReference($xmlArr);
$this->formRefs->set($paramForm, $formRef);
if ($paramCForm)
{
if($this->isInFormRefLibs($paramCForm))
{
$xmlArr["ATTRIBUTES"]["NAME"] = $paramCForm;
$xmlArr["ATTRIBUTES"]["SUBFORMS"] = "";
$cformRef = new FormReference($xmlArr);
$this->formRefs->set($paramCForm, $cformRef);
}
}
}
}
// check url arg as fld:name=val
$getKeys = array_keys($_GET);
$paramFields = null;
foreach ($getKeys as $key)
{
if (substr($key, 0, 4) == "fld:")
{
$fieldName = substr($key, 4);
$fieldValue = $_GET[$key];
$paramFields[$fieldName] = $fieldValue;
}
}
if (!$paramFields)
return;
$paramForm = $this->prefixPackage($paramForm);
$formObj = Openbizx::getObject($paramForm);
$formObj->setRequestParams($paramFields);
} | php | {
"resource": ""
} |
q265366 | WebUtils.baseURI | test | public static function baseURI()
{
// Check if uri contains a query.
$uri = $_SERVER['REQUEST_URI'];
$qmIsHere = strpos($uri, '?');
$uri = ($qmIsHere === false) ? $uri :
substr($uri, 0, $qmIsHere);
// Get file name
return pathinfo($uri)['filename'];
} | php | {
"resource": ""
} |
q265367 | ObjectRepository.validateIdentity | test | protected function validateIdentity($identity)
{
$credentialProperty = $this->options->getCredentialProperty();
$getter = 'get' . ucfirst($credentialProperty);
$documentCredential = null;
if (method_exists($identity, $getter)) {
$documentCredential = $identity->$getter();
} elseif (property_exists($identity, $credentialProperty)) {
$documentCredential = $identity->{$credentialProperty};
} else {
throw new Exception\UnexpectedValueException(
sprintf(
'Property (%s) in (%s) is not accessible. You should implement %s::%s()',
$credentialProperty,
get_class($identity),
get_class($identity),
$getter
)
);
}
$credentialValue = $this->credential;
$callable = $this->options->getCredentialCallable();
if ($callable) {
$credentialValue = call_user_func($callable, $identity, $credentialValue);
}
if ($credentialValue !== true && $credentialValue !== $documentCredential) {
$this->authenticationResultInfo['code'] = AuthenticationResult::FAILURE_CREDENTIAL_INVALID;
$this->authenticationResultInfo['messages'][] = 'Supplied credential is invalid.';
return $this->createAuthenticationResult();
}
$this->authenticationResultInfo['code'] = AuthenticationResult::SUCCESS;
$this->authenticationResultInfo['identity'] = $identity;
$this->authenticationResultInfo['messages'][] = 'Authentication successful.';
return $this->createAuthenticationResult();
} | php | {
"resource": ""
} |
q265368 | ObjectRepository.setup | test | protected function setup()
{
if (null === $this->identity) {
throw new Exception\RuntimeException(
'A value for the identity was not provided prior to authentication with ObjectRepository '
. 'authentication adapter'
);
}
if (null === $this->credential) {
throw new Exception\RuntimeException(
'A credential value was not provided prior to authentication with ObjectRepository'
. ' authentication adapter'
);
}
$this->authenticationResultInfo = array(
'code' => AuthenticationResult::FAILURE,
'identity' => $this->identity,
'messages' => array()
);
} | php | {
"resource": ""
} |
q265369 | SetsAttributes.setVisibleAttribute | test | protected function setVisibleAttribute(string $name, $value)
{
$method = "set" . ucfirst($name);
if (method_exists($this, $method)) {
$value = $this->$method($value);
} elseif (PublicReflection::hasAttribute(get_class($this), $name)) {
$value = $this->setAttribute($name, $value);
} elseif ($this->triggerUndefinedAttributeNotice) {
$className = get_class($this);
trigger_error("The property {$className}::\${$name} is not accessible.", E_USER_NOTICE);
}
return $value;
} | php | {
"resource": ""
} |
q265370 | EloquentBuilder.firstHumpArray | test | public function firstHumpArray(...$parameters){
$res = $this->firstHump(...$parameters);
if ($res instanceof EloquentModel){
$res = $res->toArray();
}
return $res;
} | php | {
"resource": ""
} |
q265371 | OptionElement.getFromList | test | public function getFromList(&$list, $selectFrom = null)
{
if (!$selectFrom) {
$selectFrom = $this->getSelectFrom();
}
if (!$selectFrom) {
return $this->getSQLFromList($list);
}
$this->getXMLFromList($list, $selectFrom);
if ($list != null)
return;
$this->getDOFromList($list, $selectFrom);
if ($list != null)
return;
$this->getSimpleFromList($list, $selectFrom);
if ($list != null)
return;
return;
} | php | {
"resource": ""
} |
q265372 | ConsoleMessageFormatter.format | test | public function format(IReport $report)
{
$output = '';
$format = $this->getParameters()->get('format', self::DEFAULT_FORMAT);
$results = $report->getResults();
foreach ($results as $result) {
$messages = $result->getMessages();
foreach ($messages as $message) {
switch($message->getSeverity()) {
case Message::SEVERITY_FATAL:
case Message::SEVERITY_ERROR:
$output .= sprintf(
$format,
$message->getGroup(),
$message->getName(),
'<error>' . $message->getText() . '</error>'
);
break;
case Message::SEVERITY_NOTICE:
case Message::SEVERITY_WARN:
$output .= sprintf(
$format,
$message->getGroup(),
$message->getName(),
'<comment>' . $message->getText() . '</comment>'
);
break;
case Message::SEVERITY_INFO:
$output .= sprintf(
$format,
$message->getGroup(),
$message->getName(),
'<info>' . $message->getText() . '</info>'
);
break;
case Message::SEVERITY_DEBUG:
default:
$output .= sprintf(
$format,
$message->getGroup(),
$message->getName(),
$message->getText()
);
break;
}
$output .= PHP_EOL;
}
}
return $output;
} | php | {
"resource": ""
} |
q265373 | HasMiddleware.callMiddleware | test | protected function callMiddleware(
$middleware,
string $method = "",
array &$arguments = [],
string $type = Caller::TYPE_DEFAULT,
$result = null
) {
if (! $this->skipMiddleware) {
$result = $this->middlewareCaller($middleware, $result)
->as($type)
->catch($this->catchHaltExceptions)
->call($method, $arguments);
}
return $result;
} | php | {
"resource": ""
} |
q265374 | HasMiddleware.callProxyGetters | test | protected function callProxyGetters(string $name, $result = null)
{
if ($this->getMiddlewareGroup(Caller::TYPE_GETTER)->isNotEmpty()) {
$middleware = $this->getMiddlewareGroup(Caller::TYPE_GETTER);
$arguments = [$name];
$result = $this->callMiddleware($middleware, "get", $arguments, Caller::TYPE_GETTER, $result);
} elseif ($this->magicMethodsFallbackLocally && property_exists($this, $name)) {
$result = $this->getAttribute($name);
}
return $result;
} | php | {
"resource": ""
} |
q265375 | HasMiddleware.callProxyMethods | test | protected function callProxyMethods(string $name, array &$arguments, $result = null)
{
if ($this->getMiddlewareGroup(Caller::TYPE_CALLER)->isNotEmpty()) {
$middleware = $this->getMiddlewareGroup(Caller::TYPE_CALLER);
$result = $this->callMiddleware($middleware, $name, $arguments, Caller::TYPE_CALLER, $result);
} elseif ($this->magicMethodsFallbackLocally && is_callable([$this, $name])) {
$result = $this->$name($arguments);
}
return $result;
} | php | {
"resource": ""
} |
q265376 | HasMiddleware.callProxySetters | test | protected function callProxySetters(string $name, $value, $result = null)
{
$result = null;
if ($this->getMiddlewareGroup(Caller::TYPE_SETTER)->isNotEmpty()) {
$middleware = $this->getMiddlewareGroup(Caller::TYPE_SETTER);
$arguments = [$name, $value];
$result = $this->callMiddleware($middleware, "set", $arguments, Caller::TYPE_SETTER, $result);
} elseif ($this->magicMethodsFallbackLocally && property_exists($this, $name)) {
$this->setAttribute($name, $value);
$result = [$name, $value];
}
return $result;
} | php | {
"resource": ""
} |
q265377 | HasMiddleware.catchHaltedMiddleware | test | protected function catchHaltedMiddleware(bool $setting = null)
{
if ($setting === null) {
return $this->catchHaltExceptions;
}
$this->catchHaltExceptions = $setting;
return $this;
} | php | {
"resource": ""
} |
q265378 | HasMiddleware.clearMiddleware | test | protected function clearMiddleware(string $group = null)
{
if ($group === null) {
$this->middleware = new Group;
} else {
unset($this->middleware[$group]);
}
return $this;
} | php | {
"resource": ""
} |
q265379 | HasMiddleware.disableMiddleware | test | protected function disableMiddleware(string $key = '', string $group = null)
{
$middleware = $this->getMiddleware($key, $group);
if ($middleware instanceof Disableable) {
$middleware->disable();
}
return $this;
} | php | {
"resource": ""
} |
q265380 | HasMiddleware.enableMiddleware | test | protected function enableMiddleware(string $key = '', string $group = null)
{
$middleware = $this->getMiddleware($key, $group);
if ($middleware instanceof Enableable) {
$middleware->enable();
}
return $this;
} | php | {
"resource": ""
} |
q265381 | HasMiddleware.getMiddleware | test | protected function getMiddleware(string $key = "", string $group = null, $default = null)
{
return $this->getMiddlewareGroup($group ?: $this->middlewareGroupId)->get($key, $default);
} | php | {
"resource": ""
} |
q265382 | HasMiddleware.getMiddlewareGroup | test | protected function getMiddlewareGroup(string $id = Group::DEFAULT_ID): MiddlewareCollection
{
if (! isset($this->middleware[$id]) || $this->middleware[$id] instanceof MiddlewareCollection === false) {
$this->middleware[$id] = $this->middlewareCollection($id);
}
return $this->middleware[$id];
} | php | {
"resource": ""
} |
q265383 | HasMiddleware.groupMiddleware | test | protected function groupMiddleware(string $name = null, Closure $closure = null)
{
if ($name === null) {
return $this->middlewareGroupId;
} else {
$previousGroup = $this->middlewareGroupId;
$this->middlewareGroupId = $name;
if ($closure !== null) {
$closure($this);
$this->middlewareGroupId = $previousGroup;
}
return $this;
}
} | php | {
"resource": ""
} |
q265384 | HasMiddleware.hasMiddleware | test | protected function hasMiddleware(string $key, string $group = null): bool
{
return $this->getMiddlewareGroup($group ?: $this->middlewareGroupId)->has($key);
} | php | {
"resource": ""
} |
q265385 | HasMiddleware.isMiddlewareDisabled | test | protected function isMiddlewareDisabled(string $key = '', string $group = null): bool
{
$middleware = $this->getMiddleware($key, $group);
return $middleware instanceof Disableable ? $middleware->isDisabled() : false;
} | php | {
"resource": ""
} |
q265386 | HasMiddleware.isMiddlewareEnabled | test | protected function isMiddlewareEnabled(string $key = '', string $group = null): bool
{
$middleware = $this->getMiddleware($key, $group);
return $middleware instanceof Enableable ? $middleware->isEnabled() : false;
} | php | {
"resource": ""
} |
q265387 | HasMiddleware.middleware | test | protected function middleware(string $key = null, string $group = Group::DEFAULT_ID)
{
$middleware = $this->middleMan->getGroup($group)->get($key);
if ($middleware) {
$this->result = $this->then($middleware);
}
return $this->resultUnlessChainable();
} | php | {
"resource": ""
} |
q265388 | HasMiddleware.middlewareCollection | test | protected function middlewareCollection(string $id = Group::DEFAULT_ID, $middleware = []): MiddlewareCollection
{
if (function_exists('collect_middleware')) {
return collect_middleware($middleware, $id);
} else {
return new Group($middleware, $id);
}
} | php | {
"resource": ""
} |
q265389 | HasMiddleware.prependMiddleware | test | protected function prependMiddleware($middleware, string $key = "", string $group = null)
{
$middleware = $this->middlewareResolver()->resolveOrFail($middleware, $key);
$this->getMiddlewareGroup($group ?: $this->middlewareGroupId)->prepend($middleware, $key);
return $this;
} | php | {
"resource": ""
} |
q265390 | HasMiddleware.pushMiddleware | test | protected function pushMiddleware($middleware, string $key = "", string $group = null)
{
$middleware = $this->middlewareResolver()->resolveOrFail($middleware, $key);
$this->getMiddlewareGroup($group ?: $this->middlewareGroupId)->put($key, $middleware);
return $this;
} | php | {
"resource": ""
} |
q265391 | HasMiddleware.setMiddlewareContext | test | protected function setMiddlewareContext($context, MiddlewareCollection &$group = null)
{
if ($group === null) {
$group = $this->middleware;
}
if ($group) {
foreach ($group as &$value) {
if ($value instanceof MiddlewareCollection) {
$this->setMiddlewareContext($context, $value);
} elseif ($value instanceof MiddlewareInterface) {
$value->as($context);
}
}
}
return $this;
} | php | {
"resource": ""
} |
q265392 | HasMiddleware.thenCallMiddleware | test | protected function thenCallMiddleware($middleware)
{
if (function_exists('call_middleware')) {
$this->result = call_middleware($middleware, $this->result);
} else {
$this->result = (new Caller($middleware))->call($this->result);
}
return $this->resultUnlessChainable();
} | php | {
"resource": ""
} |
q265393 | Cache.save | test | public function save()
{
$location = $this->location;
// no location given from commandline -> use config values or fallback to default location
if (empty($location)) {
$location = $this->parameters->get(
'write_location',
$this->parameters->get(
'location',
$this->getDefaultLocation()
)
);
}
$this->location = $location;
$data = array();
foreach ($this->settings as $setting) {
$data[] = $setting->toArray();
}
$flags = 0;
if ($this->parameters->get('pretty', true) && version_compare(PHP_VERSION, '5.4.0') >= 0) {
$flags |= JSON_PRETTY_PRINT;
}
$content = json_encode($data, $flags);
if (false === $content) {
throw new \Exception('Could not json_encode cachable settings. Nothing written to cache.');
}
$success = (false !== file_put_contents($location, $content));
$success &= chmod($location, 0600); // only current user should read/write potentially sensitive info
return $success;
} | php | {
"resource": ""
} |
q265394 | TabView._getForms | test | private function _getForms($forms)
{
$recArr = array();
if (count($forms) == 0)
return $recArr;
foreach ($forms as $form) {
if (!is_null($form["ATTRIBUTES"]))
$recArr[] = $form["ATTRIBUTES"];
else
$recArr[] = $form;
}
return $recArr;
} | php | {
"resource": ""
} |
q265395 | JsonAutoloader.setup | test | protected function setup()
{
$autoloader = $this->decode($this->filename);
if (null === $autoloader) {
throw new InvalidJsonFormatException(sprintf('The json file %s is malformed. Please check the file syntax to fix the problem', $this->filename));
}
if (empty($autoloader["bundles"])) {
throw new InvalidJsonFormatException(sprintf('The json file %s requires the bundles section. Please add that section to fix the problem', $this->filename));
}
foreach ($autoloader["bundles"] as $bundleClass => $options) {
$environments = (isset($options["environments"])) ? $options["environments"] : 'all';
if (!is_array($environments)) $environments = array($environments);
$overrides = (isset($options["overrides"])) ? $options["overrides"] : array();
$bundle = new Bundle();
$bundle
->setClass($bundleClass)
->setOverrides($overrides)
;
foreach ($environments as $environment) {
$this->bundles[$environment][] = $bundle;
}
}
if (isset($autoloader["actionManager"])) {
$this->actionManagerClass = $autoloader["actionManager"];
}
if (isset($autoloader["routing"])) {
$this->routing = $autoloader["routing"];
}
} | php | {
"resource": ""
} |
q265396 | TakeTransitionCommand.findTransition | test | protected function findTransition(Execution $execution)
{
$out = (array) $execution->getProcessModel()->findOutgoingTransitions($execution->getNode()->getId());
$trans = null;
if ($this->transitionId === null) {
if (count($out) != 1) {
throw new \RuntimeException(sprintf('No single outgoing transition found at node "%s"', $execution->getNode()->getId()));
}
return array_pop($out);
}
foreach ($out as $tmp) {
if ($tmp->getId() === $this->transitionId) {
$trans = $tmp;
break;
}
}
if ($trans === null) {
throw new \RuntimeException(sprintf('Transition "%s" not connected to node "%s"', $this->transitionId, $execution->getNode()->getId()));
}
return $trans;
} | php | {
"resource": ""
} |
q265397 | JqueryAjaxExtension.remoteCall | test | public function remoteCall($options = array())
{
return function ($options) {
$type = isset($options['type']) ? $options['type'] : "POST";
$dataType = isset($options['dataType']) ? $options['dataType'] : "html";
$js = "$.ajax({
url: '" . $options['url'] . "',
type: '" . $type . "',
dataType: '" . $dataType . "',";
if (isset($options['before'])) {
$before = str_replace('"', "'", $options['before']);
$js .= "beforeSend: function(){" . $before . "},";
}
$js .= "success: function( data ){ $('" . $options['update'] . "').html(data);";
if (isset($options['after'])) {
$after = str_replace('"', "'", $options['after']);
$js .= $after;
}
$js .= "}";
if (isset($options['complete'])) {
$complete = str_replace('"', "'", $options['complete']);
$js .= ",complete: function(){" . $complete . "},";
}
$js .= "});";
return $js;
};
} | php | {
"resource": ""
} |
q265398 | JqueryAjaxExtension.submitCall | test | public function submitCall($options = array())
{
return function ($options) {
$type = isset($options['type']) ? $options['type'] : "POST";
$dataType = isset($options['dataType']) ? $options['dataType'] : "html";
$js = "$.ajax({
url: '" . $options['url'] . "',
type: '" . $type . "',
data: $(this.form.elements).serializeArray(),
dataType: '" . $dataType . "',";
if (isset($options['before'])) {
$before = str_replace('"', "'", $options['before']);
$js .= "beforeSend: function(){" . $before . "},";
}
$js .= "success: function( data ){";
if (isset($options['success'])) {
$success = str_replace('"', "'", $options['success']);
$js .= $success ;
}
if (isset($options['after'])) {
$after = str_replace('"', "'", $options['after']);
$js .= $after;
}
$js .= "}});";
return $js;
};
} | php | {
"resource": ""
} |
q265399 | JqueryAjaxExtension.linkTag | test | public function linkTag($options = array())
{
$jsRequest = $this->remoteCall();
return function ($options) use($jsRequest)
{
$confirm = '';
if (isset($options['confirm']) && $options['confirm'] === true) {
$msg = "Are you sure you want to perform this action?";
if(isset($options['confirm_msg'])) {
$msg = htmlentities(str_replace("'", '"', $options['confirm_msg']), ENT_QUOTES);
}
$confirm .= "if(confirm('".$msg."'))" ;
}
$html = '<a class="' . (isset($options['class']) ? $options['class'] : "") . '"
id="' . (isset($options['id']) ? $options['id'] : "") . '"
href="' . $options['url'] . '"
onclick="' .$confirm. call_user_func($jsRequest, $options) . 'return false;">';
$html .= $options['text'];
$html .= '</a>';
return $html;
};
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.