_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q253300 | DeleteForm.setTarget | validation | public function setTarget($value)
{
if (in_array($value, $this->possibleTargets)) {
$this->_target = $value;
} else {
throw new Exception('Unknown deletion target ' . $value);
}
} | php | {
"resource": ""
} |
q253301 | DeleteForm.getTargetLabel | validation | public function getTargetLabel()
{
if (!isset($this->labels[$this->target])) {
return ['long' => 'unknown', 'short' => 'unknown'];
}
return $this->labels[$this->target];
} | php | {
"resource": ""
} |
q253302 | Permission.getPermissionMap | validation | public function getPermissionMap( $forRequestPath, $forRoutePath = "" ){
if(isset($this->loaded[$forRequestPath])){
return $this->loaded[$forRequestPath];
}
$database = $this->database;
//Get Permission Definitions
$permissionsSQLd = NULL;
if(!empty($forRoutePath) && ($forRoutePath <> $forRequestPath) ):
$permissionsSQLd = "OR {$database->quote($forRoutePath)} REGEXP p.permission_area_uri";
endif;
//Get Permission Definitions
$premissionsSQLc = "SELECT p.*, a.lft, a.rgt, a.authority_name,a.authority_parent_id FROM ?authority_permissions AS p LEFT JOIN ?authority AS a ON p.authority_id=a.authority_id WHERE {$database->quote($forRequestPath)} REGEXP p.permission_area_uri {$permissionsSQLd} ORDER BY a.lft ASC";
$permissionsSQL = $database->prepare( $premissionsSQLc );
$permissions = $permissionsSQL->execute()->fetchAll();
$this->loaded[$forRoutePath] = $permissions;
return $this->loaded[$forRoutePath];
} | php | {
"resource": ""
} |
q253303 | MigrateCommand.migrate | validation | protected function migrate(Module $module)
{
$path = str_replace(base_path(), '', (new Migrator($module))->getPath());
if ($this->option('subpath')) {
$path = $path . "/" . $this->option("subpath");
}
$this->call('migrate', [
'--path' => $path,
'--database' => $this->option('database'),
'--pretend' => $this->option('pretend'),
'--force' => $this->option('force'),
]);
if ($this->option('seed')) {
$this->call('component:seed', ['module' => $module->getName()]);
}
} | php | {
"resource": ""
} |
q253304 | WP_Post_Type_Util.can_save_post_meta | validation | public function can_save_post_meta( $post_id, $action, $nonce ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST[ $nonce ] ) && wp_verify_nonce( $_POST[ $nonce ], $action ) );
return ! ( $is_autosave || $is_revision ) && $is_valid_nonce;
} | php | {
"resource": ""
} |
q253305 | Session.setFlashBag | validation | public function setFlashBag($sName, $sValue)
{
if (!isset($_SESSION['flashbag'])) { $_SESSION['flashbag'] = array(); }
$_SESSION['flashbag'][$sName] = $sValue;
return $this;
} | php | {
"resource": ""
} |
q253306 | Session.destroy | validation | public function destroy()
{
session_start();
$_SESSION = array();
if (ini_get("session.use_cookies")) {
$aParams = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$aParams["path"], $aParams["domain"],
$aParams["secure"], $aParams["httponly"]
);
}
session_destroy();
} | php | {
"resource": ""
} |
q253307 | Client.invokeRpcCall | validation | public function invokeRpcCall($method, $arguments = [])
{
if (!is_null($this->namespace)) {
$method = $this->namespace . '.' . $method;
}
$body = XmlRpcBuilder::createRequest($method, $arguments);
$guzzle = new \GuzzleHttp\Client();
$this->getLogger()->info("sending request for $method to {$this->url}");
$this->getLogger()->debug(
"sending request for $method to {$this->url}, with parameters: " . print_r($arguments, true)
);
$response = $guzzle->post(
$this->url,
[
'body' => $body,
'headers' => [
'User-Agent' => 'Devedge\XmlRpc\Client/' .self::$version,
'Content-Type' => 'text/xml'
]
]
);
// if we have a fault, we will throw an exception
if ($response->xml()->fault->count() > 0) {
$this->logger->warning("serverside error occured, details: " . $response->getBody());
throw XmlRpcParser::parseFault($response->xml()->fault);
}
// responses always have only one param
return array_shift(XmlRpcParser::parseParams($response->xml()->params));
} | php | {
"resource": ""
} |
q253308 | Client.fetchProjects | validation | public function fetchProjects()
{
$response = $this->getResponse('get', 'v2/projects');
$projects = array();
if(is_array($response)) {
foreach($response as $data) {
$projects[] = $this->hydrator->hydrate(new Project(), $data);
}
}
return $projects;
} | php | {
"resource": ""
} |
q253309 | Client.fetchProject | validation | public function fetchProject(Project $project)
{
$response = $this->getResponse(
'get',
sprintf('v2/projects/%s', $project->getProjectKey())
);
return $this->hydrator->hydrate($project, $response);
} | php | {
"resource": ""
} |
q253310 | Client.updateProject | validation | public function updateProject(Project $project, $composerJson)
{
$response = $this->getResponse(
'post',
sprintf('v2/projects/%s', $project->getProjectKey()),
array(),
array('project_file' => $composerJson)
);
return $this->hydrator->hydrate($project, $response);
} | php | {
"resource": ""
} |
q253311 | Client.createProject | validation | public function createProject($composerJson)
{
$response = $this->getResponse('post', 'v2/projects', array(), array('upload' => $composerJson));
return $this->hydrator->hydrate(new Project(), $response);
} | php | {
"resource": ""
} |
q253312 | Scheme.getCfgParamsByRanks | validation | private function getCfgParamsByRanks()
{
/* aliases and tables */
$asParams = 'pbhcp';
$asRank = 'pbhr';
$tblParams = $this->resource->getTableName(CfgParam::ENTITY_NAME);
$tblRank = $this->resource->getTableName(Rank::ENTITY_NAME);
// FROM prxgt_bon_hyb_cfg_param pbhcp
$query = $this->conn->select();
$query->from([$asParams => $tblParams]);
// LEFT JOIN prxgt_bon_hyb_rank pbhr ON pbhcp.rank_id = pbhr.id
$on = "$asParams." . CfgParam::A_RANK_ID . "=$asRank." . Rank::A_ID;
$cols = [Rank::A_CODE];
$query->joinLeft([$asRank => $tblRank], $on, $cols);
// $sql = (string)$query;
$entries = $this->conn->fetchAll($query);
$result = [];
foreach ($entries as $entry) {
$rankCode = $entry[Rank::A_CODE];
$rankScheme = $entry[CfgParam::A_SCHEME];
$result[$rankCode][$rankScheme] = $entry;
}
return $result;
} | php | {
"resource": ""
} |
q253313 | Scheme.getForcedCustomersIds | validation | private function getForcedCustomersIds()
{
$mlmIds = array_keys($this->QUALIFIED_CUSTOMERS);
$where = '';
foreach ($mlmIds as $one) {
/* skip first iteration */
if (strlen($where) > 0) {
$where .= ' OR ';
}
$quoted = $this->conn->quote($one);
$where .= Customer::A_MLM_ID . "=\"$quoted\"";
}
$cols = [Customer::A_CUSTOMER_REF, Customer::A_MLM_ID];
$result = $this->daoGeneric->getEntities(Customer::ENTITY_NAME, $cols, $where);
return $result;
} | php | {
"resource": ""
} |
q253314 | Scheme.getForcedQualificationCustomers | validation | public function getForcedQualificationCustomers()
{
if (is_null($this->cacheForcedRanks)) {
/* get Customer IDs from DB to map ranks to Mage IDs instead of MLM IDs */
$custIds = $this->getForcedCustomersIds();
/* get all ranks with configuration parameters for all schemes */
$ranks = $this->getCfgParamsByRanks();
$this->cacheForcedRanks = [];
foreach ($custIds as $item) {
$custId = $item[Customer::A_CUSTOMER_REF];
$ref = $item[Customer::A_MLM_ID];
$rankCode = $this->QUALIFIED_CUSTOMERS[$ref][1];
$cfgParamsWithSchemes = $ranks[$rankCode];
$this->cacheForcedRanks[$custId] = $cfgParamsWithSchemes;
}
/* compose map from customer IDs for quick search */
$this->cacheForcedCustomerIds = array_keys($this->cacheForcedRanks);
}
return $this->cacheForcedRanks;
} | php | {
"resource": ""
} |
q253315 | ApiActionsChilds.childIndex | validation | public function childIndex(FilterRequest $filters, $id, $relation)
{
$id = $this->getRealId($id);
$resource = $this->repository->getChilds($id, $relation, $filters);
if (! $resource || count($resource) < 1) {
// return $this->notFound();
}
return $this->success($resource);
} | php | {
"resource": ""
} |
q253316 | ApiActionsChilds.childShow | validation | public function childShow(FilterRequest $filters, $id, $idChild, $relation)
{
$id = $this->getRealId($id);
$idChild = $this->getRealId($idChild);
$resource = $this->repository->getChild($id, $relation, $idChild, $filters);
if (! $resource) {
// return $this->notFound();
}
return $this->success($resource);
} | php | {
"resource": ""
} |
q253317 | ApiActionsChilds.childStore | validation | public function childStore($idParent, FilterRequest $filters, $relation)
{
$idParent = $this->getRealId($idParent);
$resource = $this->repository->storeChild($idParent, $relation, $filters->all());
if (! $resource) {
// return $this->notFound();
}
return $this->success($resource);
} | php | {
"resource": ""
} |
q253318 | ApiActionsChilds.childStoreWithPivot | validation | public function childStoreWithPivot($idParent, $request, $relation)
{
$idParent = $this->getRealId($idParent);
$resource = $this->repository->storeChildAndPivot($idParent, $relation, $request->all());
if (! $resource) {
// return $this->notFound();
}
return $this->success($resource);
} | php | {
"resource": ""
} |
q253319 | ApiActionsChilds.childAssociate | validation | public function childAssociate($request, $idParent, $idChild, $relation)
{
$request->request->merge([
'url' => $request->request->path()
]);
$idParent = $this->getRealId($idParent);
$idChild = $this->getRealId($idChild);
$resourceChild = $this->repository->attach($idParent, $idChild, $relation, $request->all());
if (! $resourceChild) {
// return $this->notFound();
}
return $this->success([
$resourceChild
]);
} | php | {
"resource": ""
} |
q253320 | ApiActionsChilds.childDissociate | validation | public function childDissociate($request, $idParent, $idChild, $relation)
{
$idParent = $this->getRealId($idParent);
$idChild = $this->getRealId($idChild);
if (! $this->repository->detach($idParent, $idChild, $relation)) {
// return $this->notFound();
}
return $this->success([]);
} | php | {
"resource": ""
} |
q253321 | ApiActionsChilds.updateChild | validation | public function updateChild($idParent, FilterRequest $filters, $idChild, $relation)
{
$idParent = $this->getRealId($idParent);
$idChild = $this->getRealId($idChild);
$resource = $this->repository->updateChild($idParent, $relation, $idChild, $filters->all());
if (! $resource) {
// return $this->notFound();
}
return $this->success($resource);
} | php | {
"resource": ""
} |
q253322 | ApiActionsChilds.deleteChild | validation | public function deleteChild($idParent, FilterRequest $filters, $idChild, $relation)
{
$idParent = $this->getRealId($idParent);
$idChild = $this->getRealId($idChild);
$resource = $this->repository->deleteChild($idParent, $relation, $idChild);
if ($resource == null) {
// return $this->notFound();
}
return $this->success();
} | php | {
"resource": ""
} |
q253323 | Content.getMedia | validation | public function getMedia($objectType = 'media', $objectURI = NULL, $objectId = NULL) {
//An alias method for getall
return $this->getAllMedia($objectType, $objectURI, $objectId);
} | php | {
"resource": ""
} |
q253324 | Content.getAllMedia | validation | public function getAllMedia($objectType = 'media', $objectURI = NULL, $objectId = NULL) {
//Get the object list of items which have no target for the timeline;
//The timeline is for root objects only, any item with a target is the result of an interaction
//For instance blah commented on itemtarget etc... and should be shown on a seperate activity feed
$objects = $this->getMediaObjectsList($objectType, $objectURI, $objectId)->fetchAll();
$items = array();
//Parse the mediacollections;
foreach ($objects as $i=>$object) {
$object = $this->getOwner($object, $object['media_owner']);
//If object is an attachment ?
if($object['object_type']==="attachment"):
$object['media_object'] = $object['object_uri']; //add to the collection
if(empty($object['media_title'])):
$object['media_title'] = $object['attachment_name'];
endif;
endif;
$object['media_comment_target'] = $object['object_uri'];
$object['media_published'] = $object['object_created_on'];
//CleanUp
// foreach ($object as $key => $value):
// $object[str_replace(array('media_', 'object_'), '', $key)] = $value;
// unset($object[$key]);
// endforeach;
$items[] = $object;
}
//print_r($items);
$mediacollections = new Collection();
$mediacollections::set("items", $items); //update the collection
$mediacollections::set("totalItems", count($items));
$collection = $mediacollections::getArray();
return $collection;
} | php | {
"resource": ""
} |
q253325 | Content.getObject | validation | public function getObject( Entity $subject ) {
//1. getActor
//Media Object;;
//First get the nature of the media object;
// if(!is_object($subject)&& !is_a($subject, Entity::class)):
// $subjectEntity = Platform\Entity::getInstance(); //An empty entity here because it is impossible to guess the properties of this object
// $subject = $subjectEntity->loadObjectByURI($subject, array()); //Then we load the object
// endif;
$object = NULL;
$mediaObjectURI = $subject->getObjectURI();
if (!empty($mediaObjectURI)):
//Create an media object, and fire an event asking callbacks to complete the media object
$mediaSubject = new Object();
$mediaObjectType = $subject->getObjectType();
//Fire the event, passing the mediaSubject by reference
//Although it looks stupid to need to find out the nature of the media subject before trigger
//It actually provides an extra exclusion for callback so not all callbacks go to the database
//so for instance if we found an media subject was a collection, callbacks can first check if the
//trigger is to model a collection before diving ing
//\Library\Event::trigger("onMediaSubjectModel", $mediaSubject, $subject);
//You never know what callbacks will do to your subject so we just check
//that the media subject is what we think it is, i.e an media object
if (is_object($mediaSubject) && method_exists($mediaSubject, "getArray")):
$object = $mediaSubject::getArray(); //If it is then we can set the media object output vars
endif;
else:
//If there no explicitly defined mediaObjects, in media_object
//parse media_content for medialinks
//Parse media targets medialinks
//@todo;
// $mediaLinks = Media\MediaLink::parse($data);
endif;
return $object;
} | php | {
"resource": ""
} |
q253326 | Content.store | validation | public function store($objectURI = null)
{
//@TODO determine the user has permission to post;
$this->setPropertyValue("media_owner", $this->user->getPropertyValue("user_name_id"));
//Determine the target
if (!$this->saveObject($objectURI, $this->getObjectType())) {
//There is a problem! the error will be in $this->getError();
return false;
}
return true;
} | php | {
"resource": ""
} |
q253327 | Settings.save | validation | public function save() {
//do you have permission to execute admin
$this->checkPermission("special", "/admin");
$referer = $this->application->input->getReferer();
//$options = $this->application->createInstance( Options::class );
//Check that we have post data;
if (!$this->application->input->methodIs("post")) {
$this->response->addAlert("No configuration data recieved", 'error');
}else {
//Get the data;
if (($data = $this->application->input->getArray("options", array(), "post")) == FALSE) {
$this->response->addAlert("No input data recieved, Something went wrong", 'error');
}else{
$namespace = $this->application->input->getString("options_namespace", "", "post");
//print_R($data);
$this->application->config->mergeParams($namespace, $data);
if (!$this->application->config->saveParams()) {
$this->response->addAlert('Something went wrong, Did not save the parameters', 'error');
}else{
$this->response->addAlert("Your configuration settings have now been saved", "success");
}
}
}
//Report on state saved
$this->application->dispatcher->redirect($referer, HTTP_FOUND, null, $this->response->getAlerts());
return true;
} | php | {
"resource": ""
} |
q253328 | Container.create | validation | public static function create($validator, $command)
{
static $cache = [];
$cacheKey = $validator;
if (isset($cache[$cacheKey])) {
$class = $cache[$cacheKey]['class'];
$validator = $cache[$cacheKey]['validator'];
} else {
if (false === strpos($validator, '.')) {
// Not FQCN
$class = __NAMESPACE__ . '\\' . String::convertToCamelCase($validator);
} else {
// FQCN
$class = explode('.', $validator);
$class = array_map(array('In2pire\\Component\\Utility\\Text', 'convertToCamelCase'), $class);
$class = implode('\\', $class);
$validator = substr($validator, strrpos($validator, '.') + 1);
}
$cache[$cacheKey] = [
'class' => $class,
'validator' => $validator
];
}
if (!class_exists($class)) {
throw new \RuntimeException('Unknow validator ' . $cacheKey);
}
return new $class($command);
} | php | {
"resource": ""
} |
q253329 | ResponsePolicy.view | validation | public function view(UserPolicy $user, Response $response)
{
if ($user->canDo('forum.response.view') && $user->isAdmin()) {
return true;
}
return $response->user_id == user_id() && $response->user_type == user_type();
} | php | {
"resource": ""
} |
q253330 | ResponsePolicy.destroy | validation | public function destroy(UserPolicy $user, Response $response)
{
return $response->user_id == user_id() && $response->user_type == user_type();
} | php | {
"resource": ""
} |
q253331 | HttpService.then | validation | public function then(callable $success = null, callable $fail = null) {
if($this->success && is_callable($success)) {
return $success($this->request, $this->request->getStatusCode());
} elseif(is_callable($fail)) {
return $fail($this->error);
}
} | php | {
"resource": ""
} |
q253332 | HttpService.client | validation | public function client()
{
if(empty($this->authToken)) {
throw new NotFoundTokenException('Token not found');
}
//dd($this->microService);
$this->client = new Client([
'base_uri' => $this->microService,
'timeout' => $this->timeout,
'headers' => [
'Auth-Token' => $this->authToken
]
]);
return $this->client;
} | php | {
"resource": ""
} |
q253333 | TimestampedPathGenerator.generate | validation | public function generate($name, array $parameters=array(), $updateTrackerName='global', $referenceType = RouterInterface::ABSOLUTE_PATH, $timestampParameterName=null)
{
if (!$timestampParameterName) {
$timestampParameterName = $this->timestampParameterName;
}
$parameters[$timestampParameterName] = $this->updateManager->getLastUpdate($updateTrackerName)->format('U');
return $this->router->generate($name, $parameters, $referenceType);
} | php | {
"resource": ""
} |
q253334 | Utils.getDomainUrl | validation | public function getDomainUrl($address, $scheme = false)
{
$this->urlAddress->setAddress($address);
return $this->urlAddress->getDomain($scheme);
} | php | {
"resource": ""
} |
q253335 | Utils.getMd5Url | validation | public function getMd5Url($address, $scheme = true, $www = true)
{
$this->urlAddress->setAddress($address);
return $this->urlAddress->getMd5Address($scheme, $www);
} | php | {
"resource": ""
} |
q253336 | Utils.shortText | validation | public function shortText($text, $length)
{
$text = trim($text);
$charset = mb_detect_encoding($text);
if (mb_strlen($text, $charset) > $length) {
$text = mb_substr($text, 0, $length, $charset) . '...';
} else {
$text = $text;
}
return $text;
} | php | {
"resource": ""
} |
q253337 | Utils.generateSignCode | validation | public function generateSignCode(array $params, $secret)
{
ksort($params);
if (isset($params[self::SIGN_NAMESPACE])) {
unset($params[self::SIGN_NAMESPACE]);
}
return md5(implode('', $params) . $secret);
} | php | {
"resource": ""
} |
q253338 | Utils.checkSignCode | validation | public function checkSignCode(array $params, $secret)
{
if (false === isset($params[self::SIGN_NAMESPACE])) {
return false;
}
return $params[self::SIGN_NAMESPACE] === $this->generateSignCode($params, $secret);
} | php | {
"resource": ""
} |
q253339 | Utils.niceDate | validation | public function niceDate(\DateTime $date)
{
$now = $this->system->getDate();
if ($now->format('Y-m-d') === $date->format('Y-m-d')) {
return $date->format('H:i');
} elseif ($now->format('Y-m') === $date->format('Y-m') && $date->format('d') + 1 == $now->format('d')) {
return sprintf($this->translate('yesterday, %s'), $date->format('H:i'));
}
return $date->format('d-m-Y');
} | php | {
"resource": ""
} |
q253340 | Utils.priceNetto | validation | public function priceNetto($brutto, $tax)
{
$tax = round((double) $tax / 100.0, 2);
if ($tax < 0.00) {
throw new Exception(sprintf('Tax must be greater than or equal to 0, given %s.', $tax));
}
if ($tax === 0.00) {
return $brutto;
}
$result = $brutto / ($tax + 1);
return round($result, 2, PHP_ROUND_HALF_UP);
} | php | {
"resource": ""
} |
q253341 | Utils.priceBrutto | validation | public function priceBrutto($netto, $tax)
{
$tax = round((double) $tax / 100.0, 2);
if ($tax < 0.00) {
throw new Exception(sprintf('Tax must be greater than or equal to 0, given %s.', $tax));
}
if ($tax === 0.00) {
return $netto;
}
$result = $netto * ($tax + 1);
return round($result, 2, PHP_ROUND_HALF_UP);
} | php | {
"resource": ""
} |
q253342 | FileField.setAccept | validation | public function setAccept($accept){
$this->setTag('accept',$accept);
if($this->getValidator()){
$this->getValidator()->setOption('accept',$accept);
}
} | php | {
"resource": ""
} |
q253343 | FileField.setMaxSize | validation | public function setMaxSize($maxSize){
$serverMaxSize=$this->getServerMaxSize();
if($maxSize>$serverMaxSize){
throw new FileMaxSizeException($serverMaxSize);
}
$this->maxSize=$maxSize;
if($this->getValidator()){
$this->getValidator()->setOption('maxSize',$maxSize);
}
} | php | {
"resource": ""
} |
q253344 | FileField.phpSizeToBytes | validation | private function phpSizeToBytes($size){
if (is_numeric( $size)){
return $size;
}
$suffix = substr($size, -1);
$value = substr($size, 0, -1);
switch(strtolower($suffix)){
/** @noinspection PhpMissingBreakStatementInspection */
case 'p':
$value *= 1024;
/** @noinspection PhpMissingBreakStatementInspection */
case 't':
$value *= 1024;
/** @noinspection PhpMissingBreakStatementInspection */
case 'g':
$value *= 1024;
/** @noinspection PhpMissingBreakStatementInspection */
case 'm':
$value *= 1024;
case 'k':
$value *= 1024;
break;
}
return $value;
} | php | {
"resource": ""
} |
q253345 | CliApp.handleRequest | validation | public function handleRequest(): void
{
global $argv;
if (!is_array($argv) || empty($argv)) {
throw new Exception('Invalid value of the cli args array was given.');
}
(new CliCtrlResolver($argv))->run();
} | php | {
"resource": ""
} |
q253346 | ErrorDispatcher.exception | validation | public function exception(Exception $exception){
if($this->stopPropagation){
return false;
}
$this->fireHandlers($exception);
$this->stopPropagation=true;
return false;
} | php | {
"resource": ""
} |
q253347 | ErrorDispatcher.error | validation | public function error($level, $message, $file, $line){
throw new SyntaxException($message,$file,$line,$level);
} | php | {
"resource": ""
} |
q253348 | PageList.getPage | validation | public function getPage($name)
{
if (!isset($this->pages[$name])) {
throw new InvalidParameterException("Page not found");
}
return $this->pages[$name];
} | php | {
"resource": ""
} |
q253349 | PageList.changePageFromRequest | validation | public function changePageFromRequest($id, $request)
{
$this->getPage($id);
$page = $this->createPageObject(null, null, $request);
$this->pages[$id] = $page;
$this->persist();
return $page;
} | php | {
"resource": ""
} |
q253350 | PageList.renamePage | validation | public function renamePage($id, $newName)
{
$this->pages[$newName] = $this->getPage($id);
unset($this->pages[$id]);
$this->persist();
} | php | {
"resource": ""
} |
q253351 | PageList.deletePage | validation | public function deletePage($id)
{
$this->getPage($id);
unset($this->pages[$id]);
$this->persist();
} | php | {
"resource": ""
} |
q253352 | PageList.persist | validation | private function persist()
{
$bootstrap = Bootstrap::getInstance();
$config = $bootstrap->getConfiguration();
$config['pages'] = array();
foreach ($this->pages as $page) {
$page->appendConfig($config['pages']);
}
$bootstrap->setConfiguration($config);
} | php | {
"resource": ""
} |
q253353 | DataSource.getForeignDataModel | validation | public function getForeignDataModel($key)
{
$config = $this->settings['foreignPullParams'];
if (!isset($config['where'])) {
$config['where'] = [];
}
if (!empty($config['where'])) {
$config['where'] = ['and', $config['where'], [$this->foreignModel->primaryKey() => $key]];
} else {
$config['where'][$this->foreignModel->primaryKey()] = $key;
}
//var_dump($this->foreignModel->find($config)->count('*', $this->module->db));
return $this->foreignModel->findOne($config);
} | php | {
"resource": ""
} |
q253354 | DataSource.getUnmappedForeignKeys | validation | public function getUnmappedForeignKeys()
{
$mappedForeign = ArrayHelper::getColumn($this->_map, 'foreignKey');
$u = array_diff(array_keys($this->foreignModel->meta->schema->columns), $mappedForeign);
unset($u[$this->foreignPrimaryKeyName]);
return $u;
} | php | {
"resource": ""
} |
q253355 | DataSource.loadForeignDataItems | validation | protected function loadForeignDataItems()
{
$this->_foreignDataItems = [];
if ($this->lazyForeign) {
$primaryKeys = $this->foreignModel->findPrimaryKeys($this->settings['foreignPullParams']);
foreach ($primaryKeys as $primaryKey) {
$this->createForeignDataItem(null, ['foreignPrimaryKey' => $primaryKey]);
}
} else {
$foreignModels = $this->foreignModel->findAll($this->settings['foreignPullParams']);
foreach ($foreignModels as $key => $model) {
$this->createForeignDataItem($model, []);
}
}
} | php | {
"resource": ""
} |
q253356 | BaseException.getExceptionTree | validation | public static function getExceptionTree(\Throwable $Throwable){
$exception = get_class($Throwable);
// Build the "tree"
for($exception_tree[] = $exception; $exception =
get_parent_class($exception); $exception_tree[] = $exception){
;
}
$exception_tree = array_reverse($exception_tree);
if(count($exception_tree) > 1){
array_shift($exception_tree);
}
return $exception_tree;
} | php | {
"resource": ""
} |
q253357 | BaseException.getShortName | validation | public static function getShortName($fqn){
$fqn_parts = explode('\\', $fqn);
$final = array_pop($fqn_parts);
if(empty($fqn_parts)){
return $final;
}
$fqn_caps = preg_replace('/[a-z]+/', '', $fqn_parts);
return implode('\\', $fqn_caps) . '\\' . $final;
} | php | {
"resource": ""
} |
q253358 | BaseException.displayConsoleException | validation | public static function displayConsoleException(\Throwable $Throwable){
ob_start();
echo PHP_EOL . ' ';
echo(($Throwable instanceof PHPAssertionFailed) ?
'Assertion Failed' : 'Uncaught ' . self::getShortName(
get_class(
$Throwable
)
));
echo ' <' . basename($Throwable->getFile()) . ':' .
$Throwable->getLine() . '>';
echo PHP_EOL . PHP_EOL . ' ';
// Message
if($Throwable instanceof PHPAssertionFailed){
$message = $Throwable->getExpression();
if($message == ''){
$message = 'false';
}
}
else{
$message = $Throwable->getMessage();
}
echo wordwrap($message, self::CONSOLE_WIDTH - 2, PHP_EOL . ' ');
echo PHP_EOL . PHP_EOL . ' Stack Trace:' . PHP_EOL . PHP_EOL;
// Stack trace
if($Throwable instanceof BaseException ||
$Throwable instanceof PHPErrorException){
/** @noinspection PhpUndefinedMethodInspection */
$trace = $Throwable->getStackTrace();
}
else{
$trace = array_reverse($Throwable->getTrace());
}
$trace_empty = [
'class' => '',
'type' => '',
'function' => '',
'file' => '{unknown}',
'line' => 0
];
foreach($trace as $key => $trace_item){
$trace_item = array_merge($trace_empty, $trace_item);
$trace_item['file'] = basename($trace_item['file']);
if($trace_item['function'] != '{closure}'){
$trace_item['function'] .= '()';
}
$key++;
echo str_pad(" $key. ", 6, ' ');
echo self::getShortName($trace_item['class']) .
$trace_item['type'] .
$trace_item['function'];
echo " <{$trace_item['file']}:{$trace_item['line']}>" . PHP_EOL;
}
return ob_get_clean();
} | php | {
"resource": ""
} |
q253359 | Benri_Controller_Request_Http.getParam | validation | public function getParam($key, $default = null)
{
$param = parent::getParam($key, $default);
if (is_string($param)) {
return trim($param);
}
return $param;
} | php | {
"resource": ""
} |
q253360 | Phase1.getCustomersMap | validation | private function getCustomersMap()
{
/** @var \Praxigento\Downline\Repo\Data\Customer[] $customers */
$customers = $this->daoCustDwnl->get();
$result = $this->hlpTree->mapById($customers, ECustomer::A_CUSTOMER_REF);
return $result;
} | php | {
"resource": ""
} |
q253361 | RequestLastModifiedCache.onViewCreate | validation | public function onViewCreate(ContentfulViewEvent $e)
{
$viewMeta = $e->getView()->cfMeta;
$updated = $viewMeta['updatedAt'];
$this->itemIds[$viewMeta['itemId']] = true;
if ($this->lastModifiedContent === null) {
$this->lastModifiedContent = $updated;
} else {
if ($this->lastModifiedContent < $updated) {
$this->lastModifiedContent = $updated;
}
}
} | php | {
"resource": ""
} |
q253362 | RequestLastModifiedCache.getLastModified | validation | public function getLastModified(Request $request)
{
$minModified = $this->getLastMinModifiedDate();
$optionalLastModified = Option::fromValue($this->cache->fetch($this->getCacheKeyRequest(sha1($request->getUri()), 'lastmodified')), false);
if ($optionalLastModified->isEmpty()) {
return $minModified;
}
return max($minModified, new \DateTime($optionalLastModified->get()));
} | php | {
"resource": ""
} |
q253363 | RequestLastModifiedCache.setLastModified | validation | public function setLastModified(Request $request, \DateTime $lastModified)
{
$this->cache->save($this->getCacheKeyRequest(sha1($request->getUri()), 'lastmodified'), $lastModified->format('r'));
foreach ($this->itemIds as $itemId => $bool) {
$key = $this->getCacheKeyItem($itemId, 'uri');
$urisForItem = Option::fromValue($this->cache->fetch($key), false)->getOrElse(array());
$urisForItem[$request->getUri()] = $bool;
$this->cache->save($key, $urisForItem);
Option::fromValue($this->logger)->map(function (LoggerInterface $logger) use ($request, $itemId) {
$logger->debug(sprintf('[ContentfulBundle:RequestLastModifiedCache] "%s" is used on "%s".', $itemId, $request->getUri()));
});
}
} | php | {
"resource": ""
} |
q253364 | RequestLastModifiedCache.onEntryUpdate | validation | public function onEntryUpdate(ContentfulEntryEvent $e)
{
$entry = $e->getEntry();
$key = $this->getCacheKeyItem($entry->getId(), 'uri');
$urisForItemOption = Option::fromValue($this->cache->fetch($key), false);
if ($urisForItemOption->isEmpty()) {
Option::fromValue($this->logger)->map(function (LoggerInterface $logger) use ($entry) {
$logger->debug(sprintf('[ContentfulBundle:RequestLastModifiedCache] Entry "%s" is not used.', $entry->getId()));
});
return;
}
// Update
$urisForItem = $urisForItemOption->get();
foreach ($urisForItem as $uri => $bool) {
$key = $this->getCacheKeyRequest(sha1($uri), 'lastmodified');
$lastModified = $this->cache->fetch($key);
if ($lastModified >= $entry->getUpdatedAt()->format('r')) {
Option::fromValue($this->logger)->map(function (LoggerInterface $logger) use ($lastModified, $uri) {
$logger->debug(sprintf('[ContentfulBundle:RequestLastModifiedCache] "%s" was last modified at "%s". Entry is older.', $uri, $lastModified));
});
continue;
}
$this->cache->save($key, $entry->getUpdatedAt()->format('r'));
Option::fromValue($this->logger)->map(function (LoggerInterface $logger) use ($entry, $uri) {
$logger->debug(sprintf('[ContentfulBundle:RequestLastModifiedCache] Setting last modified time for "%s" to "%s".', $uri, $entry->getUpdatedAt()->format('r')));
});
}
} | php | {
"resource": ""
} |
q253365 | Site.getLanguages | validation | public function getLanguages()
{
$languages = array();
/** @var SiteAliasInterface $siteAlias */
foreach ($this->getAliases() as $siteAlias) {
$language = $siteAlias->getLanguage();
if (!in_array($language, $languages)) {
$languages[] = $language;
}
}
return $languages;
} | php | {
"resource": ""
} |
q253366 | Site.getAliasIdForLanguage | validation | public function getAliasIdForLanguage($language)
{
/** @var ReadSiteAliasInterface $alias */
foreach ($this->aliases as $key => $alias) {
if ($alias->getLanguage() == $language) {
return $key;
}
}
return null;
} | php | {
"resource": ""
} |
q253367 | Type.validate | validation | public function validate(string $sValue = null) : bool
{
if ($this->_sType == 'DateTime') {
if (preg_match('#^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}#', $sValue)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q253368 | CliTask.getSetting | validation | public function getSetting($name, $default = null)
{
return array_key_exists($name, $this->settings) ? $this->settings[$name] : $default;
} | php | {
"resource": ""
} |
q253369 | CliTask.run | validation | public function run(InputInterface $input, OutputInterface $output)
{
$this->returnCode = static::RETURN_SUCCESS;
$this->doPreRun($input, $output);
if (!$this->executeDependencies($input, $output)) {
// Failed to run dependencies.
$this->returnCode = static::RETURN_ERROR;
} else {
// Execute task.
$this->returnCode = (int) $this->execute($input, $output);
}
$this->doPostRun($input, $output, $this->returnCode);
return $this->returnCode;
} | php | {
"resource": ""
} |
q253370 | Task.failed | validation | public function failed($fail = true)
{
if (!func_num_args()) {
return $this->_failed;
}
$this->_failed = $fail;
return $this;
} | php | {
"resource": ""
} |
q253371 | Task.clear | validation | public function clear()
{
$this->_repeat = 1;
$this->_startTime = 0;
$this->_duration = 0;
$this->_average = 0;
$this->_rate = 0;
$this->_startMem = 0;
$this->_memory = 0;
} | php | {
"resource": ""
} |
q253372 | ErrorHandler.handle | validation | public function handle()
{
$view = $this->application->createInstance("view",
[
$this->application->response,
$this->application->createInstance("viewengine", [$this->application->response]),
$this->application
]
);
$view->setData("title", "An Error Occured");
//Lets just show a pretty error page for now
$this->application->response->send( $view->render("errors/error") );
//$this->response->send($this->view->render("errors/error"));
//Don't execute any more handlers
return Handler::LAST_HANDLER;
} | php | {
"resource": ""
} |
q253373 | Http.addParams | validation | static public function addParams($url, $params)
{
$query = parse_url($url, PHP_URL_QUERY);
$separator = (Text::isEmpty($query)? "?" : "&");
return Text::concat($separator, $url, http_build_query($params));
} | php | {
"resource": ""
} |
q253374 | SettingsServiceFactory.createService | validation | public function createService(ServiceLocatorInterface $serviceLocator)
{
$options = $serviceLocator->get('HtSettingsModule\Options\ModuleOptions');
$settingsService = new SettingsService(
$options,
$serviceLocator->get('HtSettingsModule_SettingsMapper'),
$serviceLocator->get('HtSettingsModule\Service\NamespaceHydratorProvider')
);
if ($options->getCacheOptions()->isEnabled()) {
$settingsService->setCacheManager($serviceLocator->get('HtSettingsModule\Service\CacheManager'));
}
return $settingsService;
} | php | {
"resource": ""
} |
q253375 | QuestionResourceController.index | validation | public function index(QuestionRequest $request)
{
$view = $this->response->theme->listView();
if ($this->response->typeIs('json')) {
$function = camel_case('get-' . $view);
return $this->repository
->setPresenter(\Litecms\Forum\Repositories\Presenter\QuestionPresenter::class)
->$function();
}
$user_id = user_id();
$questions = $this->repository->questions($user_id);
return $this->response->title(trans('forum::question.names'))
->view('forum::question.index', true)
->data(compact('questions', 'view'))
->output();
} | php | {
"resource": ""
} |
q253376 | QuestionResourceController.show | validation | public function show(QuestionRequest $request, Question $question)
{
if ($question->exists) {
$view = 'forum::question.show';
} else {
$view = 'forum::question.new';
}
return $this->response->title(trans('app.view') . ' ' . trans('forum::question.name'))
->data(compact('question'))
->view($view, true)
->output();
} | php | {
"resource": ""
} |
q253377 | QuestionResourceController.edit | validation | public function edit(QuestionRequest $request, Question $question)
{
return $this->response->title(trans('forum::question.name'))
->view('forum::public.question.newdiscussion')
->data(compact('question'))
->output();
} | php | {
"resource": ""
} |
q253378 | QuestionResourceController.update | validation | public function update(QuestionRequest $request, Question $question)
{
try {
$request = $request->all();
$attributes['title'] = $request['title'];
$attributes['question'] = $request['question'];
$attributes['category_id'] = $request['category_id'];
$question->update($attributes);
return redirect('/discussion/'.$request['slug']);
} catch (Exception $e) {
return $this->response->message($e->getMessage())
->code(400)
->status('error')
->url(guard_url('forum/question/' . $question->getRouteKey()))
->redirect();
}
} | php | {
"resource": ""
} |
q253379 | QuestionResourceController.destroy | validation | public function destroy(QuestionRequest $request, Question $question)
{
try {
$question->delete();
return $this->response->message(trans('messages.success.deleted', ['Module' => trans('forum::question.name')]))
->code(202)
->status('success')
->url(guard_url('forum/question'))
->redirect();
} catch (Exception $e) {
return $this->response->message($e->getMessage())
->code(400)
->status('error')
->url(guard_url('forum/question/' . $question->getRouteKey()))
->redirect();
}
} | php | {
"resource": ""
} |
q253380 | CustomFieldsGroupRenderingTwig.renderWidget | validation | public function renderWidget(array $fields, $customFielsGroup, $documentType='html', array $params = array())
{
$resolvedParams = array_merge($this->defaultParams, $params);
return $this->container->get('templating')
->render($resolvedParams['layout'], array(
'cFGroup' => $customFielsGroup,
'cFData' => $fields,
'show_empty' => $resolvedParams['show_empty']));
} | php | {
"resource": ""
} |
q253381 | Flash.get | validation | public static function get($key, $fallback = null)
{
$message = static::provider()->get($key, $fallback);
static::provider()->drop($key);
return $message;
} | php | {
"resource": ""
} |
q253382 | ApiClient.SignupUser | validation | public function SignupUser($moniker, $mailer_id = null)
{
$endpoint = '/user/signup';
$postdata = array("moniker" => $moniker, "mailer_id" => $mailer_id);
return $this->executePostRequest($endpoint, $postdata);
} | php | {
"resource": ""
} |
q253383 | Auth.provider | validation | public static function provider(ProviderInterface $provider = null)
{
if($provider) {
static::$provider = $provider;
}
elseif(!static::$provider) {
static::$provider = new Provider\Native(static::$root);
}
return static::$provider;
} | php | {
"resource": ""
} |
q253384 | Auth.user | validation | public static function user()
{
if(!static::$user and static::$factory) {
$id = static::provider()->get('id');
static::$user = call_user_func(static::$factory, $id);
}
return static::$user;
} | php | {
"resource": ""
} |
q253385 | Auth.login | validation | public static function login($rank = 1, $id = null)
{
static::provider()->set('valid', true);
static::provider()->set('rank', $rank);
static::provider()->set('id', $id);
return static::user();
} | php | {
"resource": ""
} |
q253386 | Config.set | validation | public function set($name, $value = null) {
if ($value == null) {
return false;
}
$this->settings[$name] = $value;
} | php | {
"resource": ""
} |
q253387 | Config.get | validation | public function get($name) {
if ($this->exists($name)) {
$value = $this->settings[$name];
/*
* NO VA: Si el valor a devolver es una matriz se debe retornar una
* instancia de SubSettings para recorrer dicha matriz y asi
* sucesivamente hasta recorrer toda la configuracion.
*/
/*
* Idea si se quiere llamar a una configuracion que esta en una matriz
* dentro del settings.php
*
* podria haber dos opciones:
* 1.- con secciones:
* Settings::get($name, $section);
*
* 2.- con separaciones por punto:
* Settings::get('db.default.port');
*/
return $value;
}
return false;
} | php | {
"resource": ""
} |
q253388 | Errors.hasException | validation | public function hasException(\Exception $exception)
{
$class = get_class($exception);
$exceptions = $this->getExceptions();
return isset($exceptions[$class]);
} | php | {
"resource": ""
} |
q253389 | Errors.getExceptionCode | validation | public function getExceptionCode(\Exception $exception)
{
$class = get_class($exception);
$exceptions = $this->getExceptions();
if (!isset($exceptions[$class])) {
throw new \RuntimeException(sprintf(
'Not exist exception "%s" in storage.',
$class
));
}
return $exceptions[$class];
} | php | {
"resource": ""
} |
q253390 | Errors.getReservedCodes | validation | public function getReservedCodes()
{
$reserved = [];
/** @var ErrorFactoryInterface|string $factory */
foreach ($this->factories as $factoryClass => $factory) {
$reserved[$factoryClass] = $factory->getReservedDiapason();
}
return $reserved;
} | php | {
"resource": ""
} |
q253391 | Errors.checkReservedCodes | validation | public function checkReservedCodes()
{
$reserved = $this->getReservedCodes();
// First iterate: check all factory
foreach ($reserved as $factoryClass => $reservedForFactory) {
// Second iterate: check in each factory
foreach ($reserved as $checkInFactory => $reservedInCheckFactory) {
if ($checkInFactory == $factoryClass) {
continue;
}
if ($reservedInCheckFactory[0] >= $reservedForFactory[0] &&
$reservedInCheckFactory[0] <= $reservedForFactory[1]
) {
throw new \RuntimeException(sprintf(
'The reserved codes for factory "%s" [%d - %d] superimposed on "%s" factory [%d - %d].',
$checkInFactory,
$reservedInCheckFactory[0],
$reservedInCheckFactory[1],
$factoryClass,
$reservedForFactory[0],
$reservedForFactory[1]
));
}
if ($reservedInCheckFactory[1] >= $reservedForFactory[0] &&
$reservedInCheckFactory[1] <= $reservedForFactory[1]
) {
throw new \RuntimeException(sprintf(
'The reserved codes for factory "%s" [%d - %d] superimposed on "%s" factory [%d - %d].',
$checkInFactory,
$reservedInCheckFactory[0],
$reservedInCheckFactory[1],
$factoryClass,
$reservedForFactory[0],
$reservedForFactory[1]
));
}
}
}
} | php | {
"resource": ""
} |
q253392 | Module.getRelatedType | validation | public function getRelatedType($name)
{
list($relationship, $role) = $this->getRelationship($name);
if ($relationship) {
return $relationship->roleType($role);
}
return false;
} | php | {
"resource": ""
} |
q253393 | Module.setup | validation | public function setup()
{
$results = [true];
if (!empty($this->primaryModel) && !empty($this->collectorItem->parents)) {
$groups = ['top'];
foreach ($groups as $groupName) {
$group = Group::getBySystemName($groupName, false);
if (empty($group)) {
continue;
}
if ($this->inheritParentAccess) {
$results[] = $this->objectTypeModel->parentAccess(null, $group);
}
}
}
return min($results);
} | php | {
"resource": ""
} |
q253394 | Module.getPossibleRoles | validation | public function getPossibleRoles()
{
$roles = [];
foreach (Yii::$app->collectors['roles']->getAll() as $roleItem) {
$test = true;
switch ($roleItem->systemId) {
case 'owner':
$test = $this->isOwnable;
break;
}
if ($test) {
$roles[] = $roleItem->object->primaryKey;
}
}
return $roles;
} | php | {
"resource": ""
} |
q253395 | Module.getRequiredRoles | validation | public function getRequiredRoles()
{
$roles = [];
foreach (Yii::$app->collectors['roles']->getAll() as $roleItem) {
$test = false;
switch ($roleItem->systemId) {
case 'owner':
$test = $this->isOwnable;
break;
}
if ($test) {
$roles[] = $roleItem->object->primaryKey;
}
}
return $roles;
} | php | {
"resource": ""
} |
q253396 | Module.getInitialRole | validation | public function getInitialRole()
{
$roles = [];
foreach (Yii::$app->collectors['roles']->getAll() as $roleItem) {
$test = $roleItem->level < 400;
if ($test) {
$roles[] = $roleItem->object->primaryKey;
}
}
return $roles;
} | php | {
"resource": ""
} |
q253397 | Module.getOwner | validation | public function getOwner()
{
if (!$this->isOwnable) {
return;
}
$ownerObject = $this->getOwnerObject();
if (is_object($ownerObject)) {
return $ownerObject->primaryKey;
}
return $ownerObject;
} | php | {
"resource": ""
} |
q253398 | Module.getObjectTypeModel | validation | public function getObjectTypeModel()
{
if (!isset($this->_objectTypeModel) && isset(Yii::$app->collectors['types']->tableRegistry[$this->systemId])) {
$this->_objectTypeModel = Yii::$app->collectors['types']->tableRegistry[$this->systemId];
}
return $this->_objectTypeModel;
} | php | {
"resource": ""
} |
q253399 | Module.getObjectLevel | validation | public function getObjectLevel()
{
if ($this->isPrimaryType) {
return 1;
}
$parents = $this->collectorItem->parents;
if (!empty($parents)) {
$maxLevel = 1;
foreach ($parents as $rel) {
if (get_class($rel->parent) === get_class($this)) {
continue;
}
$newLevel = $rel->parent->objectLevel + 1;
if ($newLevel > $maxLevel) {
$maxLevel = $newLevel;
}
}
return $maxLevel;
}
return 1;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.