_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3 values | text stringlengths 83 13k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q3900 | CNabuMedioteca.getMediotecasForCustomer | train | static public function getMediotecasForCustomer(CNabuCustomer $nb_customer)
{
$nb_customer_id = nb_getMixedValue($nb_customer, NABU_CUSTOMER_FIELD_ID);
if (is_numeric($nb_customer_id)) {
$retval = CNabuMedioteca::buildObjectListFromSQL(
NABU_MEDIOTECA_FIELD_ID,
'select * '
. 'from ' . NABU_MEDIOTECA_TABLE . ' '
. 'where nb_customer_id=%cust_id$d',
array(
'cust_id' => $nb_customer_id
),
$nb_customer
);
} else {
$retval = new CNabuMediotecaList($nb_customer);
}
return $retval;
} | php | {
"resource": ""
} |
q3901 | CNabuMedioteca.refresh | train | public function refresh(bool $force = false, bool $cascade = false) : bool
{
return parent::refresh($force, $cascade) && (!$cascade || $this->getItems($force));
} | php | {
"resource": ""
} |
q3902 | CNabuDomainZoneHostBase.setDomainZoneId | train | public function setDomainZoneId(int $nb_domain_zone_id) : CNabuDataObject
{
if ($nb_domain_zone_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_domain_zone_id")
);
}
$this->setValue('nb_domain_zone_id', $nb_domain_zone_id);
return $this;
} | php | {
"resource": ""
} |
q3903 | PointerPlus.initial_pointers | train | function initial_pointers() {
global $pagenow;
$defaults = array(
'class' => '',
'width' => 300, //only fixed value
'align' => 'middle',
'edge' => 'left',
'post_type' => array(),
'pages' => array(),
'icon_class' => ''
);
$screen = get_current_screen();
$current_post_type = isset( $screen->post_type ) ? $screen->post_type : false;
$search_pt = false;
$pointers = apply_filters( $this->prefix . '-pointerplus_list', array(
// Pointers are added through the 'initial_pointerplus' filter
), $this->prefix );
foreach ( $pointers as $key => $pointer ) {
$pointers[ $key ] = wp_parse_args( $pointer, $defaults );
$search_pt = false;
// Clean from null ecc
$pointers[ $key ][ 'post_type' ] = array_filter( $pointers[ $key ][ 'post_type' ] );
if ( !empty( $pointers[ $key ][ 'post_type' ] ) ) {
if ( !empty( $current_post_type ) ) {
if ( is_array( $pointers[ $key ][ 'post_type' ] ) ) {
// Search the post_type
foreach ( $pointers[ $key ][ 'post_type' ] as $value ) {
if ( $value === $current_post_type ) {
$search_pt = true;
}
}
if ( $search_pt === false ) {
unset( $pointers[ $key ] );
}
} else {
new WP_Error( 'broke', __( 'PointerPlus Error: post_type is not an array!' ) );
}
// If not in CPT view remove all the pointers with post_type
} else {
unset( $pointers[ $key ] );
}
}
// Clean from null ecc
if ( isset( $pointers[ $key ][ 'pages' ] ) ) {
if ( is_array( $pointers[ $key ][ 'pages' ] ) ) {
$pointers[ $key ][ 'pages' ] = array_filter( $pointers[ $key ][ 'pages' ] );
}
if ( !empty( $pointers[ $key ][ 'pages' ] ) ) {
if ( is_array( $pointers[ $key ][ 'pages' ] ) ) {
// Search the page
foreach ( $pointers[ $key ][ 'pages' ] as $value ) {
if ( $pagenow === $value ) {
$search_pt = true;
}
}
if ( $search_pt === false ) {
unset( $pointers[ $key ] );
}
} else {
new WP_Error( 'broke', __( 'PointerPlus Error: pages is not an array!' ) );
}
}
}
}
return $pointers;
} | php | {
"resource": ""
} |
q3904 | PointerPlus.maybe_add_pointers | train | function maybe_add_pointers() {
// Get default pointers that we want to create
$default_keys = $this->initial_pointers();
// Get pointers dismissed by user
$dismissed = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
// Check that our pointers haven't been dismissed already
$diff = array_diff_key( $default_keys, array_combine( $dismissed, $dismissed ) );
// If we have some pointers to show, save them and start enqueuing assets to display them
if ( !empty( $diff ) ) {
$this->pointers = $diff;
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) );
foreach ( $diff as $pointer ) {
if ( isset( $pointer[ 'phpcode' ] ) ) {
add_action( 'admin_notices', $pointer[ 'phpcode' ] );
}
}
}
$this->pointers[ 'l10n' ] = array( 'next' => __( 'Next' ) );
} | php | {
"resource": ""
} |
q3905 | PointerPlus.admin_enqueue_assets | train | function admin_enqueue_assets() {
$base_url = plugins_url( '', __FILE__ );
wp_enqueue_style( $this->prefix, $base_url . '/pointerplus.css', array( 'wp-pointer' ) );
wp_enqueue_script( $this->prefix, $base_url . '/pointerplus.js?var=' . str_replace( '-', '_', $this->prefix ) . '_pointerplus', array( 'wp-pointer' ) );
wp_localize_script( $this->prefix, str_replace( '-', '_', $this->prefix ) . '_pointerplus', apply_filters( $this->prefix . '_pointerplus_js_vars', $this->pointers ) );
} | php | {
"resource": ""
} |
q3906 | PointerPlus._reset_pointer | train | function _reset_pointer( $id = 'me' ) {
if ( $id === 'me' ) {
$id = get_current_user_id();
}
$pointers = explode( ',', get_user_meta( $id, 'dismissed_wp_pointers', true ) );
foreach ( $pointers as $key => $pointer ) {
if ( strpos( $pointer, $this->prefix ) === 0 ) {
unset( $pointers[ $key ] );
}
}
$meta = implode( ',', $pointers );
update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $meta );
} | php | {
"resource": ""
} |
q3907 | CNabuProjectVersionLanguageBase.setProjectVersionId | train | public function setProjectVersionId(int $nb_project_version_id) : CNabuDataObject
{
if ($nb_project_version_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_project_version_id")
);
}
$this->setValue('nb_project_version_id', $nb_project_version_id);
return $this;
} | php | {
"resource": ""
} |
q3908 | CNabuSiteRoleLanguageBase.getSelectRegister | train | public function getSelectRegister()
{
return ($this->isValueNumeric('nb_site_id') && $this->isValueNumeric('nb_role_id') && $this->isValueNumeric('nb_language_id'))
? $this->buildSentence(
'select * '
. 'from nb_site_role_lang '
. "where nb_site_id=%nb_site_id\$d "
. "and nb_role_id=%nb_role_id\$d "
. "and nb_language_id=%nb_language_id\$d "
)
: null;
} | php | {
"resource": ""
} |
q3909 | File.setName | train | public function setName($name)
{
if ( ! is_string($name)) {
throw new \InvalidArgumentException(
__METHOD__."() expects parameter one, name, to be a string"
);
}
if ( ! is_readable($name)) {
throw new \InvalidArgumentException(
__METHOD__."() expects parameter one, name, to be a readable filename"
);
}
$this->name = $name;
return $this;
} | php | {
"resource": ""
} |
q3910 | File.getMaxChunks | train | public function getMaxChunks()
{
return ceil(($this->name !== null ? filesize($this->name) : 0) / $this->size);
} | php | {
"resource": ""
} |
q3911 | File.getChunk | train | protected function getChunk($offset)
{
if ( ! is_numeric($offset) || ! is_int(+$offset) || $offset < 0) {
throw new \InvalidArgumentException(
__METHOD__."() expects parameter one, offset, to be a positive "
. "integer or zero"
);
}
if ($this->name !== null) {
// get the single-byte chunk...
// keep in mind, if file_get_contents() encounters an invalid offset, it
// will return false AND raise an E_WARNING; we don't want the
// E_WARNING, only the false
// also, make sure you floor the offset to 0; negative values will start
// that many bytes from the end of the file
//
$sbChunk = @file_get_contents(
$this->name,
false,
null,
max(0, $offset - self::MAX_SIZE_CHARACTER),
$this->size + self::MAX_SIZE_CHARACTER
);
if ($sbChunk !== false) {
$mbChunk = mb_strcut(
$sbChunk,
min(max(0, $offset), self::MAX_SIZE_CHARACTER),
$this->size,
$this->encoding
);
} else {
// otherwise, a chunk does not exist
$mbChunk = false;
}
} else {
// otherwise, name was empty
$mbChunk = false;
}
return $mbChunk;
} | php | {
"resource": ""
} |
q3912 | CNabuDataObjectListIndex.extractNodes | train | protected function extractNodes(CNabuDataObject $item)
{
$main_index_name = $this->list->getIndexedFieldName();
if (($item->isValueNumeric($main_index_name) || $item->isValueGUID($main_index_name)) &&
($item->isValueString($this->key_field) || $item->isValueNumeric($this->key_field))
) {
$key = $item->getValue($this->key_field);
$retval = array(
'key' => $key,
'pointer' => $item->getValue($main_index_name)
);
if ($item->isValueNumeric($this->order_field) || $item->isValueString($this->order_field)) {
$retval['order'] = $item->getValue($this->order_field);
}
$retval = array($key => $retval);
} else {
$retval = null;
}
return $retval;
} | php | {
"resource": ""
} |
q3913 | CNabuDataObjectListIndex.addItem | train | public function addItem(CNabuDataObject $item)
{
if (is_array($nodes = $this->extractNodes($item)) && count($nodes) > 0) {
if ($this->index === null) {
$this->index = $nodes;
} else {
$this->index = array_merge($this->index, $nodes);
}
}
} | php | {
"resource": ""
} |
q3914 | CNabuProject.getVersions | train | public function getVersions($force = false)
{
if ($this->nb_project_version_list === null) {
$this->nb_project_version_list = new CNabuProjectVersionList();
}
if ($this->nb_project_version_list->isEmpty() || $force) {
$this->nb_project_version_list->clear();
$this->nb_project_version_list->merge(CNabuProjectVersion::getAllProjectVersions($this));
}
return $this->nb_project_version_list;
} | php | {
"resource": ""
} |
q3915 | CNabuIContactProspectDiaryBase.setIcontactProspectId | train | public function setIcontactProspectId(int $nb_icontact_prospect_id) : CNabuDataObject
{
if ($nb_icontact_prospect_id === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$nb_icontact_prospect_id")
);
}
$this->setValue('nb_icontact_prospect_id', $nb_icontact_prospect_id);
return $this;
} | php | {
"resource": ""
} |
q3916 | LicenseService.getAll | train | public function getAll(array $queryParams = [])
{
$response = $this->api->licenses()->getAll($queryParams);
return new LicensesResponse($response);
} | php | {
"resource": ""
} |
q3917 | LicenseService.getById | train | public function getById($appId, array $queryParams = [])
{
$response = $this->api->licenses()->getById($appId, $queryParams);
return new LicenseResponse($response);
} | php | {
"resource": ""
} |
q3918 | StatementFactory.createStatement | train | public function createStatement(): Statement
{
if (null === $this->actor) {
throw new InvalidStateException('A statement actor is missing.');
}
if (null === $this->verb) {
throw new InvalidStateException('A statement verb is missing.');
}
if (null === $this->object) {
throw new InvalidStateException('A statement object is missing.');
}
return new Statement($this->id, $this->actor, $this->verb, $this->object, $this->result, $this->authority, $this->created, $this->stored, $this->context);
} | php | {
"resource": ""
} |
q3919 | CNabuMessagingFactory.discoverServiceInterface | train | private function discoverServiceInterface(CNabuMessagingService $nb_service) : INabuMessagingServiceInterface
{
$retval = false;
$nb_engine = CNabuEngine::getEngine();
if (is_string($interface_name = $nb_service->getInterface())) {
if (is_array($this->nb_service_interface_list) &&
array_key_exists($interface_name, $this->nb_service_interface_list)
) {
$retval = $this->nb_service_interface_list[$interface_name];
} elseif (
is_string($provider_key = $nb_service->getProvider()) &&
count(list($vendor_key, $module_key) = preg_split("/:/", $provider_key)) === 2 &&
($nb_manager = $nb_engine->getProviderManager($vendor_key, $module_key)) instanceof INabuMessagingModule &&
($retval = $nb_manager->createServiceInterface($interface_name)) instanceof INabuMessagingServiceInterface
) {
if (is_array($this->nb_service_interface_list)) {
$this->nb_service_interface_list[$interface_name] = $retval;
} else {
$this->nb_service_interface_list = array($interface_name => $retval);
}
$retval->connect($nb_service);
} else {
throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_SERVICE_INSTANCE);
}
} else {
throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_SERVICE_CLASS_NAME);
}
return $retval;
} | php | {
"resource": ""
} |
q3920 | CNabuMessagingFactory.discoverTemplate | train | private function discoverTemplate($nb_template) : CNabuMessagingTemplate
{
if (!($nb_template instanceof CNabuMessagingTemplate)) {
if (is_numeric($nb_template_id = nb_getMixedValue($nb_template, NABU_MESSAGING_TEMPLATE_FIELD_ID))) {
$nb_template = $this->nb_messaging->getTemplate($nb_template_id);
} elseif (is_string($nb_template_id)) {
$nb_template = $this->nb_messaging->getTemplateByKey($nb_template_id);
}
}
if (!($nb_template instanceof CNabuMessagingTemplate)) {
throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_TEMPLATE);
} elseif ($nb_template->getMessagingId() !== $this->nb_messaging->getId()) {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_TEMPLATE_NOT_ALLOWED,
array($nb_template->getId())
);
}
return $nb_template;
} | php | {
"resource": ""
} |
q3921 | CNabuMessagingFactory.discoverLanguage | train | private function discoverLanguage($nb_language) : CNabuLanguage
{
if (!($nb_language instanceof CNabuLanguage)) {
$nb_language = new CNabuLanguage(nb_getMixedValue($nb_language, NABU_LANG_FIELD_ID));
}
if (!($nb_language instanceof CNabuLanguage) || $nb_language->isNew()) {
throw new ENabuCoreException(ENabuCoreException::ERROR_LANGUAGE_REQUIRED);
}
return $nb_language;
} | php | {
"resource": ""
} |
q3922 | CNabuMessagingFactory.prepareMessageUsingTemplate | train | private function prepareMessageUsingTemplate(
CNabuMessagingTemplate $nb_template,
CNabuLanguage $nb_language,
array $params = null
) : array
{
$nb_engine = CNabuEngine::getEngine();
if (is_string($interface_name = $nb_template->getRenderInterface()) &&
is_string($provider_key = $nb_template->getRenderProvider()) &&
count(list($vendor_key, $module_key) = preg_split("/:/", $provider_key)) === 2 &&
($nb_manager = $nb_engine->getProviderManager($vendor_key, $module_key)) instanceof INabuMessagingModule &&
($nb_interface = $nb_manager->createTemplateRenderInterface($interface_name)) instanceof INabuMessagingTemplateRenderInterface
) {
$nb_interface->setTemplate($nb_template);
$nb_interface->setLanguage($nb_language);
$subject = $nb_interface->createSubject($params);
$body_html = $nb_interface->createBodyHTML($params);
$body_text = $nb_interface->createBodyText($params);
return array($subject, $body_html, $body_text);
} else {
throw new ENabuMessagingException(ENabuMessagingException::ERROR_INVALID_TEMPLATE_RENDER_INSTANCE);
}
} | php | {
"resource": ""
} |
q3923 | CNabuMessagingFactory.postTemplateMessage | train | public function postTemplateMessage(
$nb_template,
$nb_language,
$to = null,
$cc = null,
$bcc = null,
array $params = null,
array $attachments = null
) : bool
{
$nb_template = $this->discoverTemplate($nb_template);
$nb_language = $this->discoverLanguage($nb_language);
list($subject, $body_html, $body_text) = $this->prepareMessageUsingTemplate($nb_template, $nb_language, $params);
return $this->postMessage($nb_template->getActiveServices(), $to, $cc, $bcc, $subject, $body_html, $body_text, $attachments);
} | php | {
"resource": ""
} |
q3924 | CNabuMessagingFactory.sendTemplateMessage | train | public function sendTemplateMessage(
$nb_template,
$to = null,
$cc = null,
$bcc = null,
array $params = null,
array $attachments = null
) : bool
{
$nb_template = $this->discoverTemplate($nb_template);
$nb_language = $this->discoverLanguage($nb_language);
list($subject, $body_html, $body_text) = $this->prepareMessageUsingTemplate($nb_template, $params);
return $this->sendMessage($nb_template->getServices(), $to, $bc, $bcc, $subject, $body_html, $body_text, $attachments);
} | php | {
"resource": ""
} |
q3925 | CNabuMessagingFactory.postMessage | train | public function postMessage(CNabuMessagingServiceList $nb_service_list, $to, $cc, $bcc, $subject, $body_html, $body_text, $attachments) : bool
{
$retval = false;
$nb_service_list->iterate(
function($key, CNabuMessagingService $nb_service)
use (&$retval, $to, $cc, $bcc, $subject, $body_html, $body_text, $attachments)
{
$nb_interface = $this->discoverServiceInterface($nb_service);
$nb_interface->post($to, $cc, $bcc, $subject, $body_html, $body_text, $attachments);
$retval |= true;
return true;
}
);
return $retval;
} | php | {
"resource": ""
} |
q3926 | CNabuMessagingFactory.sendMessage | train | public function sendMessage(CNabuMessagingServiceList $nb_service_list, $to, $cc, $bcc, $subject, $body_html, $body_text, $attachments)
{
$retval = false;
$nb_service_list->iterate(
function($key, CNabuMessagingService $nb_service)
use (&$retval, $to, $cc, $bcc, $subject, $body_html, $body_text, $attachments)
{
$nb_interface = $this->prepareServiceInterface($nb_service);
$nb_interface->send($to, $cc, $bcc, $subject, $body_html, $body_text, $attachments);
$retval |= true;
return true;
});
return $retval;
} | php | {
"resource": ""
} |
q3927 | LibraryService.getAll | train | public function getAll($appId, $scanId, array $queryParams = [])
{
$response = $this->api
->applications()
->scans()
->libraries()
->getAll($appId, $scanId, $queryParams);
return new LibrariesResponse($response);
} | php | {
"resource": ""
} |
q3928 | LibraryService.getById | train | public function getById($appId, $scanId, $libraryId, array $queryParams = [])
{
$response = $this->api
->applications()
->scans()
->libraries()
->getById($appId, $scanId, $libraryId, $queryParams);
return new LibraryResponse($response);
} | php | {
"resource": ""
} |
q3929 | LibraryService.update | train | public function update($appId, $scanId, $libraryId, $input, array $queryParams = [])
{
$response = $this->api
->applications()
->scans()
->libraries()
->update($appId, $scanId, $libraryId, $input->toArray(), $queryParams);
return new LibraryResponse($response);
} | php | {
"resource": ""
} |
q3930 | ApiRouteCompiler.compile | train | public function compile($stub, $modelName, $modelData, stdClass $scaffolderConfig, $hash, array $extensions, $extra = null)
{
$this->stub = $stub;
$this->replaceResource($modelName);
return $this->stub;
} | php | {
"resource": ""
} |
q3931 | ControllerCompiler.setValidations | train | protected function setValidations($modelData)
{
$fields = '';
$firstIteration = true;
foreach ($modelData->fields as $field)
{
if ($firstIteration)
{
$fields .= sprintf("'%s' => '%s'," . PHP_EOL, $field->name, $field->validations);
$firstIteration = false;
}
else
{
$fields .= sprintf($this->tab(3) . "'%s' => '%s'," . PHP_EOL, $field->name, $field->validations);
}
}
$this->stub = str_replace('{{validations}}', $fields, $this->stub);
return $this;
} | php | {
"resource": ""
} |
q3932 | ControllerHydrator.hydrateCollection | train | public static function hydrateCollection(array $controllers)
{
$hydrated = [];
foreach ($controllers as $controller) {
$hydrated[] = self::hydrate($controller);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3933 | ControllerHydrator.hydrate | train | public static function hydrate(stdClass $controller)
{
$hydrated = new ControllerEntity();
if (isset($controller->id)) {
$hydrated->setId($controller->id);
}
if (isset($controller->class)) {
$hydrated->setClass($controller->class);
}
if (isset($controller->method)) {
$hydrated->setMethod($controller->method);
}
if (isset($controller->parameter)) {
$hydrated->setParameter($controller->parameter);
}
if (isset($controller->type)) {
$hydrated->setType($controller->type);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3934 | CNabuSiteMapBase.getAllSiteMaps | train | public static function getAllSiteMaps(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_map_id',
'select * '
. 'from nb_site_map '
. 'where nb_site_id=%site_id$d',
array(
'site_id' => $nb_site_id
),
$nb_site
);
} else {
$retval = new CNabuSiteMapList();
}
return $retval;
} | php | {
"resource": ""
} |
q3935 | CNabuSiteMapBase.getFilteredSiteMapList | train | public static function getFilteredSiteMapList($nb_site, $q = null, $fields = null, $order = null, $offset = 0, $num_items = 0)
{
$nb_site_id = nb_getMixedValue($nb_customer, NABU_SITE_FIELD_ID);
if (is_numeric($nb_site_id)) {
$fields_part = nb_prefixFieldList(CNabuSiteMapBase::getStorageName(), $fields, false, true, '`');
$order_part = nb_prefixFieldList(CNabuSiteMapBase::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_site_map '
. 'where ' . NABU_SITE_FIELD_ID . '=%site_id$d '
. ($order_part ? "order by $order_part " : '')
. ($limit_part ? "limit $limit_part" : ''),
array(
'site_id' => $nb_site_id
)
);
} else {
$nb_item_list = null;
}
return $nb_item_list;
} | php | {
"resource": ""
} |
q3936 | CNabuSiteMapBase.setCustomerRequired | train | public function setCustomerRequired(string $customer_required = "B") : CNabuDataObject
{
if ($customer_required === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$customer_required")
);
}
$this->setValue('nb_site_map_customer_required', $customer_required);
return $this;
} | php | {
"resource": ""
} |
q3937 | CNabuSiteMapBase.setLevel | train | public function setLevel(int $level = 1) : CNabuDataObject
{
if ($level === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$level")
);
}
$this->setValue('nb_site_map_level', $level);
return $this;
} | php | {
"resource": ""
} |
q3938 | CNabuSiteMapBase.setUseURI | train | public function setUseURI(string $use_uri = "N") : CNabuDataObject
{
if ($use_uri === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$use_uri")
);
}
$this->setValue('nb_site_map_use_uri', $use_uri);
return $this;
} | php | {
"resource": ""
} |
q3939 | CNabuSiteMapBase.setOpenPopup | train | public function setOpenPopup(string $open_popup = "F") : CNabuDataObject
{
if ($open_popup === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$open_popup")
);
}
$this->setValue('nb_site_map_open_popup', $open_popup);
return $this;
} | php | {
"resource": ""
} |
q3940 | CNabuSiteMapBase.setVisible | train | public function setVisible(string $visible = "T") : CNabuDataObject
{
if ($visible === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$visible")
);
}
$this->setValue('nb_site_map_visible', $visible);
return $this;
} | php | {
"resource": ""
} |
q3941 | CNabuSiteMapBase.setSeparator | train | public function setSeparator(string $separator = "F") : CNabuDataObject
{
if ($separator === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$separator")
);
}
$this->setValue('nb_site_map_separator', $separator);
return $this;
} | php | {
"resource": ""
} |
q3942 | CNabuSiteMap.addRole | train | public function addRole(CNabuSiteMapRole $nb_role)
{
if ($nb_role->isValueNumeric(NABU_ROLE_FIELD_ID) || $nb_role->isValueGUID(NABU_ROLE_FIELD_ID)) {
$nb_role->setSiteMap($this);
$this->nb_site_map_role_list->addItem($nb_role);
}
return $nb_role;
} | php | {
"resource": ""
} |
q3943 | Definition.equals | train | public function equals(Definition $definition): bool
{
if (get_class($this) !== get_class($definition)) {
return false;
}
if (null !== $this->type xor null !== $definition->type) {
return false;
}
if (null !== $this->type && null !== $definition->type && !$this->type->equals($definition->type)) {
return false;
}
if (null !== $this->moreInfo xor null !== $definition->moreInfo) {
return false;
}
if (null !== $this->moreInfo && null !== $definition->moreInfo && !$this->moreInfo->equals($definition->moreInfo)) {
return false;
}
if (null !== $this->extensions xor null !== $definition->extensions) {
return false;
}
if (null !== $this->name xor null !== $definition->name) {
return false;
}
if (null !== $this->description xor null !== $definition->description) {
return false;
}
if (null !== $this->name) {
if (count($this->name) !== count($definition->name)) {
return false;
}
foreach ($this->name as $language => $value) {
if (!isset($definition->name[$language])) {
return false;
}
if ($value !== $definition->name[$language]) {
return false;
}
}
}
if (null !== $this->description) {
if (count($this->description) !== count($definition->description)) {
return false;
}
foreach ($this->description as $language => $value) {
if (!isset($definition->description[$language])) {
return false;
}
if ($value !== $definition->description[$language]) {
return false;
}
}
}
if (null !== $this->extensions && null !== $definition->extensions && !$this->extensions->equals($definition->extensions)) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q3944 | RouteCompiler.replaceResource | train | protected function replaceResource($modelName)
{
$this->stub = str_replace('{{resource_lw}}', strtolower($modelName), $this->stub);
$this->stub = str_replace('{{resource}}', $modelName, $this->stub);
return $this;
} | php | {
"resource": ""
} |
q3945 | View.getTemplateWebPath | train | public function getTemplateWebPath($file = '',$version = true) {
$webPath = '/assets/';
if(!empty($file) && $version) {
$webPath .= $file.'?'.$this->get_static_version();
}else{
$webPath .= $file;
}
return $webPath;
} | php | {
"resource": ""
} |
q3946 | View.get | train | public function get($key){
return (isset($this->tpl['vars'][$key])) ? $this->tpl['vars'][$key] : null;
} | php | {
"resource": ""
} |
q3947 | View.yields | train | public function yields($yield = self::DEFAULT_YIELD){
if(!empty($this->content_for[$yield])) echo $this->content_for[$yield];
if(!empty($this->tpl['layout']['yields'][$yield]) && file_exists($this->getTemplatePath($this->tpl['layout']['yields'][$yield])))
include $this->getTemplatePath($this->tpl['layout']['yields'][$yield]);
} | php | {
"resource": ""
} |
q3948 | View.isYieldable | train | public function isYieldable($yield = self::DEFAULT_YIELD) {
return (!empty($this->tpl['layout']['yields'][$yield]) && file_exists($this->getTemplatePath($this->tpl['layout']['yields'][$yield])));
} | php | {
"resource": ""
} |
q3949 | View.compute | train | public function compute(){
if(file_exists($this->getTemplatePath($this->tpl['layout']['path']))){
include $this->getTemplatePath($this->tpl['layout']['path']);
}else
echo "Layout does not exists ".$this->tpl['layout']['path'];
} | php | {
"resource": ""
} |
q3950 | CNabuClusterGroupServiceBase.getFilteredClusterGroupServiceList | train | public static function getFilteredClusterGroupServiceList($q = null, $fields = null, $order = null, $offset = 0, $num_items = 0)
{
$fields_part = nb_prefixFieldList(CNabuClusterGroupServiceBase::getStorageName(), $fields, false, true, '`');
$order_part = nb_prefixFieldList(CNabuClusterGroupServiceBase::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_cluster_group_service '
. ($order_part ? "order by $order_part " : '')
. ($limit_part ? "limit $limit_part" : ''),
array(
)
);
return $nb_item_list;
} | php | {
"resource": ""
} |
q3951 | CNabuClusterGroupServiceBase.setUseSSL | train | public function setUseSSL(string $use_ssl = "F") : CNabuDataObject
{
if ($use_ssl === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$use_ssl")
);
}
$this->setValue('nb_cluster_group_service_use_ssl', $use_ssl);
return $this;
} | php | {
"resource": ""
} |
q3952 | CNabuMessagingModuleManagerAdapter.registerServiceInterface | train | protected function registerServiceInterface(INabuMessagingServiceInterface $interface) : bool
{
$hash = $interface->getHash();
if (is_array($this->service_interface_list) && array_key_exists($hash, $this->service_interface_list)) {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_SERVICE_INSTANCE_ALREADY_REGISTERED,
array($hash)
);
}
if ($this->service_interface_list === null) {
$this->service_interface_list = array($hash => $interface);
} else {
$this->service_interface_list[$hash] = $interface;
}
return $interface->init();
} | php | {
"resource": ""
} |
q3953 | CNabuMessagingModuleManagerAdapter.createServiceInterface | train | public function createServiceInterface(string $class_name) : INabuMessagingServiceInterface
{
$nb_engine = CNabuEngine::getEngine();
$nb_descriptor = $nb_engine->getProviderInterfaceDescriptor(
$this->getVendorKey(), $this->getModuleKey(),
CNabuProviderFactory::INTERFACE_MESSAGING_SERVICE, $class_name
);
if ($nb_descriptor instanceof CNabuProviderInterfaceDescriptor) {
$fullname = $nb_descriptor->getNamespace() . "\\services\\$class_name";
if ($nb_engine->preloadClass($fullname)) {
$interface = new $fullname($this);
if ($this->registerServiceInterface($interface)) {
return $interface;
} else {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_SERVICE_CANNOT_BE_INSTANTIATED,
array($class_name)
);
}
} else {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_INVALID_SERVICE_CLASS_NAME, array($class_name)
);
}
} else {
throw new ENabuProviderException(
ENabuProviderException::ERROR_INTERFACE_DESCRIPTOR_NOT_FOUND, array($class_name)
);
}
} | php | {
"resource": ""
} |
q3954 | CNabuMessagingModuleManagerAdapter.registerTemplateRenderInterface | train | protected function registerTemplateRenderInterface(INabuMessagingTemplateRenderInterface $interface) : bool
{
$hash = $interface->getHash();
if (is_array($this->template_render_interface_list) &&
array_key_exists($hash, $this->template_render_interface_list)
) {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_TEMPLATE_RENDER_INSTANCE_ALREADY_REGISTERED,
array($hash)
);
}
if ($this->template_render_interface_list === null) {
$this->template_render_interface_list = array($hash => $interface);
} else {
$this->template_render_interface_list[$hash] = $interface;
}
return $interface->init();
} | php | {
"resource": ""
} |
q3955 | CNabuMessagingModuleManagerAdapter.createTemplateRenderInterface | train | public function createTemplateRenderInterface(string $class_name) : INabuMessagingTemplateRenderInterface
{
$nb_engine = CNabuEngine::getEngine();
$nb_descriptor = $nb_engine->getProviderInterfaceDescriptor(
$this->getVendorKey(), $this->getModuleKey(),
CNabuProviderFactory::INTERFACE_MESSAGING_TEMPLATE_RENDER, $class_name
);
if ($nb_descriptor instanceof CNabuProviderInterfaceDescriptor) {
$fullname = $nb_descriptor->getNamespace() . "\\templates\\renders\\$class_name";
if ($nb_engine->preloadClass($fullname)) {
$interface = new $fullname($this);
if ($this->registerTemplateRenderInterface($interface)) {
return $interface;
} else {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_TEMPLATE_RENDER_CANNOT_BE_INSTANTIATED,
array($class_name)
);
}
} else {
throw new ENabuMessagingException(
ENabuMessagingException::ERROR_INVALID_TEMPLATE_RENDER_CLASS_NAME,
array($class_name)
);
}
} else {
throw new ENabuProviderException(
ENabuProviderException::ERROR_INTERFACE_DESCRIPTOR_NOT_FOUND,
array($class_name)
);
}
} | php | {
"resource": ""
} |
q3956 | CNabuHTTPServerPoolManager.getHTTPServerFactory | train | public function getHTTPServerFactory(CNabuHTTPServerInterfaceDescriptor $nb_descriptor)
{
if (!($retval = $this->nb_http_server_factory_list->getItem($nb_descriptor->getKey()))) {
$retval = $this->nb_http_server_factory_list->addItem(new CNabuHTTPServerFactory($nb_descriptor));
}
return $retval;
} | php | {
"resource": ""
} |
q3957 | SanitizerHydrator.hydrateCollection | train | public static function hydrateCollection(array $sanitizers)
{
$hydrated = [];
foreach ($sanitizers as $sanitizer) {
$hydrated[] = self::hydrate($sanitizer);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3958 | SanitizerHydrator.hydrate | train | public static function hydrate(stdClass $sanitizer)
{
$hydrated = new SanitizerEntity();
if (isset($sanitizer->id)) {
$hydrated->setId($sanitizer->id);
}
if (isset($sanitizer->class)) {
$hydrated->setClass($sanitizer->class);
}
if (isset($sanitizer->method)) {
$hydrated->setMethod($sanitizer->method);
}
if (isset($sanitizer->parameter)) {
$hydrated->setParameter($sanitizer->parameter);
}
if (isset($sanitizer->characters)) {
$hydrated->setCharacters($sanitizer->characters);
}
if (isset($sanitizer->issueType)) {
$hydrated->setIssueType(TypeHydrator::hydrate($sanitizer->issueType));
}
return $hydrated;
} | php | {
"resource": ""
} |
q3959 | SinkService.getAll | train | public function getAll($appId, $profileId, array $queryParams)
{
$response = $this->api->applications()->profiles()->sinks()->getAll($appId, $profileId, $queryParams);
return new SinksResponse($response);
} | php | {
"resource": ""
} |
q3960 | SinkService.getById | train | public function getById($appId, $profileId, $sinkId, array $queryParams = [])
{
$response = $this->api->applications()->profiles()->sinks()->getById($appId, $profileId, $sinkId, $queryParams);
return new SinkResponse($response);
} | php | {
"resource": ""
} |
q3961 | SinkService.create | train | public function create($appId, $profileId, SinkBuilder $input, array $queryParams = [])
{
$response = $this->api->applications()->profiles()->sinks()->create($appId, $profileId, $input->toArray(), $queryParams);
return new SinkResponse($response);
} | php | {
"resource": ""
} |
q3962 | CNabuCommerceBase.getAllCommerces | train | public static function getAllCommerces(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_commerce_id',
'select * '
. 'from nb_commerce '
. 'where nb_customer_id=%cust_id$d',
array(
'cust_id' => $nb_customer_id
),
$nb_customer
);
} else {
$retval = new CNabuCommerceList();
}
return $retval;
} | php | {
"resource": ""
} |
q3963 | CNabuXMLSiteTargetBase.setAttributes | train | protected function setAttributes(SimpleXMLElement $element)
{
$element->addAttribute('GUID', $this->nb_data_object->grantHash(true));
$this->putAttributesFromList($element, array(
'nb_site_target_key' => 'key',
'nb_site_target_order' => 'order',
'nb_site_target_begin_date' => 'beginDate',
'nb_site_target_plugin_name' => 'plugin',
'nb_site_target_php_trace' => 'trace',
'nb_site_target_use_commerce' => 'useCommerce'
), false);
} | php | {
"resource": ""
} |
q3964 | CNabuXMLSiteTargetBase.getChilds | train | protected function getChilds(SimpleXMLElement $element)
{
parent::getChilds($element);
$this->getChildsAsCDATAFromList($element, array(
'nb_site_target_attributes' => 'attributes'
), false);
} | php | {
"resource": ""
} |
q3965 | CNabuXMLSiteTargetBase.setChilds | train | protected function setChilds(SimpleXMLElement $element)
{
parent::setChilds($element);
$this->putChildsAsCDATAFromList($element, array(
'nb_site_target_attributes' => 'attributes'
), false);
} | php | {
"resource": ""
} |
q3966 | IssueHydrator.hydrateCollection | train | public static function hydrateCollection(array $issues)
{
$hydrated = [];
foreach ($issues as $issue) {
$hydrated[] = self::hydrate($issue);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3967 | ClientEntity.setAllowedGrantTypes | train | public function setAllowedGrantTypes($allowedGrantTypes)
{
foreach ($allowedGrantTypes as $allowedGrantType) {
if (!in_array($allowedGrantType, $this->availableGrantTypes)) {
throw new \Exception('Unknown grant type ' . $allowedGrantType);
}
}
$this->allowedGrantTypes = $allowedGrantTypes;
} | php | {
"resource": ""
} |
q3968 | CNabuModuleMorphList.acquireItem | train | protected function acquireItem($key, $index = false)
{
$retval = false;
$nb_engine = CNabuEngine::getEngine();
if ($nb_engine->isMainDBAvailable()) {
$item = new CNabuModuleMorph($key);
if ($item->isFetched()) {
$retval = $item;
}
}
return $retval;
} | php | {
"resource": ""
} |
q3969 | LoginViewCompiler.compile | train | public function compile($stub, $modelName, $modelData, stdClass $scaffolderConfig, $hash, ScaffolderThemeExtensionInterface $themeExtension, array $extensions, $extra = null)
{
$this->stub = $stub;
$this->stub = $themeExtension->runAfterLoginViewIsCompiled($this->stub, $scaffolderConfig);
foreach ($extensions as $extension)
{
$this->stub = $extension->runAfterLoginViewIsCompiled($this->stub, $scaffolderConfig);
}
return $this->store(null, $scaffolderConfig, $this->stub, new FileToCompile(null, null));
} | php | {
"resource": ""
} |
q3970 | RoutesRequests.parseIncomingRequest | train | protected function parseIncomingRequest($request)
{
if (! $request) {
$request = LumenRequest::capture();
}
$this->instance(Request::class, $this->prepareRequest($request));
return [$request->getMethod(), '/'.\trim($request->getPathInfo(), '/')];
} | php | {
"resource": ""
} |
q3971 | RoutesRequests.callActionOnArrayBasedRoute | train | protected function callActionOnArrayBasedRoute($routeInfo)
{
$action = $routeInfo[1];
if (isset($action['uses'])) {
return $this->prepareResponse($this->callControllerAction($routeInfo));
}
foreach ($action as $value) {
if ($value instanceof Closure) {
$closure = $value->bindTo(new RoutingClosure());
break;
}
}
try {
return $this->prepareResponse($this->call($closure, $routeInfo[2]));
} catch (HttpResponseException $e) {
return $e->getResponse();
}
} | php | {
"resource": ""
} |
q3972 | RoutesRequests.prepareResponse | train | public function prepareResponse($response)
{
$request = \app(Request::class);
if ($response instanceof Responsable) {
$response = $response->toResponse($request);
}
if ($response instanceof PsrResponseInterface) {
$response = (new HttpFoundationFactory())->createResponse($response);
} elseif (! $response instanceof SymfonyResponse) {
$response = new Response($response);
} elseif ($response instanceof BinaryFileResponse) {
$response = $response->prepare(Request::capture());
}
return $response->prepare($request);
} | php | {
"resource": ""
} |
q3973 | EntityScanner.scan | train | public function scan($classes, $namespaceTablenames=true, $morphClassAbbreviations=true)
{
$this->namespaceTablenames = $namespaceTablenames;
$this->morphClassAbbreviations = $morphClassAbbreviations;
$metadata = [];
foreach ($classes as $class) {
$entityMetadata = $this->parseClass($class);
if ($entityMetadata) {
$metadata[$class] = $entityMetadata;
}
}
// validate pivot tables
$this->validator->validatePivotTables($metadata);
// generate morphable classes
$this->generateMorphableClasses($metadata);
return $metadata;
} | php | {
"resource": ""
} |
q3974 | EntityScanner.parseClass | train | public function parseClass($class)
{
$reflectionClass = new ReflectionClass($class);
// check if class is entity
if ($this->reader->getClassAnnotation($reflectionClass, '\ProAI\Datamapper\Annotations\Entity')) {
return $this->parseEntity($class);
} else {
return null;
}
} | php | {
"resource": ""
} |
q3975 | EntityScanner.parseEmbeddedClass | train | protected function parseEmbeddedClass($name, Annotation $annotation, EntityDefinition &$entityMetadata, $primaryKeyOnly = false)
{
// check if related class is valid
$annotation->class = $this->getRealEntity($annotation->class, $entityMetadata['class']);
$reflectionClass = new ReflectionClass($annotation->class);
$classAnnotations = $this->reader->getClassAnnotations($reflectionClass);
// check if class is embedded class
$this->validator->validateEmbeddedClass($annotation->class, $classAnnotations);
$embeddedColumnPrefix = ($annotation->columnPrefix || $annotation->columnPrefix === false)
? $annotation->columnPrefix
: $name;
$embeddedClassMetadata = new EmbeddedClassDefinition([
'name' => $name,
'class' => $annotation->class,
'columnPrefix' => $embeddedColumnPrefix,
'attributes' => [],
]);
// scan property annotations
foreach ($reflectionClass->getProperties() as $reflectionProperty) {
$name = $this->getSanitizedName($reflectionProperty->getName(), $entityMetadata['class']);
$propertyAnnotations = $this->reader->getPropertyAnnotations($reflectionProperty);
foreach ($propertyAnnotations as $annotation) {
// property is column
if ($annotation instanceof \ProAI\Datamapper\Annotations\Column) {
$this->setAdditionalColumnProperties($name, $annotation, $propertyAnnotations, true, $embeddedColumnPrefix);
$embeddedClassMetadata['attributes'][] = $this->parseColumn($name, $annotation, $entityMetadata, true, $primaryKeyOnly);
}
}
}
return $embeddedClassMetadata;
} | php | {
"resource": ""
} |
q3976 | EntityScanner.setAdditionalColumnProperties | train | protected function setAdditionalColumnProperties($name, Annotation &$annotation, array $propertyAnnotations, $embedded=false, $columnPrefix=false)
{
// scan for primary and versioned property
foreach ($propertyAnnotations as $subAnnotation) {
// set primary key
if ($subAnnotation instanceof \ProAI\Datamapper\Annotations\Id) {
$annotation->primary = true;
}
// set auto increment
if ($subAnnotation instanceof \ProAI\Datamapper\Annotations\AutoIncrement) {
$annotation->autoIncrement = true;
}
// set auto increment
if ($subAnnotation instanceof \ProAI\Datamapper\Annotations\AutoUuid) {
$annotation->autoUuid = true;
}
// set versioned
if ($subAnnotation instanceof \ProAI\Datamapper\Annotations\Versioned) {
$annotation->versioned = true;
}
}
// set column name
$annotation->name = $this->getColumnName($annotation->name ?: $name, $columnPrefix);
} | php | {
"resource": ""
} |
q3977 | EntityScanner.parseColumn | train | protected function parseColumn($name, Annotation $annotation, EntityDefinition &$entityMetadata, $embedded=false, $primaryKeyOnly = false)
{
if ($annotation->primary == $primaryKeyOnly) {
// set column data
if (! empty($entityMetadata['versionTable']) && $annotation->versioned) {
$entityMetadata['versionTable']['columns'][] = $this->generateColumn($name, $annotation);
} else {
$entityMetadata['table']['columns'][] = $this->generateColumn($name, $annotation);
}
// set up version feature
if (! empty($entityMetadata['versionTable']) && ! $annotation->versioned && $annotation->primary) {
$this->generateVersionTable($name, $annotation, $entityMetadata);
}
}
return $this->generateAttribute($name, $annotation);
} | php | {
"resource": ""
} |
q3978 | EntityScanner.generateColumn | train | protected function generateColumn($name, $annotation)
{
// check if column type is valid
$this->validator->validateColumnType($annotation->type);
// add column
return new ColumnDefinition([
'name' => $annotation->name,
'type' => $annotation->type,
'nullable' => $annotation->nullable,
'default' => $annotation->default,
'primary' => $annotation->primary,
'unique' => $annotation->unique,
'index' => $annotation->index,
'options' => $this->generateAttributeOptionsArray($annotation)
]);
} | php | {
"resource": ""
} |
q3979 | EntityScanner.generateVersionTable | train | protected function generateVersionTable($name, Annotation $annotation, EntityDefinition &$entityMetadata)
{
$annotation = clone $annotation;
$annotation->name ='ref_' . $annotation->name;
$annotation->autoIncrement = false;
// copy primary key to version table
$entityMetadata['versionTable']['columns'][] = $this->generateColumn($name, $annotation);
} | php | {
"resource": ""
} |
q3980 | EntityScanner.generateAttributeOptionsArray | train | protected function generateAttributeOptionsArray(Annotation $annotation)
{
$options = [];
// length option
if ($annotation->type == 'string' || $annotation->type == 'char' || $annotation->type == 'binary') {
$options['length'] = $annotation->length;
}
// fixed option
if ($annotation->type == 'binary' && $annotation->length == 16) {
$options['fixed'] = $annotation->fixed;
$options['autoUuid'] = $annotation->autoUuid;
}
// unsigned and autoIncrement option
if ($annotation->type == 'smallInteger' || $annotation->type == 'integer' || $annotation->type == 'bigInteger') {
$options['unsigned'] = $annotation->unsigned;
$options['autoIncrement'] = $annotation->autoIncrement;
}
// scale and precision option
if ($annotation->type == 'decimal') {
$options['scale'] = $annotation->scale;
$options['precision'] = $annotation->precision;
}
return $options;
} | php | {
"resource": ""
} |
q3981 | EntityScanner.parseRelation | train | protected function parseRelation($name, Annotation $annotation, EntityDefinition &$entityMetadata)
{
// check if relation type is valid
$this->validator->validateRelationType($annotation->type);
// check if we need to add base namespace from configuration
$annotation->relatedEntity = $annotation->relatedEntity
? $this->getRealEntity($annotation->relatedEntity, $entityMetadata['class'])
: null;
$annotation->throughEntity = $annotation->throughEntity
? $this->getRealEntity($annotation->throughEntity, $entityMetadata['class'])
: null;
// change morphedByMany to inverse morphToMany
if ($annotation->type == 'morphedByMany') {
$annotation->type = 'morphToMany';
$annotation->inverse = true;
}
// create extra columns for belongsTo
if ($annotation->type == 'belongsTo') {
$this->generateBelongsToColumns($name, $annotation, $entityMetadata);
}
// create extra columns for morphTo
if ($annotation->type == 'morphTo') {
$this->generateMorphToColumns($name, $annotation, $entityMetadata);
}
$pivotTable = null;
// create pivot table for belongsToMany
if ($annotation->type == 'belongsToMany') {
$pivotTable = $this->generateBelongsToManyPivotTable($name, $annotation, $entityMetadata);
}
// create pivot table for morphToMany
if ($annotation->type == 'morphToMany') {
$pivotTable = $this->generateMorphToManyPivotTable($name, $annotation, $entityMetadata);
}
// add relation
return new RelationDefinition([
'name' => $name,
'type' => $annotation->type,
'relatedEntity' => $annotation->relatedEntity,
'pivotTable' => $pivotTable,
'options' => $this->generateRelationOptionsArray($name, $annotation, $entityMetadata)
]);
} | php | {
"resource": ""
} |
q3982 | EntityScanner.generateBelongsToColumns | train | protected function generateBelongsToColumns($name, Annotation $annotation, EntityDefinition &$entityMetadata)
{
$relatedForeignKey = $annotation->relatedForeignKey ?: $this->generateKey($annotation->relatedEntity);
$entityMetadata['table']['columns'][] = $this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
'name' => $relatedForeignKey,
'primary' => false,
'options' => [
'autoIncrement' => false
]
]);
} | php | {
"resource": ""
} |
q3983 | EntityScanner.generateMorphToColumns | train | protected function generateMorphToColumns($name, Annotation $annotation, EntityDefinition &$entityMetadata)
{
$morphName = (! empty($annotation->morphName))
? $annotation->morphName
: $name;
$morphId = (! empty($annotation->morphId))
? $annotation->morphId
: $morphName.'_id';
$morphType = (! empty($annotation->morphType))
? $annotation->morphType
: $morphName.'_type';
$entityMetadata['table']['columns'][] = $this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
'name' => $morphId,
'primary' => false,
'options' => [
'autoIncrement' => false
]
]);
$entityMetadata['table']['columns'][] = new ColumnDefinition([
'name' => $morphType,
'type' => 'string',
'nullable' => false,
'default' => false,
'primary' => false,
'unique' => false,
'index' => false,
'options' => []
]);
} | php | {
"resource": ""
} |
q3984 | EntityScanner.generateBelongsToManyPivotTable | train | protected function generateBelongsToManyPivotTable($name, Annotation $annotation, EntityDefinition &$entityMetadata)
{
$tableName = ($annotation->pivotTable)
? $annotation->pivotTable
: $this->generatePivotTablename($entityMetadata['class'], $annotation->relatedEntity, $annotation->inverse);
$localPivotKey = $annotation->localForeignKey ?: $this->generateKey($entityMetadata['class']);
$relatedPivotKey = $annotation->relatedForeignKey ?: $this->generateKey($annotation->relatedEntity);
return new TableDefinition([
'name' => $tableName,
'columns' => [
$this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
'name' => $localPivotKey,
'options' => [
'autoIncrement' => false
]
]),
$this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
'name' => $relatedPivotKey,
'options' => [
'autoIncrement' => false
]
]),
]
]);
} | php | {
"resource": ""
} |
q3985 | EntityScanner.generateMorphToManyPivotTable | train | protected function generateMorphToManyPivotTable($name, Annotation $annotation, EntityDefinition &$entityMetadata)
{
$morphName = $annotation->morphName;
$tableName = ($annotation->pivotTable)
? $annotation->pivotTable
: $this->generatePivotTablename($entityMetadata['class'], $annotation->relatedEntity, $annotation->inverse, $morphName);
if ($annotation->inverse) {
$pivotKey = $annotation->localPivotKey ?: $this->generateKey($entityMetadata['class']);
} else {
$pivotKey = $annotation->relatedPivotKey ?: $this->generateKey($annotation->relatedEntity);
}
$morphId = (! empty($annotation->localKey))
? $annotation->localKey
: $morphName.'_id';
$morphType = $morphName.'_type';
return new TableDefinition([
'name' => $tableName,
'columns' => [
$this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
'name' => $pivotKey,
'options' => [
'autoIncrement' => false
]
]),
$this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
'name' => $morphId,
'options' => [
'autoIncrement' => false
]
]),
new ColumnDefinition([
'name' => $morphType,
'type' => 'string',
'nullable' => false,
'default' => false,
'primary' => true,
'unique' => false,
'index' => false,
'options' => []
]),
]
]);
} | php | {
"resource": ""
} |
q3986 | EntityScanner.getModifiedPrimaryKeyColumn | train | protected function getModifiedPrimaryKeyColumn(TableDefinition $tableMetadata, array $data)
{
foreach($tableMetadata['columns'] as $columnMetadata) {
if ($columnMetadata['primary']) {
$modifiedColumnMetadata = clone $columnMetadata;
foreach($data as $key => $value) {
if ($key == 'options') {
$modifiedColumnMetadata[$key] = array_merge($modifiedColumnMetadata[$key], $value);
} else {
$modifiedColumnMetadata[$key] = $value;
}
}
return $modifiedColumnMetadata;
}
}
return false;
} | php | {
"resource": ""
} |
q3987 | EntityScanner.generateMorphableClasses | train | protected function generateMorphableClasses(array &$metadata)
{
foreach ($metadata as $key => $entityMetadata) {
foreach ($entityMetadata['relations'] as $relationKey => $relationMetadata) {
// get morphable classes for morphTo relations
if ($relationMetadata['type'] == 'morphTo') {
$metadata[$key]['relations'][$relationKey]['options']['morphableClasses']
= $this->getMorphableClasses($entityMetadata['class'], $relationMetadata['options']['morphName'], $metadata);
}
// get morphable classes for morphToMany relations
if ($relationMetadata['type'] == 'morphToMany' && ! $relationMetadata['options']['inverse']) {
$metadata[$key]['relations'][$relationKey]['options']['morphableClasses']
= $this->getMorphableClasses($entityMetadata['class'], $relationMetadata['options']['morphName'], $metadata, true);
}
}
}
} | php | {
"resource": ""
} |
q3988 | EntityScanner.getMorphableClasses | train | protected function getMorphableClasses($relatedEntity, $morphName, array $metadata, $many=false)
{
$morphableClasses = [];
foreach ($metadata as $entityMetadata) {
foreach ($entityMetadata['relations'] as $relationMetadata) {
// check relation type
if (! ((! $many && $relationMetadata['type'] == 'morphOne')
|| (! $many && $relationMetadata['type'] == 'morphMany')
|| ($many && $relationMetadata['type'] == 'morphToMany' && $relationMetadata['options']['inverse']))) {
continue;
}
// check foreign entity and morph name
if ($relationMetadata['relatedEntity'] == $relatedEntity
&& $relationMetadata['options']['morphName'] == $morphName) {
$morphableClasses[$entityMetadata['morphClass']] = $entityMetadata['class'];
}
}
}
return $morphableClasses;
} | php | {
"resource": ""
} |
q3989 | EntityScanner.generatePivotTablename | train | protected function generatePivotTablename($class1, $class2, $inverse, $morph=null)
{
// datamapper namespace tables
if ($this->namespaceTablenames) {
$base = ($inverse)
? $this->generateTableName($class1, true)
: $this->generateTableName($class2, true);
$related = (! empty($morph))
? $morph
: (! empty($inverse)
? snake_case(class_basename($class2))
: snake_case(class_basename($class1)));
return $base . '_' . $related . '_pivot';
}
// eloquent default
$base = snake_case(class_basename($class1));
$related = snake_case(class_basename($class2));
$models = array($related, $base);
sort($models);
return strtolower(implode('_', $models));
} | php | {
"resource": ""
} |
q3990 | EntityScanner.generateTableName | train | protected function generateTableName($class)
{
// datamapper namespace tables
if ($this->namespaceTablenames) {
$className = array_slice(explode('/', str_replace('\\', '/', $class)), 2);
// delete last entry if entry is equal to the next to last entry
if (count($className) >= 2 && end($className) == prev($className)) {
array_pop($className);
}
$classBasename = array_pop($className);
return strtolower(implode('_', array_merge($className, preg_split('/(?<=\\w)(?=[A-Z])/', $classBasename))));
}
// eloquent default
return str_replace('\\', '', snake_case(str_plural(class_basename($class))));
} | php | {
"resource": ""
} |
q3991 | EntityScanner.getColumnName | train | protected function getColumnName($name, $prefix = false)
{
$name = snake_case($name);
if ($prefix) {
$name = $prefix.'_'.$name;
}
return $name;
} | php | {
"resource": ""
} |
q3992 | CensusHydrator.hydrateCollection | train | public static function hydrateCollection(array $censuses)
{
$hydrated = [];
foreach ($censuses as $census) {
$hydrated[] = self::hydrate($census);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3993 | CensusHydrator.hydrate | train | public static function hydrate(stdClass $census)
{
$hydrated = new CensusEntity();
if (isset($census->id)) {
$hydrated->setId($census->id);
}
if (isset($census->scans)) {
$hydrated->setScans($census->scans);
}
if (isset($census->issues)) {
$hydrated->setIssues($census->issues);
}
if (isset($census->loc)) {
$hydrated->setLoc($census->loc);
}
return $hydrated;
} | php | {
"resource": ""
} |
q3994 | CNabuSiteBase.getAllSites | train | public static function getAllSites(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_site_id',
'select * '
. 'from nb_site '
. 'where nb_customer_id=%cust_id$d',
array(
'cust_id' => $nb_customer_id
),
$nb_customer
);
} else {
$retval = new CNabuSiteList();
}
return $retval;
} | php | {
"resource": ""
} |
q3995 | CNabuSiteBase.setMountingOrder | train | public function setMountingOrder(int $mounting_order = 0) : CNabuDataObject
{
if ($mounting_order === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$mounting_order")
);
}
$this->setValue('nb_site_mounting_order', $mounting_order);
return $this;
} | php | {
"resource": ""
} |
q3996 | CNabuSiteBase.setPublished | train | public function setPublished(string $published = "F") : CNabuDataObject
{
if ($published === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$published")
);
}
$this->setValue('nb_site_published', $published);
return $this;
} | php | {
"resource": ""
} |
q3997 | CNabuSiteBase.setPublicBasePathEnabled | train | public function setPublicBasePathEnabled(string $public_base_path_enabled = "F") : CNabuDataObject
{
if ($public_base_path_enabled === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$public_base_path_enabled")
);
}
$this->setValue('nb_site_public_base_path_enabled', $public_base_path_enabled);
return $this;
} | php | {
"resource": ""
} |
q3998 | CNabuSiteBase.setDefaultTargetUseURI | train | public function setDefaultTargetUseURI(string $default_target_use_uri = "N") : CNabuDataObject
{
if ($default_target_use_uri === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$default_target_use_uri")
);
}
$this->setValue('nb_site_default_target_use_uri', $default_target_use_uri);
return $this;
} | php | {
"resource": ""
} |
q3999 | CNabuSiteBase.setDefaultErrorCode | train | public function setDefaultErrorCode(int $default_error_code = 301) : CNabuDataObject
{
if ($default_error_code === null) {
throw new ENabuCoreException(
ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
array("\$default_error_code")
);
}
$this->setValue('nb_site_default_error_code', $default_error_code);
return $this;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.