idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
48,700
public function getNotificationsActivities ( AccountInterface $ account , array $ status = [ ACTIVITY_STATUS_RECEIVED ] ) { $ ids = $ this -> getNotificationIds ( $ account , $ status ) ; return entity_load_multiple ( 'activity' , $ ids ) ; }
Returns the Activity objects with destination notification for account .
48,701
public function markAllNotificationsAsSeen ( AccountInterface $ account ) { $ ids = $ this -> getNotificationIds ( $ account , [ ACTIVITY_STATUS_RECEIVED ] ) ; foreach ( $ ids as $ activity_id ) { $ activity = Activity :: load ( $ activity_id ) ; $ this -> changeStatusOfActivity ( $ activity , ACTIVITY_STATUS_SEEN ) ; ...
Mark all notifications as Seen for account .
48,702
public function markEntityNotificationsAsRead ( AccountInterface $ account , Entity $ entity ) { $ ids = $ this -> getNotificationIds ( $ account , [ ACTIVITY_STATUS_RECEIVED , ACTIVITY_STATUS_SEEN ] , $ entity ) ; foreach ( $ ids as $ activity_id ) { $ activity = Activity :: load ( $ activity_id ) ; $ this -> changeSt...
Mark Notifications as Read for given account and entity ..
48,703
public function changeStatusOfActivity ( Activity $ activity , $ status = ACTIVITY_STATUS_RECEIVED ) { $ activity -> set ( 'field_activity_status' , $ status ) ; return $ activity -> save ( ) ; }
Change the status of an activity .
48,704
private function getNotificationIds ( AccountInterface $ account , array $ status = [ ] , Entity $ entity = NULL ) { $ destinations = [ 'notifications' ] ; $ uid = $ account -> id ( ) ; $ entity_query = \ Drupal :: entityQuery ( 'activity' ) ; $ entity_query -> condition ( 'field_activity_recipient_user' , $ uid , '=' ...
Returns the Activity ids for an account with destination notification .
48,705
public function enrollAccess ( NodeInterface $ node ) { $ config = $ this -> config ( 'social_event_an_enroll.settings' ) ; $ is_global_enabled = $ config -> get ( 'event_an_enroll' ) ; $ is_event = $ node -> getType ( ) === 'event' ; $ is_public = $ node -> get ( 'field_content_visibility' ) -> getString ( ) === 'publ...
Determines if user has access to enroll form .
48,706
public function enrollDialog ( NodeInterface $ node ) { $ action_links = [ 'login' => [ 'uri' => Url :: fromRoute ( 'user.login' , [ ] , [ 'query' => [ 'destination' => Url :: fromRoute ( 'entity.node.canonical' , [ 'node' => $ node -> id ( ) ] ) -> toString ( ) , ] , ] ) -> toString ( ) , ] , 'register' => [ 'uri' => ...
Enroll dialog callback .
48,707
public function enrollManageAccess ( AccountInterface $ account ) { if ( AccessResult :: allowedIfHasPermission ( $ account , 'manage all enrollments' ) -> isAllowed ( ) ) { return AccessResult :: allowed ( ) ; } else { $ node = $ this -> routeMatch -> getParameter ( 'node' ) ; if ( ! is_null ( $ node ) && ( ! is_objec...
Checks access for manage enrollment page .
48,708
protected function getUnselectedFields ( ) { $ profile_fields = $ this -> fieldStorage -> loadByProperties ( [ 'entity_type' => 'profile' , 'bundle' => 'profile' ] ) ; $ settings = $ this -> configFactory -> get ( 'social_profile_fields.settings' ) ; $ empty = [ ] ; foreach ( $ profile_fields as $ key => $ value ) { $ ...
Function that return an array of field names .
48,709
protected function addFilterOverride ( $ text_format , $ convert_url , array & $ overrides ) { $ config_name = 'filter.format.' . $ text_format ; $ config = $ this -> configFactory -> getEditable ( $ config_name ) ; $ filters = $ config -> get ( 'filters' ) ; $ overrides = [ ] ; $ overrides [ $ config_name ] [ 'depende...
Alters the filter settings for the text format .
48,710
protected function addEditorOverride ( $ text_format , array & $ overrides ) { $ config_name = 'editor.editor.' . $ text_format ; $ config = $ this -> configFactory -> getEditable ( $ config_name ) ; $ settings = $ config -> get ( 'settings' ) ; if ( empty ( $ settings ) || ! isset ( $ settings [ 'toolbar' ] [ 'rows' ]...
Alters the editor settings for the text format .
48,711
public static function getEntityAccessResult ( NodeInterface $ node , $ op , AccountInterface $ account ) { $ access = self :: nodeAccessCheck ( $ node , $ op , $ account ) ; switch ( $ access ) { case 2 : return AccessResult :: allowed ( ) -> cachePerPermissions ( ) -> addCacheableDependency ( $ node ) ; case 1 : retu...
Gets the Entity access for the given node .
48,712
public static function processDropdown ( & $ element , FormStateInterface $ form_state , & $ complete_form ) { if ( count ( $ element [ '#options' ] ) > 0 ) { $ weight = 0 ; foreach ( $ element [ '#options' ] as $ key => $ option ) { $ value = HtmlUtility :: escape ( $ option [ 'value' ] ) ; $ label = HtmlUtility :: es...
Expands a radios element into individual radio elements .
48,713
protected function prepareTerms ( array $ values ) { $ terms = [ ] ; foreach ( $ values as $ uuid ) { $ term = $ this -> termStorage -> loadByProperties ( [ 'uuid' => $ uuid , ] ) ; $ term = reset ( $ term ) ; if ( ! empty ( $ term ) ) { $ terms [ ] = [ 'target_id' => $ term -> id ( ) , ] ; } } return $ terms ; }
Returns taxonomy terms for UUIDs .
48,714
protected function fillProfile ( ProfileInterface $ profile , array $ item ) { $ profile -> field_profile_image = $ item [ 'image' ] ; $ profile -> field_profile_first_name = $ item [ 'first_name' ] ; $ profile -> field_profile_last_name = $ item [ 'last_name' ] ; $ profile -> field_profile_organization = $ item [ 'org...
Fills the some fields of a profile .
48,715
public function getGuestName ( EventEnrollmentInterface $ entity , $ email = TRUE ) { $ parts = [ ] ; if ( ! social_event_manager_or_organizer ( ) ) { return $ this -> t ( 'Guest' ) ; } if ( ! $ entity -> field_first_name -> isEmpty ( ) ) { $ parts [ ] = $ entity -> field_first_name -> value ; } if ( ! $ entity -> fiel...
Returns guest name .
48,716
public function access ( AccountInterface $ account , RouteMatch $ route_match ) { if ( $ account -> hasPermission ( 'manage everything enrollments' ) ) { return AccessResult :: allowed ( ) ; } else { $ node = $ route_match -> getParameter ( 'node' ) ; if ( ! $ node instanceof NodeInterface ) { $ node = $ this -> entit...
Checks access for manage all enrollment page .
48,717
public static function renderLinks ( $ post_entity_id , $ view_mode , $ langcode , $ is_in_preview ) { $ links = [ '#theme' => 'links' , '#pre_render' => [ 'drupal_pre_render_links' ] , '#attributes' => [ 'class' => [ 'links' , 'inline' ] ] , ] ; if ( ! $ is_in_preview ) { $ entity = Post :: load ( $ post_entity_id ) -...
Lazy_builder callback ; builds a post s links .
48,718
public function query ( ) { $ group = \ Drupal :: routeMatch ( ) -> getParameter ( 'group' ) ; $ this -> query -> addTable ( 'post__field_visibility' ) ; $ this -> query -> addTable ( 'post__field_recipient_group' ) ; $ recipient_condition = db_and ( ) ; $ recipient_condition -> condition ( 'post__field_visibility.fiel...
Query for the activity stream on the group pages .
48,719
public static function performFlush ( array $ pids , array $ fields , array & $ context ) { $ message = 'Flushing profile data...' ; $ results = [ ] ; foreach ( $ pids as $ pid ) { $ profile = Profile :: load ( $ pid ) ; foreach ( $ fields as $ field_name ) { if ( $ profile -> hasField ( $ field_name ) ) { $ profile ->...
Perform the flush .
48,720
public function performFlushFinishedCallback ( $ success , array $ results , $ operations ) { if ( $ success ) { $ message = \ Drupal :: translation ( ) -> formatPlural ( count ( $ results ) , 'One profile flushed.' , '@count profiles flushed.' ) ; $ indexes = Index :: loadMultiple ( [ 'social_all' , 'social_users' ] )...
Message when done .
48,721
public function userLoginCallback ( ) { $ sdk = $ this -> getSdk ( 'login' ) ; if ( $ sdk instanceof RedirectResponse ) { return $ sdk ; } $ this -> authManager -> setSdk ( $ sdk ) ; $ profile = $ this -> getProfile ( 'login' ) ; if ( $ profile instanceof RedirectResponse ) { return $ profile ; } $ account = $ this -> ...
Authorizes the user after redirect from Facebook .
48,722
public function userRegisterCallback ( ) { $ sdk = $ this -> getSdk ( 'register' ) ; if ( $ sdk instanceof RedirectResponse ) { return $ sdk ; } $ this -> authManager -> setSdk ( $ sdk ) ; $ profile = $ this -> getProfile ( 'register' ) ; if ( $ profile instanceof RedirectResponse ) { return $ profile ; } $ account = $...
Registers the new account after redirect from Facebook .
48,723
public static function preRenderAccountHeaderElement ( array $ item ) { $ children = Element :: children ( $ item , TRUE ) ; $ link_attributes = [ ] ; $ link_text = [ ] ; if ( ! empty ( $ children ) ) { $ link_attributes = [ "data-toggle" => "dropdown" , "aria-expanded" => "true" , "aria-haspopup" => "true" , "role" =>...
Returns an array that can be provided as an item in an item_list .
48,724
public function quickJoin ( GroupInterface $ group ) { if ( ! $ group instanceof GroupInterface ) { return new RedirectResponse ( Url :: fromRoute ( '<front>' ) -> toString ( ) ) ; } $ groupRedirect = $ group -> toUrl ( ) -> toString ( ) ; $ active = $ this -> configFactory -> get ( 'social_group_quickjoin.settings' ) ...
Function that add the current user to a group without confirmation step .
48,725
public function accessDenied ( ) { $ frontpage = $ this -> config ( 'system.site' ) -> get ( 'page.front' ) ; $ text = $ this -> t ( "<p>You have insufficient permissions to view the page you're trying to access. There could be several reasons for this:</p><ul><li>You are trying to edit content you're not allowed to ed...
Custom function for returning markup on the access denied page .
48,726
protected function getCollectionRoute ( EntityTypeInterface $ entity_type ) { if ( $ entity_type -> hasLinkTemplate ( 'collection' ) && $ entity_type -> hasListBuilderClass ( ) ) { $ entity_type_id = $ entity_type -> id ( ) ; $ route = new Route ( $ entity_type -> getLinkTemplate ( 'collection' ) ) ; $ route -> setDefa...
Gets the collection route .
48,727
protected function getSettingsFormRoute ( EntityTypeInterface $ entity_type ) { if ( ! $ entity_type -> getBundleEntityType ( ) ) { $ route = new Route ( "/admin/structure/{$entity_type->id()}/settings" ) ; $ route -> setDefaults ( [ '_form' => 'Drupal\social_font\Form\FontSettingsForm' , '_title' => "{$entity_type->ge...
Gets the settings form route .
48,728
public function whiteList ( $ text ) { $ patterns = $ this -> getPatterns ( ) ; foreach ( $ patterns as $ pattern ) { $ testing_pattern = '/' . $ pattern . '/' ; if ( preg_match ( $ testing_pattern , $ text ) ) { return TRUE ; } } return FALSE ; }
Checks if item is on the whitelist .
48,729
public function onboardingEnabled ( ) { if ( $ this -> configFactory -> get ( 'social_tour_enabled' ) == FALSE ) { return FALSE ; } if ( ! $ this -> currentUser -> hasPermission ( 'access tour' ) ) { return FALSE ; } if ( $ this -> userData -> get ( 'social_tour' , $ this -> currentUser -> id ( ) , 'onboarding_disabled...
Check if onboarding is enabled .
48,730
public function toggleOnboarding ( array $ account = NULL ) { $ id = $ this -> currentUser -> id ( ) ; if ( $ account instanceof User ) { $ id = $ account -> id ( ) ; } $ new_value = TRUE ; if ( $ this -> userData -> get ( 'social_tour' , $ id , 'onboarding_disabled' ) == TRUE ) { $ new_value = FALSE ; } $ this -> setD...
Toggle onboarding .
48,731
public function disableOnboarding ( ) { $ this -> setData ( TRUE ) ; $ redirect = \ Drupal :: request ( ) -> get ( 'destination' ) ? : '/stream' ; drupal_set_message ( $ this -> t ( 'You will not see tips like this anymore.' ) ) ; return new RedirectResponse ( $ redirect ) ; }
Disable onboarding for current_user by Ajax call .
48,732
private function setData ( $ disabled = TRUE ) { $ this -> userData -> set ( 'social_tour' , $ this -> currentUser -> id ( ) , 'onboarding_disabled' , $ disabled ) ; }
Set onboarding data value .
48,733
protected function getEventsCount ( ) { $ query = $ this -> connection -> select ( 'node_field_data' , 'n' ) ; $ query -> addExpression ( 'COUNT(*)' ) ; $ query -> condition ( 'n.type' , 'event' ) ; $ query -> condition ( 'n.status' , 1 ) ; return $ query -> execute ( ) -> fetchField ( ) ; }
Get total count of events .
48,734
protected function getGroupsCount ( ) { $ query = $ this -> connection -> select ( 'groups' , 'g' ) ; $ query -> addExpression ( 'COUNT(*)' ) ; return $ query -> execute ( ) -> fetchField ( ) ; }
Get total count of groups .
48,735
public function getRecipientOrganizerFromEntity ( array $ related_entity , array $ data ) { $ recipients = [ ] ; $ original_related_object = $ data [ 'related_object' ] [ 0 ] ; if ( isset ( $ original_related_object [ 'target_type' ] ) && $ original_related_object [ 'target_type' ] === 'event_enrollment' && $ related_e...
Returns Organizer recipient from Events .
48,736
public function checkAccess ( array $ tree ) { if ( $ this -> account -> id ( ) != 1 ) { $ account_roles = $ this -> account -> getRoles ( ) ; $ routes = [ 'contentmanager' => [ 'config' => 'system.admin_config' , 'reports' => 'system.admin_reports' , 'help' => 'help.main' , ] , 'sitemanager' => [ 'help' => 'help.main'...
Performs access checks of a menu tree .
48,737
public function renderForm ( ) { $ menu_tree = \ Drupal :: service ( 'toolbar.menu_tree' ) ; $ parameters = new MenuTreeParameters ( ) ; $ parameters -> setRoot ( 'system.admin' ) -> excludeRoot ( ) -> setMaxDepth ( 4 ) -> onlyEnabledLinks ( ) ; $ manipulators = [ [ 'callable' => 'menu.default_tree_manipulators:checkAc...
Renders the toolbar s administration tray .
48,738
public function isValidEntity ( $ entity ) { if ( $ entity -> getEntityTypeId ( ) === 'mentions' ) { return TRUE ; } $ allowed_content_types = [ 'comment' , ] ; if ( in_array ( $ entity -> getEntityTypeId ( ) , $ allowed_content_types ) ) { $ mentions = $ this -> getMentionsFromRelatedEntity ( $ entity ) ; if ( ! empty...
Check for valid entity .
48,739
public function getMentionsFromRelatedEntity ( $ entity ) { if ( $ entity -> getEntityTypeId ( ) === 'comment' ) { if ( $ entity -> getParentComment ( ) ) { $ entity = $ entity -> getParentComment ( ) ; } } $ mentions = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'mentions' ) -> loadByProperties ( [ 'entity_type'...
Get the mentions from the related entity .
48,740
protected function createQueueItem ( $ queue_name , $ data ) { $ queue = \ Drupal :: queue ( $ queue_name ) ; $ queue -> createItem ( $ data ) ; }
Simple reporter log and display information about the queue .
48,741
public function query ( ) { $ order = ( $ this -> view -> exposed_data [ "{$this->realField}_op" ] == '>=' ) ? 'ASC' : 'DESC' ; $ this -> query -> addOrderBy ( $ this -> tableAlias , $ this -> realField , $ order ) ; }
Called to add the sort to a query .
48,742
public function createMessages ( Entity $ entity , $ action ) { $ message_types = $ this -> getMessageTypes ( $ action , $ entity ) ; foreach ( $ message_types as $ message_type => $ message_values ) { $ destinations = [ ] ; if ( ! empty ( $ message_values [ 'destinations' ] ) && is_array ( $ message_values [ 'destinat...
Create message entities .
48,743
public function getMessageTypes ( $ action , Entity $ entity ) { $ messagetypes = [ ] ; $ entity_type_manager = \ Drupal :: service ( 'entity_type.manager' ) ; $ message_storage = $ entity_type_manager -> getStorage ( 'message_template' ) ; foreach ( $ message_storage -> loadByProperties ( [ 'status' => '1' ] ) as $ ke...
Get message templates for action and entity .
48,744
protected function createFieldInstances ( $ message_type , array $ fields ) { foreach ( $ fields as $ field ) { $ id = 'message.' . $ message_type . '.' . $ field [ 'name' ] ; $ config_storage = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'field_config' ) ; if ( $ config_storage -> load ( $ id ) === NULL ) { $ fi...
Create field instances .
48,745
public function checkIfMessageExist ( $ message_type , $ context , array $ destination , array $ related_object , $ uid ) { $ exists = FALSE ; $ query = \ Drupal :: entityQuery ( 'message' ) ; $ query -> condition ( 'template' , $ message_type ) ; $ query -> condition ( 'field_message_related_object.target_id' , $ rela...
Checks if a message already exists .
48,746
public function hasContent ( ) { if ( count ( $ this -> getCategories ( ) ) == 0 ) { return FALSE ; } if ( count ( $ this -> getAllChildren ( ) ) == 0 ) { return FALSE ; } return TRUE ; }
Returns if there are any taxonomy items available .
48,747
public function getCategories ( ) { $ options = [ ] ; foreach ( $ this -> termStorage -> loadTree ( 'social_tagging' , 0 , 1 ) as $ category ) { $ options [ $ category -> tid ] = $ category -> name ; } return $ options ; }
Returns all the top level term items that are considered categories .
48,748
public function getAllChildren ( ) { $ options = [ ] ; foreach ( array_keys ( $ this -> getCategories ( ) ) as $ category ) { $ options = array_merge ( $ options , $ this -> getChildren ( $ category ) ) ; } return $ options ; }
Returns all the children of top level term items .
48,749
public function buildHierarchy ( array $ terms , $ entity_type ) { $ tree = [ ] ; foreach ( $ terms as $ term ) { if ( ! isset ( $ term [ 'target_id' ] ) ) { continue ; } $ current_term = $ this -> termStorage -> load ( $ term [ 'target_id' ] ) ; if ( ! $ current_term instanceof TermInterface ) { continue ; } $ parents...
Returns a multilevel tree .
48,750
public function getUserIdsFromName ( $ name , $ count , $ suggestion_format = SOCIAL_PROFILE_SUGGESTIONS_ALL ) { $ query = $ this -> startQuery ( ) ; $ name = '%' . ltrim ( $ query -> escapeLike ( $ name ) ) . '%' ; switch ( $ suggestion_format ) { case SOCIAL_PROFILE_SUGGESTIONS_USERNAME : $ query -> condition ( 'uf.n...
Get a list of account IDs whose account names begin with the given string .
48,751
private function startQuery ( ) { $ connection = \ Drupal :: database ( ) ; $ query = $ connection -> select ( 'users' , 'u' ) -> fields ( 'u' , [ 'uid' ] ) ; $ query -> join ( 'users_field_data' , 'uf' , 'uf.uid = u.uid' ) ; $ query -> leftJoin ( 'profile' , 'p' , 'p.uid = u.uid' ) ; if ( $ this -> useFullName ( ) ) {...
Start a Social Profile Mention Query .
48,752
private function sortQuery ( SelectInterface $ query , $ name , $ suggestion_format ) { if ( $ suggestion_format !== SOCIAL_PROFILE_SUGGESTIONS_USERNAME && $ this -> useFullName ( ) ) { $ name = substr ( $ name , 1 ) ; $ query -> addExpression ( " CASE WHEN fn.field_profile_first_name_value LIKE '$name' THEN 0 ...
Sorts the query .
48,753
private function endQuery ( SelectInterface $ query , $ count ) { $ result = $ query -> range ( 0 , $ count ) -> execute ( ) -> fetchCol ( ) ; return ! empty ( $ result ) ? $ result : [ ] ; }
End a Social Profile Mention Query .
48,754
public function checkMentionTypes ( ) { $ settings = $ this -> settings ; if ( isset ( $ settings [ 'mentions_filter' ] ) ) { $ configs = $ this -> config -> listAll ( 'mentions.mentions_type' ) ; foreach ( $ configs as $ config ) { $ this -> mentionTypes [ ] = str_replace ( 'mentions.mentions_type.' , '' , $ config ) ...
Checks if there are mentionTypes .
48,755
public function shouldApplyFilter ( ) { if ( $ this -> checkMentionTypes ( ) ) { return TRUE ; } elseif ( $ this -> textFormat && ( $ format = FilterFormat :: load ( $ this -> textFormat ) ) ) { $ filters = $ format -> get ( 'filters' ) ; if ( ! empty ( $ filters [ 'filter_mentions' ] [ 'status' ] ) ) { $ this -> setti...
Checks if a textFormat filter should be applied .
48,756
public function getMentions ( $ text ) { $ mentions = [ ] ; $ config_names = $ this -> mentionTypes ; foreach ( $ config_names as $ config_name ) { $ settings = $ this -> config -> get ( 'mentions.mentions_type.' . $ config_name ) ; $ input_settings = [ 'prefix' => $ settings -> get ( 'input.prefix' ) , 'suffix' => $ s...
Gets the mentions in text .
48,757
public function filterMentions ( $ text ) { $ mentions = $ this -> getMentions ( $ text ) ; foreach ( $ mentions as $ match ) { $ mention = $ this -> mentionsManager -> createInstance ( $ match [ 'type' ] ) ; if ( $ mention instanceof MentionsPluginInterface ) { $ output_settings = $ this -> outputSettings [ $ match [ ...
Filters mentions in a text .
48,758
private function getExtensionsInfo ( array $ projects ) { $ value = [ ] ; uasort ( $ projects , 'system_sort_modules_by_info_name' ) ; foreach ( $ projects as $ project ) { $ name = $ project -> getName ( ) ; $ info = $ project -> info ; unset ( $ info [ 'dependencies' ] ) ; $ value [ $ name ] = [ 'type' => $ project -...
Get safe extensions info .
48,759
public function getProfileFields ( $ profile_type_id ) { $ fields = [ ] ; try { $ profile_fields = $ this -> entityTypeManager -> getStorage ( 'field_config' ) -> loadByProperties ( [ 'entity_type' => 'profile' , 'bundle' => $ profile_type_id ] ) ; } catch ( \ Exception $ e ) { return $ fields ; } foreach ( $ profile_f...
Functions fetches profile fields from a profile type .
48,760
public static function deleteGroupAndContent ( $ nids , $ posts , & $ context ) { $ results = [ ] ; foreach ( $ nids as $ nid ) { $ node = Node :: load ( $ nid ) ; $ message = t ( 'Delete @type "@title"' , [ '@type' => $ node -> getType ( ) , '@title' => $ node -> getTitle ( ) ] ) ; $ results [ ] = $ node -> delete ( )...
Get the group and all of its content that needs to be deleted .
48,761
public static function deleteGroupAndContentFinishedCallback ( $ success , $ results , $ operations ) { if ( $ success ) { $ message = \ Drupal :: translation ( ) -> formatPlural ( count ( $ results ) , 'One item deleted.' , '@count items deleted.' ) ; drupal_set_message ( t ( 'Your group and all of its topics, events ...
Callback when the batch for group and content deletion is done .
48,762
public static function getDefaultGroupVisibility ( $ type ) { $ visibility = & drupal_static ( __FUNCTION__ . $ type ) ; if ( empty ( $ visibility ) ) { switch ( $ type ) { case 'closed_group' : $ visibility = 'group' ; break ; case 'open_group' : $ visibility = 'community' ; break ; case 'public_group' : $ visibility ...
Returns the default visibility .
48,763
public function getAllGroupsForUser ( $ uid ) { $ groups = & drupal_static ( __FUNCTION__ ) ; if ( ! isset ( $ groups [ $ uid ] ) ) { $ group_content_types = GroupContentType :: loadByEntityTypeId ( 'user' ) ; $ group_content_types = array_keys ( $ group_content_types ) ; $ query = $ this -> database -> select ( 'group...
Get all group memberships for a certain user .
48,764
protected function getBlockDefinitions ( ) { $ definitions = $ this -> blockManager -> getSortedDefinitions ( ) ; $ block_definitions = [ ] ; foreach ( $ definitions as $ plugin_id => $ definition ) { if ( isset ( $ definition [ 'context' ] ) ) { continue ; } $ block_definitions [ $ plugin_id ] = $ definition ; } retur...
Get sorted listed of supported block definitions .
48,765
public function getUserFromRoute ( ) { $ route_match = $ this -> currentRouteMatch ; if ( ( $ account = $ route_match -> getParameter ( 'user' ) ) ) { if ( $ account instanceof UserInterface ) { return $ account ; } elseif ( is_numeric ( $ account ) ) { $ account = $ this -> userStorage -> load ( $ account ) ; if ( $ a...
Retrieves the user entity from the current route .
48,766
private function isImage ( FileInterface $ file ) { $ image = $ this -> getImage ( $ file ) ; if ( $ image === NULL ) { return FALSE ; } return $ image -> isValid ( ) ; }
Check if its a file or image so we know what to render .
48,767
private function getImage ( FileInterface $ file ) { $ image_factory = \ Drupal :: service ( 'image.factory' ) ; return $ image_factory -> get ( $ file -> getFileUri ( ) ) ; }
Grab the Image if we are dealing with one .
48,768
public function getRecipientsFromPost ( array $ referenced_entity ) { $ recipients = [ ] ; $ post = Post :: load ( $ referenced_entity [ 'target_id' ] ) ; $ recipient_user = $ post -> get ( 'field_recipient_user' ) -> getValue ( ) ; if ( ! empty ( $ recipient_user ) ) { $ recipients [ ] = [ 'target_type' => 'user' , 't...
Returns recipients from post .
48,769
protected function returnAccessRelatedObject ( EntityInterface $ entity , $ operation , $ account ) { $ related_object = $ entity -> get ( 'field_activity_entity' ) -> getValue ( ) ; if ( ! empty ( $ related_object ) ) { $ ref_entity_type = $ related_object [ '0' ] [ 'target_type' ] ; $ ref_entity_id = $ related_object...
Return access control from the related entity .
48,770
protected function checkIfPersonalNotification ( EntityInterface $ entity ) { $ recipient = $ entity -> getRecipient ( ) ; $ value = FALSE ; if ( ! empty ( $ recipient ) && $ recipient [ '0' ] [ 'target_type' ] === 'user' ) { $ destinations = $ entity -> getDestinations ( ) ; $ is_notification = in_array ( 'notificatio...
Check if this is a personal notification .
48,771
public function write ( $ filename = null ) { if ( $ filename === null ) { $ filename = $ this -> getFilename ( ) ; } if ( empty ( $ filename ) ) { $ filename = 'file' ; } if ( ! $ handle = fopen ( $ filename , 'w' ) ) { trigger_error ( 'Can not open the destination file' , E_USER_ERROR ) ; return 0 ; } $ written = $ t...
Writes this file to the filesystem
48,772
public function getBytes ( ) { $ result = '' ; foreach ( $ this -> getChunks ( ) as $ chunk ) { $ result .= $ chunk [ 'data' ] -> bin ; } return $ result ; }
This will load the file into memory . If the file is bigger than your memory this will cause problems!
48,773
public function count ( $ foundOnly = false ) { $ optionNames = [ 'hint' , 'maxTimeMS' ] ; if ( $ foundOnly ) { $ optionNames = array_merge ( $ optionNames , [ 'limit' , 'skip' ] ) ; } $ options = $ this -> getOptions ( $ optionNames ) + $ this -> options ; try { $ count = $ this -> collection -> count ( TypeConverter ...
Counts the number of results for this query
48,774
public function explain ( ) { $ optionNames = [ 'allowPartialResults' , 'batchSize' , 'cursorType' , 'limit' , 'maxTimeMS' , 'noCursorTimeout' , 'projection' , 'skip' , 'sort' , ] ; $ options = $ this -> getOptions ( $ optionNames ) ; $ command = [ 'explain' => [ 'find' => $ this -> collection -> getCollectionName ( ) ...
Return an explanation of the query often useful for optimization and debugging
48,775
public function hasNext ( ) { if ( ! $ this -> startedIterating ) { $ this -> ensureIterator ( ) ; $ this -> startedIterating = true ; $ this -> storeIteratorState ( ) ; $ this -> cursorNeedsAdvancing = false ; } elseif ( $ this -> cursorNeedsAdvancing ) { $ this -> ensureIterator ( ) -> next ( ) ; $ this -> cursorNeed...
Checks if there are any more elements in this cursor
48,776
public function toBSONType ( ) { $ milliSeconds = ( $ this -> sec * 1000 ) + ( $ this -> truncateMicroSeconds ( $ this -> usec ) / 1000 ) ; return new UTCDateTime ( $ milliSeconds ) ; }
Converts this MongoDate to the new BSON UTCDateTime type
48,777
public function toDateTime ( ) { $ datetime = new \ DateTime ( ) ; $ datetime -> setTimestamp ( $ this -> sec ) ; $ microSeconds = $ this -> truncateMicroSeconds ( $ this -> usec ) ; if ( $ microSeconds > 0 ) { $ datetime = \ DateTime :: createFromFormat ( 'Y-m-d H:i:s.u' , $ datetime -> format ( 'Y-m-d H:i:s' ) . '.' ...
Returns a DateTime object representing this date
48,778
public function current ( ) { $ file = parent :: current ( ) ; return ( $ file !== null ) ? new MongoGridFSFile ( $ this -> gridfs , $ file ) : null ; }
Returns the current file
48,779
public function key ( ) { $ file = $ this -> current ( ) ; return ( $ file !== null ) ? ( string ) $ file -> file [ '_id' ] : null ; }
Returns the current result s filename
48,780
public function add ( $ item ) { if ( is_object ( $ item ) ) { $ item = ( array ) $ item ; } $ this -> validate ( $ item ) ; $ this -> addItem ( $ item ) ; return true ; }
Adds a write operation to a batch
48,781
public function getCollectionInfo ( array $ options = [ ] ) { $ includeSystemCollections = false ; if ( isset ( $ options [ 'includeSystemCollections' ] ) ) { $ includeSystemCollections = $ options [ 'includeSystemCollections' ] ; unset ( $ options [ 'includeSystemCollections' ] ) ; } try { $ collections = $ this -> db...
Returns information about collections in this database
48,782
public function getCollectionNames ( array $ options = [ ] ) { $ includeSystemCollections = false ; if ( isset ( $ options [ 'includeSystemCollections' ] ) ) { $ includeSystemCollections = $ options [ 'includeSystemCollections' ] ; unset ( $ options [ 'includeSystemCollections' ] ) ; } try { $ collections = $ this -> d...
Get all collections from this database
48,783
public function setProfilingLevel ( $ level ) { $ result = $ this -> command ( [ 'profile' => $ level ] ) ; return ( $ result [ 'ok' ] && isset ( $ result [ 'was' ] ) ) ? $ result [ 'was' ] : 0 ; }
Sets this database s profiling level
48,784
public function repair ( $ preserve_cloned_files = false , $ backup_original_files = false ) { $ command = [ 'repairDatabase' => 1 , 'preserveClonedFilesOnFailure' => $ preserve_cloned_files , 'backupOriginalFiles' => $ backup_original_files , ] ; return $ this -> command ( $ command ) ; }
Repairs and compacts this database
48,785
public function createCollection ( $ name , $ options = [ ] ) { try { if ( isset ( $ options [ 'capped' ] ) ) { $ options [ 'capped' ] = ( bool ) $ options [ 'capped' ] ; } $ this -> db -> createCollection ( $ name , $ options ) ; } catch ( \ MongoDB \ Driver \ Exception \ Exception $ e ) { return false ; } return $ th...
Creates a collection
48,786
public function dropCollection ( $ coll ) { if ( $ coll instanceof MongoCollection ) { $ coll = $ coll -> getName ( ) ; } return TypeConverter :: toLegacy ( $ this -> db -> dropCollection ( ( string ) $ coll ) ) ; }
Drops a collection
48,787
public function getDBRef ( array $ ref ) { $ db = ( isset ( $ ref [ '$db' ] ) && $ ref [ '$db' ] !== $ this -> name ) ? $ this -> connection -> selectDB ( $ ref [ '$db' ] ) : $ this ; return MongoDBRef :: get ( $ db , $ ref ) ; }
Fetches the document pointed to by a database reference
48,788
public function command ( array $ data , $ options = [ ] , & $ hash = null ) { try { $ cursor = new \ MongoCommandCursor ( $ this -> connection , $ this -> name , $ data ) ; $ cursor -> setReadPreference ( $ this -> getReadPreference ( ) ) ; return iterator_to_array ( $ cursor ) [ 0 ] ; } catch ( \ MongoDB \ Driver \ E...
Execute a database command
48,789
public static function fromLegacy ( $ value ) { switch ( true ) { case $ value instanceof TypeInterface : return $ value -> toBSONType ( ) ; case $ value instanceof BSON \ Type : return $ value ; case is_array ( $ value ) : case is_object ( $ value ) : $ result = [ ] ; foreach ( $ value as $ key => $ item ) { $ result ...
Converts a legacy type to the new BSON type
48,790
public static function toLegacy ( $ value ) { switch ( true ) { case $ value instanceof BSON \ Type : return self :: convertBSONObjectToLegacy ( $ value ) ; case is_array ( $ value ) : case is_object ( $ value ) : $ result = [ ] ; foreach ( $ value as $ key => $ item ) { $ result [ $ key ] = self :: toLegacy ( $ item )...
Converts a BSON type to the legacy types
48,791
public static function convertProjection ( $ fields ) { if ( ! is_array ( $ fields ) || $ fields === [ ] ) { return null ; } if ( ! TypeConverter :: isNumericArray ( $ fields ) ) { $ projection = TypeConverter :: fromLegacy ( $ fields ) ; } else { $ projection = array_fill_keys ( array_map ( function ( $ field ) { if (...
Converts a projection used in find queries .
48,792
private static function convertBSONObjectToLegacy ( BSON \ Type $ value ) { switch ( true ) { case $ value instanceof BSON \ ObjectID : return new \ MongoId ( $ value ) ; case $ value instanceof BSON \ Binary : return new \ MongoBinData ( $ value ) ; case $ value instanceof BSON \ Javascript : return new \ MongoCode ( ...
Converter method to convert a BSON object to its legacy type
48,793
public function listDBs ( ) { try { $ databaseInfoIterator = $ this -> client -> listDatabases ( ) ; } catch ( \ MongoDB \ Driver \ Exception \ Exception $ e ) { throw ExceptionConverter :: toLegacy ( $ e ) ; } $ databases = [ 'databases' => [ ] , 'totalSize' => 0 , 'ok' => 1.0 , ] ; foreach ( $ databaseInfoIterator as...
Lists all of the databases available
48,794
private function forceConnect ( ) { try { $ command = new \ MongoDB \ Driver \ Command ( [ 'ping' => 1 ] ) ; $ this -> manager -> executeCommand ( 'db' , $ command ) ; } catch ( \ MongoDB \ Driver \ Exception \ Exception $ e ) { throw ExceptionConverter :: toLegacy ( $ e ) ; } }
Forces a connection by executing the ping command
48,795
public function aggregate ( array $ pipeline , array $ op = [ ] ) { if ( ! TypeConverter :: isNumericArray ( $ pipeline ) ) { $ operators = func_get_args ( ) ; $ pipeline = [ ] ; $ options = [ ] ; $ i = 0 ; foreach ( $ operators as $ operator ) { $ i ++ ; if ( ! is_array ( $ operator ) ) { trigger_error ( "Argument $i ...
Perform an aggregation using the aggregation framework
48,796
public function aggregateCursor ( array $ pipeline , array $ options = [ ] ) { $ command = [ 'aggregate' => $ this -> name , 'pipeline' => $ pipeline ] ; if ( ! isset ( $ options [ 'cursor' ] ) ) { $ options [ 'cursor' ] = new \ stdClass ( ) ; } $ command += $ options ; $ cursor = new MongoCommandCursor ( $ this -> db ...
Execute an aggregation pipeline command and retrieve results through a cursor
48,797
public function validate ( $ scan_data = false ) { $ command = [ 'validate' => $ this -> name , 'full' => $ scan_data , ] ; return $ this -> db -> command ( $ command ) ; }
Validates this collection
48,798
public function insert ( & $ a , array $ options = [ ] ) { if ( ! $ this -> ensureDocumentHasMongoId ( $ a ) ) { trigger_error ( sprintf ( '%s(): expects parameter %d to be an array or object, %s given' , __METHOD__ , 1 , gettype ( $ a ) ) , E_USER_WARNING ) ; return ; } $ this -> mustBeArrayOrObject ( $ a ) ; try { $ ...
Inserts an array into the collection
48,799
public function batchInsert ( array & $ a , array $ options = [ ] ) { if ( empty ( $ a ) ) { throw new \ MongoException ( 'No write ops were included in the batch' ) ; } $ continueOnError = isset ( $ options [ 'continueOnError' ] ) && $ options [ 'continueOnError' ] ; foreach ( $ a as $ key => $ item ) { try { if ( ! $...
Inserts multiple documents into this collection