_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3 values | text stringlengths 83 13k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q3400 | CNabuSiteRoleBase.setLoginRedirectionTargetUseURI | train | public function setLoginRedirectionTargetUseURI($login_redirection_target_use_uri) : CNabuDataObject
{
if ($login_redirection_target_use_uri === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$login_redirection_target_use_uri")
);
}
$this->setValue('nb_site_role_login_redirection_target_use_uri', $login_redirection_target_use_uri);
return $this;
} | php | {
"resource": ""
} |
q3401 | CNabuSiteRoleBase.setPoliciesTargetUseURI | train | public function setPoliciesTargetUseURI($policies_target_use_uri) : CNabuDataObject
{
if ($policies_target_use_uri === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$policies_target_use_uri")
);
}
$this->setValue('nb_site_role_policies_target_use_uri', $policies_target_use_uri);
return $this;
} | php | {
"resource": ""
} |
q3402 | CNabuUserGroupLanguageBase.setUserGroupId | train | public function setUserGroupId(int $nb_user_group_id) : CNabuDataObject
{
if ($nb_user_group_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_user_group_id")
);
}
$this->setValue('nb_user_group_id', $nb_user_group_id);
return $this;
} | php | {
"resource": ""
} |
q3403 | CNabuUserGroupLanguageBase.setTitle | train | public function setTitle(string $title) : CNabuDataObject
{
if ($title === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$title")
);
}
$this->setValue('nb_user_group_lang_title', $title);
return $this;
} | php | {
"resource": ""
} |
q3404 | CNabuCommerceProduct.getProductsForCommerce | train | static public function getProductsForCommerce($nb_commerce)
{
$nb_commerce_id = nb_getMixedValue($nb_commerce, NABU_COMMERCE_FIELD_ID);
if (is_numeric($nb_commerce_id)) {
$retval = CNabuCommerceProduct::buildObjectListFromSQL(
'nb_commerce_product_id',
'SELECT *
FROM nb_commerce_product
WHERE nb_commerce_id=%commerce_id$d',
array(
'commerce_id' => $nb_commerce_id
)
);
if ($nb_commerce instanceof CNabuCommerce) {
$retval->setCommerce($nb_commerce);
}
} else {
$retval = new CNabuCommerceProductCategoryList($nb_commerce instanceof CNabuCommerce ? $nb_commerce : null);
}
return $retval;
} | php | {
"resource": ""
} |
q3405 | CNabuCommerceProduct.findBySKU | train | static public function findBySKU($nb_commerce, string $sku)
{
$retval = false;
$nb_commerce_id = nb_getMixedValue($nb_commerce, NABU_COMMERCE_FIELD_ID);
if (is_numeric($nb_commerce_id)) {
$retval = CNabuCommerceProduct::buildObjectFromSQL(
'SELECT *
from nb_commerce_product
where nb_commerce_id=%commerce_id$d
and nb_commerce_product_sku=\'%sku$s\'
',
array(
'commerce_id' => $nb_commerce_id,
'sku' => $sku
)
);
}
return $retval;
} | php | {
"resource": ""
} |
q3406 | CNabuUser.setEmail | train | public function setEmail(string $email) : CNabuDataObject
{
$value = parent::setEmail(strtolower($email));
return $value;
} | php | {
"resource": ""
} |
q3407 | CNabuUser.activate | train | public function activate(bool $save = false) : bool
{
$retval = false;
$current = $this->getValidationStatus();
if ($current === self::USER_VALIDATION_PENDING || $current === self::USER_VALIDATION_PENDING_WITH_INVITATION) {
$this->setActivationDatetime(date('Y-m-d H:i:s', time()));
$this->setValidationStatus(CNabuUser::USER_ACTIVE);
$retval = ($save ? $this->save() : true);
}
return $retval;
} | php | {
"resource": ""
} |
q3408 | CNabuUser.findByStaticEncodedId | train | public static function findByStaticEncodedId($nb_customer, string $key)
{
$retval = null;
if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID)) &&
strlen($key) > 0
) {
$retval = CNabuUser::buildObjectFromSQL(
'select * '
. 'from nb_user u, nb_customer c '
. 'where u.nb_customer_id=c.nb_customer_id '
. 'and c.nb_customer_id=%cust_id$d '
. "and md5(concat('%pref\$s', u.nb_user_id, '%suff\$s'))='%key\$s'",
array(
'pref' => NABU_ENC_ID_PREF,
'suff' => NABU_ENC_ID_SUFF,
'cust_id' => $nb_customer_id,
'key' => $key
)
);
if ($nb_customer instanceof CNabuCustomer && $retval !== null) {
$retval->setCustomer($nb_customer);
}
}
return $retval;
} | php | {
"resource": ""
} |
q3409 | CNabuUser.findByStaticEncodedLogin | train | public static function findByStaticEncodedLogin($nb_customer, string $key)
{
$retval = null;
if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID)) &&
strlen($key) > 0
) {
$retval = CNabuUser::buildObjectFromSQL(
'select * '
. 'from nb_user u, nb_customer c '
. 'where u.nb_customer_id=c.nb_customer_id '
. 'and c.nb_customer_id=%cust_id$d '
. "and md5(concat('%pref\$s', u.nb_user_login, '%suff\$s'))='%key\$s'",
array(
'pref' => self::PASS_PREF,
'suff' => self::PASS_SUFF,
'cust_id' => $nb_customer_id,
'key' => $key
)
);
if ($nb_customer instanceof CNabuCustomer && $retval !== null) {
$retval->setCustomer($nb_customer);
}
}
return $retval;
} | php | {
"resource": ""
} |
q3410 | CNabuUser.findByTemporalEncodedId | train | public static function findByTemporalEncodedId($nb_customer, string $key, int $expires = NABU_TEMP_ENC_ID_EXPIRATION_TIME)
{
$retval = null;
if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID)) &&
strlen($key) > 0
) {
$hash_left = $hash_time = null;
sscanf($key, "%32s%x", $hash_left, $hash_time);
if ($hash_time >= time()) {
$retval = CNabuUser::buildObjectFromSQL(
'select * '
. 'from nb_user u, nb_customer c '
. 'where u.nb_customer_id=c.nb_customer_id '
. 'and c.nb_customer_id=%cust_id$d '
. "and md5(concat('%pref\$s', u.nb_user_id, '%suff\$s'))='%key\$s'",
array(
'pref' => NABU_ENC_ID_PREF,
'suff' => NABU_ENC_ID_SUFF,
'cust_id' => $nb_customer_id,
'key' => $hash_left
)
);
if ($nb_customer instanceof CNabuCustomer && $retval !== null) {
$retval->setCustomer($nb_customer);
}
}
}
return $retval;
} | php | {
"resource": ""
} |
q3411 | CNabuUser.findBySiteLogin | train | static public function findBySiteLogin($nb_site, $login, $passwd, $active = true)
{
$retval = null;
$nb_site_id = nb_getMixedValue($nb_site, 'nb_site_id');
if (is_numeric($nb_site_id)) {
$retval = CNabuUser::buildObjectFromSQL(
"select u.*, su.nb_role_id "
. "from nb_user u, nb_site_user su "
. "where (u.nb_user_login='%login\$s' or lower(u.nb_user_email)=lower('%login\$s')) "
. "and u.nb_user_passwd='%passwd\$s' "
. ($active ? "and u.nb_user_validation_status='T' " : '')
. "and u.nb_user_id=su.nb_user_id "
. "and su.nb_site_id=%site_id\$d",
array(
'login' => $login,
'passwd' => CNabuUser::encodePassword($passwd),
'site_id' => $nb_site_id
)
);
}
return $retval;
} | php | {
"resource": ""
} |
q3412 | CNabuUser.findByEMail | train | static public function findByEMail($nb_customer, string $email)
{
$retval = null;
if (is_numeric($nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID))) {
$retval = CNabuUser::buildObjectFromSQL(
'select u.* '
. 'from nb_user u, nb_customer c '
. 'where u.nb_customer_id=c.nb_customer_id '
. 'and c.nb_customer_id=%cust_id$d '
. 'and u.nb_user_email=\'%email$s\'',
array(
'cust_id' => $nb_customer_id,
'email' => $email
)
);
if ($retval instanceof CNabuUser && $nb_customer instanceof CNabuCustomer) {
$retval->setCustomer($nb_customer);
}
}
return $retval;
} | php | {
"resource": ""
} |
q3413 | CNabuUser.getPrescriber | train | public function getPrescriber(bool $force = false)
{
if ($this->nb_prescriber == NULL ||
$this->nb_prescriber->getId() != $this->getPrescriberId() ||
$force
) {
$nb_prescriber_id = $this->getPrescriberId();
if ($nb_prescriber_id === null || $this->getCustomer() === null) {
$this->nb_prescriber = null;
} else {
$this->nb_prescriber = $this->getCustomer()->getUser($nb_prescriber_id);
}
}
return $this->nb_prescriber;
} | php | {
"resource": ""
} |
q3414 | CallbackHydrator.hydrateCollection | train | public static function hydrateCollection(array $callbacks)
{
$hydrated = [];
foreach ($callbacks as $callback) {
$hydrated[] = self::hydrate($callback);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3415 | CallbackHydrator.hydrate | train | public static function hydrate(stdClass $callback)
{
$hydrated = new CallbackEntity();
if (isset($callback->id)) {
$hydrated->setId($callback->id);
}
if (isset($callback->internal)) {
$hydrated->setInternal($callback->internal);
}
if (isset($callback->observe_organization)) {
$hydrated->setObserveOrganization($callback->observe_organization);
}
if (isset($callback->url)) {
$hydrated->setUrl($callback->url);
}
if (isset($callback->reports) && is_array($callback->reports)) {
$hydrated->setReports($callback->reports);
}
if (isset($callback->created_at)) {
$hydrated->setCreatedAt(new DateTime($callback->created_at));
}
if (isset($callback->created_by)) {
$hydrated->setCreatedBy(UserHydrator::hydrate($callback->created_by));
}
if (isset($callback->users) && is_array($callback->users)) {
$hydrated->setUsers(UserHydrator::hydrateCollection($callback->users));
}
if (isset($callback->applications) && is_array($callback->applications)) {
$hydrated->setApplications(ApplicationHydrator::hydrateCollection($callback->applications));
}
if (isset($callback->scans) && is_array($callback->scans)) {
$hydrated->setScans(ScanHydrator::hydrateCollection($callback->scans));
}
return $hydrated;
} | php | {
"resource": ""
} |
q3416 | TNabuSiteRoleMask.isForPublicZone | train | public function isForPublicZone(bool $strict = false)
{
if (!method_exists($this, 'getZone')) {
throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED);
}
$zone = $this->getZone();
return ($zone === CNabuSite::ZONE_PUBLIC || (!$strict && $zone === CNabuSite::ZONE_BOTH));
} | php | {
"resource": ""
} |
q3417 | TNabuSiteRoleMask.isForPrivateZone | train | public function isForPrivateZone(bool $strict = false)
{
if (!method_exists($this, 'getZone')) {
throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED);
}
$zone = $this->getZone();
return ($zone === CNabuSite::ZONE_PRIVATE || (!$strict && $zone === CNabuSite::ZONE_BOTH));
} | php | {
"resource": ""
} |
q3418 | TNabuSiteRoleMask.isForBothZones | train | public function isForBothZones()
{
if (!method_exists($this, 'getZone')) {
throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED);
}
return $this->getZone() === CNabuSite::ZONE_BOTH;
} | php | {
"resource": ""
} |
q3419 | TNabuSiteRoleMask.isZoneHidden | train | public function isZoneHidden()
{
if (!method_exists($this, 'getZone')) {
throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED);
}
$zone = $this->getZone();
return $zone !== CNabuSite::ZONE_PUBLIC && $zone !== CNabuSite::ZONE_PRIVATE && $zone !== CNabuSite::ZONE_HIDDEN;
} | php | {
"resource": ""
} |
q3420 | TNabuHashed.grantHash | train | public function grantHash(bool $save = false) : string
{
if (!nb_isValidGUID($hash = $this->getHash())) {
$this->setHash($hash = nb_generateGUID());
if ($save && $this instanceof CNabuDBObject) {
$this->save();
}
}
return $hash;
} | php | {
"resource": ""
} |
q3421 | UserHydrator.hydrateCollection | train | public static function hydrateCollection(array $users)
{
$hydrated = [];
foreach ($users as $user) {
$hydrated[] = self::hydrate($user);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3422 | UserHydrator.hydrate | train | public static function hydrate(stdClass $user)
{
$hydrated = new UserEntity();
if (isset($user->id)) {
$hydrated->setId($user->id);
}
if (isset($user->email)) {
$hydrated->setEmail($user->email);
}
if (isset($user->firstname)) {
$hydrated->setFirstname($user->firstname);
}
if (isset($user->lastname)) {
$hydrated->setLastname($user->lastname);
}
if (isset($user->valid_until)) {
$hydrated->setValidUntil(new DateTime($user->valid_until));
}
if (isset($user->organization)) {
$hydrated->setOrganization(OrgHydrator::hydrate($user->organization));
}
if (isset($user->roles)) {
$hydrated->setRoles($user->roles);
}
if (isset($user->root)) {
$hydrated->setRoot($user->root);
}
if (isset($user->whitelisted_ips)) {
$hydrated->setWhitelistedIps($user->whitelisted_ips);
}
if (isset($user->last_login)) {
$hydrated->setLastLogin(new DateTime($user->last_login));
}
if (isset($user->confirmation_token)) {
$hydrated->setConfirmationToken($user->confirmation_token);
}
if (isset($user->reset_token)) {
$hydrated->setResetToken($user->reset_token);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3423 | UrlGenerator.replaceRouteParameters | train | protected function replaceRouteParameters($route, &$parameters = [])
{
return \preg_replace_callback('/\{(.*?)(:.*?)?(\{[0-9,]+\})?\}/', function ($m) use (&$parameters) {
return isset($parameters[$m[1]]) ? Arr::pull($parameters, $m[1]) : $m[0];
}, $route);
} | php | {
"resource": ""
} |
q3424 | CNabuSiteMapRole.getMapRolesForSite | train | static public function getMapRolesForSite($nb_site)
{
$nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID);
if (is_numeric($nb_site_id)) {
$retval = CNabuEngine::getEngine()
->getMainDB()
->getQueryAsObjectArray(
'\nabu\data\site\CNabuSiteMapRole', null,
'select smr.* '
. 'from nb_site_map sm, nb_site_map_role smr '
. 'where sm.nb_site_map_id=smr.nb_site_map_id '
. 'and sm.nb_site_id=%site_id$d '
. 'order by sm.nb_site_map_order, smr.nb_role_id',
array(
'site_id' => $nb_site_id
), null, true
)
;
} else {
$retval = null;
}
return $retval;
} | php | {
"resource": ""
} |
q3425 | CommentHydrator.hydrateCollection | train | public static function hydrateCollection(array $comments)
{
$hydrated = [];
foreach ($comments as $comment) {
$hydrated[] = self::hydrate($comment);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3426 | CommentHydrator.hydrate | train | public static function hydrate(stdClass $comment)
{
$hydrated = new CommentEntity();
if (isset($comment->id)) {
$hydrated->setId($comment->id);
}
if (isset($comment->comment)) {
$hydrated->setComment($comment->comment);
}
if (isset($comment->created_at)) {
$hydrated->setCreatedAt(new DateTime($comment->created_at));
}
if (isset($comment->created_by)) {
$hydrated->setCreatedBy(UserHydrator::hydrate($comment->created_by));
}
if (isset($comment->source)) {
$hydrated->setSource($comment->source);
}
if (isset($comment->issue)) {
$hydrated->setIssue(IssueHydrator::hydrate($comment->issue));
}
return $hydrated;
} | php | {
"resource": ""
} |
q3427 | CNabuCatalogItemTagBase.setCatalogItemId | train | public function setCatalogItemId(int $nb_catalog_item_id) : CNabuDataObject
{
if ($nb_catalog_item_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_catalog_item_id")
);
}
$this->setValue('nb_catalog_item_id', $nb_catalog_item_id);
return $this;
} | php | {
"resource": ""
} |
q3428 | LdapService.get | train | public function get(array $queryParams = [])
{
$response = $this->api->systems()->ldap()->get($queryParams);
return new LdapResponse($response);
} | php | {
"resource": ""
} |
q3429 | LdapService.update | train | public function update(LdapBuilder $input, array $queryParams = [])
{
$response = $this->api->systems()->ldap()->update($input->toArray(), $queryParams);
return new LdapResponse($response);
} | php | {
"resource": ""
} |
q3430 | LdapService.sync | train | public function sync(array $queryParams = [])
{
$response = $this->api->systems()->ldap()->sync($queryParams);
return new BaseResponse($response);
} | php | {
"resource": ""
} |
q3431 | SettingService.getAll | train | public function getAll(array $queryParams = [])
{
$response = $this->api->settings()->getAll($queryParams);
return new SettingsResponse($response);
} | php | {
"resource": ""
} |
q3432 | SettingService.createOrUpdate | train | public function createOrUpdate($key, SettingBuilder $input, array $queryParams = [])
{
$response = $this->api->settings()->createOrUpdate($key, $input->toArray(), $queryParams);
return new SettingResponse($response);
} | php | {
"resource": ""
} |
q3433 | SettingService.deleteAll | train | public function deleteAll(array $queryParams = [])
{
$response = $this->api->settings()->deleteAll($queryParams);
return new BaseResponse($response);
} | php | {
"resource": ""
} |
q3434 | CNabuErrorHandler.errorHandler | train | public function errorHandler(int $errno, string $errstr, string $errfile, string $errline, array $errcontext)
{
$this->dumpStack($errstr, $errno, $errfile, $errline, $errcontext);
return true;
} | php | {
"resource": ""
} |
q3435 | CNabuErrorHandler.dumpStack | train | public function dumpStack(
string $message = null,
string $type = null,
string $errfile = null,
int $errline = null,
$errcontext = null,
array $stack = null
) {
global $NABU_MESSAGE_TYPE_NAME;
if (($errtype = nb_getArrayValueByKey($type, $NABU_MESSAGE_TYPE_NAME)) === null) {
$this->nb_engine->errorLog("Unknow error type [$type]: $message in $errfile [line:$errline]");
} else {
$this->nb_engine->errorLog("$errtype: $message in $errfile [line:$errline]");
}
if ($stack === null) {
$stack = debug_backtrace(true);
}
$count = -1;
do {
foreach ($stack as $line) {
if ($count < 0 &&
(!array_key_exists('file', $line) ||
!array_key_exists('line', $line) ||
$line['file'] !== $errfile ||
$line['line'] !== $errline
)
) {
continue;
} elseif (array_key_exists('file', $line) &&
$line['file'] === $errfile && $line['line'] === $errline
) {
$count++;
continue;
}
$source = '';
if (array_key_exists(self::LINE_CLASS, $line)) {
$source .= $line[self::LINE_CLASS];
}
if (array_key_exists('type', $line)) {
$source .= $line['type'];
}
if (array_key_exists(self::LINE_FUNCTION, $line)) {
$source .= $line[self::LINE_FUNCTION];
}
if (array_key_exists(self::LINE_CLASS, $line) &&
array_key_exists('type', $line) &&
array_key_exists(self::LINE_FUNCTION, $line) &&
array_key_exists('args', $line) &&
is_array($line['args']) &&
count($line['args']) > 0 &&
$line[self::LINE_CLASS] == 'nabu\\core\\CNabuPluginManager' &&
$line[self::LINE_FUNCTION] == 'invoqueCommand'
) {
$source .= ' calling command ['.$line['args'][0].']';
}
if (array_key_exists('file', $line)) {
$source .= ' in '.$line['file'];
}
if (array_key_exists('line', $line)) {
$source .= " [line:$line[line]]";
}
$this->nb_engine->errorLog("#$count at $source");
$count++;
}
$count++;
} while ($count < 1);
} | php | {
"resource": ""
} |
q3436 | CNabuErrorHandler.traceLog | train | public function traceLog(string $key = null, $message = null)
{
if ($this->trace_log_enabled) {
if (is_array($message) || is_object($message)) {
$text = print_r($message, true);
} elseif ($message === null) {
$text = "[null]";
} elseif ($message === false) {
$text = "[false]";
} elseif ($message === true) {
$text = "[true]";
} else {
$text = $message;
}
error_log("=== " . ($key !== null ? "$key: " : '') . $text);
}
if ($key === null) {
if ($this->trace_log_buffer === null) {
$this->trace_log_buffer = array();
}
if (array_key_exists(self::MESSAGES_STACK, $this->trace_log_buffer)) {
$this->trace_log_buffer[self::MESSAGES_STACK][] = $message;
} else {
$this->trace_log_buffer[self::MESSAGES_STACK] = array($message);
}
} else {
$this->trace_log_buffer[$key] = $message;
}
} | php | {
"resource": ""
} |
q3437 | AutoUuid.bootAutoUuid | train | protected static function bootAutoUuid()
{
static::creating(function ($model) {
foreach($model->getAutoUuids() as $autoUuid) {
if (empty($model->{$autoUuid})) {
$model->setAttribute($autoUuid, $model->generateUuid()->getBytes());
}
}
});
} | php | {
"resource": ""
} |
q3438 | ApplicationService.getById | train | public function getById($appId, array $queryParams = [])
{
$response = $this->api->applications()->getById($appId, $queryParams);
return new ApplicationResponse($response);
} | php | {
"resource": ""
} |
q3439 | ApplicationService.update | train | public function update($appId, ApplicationBuilder $input, array $queryParams = [])
{
$response = $this->api->applications()->update($appId, $input->toArray(), $queryParams);
return new ApplicationResponse($response);
} | php | {
"resource": ""
} |
q3440 | ApplicationService.deleteAll | train | public function deleteAll(array $queryParams = [])
{
$response = $this->api->applications()->deleteAll($queryParams);
return new BaseResponse($response);
} | php | {
"resource": ""
} |
q3441 | Historable.writeHistory | train | public function writeHistory($action, $title = null, array $old = [], array $new = [])
{
$data['historable_id'] = $this->getKey();
$data['historable_type'] = get_class($this);
$data['user_id'] = auth()->id();
$data['title'] = $title;
$data['icon_class'] = $this->iconClass($action);
$data['historable_table'] = $this->getTable();
$data['action'] = $action;
$data['old'] = $old;
$data['new'] = $new;
(new EloquentHistory())->create($data);
} | php | {
"resource": ""
} |
q3442 | EditLayoutCompiler.compile | train | public function compile($stub, $modelName, $modelData, stdClass $scaffolderConfig, $hash, ScaffolderThemeExtensionInterface $themeExtension, array $extensions, $extra = null)
{
$this->stub = $stub;
return $this->store(null, $scaffolderConfig, $themeExtension->runAfterEditLayoutIsCompiled($this->stub, $scaffolderConfig), new FileToCompile(null, null));
} | php | {
"resource": ""
} |
q3443 | CNabuCatalogItemList.populate | train | public function populate(int $deep = 0)
{
$nb_catalog = $this->getCatalog();
$this->clear();
$this->merge(CNabuCatalogItem::getItemsForCatalog($nb_catalog, $deep));
$translations = CNabuCatalogItem::getItemTranslationsForCatalog($nb_catalog, $deep);
$translations->iterate(
function ($key, $translation)
{
$item = $this->getItem($translation->getCatalogItemId());
if ($item instanceof INabuTranslated) {
$item->setTranslation($translation);
}
return true;
}
);
} | php | {
"resource": ""
} |
q3444 | CNabuDBObject.getDescriptor | train | public function getDescriptor($force = false)
{
if (!($this->storage_descriptor instanceof INabuDBDescriptor) || $force) {
$this->storage_descriptor = null;
$this->storage_descriptor = $this->db->getDescriptorFromFile($this->getStorageDescriptorPath());
}
return $this->storage_descriptor;
} | php | {
"resource": ""
} |
q3445 | CNabuDBObject.refresh | train | public function refresh(bool $force = false, bool $cascade = false) : bool
{
$this->relinkDB();
return $this->load();
} | php | {
"resource": ""
} |
q3446 | CNabuSiteTargetBase.findByKey | train | public static function findByKey($nb_site, $key)
{
$nb_site_id = nb_getMixedValue($nb_site, 'nb_site_id');
if (is_numeric($nb_site_id)) {
$retval = CNabuSiteTarget::buildObjectFromSQL(
'select * '
. 'from nb_site_target '
. 'where nb_site_id=%site_id$d '
. "and nb_site_target_key='%key\$s'",
array(
'site_id' => $nb_site_id,
'key' => $key
)
);
} else {
$retval = null;
}
return $retval;
} | php | {
"resource": ""
} |
q3447 | CNabuSiteTargetBase.getAllSiteTargets | train | public static function getAllSiteTargets(CNabuSite $nb_site)
{
$nb_site_id = nb_getMixedValue($nb_site, 'nb_site_id');
if (is_numeric($nb_site_id)) {
$retval = forward_static_call(
array(get_called_class(), 'buildObjectListFromSQL'),
'nb_site_target_id',
'select * '
. 'from nb_site_target '
. 'where nb_site_id=%site_id$d',
array(
'site_id' => $nb_site_id
),
$nb_site
);
} else {
$retval = new CNabuSiteTargetList();
}
return $retval;
} | php | {
"resource": ""
} |
q3448 | CNabuSiteTargetBase.setUseHTTP | train | public function setUseHTTP(string $use_http = "F") : CNabuDataObject
{
if ($use_http === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$use_http")
);
}
$this->setValue('nb_site_target_use_http', $use_http);
return $this;
} | php | {
"resource": ""
} |
q3449 | CNabuSiteTargetBase.setUseHTTPS | train | public function setUseHTTPS(string $use_https = "F") : CNabuDataObject
{
if ($use_https === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$use_https")
);
}
$this->setValue('nb_site_target_use_https', $use_https);
return $this;
} | php | {
"resource": ""
} |
q3450 | CNabuSiteTargetBase.setAttachment | train | public function setAttachment(string $attachment = "F") : CNabuDataObject
{
if ($attachment === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$attachment")
);
}
$this->setValue('nb_site_target_attachment', $attachment);
return $this;
} | php | {
"resource": ""
} |
q3451 | CNabuSiteTargetBase.setSmartyDebugging | train | public function setSmartyDebugging(string $smarty_debugging = "F") : CNabuDataObject
{
if ($smarty_debugging === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$smarty_debugging")
);
}
$this->setValue('nb_site_target_smarty_debugging', $smarty_debugging);
return $this;
} | php | {
"resource": ""
} |
q3452 | CNabuSiteTargetBase.setPHPTrace | train | public function setPHPTrace(string $php_trace = "F") : CNabuDataObject
{
if ($php_trace === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$php_trace")
);
}
$this->setValue('nb_site_target_php_trace', $php_trace);
return $this;
} | php | {
"resource": ""
} |
q3453 | CNabuSiteTargetBase.setIgnorePolicies | train | public function setIgnorePolicies(string $ignore_policies = "F") : CNabuDataObject
{
if ($ignore_policies === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$ignore_policies")
);
}
$this->setValue('nb_site_target_ignore_policies', $ignore_policies);
return $this;
} | php | {
"resource": ""
} |
q3454 | CNabuSiteTargetBase.setUseCommerce | train | public function setUseCommerce(string $use_commerce = "F") : CNabuDataObject
{
if ($use_commerce === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$use_commerce")
);
}
$this->setValue('nb_site_target_use_commerce', $use_commerce);
return $this;
} | php | {
"resource": ""
} |
q3455 | CNabuSiteTargetBase.setUseApps | train | public function setUseApps(string $use_apps = "F") : CNabuDataObject
{
if ($use_apps === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$use_apps")
);
}
$this->setValue('nb_site_target_use_apps', $use_apps);
return $this;
} | php | {
"resource": ""
} |
q3456 | CNabuSiteTargetBase.setDynamicCacheControl | train | public function setDynamicCacheControl(string $dynamic_cache_control = "S") : CNabuDataObject
{
if ($dynamic_cache_control === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$dynamic_cache_control")
);
}
$this->setValue('nb_site_target_dynamic_cache_control', $dynamic_cache_control);
return $this;
} | php | {
"resource": ""
} |
q3457 | CNabuMessagingTemplate.getActiveServices | train | public function getActiveServices(bool $force = false) : CNabuMessagingServiceList
{
if ($this->nb_messaging_service_list->isEmpty() || $force) {
$this->nb_messaging_service_list->clear();
if (($nb_messaging = $this->getMessaging()) instanceof CNabuMessaging &&
!($nb_services_list = $nb_messaging->getActiveServices())->isEmpty()
) {
$nb_services_list->iterate(function($key, CNabuMessagingService $nb_service) {
if ($nb_service->isTemplateConnected($this->getId())) {
$this->nb_messaging_service_list->addItem($nb_service);
}
return true;
});
}
}
return $this->nb_messaging_service_list;
} | php | {
"resource": ""
} |
q3458 | CNabuMessagingServiceStackBase.getAllMessagingServiceStacks | train | public static function getAllMessagingServiceStacks(CNabuMessaging $nb_messaging)
{
$nb_messaging_id = nb_getMixedValue($nb_messaging, 'nb_messaging_id');
if (is_numeric($nb_messaging_id)) {
$retval = forward_static_call(
array(get_called_class(), 'buildObjectListFromSQL'),
'nb_messaging_service_stack_id',
'select * '
. 'from nb_messaging_service_stack '
. 'where nb_messaging_id=%messaging_id$d',
array(
'messaging_id' => $nb_messaging_id
),
$nb_messaging
);
} else {
$retval = new CNabuMessagingServiceStackList();
}
return $retval;
} | php | {
"resource": ""
} |
q3459 | CNabuMessagingServiceStackBase.setMessagingId | train | public function setMessagingId(int $nb_messaging_id) : CNabuDataObject
{
if ($nb_messaging_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_messaging_id")
);
}
$this->setValue('nb_messaging_id', $nb_messaging_id);
return $this;
} | php | {
"resource": ""
} |
q3460 | CNabuMessagingServiceStackBase.setMessagingServiceId | train | public function setMessagingServiceId(int $nb_messaging_service_id) : CNabuDataObject
{
if ($nb_messaging_service_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_messaging_service_id")
);
}
$this->setValue('nb_messaging_service_id', $nb_messaging_service_id);
return $this;
} | php | {
"resource": ""
} |
q3461 | CNabuMessagingServiceStackBase.setMessagingTemplateId | train | public function setMessagingTemplateId(int $nb_messaging_template_id) : CNabuDataObject
{
if ($nb_messaging_template_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_messaging_template_id")
);
}
$this->setValue('nb_messaging_template_id', $nb_messaging_template_id);
return $this;
} | php | {
"resource": ""
} |
q3462 | CNabuProjectVersionBase.getAllProjectVersions | train | public static function getAllProjectVersions(CNabuProject $nb_project)
{
$nb_project_id = nb_getMixedValue($nb_project, 'nb_project_id');
if (is_numeric($nb_project_id)) {
$retval = forward_static_call(
array(get_called_class(), 'buildObjectListFromSQL'),
'nb_project_version_id',
'select * '
. 'from nb_project_version '
. 'where nb_project_id=%project_id$d',
array(
'project_id' => $nb_project_id
),
$nb_project
);
} else {
$retval = new CNabuProjectVersionList();
}
return $retval;
} | php | {
"resource": ""
} |
q3463 | CNabuProjectVersionBase.getFilteredProjectVersionList | train | public static function getFilteredProjectVersionList($nb_project = null, $q = null, $fields = null, $order = null, $offset = 0, $num_items = 0)
{
$nb_project_id = nb_getMixedValue($nb_customer, NABU_PROJECT_FIELD_ID);
if (is_numeric($nb_project_id)) {
$fields_part = nb_prefixFieldList(CNabuProjectVersionBase::getStorageName(), $fields, false, true, '`');
$order_part = nb_prefixFieldList(CNabuProjectVersionBase::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_project_version '
. 'where ' . NABU_PROJECT_FIELD_ID . '=%project_id$d '
. ($order_part ? "order by $order_part " : '')
. ($limit_part ? "limit $limit_part" : ''),
array(
'project_id' => $nb_project_id
)
);
} else {
$nb_item_list = null;
}
return $nb_item_list;
} | php | {
"resource": ""
} |
q3464 | CNabuProjectVersionBase.setProjectId | train | public function setProjectId(int $nb_project_id) : CNabuDataObject
{
if ($nb_project_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_project_id")
);
}
$this->setValue('nb_project_id', $nb_project_id);
return $this;
} | php | {
"resource": ""
} |
q3465 | LogHydrator.hydrateCollection | train | public static function hydrateCollection(array $logs)
{
$hydrated = [];
foreach ($logs as $log) {
$hydrated[] = self::hydrate($log);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3466 | LogHydrator.hydrate | train | public static function hydrate(stdClass $log)
{
$hydrated = new LogEntity();
if (isset($log->id)) {
$hydrated->setId($log->id);
}
if (isset($log->text)) {
$hydrated->setText($log->text);
}
if (isset($log->level)) {
$hydrated->setLevel($log->level);
}
if (isset($log->channel)) {
$hydrated->setChannel($log->channel);
}
if (isset($log->request_uri)) {
$hydrated->setRequestUri($log->request_uri);
}
if (isset($log->request_method)) {
$hydrated->setRequestMethod($log->request_method);
}
if (isset($log->ip)) {
$hydrated->setIp($log->ip);
}
if (isset($log->created_by)) {
$hydrated->setCreatedBy(UserHydrator::hydrate($log->created_by));
}
if (isset($log->email)) {
$hydrated->setEmail($log->email);
}
if (isset($log->organization)) {
$hydrated->setOrganization(OrgHydrator::hydrate($log->organization));
}
if (isset($log->organization_name)) {
$hydrated->setOrganizationName($log->organization_name);
}
if (isset($log->context)) {
$hydrated->setContext($log->context);
}
if (isset($log->created_at)) {
$hydrated->setCreatedAt(new DateTime($log->created_at));
}
if (isset($log->user_agent)) {
$hydrated->setUserAgent($log->user_agent);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3467 | PartHydrator.hydrateCollection | train | public static function hydrateCollection(array $parts)
{
$hydrated = [];
foreach ($parts as $part) {
$hydrated[] = self::hydrate($part);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3468 | PartHydrator.hydrate | train | public static function hydrate(stdClass $part)
{
$hydrated = new PartEntity();
if (isset($part->id)) {
$hydrated->setId($part->id);
}
if (isset($part->type)) {
$hydrated->setType($part->type);
}
if (isset($part->content)) {
$hydrated->setContent($part->content);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3469 | EntityManager.insert | train | public function insert($entity)
{
$eloquentModel = $this->getEloquentModel($entity);
$this->updateRelations($eloquentModel, 'insert');
$eloquentModel->save();
$eloquentModel->afterSaving($entity, 'insert');
} | php | {
"resource": ""
} |
q3470 | EntityManager.update | train | public function update($entity)
{
$eloquentModel = $this->getEloquentModel($entity, true);
$this->updateRelations($eloquentModel, 'update');
$eloquentModel->save();
$eloquentModel->afterSaving($entity, 'update');
} | php | {
"resource": ""
} |
q3471 | EntityManager.updateRelations | train | protected function updateRelations($eloquentModel, $action)
{
$mapping = $eloquentModel->getMapping();
$eloquentRelations = $eloquentModel->getRelations();
foreach($mapping['relations'] as $name => $relationMapping) {
if (isset($eloquentRelations[$name])) {
$this->updateRelation($eloquentModel, $name, $relationMapping, $action);
}
}
} | php | {
"resource": ""
} |
q3472 | EntityManager.updateRelation | train | protected function updateRelation($eloquentModel, $name, $relationMapping, $action)
{
// set foreign key for belongsTo/morphTo relation
if ($relationMapping['type'] == 'belongsTo' || $relationMapping['type'] == 'morphTo') {
$this->updateBelongsToRelation($eloquentModel, $name, $action);
}
// set foreign keys for belongsToMany/morphToMany relation
if (($relationMapping['type'] == 'belongsToMany' || $relationMapping['type'] == 'morphToMany') && ! $relationMapping['inverse']) {
$this->updateBelongsToManyRelation($eloquentModel, $name, $action);
}
} | php | {
"resource": ""
} |
q3473 | EntityManager.updateBelongsToRelation | train | protected function updateBelongsToRelation($eloquentModel, $name, $action)
{
if ($action == 'insert' || $action == 'update') {
$eloquentModel->{$name}()->associate($eloquentModel->getRelation($name));
}
} | php | {
"resource": ""
} |
q3474 | EntityManager.updateBelongsToManyRelation | train | protected function updateBelongsToManyRelation($eloquentModel, $name, $action)
{
$eloquentCollection = $eloquentModel->getRelation($name);
if (! $eloquentCollection instanceof \Illuminate\Database\Eloquent\Collection) {
throw new Exception("Many-to-many relation '".$name."' is not a valid collection");
}
// get related keys
$keys = [];
foreach($eloquentCollection as $item) {
$keys[] = $item->getKey();
}
// attach/sync/detach keys
if ($action == 'insert') {
$eloquentModel->{$name}()->attach($keys);
}
if ($action == 'update') {
$eloquentModel->{$name}()->sync($keys);
}
if ($action == 'delete') {
$eloquentModel->{$name}()->detach($keys);
}
} | php | {
"resource": ""
} |
q3475 | ContextService.getAll | train | public function getAll($appId, $scanId, $issueId, array $queryParams = [])
{
$response = $this->api
->applications()
->scans()
->issues()
->contexts()
->getAll($appId, $scanId, $issueId, $queryParams);
return new ContextsResponse($response);
} | php | {
"resource": ""
} |
q3476 | ContextService.getById | train | public function getById($appId, $scanId, $issueId, $contextId, array $queryParams = [])
{
$response = $this->api
->applications()
->scans()
->issues()
->contexts()
->getById($appId, $scanId, $issueId, $contextId, $queryParams);
return new ContextResponse($response);
} | php | {
"resource": ""
} |
q3477 | GraphBuilder.getResults | train | protected function getResults($method)
{
if ($this->schema) {
// set root constraints
if (isset($this->constraints[$this->root])) {
$this->constraints[$this->root]($this->eloquentQuery);
}
// set eager load constraints
$this->eloquentQuery->setEagerLoads($this->parseRelationsFromSchema($this->schema, ''));
// execute query
$results = $this->eloquentQuery->$method();
// transform to data transfer objects
if ($results) {
$dtos = $results->toDataTransferObject($this->root, $this->schema, $this->transformations);
return [$this->root => $dtos];
}
}
return null;
} | php | {
"resource": ""
} |
q3478 | GraphBuilder.parseRelationsFromSchema | train | protected function parseRelationsFromSchema(array $schema, $path='')
{
$results = [];
foreach ($schema as $key => $value) {
if (! is_numeric($key)) {
// join relation
if (substr($key, 0, 3) != '...') {
$childPath = ($path)
? $path.'.'.$key
: $key;
$results[$childPath] = (isset($this->constraints[$this->root.'.'.$childPath]))
? $this->constraints[$this->root.'.'.$childPath]
: function () {};
} else {
$childPath = $path;
}
// recursive call
$results = array_merge($results, $this->parseRelationsFromSchema($value, $childPath));
}
}
return $results;
} | php | {
"resource": ""
} |
q3479 | GraphBuilder.schema | train | public function schema(array $schema)
{
$this->root = key($schema);
$this->schema = current($schema);
return $this;
} | php | {
"resource": ""
} |
q3480 | ResourceHydrator.hydrateCollection | train | public static function hydrateCollection(array $resources)
{
$hydrated = [];
foreach ($resources as $resource) {
$hydrated[] = self::hydrate($resource);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3481 | ResourceHydrator.hydrate | train | public static function hydrate(stdClass $resource)
{
$hydrated = new ResourceEntity();
if (isset($resource->id)) {
$hydrated->setId($resource->id);
}
if (isset($resource->title)) {
$hydrated->setTitle($resource->title);
}
if (isset($resource->author)) {
$hydrated->setAuthor($resource->author);
}
if (isset($resource->url)) {
$hydrated->setUrl($resource->url);
}
if (isset($resource->published_at)) {
$hydrated->setPublishedAt(new DateTime($resource->published_at));
}
if (isset($resource->languages) && is_array($resource->languages)) {
$hydrated->setLanguages(LanguageHydrator::hydrateCollection($resource->languages));
}
return $hydrated;
} | php | {
"resource": ""
} |
q3482 | CNabuSiteAliasBase.getAllSiteAliass | train | public static function getAllSiteAliass(CNabuSite $nb_site)
{
$nb_site_id = nb_getMixedValue($nb_site, 'nb_site_id');
if (is_numeric($nb_site_id)) {
$retval = forward_static_call(
array(get_called_class(), 'buildObjectListFromSQL'),
'nb_site_alias_id',
'select * '
. 'from nb_site_alias '
. 'where nb_site_id=%site_id$d',
array(
'site_id' => $nb_site_id
),
$nb_site
);
} else {
$retval = new CNabuSiteAliasList();
}
return $retval;
} | php | {
"resource": ""
} |
q3483 | CNabuSiteAliasBase.setDomainZoneHostId | train | public function setDomainZoneHostId(int $nb_domain_zone_host_id) : CNabuDataObject
{
if ($nb_domain_zone_host_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_domain_zone_host_id")
);
}
$this->setValue('nb_domain_zone_host_id', $nb_domain_zone_host_id);
return $this;
} | php | {
"resource": ""
} |
q3484 | CNabuSiteAliasBase.setType | train | public function setType(string $type = "F") : CNabuDataObject
{
if ($type === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$type")
);
}
$this->setValue('nb_site_alias_type', $type);
return $this;
} | php | {
"resource": ""
} |
q3485 | TypeHydrator.hydrateCollection | train | public static function hydrateCollection(array $types)
{
$hydrated = [];
foreach ($types as $type) {
$hydrated[] = self::hydrate($type);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3486 | CNabuSiteVisualEditorItemBase.setVRId | train | public function setVRId(string $vr_id) : CNabuDataObject
{
if ($vr_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$vr_id")
);
}
$this->setValue('nb_site_visual_editor_item_vr_id', $vr_id);
return $this;
} | php | {
"resource": ""
} |
q3487 | Model.toDatamapperObject | train | public function toDatamapperObject()
{
// directly set private properties if entity extends the datamapper entity class (fast!)
if (is_subclass_of($this->class, '\ProAI\Datamapper\Support\Entity')) {
$class = $this->class;
return $class::newFromEloquentObject($this);
}
// set private properties via reflection (slow!)
$reflectionClass = new ReflectionClass($this->class);
$entity = $reflectionClass->newInstanceWithoutConstructor();
// attributes
foreach ($this->mapping['attributes'] as $attribute => $column) {
$this->setProperty(
$reflectionClass,
$entity,
$attribute,
$this->attributes[$column]
);
}
// embeddeds
foreach ($this->mapping['embeddeds'] as $name => $embedded) {
$embeddedReflectionClass = new ReflectionClass($embedded['class']);
$embeddedObject = $embeddedReflectionClass->newInstanceWithoutConstructor();
foreach ($embedded['attributes'] as $attribute => $column) {
// set property
$this->setProperty(
$embeddedReflectionClass,
$embeddedObject,
$attribute,
$this->attributes[$column]
);
}
$this->setProperty(
$reflectionClass,
$entity,
$name,
$embeddedObject
);
}
// relations
foreach ($this->mapping['relations'] as $name => $relation) {
// set relation object
if (! empty($this->relations[$name])) {
$relationObject = $this->relations[$name]->toDatamapperObject();
} elseif (in_array($relation['type'], $this->manyRelations)) {
$relationObject = new ProxyCollection;
} else {
$relationObject = new Proxy;
}
// set property
$this->setProperty(
$reflectionClass,
$entity,
$name,
$relationObject
);
}
return $entity;
} | php | {
"resource": ""
} |
q3488 | Model.setProperty | train | protected function setProperty(&$reflectionClass, $entity, $name, $value)
{
$property = $reflectionClass->getProperty($name);
$property->setAccessible(true);
$property->setValue($entity, $value);
} | php | {
"resource": ""
} |
q3489 | Model.toDataTransferObject | train | public function toDataTransferObject($root, $schema, $transformations, $path='')
{
$dto = new DataTransferObject();
// get morphed schema
if($this->morphClass) {
$morphKey = '...'.Str::studly($this->morphClass);
if (isset($schema[$morphKey])) {
$schema = $schema[$morphKey];
}
}
foreach ($schema as $key => $value) {
// entry is attribute
if (is_numeric($key)) {
// transformation key
$transformationKey = ($path)
? $root.'.'.$path.'.'.$value
: $root.'.'.$value;
// set value
if ($value == '__type') {
$dto->{$value} = class_basename($this->class);
} elseif (isset($transformations[$transformationKey])) {
$node = new GraphNode;
$transformations[$transformationKey]($node, $this->attributes);
$dto->{$value} = $node->getValue();
} elseif (isset($transformations['*.'.$value])) {
$node = new GraphNode;
$transformations['*.'.$value]($node, $this->attributes);
$dto->{$value} = $node->getValue();
} else {
$columnName = $this->getColumnName($value);
if (isset($this->attributes[$columnName])) {
$dto->{$value} = $this->attributes[$columnName];
}
}
}
// entry is relation
if (! is_numeric($key) && isset($this->relations[$key])) {
// set value and transform childs to dtos
$newPath = ($path) ? $path.'.'.$key : $key;
$dto->{$key} = $this->relations[$key]->toDataTransferObject(
$root,
$value,
$transformations,
$newPath
);
}
}
return $dto;
} | php | {
"resource": ""
} |
q3490 | Model.newFromDatamapperObject | train | public static function newFromDatamapperObject(EntityContract $entity, $lastObjectId = null, $lastEloquentModel = null)
{
// directly get private properties if entity extends the datamapper entity class (fast!)
if ($entity instanceof \ProAI\Datamapper\Support\Entity) {
return $entity->toEloquentObject($lastObjectId, $lastEloquentModel);
}
// get private properties via reflection (slow!)
$class = get_mapped_model(get_class($entity));
$eloquentModel = new $class;
$reflectionObject = new ReflectionObject($entity);
$mapping = $eloquentModel->getMapping();
// attributes
foreach ($mapping['attributes'] as $attribute => $column) {
if (! $eloquentModel->isAutomaticallyUpdatedDate($column)) {
// get property
$property = $eloquentModel->getProperty(
$reflectionObject,
$entity,
$attribute
);
// set attribute
$eloquentModel->setAttribute($column, $property);
}
}
// embeddeds
foreach ($mapping['embeddeds'] as $name => $embedded) {
$embeddedObject = $eloquentModel->getProperty($reflectionObject, $entity, $name);
if (! empty($embeddedObject)) {
$embeddedReflectionObject = new ReflectionObject($embeddedObject);
foreach ($embedded['attributes'] as $attribute => $column) {
// get property
$property = $eloquentModel->getProperty(
$embeddedReflectionObject,
$embeddedObject,
$attribute
);
// set attribute
$eloquentModel->setAttribute($column, $property);
}
}
}
// relations
foreach ($mapping['relations'] as $name => $relation) {
$relationObject = $eloquentModel->getProperty(
$reflectionObject,
$entity,
$name
);
if (! empty($relationObject) && ! $relationObject instanceof \ProAI\Datamapper\Contracts\Proxy) {
// set relation
if ($relationObject instanceof \ProAI\Datamapper\Support\Collection) {
$value = EloquentCollection::newFromDatamapperObject($relationObject, $this, $eloquentModel);
} elseif (spl_object_hash($relationObject) == $lastObjectId) {
$value = $lastEloquentModel;
} else {
$value = EloquentModel::newFromDatamapperObject($relationObject, spl_object_hash($this), $eloquentModel);
}
$eloquentModel->setRelation($name, $value);
}
}
return $eloquentModel;
} | php | {
"resource": ""
} |
q3491 | Model.isAutomaticallyUpdatedDate | train | public function isAutomaticallyUpdatedDate($attribute)
{
// soft deletes
if (in_array('Illuminate\Database\Eloquent\SoftDeletes', class_uses(static::class)) && $attribute == $this->getDeletedAtColumn()) {
return true;
}
// timestamps
if ($this->timestamps && ($attribute == $this->getCreatedAtColumn() || $attribute == $this->getUpdatedAtColumn())) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q3492 | Model.getProperty | train | protected function getProperty($reflectionObject, $entity, $name)
{
$property = $reflectionObject->getProperty($name);
$property->setAccessible(true);
return $property->getValue($entity);
} | php | {
"resource": ""
} |
q3493 | Model.getColumnName | train | protected function getColumnName($name)
{
// check attributes for given name
if (isset($this->mapping['attributes'][$name])) {
return $this->mapping['attributes'][$name];
}
// check embeddeds for given name
foreach($this->mapping['embeddeds'] as $embedded) {
// check for embedded attributes
if (isset($embedded['attributes'][$name])) {
return $embedded['attributes'][$name];
}
// check for embedded attributes using embedded column prefix
if ($embedded['columnPrefix'] && strpos($name, $embedded['columnPrefix']) === 0) {
$embeddedName = substr($name, strlen($embedded['columnPrefix']));
if (isset($embedded['attributes'][$embeddedName])) {
return $embedded['attributes'][$embeddedName];
}
}
}
} | php | {
"resource": ""
} |
q3494 | CNabuMediotecasManager.getMedioteca | train | public function getMedioteca($nb_medioteca)
{
$nb_medioteca_id = nb_getMixedValue($nb_medioteca, NABU_MEDIOTECA_FIELD_ID);
return is_numeric($nb_medioteca_id) || nb_isValidGUID($nb_medioteca_id)
? $this->nb_medioteca_list->getItem($nb_medioteca_id)
: false
;
} | php | {
"resource": ""
} |
q3495 | CNabuMediotecasManager.getMediotecas | train | public function getMediotecas($force = false)
{
if ($this->nb_medioteca_list->isEmpty() || $force) {
$this->nb_medioteca_list->merge(
CNabuMedioteca::getMediotecasForCustomer(CNabuEngine::getEngine()->getCustomer())
);
}
return $this->nb_medioteca_list;
} | php | {
"resource": ""
} |
q3496 | TNabuTranslated.getLanguage | train | public function getLanguage($nb_language)
{
$retval = false;
$nb_language_id = nb_getMixedValue($nb_language, NABU_LANG_FIELD_ID);
if (is_numeric($nb_language_id) || nb_isValidGUID($nb_language_id)) {
$this->getLanguages();
if ($this->languages_list->containsKey($nb_language_id)) {
$retval = $this->languages_list->getItem($nb_language_id);
}
}
return $retval;
} | php | {
"resource": ""
} |
q3497 | TNabuTranslated.setLanguage | train | public function setLanguage(CNabuLanguage $nb_language)
{
if ($nb_language->isValueNumeric(NABU_LANG_FIELD_ID) || $nb_language->isValueGUID(NABU_LANG_FIELD_ID)) {
$nb_language_id = $nb_language->getValue(NABU_LANG_FIELD_ID);
$this->languages_list->addItem($nb_language);
}
} | php | {
"resource": ""
} |
q3498 | TNabuTranslated.getTranslation | train | public function getTranslation($nb_language)
{
$retval = false;
$nb_language_id = nb_getMixedValue($nb_language, NABU_LANG_FIELD_ID);
if (is_numeric($nb_language_id) || nb_isValidGUID($nb_language_id)) {
$this->getTranslations();
if ($this->translations_list->containsKey($nb_language_id)) {
$retval = $this->translations_list->getItem($nb_language_id);
}
}
return $retval;
} | php | {
"resource": ""
} |
q3499 | TNabuTranslated.hasTranslations | train | public function hasTranslations(bool $force = false)
{
$this->getTranslations($force);
return $this->translations_list->isFilled();
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.