_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q3800
PageLayoutCompiler.setAppName
train
private function setAppName(stdClass $scaffolderConfig) { $this->stub = str_replace('{{app_name}}', $scaffolderConfig->name, $this->stub); return $this; }
php
{ "resource": "" }
q3801
PageLayoutCompiler.setLinks
train
private function setLinks($links, stdClass $scaffolderConfig) { $navLinks = ''; foreach ($links as $link) { $navLinks .= sprintf(" <li> <a href='/%s' class='waves-effect'> %s </a> </li>", $scaffolderConfig->routing->prefix . '/' . strtolower($link['modelName']), $link['modelLabel']); } $this->stub = str_replace('{{links}}', $navLinks, $this->stub); return $this; }
php
{ "resource": "" }
q3802
SanitizerService.getAll
train
public function getAll($appId, $profileId, array $queryParams) { $response = $this->api->applications()->profiles()->sanitizers()->getAll($appId, $profileId, $queryParams); return new SanitizersResponse($response); }
php
{ "resource": "" }
q3803
SanitizerService.getById
train
public function getById($appId, $profileId, $sanitizerId, array $queryParams = []) { $response = $this->api->applications()->profiles()->sanitizers()->getById($appId, $profileId, $sanitizerId, $queryParams); return new SanitizerResponse($response); }
php
{ "resource": "" }
q3804
SanitizerService.create
train
public function create($appId, $profileId, SanitizerBuilder $input, array $queryParams = []) { $response = $this->api->applications()->profiles()->sanitizers()->create($appId, $profileId, $input->toArray(), $queryParams); return new SanitizerResponse($response); }
php
{ "resource": "" }
q3805
IgnoredLocationHydrator.hydrateCollection
train
public static function hydrateCollection(array $ignores) { $hydrated = []; foreach ($ignores as $ignore) { $hydrated[] = self::hydrate($ignore); } return $hydrated; }
php
{ "resource": "" }
q3806
IgnoredLocationHydrator.hydrate
train
public static function hydrate(stdClass $ignore) { $hydrated = new IgnoredLocationEntity(); if (isset($ignore->id)) { $hydrated->setId($ignore->id); } if (isset($ignore->path)) { $hydrated->setPath($ignore->path); } if (isset($ignore->match)) { $hydrated->setMatch($ignore->match); } if (isset($ignore->exclude)) { $hydrated->setExclude($ignore->exclude); } return $hydrated; }
php
{ "resource": "" }
q3807
CustomFunctionHydrator.hydrateCollection
train
public static function hydrateCollection(array $customFunctions) { $hydrated = []; foreach ($customFunctions as $customFunction) { $hydrated[] = self::hydrate($customFunction); } return $hydrated; }
php
{ "resource": "" }
q3808
CustomFunctionHydrator.hydrate
train
public static function hydrate(stdClass $customFunction) { $hydrated = new CustomFunctionEntity(); if (isset($customFunction->id)) { $hydrated->setId($customFunction->id); } if (isset($customFunction->start_line)) { $hydrated->setStartLine($customFunction->start_line); } if (isset($customFunction->end_line)) { $hydrated->setEndLine($customFunction->end_line); } if (isset($customFunction->start_column)) { $hydrated->setStartColumn($customFunction->start_column); } if (isset($customFunction->end_column)) { $hydrated->setEndColumn($customFunction->end_column); } if (isset($customFunction->name)) { $hydrated->setName($customFunction->name); } if (isset($customFunction->file)) { $hydrated->setFile(FileHydrator::hydrate($customFunction->file)); } if (isset($customFunction->class)) { $hydrated->setClass(CustomClassHydrator::hydrate($customFunction->class)); } if (isset($customFunction->parameters)) { $hydrated->setParameters($customFunction->parameters); } return $hydrated; }
php
{ "resource": "" }
q3809
IndexViewCompiler.compile
train
public function compile($stub, $modelName, $modelData, stdClass $scaffolderConfig, $hash, ScaffolderThemeExtensionInterface $themeExtension, array $extensions, $extra = null) { if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT))) { return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); } else { $this->stub = $stub; $this->replaceClassName($modelName) ->replaceBreadcrumb($modelName, $modelData->modelLabel) ->addDatatableFields($modelName, $modelData) ->setTableHeaders($modelData) ->replaceRoutePrefix($scaffolderConfig->routing->prefix); $this->stub = $themeExtension->runAfterIndexViewIsCompiled($this->stub, $modelData, $scaffolderConfig); foreach ($extensions as $extension) { $this->stub = $extension->runAfterIndexViewIsCompiled($this->stub, $modelData, $scaffolderConfig); } return $this->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash)); } }
php
{ "resource": "" }
q3810
IndexViewCompiler.addDatatableFields
train
private function addDatatableFields($modelName, $modelData) { $fields = ''; $firstIteration = true; foreach ($modelData->fields as $field) { if ($field->hideInListings === false) { if ($firstIteration) { $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); $firstIteration = false; } else { $fields .= sprintf($this->tab(4) . "{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); } } } $this->stub = str_replace('{{datatable_fields}}', $fields, $this->stub); $this->stub = str_replace('{{datatable_url}}', ucfirst($modelName), $this->stub); return $this; }
php
{ "resource": "" }
q3811
Helpers.getVersionedResourceClassName
train
protected function getVersionedResourceClassName($group, $name) { $class = \str_replace('.', '\\', $name); $version = $this->getVersionNamespace(); return \sprintf('%s\%s\%s\%s', $this->namespace, $group, $version, $class); }
php
{ "resource": "" }
q3812
Helpers.getVersionNamespace
train
protected function getVersionNamespace() { $version = $this->api()->getVersion(); $supported = $this->getSupportedVersionNamespace(); if (isset($supported[$version])) { return $supported[$version]; } return 'Base'; }
php
{ "resource": "" }
q3813
CNabuCatalogItem.getItemsForCatalog
train
static public function getItemsForCatalog($nb_catalog, int $level) { $nb_catalog_id = nb_getMixedValue($nb_catalog, NABU_CATALOG_FIELD_ID); if (is_numeric($nb_catalog_id)) { $retval = CNabuCatalogItem::buildObjectListFromSQL( NABU_CATALOG_ITEM_FIELD_ID, 'SELECT * FROM nb_catalog_item WHERE nb_catalog_id=%catalog_id$d ' . ($level > 0 ? 'AND nb_catalog_item_level<=%level$d ' : '') . 'ORDER BY nb_catalog_item_order ASC', array( 'catalog_id' => $nb_catalog_id, 'level' => $level ), ($nb_catalog instanceof CNabuCatalog ? $nb_catalog : null) ); if ($nb_catalog instanceof CNabuCatalog) { $retval->setCatalog($nb_catalog); } } else { if ($nb_catalog instanceof CNabuCatalog) { $retval = new CNabuCatalogItemList($nb_catalog); $retval->setOwner($nb_catalog); } else { $retval = new CNabuCatalogItemList(); } } return $retval; }
php
{ "resource": "" }
q3814
CNabuCatalogItem.getItemTranslationsForCatalog
train
static public function getItemTranslationsForCatalog($nb_catalog, int $level) { $nb_catalog_id = nb_getMixedValue($nb_catalog, NABU_CATALOG_FIELD_ID); if (is_numeric($nb_catalog_id)) { $retval = CNabuCatalogItemLanguage::buildObjectListFromSQL( null, 'SELECT cil.* FROM nb_catalog_item ci, nb_catalog_item_lang cil WHERE ci.nb_catalog_item_id=cil.nb_catalog_item_id AND ci.nb_catalog_id=%catalog_id$d ' . ($level > 0 ? 'and ci.nb_catalog_item_level<=%level$d ' : '') . 'ORDER BY ci.nb_catalog_item_order, cil.nb_language_id', array( 'catalog_id' => $nb_catalog_id, 'level' => $level ) ); } else { $retval = new CNabuCatalogItemLanguageList(); } return $retval; }
php
{ "resource": "" }
q3815
CNabuCatalogItem.getItems
train
public function getItems(bool $force = false) : CNabuCatalogItemList { if ($this->nb_tree_child_list->isEmpty() || $force) { $this->nb_tree_child_list->merge( CNabuCatalogItem::buildObjectListFromSQL( 'nb_catalog_item_id', 'SELECT * FROM nb_catalog_item WHERE nb_catalog_id=%catalog_id$d AND nb_catalog_item_parent_id=%parent_id$d ORDER BY nb_catalog_item_order ASC', array( 'catalog_id' => $this->getCatalogId(), 'parent_id' => $this->getId() ), $this->getCatalog() ) ); } return $this->nb_tree_child_list; }
php
{ "resource": "" }
q3816
CNabuCatalogTaxonomyBase.getAllCatalogTaxonomies
train
public static function getAllCatalogTaxonomies(CNabuCatalog $nb_catalog) { $nb_catalog_id = nb_getMixedValue($nb_catalog, 'nb_catalog_id'); if (is_numeric($nb_catalog_id)) { $retval = forward_static_call( array(get_called_class(), 'buildObjectListFromSQL'), 'nb_catalog_taxonomy_id', 'select * ' . 'from nb_catalog_taxonomy ' . 'where nb_catalog_id=%catalog_id$d', array( 'catalog_id' => $nb_catalog_id ), $nb_catalog ); } else { $retval = new CNabuCatalogTaxonomyList(); } return $retval; }
php
{ "resource": "" }
q3817
CNabuCatalogTaxonomyBase.setScope
train
public function setScope(string $scope = "O") : CNabuDataObject { if ($scope === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$scope") ); } $this->setValue('nb_catalog_taxonomy_scope', $scope); return $this; }
php
{ "resource": "" }
q3818
CNabuUserGroupMemberBase.setNew
train
public function setNew(string $new = "T") : CNabuDataObject { if ($new === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$new") ); } $this->setValue('nb_user_group_member_new', $new); return $this; }
php
{ "resource": "" }
q3819
CNabuUserGroupMemberBase.setAdmin
train
public function setAdmin(string $admin = "F") : CNabuDataObject { if ($admin === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$admin") ); } $this->setValue('nb_user_group_member_admin', $admin); return $this; }
php
{ "resource": "" }
q3820
CNabuProviderModuleManagerAdapter.setVendorKey
train
public function setVendorKey(string $vendor_key) { if (!nb_isValidKey($vendor_key)) { throw new ENabuProviderException(ENabuProviderException::ERROR_VENDOR_KEY_NOT_VALID, array($vendor_key)); } $this->setValue(self::VENDOR_KEY, $vendor_key); try { $this->getComplexKey(); } catch (ENabuProviderException $ex) { } return $this; }
php
{ "resource": "" }
q3821
CNabuProviderModuleManagerAdapter.setModuleKey
train
public function setModuleKey(string $module_key) { if (!nb_isValidKey($module_key)) { throw new ENabuProviderException(ENabuProviderException::ERROR_MODULE_KEY_NOT_VALID, array($module_key)); } $this->setValue(self::MODULE_KEY, $module_key); try { $this->getComplexKey(); } catch (ENabuProviderException $ex) { } return $this; }
php
{ "resource": "" }
q3822
CNabuUserGroupTypeBase.getAllUserGroupTypes
train
public static function getAllUserGroupTypes(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_user_group_type_id', 'select * ' . 'from nb_user_group_type ' . 'where nb_customer_id=%cust_id$d', array( 'cust_id' => $nb_customer_id ), $nb_customer ); } else { $retval = new CNabuUserGroupTypeList(); } return $retval; }
php
{ "resource": "" }
q3823
CNabuUserGroupTypeBase.setExclusive
train
public function setExclusive(string $exclusive = "F") : CNabuDataObject { if ($exclusive === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$exclusive") ); } $this->setValue('nb_user_group_type_exclusive', $exclusive); return $this; }
php
{ "resource": "" }
q3824
CNabuUserGroupTypeBase.setCreatorOwner
train
public function setCreatorOwner(string $creator_owner = "T") : CNabuDataObject { if ($creator_owner === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$creator_owner") ); } $this->setValue('nb_user_group_type_creator_owner', $creator_owner); return $this; }
php
{ "resource": "" }
q3825
ChildMe.addElementTableAttributes
train
protected function addElementTableAttributes() { $segments = Craft::$app->getRequest()->getSegments(); $actionSegment = $segments[count($segments) - 1] ?? null; $classes = [Entry::class, Category::class]; foreach ($classes as $class) { // Register "Add child" attribute Event::on($class, Element::EVENT_REGISTER_TABLE_ATTRIBUTES, function (RegisterElementTableAttributesEvent $event) use ($actionSegment) { $event->tableAttributes['_childme_addChild'] = $actionSegment !== 'get-elements' ? Craft::t('child-me', 'Add child') : ''; }); // Get the HTML for that attribute Event::on($class, Element::EVENT_SET_TABLE_ATTRIBUTE_HTML, function (SetElementTableAttributeHtmlEvent $event) use ($class) { if ($event->attribute === '_childme_addChild') { $html = ''; switch ($class) { case 'craft\elements\Entry': $entry = $event->sender; if ($entry->section->type !== 'structure') { break; } $maxLevels = $entry->section->maxLevels; $visible = !$maxLevels || $entry->level < $maxLevels; $newUrl = UrlHelper::cpUrl(implode('/', ['entries', $entry->section->handle, 'new']), [ 'typeId' => $entry->type->id, 'parentId' => $entry->id, ]); $html = $this->getElementTableAttributeHtml($newUrl, $visible, [ 'data-section="' . $entry->section->handle . '"', 'data-id="' . $entry->id . '"' ]); break; case 'craft\elements\Category': $category = $event->sender; $maxLevels = $category->group->maxLevels; $visible = !$maxLevels || $category->level < $maxLevels; $newUrl = UrlHelper::cpUrl(implode('/', ['categories', $category->group->handle, 'new']), [ 'parentId' => $category->id, ]); $html = $this->getElementTableAttributeHtml($newUrl, $visible); break; } $event->html = $html; $event->handled = true; } }); } }
php
{ "resource": "" }
q3826
CNabuCommerceProductCategoryLanguageBase.setCommerceProductCategoryId
train
public function setCommerceProductCategoryId(int $nb_commerce_product_category_id) : CNabuDataObject { if ($nb_commerce_product_category_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_commerce_product_category_id") ); } $this->setValue('nb_commerce_product_category_id', $nb_commerce_product_category_id); return $this; }
php
{ "resource": "" }
q3827
CNabuUserGroupBase.getAllUserGroups
train
public static function getAllUserGroups(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_user_group_id', 'select * ' . 'from nb_user_group ' . 'where nb_customer_id=%cust_id$d', array( 'cust_id' => $nb_customer_id ), $nb_customer ); } else { $retval = new CNabuUserGroupList(); } return $retval; }
php
{ "resource": "" }
q3828
CNabuUserGroupBase.setStatus
train
public function setStatus(string $status = "E") : CNabuDataObject { if ($status === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$status") ); } $this->setValue('nb_user_group_status', $status); return $this; }
php
{ "resource": "" }
q3829
CNabuCommerce.newProductCategory
train
public function newProductCategory(string $key = null, int $order = 1) : CNabuCommerceProductCategory { $nb_commerce_product_category = $this->isBuiltIn() ? new CNabuBuiltInCommerceProductCategory() : new CNabuCommerceProductCategory() ; $nb_commerce_product_category->setKey($key); $nb_commerce_product_category->setOrder($order); return $this->addProductCategoryObject($nb_commerce_product_category); }
php
{ "resource": "" }
q3830
CNabuCommerce.addProductCategoryObject
train
public function addProductCategoryObject(CNabuCommerceProductCategory $nb_commerce_product_category) { $nb_commerce_product_category->setCommerce($this); return $this->nb_commerce_product_category_list->addItem($nb_commerce_product_category); }
php
{ "resource": "" }
q3831
CNabuCommerce.getProductCategory
train
public function getProductCategory($nb_commerce_product_category) { $nb_category = false; $nb_category_id = nb_getMixedValue($nb_commerce_product_category, NABU_COMMERCE_PRODUCT_CATEGORY_FIELD_ID); if (is_numeric($nb_category_id)) { $nb_category = $this->nb_commerce_product_category_list->getItem($nb_category_id); } return $nb_category; }
php
{ "resource": "" }
q3832
CNabuCommerce.getProductCategories
train
public function getProductCategories(bool $force = false) : CNabuCommerceProductCategoryList { if ($this->nb_commerce_product_category_list->isEmpty() || $force) { $this->nb_commerce_product_category_list->clear(); $this->nb_commerce_product_category_list->merge( CNabuCommerceProductCategory::getCategoriesForCommerce($this) ); } return $this->nb_commerce_product_category_list; }
php
{ "resource": "" }
q3833
CNabuCommerce.getProducts
train
public function getProducts(bool $force = false) : CNabuCommerceProductList { if ($this->nb_commerce_product_list->isEmpty() || $force) { $this->nb_commerce_product_list->clear(); $this->nb_commerce_product_list->merge( CNabuCommerceProduct::getProductsForCommerce($this) ); } return $this->nb_commerce_product_list; }
php
{ "resource": "" }
q3834
CNabuCommerce.getProduct
train
public function getProduct($nb_commerce_product) { $nb_product = false; $nb_product_id = nb_getMixedValue($nb_commerce_product, NABU_COMMERCE_PRODUCT_FIELD_ID); if (is_numeric($nb_product_id)) { $nb_product = $this->nb_commerce_product_list->getItem($nb_product_id); } return $nb_product; }
php
{ "resource": "" }
q3835
CNabuCommerce.findProductBySlug
train
public function findProductBySlug(string $slug, $nb_language = null) { $retval = false; $nb_language_id = nb_getMixedValue($nb_language, NABU_LANG_FIELD_ID); $this->getProducts()->iterate( function ($key, CNabuCommerceProduct $nb_product) use (&$retval, $slug, $nb_language_id) { if (is_numeric($nb_language_id) && ($nb_translation = $nb_product->getTranslation($nb_language_id)) instanceof CNabuCommerceProductLanguage && $nb_translation->getSlug() === $slug ) { $retval = $nb_product; } else { $nb_product->getTranslations()->iterate( function ($key, CNabuCommerceProductLanguage $nb_translation) use (&$retval, $nb_product, $slug) { if ($nb_translation->getSlug() === $slug) { $retval = $nb_product; } return !$retval; } ); } return !$retval; } ); return $retval; }
php
{ "resource": "" }
q3836
CNabuCommerce.refresh
train
public function refresh(bool $force = false, bool $cascade = false) : bool { return parent::refresh($force, $cascade) && (!$cascade || ( $this->getProductCategories($force) && $this->getProducts($force) )) ; }
php
{ "resource": "" }
q3837
CNabuHTTPServerAdapter.isServerValid
train
public function isServerValid() { return ($this->nb_server !== null && ($this->nb_server->isBuiltIn() || $this->nb_server->isFetched())); }
php
{ "resource": "" }
q3838
CNabuMessagingServiceStackAttachmentBase.setMessagingServiceStackId
train
public function setMessagingServiceStackId(int $nb_messaging_service_stack_id) : CNabuDataObject { if ($nb_messaging_service_stack_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_messaging_service_stack_id") ); } $this->setValue('nb_messaging_service_stack_id', $nb_messaging_service_stack_id); return $this; }
php
{ "resource": "" }
q3839
CNabuRenderTransformFactory.transform
train
public function transform($source) { if ($this->discoverInterface()) { $this->nb_interface->transform($source); } else { throw new ENabuRenderException( ENabuRenderException::ERROR_RENDER_TRANSFORM_NOT_FOUND, array($this->nb_descriptor->getKey()) ); } }
php
{ "resource": "" }
q3840
TNabuSiteChild.getSite
train
public function getSite(CNabuCustomer $nb_customer = null, $force = false) { if ($nb_customer !== null && ($this->nb_site === null || $force)) { $this->nb_site = null; if ($this instanceof CNabuDataObject && $this->contains(NABU_SITE_FIELD_ID)) { $this->nb_site = $nb_customer->getSite($this); } } return $this->nb_site; }
php
{ "resource": "" }
q3841
TNabuSiteChild.setSite
train
public function setSite(CNabuSite $nb_site = null, $field = NABU_SITE_FIELD_ID) { $this->nb_site = $nb_site; if ($this instanceof CNabuDataObject) { $this->transferValue($nb_site, $field); } return $this; }
php
{ "resource": "" }
q3842
Actor.equals
train
public function equals(StatementObject $actor): bool { if (!parent::equals($actor)) { return false; } if (!$actor instanceof Actor) { return false; } if ($this->name !== $actor->name) { return false; } if (null !== $this->iri xor null !== $actor->iri) { return false; } if (null !== $this->iri && null !== $actor->iri && !$this->iri->equals($actor->iri)) { return false; } return true; }
php
{ "resource": "" }
q3843
FileUtils.mkdir
train
public static function mkdir($path, $mode = 0755) { $filesystem = new Filesystem(); try { $filesystem->mkdir($path, $mode); } catch (IOException $exception) { return false; } return true; }
php
{ "resource": "" }
q3844
FileUtils.rmdir
train
public static function rmdir($path) { $files = array_diff(scandir($path), array('.', '..')); $filesystem = new Filesystem(); foreach ($files as $file) { $file = $path . DIRECTORY_SEPARATOR . $file; if (!file_exists($file)) { continue; } try { $filesystem->remove($file); } catch (IOException $exception) { return false; } } return true; }
php
{ "resource": "" }
q3845
FileUtils.detectStream
train
private static function detectStream($path) { $stream = 'file'; if (false !== strpos($path, '://')) { $parts = explode('://', $path); $stream = $parts[0]; } return $stream; }
php
{ "resource": "" }
q3846
LanguageService.getAll
train
public function getAll(array $queryParams = []) { $response = $this->api->languages()->getAll($queryParams); return new LanguagesResponse($response); }
php
{ "resource": "" }
q3847
LanguageService.getById
train
public function getById($languageId, array $queryParams = []) { $response = $this->api->languages()->getById($languageId, $queryParams); return new LanguageResponse($response); }
php
{ "resource": "" }
q3848
CNabuHTTPResponse.calculateFrameOptions
train
private function calculateFrameOptions() { $retval = null; $nb_site = $this->nb_request->getSite(); switch ($nb_site->getXFrameOptions()) { case 'D': $retval = 'DENY'; break; case 'S': $retval = 'SAMEORIGIN'; break; case 'A': if (is_string($url = $nb_site->getXFrameOptionsURL()) && strlen($url = preg_replace(array('/^\s*/', '/\s*$/'), '', $url)) > 0) { $retval = 'ALLOW-FROM ' . $url; } else { throw new ENabuHTTPException(ENabuHTTPException::ERROR_X_FRAME_OPTIONS_URL_NOT_FOUND); } } return $retval; }
php
{ "resource": "" }
q3849
CNabuHTTPResponse.buildHeaders
train
public function buildHeaders() { if ($this->use_cors) { if (strlen($this->cors_allow_origin) > 0) { header("Access-Control-Allow-Origin: $this->cors_allow_origin"); } if ($this->cors_with_credentials) { header('Access-Control-Allow-Credentials: true'); } else { header('Access-Control-Allow-Credentials: false'); } } // Cache Control RFC: https://tools.ietf.org/html/rfc7234 if ($this->nb_request instanceof CNabuHTTPRequest && ($nb_site_target = $this->nb_request->getSiteTarget()) instanceof CNabuSiteTarget ) { if (($max_age = $nb_site_target->getDynamicCacheEffectiveMaxAge()) !== false) { $expire_date = gmdate("D, d M Y H:i:s", time() + $max_age); $this->setHeader('Expires', $expire_date . 'GMT'); $this->setHeader('Cache-Control', "max-age=$max_age"); $this->setHeader('User-Cache-Control', "max-age=$max_age"); $this->setHeader('Pragma', 'cache'); } else { $this->setHeader('Expires', 'Thu, 1 Jan 1981 00:00:00 GMT'); $this->setheader('Cache-Control', 'no-store, no-cache, must-revalidate'); $this->setHeader('Pragma', 'no-cache'); } if ($nb_site_target->getAttachment() === 'T') { if (is_string($this->attachment_filename) && strlen($this->attachment_filename) > 0) { $this->setHeader('Content-Disposition', 'attachment; filename=' . $this->attachment_filename); } else { $this->setHeader('Content-Disposition', 'attachment'); } } } if (($frame_options = $this->calculateFrameOptions()) !== null) { $this->setHeader('X-Frame-Options', $frame_options); } if (count($this->header_list) > 0) { foreach ($this->header_list as $name => $value) { header("$name: $value"); } } }
php
{ "resource": "" }
q3850
CNabuHTTPResponse.getRender
train
public function getRender() { if ($this->render_factory !== null) { $retval = $this->render_factory->getInterface(); } else { $retval = $this->render; } return $retval; }
php
{ "resource": "" }
q3851
CNabuHTTPResponse.redirect
train
public function redirect($code, $nb_site_target, $nb_language = null, $params = null) { global $NABU_HTTP_CODES; if (is_string($nb_site_target)) { $url = new CNabuURL($nb_site_target); if (!$url->isValid()) { $nb_site_target = CNabuSiteTarget::findByKey($this, $nb_site_target); unset($url); } } elseif (is_numeric($nb_site_target)) { $nb_site_target = new CNabuSiteTarget($nb_site_target); if ($nb_site_target->isNew()) { $nb_site_target = null; } } elseif ($nb_site_target instanceof CNabuDataObject) { if (!($nb_site_target instanceof CNabuSiteTarget)) { $nb_site_target = new CNabuSiteTarget($nb_site_target); if ($nb_site_target->isNew()) { $nb_site_target = null; } } } else { $nb_site_target = null; } if ($nb_site_target != null) { $encoded = ''; if ($params != null && count($params) > 0) { foreach ($params as $field => $value) { $encoded .= (strlen($encoded) > 0 ? "&" : "").urlencode($field)."=".urlencode($value); } $encoded = '?'.$encoded; } $nb_language_id = nb_getMixedValue($nb_language, 'nb_language_id'); $nb_site = $this->nb_request->getSite(); if ($nb_language_id == null) { $nb_language_id = $nb_site->getDefaultLanguageId(); } $url = ($nb_site_target instanceof CNabuSiteTarget ? $nb_site_target->getFullyQualifiedURL($nb_language_id) . $encoded : $nb_site_target); throw new ENabuRedirectionException($code, $url); } elseif (isset($url)) { throw new ENabuRedirectionException($code, $url->getURL()); } else { $this->http_response_code = 500; throw new ENabuCoreException(ENabuCoreException::ERROR_REDIRECTION_TARGET_NOT_VALID); } }
php
{ "resource": "" }
q3852
DB.query
train
public function query($q, $params = array()){ try{ if(!empty($this->pdo)){ $this->st = $this->pdo->prepare($q); if(!empty($params)){ $keys = array_keys($params); $qmark = false;//qmark = question mark if(is_int($keys[0])){//mode '?' $qmark = true; } foreach($params as $p => $val){ if($qmark){ //$p is a numeric - 0, 1, 2, ... $p += 1;//bindValue starts to 1 } if(is_array($val) && count($val) == 2){//if called with PDO::PARAM_STR or PDO::PARAM_INT, PDO::PARAM_BOOL $this->st->bindValue($p, $val[0], $val[1]); } else{ if(! is_bool($val)) { //fix fatal error with some php versions $this->st->bindValue($p, $val); } else { $this->st->bindValue($p, $val, PDO::PARAM_INT);//cast } } } } $this->st->execute(); return $this->st; } else{ throw new DBException('PDO attribute is undefined'); } } catch(\Exception $e){ throw new DBException($e->getMessage(), $e->getCode()); } }
php
{ "resource": "" }
q3853
ContextService.getUserInfo
train
public function getUserInfo(array $params) { $this->logger->debug('Get User Info.'); if (array_key_exists("error", $params)) { $this->logger->error( $params["error"].array_key_exists("error_description", $params) ? $params["error_description"] : '' ); throw new Exception('FranceConnect error => '.$params["error"]); } $this->verifyState($params['state']); $accessToken = $this->getAccessToken($params['code']); $userInfo = $this->getInfos($accessToken); $userInfo['access_token'] = $accessToken; $token = new FranceConnectToken($userInfo, [ FranceConnectAuthenticatedVoter::IS_FRANCE_CONNECT_AUTHENTICATED, AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY, ] ); $request = $this->requestStack->getCurrentRequest(); if (null !== $request) { $this->sessionStrategy->onAuthentication($request, $token); } $this->tokenStorage->setToken($token); foreach ($this->providersKeys as $key) { $this->session->set('_security_'.$key, serialize($token)); } return json_encode($userInfo, true); }
php
{ "resource": "" }
q3854
ContextService.verifyState
train
private function verifyState($state) { $this->logger->debug('Verify parameter state.'); $state = urldecode($state); $stateArray = []; parse_str($state, $stateArray); $token = $stateArray['token']; $token = preg_replace('~{~', '', $token, 1); $token = preg_replace('~}~', '', $token, 1); if ($token != $this->session->get(static::OPENID_SESSION_TOKEN)) { $this->logger->error('The value of the parameter STATE is not equal to the one which is expected'); throw new SecurityException("The token is invalid."); } }
php
{ "resource": "" }
q3855
ContextService.getAccessToken
train
private function getAccessToken($code) { $this->logger->debug('Get Access Token.'); $this->initRequest(); $token_url = $this->fcBaseUrl.'token'; $post_data = [ "grant_type" => "authorization_code", "redirect_uri" => $this->callbackUrl, "client_id" => $this->clientId, "client_secret" => $this->clientSecret, "code" => $code, ]; $this->logger->debug('POST Data to FranceConnect.'); $this->setPostFields($post_data); $response = \Unirest\Request::post($token_url); // check status code if ($response->code != Response::HTTP_OK) { $result_array = $response->body; $description = array_key_exists( "error_description", $result_array ) ? $result_array["error_description"] : ''; $this->logger->error( $result_array["error"].$description ); throw new Exception("FranceConnectError".$response->code." msg = ".$response->raw_body); } $result_array = $response->body; $id_token = $result_array['id_token']; $this->session->set(static::ID_TOKEN_HINT, $id_token); $all_part = explode(".", $id_token); $payload = json_decode(base64_decode($all_part[1]), true); // check nonce parameter if ($payload['nonce'] != $this->session->get(static::OPENID_SESSION_NONCE)) { $this->logger->error('The value of the parameter NONCE is not equal to the one which is expected'); throw new SecurityException("The nonce parameter is invalid"); } // verify the signature of jwt $this->logger->debug('Check JWT signature.'); $jws = SimpleJWS::load($id_token); if (!$jws->verify($this->clientSecret)) { $this->logger->error('The signature of the JWT is not valid.'); throw new SecurityException("JWS is invalid"); } $this->session->remove(static::OPENID_SESSION_NONCE); return $result_array['access_token']; }
php
{ "resource": "" }
q3856
ContextService.setPostFields
train
private function setPostFields(array $post_data) { $pd = []; foreach ($post_data as $k => $v) { $pd[] = "$k=$v"; } $pd = implode("&", $pd); \Unirest\Request::curlOpt(CURLOPT_POST, true); \Unirest\Request::curlOpt(CURLOPT_POSTFIELDS, $pd); \Unirest\Request::curlOpt(CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded']); }
php
{ "resource": "" }
q3857
SourceService.getAll
train
public function getAll($appId, $scanId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->sources() ->getAll($appId, $scanId, $queryParams); return new SourcesResponse($response); }
php
{ "resource": "" }
q3858
SourceService.getById
train
public function getById($appId, $scanId, $sourceId, array $queryParams = []) { $response = $this->api ->applications() ->scans() ->sources() ->getById($appId, $scanId, $sourceId, $queryParams); return new SourceResponse($response); }
php
{ "resource": "" }
q3859
InverseFunctionalIdentifier.equals
train
public function equals(InverseFunctionalIdentifier $iri): bool { if (null !== $this->mbox && null !== $iri->mbox && !$this->mbox->equals($iri->mbox)) { return false; } if ($this->mboxSha1Sum !== $iri->mboxSha1Sum) { return false; } if ($this->openId !== $iri->openId) { return false; } if (null === $this->account && null !== $iri->account) { return false; } if (null !== $this->account && null === $iri->account) { return false; } if (null !== $this->account && !$this->account->equals($iri->account)) { return false; } return true; }
php
{ "resource": "" }
q3860
UploadService.getAll
train
public function getAll($appId = null, array $queryParams = []) { $response = $this->api->applications()->uploads()->getAll($appId, $queryParams); return new UploadsResponse($response); }
php
{ "resource": "" }
q3861
UploadService.getById
train
public function getById($appId, $uploadId, array $queryParams = []) { $response = $this->api->applications()->uploads()->getById($appId, $uploadId, $queryParams); return new UploadResponse($response); }
php
{ "resource": "" }
q3862
UploadService.deleteAll
train
public function deleteAll($appId, array $queryParams = []) { $response = $this->api->applications()->uploads()->deleteAll($appId, $queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3863
UploadService.deleteById
train
public function deleteById($appId, $uploadId, array $queryParams = []) { $response = $this->api->applications()->uploads()->deleteById($appId, $uploadId, $queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3864
IgnoredCodeHydrator.hydrate
train
public static function hydrate(stdClass $ignore) { $hydrated = new IgnoredCodeEntity(); if (isset($ignore->id)) { $hydrated->setId($ignore->id); } if (isset($ignore->class)) { $hydrated->setClass($ignore->class); } if (isset($ignore->method)) { $hydrated->setMethod($ignore->method); } if (isset($ignore->exclude)) { $hydrated->setExclude($ignore->exclude); } return $hydrated; }
php
{ "resource": "" }
q3865
AclHydrator.hydrateCollection
train
public static function hydrateCollection(array $acls) { $hydrated = []; foreach ($acls as $acl) { $hydrated[] = self::hydrate($acl); } return $hydrated; }
php
{ "resource": "" }
q3866
CNabuServerHostBase.setServerId
train
public function setServerId(int $nb_server_id) : CNabuDataObject { if ($nb_server_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_server_id") ); } $this->setValue('nb_server_id', $nb_server_id); return $this; }
php
{ "resource": "" }
q3867
CNabuServerHostBase.setIPId
train
public function setIPId(int $nb_ip_id) : CNabuDataObject { if ($nb_ip_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_ip_id") ); } $this->setValue('nb_ip_id', $nb_ip_id); return $this; }
php
{ "resource": "" }
q3868
CNabuServerHostBase.setClusterGroupServiceId
train
public function setClusterGroupServiceId(int $nb_cluster_group_service_id) : CNabuDataObject { if ($nb_cluster_group_service_id === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$nb_cluster_group_service_id") ); } $this->setValue('nb_cluster_group_service_id', $nb_cluster_group_service_id); return $this; }
php
{ "resource": "" }
q3869
CNabuServerHostBase.setPort
train
public function setPort(int $port = 80) : CNabuDataObject { if ($port === null) { throw new ENabuCoreException( ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN, array("\$port") ); } $this->setValue('nb_server_host_port', $port); return $this; }
php
{ "resource": "" }
q3870
CNabuSiteTarget.findByURL
train
public static function findByURL(CNabuSite $nb_site, string $target_url) { $retval = null; if ($nb_site->isPublicBasePathEnabled()) { $check_pbp = CNabuEngine::getEngine()->getMainDB()->getQueryAsSingleField( 'nb_site_lang_public_base_path', "SELECT * FROM nb_site_lang WHERE nb_site_id=%site_id\$d AND length(nb_site_lang_public_base_path) > 0 AND instr('%url\$s', nb_site_lang_public_base_path)=1 LIMIT 1", array( 'site_id' => $nb_site->getId(), 'url' => $target_url ) ); if (strlen($check_pbp) > 0) { $target_url = substr($target_url, strlen($check_pbp)); } else { $target_url = null; } } if ($target_url !== null) { $retval = CNabuSiteTarget::buildObjectFromSQL( "SELECT ca.*, cal.nb_language_id, cal.nb_site_target_lang_url FROM nb_site_target ca, nb_site_target_lang cal, nb_site_lang sl WHERE ca.nb_site_target_id = cal.nb_site_target_id AND ca.nb_site_id=%site_id\$d AND ca.nb_site_id=sl.nb_site_id AND sl.nb_site_lang_enabled='T' AND cal.nb_language_id=sl.nb_language_id AND ca.nb_site_target_url_filter='U' AND cal.nb_site_target_lang_url='%url\$s' LIMIT 1", array('site_id' => $nb_site->getId(), 'url' => $target_url) ) ?? CNabuSiteTarget::buildObjectFromSQL( "SELECT ca.*, cal.nb_language_id, cal.nb_site_target_lang_url FROM nb_site_target ca, nb_site_target_lang cal, nb_site_lang sl WHERE ca.nb_site_target_id = cal.nb_site_target_id AND ca.nb_site_id=%site_id\$d AND ca.nb_site_id=sl.nb_site_id AND sl.nb_site_lang_enabled='T' AND cal.nb_language_id=sl.nb_language_id AND ca.nb_site_target_url_filter='R' AND length(cal.nb_site_target_lang_url)>0 AND '%url\$s' REGEXP cal.nb_site_target_lang_url ORDER BY ca.nb_site_target_order ASC LIMIT 1", array('site_id' => $nb_site->getValue('nb_site_id'), 'url' => $target_url) ) ?? CNabuSiteTarget::buildObjectFromSQL( "SELECT ca.*, cal.nb_language_id, cal.nb_site_target_lang_url FROM nb_site_target ca, nb_site_target_lang cal, nb_site_lang sl WHERE ca.nb_site_target_id = cal.nb_site_target_id AND ca.nb_site_id=%site_id\$d AND ca.nb_site_id=sl.nb_site_id AND sl.nb_site_lang_enabled='T' AND cal.nb_language_id=sl.nb_language_id AND ca.nb_site_target_url_filter='L' AND length(cal.nb_site_target_lang_url)>0 AND '%url\$s' LIKE cal.nb_site_target_lang_url ORDER BY ca.nb_site_target_order ASC LIMIT 1", array('site_id' => $nb_site->getId(), 'url' => $target_url) ) ; } if ($retval !== null) { $retval->setSite($nb_site); } return $retval; }
php
{ "resource": "" }
q3871
CNabuSiteTarget.addCTAObject
train
public function addCTAObject(CNabuSiteTargetCTA $nb_site_target_cta) { $nb_site_target_cta->setSiteTarget($this); return $this->nb_site_target_cta_list->addItem($nb_site_target_cta); }
php
{ "resource": "" }
q3872
CNabuSiteTarget.getCTAs
train
public function getCTAs($force = false) { if ($this->nb_site_target_cta_list->isEmpty() || $force) { $this->nb_site_target_cta_list->clear(); $this->nb_site_target_cta_list->merge(CNabuSiteTargetCTA::getSiteTargetCTAs($this)); $translations = CNabuSiteTargetCTALanguage::getCTATranslationsForSiteTarget($this); if (is_array($translations) && count($translations) > 0) { foreach ($translations as $translation) { $nb_site_target_cta = $this->nb_site_target_cta_list->getItem($translation->getSiteTargetCTAId()); if ($nb_site_target_cta instanceof CNabuSiteTargetCTA) { $nb_site_target_cta->setTranslation($translation); } } } $roles = CNabuSiteTargetCTARole::getCTARolesForSiteTarget($this); if (is_array($roles) && count($roles) > 0) { foreach ($roles as $role) { $nb_site_target_cta = $this->nb_site_target_cta_list->getItem($role->getSiteTargetCTAId()); if ($nb_site_target_cta instanceof CNabuSiteTargetCTA) { $nb_site_target_cta->addRole($role); } } } } return $this->nb_site_target_cta_list; }
php
{ "resource": "" }
q3873
CNabuSiteTarget.getCTAByKey
train
public function getCTAByKey($key, $force = false) { $this->getCTAs($force); return $this->nb_site_target_cta_list->getItem($key, CNabuSiteTargetCTAList::INDEX_KEY); }
php
{ "resource": "" }
q3874
CNabuSiteTarget.getDynamicCacheEffectiveMaxAge
train
public function getDynamicCacheEffectiveMaxAge() { if (($nb_site = $this->getSite()) === null) { throw new ENabuCoreException(ENabuCoreException::ERROR_SITE_NOT_FOUND); } $retval = false; if (($nb_application = CNabuEngine::getEngine()->getApplication()) !== null) { if (($nb_running_site = $nb_application->getRequest()->getSite()) instanceof CNabuSite && ($nb_running_site->getId() === $nb_site->getId()) ) { if (($nb_security_manager = $nb_application->getSecurityManager()) !== null && (!$nb_security_manager->isUserLogged() || $nb_security_manager->arePoliciesAccepted())) { $site_cache_control = $nb_site->getDynamicCacheControl(); $site_max_age = $nb_site->getDynamicCacheDefaultMaxAge(); $target_cache_control = $this->getDynamicCacheControl(); $target_max_age = $this->getDynamicCacheMaxAge(); if ($target_cache_control === self::DYNAMIC_CACHE_CONTROL_INHERITED && $site_cache_control === CNabuSite::DYNAMIC_CACHE_CONTROL_ENABLED && is_numeric($site_max_age) && $site_max_age > 0 ) { $retval = $site_max_age; } elseif ($target_cache_control === self::DYNAMIC_CACHE_CONTROL_ENABLED && is_numeric($target_max_age) && $target_max_age > 0 ) { $retval = $target_max_age; } } } else { throw new ENabuCoreException(ENabuCoreException::ERROR_SITES_DOES_NOT_MATCH); } } else { throw new ENabuCoreException(ENabuCoreException::ERROR_APPLICATION_REQUIRED); } return $retval; }
php
{ "resource": "" }
q3875
CNabuSiteUser.logAccess
train
public function logAccess() { $this->db->executeUpdate( "update nb_site_user " . "set nb_site_user_last_login_datetime=now() " . "where nb_site_id=%site_id\$d " . "and nb_role_id=%role_id\$d " . "and nb_user_id=%user_id\$d", array( 'site_id' => $this->getValue('nb_site_id'), 'role_id' => $this->getValue('nb_role_id'), 'user_id' => $this->getValue('nb_user_id') ) ); }
php
{ "resource": "" }
q3876
CNabuSiteUser.getSitesForUser
train
public static function getSitesForUser($nb_user) { if (is_numeric ($nb_user_id = nb_getMixedValue($nb_user, NABU_USER_FIELD_ID))) { $retval = CNabuSiteUser::buildObjectListFromSQL( 'nb_site_id', 'SELECT su.* FROM nb_site_user su, nb_user u, nb_site s WHERE su.nb_user_id=u.nb_user_id AND su.nb_site_id=s.nb_site_id AND su.nb_user_id=%user_id$d', array( 'user_id' => $nb_user_id ), ($nb_user instanceof CNabuUser ? $nb_user : null) ); } else { $retval = new CNabuSiteUserList(); } return $retval; }
php
{ "resource": "" }
q3877
CNabuSiteUser.getAvailableSitesForUser
train
public static function getAvailableSitesForUser(CNabuCustomer $nb_customer, $nb_user) { if ($nb_customer->isFetched() && is_numeric($nb_user_id = nb_getMixedValue($nb_user, NABU_USER_FIELD_ID)) ) { if (!($nb_user = $nb_customer->getUser($nb_user_id))) { throw new ENabuSecurityException(ENabuSecurityException::ERROR_USER_NOT_ALLOWED); } $retval = CNabuSite::buildObjectListFromSQL( 'nb_site_id', 'SELECT s.*, su.nb_user_id FROM nb_site s LEFT OUTER JOIN nb_site_user su ON s.nb_site_id=su.nb_site_id AND su.nb_user_id=%user_id$d WHERE s.nb_customer_id=%cust_id$d HAVING su.nb_user_id IS NULL', array( 'cust_id' => $nb_customer->getId(), 'user_id' => $nb_user->getId() ), $nb_customer ); } else { $retval = new CNabuSiteList($nb_customer); } return $retval; }
php
{ "resource": "" }
q3878
BaseCommand.writeStatus
train
protected function writeStatus($status, $webExecution) { if ($webExecution) { $cachedStatus = unserialize(Cache::get('scaffolder-status')); array_push($cachedStatus, $status); Cache::forever('scaffolder-status', serialize($cachedStatus)); } else { $this->info($status); } }
php
{ "resource": "" }
q3879
QuotaService.getAll
train
public function getAll(array $queryParams = []) { $response = $this->api->quotas()->getAll($queryParams); return new QuotasResponse($response); }
php
{ "resource": "" }
q3880
QuotaService.create
train
public function create(QuotaBuilder $input, array $queryParams = []) { $response = $this->api->quotas()->create($input->toArray(), $queryParams); return new QuotaResponse($response); }
php
{ "resource": "" }
q3881
QuotaService.update
train
public function update($quotaId, QuotaBuilder $input, array $queryParams = []) { $response = $this->api->quotas()->update($quotaId, $input->toArray(), $queryParams); return new QuotaResponse($response); }
php
{ "resource": "" }
q3882
QuotaService.deleteAll
train
public function deleteAll(array $queryParams = []) { $response = $this->api->quotas()->deleteAll($queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3883
ContextHydrator.hydrateCollection
train
public static function hydrateCollection(array $contexts) { $hydrated = []; foreach ($contexts as $context) { $hydrated[] = self::hydrate($context); } return $hydrated; }
php
{ "resource": "" }
q3884
ContextHydrator.hydrate
train
public static function hydrate(stdClass $context) { $hydrated = new ContextEntity(); if (isset($context->id)) { $hydrated->setId($context->id); } if (isset($context->parts)) { $hydrated->setParts(PartHydrator::hydrateCollection($context->parts)); } return $hydrated; }
php
{ "resource": "" }
q3885
CNabuMessagingServiceBase.findByKey
train
public static function findByKey($nb_messaging, $key) { $nb_messaging_id = nb_getMixedValue($nb_messaging, 'nb_messaging_id'); if (is_numeric($nb_messaging_id)) { $retval = CNabuMessagingService::buildObjectFromSQL( 'select * ' . 'from nb_messaging_service ' . 'where nb_messaging_id=%messaging_id$d ' . "and nb_messaging_service_key='%key\$s'", array( 'messaging_id' => $nb_messaging_id, 'key' => $key ) ); } else { $retval = null; } return $retval; }
php
{ "resource": "" }
q3886
CNabuMessagingServiceBase.getFilteredMessagingServiceList
train
public static function getFilteredMessagingServiceList($nb_messaging = null, $q = null, $fields = null, $order = null, $offset = 0, $num_items = 0) { $nb_messaging_id = nb_getMixedValue($nb_customer, NABU_MESSAGING_FIELD_ID); if (is_numeric($nb_messaging_id)) { $fields_part = nb_prefixFieldList(CNabuMessagingServiceBase::getStorageName(), $fields, false, true, '`'); $order_part = nb_prefixFieldList(CNabuMessagingServiceBase::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_messaging_service ' . 'where ' . NABU_MESSAGING_FIELD_ID . '=%messaging_id$d ' . ($order_part ? "order by $order_part " : '') . ($limit_part ? "limit $limit_part" : ''), array( 'messaging_id' => $nb_messaging_id ) ); } else { $nb_item_list = null; } return $nb_item_list; }
php
{ "resource": "" }
q3887
TNabuCustomerChild.setCustomer
train
public function setCustomer(CNabuCustomer $nb_customer, $field = NABU_CUSTOMER_FIELD_ID) { $this->nb_customer = $nb_customer; if ($this instanceof CNabuDataObject) { if ($nb_customer !== null) { $this->transferValue($nb_customer, NABU_CUSTOMER_FIELD_ID, $field); } else { $this->setValue(NABU_CUSTOMER_FIELD_ID, null); } } return $this; }
php
{ "resource": "" }
q3888
TNabuCustomerChild.validateCustomer
train
public function validateCustomer($nb_customer) { $nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID); return ($this instanceof CNabuDataObject) && (is_numeric($nb_customer_id) || nb_isValidGUID($nb_customer_id)) && $this->isValueEqualThan(NABU_CUSTOMER_FIELD_ID, $nb_customer_id) ; }
php
{ "resource": "" }
q3889
CNabuRenderPoolManager.getRenderFactory
train
public function getRenderFactory(CNabuRenderInterfaceDescriptor $nb_descriptor) { if (!($retval = $this->nb_render_factory_list->getItem($nb_descriptor->getKey()))) { $retval = $this->nb_render_factory_list->addItem(new CNabuRenderFactory($nb_descriptor)); } return $retval; }
php
{ "resource": "" }
q3890
CNabuRenderPoolManager.getTransformFactory
train
public function getTransformFactory(CNabuRenderTransformInterfaceDescriptor $nb_descriptor) { if (!($retval = $this->nb_render_transform_factory_list->getItem($nb_descriptor->getKey()))) { $retval = $this->nb_render_transform_factory_list->addItem(new CNabuRenderTransformFactory($nb_descriptor)); } return $retval; }
php
{ "resource": "" }
q3891
AclService.getById
train
public function getById($quotaId, $aclId, array $queryParams = []) { $response = $this->api->quotas()->acls()->getById($quotaId, $aclId, $queryParams); return new AclResponse($response); }
php
{ "resource": "" }
q3892
AclService.create
train
public function create($quotaId, AclBuilder $input, array $queryParams = []) { $response = $this->api->quotas()->acls()->create($quotaId, $input->toArray(), $queryParams); return new AclResponse($response); }
php
{ "resource": "" }
q3893
AclService.update
train
public function update($quotaId, $aclId, AclBuilder $input, array $queryParams = []) { $response = $this->api->quotas()->acls()->update($quotaId, $aclId, $input->toArray(), $queryParams); return new AclResponse($response); }
php
{ "resource": "" }
q3894
AclService.deleteAll
train
public function deleteAll($quotaId, array $queryParams = []) { $response = $this->api->quotas()->acls()->deleteAll($quotaId, $queryParams); return new BaseResponse($response); }
php
{ "resource": "" }
q3895
CNabuMedioteca.getItems
train
public function getItems($force = false) { if (!$this->isBuiltIn() && ($this->nb_medioteca_item_list->isEmpty() || $force)) { $this->nb_medioteca_item_list = CNabuMediotecaItem::getItemsForMedioteca($this); } return $this->nb_medioteca_item_list; }
php
{ "resource": "" }
q3896
CNabuMedioteca.getItem
train
public function getItem($nb_medioteca_item) { $nb_medioteca_item_id = nb_getMixedValue($nb_medioteca_item, 'nb_medioteca_item_id'); if (is_numeric($nb_medioteca_item_id) || nb_isValidGUID($nb_medioteca_item_id)) { return $this->nb_medioteca_item_list->getItem($nb_medioteca_item_id); } return null; }
php
{ "resource": "" }
q3897
CNabuMedioteca.newItem
train
public function newItem(string $key = null) { $nb_medioteca_item = $this->isBuiltIn() ? new CNabuBuiltInMediotecaItem() : new CNabuMediotecaItem() ; $nb_medioteca_item->setKey($key); return $this->addItemObject($nb_medioteca_item); }
php
{ "resource": "" }
q3898
CNabuMedioteca.findItemByURL
train
public function findItemByURL(string $url, $nb_language = null) { $retval = false; $nb_language_id = nb_getMixedValue($nb_language, NABU_LANG_FIELD_ID); $this->getItems()->iterate( function ($key, CNabuMediotecaItem $nb_item) use (&$retval, $url, $nb_language_id) { if (is_numeric($nb_language_id) && ($nb_translation = $nb_item->getTranslation($nb_language_id)) instanceof CNabuMediotecaItemLanguage && $nb_translation->getURL() === $url ) { $retval = $nb_item; } else { $nb_item->getTranslations()->iterate( function ($key, CNabuMediotecaItemLanguage $nb_translation) use (&$retval, $nb_item, $url) { if ($nb_translation->getURL() === $url) { $retval = $nb_item; } return !$retval; } ); } return !$retval; } ); return $retval; }
php
{ "resource": "" }
q3899
CNabuMedioteca.addItemObject
train
public function addItemObject(CNabuMediotecaItem $nb_medioteca_item) { $nb_medioteca_item->setMedioteca($this); return $this->nb_medioteca_item_list->addItem($nb_medioteca_item); }
php
{ "resource": "" }