_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q3600
CNabuProviderFactory.getManager
train
public function getManager(string $vendor_key, string $module_key) { if (nb_isValidKey($vendor_key) && nb_isValidKey($module_key)) { return $this->nb_manager_list->getItem("$vendor_key:$module_key"); } else { throw new ENabuProviderException(ENabuProviderException::ERROR_INVALID_KEYS); } }
php
{ "resource": "" }
q3601
CNabuProviderFactory.addInterface
train
public function addInterface(CNabuProviderInterfaceDescriptor $nb_descriptor) { $interface_type = $nb_descriptor->getType(); if (!array_key_exists($interface_type, $this->nb_interface_list)) { throw new ENabuProviderException( ENabuProviderException::ERROR_INTERFACE_TYPE_NOT_EXISTS, array(print_r($interface_type, true)) ); } $retval = $this->nb_interface_list[$interface_type]->addItem($nb_descriptor); if ($retval === false) { throw new ENabuProviderException( ENabuProviderException::ERROR_INTERFACE_ALREADY_REGISTERED, array($nb_descriptor->getClassName()) ); } return $retval; }
php
{ "resource": "" }
q3602
CNabuProviderFactory.getInterfaceDescriptors
train
public function getInterfaceDescriptors(int $interface_type) { if (!array_key_exists($interface_type, $this->nb_interface_list)) { throw new ENabuProviderException( ENabuProviderException::ERROR_INTERFACE_TYPE_NOT_EXISTS, array(print_r($interface_type, true)) ); } return $this->nb_interface_list[$interface_type]; }
php
{ "resource": "" }
q3603
CNabuProviderFactory.getInterfaceDescriptor
train
public function getInterfaceDescriptor(string $vendor, string $module, int $interface_type, string $interface) { if (!array_key_exists($interface_type, $this->nb_interface_list)) { throw new ENabuProviderException( ENabuProviderException::ERROR_INTERFACE_TYPE_NOT_EXISTS, array(print_r($interface_type, true)) ); } $nb_descriptor = null; $this->nb_interface_list[$interface_type]->iterate( function ($key, $nb_interface_desc) use ($vendor, $module, $interface, &$nb_descriptor) { $retval = true; $nb_manager = $nb_interface_desc->getManager(); if ($nb_manager->getVendorKey() === $vendor && $nb_manager->getModuleKey() === $module && $nb_interface_desc->getClassName() === $interface ) { $nb_descriptor = $nb_interface_desc; $retval = false; } return $retval; } ); return $nb_descriptor; }
php
{ "resource": "" }
q3604
CNabuProviderFactory.registerApplication
train
public function registerApplication(INabuApplication $nb_application) { $this->nb_manager_list->iterate( function($key, $manager) use ($nb_application) { $manager->registerApplication($nb_application); return true; } ); }
php
{ "resource": "" }
q3605
ComparisonService.getComparison
train
public function getComparison($appId, $scanId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->comparisons() ->getComparison($appId, $scanId, $queryParams); return new ComparisonResponse($response); }
php
{ "resource": "" }
q3606
SinkHydrator.hydrateCollection
train
public static function hydrateCollection(array $sinks) { $hydrated = []; foreach ($sinks as $sink) { $hydrated[] = self::hydrate($sink); } return $hydrated; }
php
{ "resource": "" }
q3607
ValidatorService.getAll
train
public function getAll($appId, $profileId, array $queryParams) { $response = $this->api->applications()->profiles()->validators()->getAll($appId, $profileId, $queryParams); return new ValidatorsResponse($response); }
php
{ "resource": "" }
q3608
ValidatorService.getById
train
public function getById($appId, $profileId, $validatorId, array $queryParams = []) { $response = $this->api->applications()->profiles()->validators()->getById($appId, $profileId, $validatorId, $queryParams); return new ValidatorResponse($response); }
php
{ "resource": "" }
q3609
ValidatorService.create
train
public function create($appId, $profileId, ValidatorBuilder $input, array $queryParams = []) { $response = $this->api->applications()->profiles()->validators()->create($appId, $profileId, $input->toArray(), $queryParams); return new ValidatorResponse($response); }
php
{ "resource": "" }
q3610
CNabuSiteTargetMediotecaBase.setSiteTargetId
train
public function setSiteTargetId(int $nb_site_target_id) : CNabuDataObject { if ($nb_site_target_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_site_target_id") ); } $this->setValue('nb_site_target_id', $nb_site_target_id); return $this; }
php
{ "resource": "" }
q3611
CNabuHTTPApplication.init
train
protected function init() { $this->prepareHTTPManagers(); $this->prepareHTTPRendersManager(); $this->prepareMediotecasManager(); $this->nb_engine->registerApplication($this); }
php
{ "resource": "" }
q3612
CNabuHTTPApplication.run
train
final public function run() { $this->nb_http_server = $this->nb_engine->getHTTPServer(); if (!($this->nb_http_server instanceof INabuHTTPServerInterface)) { throw new ENabuCoreException(ENabuCoreException::ERROR_HTTP_SERVER_NOT_FOUND); } $this->prepareSecurityManager(); $this->preparePluginsManager(); $this->prepareModulesManager(); $this->nb_session = CNabuHTTPSession::getSession(); $this->nb_engine->traceLog("Cookies", $_COOKIE); // If the request is not allowed then treat it as a redirection or an error try { if ($this->prepareRequest()) { $method = $this->nb_request->getMethod(); $this->prepareCookies(); $this->prepareLocale(); if ($this->validateCORSOrigin()) { if ($method !== 'OPTIONS') { $this->prepareModules(); } if ($this->prepareResponse() && $this->processMethods() && $this->processCommands() ) { if ($method !== 'OPTIONS' && $method !== 'HEAD') { $this->buildResponse(); } else { $this->prepareHeaders(); } } } } else { nb_displayErrorPage($this->nb_response->getHTTPResponseCode()); } } catch (ENabuRedirectionException $re) { $this->nb_engine->traceLog("Redirection", "Via exception"); $this->prepareCookies(); $this->buildRedirection($re->getHTTPResponseCode(), $re->getLocation()); } return true; }
php
{ "resource": "" }
q3613
ProfileService.getAll
train
public function getAll($appId = null, array $queryParams = []) { $response = $this->api->applications()->profiles()->getAll($appId, $queryParams); return new ProfilesResponse($response); }
php
{ "resource": "" }
q3614
ProfileService.getById
train
public function getById($appId, $profileId, array $queryParams = []) { $response = $this->api->applications()->profiles()->getById($appId, $profileId, $queryParams); return new ProfileResponse($response); }
php
{ "resource": "" }
q3615
ProfileService.create
train
public function create($appId, ProfileBuilder $input, array $queryParams = []) { $response = $this->api->applications()->profiles()->create($appId, $input->toArray(), $queryParams); return new ProfileResponse($response); }
php
{ "resource": "" }
q3616
ProfileService.update
train
public function update($appId, $profileId, ProfileBuilder $input, array $queryParams = []) { $response = $this->api->applications()->profiles()->update($appId, $profileId, $input->toArray(), $queryParams); return new ProfileResponse($response); }
php
{ "resource": "" }
q3617
TNabuMessagingChild.getMessaging
train
public function getMessaging(CNabuCustomer $nb_customer = null, string $field = NABU_MESSAGING_FIELD_ID, bool $force = false) { if ($nb_customer !== null && ($this->nb_messaging === null || $force)) { $this->nb_messaging = null; if ($this instanceof CNabuDataObject && $this->contains(NABU_MESSAGING_FIELD_ID)) { $this->nb_messaging = $nb_customer->getMessaging($this); } } return $this->nb_messaging; }
php
{ "resource": "" }
q3618
UserService.getAll
train
public function getAll(array $queryParams = []) { $response = $this->api->users()->getAll($queryParams); return new UsersResponse($response); }
php
{ "resource": "" }
q3619
UserService.getById
train
public function getById($userId, array $queryParams = []) { $response = $this->api->users()->getById($userId, $queryParams); return new UserResponse($response); }
php
{ "resource": "" }
q3620
UserService.deleteAll
train
public function deleteAll(array $queryParams = []) { $response = $this->api->users()->deleteAll($queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3621
UserService.deleteById
train
public function deleteById($userId, array $queryParams = []) { $response = $this->api->users()->deleteById($userId, $queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3622
UserService.reset
train
public function reset($input, array $queryParams = []) { $response = $this->api->users()->reset($input->toArray(), $queryParams); return new UserResponse($response); }
php
{ "resource": "" }
q3623
UserService.activate
train
public function activate($userId, $token, array $queryParams = []) { $response = $this->api->users()->activate($userId, $token, $queryParams); return new UserResponse($response); }
php
{ "resource": "" }
q3624
ReviewService.getAll
train
public function getAll($appId, $scanId, $issueId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->issues() ->reviews() ->getAll($appId, $scanId, $issueId, $queryParams); return new ReviewsResponse($response); }
php
{ "resource": "" }
q3625
ReviewService.getById
train
public function getById($appId, $scanId, $issueId, $reviewId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->issues() ->reviews() ->getById($appId, $scanId, $issueId, $reviewId, $queryParams); return new ReviewResponse($response); }
php
{ "resource": "" }
q3626
ReviewService.create
train
public function create($appId, $scanId, $issueId, ReviewBuilder $input, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->issues() ->reviews() ->create($appId, $scanId, $issueId, $input->toArray(), $queryParams); return new ReviewResponse($response); }
php
{ "resource": "" }
q3627
PhpHydrator.hydrateCollection
train
public static function hydrateCollection(array $phps) { $hydrated = []; foreach ($phps as $php) { $hydrated[] = self::hydrate($php); } return $hydrated; }
php
{ "resource": "" }
q3628
PhpHydrator.hydrate
train
public static function hydrate(stdClass $php) { $hydrated = new PhpEntity(); if (isset($php->id)) { $hydrated->setId($php->id); } if (isset($php->major_version)) { $hydrated->setMajorVersion($php->major_version); } if (isset($php->minor_version)) { $hydrated->setMinorVersion($php->minor_version); } if (isset($php->release_version)) { $hydrated->setReleaseVersion($php->release_version); } if (isset($php->magic_quotes_gpc)) { $hydrated->setMagicQuotesGpc($php->magic_quotes_gpc); } if (isset($php->register_globals)) { $hydrated->setRegisterGlobals($php->register_globals); } if (isset($php->allow_url_fopen)) { $hydrated->setAllowUrlFopen($php->allow_url_fopen); } if (isset($php->allow_url_include)) { $hydrated->setAllowUrlInclude($php->allow_url_include); } if (isset($php->filter_default)) { $hydrated->setFilterDefault($php->filter_default); } if (isset($php->setting)) { $hydrated->setSetting(SettingHydrator::hydrate($php->setting)); } return $hydrated; }
php
{ "resource": "" }
q3629
Application.configure
train
public function configure($name) { if (isset($this->loadedConfigurations[$name])) { return; } $this->loadedConfigurations[$name] = true; $path = $this->getConfigurationPath($name); if (! \is_null($path)) { $this->make('config')->set(Arr::dot([ $name => require $path, ])); } }
php
{ "resource": "" }
q3630
Application.getProviders
train
public function getProviders($provider) { $name = \is_string($provider) ? $provider : \get_class($provider); return Arr::where($this->loadedProviders, function ($value) use ($name) { return $value instanceof $name; }); }
php
{ "resource": "" }
q3631
Application.resourcePath
train
public function resourcePath($path = '') { if ($this->resourcePath) { return $this->resourcePath.($path ? '/'.$path : $path); } return $this->basePath('resources'.($path ? '/'.$path : $path)); }
php
{ "resource": "" }
q3632
SourceHydrator.hydrateCollection
train
public static function hydrateCollection(array $sources) { $hydrated = []; foreach ($sources as $source) { $hydrated[] = self::hydrate($source); } return $hydrated; }
php
{ "resource": "" }
q3633
CNabuIContactProspectStatusType.getTypesForIContact
train
public static function getTypesForIContact($nb_icontact) { if (is_numeric($nb_icontact_id = nb_getMixedValue($nb_icontact, 'nb_icontact_id'))) { $retval = CNabuIContactProspectStatusType::buildObjectListFromSQL( 'nb_icontact_prospect_status_type_id', 'SELECT ipst.* FROM nb_icontact_prospect_status_type ipst, nb_icontact i WHERE ipst.nb_icontact_id=i.nb_icontact_id AND i.nb_icontact_id=%cont_id$d', array( 'cont_id' => $nb_icontact_id ), ($nb_icontact instanceof CNabuIContact ? $nb_icontact : null) ); if ($nb_icontact instanceof CNabuIContact) { $retval->iterate(function($key, CNabuIContactProspectStatusType $nb_status) use($nb_icontact) { $nb_status->setIContact($nb_icontact); return true; }); } } else { if ($nb_icontact instanceof CNabuIContact) { $retval = new CNabuIContactProspectStatusTypeList($nb_icontact); } else { $retval = new CNabuIContactProspectStatusTypeList(); } } return $retval; }
php
{ "resource": "" }
q3634
CNabuSiteRole.getSiteRolesForSite
train
public static function getSiteRolesForSite($nb_site) : CNabuSiteRoleList { if (is_numeric($nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID))) { $retval = CNabuSiteRole::buildObjectListFromSQL( 'nb_role_id', 'select * ' . 'from nb_site_role ' . 'where nb_site_id=%site_id$d', array( 'site_id' => $nb_site_id ) ); if ($nb_site instanceof CNabuSite) { $retval->iterate(function($key, CNabuSiteRole $nb_site_role) use ($nb_site) { $nb_site_role->setSite($nb_site); return true; }); } } else { $retval = new CNabuSiteRoleList(); } return $retval; }
php
{ "resource": "" }
q3635
CNabuMediotecaItemBase.getAllMediotecaItems
train
public static function getAllMediotecaItems(CNabuMedioteca $nb_medioteca) { $nb_medioteca_id = nb_getMixedValue($nb_medioteca, 'nb_medioteca_id'); if (is_numeric($nb_medioteca_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_medioteca_item_id', 'select * ' . 'from nb_medioteca_item ' . 'where nb_medioteca_id=%medioteca_id$d', array( 'medioteca_id' => $nb_medioteca_id ), $nb_medioteca ); } else { $retval = new CNabuMediotecaItemList(); } return $retval; }
php
{ "resource": "" }
q3636
CNabuSiteTargetCTA.getSiteTargetCTAs
train
static public function getSiteTargetCTAs($nb_site_target) { $nb_site_target_id = nb_getMixedValue($nb_site_target, 'nb_site_target_id'); if (is_numeric($nb_site_target_id)) { $retval = CNabuSiteTargetCTA::buildObjectListFromSQL( 'nb_site_target_cta_id', 'select * ' . 'from nb_site_target_cta ' . 'where nb_site_target_id=%target_id$d ' . 'order by nb_site_target_cta_order', array( 'target_id' => $nb_site_target_id ) ); if ($nb_site_target instanceof CNabuSiteTarget) { $retval->iterate(function($key, $nb_cta) use($nb_site_target) { $nb_cta->setSiteTarget($nb_site_target); return true; }); } } else { $retval = new CNabuSiteTargetCTAList(); } return $retval; }
php
{ "resource": "" }
q3637
CNabuSiteTargetCTA.getCTATarget
train
public function getCTATarget() { if (!($this->nb_site_target_destination instanceof CNabuSiteTarget) && $this->getTargetUseURI() === CNabuSiteTargetLink::USE_URI_TRANSLATED && is_numeric($this->getTargetId()) ) { $this->nb_site_target_destination = $this->nb_site_target->getSite()->getTarget($this->getTargetId()); } return $this->nb_site_target_destination; }
php
{ "resource": "" }
q3638
CNabuSiteTargetCTA.setCTATarget
train
public function setCTATarget(CNabuSiteTarget $nb_site_target = null) { if ($nb_site_target instanceof CNabuSiteTarget) { $this->setTargetUseURI(CNabuSiteTargetLink::USE_URI_TRANSLATED); $this->transferValue($nb_site_target, 'nb_site_target_id', 'nb_site_target_cta_target_id'); } else { $this->setTargetUseURI(CNabuSiteTargetLink::USE_URI_NONE); $this->setTargetId(null); } $this->nb_site_target_destination = $nb_site_target; return $this; }
php
{ "resource": "" }
q3639
CNabuSiteTargetCTA.addRole
train
public function addRole(CNabuSiteTargetCTARole $nb_role) { if ($nb_role->isValueNumeric(NABU_ROLE_FIELD_ID) || $nb_role->isValueGUID(NABU_ROLE_FIELD_ID)) { $nb_role->setSiteTargetCTA($this); $this->nb_site_target_cta_role_list->addItem($nb_role); } return $nb_role; }
php
{ "resource": "" }
q3640
CNabuSiteTargetCTA.getCTAOfSite
train
public static function getCTAOfSite($nb_site, $nb_site_target_cta) { $retval = null; if (is_numeric($nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID)) && is_numeric($nb_site_target_cta_id = nb_getMixedValue($nb_site_target_cta, NABU_SITE_TARGET_CTA_FIELD_ID)) ) { $retval = CNabuSiteTargetCTA::buildObjectFromSQL( 'select stc.* ' . 'from nb_site s, nb_site_target st, nb_site_target_cta stc ' . 'where s.nb_site_id=st.nb_site_id ' . 'and st.nb_site_target_id=stc.nb_site_target_id ' . 'and s.nb_site_id=%site_id$d ' . 'and stc.nb_site_target_cta_id=%cta_id$d', array( 'site_id' => $nb_site_id, 'cta_id' => $nb_site_target_cta_id ) ); } return $retval; }
php
{ "resource": "" }
q3641
SettingHydrator.hydrate
train
public static function hydrate(stdClass $setting) { $hydrated = new SettingEntity(); if (isset($setting->id)) { $hydrated->setId($setting->id); } if (isset($setting->issue_types)) { $hydrated->setIssueTypes($setting->issue_types); } if (isset($setting->code_stored)) { $hydrated->setCodeStored($setting->code_stored); } if (isset($setting->upload_removed)) { $hydrated->setUploadRemoved($setting->upload_removed); } if (isset($setting->full_code_compared)) { $hydrated->setFullCodeCompared($setting->full_code_compared); } if (isset($setting->history_inherited)) { $hydrated->setHistoryInherited($setting->history_inherited); } if (isset($setting->analysis_depth)) { $hydrated->setAnalysisDepth($setting->analysis_depth); } if (isset($setting->max_issues_per_type)) { $hydrated->setMaxIssuesPerType($setting->max_issues_per_type); } if (isset($setting->php)) { $hydrated->setPhp(PhpHydrator::hydrate($setting->php)); } if (isset($setting->java)) { $hydrated->setJava(JavaHydrator::hydrate($setting->java)); } return $hydrated; }
php
{ "resource": "" }
q3642
EntrypointService.getAll
train
public function getAll($appId, $scanId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->entrypoints() ->getAll($appId, $scanId, $queryParams); return new EntrypointsResponse($response); }
php
{ "resource": "" }
q3643
EntrypointService.getById
train
public function getById($appId, $scanId, $entrypointId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->entrypoints() ->getById($appId, $scanId, $entrypointId, $queryParams); return new EntrypointResponse($response); }
php
{ "resource": "" }
q3644
TaintHydrator.hydrateCollection
train
public static function hydrateCollection(array $taints) { $hydrated = []; foreach ($taints as $taint) { $hydrated[] = self::hydrate($taint); } return $hydrated; }
php
{ "resource": "" }
q3645
TaintHydrator.hydrate
train
public static function hydrate(stdClass $taint) { $hydrated = new TaintEntity(); if (isset($taint->id)) { $hydrated->setId($taint->id); } if (isset($taint->start_line)) { $hydrated->setStartLine($taint->start_line); } if (isset($taint->end_line)) { $hydrated->setEndLine($taint->end_line); } if (isset($taint->start_column)) { $hydrated->setStartColumn($taint->start_column); } if (isset($taint->end_column)) { $hydrated->setEndColumn($taint->end_column); } return $hydrated; }
php
{ "resource": "" }
q3646
CNabuCatalogLanguageBase.setCatalogId
train
public function setCatalogId(int $nb_catalog_id) : CNabuDataObject { if ($nb_catalog_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_catalog_id") ); } $this->setValue('nb_catalog_id', $nb_catalog_id); return $this; }
php
{ "resource": "" }
q3647
ConcatHydrator.hydrateCollection
train
public static function hydrateCollection(array $concats) { $hydrated = []; foreach ($concats as $concat) { $hydrated[] = self::hydrate($concat); } return $hydrated; }
php
{ "resource": "" }
q3648
ConcatHydrator.hydrate
train
public static function hydrate(stdClass $concat) { $hydrated = new ConcatEntity(); if (isset($concat->id)) { $hydrated->setId($concat->id); } if (isset($concat->line)) { $hydrated->setLine($concat->line); } if (isset($concat->start_line)) { $hydrated->setStartLine($concat->start_line); } if (isset($concat->end_line)) { $hydrated->setEndLine($concat->end_line); } if (isset($concat->file)) { $hydrated->setFile(FileHydrator::hydrate($concat->file)); } if (isset($concat->function)) { $hydrated->setFunction(CustomFunctionHydrator::hydrate($concat->function)); } if (isset($concat->class)) { $hydrated->setClass(CustomClassHydrator::hydrate($concat->class)); } if (isset($concat->start_column)) { $hydrated->setStartColumn($concat->start_column); } if (isset($concat->end_column)) { $hydrated->setEndColumn($concat->end_column); } if (isset($concat->taint)) { $hydrated->setTaint(TaintHydrator::hydrate($concat->taint)); } return $hydrated; }
php
{ "resource": "" }
q3649
ClientService.getAll
train
public function getAll(array $queryParams = []) { $response = $this->api->oauth2()->clients()->getAll($queryParams); return new ClientsResponse($response); }
php
{ "resource": "" }
q3650
ClientService.getById
train
public function getById($clientId, array $queryParams = []) { $response = $this->api->oauth2()->clients()->getById($clientId, $queryParams); return new ClientResponse($response); }
php
{ "resource": "" }
q3651
ClientService.create
train
public function create(ClientBuilder $input, array $queryParams = []) { $response = $this->api->oauth2()->clients()->create($input->toArray(), $queryParams); return new ClientResponse($response); }
php
{ "resource": "" }
q3652
ClientService.delete
train
public function delete($clientId, array $queryParams) { $response = $this->api->oauth2()->clients()->delete($clientId, $queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3653
Account.equals
train
public function equals(Account $account): bool { if ($this->name !== $account->name) { return false; } if (!$this->homePage->equals($account->homePage)) { return false; } return true; }
php
{ "resource": "" }
q3654
EditViewCompiler.addFields
train
private function addFields($modelData) { $fields = ''; $firstIteration = true; foreach ($modelData->fields as $field) { if ($firstIteration) { $fields .= self::getInputFor($field) . PHP_EOL; $firstIteration = false; } else { $fields .= $this->tab(2) . self::getInputFor($field) . PHP_EOL; } } $this->stub = str_replace('{{fields}}', $fields, $this->stub); return $this; }
php
{ "resource": "" }
q3655
EditViewCompiler.replacePrimaryKey
train
private function replacePrimaryKey($modelData) { $primaryKey = 'id'; foreach ($modelData->fields as $field) { if ($field->index == 'primary') { $primaryKey = $field->name; break; } } $this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub); return $this; }
php
{ "resource": "" }
q3656
CNabuHTTPModuleManagerAdapter.registerHTTPServerInterface
train
protected function registerHTTPServerInterface(INabuHTTPServerInterface $interface) : bool { $hash = $interface->getHash(); if (is_array($this->http_server_interface_list) && array_key_exists($hash, $this->http_server_interface_list)) { throw new ENabuHTTPException( ENabuHTTPException::ERROR_HTTP_SERVER_INSTANCE_ALREADY_REGISTERED, array(get_class($interface)) ); } if ($this->http_server_interface_list === null) { $this->http_server_interface_list = array($hash => $interface); } else { $this->http_server_interface_list[$hash] = $interface; } return $interface->init(); }
php
{ "resource": "" }
q3657
ClassFinder.getClassesFromNamespace
train
public function getClassesFromNamespace($namespace = null) { $namespace = $namespace ?: $this->getAppNamespace(); $path = $this->convertNamespaceToPath($namespace); return $this->finder->findClasses($path); }
php
{ "resource": "" }
q3658
ClassFinder.convertNamespaceToPath
train
protected function convertNamespaceToPath($namespace) { // strip app namespace $appNamespace = $this->getAppNamespace(); if (substr($namespace, 0, strlen($appNamespace)) != $appNamespace) { return null; } $subNamespace = substr($namespace, strlen($appNamespace)); // replace \ with / to get the correct file path $subPath = str_replace('\\', '/', $subNamespace); // create path return app('path') . '/' . $subPath; }
php
{ "resource": "" }
q3659
Generator.clean
train
public function clean() { if ($this->files->exists($this->path)) { $this->files->cleanDirectory($this->path); } }
php
{ "resource": "" }
q3660
Generator.getPrimaryKeyColumn
train
protected function getPrimaryKeyColumn($entityMetadata) { $primaryKey = 'id'; $incrementing = true; foreach ($entityMetadata['table']['columns'] as $column) { if ($column['primary']) { return $column; } } }
php
{ "resource": "" }
q3661
Generator.replaceTraits
train
protected function replaceTraits($entityMetadata, &$stub) { $traits = []; // versionable if (! empty($entityMetadata['versionTable'])) { $traits['versionable'] = 'use \ProAI\Versioning\Versionable;'; } // softDeletes if ($entityMetadata['softDeletes']) { $traits['softDeletes'] = 'use \ProAI\Versioning\SoftDeletes;'; } // autoUuid if ($this->hasAutoUuidColumn($entityMetadata)) { $traits['autoUuid'] = 'use \ProAI\Datamapper\Eloquent\AutoUuid;'; } $separator = PHP_EOL . PHP_EOL . ' '; $stub = str_replace('{{traits}}', implode($separator, $traits) . $separator, $stub); }
php
{ "resource": "" }
q3662
Generator.replaceVersionable
train
protected function replaceVersionable($versionTable, &$stub) { $option = (! empty($versionTable)) ? true : false; $stub = str_replace('{{versionable}}', (! empty($versionTable)) ? 'use \ProAI\Versioning\Versionable;' . PHP_EOL . PHP_EOL . ' ' : '', $stub); }
php
{ "resource": "" }
q3663
Generator.replaceAutoUuids
train
protected function replaceAutoUuids($entityMetadata, &$stub) { $autoUuids = []; foreach ($entityMetadata['table']['columns'] as $column) { if (! empty($column['options']['autoUuid'])) { $autoUuids[] = $column['name']; } } $stub = str_replace('{{autoUuids}}', $this->getArrayAsText($autoUuids), $stub); }
php
{ "resource": "" }
q3664
Generator.replaceVersioned
train
protected function replaceVersioned($versionTable, &$stub) { if (! $versionTable) { $stub = str_replace('{{versioned}}', $this->getArrayAsText([]), $stub); return; } $versioned = []; foreach ($versionTable['columns'] as $column) { if (! $column['primary'] || $column['name'] == 'version') { $versioned[] = $column['name']; } } $stub = str_replace('{{versioned}}', $this->getArrayAsText($versioned), $stub); }
php
{ "resource": "" }
q3665
Generator.replaceMapping
train
protected function replaceMapping($entityMetadata, &$stub) { $attributes = []; foreach ($entityMetadata['attributes'] as $attributeMetadata) { $attributes[$attributeMetadata['name']] = $attributeMetadata['columnName']; } $embeddeds = []; foreach ($entityMetadata['embeddeds'] as $embeddedMetadata) { $embedded = []; $embedded['class'] = $embeddedMetadata['class']; $embedded['columnPrefix'] = $embeddedMetadata['columnPrefix']; $embeddedAttributes = []; foreach ($embeddedMetadata['attributes'] as $attributeMetadata) { $embeddedAttributes[$attributeMetadata['name']] = $attributeMetadata['columnName']; } $embedded['attributes'] = $embeddedAttributes; $embeddeds[$embeddedMetadata['name']] = $embedded; } $relations = []; foreach ($entityMetadata['relations'] as $relationMetadata) { $relation = []; $relation['type'] = $relationMetadata['type']; if ($relation['type'] == 'belongsToMany' || $relation['type'] == 'morphToMany') { $relation['inverse'] = (! empty($relationMetadata['options']['inverse'])); } $relations[$relationMetadata['name']] = $relation; } $mapping = [ 'attributes' => $attributes, 'embeddeds' => $embeddeds, 'relations' => $relations, ]; $stub = str_replace('{{mapping}}', $this->getArrayAsText($mapping), $stub); }
php
{ "resource": "" }
q3666
Generator.replaceRelations
train
protected function replaceRelations($relations, &$stub) { $textRelations = []; foreach ($relations as $key => $relation) { $relationStub = $this->stubs['relation']; // generate options array $options = []; if ($relation['type'] != 'morphTo') { $options[] = "'" . get_mapped_model($relation['relatedEntity'], false)."'"; } foreach ($relation['options'] as $name => $option) { if ($option === null) { $options[] = 'null'; } elseif ($option === true) { $options[] = 'true'; } elseif ($option === false) { $options[] = 'false'; } else { if ($name == 'throughEntity') { $options[] = "'".get_mapped_model($option, false)."'"; } elseif ($name != 'morphableClasses') { $options[] = "'".$option."'"; } } } $options = implode(", ", $options); $relationStub = str_replace('{{name}}', $relation['name'], $relationStub); $relationStub = str_replace('{{options}}', $options, $relationStub); $relationStub = str_replace('{{ucfirst_type}}', ucfirst($relation['type']), $relationStub); $relationStub = str_replace('{{type}}', $relation['type'], $relationStub); $textRelations[] = $relationStub; if ($relation['type'] == 'morphTo' || ($relation['type'] == 'morphToMany' && ! $relation['options']['inverse'])) { $morphStub = $this->stubs['morph_extension']; $morphableClasses = []; foreach ($relation['options']['morphableClasses'] as $key => $name) { $morphableClasses[$key] = get_mapped_model($name, false); } $morphStub = str_replace('{{name}}', $relation['name'], $morphStub); $morphStub = str_replace('{{morphName}}', ucfirst($relation['options']['morphName']), $morphStub); $morphStub = str_replace('{{types}}', $this->getArrayAsText($morphableClasses, 2), $morphStub); $textRelations[] = $morphStub; } } $stub = str_replace('{{relations}}', implode(PHP_EOL . PHP_EOL, $textRelations), $stub); }
php
{ "resource": "" }
q3667
Generator.getArrayAsText
train
protected function getArrayAsText($array, $intendBy=1) { $intention = ''; for ($i=0; $i<$intendBy; $i++) { $intention .= ' '; } $text = var_export($array, true); $text = preg_replace('/[ ]{2}/', ' ', $text); $text = preg_replace("/\=\>[ \n ]+array[ ]+\(/", '=> array(', $text); return $text = preg_replace("/\n/", "\n".$intention, $text); }
php
{ "resource": "" }
q3668
TNabuProjectChild.getProject
train
public function getProject(CNabuCustomer $nb_customer = null, $force = false) { if ($nb_customer !== null && ($this->nb_project === null || $force)) { $this->nb_project = null; if ($this instanceof CNabuDataObject && $this->contains(NABU_PROJECT_FIELD_ID)) { $this->nb_project = $nb_customer->getProject($this); } } return $this->nb_project; }
php
{ "resource": "" }
q3669
TNabuProjectChild.setProject
train
public function setProject(CNabuProject $nb_project, $field = NABU_PROJECT_FIELD_ID) { $this->nb_project = $nb_project; if ($this instanceof CNabuDataObject) { $this->transferValue($nb_project, NABU_PROJECT_FIELD_ID, $field); } return $this; }
php
{ "resource": "" }
q3670
SourceService.getAll
train
public function getAll($appId, $profileId, array $queryParams) { $response = $this->api->applications()->profiles()->sources()->getAll($appId, $profileId, $queryParams); return new SourcesResponse($response); }
php
{ "resource": "" }
q3671
SourceService.getById
train
public function getById($appId, $profileId, $sourceId, array $queryParams = []) { $response = $this->api->applications()->profiles()->sources()->getById($appId, $profileId, $sourceId, $queryParams); return new SourceResponse($response); }
php
{ "resource": "" }
q3672
SourceService.create
train
public function create($appId, $profileId, SourceBuilder $input, array $queryParams = []) { $response = $this->api->applications()->profiles()->sources()->create($appId, $profileId, $input->toArray(), $queryParams); return new SourceResponse($response); }
php
{ "resource": "" }
q3673
CNabuSiteModuleBase.setErrorReporting
train
public function setErrorReporting(int $error_reporting = 0) : CNabuDataObject { if ($error_reporting === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$error_reporting") ); } $this->setValue('nb_site_module_error_reporting', $error_reporting); return $this; }
php
{ "resource": "" }
q3674
CNabuSiteModuleBase.setDebugging
train
public function setDebugging(string $debugging = "F") : CNabuDataObject { if ($debugging === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$debugging") ); } $this->setValue('nb_site_module_debugging', $debugging); return $this; }
php
{ "resource": "" }
q3675
AbstractCompiler.replaceClassName
train
protected function replaceClassName($modelName) { $this->stub = str_replace('{{class_name}}', $modelName, $this->stub); $this->stub = str_replace('{{class_name_lw}}', strtolower($modelName), $this->stub); return $this; }
php
{ "resource": "" }
q3676
AbstractCompiler.replaceNamespace
train
protected function replaceNamespace(stdClass $scaffolderConfig) { $this->stub = str_replace('{{namespace}}', $scaffolderConfig->namespaces->models, $this->stub); return $this; }
php
{ "resource": "" }
q3677
CNabuRole.getRolesForSite
train
static public function getRolesForSite($nb_site) : CNabuRoleList { $nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID); if (is_numeric($nb_site_id)) { $retval = self::buildObjectListFromSQL( 'nb_role_id', 'select r.* ' . 'from nb_role r, nb_site_role sr, nb_site s ' . 'where r.nb_role_id=sr.nb_role_id ' . 'and sr.nb_site_id=s.nb_site_id ' . 'and s.nb_site_id=%site_id$d', array( 'site_id' => $nb_site_id ), ($nb_site instanceof CNabuSite ? $nb_site : null) ); } else { $retval = new CNabuRoleList(); } return $retval; }
php
{ "resource": "" }
q3678
Text.setText
train
public function setText($text) { if ( ! is_string($text)) { throw new \InvalidArgumentException( __METHOD__."() expects parameter one, text, to be a string" ); } $this->text = $text; return $this; }
php
{ "resource": "" }
q3679
Text.getMaxChunks
train
public function getMaxChunks() { return ceil(mb_strlen((string) $this->text, $this->encoding) / $this->size); }
php
{ "resource": "" }
q3680
Text.getChunk
train
protected function getChunk($offset) { if ( ! is_numeric($offset) || ! is_int(+$offset) || $offset < 0) { throw new \InvalidArgumentException( __METHOD__."() expects parameter one, offset, to be a positive " . "integer or zero" ); } $chunk = false; $text = (string) $this->text; if ($offset < mb_strlen($text)) { $chunk = mb_substr($text, $offset, $this->size, $this->encoding); } return $chunk; }
php
{ "resource": "" }
q3681
ModelCompiler.replaceNamespaceModelExtend
train
private function replaceNamespaceModelExtend(stdClass $scaffolderConfig) { $this->stub = str_replace('{{namespace_model_extend}}', $scaffolderConfig->inheritance->model, $this->stub); return $this; }
php
{ "resource": "" }
q3682
CNabuMediotecaTypeLanguageBase.setMediotecaTypeId
train
public function setMediotecaTypeId(int $nb_medioteca_type_id) : CNabuDataObject { if ($nb_medioteca_type_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_medioteca_type_id") ); } $this->setValue('nb_medioteca_type_id', $nb_medioteca_type_id); return $this; }
php
{ "resource": "" }
q3683
Score.equals
train
public function equals(Score $score): bool { if (null !== $this->scaled xor null !== $score->scaled) { return false; } if ((float) $this->scaled !== (float) $score->scaled) { return false; } if (null !== $this->raw xor null !== $score->raw) { return false; } if ((float) $this->raw !== (float) $score->raw) { return false; } if (null !== $this->min xor null !== $score->min) { return false; } if ((float) $this->min !== (float) $score->min) { return false; } if (null !== $this->max xor null !== $score->max) { return false; } if ((float) $this->max !== (float) $score->max) { return false; } return true; }
php
{ "resource": "" }
q3684
EmailService.renderEmailBody
train
public function renderEmailBody(string $templateName, string $templatePackage, string $format, array $variables, bool $emogrify = true): string { $standaloneView = new StandaloneView(); $request = $standaloneView->getRequest(); // $request->setControllerPackageKey('Sandstorm.Maklerapp'); TODO needed? $request->setFormat($format); $templatePath = sprintf('resource://%s/Private/EmailTemplates/', $templatePackage); $templatePathAndFilename = sprintf('%s%s.%s', $templatePath, $templateName, $format); $standaloneView->setTemplatePathAndFilename($templatePathAndFilename); $standaloneView->setLayoutRootPath($templatePath . 'Layouts'); $standaloneView->setPartialRootPath($templatePath . 'Partials'); $standaloneView->assignMultiple($variables); $emailBody = $standaloneView->render(); // Emogrify - this will inline any styles in the HTML for proper display in Gmail. $emogrifiedFormats = ['htm', 'html']; if ($emogrify && in_array($format, $emogrifiedFormats)) { $emogrifier = new Emogrifier($emailBody); $emailBody = $emogrifier->emogrify(); } return $emailBody; }
php
{ "resource": "" }
q3685
EmailService.sendMail
train
protected function sendMail(Message $mail): bool { $allRecipients = $mail->getTo() + $mail->getCc() + $mail->getBcc(); $totalNumberOfRecipients = count($allRecipients); $actualNumberOfRecipients = 0; $exceptionMessage = ''; try { $actualNumberOfRecipients = $mail->send(); } catch (\Exception $e) { $exceptionMessage = $e->getMessage(); if ($this->logSendingErrors === self::LOG_LEVEL_LOG) { $this->systemLogger->logException($e); } elseif ($this->logSendingErrors === self::LOG_LEVEL_THROW) { throw $e; } } $emailInfo = [ 'recipients' => array_keys($mail->getTo() + $mail->getCc() + $mail->getBcc()), 'failedRecipients' => $mail->getFailedRecipients(), 'subject' => $mail->getSubject(), 'id' => (string)$mail->getHeaders()->get('Message-ID') ]; if (strlen($exceptionMessage) > 0) { $emailInfo['exception'] = $exceptionMessage; } if ($actualNumberOfRecipients < $totalNumberOfRecipients && $this->logSendingErrors === self::LOG_LEVEL_LOG) { $this->systemLogger->log( sprintf('Could not send an email to all given recipients. Given %s, sent to %s', $totalNumberOfRecipients, $actualNumberOfRecipients), LOG_ERR, $emailInfo); return false; } if ($this->logSendingSuccess === self::LOG_LEVEL_LOG) { $this->systemLogger->log('Email sent successfully.', LOG_INFO, $emailInfo); } return true; }
php
{ "resource": "" }
q3686
ConcatService.getAll
train
public function getAll($appId, $scanId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->concats() ->getAll($appId, $scanId, $queryParams); return new ConcatsResponse($response); }
php
{ "resource": "" }
q3687
ConcatService.getById
train
public function getById($appId, $scanId, $concatId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->concats() ->getById($appId, $scanId, $concatId, $queryParams); return new ConcatResponse($response); }
php
{ "resource": "" }
q3688
ValidatorHydrator.hydrateCollection
train
public static function hydrateCollection(array $validators) { $hydrated = []; foreach ($validators as $validator) { $hydrated[] = self::hydrate($validator); } return $hydrated; }
php
{ "resource": "" }
q3689
ValidatorHydrator.hydrate
train
public static function hydrate(stdClass $validator) { $hydrated = new ValidatorEntity(); if (isset($validator->id)) { $hydrated->setId($validator->id); } if (isset($validator->class)) { $hydrated->setClass($validator->class); } if (isset($validator->method)) { $hydrated->setMethod($validator->method); } if (isset($validator->parameter)) { $hydrated->setParameter($validator->parameter); } if (isset($validator->characters)) { $hydrated->setCharacters($validator->characters); } if (isset($validator->issueType)) { $hydrated->setIssueType(TypeHydrator::hydrate($validator->issueType)); } return $hydrated; }
php
{ "resource": "" }
q3690
CNabuMediotecaTypeBase.findByKey
train
public static function findByKey($nb_customer, $key) { $nb_customer_id = nb_getMixedValue($nb_customer, 'nb_customer_id'); if (is_numeric($nb_customer_id)) { $retval = CNabuMediotecaType::buildObjectFromSQL( 'select * ' . 'from nb_medioteca_type ' . 'where nb_customer_id=%cust_id$d ' . "and nb_medioteca_type_key='%key\$s'", array( 'cust_id' => $nb_customer_id, 'key' => $key ) ); } else { $retval = null; } return $retval; }
php
{ "resource": "" }
q3691
CNabuMediotecaTypeBase.getAllMediotecaTypes
train
public static function getAllMediotecaTypes(CNabuCustomer $nb_customer) { $nb_customer_id = nb_getMixedValue($nb_customer, 'nb_customer_id'); if (is_numeric($nb_customer_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_medioteca_type_id', 'select * ' . 'from nb_medioteca_type ' . 'where nb_customer_id=%cust_id$d', array( 'cust_id' => $nb_customer_id ), $nb_customer ); } else { $retval = new CNabuMediotecaTypeList(); } return $retval; }
php
{ "resource": "" }
q3692
CNabuMediotecaTypeBase.getFilteredMediotecaTypeList
train
public static function getFilteredMediotecaTypeList($nb_customer, $q = null, $fields = null, $order = null, $offset = 0, $num_items = 0) { $nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID); if (is_numeric($nb_customer_id)) { $fields_part = nb_prefixFieldList(CNabuMediotecaTypeBase::getStorageName(), $fields, false, true, '`'); $order_part = nb_prefixFieldList(CNabuMediotecaTypeBase::getStorageName(), $fields, false, false, '`'); if ($num_items !== 0) { $limit_part = ($offset > 0 ? $offset . ', ' : '') . $num_items; } else { $limit_part = false; } $nb_item_list = CNabuEngine::getEngine()->getMainDB()->getQueryAsArray( "select " . ($fields_part ? $fields_part . ' ' : '* ') . 'from nb_medioteca_type ' . 'where ' . NABU_CUSTOMER_FIELD_ID . '=%cust_id$d ' . ($order_part ? "order by $order_part " : '') . ($limit_part ? "limit $limit_part" : ''), array( 'cust_id' => $nb_customer_id ) ); } else { $nb_item_list = null; } return $nb_item_list; }
php
{ "resource": "" }
q3693
SourceService.getAll
train
public function getAll(array $queryParams = []) { $response = $this->api->sources()->getAll($queryParams); return new SourcesResponse($response); }
php
{ "resource": "" }
q3694
AclService.getById
train
public function getById($appId, $aclId, array $queryParams = []) { $response = $this->api->applications()->acls()->getById($appId, $aclId, $queryParams); return new AclResponse($response); }
php
{ "resource": "" }
q3695
AclService.create
train
public function create($appId, AclBuilder $input, array $queryParams = []) { $response = $this->api->applications()->acls()->create($appId, $input->toArray(), $queryParams); return new AclResponse($response); }
php
{ "resource": "" }
q3696
AclService.update
train
public function update($appId, $aclId, AclBuilder $input, array $queryParams = []) { $response = $this->api->applications()->acls()->update($appId, $aclId, $input->toArray(), $queryParams); return new AclResponse($response); }
php
{ "resource": "" }
q3697
StatementsFilter.byVerb
train
public function byVerb(Verb $verb): self { $this->filter['verb'] = $verb->getId()->getValue(); return $this; }
php
{ "resource": "" }
q3698
StatementsFilter.byActivity
train
public function byActivity(Activity $activity): self { $this->filter['activity'] = $activity->getId()->getValue(); return $this; }
php
{ "resource": "" }
q3699
StatementsFilter.limit
train
public function limit(int $limit): self { if ($limit < 0) { throw new \InvalidArgumentException('Limit must be a non-negative integer'); } $this->filter['limit'] = $limit; return $this; }
php
{ "resource": "" }