_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q240800
|
RequestCookieCollection.set
|
train
|
public function set(string $name, RequestCookieInterface $requestCookie): void
{
$this->requestCookies[$name] = $requestCookie;
}
|
php
|
{
"resource": ""
}
|
q240801
|
TransformerFactory.make
|
train
|
public function make($name, $options)
{
if (!$name || !is_string($name)) {
return null;
}
if (isset($this->objTemplates[$name])) {
return clone $this->objTemplates[$name];
}
if (!$this->namespaceTransformer) {
$this->namespaceTransformer = $this->objTemplates[self::NAMESPACE_TRANSFORMER] = new PrependNamespace();
}
$className = $this->namespaceTransformer->transform($name, ['namespace' => __NAMESPACE__]);
if (!class_exists($className, true)) {
return null;
}
$this->objTemplates[$name] = new $className();
return clone $this->objTemplates[$name];
}
|
php
|
{
"resource": ""
}
|
q240802
|
ConnectTrait.setDefaultAttributes
|
train
|
protected function setDefaultAttributes()
{
if (!empty($this->attributes)) {
foreach ($this->attributes as $attr => $val) {
$this->realSetAttribute($attr, $val);
}
}
}
|
php
|
{
"resource": ""
}
|
q240803
|
AbstractMapperCollection.doAdd
|
train
|
protected function doAdd($object)
{
$this->notifyAccess();
$this->objectsArray[$this->total] = $object;
$this->total++;
}
|
php
|
{
"resource": ""
}
|
q240804
|
Reference.countVideos
|
train
|
public function countVideos(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null)
{
$partial = $this->collVideosPartial && !$this->isNew();
if (null === $this->collVideos || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collVideos) {
return 0;
}
if ($partial && !$criteria) {
return count($this->getVideos());
}
$query = ChildVideoQuery::create(null, $criteria);
if ($distinct) {
$query->distinct();
}
return $query
->filterByReference($this)
->count($con);
}
return count($this->collVideos);
}
|
php
|
{
"resource": ""
}
|
q240805
|
Reference.getSkillReferences
|
train
|
public function getSkillReferences(Criteria $criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collSkillReferencesPartial && !$this->isNew();
if (null === $this->collSkillReferences || null !== $criteria || $partial) {
if ($this->isNew() && null === $this->collSkillReferences) {
// return empty collection
$this->initSkillReferences();
} else {
$collSkillReferences = ChildSkillReferenceQuery::create(null, $criteria)
->filterByReference($this)
->find($con);
if (null !== $criteria) {
if (false !== $this->collSkillReferencesPartial && count($collSkillReferences)) {
$this->initSkillReferences(false);
foreach ($collSkillReferences as $obj) {
if (false == $this->collSkillReferences->contains($obj)) {
$this->collSkillReferences->append($obj);
}
}
$this->collSkillReferencesPartial = true;
}
return $collSkillReferences;
}
if ($partial && $this->collSkillReferences) {
foreach ($this->collSkillReferences as $obj) {
if ($obj->isNew()) {
$collSkillReferences[] = $obj;
}
}
}
$this->collSkillReferences = $collSkillReferences;
$this->collSkillReferencesPartial = false;
}
}
return $this->collSkillReferences;
}
|
php
|
{
"resource": ""
}
|
q240806
|
Reference.getSkillReferencesJoinSkill
|
train
|
public function getSkillReferencesJoinSkill(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN)
{
$query = ChildSkillReferenceQuery::create(null, $criteria);
$query->joinWith('Skill', $joinBehavior);
return $this->getSkillReferences($query, $con);
}
|
php
|
{
"resource": ""
}
|
q240807
|
Reference.getSkills
|
train
|
public function getSkills(Criteria $criteria = null, ConnectionInterface $con = null)
{
$partial = $this->collSkillsPartial && !$this->isNew();
if (null === $this->collSkills || null !== $criteria || $partial) {
if ($this->isNew()) {
// return empty collection
if (null === $this->collSkills) {
$this->initSkills();
}
} else {
$query = ChildSkillQuery::create(null, $criteria)
->filterByReference($this);
$collSkills = $query->find($con);
if (null !== $criteria) {
return $collSkills;
}
if ($partial && $this->collSkills) {
//make sure that already added objects gets added to the list of the database.
foreach ($this->collSkills as $obj) {
if (!$collSkills->contains($obj)) {
$collSkills[] = $obj;
}
}
}
$this->collSkills = $collSkills;
$this->collSkillsPartial = false;
}
}
return $this->collSkills;
}
|
php
|
{
"resource": ""
}
|
q240808
|
Reference.removeSkill
|
train
|
public function removeSkill(ChildSkill $skill)
{
if ($this->getSkills()->contains($skill)) { $skillReference = new ChildSkillReference();
$skillReference->setSkill($skill);
if ($skill->isReferencesLoaded()) {
//remove the back reference if available
$skill->getReferences()->removeObject($this);
}
$skillReference->setReference($this);
$this->removeSkillReference(clone $skillReference);
$skillReference->clear();
$this->collSkills->remove($this->collSkills->search($skill));
if (null === $this->skillsScheduledForDeletion) {
$this->skillsScheduledForDeletion = clone $this->collSkills;
$this->skillsScheduledForDeletion->clear();
}
$this->skillsScheduledForDeletion->push($skill);
}
return $this;
}
|
php
|
{
"resource": ""
}
|
q240809
|
Index.search
|
train
|
public function search($key)
{
$binarySearch = new BinarySearch($this);
$result = $binarySearch->search($key);
if (\is_null($result) || $result->getKey() != $key) {
return null;
}
return $result;
}
|
php
|
{
"resource": ""
}
|
q240810
|
Index.searchRange
|
train
|
public function searchRange(Range $range)
{
$iterator = $this->getIterator();
// find start
$start = null;
$binarySearch = new BinarySearch($this);
$startHint = $binarySearch->search($range->getMin());
if ($startHint == null) {
return new RangeIterator($iterator, Range::getEmptyRange());
}
$iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY);
if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) {
// shift $startHint higher
foreach ($iterator as $result) {
if ($range->contains($result->getKey())) {
$start = $result;
break;
}
}
} else {
// shift $startHint lower
if ($range->contains($startHint->getKey())) {
$start = $startHint;
}
$iterator->setDirection(KeyReader::DIRECTION_BACKWARD);
foreach ($iterator as $result) {
// Skip everything which is too big
if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) {
continue;
}
// shift the start left until no more key is included
if ($range->contains($result->getKey())) {
$start = $result;
} else {
break;
}
}
}
if (is_null($start)) {
return new RangeIterator($iterator, Range::getEmptyRange());
}
$iterator = $this->getIterator();
$iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY);
return new RangeIterator($iterator, $range);
}
|
php
|
{
"resource": ""
}
|
q240811
|
Object.get
|
train
|
public function get($property, $default = null)
{
if (!$this->has($property))
{
return $default;
}
return null !== $this->data[$property] ? $this->data[$property] : $default;
}
|
php
|
{
"resource": ""
}
|
q240812
|
Mapper.copyfrom
|
train
|
public function copyfrom($var,$func=NULL)
{
if (is_string($var)) {
$var = Base::instance()->get($var);
}
if ($func) {
$var = call_user_func($func, $var);
}
foreach ($var as $key=>$val) {
if (
array_key_exists($key, $this->fields)
|| array_key_exists($key, $this->extras)
) {
$this->set($key,$val);
}
}
}
|
php
|
{
"resource": ""
}
|
q240813
|
RequireAnnotation.parse
|
train
|
public function parse($param_str) {
$file = new File(trim($param_str), $this->getScope()->getFile()->getAbsoluteFile()->getParent());
if (!$file->exists()) {
throw new ResourceNotFoundException($param_str, $this->getScope(), $this->getOccursPos(), "The Requirement File Not Exists");
}
if (is_null($require_resource = $this->getParentProject()->getResourceByFile($file))) {
throw new \Chigi\Chiji\Exception\ProjectMemberNotFoundException("ERROR: UNREGISTERED Resource File: " + $file->getAbsolutePath());
}
if ($this->getScope() instanceof RequiresMapInterface) {
$this->getScope()->getRequires()->addResource($require_resource);
}
}
|
php
|
{
"resource": ""
}
|
q240814
|
Tiny_diff.compare
|
train
|
public function compare($old, $new, $mode = 'normal')
{
// Mixed
if ( $mode === 'mixed')
{
// Insert characters
$ins_begin = '<ins>+ ';
$ins_end = '</ins>' . PHP_EOL;
// Delete characters
$del_begin = '<del>- ';
$del_end = '</del>' . PHP_EOL;
}
// HTML mode
elseif ( $mode === 'html' )
{
// Insert characters
$ins_begin = '<ins>';
$ins_end = '</ins>' . PHP_EOL;
// Delete characters
$del_begin = '<del>';
$del_end = '</del>' . PHP_EOL;
}
// Normal mode
else
{
// Insert characters
$ins_begin = '+ ';
$ins_end = PHP_EOL;
// Delete characters
$del_begin = '- ';
$del_end = PHP_EOL;
}
// Turn the strings into an array so it's a bit easier to parse them
$diff = $this->diff(explode(PHP_EOL, $old), explode(PHP_EOL, $new));
$result = '';
if ($mode == 'raw')
return $diff;
foreach($diff as $line)
{
if(is_array($line))
{
$result .= !empty($line['del']) ? $del_begin . implode(PHP_EOL, $line['del']) . $del_end : '';
$result .= !empty($line['ins']) ? $ins_begin . implode(PHP_EOL, $line['ins']) . $ins_end : '';
}
else
{
$result .= $line . PHP_EOL;
}
}
// Return the result
return $result;
}
|
php
|
{
"resource": ""
}
|
q240815
|
Tiny_diff.diff
|
train
|
private function diff($old, $new)
{
$maxlen = 0;
// Go through each old line.
foreach($old as $old_line => $old_value)
{
// Get the new lines that match the old line
$new_lines = array_keys($new, $old_value);
// Go through each new line number
foreach($new_lines as $new_line)
{
$matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1;
if($matrix[$old_line][$new_line] > $maxlen)
{
$maxlen = $matrix[$old_line][$new_line];
$old_max = $old_line + 1 - $maxlen;
$new_max = $new_line + 1 - $maxlen;
}
}
}
if($maxlen == 0)
{
return array(array('del'=>$old, 'ins'=>$new));
}
return array_merge(
self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)),
array_slice($new, $new_max, $maxlen),
self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen))
);
}
|
php
|
{
"resource": ""
}
|
q240816
|
BackyardGeo.getRoughDistance
|
train
|
public function getRoughDistance($clientLng, $clientLat, $poiLng, $poiLat)
{
$result = abs($clientLng - $poiLng) + abs($clientLat - $poiLat);
$this->BackyardError->log(5, "client({$clientLng}, {$clientLat}) poi({$poiLng}, {$poiLat}) roughDistance = {$result}");
return $result;
}
|
php
|
{
"resource": ""
}
|
q240817
|
ServiceProvider.register
|
train
|
public function register()
{
// Register Sub Providers
$this->registerSubProviders(collect($this->subProviders));
// Register bindings.
$this->registerBindings(collect($this->bindings));
// Register migrations.
$this->registerMigrations(collect($this->migrations));
// Register seeders.
$this->registerSeeders(collect($this->seeders));
// Register model factories.
$this->registerFactories(collect($this->factories));
}
|
php
|
{
"resource": ""
}
|
q240818
|
ServiceProvider.registerSubProviders
|
train
|
protected function registerSubProviders(Collection $subProviders)
{
$subProviders->each(function ($provider) {
$this->app->register($provider);
});
}
|
php
|
{
"resource": ""
}
|
q240819
|
ServiceProvider.registerBindings
|
train
|
protected function registerBindings(Collection $bindings)
{
$bindings->each(function ($concretion, $abstraction) {
$this->app->bind($abstraction, $concretion);
});
}
|
php
|
{
"resource": ""
}
|
q240820
|
RobocloudKinesisClient.getKinesisClient
|
train
|
public function getKinesisClient($type)
{
if (!empty($this->clients[$type])) {
return $this->clients[$type];
}
$config = [
'version' => $this->config['api_version'],
'region' => $this->config['region'],
];
$config['credentials'] = [
'key' => $this->config[$type]['key'],
'secret' => $this->config[$type]['secret'],
];
$sdk = new Sdk();
$this->clients[$type] = $sdk->createKinesis($config);
return $this->clients[$type];
}
|
php
|
{
"resource": ""
}
|
q240821
|
IndexController.preDispatch
|
train
|
public function preDispatch(MvcEvent $e) {
if ($this->zfcUserAuthentication ()->hasIdentity ()) {
$userName = $this->zfcUserAuthentication ()->getIdentity ()->getUsername ();
} else {
$userName = 'anonymous';
}
$this->layout ()->setVariable ( 'dataTypes', $this->getDataTypesHandler ()->getDataTypes () );
$this->layout ()->setVariable ( 'userName', $userName );
$this->layout ()->setVariable ( 'action', $this->params ( 'action' ) );
$this->layout ()->setVariable ( 'authService', $this->getFileAuthService () );
$this->layout ()->setVariable ( 'jqueryUiTheme', $this->getJqueryUiTheme () );
$controller = $this->params ( 'controller' );
$controller = explode ( '\\', $controller );
$controller = array_pop ( $controller );
$controller = strtolower ( $controller );
$this->layout ()->setVariable ( 'controller', $controller );
}
|
php
|
{
"resource": ""
}
|
q240822
|
Collection.isDirty
|
train
|
public function isDirty()
{
if (count($this) != $this->_original) {
return true;
}
if (count($this->_deleted)) {
return true;
}
foreach ($this as $model) {
if (is_object($model)
&& ($model->isDirty() || $model->isNew())
) {
return true;
}
}
return false;
}
|
php
|
{
"resource": ""
}
|
q240823
|
Collection.markClean
|
train
|
public function markClean()
{
foreach ($this as $model) {
if (is_object($model)) {
$model->markClean();
}
}
$this->_original = count($this);
}
|
php
|
{
"resource": ""
}
|
q240824
|
Collection.jsonSerialize
|
train
|
public function jsonSerialize()
{
$out = [];
foreach ($this as $model) {
if (!is_object($model)) {
continue;
}
if ($model instanceof JsonSerializable) {
$out[] = $model->jsonSerialize();
} else {
$out[] = (object)(array)$model;
}
}
return $out;
}
|
php
|
{
"resource": ""
}
|
q240825
|
Item.get
|
train
|
public function get($key, $default = null)
{
if(!is_string($key) || empty($key)) {
return $default;
}
//split string into array
$item_pieces = explode('.', $key);
//let igorw check if array item exists
return igorw\get_in($this->data, $item_pieces, $default);
}
|
php
|
{
"resource": ""
}
|
q240826
|
Seeder.execute
|
train
|
protected static function execute($seeder)
{
$data = self::fill($seeder);
//
$table = new DBTable($seeder->table);
return $table->insert($data);
}
|
php
|
{
"resource": ""
}
|
q240827
|
Seeder.fill
|
train
|
public static function fill($seeder)
{
$data = [];
//
if ($seeder->count <= 0) {
foreach ($seeder->data() as $value) {
// Collection::push($data, $value);
array_push($data, $value);
}
} else {
for ($i = 0; $i < $seeder->count; $i++) {
// Collection::push($data, $seeder->data());
array_push($data, $seeder->data());
}
}
//
return $data;
}
|
php
|
{
"resource": ""
}
|
q240828
|
PasswordController.request
|
train
|
public function request(Request $request)
{
$user = User::whereEmail($request->email)->firstOrFail();
$user->sendResetPasswordNotification($this->broker()->createToken($user), $request);
return response()->json('Password request successful', 200);
}
|
php
|
{
"resource": ""
}
|
q240829
|
Scores.createNew
|
train
|
public function createNew(
string $attribute,
string $name,
float $value
) : array {
return $this->sendPost(
sprintf('/profiles/%s/scores', $this->userName),
[],
[
'attribute' => $attribute,
'name' => $name,
'value' => $value
]
);
}
|
php
|
{
"resource": ""
}
|
q240830
|
Scores.upsertOne
|
train
|
public function upsertOne(
string $attribute,
string $name,
float $value
) : array {
return $this->sendPut(
sprintf('/profiles/%s/scores', $this->userName),
[],
[
'attribute' => $attribute,
'name' => $name,
'value' => $value
]
);
}
|
php
|
{
"resource": ""
}
|
q240831
|
Scores.updateOne
|
train
|
public function updateOne(string $attribute, string $name, float $value) : array {
return $this->sendPatch(
sprintf('/profiles/%s/scores/%s', $this->userName, $name),
[],
[
'attribute' => $attribute,
'value' => $value
]
);
}
|
php
|
{
"resource": ""
}
|
q240832
|
ClearShell.all
|
train
|
public function all() {
foreach ( $this->tasks as $task => $option ) {
$task = $this->taskClassname($task);
$this->$task->all();
}
}
|
php
|
{
"resource": ""
}
|
q240833
|
Bstall.make
|
train
|
public function make($name="default", $width=100, $height=100, $bgcolor=0xFFFFFF)
{
$bstall = new Bstall;
$this->width = $width;
$this->height = $height;
$this->bgcolor = $bgcolor;
$this->load($name);
return View::make('bstall::canvas', [
'name' => $name,
'width' => $this->width,
'height' => $this->height,
'canvas' => json_encode($this->canvas, true)
]);
}
|
php
|
{
"resource": ""
}
|
q240834
|
Bstall.load
|
train
|
public function load($name)
{
$stall = $this->redis->get("bstall_{$name}");
if(is_null($stall)) {
$this->clean();
$this->save($name);
} else {
$canvas = unserialize($stall);
$this->canvas = $canvas;
}
}
|
php
|
{
"resource": ""
}
|
q240835
|
Bstall.clean
|
train
|
public function clean()
{
$this->canvas = [];
for($y=0; $y < $this->height; $y++) {
array_push($this->canvas, []);
for($x=0; $x < $this->width; $x++) {
$this->canvas[$y][$x] = $this->bgcolor;
}
}
}
|
php
|
{
"resource": ""
}
|
q240836
|
Bstall.write
|
train
|
public function write($x, $y, $color)
{
if(isset($this->canvas[$y][$x])) {
$this->canvas[$y][$x] = $color;
}
}
|
php
|
{
"resource": ""
}
|
q240837
|
next.parent
|
train
|
public static function parent()
{
if (!self::$activeTraitMethod) {
throw new \BadMethodCallException("next:parent() call is only allowed in trait calls");
}
$arguments = func_get_args();
return call_user_func(self::$activeTraitMethod, $arguments);
}
|
php
|
{
"resource": ""
}
|
q240838
|
ArticleStatisticImporter.importArticleStatistics
|
train
|
public function importArticleStatistics()
{
$pendingImports = $this->em->getRepository('ImportBundle:PendingStatisticImport')->findAll();
$this->consoleOutput->writeln("Importing article statistics...");
foreach ($pendingImports as $import) {
$this->importArticleStatistic($import->getOldId(), $import->getArticle()->getId());
$this->em->remove($import);
$this->em->flush($import);
}
}
|
php
|
{
"resource": ""
}
|
q240839
|
ArticleStatisticImporter.importArticleStatistic
|
train
|
public function importArticleStatistic($oldId, $newId)
{
$article = $this->em->getRepository('VipaJournalBundle:Article')->find($newId);
if (!$article) {
$this->consoleOutput->writeln("Couldn't find #" . $newId . " on the new database.");
return;
}
$this->consoleOutput->writeln("Reading view statistics for #" . $oldId . "...");
$viewStatsSql = "SELECT DATE(view_time) AS date, COUNT(*) as view FROM " .
"article_view_stats WHERE article_id = :id GROUP BY DATE(view_time)";
$viewStatsStatement = $this->dbalConnection->prepare($viewStatsSql);
$viewStatsStatement->bindValue('id', $oldId);
$viewStatsStatement->execute();
$this->consoleOutput->writeln("Reading download statistics for #" . $oldId . "...");
$downloadStatsSql = "SELECT DATE(download_time) AS date, COUNT(*) as download FROM " .
"article_download_stats WHERE article_id = :id GROUP BY DATE(download_time)";
$downloadStatsStatement = $this->dbalConnection->prepare($downloadStatsSql);
$downloadStatsStatement->bindValue('id', $oldId);
$downloadStatsStatement->execute();
$pkpViewStats = $viewStatsStatement->fetchAll();
$pkpDownloadStats = $downloadStatsStatement->fetchAll();
foreach ($pkpViewStats as $stat) {
$articleFileStatistic = new ArticleStatistic();
$articleFileStatistic->setArticle($article);
$articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date']));
$articleFileStatistic->setView($stat['view']);
$this->em->persist($articleFileStatistic);
}
if (!$article->getArticleFiles()->isEmpty()) {
foreach ($pkpDownloadStats as $stat) {
$articleFileStatistic = new ArticleFileStatistic();
$articleFileStatistic->setArticleFile($article->getArticleFiles()->first());
$articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date']));
$articleFileStatistic->setDownload($stat['download']);
$this->em->persist($articleFileStatistic);
}
}
$this->em->flush();
}
|
php
|
{
"resource": ""
}
|
q240840
|
Zend_Gdata.getFeed
|
train
|
public function getFeed($location, $className = 'Zend_Gdata_Feed')
{
if (is_string($location)) {
$uri = $location;
} elseif ($location instanceof Zend_Gdata_Query) {
$uri = $location->getQueryUrl();
} else {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'You must specify the location as either a string URI ' .
'or a child of Zend_Gdata_Query');
}
return parent::getFeed($uri, $className);
}
|
php
|
{
"resource": ""
}
|
q240841
|
Zend_Gdata.performHttpRequest
|
train
|
public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null)
{
if ($this->_httpClient instanceof Zend_Gdata_HttpClient) {
$filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType);
$method = $filterResult['method'];
$url = $filterResult['url'];
$body = $filterResult['body'];
$headers = $filterResult['headers'];
$contentType = $filterResult['contentType'];
return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects));
} else {
return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects);
}
}
|
php
|
{
"resource": ""
}
|
q240842
|
Zend_Gdata.isAuthenticated
|
train
|
public function isAuthenticated()
{
$client = parent::getHttpClient();
if ($client->getClientLoginToken() ||
$client->getAuthSubToken()
) {
return true;
}
return false;
}
|
php
|
{
"resource": ""
}
|
q240843
|
CmsPageHelper.renderTree
|
train
|
public function renderTree($pages, $closedPages, $langId, $level = null) {
if (empty($pages)) {
$newPageLink = $this->Html->link(
__d('wasabi_cms', 'Please add your first Page'),
[
'plugin' => 'Wasabi/Cms',
'controller' => 'Pages',
'action' => 'add'
],
[
'title' => __d('wasabi_cms', 'Add your first Page')
]
);
return '<li class="center">' . __d('wasabi_cms', 'There are no pages yet. {0}.', $newPageLink) . '</li>';
}
$output = '';
$depth = ($level !== null) ? $level : 1;
foreach ($pages as $page) {
$closed = false;
$classes = ['page'];
if (in_array($page->id, $closedPages)) {
$closed = true;
$classes[] = 'closed';
}
$pageRow = $this->_View->element('Wasabi/Cms.../Pages/__page-row', [
'page' => $page,
'closed' => $closed,
'langId' => $langId
]);
if (!empty($page->children)) {
$pageRow .= '<ul' . ($closed ? ' style="display: none;"' : '') . '>' . $this->renderTree($page->children, $closedPages, $langId, $depth + 1) . '</ul>';
} else {
$classes[] = 'no-children';
}
$output .= '<li class="' . join(' ', $classes) . '" data-cms-page-id="' . $page->id . '">' . $pageRow . '</li>';
}
return $output;
}
|
php
|
{
"resource": ""
}
|
q240844
|
SimpleXmlElement._toBoolean
|
train
|
protected function _toBoolean($value)
{
$value = strtolower((string)$value);
$result = ($value != 'false')
&& ($value != 'off')
&& !empty($value);
return $result;
}
|
php
|
{
"resource": ""
}
|
q240845
|
SimpleXmlElement.quoteXpathValue
|
train
|
public static function quoteXpathValue($string)
{
if (strpos($string, "'") === false) {
return "'$string'";
}
if (strpos($string, '"') === false) {
return '"' . $string . '"';
}
// String contains ' and " -> need to use concat ...
$parts = explode("'", $string);
$quoted = implode('\', "\'", \'', $parts);
return "concat('$quoted')";
}
|
php
|
{
"resource": ""
}
|
q240846
|
SimpleXmlElement.getPath
|
train
|
public function getPath()
{
$stack = array($this->getName());
$current = $this;
while ($parent = $current->getParent()) {
array_unshift($stack, $parent->getName());
$current = $parent;
}
return implode('/', $stack);
}
|
php
|
{
"resource": ""
}
|
q240847
|
SimpleXmlElement.toValue
|
train
|
public function toValue($type = null, $valueAttribute = null)
{
$value = ($valueAttribute)? (string)$this[$valueAttribute] : (string)$this;
$type = ($type)?: (string)$this['type'];
switch ($type) {
case 'int':
$value = (int)$value;
break;
case 'float':
$value = (float)$value;
break;
case 'bool':
$value = $this->_toBoolean($value);
break;
case 'double':
$value = (double)$value;
break;
case 'null':
$value = null;
break;
case 'array':
$value = $this->toArray(true);
break;
}
return $value;
}
|
php
|
{
"resource": ""
}
|
q240848
|
SimpleXmlElement.toArray
|
train
|
public function toArray($force = true)
{
if (!$force && !$this->hasChildren()) {
return $this->toValue();
}
$data = array();
foreach ($this->children() as $name => $child) {
$data[$name] = $child->toArray(false);
}
return $data;
}
|
php
|
{
"resource": ""
}
|
q240849
|
SimpleXmlElement.toPhpValue
|
train
|
public function toPhpValue($type = null, $serviceLocator = null)
{
if (!$type) {
$type = $this->getName();
}
switch ($type) {
case 'array':
$value = array();
if (!isset($this->item)) {
return $value;
}
foreach ($this->item as $item) {
if (!($type = (string)$item['type'])) {
$type = 'string';
}
// Instance must be defined in subtag
if (($type == 'instance') && !$item->{$type}) {
$current = null;
} else {
$current = ($item->{$type})? $item->{$type}->toPhpValue($type, $serviceLocator) : $item->toPhpValue($type, $serviceLocator);
}
if (!isset($item['key']) && !isset($item['index'])) {
$value[] = $current;
continue;
}
$key = (isset($item['key']))? (string)$item['key'] : intval((string)$item['index']);
$value[$key] = $current;
}
break;
case 'null':
$value = null;
break;
case 'instance':
$class = (string)$this['class'];
$value = null;
if (($serviceLocator instanceof ServiceLocatorInterface) && ($serviceLocator->has($class))) {
$value = $serviceLocator->get($class);
break;
}
if ($serviceLocator instanceof DependencyInjectionInterface) {
$options = array();
if (isset($this->options)) {
$options = $this->options->toPhpValue('array', $serviceLocator);
}
$value = $serviceLocator->newInstance($class, $options);
break;
}
break;
default:
$value = $this->toValue($type);
break;
}
return $value;
}
|
php
|
{
"resource": ""
}
|
q240850
|
SimpleXmlElement._getMergeRule
|
train
|
protected function _getMergeRule($element, &$affected = null, $rule = null)
{
if ($rule instanceof MergeRuleInterface) {
$result = $rule($this, $element, $affected);
if ($result !== false) {
return $result;
}
}
$name = $element->getName();
if (isset($this->{$name})) {
$affected = $this->{$name};
return self::MERGE_REPLACE;
}
return self::MERGE_APPEND;
}
|
php
|
{
"resource": ""
}
|
q240851
|
SimpleXmlElement.mergeAttributes
|
train
|
public function mergeAttributes(SimpleXmlElement $node, $replace = true)
{
foreach ($node->attributes() as $name => $value) {
if (isset($this[$name])) {
if ($replace) {
$this[$name] = (string)$value;
}
continue;
}
$this->addAttribute($name, (string)$value);
}
return $this;
}
|
php
|
{
"resource": ""
}
|
q240852
|
SimpleXmlElement.merge
|
train
|
public function merge(SimpleXmlElement $element, $replace = true, $rule = null)
{
foreach ($element->children() as $name => $child) {
$affected = null;
$currentpath = $child->getPath();
$action = $this->_getMergeRule($child, $affected, $rule);
if ($action == self::MERGE_APPEND) {
$affected = $this->addChild($name, (string)$child);
}
if (!$affected instanceof SimpleXmlElement) {
continue;
}
$affected->mergeAttributes($child, $replace);
if ($child->hasChildren()) {
$affected->merge($child, $replace, $rule);
continue;
} else if ($replace) {
$affected[0] = (string)$child;
}
}
return $this;
}
|
php
|
{
"resource": ""
}
|
q240853
|
Router.route_exists
|
train
|
private function route_exists() : bool {
if ( property_exists( $this, 'routes' ) ) {
return array_key_exists( $this->__method_name, $this->routes );
}
return false;
}
|
php
|
{
"resource": ""
}
|
q240854
|
Router.route_request
|
train
|
private function route_request() {
$named_arguments = $this->get_named_arguments();
list( $to_class, $to_method, $on_error ) = $this->get_route_parts();
return $this->do_route( $to_class, $to_method, $named_arguments, $on_error );
}
|
php
|
{
"resource": ""
}
|
q240855
|
Router.get_named_arguments
|
train
|
private function get_named_arguments() : array {
// name the parameters
$named_arguments = [];
if ( array_key_exists( 'expects', $this->routes[ $this->__method_name ] ) ) {
$expects = $this->routes[ $this->__method_name ]['expects'];
foreach ( $expects as $index => $parameter_name ) {
if ( array_key_exists( $index, $this->__arguments ) ) {
$named_arguments[ $parameter_name ] = $this->__arguments[ $index ];
}
}
}
return $named_arguments;
}
|
php
|
{
"resource": ""
}
|
q240856
|
Router.get_route_parts
|
train
|
private function get_route_parts() : array {
$to = $this->routes[ $this->__method_name ]['to'];
if ( \is_array( $to ) ) {
$to_parts = $to;
} else {
$to_parts = explode( '@', $to );
}
$to_class = $to_parts[0];
$to_method = $to_parts[1];
$on_error = null;
if ( array_key_exists( 'on_error', $this->routes[ $this->__method_name ] ) ) {
$on_error = $this->routes[ $this->__method_name ]['on_error'];
}
return [ $to_class, $to_method, $on_error ];
}
|
php
|
{
"resource": ""
}
|
q240857
|
Router.do_route
|
train
|
private function do_route( $class_name, $method_name, $named_arguments, $on_error ) {
if ( \is_object( $class_name ) ) {
return $this->call(
array(
$class_name,
$method_name,
),
$named_arguments
);
}
$injector_factory = new Dependency_Injection_Factory(
$class_name,
$method_name,
$named_arguments
);
list(
$obj,
$dependencies,
$validators
) = $injector_factory->build();
// Check all validators
foreach ( $validators as $validator ) {
$message = $validator->validate( $on_error );
if ( $message ) {
return $message;
}
}
return $this->call(
array(
$obj,
$method_name,
),
$dependencies
);
}
|
php
|
{
"resource": ""
}
|
q240858
|
ResponseFactory.template
|
train
|
public static function template($template, $parameter = array(), $status = 200, $headers = array())
{
View::setTemplate($template, $parameter);
return new Response('', $status, $headers);
}
|
php
|
{
"resource": ""
}
|
q240859
|
ResponseFactory.json
|
train
|
public static function json($data, $status = 200, $headers = array())
{
$jsonHeader = array('Content-Type' => 'application/json');
$content = json_encode($data);
return new Response($content, $status, $jsonHeader);
}
|
php
|
{
"resource": ""
}
|
q240860
|
ResponseFactory.redirect
|
train
|
public static function redirect($url, $status = 302, $headers = array())
{
$redirect = new RedirectResponse($url, $status, $headers);
$redirect->sendHeaders();
die();
}
|
php
|
{
"resource": ""
}
|
q240861
|
ResponseFactory.download
|
train
|
public static function download($file, $status = 200, $headers = array())
{
require_once ABSPATH.'wp-admin/includes/file.php';
WP_Filesystem();
global $wp_filesystem;
$fileData = $wp_filesystem->get_contents($file);
$downloadHeader['Content-Description'] = 'File Transfer';
$downloadHeader['Content-Type'] = 'application/octet-stream';
$downloadHeader['Content-Disposition'] = 'attachment; filename='.basename($file);
$downloadHeader['Content-Transfer-Encoding'] = 'binary';
$downloadHeader['Expires'] = '0';
$downloadHeader['Cache-Control'] = 'must-revalidate';
$downloadHeader['Pragma'] = 'public';
$downloadHeader['Content-Length'] = filesize($file);
$response = new Response($fileData, 200, $downloadHeader);
$response->send();
}
|
php
|
{
"resource": ""
}
|
q240862
|
LanguageListener.setLocaleForUnauthenticatedUser
|
train
|
public function setLocaleForUnauthenticatedUser(GetResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$request = $event->getRequest();
if ('unset' == $request->getLocale()) {
if ($locale = $request->getSession()->get('_locale')) {
$request->setLocale($locale);
} else {
$request->setLocale($request->getPreferredLanguage());
}
}
}
|
php
|
{
"resource": ""
}
|
q240863
|
LanguageListener.setLocaleForAuthenticatedUser
|
train
|
public function setLocaleForAuthenticatedUser(InteractiveLoginEvent $event)
{
$user = $event->getAuthenticationToken()->getUser();
if ($lang = $user->getLocale()) {
$this->session->set('_locale', $lang);
} else {
$request = $event->getRequest();
if ('unset' == $request->getLocale()) {
$this->session->set('_locale', 'en');
}
}
}
|
php
|
{
"resource": ""
}
|
q240864
|
App.makeInstance
|
train
|
protected static function makeInstance(
$class, array $options = null
): Implementation {
$options || $options = ['provider' => self::app()];
return IOC::make($class, [$options, true]);
}
|
php
|
{
"resource": ""
}
|
q240865
|
App.getInstance
|
train
|
public static function getInstance(
$class = null,
array $options = []
) {
/** @var Implementation $instance */
if (is_null(self::$instance)) {
if (is_null($class)) {
self::$instance = self::makeInstance(
Implementation::class, $options
)->getApp($options);
self::$instance->load();
} else {
! is_object($class) || self::$instance = $class;
}
}
return self::$instance;
}
|
php
|
{
"resource": ""
}
|
q240866
|
Signature.setHttpMethod
|
train
|
public function setHttpMethod($method)
{
$allowedMethods = array(
'POST',
'PUT',
'GET',
'DELETE',
'PATCH'
);
if (!in_array(strtoupper($method), $allowedMethods)) {
throw new \InvalidArgumentException('Provided method not allowed');
}
$this->httpMethod = strtoupper($method);
return $this;
}
|
php
|
{
"resource": ""
}
|
q240867
|
Signature.getNonce
|
train
|
public function getNonce()
{
if ($this->nonce !== '') {
return $this->nonce;
}
$this->nonce = md5(uniqid(rand(), true));
return $this->nonce;
}
|
php
|
{
"resource": ""
}
|
q240868
|
Signature.setTimestamp
|
train
|
public function setTimestamp($timestamp = 0)
{
$this->timestamp = $timestamp;
if ($timestamp === 0) {
$this->timestamp = $this->generateTimestamp();
}
return $this;
}
|
php
|
{
"resource": ""
}
|
q240869
|
AnnotationManagerFactory.createService
|
train
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$annotationManager = new AnnotationManager();
$parser = new DoctrineAnnotationParser();
foreach ($this->defaultAnnotations as $annotationName) {
$class = 'TjoAnnotationRouter\\Annotation\\' . $annotationName;
$parser->registerAnnotation($class);
}
$annotationManager->attach($parser);
return $annotationManager;
}
|
php
|
{
"resource": ""
}
|
q240870
|
TimeEntry.setTask
|
train
|
public function setTask($task)
{
$taskCode = filter_var($task, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if (strpos($taskCode, '-') !== false) {
$taskCode = str_replace('-', '', $taskCode);
}
$taskCode = $this->project . $taskCode;
$this->task = $taskCode;
}
|
php
|
{
"resource": ""
}
|
q240871
|
TimeEntry.processTags
|
train
|
public function processTags($tags = null)
{
if (empty($tags)) {
$tags = $this->tags;
}
foreach ($tags as $tag) {
$this->tags[] = $tag;
if (preg_match('/[A-Z]+\-[\d]+/', $tag)) {
$this->setTicket($tag);
continue;
}
if ($tag == 'Jira') {
$this->setLogged(true);
}
}
$this->tags = array_unique($this->tags);
}
|
php
|
{
"resource": ""
}
|
q240872
|
StorageboxMethod.startRestoreService
|
train
|
private function startRestoreService( StorageboxData $data, $backupKey, Database $database, OutputInterface $output) {
$stackName = $data->getBackup()->getStackName();
$restoreService = new Service();
$restoreService->setImage('ipunktbs/xtrabackup:1.1.1');
$restoreService->setName('restore-'.$backupKey);
$restoreService->setCommand('restore '.$backupKey);
$restoreService->setRestart(Service::RESTART_START_ONCE);
$mysqlVolume = $this->makeVolume($data);
$backupVolume = $this->makeBackupVolume($database);
$restoreService->addVolume( $mysqlVolume );
$restoreService->addVolume( $backupVolume );
/**
* @var SchedulerParser $schedulerParser
*/
//$schedulerParser = container(SchedulerParser::class);
$schedulerParser = container('scheduler-parser');
$config = new ArrayConfiguration([
'scheduler' => [
'should-have-tags' => [ 'primary-restore' ]
]
]);
$schedulerParser->parse($restoreService, $config);
$restoreInfrastructure = new Infrastructure();
$restoreInfrastructure->addService($restoreService);
$this->infrastructureWriter->setPath( $this->getWorkDirectory() )
->setSkipClear(false)
->write($restoreInfrastructure, new FileWriter());
$output->writeln("Starting ".$restoreService->getName().".");
$this->rancherService->start( $this->getWorkDirectory(), $stackName);
$output->writeln("Waiting for ".$restoreService->getName()." to finish.");
$this->rancherService->wait($stackName, $restoreService->getName(), new HealthStateMatcher('started-once') );
$output->writeln($restoreService->getName()." finished.");
return $restoreService;
}
|
php
|
{
"resource": ""
}
|
q240873
|
StorageboxMethod.startNewService
|
train
|
private function startNewService(Service $restoreService,StorageboxData $data, $backupKey, OutputInterface $output) {
$stackName = $data->getBackup()->getStackName();
$restoreServiceName = $restoreService->getName();
$dockerCompose = [
'version' => '2',
'services' => array_merge(
[$data->getBackup()->getServiceName() => $data->getService()],
$data->getSidekicks()
)
];
$rancherCompose = $data->getRancherData();
// TODO: Allow to set as option. If not set: ask user
$regex = '~$~';
$replacement = '-'.$backupKey;
foreach($this->modifiers as $modifier) {
if($modifier instanceof RequiresReplacementRegex)
$modifier->setReplacementRegex($regex, $replacement);
$modifier->modify($dockerCompose, $rancherCompose, $data);
}
// Start on the same server as the restore service
$compose = &$dockerCompose;
foreach([
'services',
$data->getNewServiceName(),
'labels',
] as $key) {
if( !array_key_exists($key, $compose) )
$compose[$key] = [];
$compose = &$compose[$key];
}
$dockerCompose['services'][$data->getNewServiceName()]['labels']['io.rancher.scheduler.affinity:container_label_soft'] = "io.rancher.stack_service.name=${stackName}/${restoreServiceName}";
$dockerFileContent = Yaml::dump($dockerCompose, 100, 2);
$this->buildService->createDockerCompose($dockerFileContent);
$rancherFileContent = Yaml::dump($rancherCompose, 100, 2);
$this->buildService->createRancherCompose($rancherFileContent);
$stackName = $data->getBackup()->getStackName();
$newServiceName = $data->getNewServiceName();
$output->writeln("Starting $newServiceName.");
$this->rancherService->start( $this->getWorkDirectory(), $stackName);
$output->writeln("Waiting for $newServiceName to start.");
$this->rancherService->wait($stackName, $newServiceName, new SingleStateMatcher('active') );
$output->writeln("$newServiceName Started.");
}
|
php
|
{
"resource": ""
}
|
q240874
|
ContentBase.prepareI18nModels
|
train
|
public function prepareI18nModels()
{
$mI18n = $this->getJoined()->all();
$modelsI18n = [];
foreach ($mI18n as $modelI18n) {
$modelI18n->correctSelectedText();
$modelsI18n[$modelI18n->lang_code] = $modelI18n;
}
foreach ($this->languages as $langCode => $lang) {
if (empty($modelsI18n[$langCode])) {
$newI18n = $this->module->model(static::I18N_JOIN_MODEL);
$modelsI18n[$langCode] = $newI18n->loadDefaultValues();
$modelsI18n[$langCode]->lang_code = $langCode;
}
}
return $modelsI18n;
}
|
php
|
{
"resource": ""
}
|
q240875
|
Setting.errors
|
train
|
public function errors($field = null, $errors = null, $overwrite = false)
{
if (isset($this->_properties['scope'])) {
$this->_errors = [];
}
return parent::errors($field, $errors, $overwrite);
}
|
php
|
{
"resource": ""
}
|
q240876
|
RepositoryDispatcher.addRepository
|
train
|
public function addRepository(RepositoryInterface $repository)
{
if ($repository instanceof IssueRepository) {
$type = 'issue';
} else {
throw new \Exception('Unknown repository type.');
}
$this->repositories[$type] = $repository;
}
|
php
|
{
"resource": ""
}
|
q240877
|
Help.addArgument
|
train
|
public function addArgument($shortName = '', $fullName = '', $description = '', $hasValue = false, $isMandatory = false)
{
$argument = new \stdClass();
$argument->shortName = $shortName;
$argument->fullName = $fullName;
$argument->description = $description;
$argument->hasValue = (bool) $hasValue;
$argument->isMandatory = (bool) $isMandatory;
$this->arguments[] = $argument;
}
|
php
|
{
"resource": ""
}
|
q240878
|
EarthIT_CMIPREST_ResultAssembler_NOJResultAssembler._q45
|
train
|
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) {
$restObjects = array();
$keyByIds = $this->shouldKeyRestItemsById($rc);
foreach( $items as $item ) {
$restItem = $this->internalObjectToRest($rc, $item);
if( $keyByIds ) {
$restObjects[EarthIT_Storage_Util::itemId($item,$rc)] = $restItem;
} else {
$restObjects[] = $restItem;
}
}
return $this->jsonTyped($restObjects, $keyByIds ? EarthIT_JSON::JT_OBJECT : EarthIT_JSON::JT_LIST);
}
|
php
|
{
"resource": ""
}
|
q240879
|
ViewController.addAssets
|
train
|
protected function addAssets()
{
$this->assets = ViewService::getAssetManager();
$this->assets
->addCss(__DIR__ . '/../../assets/common/dist/common.css')
->addJs(__DIR__ . '/../../assets/common/dist/common.js')
->entry('teamelf/common/main');
}
|
php
|
{
"resource": ""
}
|
q240880
|
EntityManager.buildDataRequestQuery
|
train
|
public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode)
{
$queryBuilder->select($tableCode)
->from($entity, $tableCode);
$hasWhere = false;
$i = 1;
foreach ($dataRequest->getFilters() as $filter) {
$whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :p' . $i;
if ($hasWhere) {
$queryBuilder->andWhere($whereQuery);
} else {
$queryBuilder->where($whereQuery);
$hasWhere = true;
}
$queryBuilder->setParameter('p' . $i, $this->prepareValue($filter->getNeededValue(), $filter->getMode()));
$i++;
}
// Sorting
if ($dataRequest->hasSorting()) {
$mode = 'ASC';
if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) {
$mode = $dataRequest->getSortByDirection();
}
$queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode);
}
// Offset
if ($dataRequest->hasRange()) {
$queryBuilder->setFirstResult($dataRequest->getOffset());
$queryBuilder->setMaxResults($dataRequest->getNumberOfEntries());
}
}
|
php
|
{
"resource": ""
}
|
q240881
|
Server.run
|
train
|
public static function run($cwd = null, array $index = ['html', 'php'], $front = '/index.php')
{
if ($cwd === null) {
$cwd = getcwd();
}
$file = self::getFilePath($cwd, $index);
//The file does not exists
if ($file === false) {
return false;
}
//The file is the front controller
if (!empty($front) && ($file === $cwd.$front)) {
return false;
}
//The file can be served by the php server
if ($cwd === getcwd()) {
return true;
}
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
//The file is a php script that must be included
if ($ext === 'php') {
return $file;
}
//Output the file content
if (isset(self::$mimes[$ext])) {
$mime = self::$mimes[$ext];
} else {
$info = new finfo(FILEINFO_MIME);
$mime = $info->file($file);
}
header('Content-Type: '.$mime);
readfile($file);
exit;
}
|
php
|
{
"resource": ""
}
|
q240882
|
Server.getRequestPath
|
train
|
public static function getRequestPath()
{
if (empty($_SERVER['REQUEST_URI'])) {
return false;
}
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
return empty($path) ? $path : urldecode($path);
}
|
php
|
{
"resource": ""
}
|
q240883
|
Server.getFilePath
|
train
|
public static function getFilePath($cwd, array $index)
{
$path = self::getRequestPath();
if ($path === false) {
return false;
}
$file = $cwd.$path;
if (is_file($file)) {
return $file;
}
if (empty($index)) {
return false;
}
foreach ($index as $ext) {
$f = rtrim($file, '/').'/index.'.$ext;
if (is_file($f)) {
return $f;
}
}
return false;
}
|
php
|
{
"resource": ""
}
|
q240884
|
Dispatcher.handle
|
train
|
public function handle( \AltoRouter $router, \PowerOn\Network\Request $request ) {
$match = $router->match($request->path);
if ( $match ) {
$target = explode('#', $match['target']);
$this->controller = $target[0];
$this->action = key_exists(1, $target) ? $target[1] : 'index';
} else {
$url = $request->urlToArray();
$controller = array_shift($url);
$action = array_shift($url);
$this->controller = $controller ? $controller : 'index';
$this->action = $action ? $action : 'index';
}
$handler = $this->loadController();
if ( !$handler || !method_exists($handler, $this->action) ) {
throw new NotFoundException('El sitio al que intenta ingresar no existe.');
}
return $handler;
}
|
php
|
{
"resource": ""
}
|
q240885
|
Dispatcher.force
|
train
|
public function force($request_controller, $request_action = 'index') {
$this->controller = $request_controller;
$this->action = $request_action;
$handler = $this->loadController();
if ( !$handler ) {
throw new LogicException(sprintf('No se existe la clase del controlador (%s)', $this->controller));
}
if ( !method_exists($handler, $this->action) ) {
$reflection = new \ReflectionClass($handler);
throw new LogicException(sprintf('No existe el método (%s) del controlador (%s)',
$this->action, $reflection->getName()), ['controller' => $handler]);
}
return $handler;
}
|
php
|
{
"resource": ""
}
|
q240886
|
Dispatcher.loadController
|
train
|
private function loadController() {
$controller_name = Inflector::classify($this->controller) . 'Controller';
$controller_class = $this->controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $controller_name;
if ( !class_exists($controller_class) ) {
return FALSE;
}
return new $controller_class();
}
|
php
|
{
"resource": ""
}
|
q240887
|
Request.getParameter
|
train
|
public function getParameter($as = self::AS_STRING) {
if ($as == self::AS_SIMPLEXML) {
//convert to SimpleXMLElement
$success = simplexml_load_string($this->parameter);
if ($success === false) {
$error = libxml_get_last_error();
throw new \RuntimeException("XML Syntax error: " . $error->message);
}
return $success;
}
elseif ($as == self::AS_DOM) {
//convert to DOMDocument
$dom = new \DOMDocument();
if (!$dom->loadXML($this->parameter)) {
$error = libxml_get_last_error();
throw new \RuntimeException("XML Syntax error: " . $error->message);
}
return $dom;
}
return $this->parameter;
}
|
php
|
{
"resource": ""
}
|
q240888
|
HeaderOnReadyManager.makeAdd
|
train
|
public function makeAdd(){
if(OWEB_DEBUG > 0)
$code .= $this->makeAddNormal ();
else
$code .= $this->makeAddNormal ();
Headers::getInstance()->addHeader($code, Headers::jsCode);
}
|
php
|
{
"resource": ""
}
|
q240889
|
HeaderOnReadyManager.makeAddDebug
|
train
|
public function makeAddDebug(){
$s = "";
foreach ($this->headers as $code){
$s .= '$( document ).ready(function() {'."\n";
$s .= $code;
$s .= "\n});\n\n";
}
return $s;
}
|
php
|
{
"resource": ""
}
|
q240890
|
HeaderOnReadyManager.makeAddNormal
|
train
|
public function makeAddNormal(){
$s = "var oweb_ready = function (){";
foreach ($this->headers as $code)
$s .= $code."\n\n";
$s .= "}\n\n";
$s .= '$( document ).ready(function() {'."\n";
$s .= "oweb_ready(); \n";
$s .= "\n});\n\n";
return $s;
}
|
php
|
{
"resource": ""
}
|
q240891
|
PreCompileCommand.execute
|
train
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->validateCommand($input);
$output->writeln('> Loading configuration file');
$config = $input->getOption('config');
$files = (new ConfigResolver())->getFileList($config);
$output->writeLn('- Found '.count($files).' files');
$preloader = (new Factory())->create($this->getOptions($input));
$outputFile = $input->getOption('output');
$handle = $preloader->prepareOutput($outputFile, $input->getOption('strict_types'));
$output->writeln('> Compiling classes');
$count = 0;
$countSkipped = 0;
$comments = !$input->getOption('strip_comments');
foreach ($files as $file) {
$count++;
try {
$code = $preloader->getCode($file, $comments);
$output->writeln('- Writing '.$file);
fwrite($handle, $code."\n");
} catch (VisitorExceptionInterface $e) {
$countSkipped++;
$output->writeln('- Skipping '.$file);
}
}
fclose($handle);
$output->writeln("> Compiled loader written to $outputFile");
$output->writeln('- Files: '.($count - $countSkipped).'/'.$count.' (skipped: '.$countSkipped.')');
$output->writeln('- Filesize: '.(round(filesize($outputFile) / 1024)).' kb');
}
|
php
|
{
"resource": ""
}
|
q240892
|
PreCompileCommand.getOptions
|
train
|
protected function getOptions(InputInterface $input)
{
return [
'dir' => (bool) $input->getOption('fix_dir'),
'file' => (bool) $input->getOption('fix_file'),
'skip' => (bool) $input->getOption('skip_dir_file'),
'strict' => (bool) $input->getOption('strict_types'),
];
}
|
php
|
{
"resource": ""
}
|
q240893
|
AuthPanel.&
|
train
|
public function & getViewData () {
if ($this->view !== NULL) return $this->view;
$user = & \MvcCore\Ext\Auths\Basic::GetInstance()->GetUser();
$authenticated = $user instanceof \MvcCore\Ext\Auths\Basics\IUser;
$this->view = (object) [
'user' => $user,
'authenticated' => $authenticated,
];
return $this->view;
}
|
php
|
{
"resource": ""
}
|
q240894
|
Repository.find
|
train
|
public function find($find, $column = 'id', array $relations = [], array $columns = ['*'])
{
$this->model = $this->where($column, $find);
$this->model = $this->relation->apply($this->model, $this, $relations);
return $this->model->firstOrFail($columns);
}
|
php
|
{
"resource": ""
}
|
q240895
|
Repository.findWith
|
train
|
public function findWith($find, array $with = [], $column = 'id', array $columns = ['*'])
{
return $this->whereWith($find, $column, $with)->firstOrFail($columns);
}
|
php
|
{
"resource": ""
}
|
q240896
|
Repository.onlyFillable
|
train
|
public function onlyFillable(array $input)
{
$result = array_intersect_key($input, array_flip($this->modelInstance->getFillable()));
foreach ($this->avoidEmptyUpdate as $avoid) {
if (array_key_exists($avoid, $result) && empty($result[$avoid])) {
unset($result[$avoid]);
}
}
return $result;
}
|
php
|
{
"resource": ""
}
|
q240897
|
Repository.whereWith
|
train
|
protected function whereWith($find, $column, $with, $where_role = '=')
{
$this->where($column, $where_role, $find);
$this->with($with);
return $this->model;
}
|
php
|
{
"resource": ""
}
|
q240898
|
PathManager.get
|
train
|
public function get($type, $file = null)
{
if (!isset($this->paths[$type])) {
$method = 'get'.Utils::camelize($type).'Dir';
if (!method_exists($this, $method)) {
return null;
}
$this->set($type, $this->$method());
}
$path = $this->paths[$type];
if ($file) {
if ($path instanceof pathmanager\FallbackInterface) {
$path = $path->resolve($file);
} else {
$path .= '/' . ltrim($file, '/');
}
}
return $path;
}
|
php
|
{
"resource": ""
}
|
q240899
|
Lexer.isNextToken
|
train
|
public function isNextToken($token, $ignoreSpaces = true)
{
if($this->pos >= $this->len) {
return Tokens::T_END == $token;
}
switch($token) {
case Tokens::T_END:
return false;
case Tokens::T_OPERATOR:
return
$this->isNextToken(Tokens::T_LOGICAL_OP, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_COMPARISON_OP, $ignoreSpaces)
;
case Tokens::T_QUOTE:
return
$this->isNextToken(Tokens::T_SINGLE_QUOTE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_DOUBLE_QUOTE, $ignoreSpaces)
;
case Tokens::T_LOGICAL_OP:
return
$this->isNextToken(Tokens::T_AND, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_OR, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_NOT, $ignoreSpaces)
;
break;
case Tokens::T_COMPARISON_OP:
return
$this->isNextToken(Tokens::T_EQ, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_NE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_GT, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_GE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_LT, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_LE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IS_NULL, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IS_ANY, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_IN, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_RANGE, $ignoreSpaces) ||
$this->isNextToken(Tokens::T_MATCH, $ignoreSpaces)
;
break;
case Tokens::T_IDENTIFIER:
$pos = $this->pos;
if($ignoreSpaces) {
$pos = $this->getPosAfterSpaces($pos);
}
// if alphabet or '_' is following, then identifier.
return ctype_alpha($this->value[$pos]) || ('_' == $this->value[$pos]);
default:
$literal = $this->literals->getLiteralForToken($token);
if($this->literals->isSpace($literal)) {
$ignoreSpaces = false;
}
return $this->isNextLiteral($literal, $ignoreSpaces);
break;
}
}
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.