idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
48,600 | protected function getContentEntityTypes ( ) { $ options = [ ] ; foreach ( $ this -> entityTypeManager -> getDefinitions ( ) as $ entity_type ) { if ( $ entity_type instanceof ContentEntityTypeInterface ) { $ options [ $ entity_type -> id ( ) ] = $ entity_type -> getLabel ( ) ; } } return $ options ; } | Get content entity types keyed by id . |
48,601 | public function query ( ) { $ account = $ this -> view -> getUser ( ) ; $ this -> query -> addTable ( 'post__field_visibility' ) ; $ and_condition = db_and ( ) ; $ should_add_where_clause = FALSE ; if ( ! $ account -> hasPermission ( 'view public posts' ) ) { $ and_condition -> condition ( 'post__field_visibility.field... | Currently use similar access as for the entity . |
48,602 | protected static function getRootPackage ( ) { $ file = new JsonFile ( 'composer.json' ) ; $ dir = explode ( DIRECTORY_SEPARATOR , trim ( getcwd ( ) , DIRECTORY_SEPARATOR ) ) ; do { if ( $ file -> exists ( ) ) { $ info = $ file -> read ( ) ; if ( isset ( $ info [ 'require' ] [ 'goalgorilla/open_social' ] ) ) { return $... | Reads the root package s composer . json . |
48,603 | private function isAllowedPath ( $ path ) { $ unallowed_paths = [ '/user/logout' , '/ajax' , ] ; foreach ( $ unallowed_paths as $ unallowed_path ) { if ( $ unallowed_path === substr ( $ path , 0 , strlen ( $ unallowed_path ) ) ) { return FALSE ; } } return TRUE ; } | Checks if a path is allowed . |
48,604 | protected function getRolesWithPermission ( ) { $ roles_with_perm = [ ] ; $ roles = Role :: loadMultiple ( ) ; foreach ( $ roles as $ role ) { if ( $ role -> hasPermission ( 'view inappropriate reports' ) ) { $ roles_with_perm [ ] = $ role -> id ( ) ; } } return $ roles_with_perm ; } | Returns the role with the required permission . |
48,605 | public function access ( RouteMatchInterface $ route_match , AccountInterface $ account , $ permission = NULL ) { if ( count ( $ this -> languageManager -> getLanguages ( ) ) > 1 ) { if ( ! empty ( $ permission ) ) { return AccessResult :: allowedIfHasPermission ( $ account , $ permission ) ; } else { return AccessResu... | Checks access to the overview based on permissions and translatability . |
48,606 | public function processItem ( $ data ) { $ config = $ this -> config -> get ( 'social_lets_connect_usage.settings' ) ; $ usage_data_url = $ config -> get ( 'url' ) ; try { $ response = $ this -> client -> post ( $ usage_data_url , [ 'json' => $ data ] ) ; } catch ( RequestException $ e ) { return FALSE ; } return Json ... | Will process a queue item . |
48,607 | public function enabled ( ) { $ config = $ this -> config -> get ( 'social_lets_connect_usage.settings' ) ; $ usage_data_settings = $ config -> get ( 'usage_data' ) ; $ plugin_definition = $ this -> getPluginDefinition ( ) ; if ( in_array ( $ plugin_definition [ 'setting' ] , $ usage_data_settings ) ) { return TRUE ; }... | Check if this plugin should be enabled . |
48,608 | public function groupMembersTitle ( $ group ) { if ( ! $ group instanceof Group ) { $ group = Group :: load ( $ group ) ; } return $ this -> t ( 'Members of @name' , [ '@name' => $ group -> label ( ) ] ) ; } | The _title_callback for the view . group_members . page_group_members route . |
48,609 | protected function configureViewMode ( FormStateInterface $ form_state ) { $ view_mode = $ this -> postViewDefault ; if ( $ this -> entity -> hasField ( 'field_recipient_user' ) && ! $ this -> entity -> get ( 'field_recipient_user' ) -> isEmpty ( ) ) { $ view_mode = $ this -> postViewProfile ; } elseif ( $ this -> enti... | Configures the view mode when an existing entity is being edited . |
48,610 | protected function setFormMode ( ) { if ( $ this -> getBundleEntity ( ) !== NULL ) { $ bundle = $ this -> getBundleEntity ( ) -> id ( ) ; $ this -> postViewDefault = 'post.' . $ bundle . '.default' ; $ this -> postViewProfile = 'post.' . $ bundle . '.profile' ; $ this -> postViewGroup = 'post.' . $ bundle . '.group' ; ... | Function to set the current form modes . |
48,611 | public function isSmall ( ) : bool { $ this -> cropToStyle ( $ this -> configFactory -> get ( 'social_group.settings' ) -> get ( 'default_hero' ) ) ; return $ this -> isSmall ; } | Small or not . |
48,612 | protected function cropToStyle ( $ cropType ) : string { $ values = [ 'hero' => 'social_xx_large' , 'hero_small' => 'social_hero_small' , ] ; switch ( $ cropType ) { case 'hero_small' : $ this -> isSmall = TRUE ; default : } return $ values [ $ cropType ] ?? 'social_xx_large' ; } | Function that converts crop type to image style . |
48,613 | public function getLabelForValue ( $ value ) { $ settings = $ this -> getFieldSettings ( ) ; $ allowed_values = $ settings [ 'allowed_values' ] ; foreach ( $ allowed_values as $ allowed_value ) { if ( isset ( $ allowed_value [ 'value' ] ) && $ allowed_value [ 'value' ] === $ value ) { $ label = $ allowed_value [ 'label... | Display dropdown labels . |
48,614 | public function getListByProperties ( $ condition = NULL , $ value = NULL ) { $ options = [ ] ; foreach ( $ this -> getDefinitions ( ) as $ plugin_id => $ plugin_definition ) { if ( empty ( $ condition ) || ( isset ( $ plugin_definition [ $ condition ] ) && $ plugin_definition [ $ condition ] === $ value ) ) { $ option... | Retrieves an list of available destinations by given properties . |
48,615 | public function getPluginNames ( ) { $ definitions = $ this -> getDefinitions ( ) ; $ plugin_names = [ ] ; foreach ( $ definitions as $ definition ) { $ name = $ definition [ 'name' ] -> getUntranslatedString ( ) ; $ plugin_names [ $ definition [ 'id' ] ] = $ name ; } return $ plugin_names ; } | Get the names of plugins of type mentions_type . |
48,616 | protected function eventHasBeenFinished ( Node $ node ) { $ check_end_date = $ node -> field_event_date -> date ; if ( isset ( $ node -> field_event_date_end -> date ) ) { $ check_end_date = $ node -> field_event_date_end -> date ; } $ current_time = new DrupalDateTime ( ) ; if ( $ current_time > $ check_end_date ) { r... | Function to determine if an event has been finished . |
48,617 | public function getGroups ( $ node ) { $ groupcontents = GroupContent :: loadByEntity ( $ node ) ; $ groups = [ ] ; if ( ! empty ( $ groupcontents ) ) { foreach ( $ groupcontents as $ groupcontent ) { $ group = $ groupcontent -> getGroup ( ) ; $ groups [ ] = $ group ; } } return $ groups ; } | Get group object where event enrollment is posted in . |
48,618 | public function buildConfigurationForm ( array $ form , FormStateInterface $ form_state ) { $ form [ 'subject' ] = [ '#type' => 'textfield' , '#title' => t ( 'Subject' ) , '#required' => TRUE , '#default_value' => $ form_state -> getValue ( 'subject' ) , '#maxlength' => '254' , ] ; $ form [ 'message' ] = [ '#type' => '... | Configuration form builder . |
48,619 | private function getOrCreateFont ( $ fontName ) { foreach ( Font :: loadMultiple ( ) as $ font_entities ) { if ( $ fontName == $ font_entities -> get ( 'name' ) -> value ) { return $ font_entities -> id ( ) ; } } $ font = Font :: create ( [ 'name' => $ fontName , 'user_id' => 1 , 'created' => \ Drupal :: time ( ) -> ge... | Get or create the font . |
48,620 | private function replaceAnBlock ( BlockContent $ block , array $ data ) { $ block -> field_text_block = [ 'value' => $ data [ 'textblock' ] , 'format' => 'full_html' , ] ; $ block_image = $ this -> prepareImage ( $ data [ 'image' ] , 'Anonymous front page image homepage' ) ; $ block -> field_hero_image = $ block_image ... | Function to replace the AN homepage Block . |
48,621 | public function getEntityLabel ( EntityInterface $ entity ) { $ profiles = $ this -> entityTypeManager -> getStorage ( 'profile' ) -> loadByProperties ( [ 'uid' => $ entity -> field_account -> target_id , ] ) ; $ profile = reset ( $ profiles ) ; if ( ! $ profile ) { $ name = '' ; $ first_name = $ entity -> get ( 'field... | Returns modified entity label . |
48,622 | protected function getGroups ( ) { $ types = [ ] ; foreach ( GroupType :: loadMultiple ( ) as $ group_type ) { if ( in_array ( 'join group' , $ group_type -> getOutsiderRole ( ) -> getPermissions ( ) ) ) { $ types [ ] = $ group_type ; } } return $ types ; } | Function that returns all groups that outsider can become a member of . |
48,623 | public static function validateGroupSelection ( array $ form , FormStateInterface $ form_state ) { $ ajax_response = new AjaxResponse ( ) ; $ selected_visibility = $ form_state -> getValue ( 'field_content_visibility' ) ; if ( ! empty ( $ selected_visibility ) ) { $ selected_visibility = $ selected_visibility [ '0' ] [... | Validate the group selection and change the visibility settings . |
48,624 | private function removeGroupsWithoutCreateAccess ( array $ options , User $ account , EntityInterface $ entity ) { foreach ( $ options as $ option_category_key => $ groups_in_category ) { if ( is_array ( $ groups_in_category ) ) { foreach ( $ groups_in_category as $ gid => $ group_title ) { if ( ! $ this -> checkGroupC... | Remove options from the list . |
48,625 | private function checkGroupContentCreateAccess ( $ gid , User $ account , EntityInterface $ entity ) { $ group = Group :: load ( $ gid ) ; if ( $ group -> hasPermission ( 'create group_' . $ entity -> getEntityTypeId ( ) . ':' . $ entity -> bundle ( ) . ' entity' , $ account ) ) { if ( $ group -> getGroupType ( ) -> id... | Check if user may create content of bundle in group . |
48,626 | public static function validateElement ( array $ element , FormStateInterface $ form_state ) { if ( $ element [ '#required' ] && $ element [ '#value' ] == '_none' ) { $ form_state -> setError ( $ element , t ( '@name field is required.' , [ '@name' => $ element [ '#title' ] ] ) ) ; } $ items = [ $ element [ '#key_colum... | Form validation handler for widget elements . |
48,627 | protected function getSelectedOptions ( FieldItemListInterface $ items , $ delta = 0 ) { $ options = $ this -> getOptions ( $ items -> getEntity ( ) ) ; $ selected_options = [ ] ; foreach ( $ items as $ item ) { $ value = $ item -> { $ this -> column } ; if ( isset ( $ options [ $ value ] ) ) { $ selected_options [ ] =... | Determines selected options from the incoming field values . |
48,628 | protected function getGroupedOptions ( array $ options , array $ selected ) { $ grouped_options = [ ] ; foreach ( $ options as $ tid => $ label ) { $ group = & $ grouped_options ; while ( strpos ( $ label , '-' ) === 0 ) { $ label = substr ( $ label , 1 ) ; end ( $ group ) ; $ group = & $ group [ key ( $ group ) ] [ 'c... | Group the options with their parent taxonomy terms . |
48,629 | private function getTaxonomyChildren ( array $ parent , $ hyphens = 0 ) { $ children = [ ] ; $ selected = [ ] ; foreach ( $ parent [ 'children' ] as $ tid => $ child ) { $ children [ $ tid ] = str_repeat ( '-' , $ hyphens ) . $ child [ 'label' ] ; if ( $ child [ 'selected' ] ) { $ selected [ ] = $ tid ; } if ( ! empty ... | Reaches into all children and flattens the taxonomy . |
48,630 | public static function removeGroupContent ( NodeInterface $ node , Group $ group ) { if ( $ group_contents = GroupContent :: loadByEntity ( $ node ) ) { foreach ( $ group_contents as $ group_content ) { if ( $ group -> id ( ) === $ group_content -> getGroup ( ) -> id ( ) ) { $ group_content -> delete ( ) ; } } } } | Deletes a group content . |
48,631 | public function updateLastThreadCheckTime ( Entity $ entity ) { $ this -> userData -> set ( 'private_message' , $ this -> currentUser -> id ( ) , 'private_message_thread:' . $ entity -> id ( ) , $ this -> time -> getRequestTime ( ) ) ; } | Update the last time the thread was checked by the user . |
48,632 | public function deleteUserDataThreadInfo ( Entity $ entity ) { $ this -> userData -> delete ( 'private_message' , $ this -> currentUser -> id ( ) , 'private_message_thread:' . $ entity -> id ( ) ) ; } | Remove the thread info from the user_data . |
48,633 | public function updateUnreadCount ( ) { $ unread = 0 ; $ uid = $ this -> currentUser -> id ( ) ; $ threads = $ this -> getAllThreadIdsForUser ( $ uid ) ; if ( empty ( $ threads ) ) { return $ unread ; } $ thread_last_messages = $ this -> getLastMessagesFromOtherUsers ( $ uid , $ threads ) ; if ( empty ( $ thread_last_m... | Update the unread thread count . |
48,634 | public function getAllThreadIdsForUser ( $ uid ) { $ query = 'SELECT DISTINCT(thread.id), MAX(thread.updated) ' . 'FROM {private_message_threads} AS thread ' . 'JOIN {private_message_thread__members} AS member ' . 'ON member.entity_id = thread.id AND member.members_target_id = :uid ' . 'JOIN {private_message_thread__pr... | Copy function of the one in the private_message module to disable count . |
48,635 | public function getLastMessageFromOtherUser ( $ uid , $ thread_id ) { $ timestamp = $ this -> database -> query ( 'SELECT MAX(pm.created) ' . 'FROM {private_message_thread__private_messages} pmt ' . 'JOIN {private_messages} pm ON pmt.private_messages_target_id = pm.id ' . 'WHERE pmt.entity_id = :thread AND pm.owner <> ... | Last time a message was added to the thread by another user than current . |
48,636 | public function mentionPermalink ( MentionsInterface $ mentions ) { if ( $ entity = $ mentions -> getMentionedEntity ( ) ) { if ( ! $ entity -> access ( 'view' ) ) { throw new AccessDeniedHttpException ( ) ; } $ entity_url = $ entity -> toUrl ( 'canonical' ) ; return new RedirectResponse ( $ entity_url -> setAbsolute (... | Redirects mention links to the correct page depending on entity context . |
48,637 | protected function fetchData ( ) { if ( ! $ this -> data ) { $ this -> data = $ this -> parser -> parseFileFromModule ( $ this -> getSource ( ) , $ this -> getModule ( ) , $ this -> getProfile ( ) ) ; } return $ this -> data ; } | Gets the data from a file . |
48,638 | protected function loadByUuid ( $ entity_type_id , $ id , $ all = FALSE ) { if ( property_exists ( $ this , $ entity_type_id . 'Storage' ) ) { $ storage = $ this -> { $ entity_type_id . 'Storage' } ; } else { $ storage = \ Drupal :: entityTypeManager ( ) -> getStorage ( $ entity_type_id ) ; } if ( is_numeric ( $ id ) )... | Load entity by uuid . |
48,639 | protected function createEventDate ( $ date_string ) { $ timestamp = explode ( '|' , $ date_string ) ; $ date = strtotime ( $ timestamp [ 0 ] ) ; $ date = date ( 'Y-m-d' , $ date ) . 'T' . $ timestamp [ 1 ] . ':00' ; return $ date ; } | Function to calculate the date . |
48,640 | protected function prepareAttachment ( array $ files ) { $ attachments = NULL ; foreach ( $ files as $ file ) { $ description = '' ; if ( is_array ( $ file ) ) { $ uuid = key ( $ file ) ; $ description = current ( $ file ) ; } else { $ uuid = $ file ; } $ object = $ this -> fileStorage -> loadByProperties ( [ 'uuid' =>... | Returns reference to attachment possibly with a description . |
48,641 | protected function prepareEventManagers ( array $ managers ) { $ values = NULL ; foreach ( $ managers as $ uuid ) { $ load = $ this -> userStorage -> loadByProperties ( [ 'uuid' => $ uuid ] ) ; $ account = current ( $ load ) ; if ( $ account instanceof User ) { $ properties = [ 'target_id' => $ account -> id ( ) , ] ; ... | Returns event managers . |
48,642 | protected function getRedirectResponse ( $ type ) { $ sdk = $ this -> getSdk ( $ type ) ; if ( $ sdk instanceof RedirectResponse ) { return $ sdk ; } $ this -> authManager -> setSdk ( $ sdk ) ; $ url = $ this -> authManager -> getAuthenticationUrl ( $ type ) ; return new TrustedRedirectResponse ( $ url ) ; } | Returns the redirect response . |
48,643 | 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 LinkedIn . |
48,644 | protected function applyCrops ( array $ item , FileInterface $ entity ) { foreach ( $ item [ 'crops' ] as $ crop_name => $ data ) { $ crop_type = $ this -> entityTypeManager -> getStorage ( 'crop_type' ) -> load ( $ crop_name ) ; if ( ! empty ( $ crop_type ) && $ crop_type instanceof CropType ) { $ this -> imageWidgetC... | Crops the images . |
48,645 | public static function validateAllowedValues ( array $ element , FormStateInterface $ form_state ) { $ values = static :: extractAllowedValues ( $ element [ '#value' ] , $ element [ '#field_has_data' ] ) ; if ( ! is_array ( $ values ) ) { $ form_state -> setError ( $ element , t ( 'Allowed values list: invalid input.' ... | Element_validate callback for options field allowed values . |
48,646 | protected function allowedValuesString ( array $ values ) { $ lines = [ ] ; foreach ( $ values as $ key => $ value ) { if ( is_array ( $ value ) ) { $ lines [ $ key ] = implode ( "|" , $ value ) ; ; } } return implode ( "\n" , $ lines ) ; } | Generates a string representation of an array of allowed values . |
48,647 | protected static function extractAllowedValues ( $ string , $ has_data ) { $ values = [ ] ; $ list = explode ( "\n" , $ string ) ; $ list = array_map ( 'trim' , $ list ) ; $ list = array_filter ( $ list , 'strlen' ) ; foreach ( $ list as $ position => $ text ) { $ matches = [ ] ; if ( preg_match ( '/(.*)\|(.*)\|(.*)/' ... | Extracts the allowed values array from the allowed_values element . |
48,648 | protected function buildActivities ( array $ data ) { $ activities = [ ] ; $ message = Message :: load ( $ data [ 'mid' ] ) ; $ activity_fields = [ 'created' => $ this -> getCreated ( $ message ) , 'field_activity_destinations' => $ this -> getFieldDestinations ( $ data ) , 'field_activity_entity' => $ this -> getField... | Build the activities based on a data array . |
48,649 | protected function getFieldDestinations ( array $ data , $ allowed_destinations = [ ] ) { $ value = NULL ; if ( isset ( $ data [ 'destination' ] ) ) { $ value = $ data [ 'destination' ] ; if ( ! empty ( $ allowed_destinations ) ) { foreach ( $ value as $ key => $ destination ) { if ( ! in_array ( $ destination [ 'value... | Get field value for destination field from data array . |
48,650 | protected function getFieldMessage ( $ data ) { $ value = NULL ; if ( isset ( $ data [ 'mid' ] ) ) { $ value = [ ] ; $ value [ ] = [ 'target_id' => $ data [ 'mid' ] , ] ; } return $ value ; } | Get field value for message field from data array . |
48,651 | protected function getCreated ( Message $ message ) { $ value = NULL ; if ( isset ( $ message ) ) { $ value = $ message -> getCreatedTime ( ) ; } return $ value ; } | Get field value for created field from data array . |
48,652 | protected function buildAggregatedActivites ( $ data , $ activity_fields ) { $ activities = [ ] ; $ common_destinations = $ this -> activityDestinationManager -> getListByProperties ( 'isCommon' , TRUE ) ; $ personal_destinations = $ this -> activityDestinationManager -> getListByProperties ( 'isCommon' , FALSE ) ; $ r... | Build the aggregated activities based on a data array . |
48,653 | protected function getAggregationRelatedActivities ( $ data ) { $ activities = [ ] ; $ related_object = $ data [ 'related_object' ] [ 0 ] ; if ( ! empty ( $ related_object [ 'target_id' ] ) && ! empty ( $ related_object [ 'target_type' ] ) ) { if ( $ related_object [ 'target_type' ] === 'comment' ) { $ comment_storage ... | Get related activities for activity aggregation . |
48,654 | public static function getActivityRelatedEntity ( $ data ) { $ related_object = $ data [ 'related_object' ] [ 0 ] ; if ( $ data [ 'message_template' ] === 'create_comment_reply' ) { $ comment_storage = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'comment' ) ; $ comment = $ comment_storage -> load ( $ related_obje... | Get related entity for activity aggregation . |
48,655 | protected function getAggregationAuthorsCount ( array $ data ) { $ count = 0 ; $ related_object = $ data [ 'related_object' ] [ 0 ] ; if ( isset ( $ related_object [ 'target_type' ] ) && $ related_object [ 'target_type' ] === 'comment' ) { $ related_entity = $ this -> getActivityRelatedEntity ( $ data ) ; if ( ! empty ... | Get unique authors number for activity aggregation . |
48,656 | protected function getFieldRecipientGroup ( $ data ) { $ value = NULL ; if ( isset ( $ data [ 'recipient' ] ) ) { if ( $ data [ 'recipient' ] [ 'target_type' ] === 'group' ) { $ value = [ $ data [ 'recipient' ] ] ; } } return $ value ; } | Get field value for recipient_group field from data array . |
48,657 | protected function getFieldRecipientUser ( $ data ) { $ value = NULL ; if ( isset ( $ data [ 'recipient' ] ) && is_array ( $ data [ 'recipient' ] ) ) { if ( $ data [ 'recipient' ] [ 'target_type' ] === 'user' ) { $ value = [ $ data [ 'recipient' ] ] ; } } return $ value ; } | Get field value for recipient_user field from data array . |
48,658 | public function getMessageText ( Message $ message , $ langcode = '' ) { $ message_template = $ message -> getTemplate ( ) ; $ message_arguments = $ message -> getArguments ( ) ; $ message_template_text = $ message_template -> get ( 'text' ) ; if ( ! empty ( $ langcode ) ) { $ language_manager = \ Drupal :: languageMan... | Get message text . |
48,659 | protected function processArguments ( array $ arguments , array $ output , Message $ message ) { if ( empty ( $ arguments ) ) { return $ output ; } foreach ( $ arguments as $ key => $ value ) { if ( is_array ( $ value ) && ! empty ( $ value [ 'callback' ] ) && is_callable ( $ value [ 'callback' ] ) ) { $ value += [ 'pa... | Process the message given the arguments saved with it . |
48,660 | protected function processTokens ( array $ output , $ clear , Message $ message ) { $ options = [ 'clear' => $ clear , ] ; foreach ( $ output as $ key => $ value ) { if ( is_string ( $ value ) ) { $ output [ $ key ] = \ Drupal :: token ( ) -> replace ( $ value , [ 'message' => $ message ] , $ options ) ; } else { if ( ... | Replace placeholders with tokens . |
48,661 | protected function sendEmail ( $ body_text , $ langcode , User $ target ) { $ frequency_translated = t ( $ this -> getName ( ) -> getUntranslatedString ( ) , [ ] , [ 'langcode' => $ langcode ] ) ; $ notification = [ '#theme' => 'directmail' , '#notification' => $ body_text , '#notification_settings' => t ( 'Based on yo... | Send an email with a single notification . |
48,662 | public function getGroupTypeElement ( ) { $ user = \ Drupal :: currentUser ( ) ; $ element = [ '#type' => 'radios' , '#title' => $ this -> t ( 'Group type' ) , '#default_value' => 'open_group' , '#required' => TRUE , '#cache' => [ 'tags' => $ this -> entityTypeManager -> getDefinition ( 'group_type' ) -> getListCacheTa... | Get the group type element . |
48,663 | public function createFollow ( Entity $ entity , array $ uuids ) { foreach ( $ uuids as $ uuid ) { $ account = $ this -> loadByUuid ( 'user' , $ uuid ) ; $ properties = [ 'uid' => $ account -> id ( ) , 'entity_type' => 'node' , 'entity_id' => $ entity -> id ( ) , 'flag_id' => 'follow_content' , ] ; $ flaggings = \ Drup... | The function that checks and creates a follow on an entity . |
48,664 | public function validateNameMail ( array & $ form , FormStateInterface $ form_state ) { $ user_blocked = social_user_is_blocked ( $ form_state -> getValue ( 'name_or_mail' ) ) ; if ( $ user_blocked ) { if ( ! $ form_state -> get ( 'uid' ) ) { $ this -> setGeneralErrorMessage ( $ form , $ form_state ) ; } else { $ form_... | Sets an error if supplied username or mail has been blocked . |
48,665 | public function validateFinal ( array & $ form , FormStateInterface $ form_state ) { $ flood_config = $ this -> config ( 'user.flood' ) ; if ( ! $ form_state -> get ( 'uid' ) ) { $ this -> setGeneralErrorMessage ( $ form , $ form_state ) ; $ this -> flood -> register ( 'user.failed_login_ip' , $ flood_config -> get ( '... | Checks if user was not authenticated or if too many logins were attempted . |
48,666 | protected function createDate ( $ date_string ) { $ timestamp = explode ( '|' , $ date_string ) ; $ date = strtotime ( $ timestamp [ 0 ] ) ; $ date = date ( 'Y-m-d' , $ date ) . 'T' . $ timestamp [ 1 ] . ':00' ; return strtotime ( $ date ) ; } | Converts a date in the correct format . |
48,667 | protected function addMembers ( array $ members , array $ managers , GroupInterface $ entity ) { foreach ( $ members as $ account_uuid ) { $ account = $ this -> userStorage -> loadByProperties ( [ 'uuid' => $ account_uuid , ] ) ; if ( ( $ account = current ( $ account ) ) && ! $ entity -> getMember ( $ account ) ) { $ ... | Adds members to a group . |
48,668 | protected function prepareFiles ( $ files ) { $ values = [ ] ; foreach ( $ files as $ file_uuid ) { $ file = $ this -> fileStorage -> loadByProperties ( [ 'uuid' => $ file_uuid , ] ) ; if ( $ file ) { $ values [ ] = [ 'target_id' => current ( $ file ) -> id ( ) , ] ; } } return $ values ; } | Prepares an array with list of files to set as field value . |
48,669 | public function permissions ( ) { $ permissions = [ ] ; $ contentTypes = $ this -> getContentTypes ( ) ; foreach ( $ contentTypes as $ bundle ) { $ entity_type = 'node' ; $ fields = $ this -> getEntityAccessFields ( $ entity_type , $ bundle ) ; foreach ( $ fields as $ field ) { $ field_storage = $ field -> getFieldStor... | Return all the permissions generated by this user . |
48,670 | public function getRealmWithPermission ( ) { $ realms = [ ] ; $ contentTypes = $ this -> getContentTypes ( ) ; foreach ( $ contentTypes as $ bundle ) { $ entity_type = 'node' ; $ fields = $ this -> getEntityAccessFields ( $ entity_type , $ bundle ) ; foreach ( $ fields as $ field ) { $ field_storage = $ field -> getFie... | Get the realms array with permissions as value . |
48,671 | public function getRealmForFieldValue ( $ op , $ entity_type , $ bundle_id , $ field_name , $ field_value ) { $ realm = $ op . '_' . $ entity_type . '_' . $ bundle_id . '_' . $ field_name . '_' . $ field_value ; return $ realm ; } | Returns a realm for a field value in order to create access . |
48,672 | public function getEntityAccessFields ( $ entity , $ bundle ) { $ fields = [ ] ; $ field_definitions = $ this -> entityManager -> getFieldDefinitions ( $ entity , $ bundle -> id ( ) ) ; foreach ( $ field_definitions as $ field_name => $ field_definition ) { if ( ! empty ( $ field_definition -> getTargetBundle ( ) ) ) {... | Get all fields of type entity_access_field . |
48,673 | public function myTopicAccess ( AccountInterface $ account ) { $ user = $ this -> requestStack -> getCurrentRequest ( ) -> get ( 'user' ) ; if ( is_null ( $ user ) ) { $ user = User :: load ( $ account -> id ( ) ) ; } if ( ! $ user instanceof User ) { $ user = User :: load ( $ user ) ; if ( ! $ user instanceof User ) {... | Function that checks access on the my topic pages . |
48,674 | public function access ( AccountInterface $ account , FlagInterface $ flag , $ entity_id ) { if ( in_array ( $ flag -> id ( ) , $ this -> socialContentReport -> getReportFlagTypes ( ) ) ) { if ( ! $ account -> hasPermission ( 'flag ' . $ flag -> id ( ) ) ) { return AccessResult :: forbidden ( ) ; } $ entity = $ this ->... | Checks if user is allowed to flag . |
48,675 | public function getRelatedEntityUrl ( ) { $ link = "" ; $ related_object = $ this -> get ( 'field_activity_entity' ) -> getValue ( ) ; if ( ! empty ( $ related_object ) ) { $ target_type = $ related_object [ '0' ] [ 'target_type' ] ; $ target_id = $ related_object [ '0' ] [ 'target_id' ] ; if ( $ target_type === 'vote'... | Get related entity url . |
48,676 | public function getProfile ( UserInterface $ entity ) { $ user_profile = NULL ; try { $ storage = $ this -> entityTypeManager -> getStorage ( 'profile' ) ; if ( ! empty ( $ storage ) ) { $ user_profile = $ storage -> loadByUser ( $ entity , 'profile' , TRUE ) ; if ( $ user_profile === FALSE ) { $ user_profile = NULL ; ... | Get the Profile entity . |
48,677 | public function profileGetFieldValue ( $ field_name , ProfileInterface $ user_profile = NULL ) { if ( $ user_profile === NULL ) { return '' ; } try { $ value = $ user_profile -> get ( $ field_name ) -> value ; } catch ( \ Exception $ e ) { $ value = '' ; } return $ value ; } | Returns the value of a field for a given profile . |
48,678 | public function profileGetAddressFieldValue ( $ field_name , $ address_element , ProfileInterface $ user_profile = NULL ) { if ( $ user_profile === NULL ) { return '' ; } $ value = '' ; try { $ address = $ user_profile -> get ( $ field_name ) -> getValue ( ) ; if ( isset ( $ address [ '0' ] [ $ address_element ] ) ) { ... | Returns the value for the address field and element within address . |
48,679 | public function profileGetTaxonomyFieldValue ( $ field_name , ProfileInterface $ user_profile = NULL ) { if ( $ user_profile === NULL ) { return '' ; } $ names = array_map ( function ( TermInterface $ taxonomy_term ) { return $ taxonomy_term -> getName ( ) ; } , $ user_profile -> get ( $ field_name ) -> referencedEntit... | Returns the values of a taxonomy reference field . |
48,680 | public function parseFileFromModule ( $ file , $ module , $ profile ) { return $ this -> parse ( file_get_contents ( $ this -> getPath ( $ file , $ module , $ profile ) ) ) ; } | Parses YAML file into a PHP value . |
48,681 | public function checkForHomepageRedirect ( Event $ event ) { if ( PHP_SAPI === 'cli' || drupal_installation_attempted ( ) ) { return ; } if ( \ Drupal :: state ( ) -> get ( 'system.maintenance_mode' ) ) { return ; } if ( ! empty ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) && realpath ( DRUPAL_ROOT . '/index.php' ) != realpath ... | This method is called whenever the request event is dispatched . |
48,682 | protected function getCropTypes ( ) { $ croptypes = [ 'hero' , 'hero_small' , ] ; $ options = [ ] ; foreach ( $ croptypes as $ croptype ) { $ type = CropType :: load ( $ croptype ) ; if ( $ type instanceof CropType ) { $ options [ $ type -> id ( ) ] = $ type -> label ( ) ; } } return $ options ; } | Function that gets the available crop types . |
48,683 | public static function batchUpdateGroupContentVisibility ( Group $ group , $ new_type ) { $ entities = $ group -> getContentEntities ( ) ; $ posts = self :: getPostsFromGroup ( $ group ) ; foreach ( $ posts as $ pid => $ post ) { $ entities [ ] = $ post ; } $ memberships = $ group -> getMembers ( ) ; foreach ( $ member... | Update Group content after Group changed . |
48,684 | public function updateVisibility ( $ entity , $ new_type , array & $ context ) { $ default_visibility = SocialGroupHelperService :: getDefaultGroupVisibility ( $ new_type ) ; if ( $ entity instanceof Post ) { $ entity -> setVisibility ( $ default_visibility ) ; $ entity -> save ( ) ; } if ( $ entity instanceof Node ) {... | Update visibility for all Group Content based on a new group type . |
48,685 | public static function updateVisibilityFinishedCallback ( $ success , array $ results , array $ operations ) { $ messenger = \ Drupal :: messenger ( ) ; if ( $ success ) { $ messenger -> addStatus ( t ( 'Visibility of @count content item(s) updated.' , [ '@count' => count ( $ results ) ] ) ) ; } else { $ error_operatio... | Callback for finished batch events . |
48,686 | public static function getPostsFromGroup ( Group $ group ) { $ posts = & drupal_static ( __FUNCTION__ ) ; if ( ! isset ( $ posts ) ) { $ query = \ Drupal :: database ( ) -> select ( 'post__field_recipient_group' , 'pst' ) ; $ query -> addField ( 'pst' , 'entity_id' ) ; $ query -> condition ( 'pst.field_recipient_group_... | Load all Posts based on a certain group . |
48,687 | public function onFlag ( FlaggingEvent $ event ) { $ flagging = $ event -> getFlagging ( ) ; if ( ! in_array ( $ flagging -> getFlagId ( ) , $ this -> socialContentReport -> getReportFlagTypes ( ) ) ) { return ; } $ entity = $ flagging -> getFlaggable ( ) ; $ entity_type = $ entity -> getEntityTypeId ( ) ; $ entity_id ... | Listener for flagging events . |
48,688 | public static function getSendMessageTemplates ( $ destination ) { $ email_message_templates = [ ] ; $ message_templates = \ Drupal :: entityTypeManager ( ) -> getStorage ( 'message_template' ) -> loadMultiple ( ) ; foreach ( $ message_templates as $ message_template ) { $ destinations = $ message_template -> getThirdP... | Returns message templates for which given destination is enabled . |
48,689 | public static function getSendUserSettings ( $ destination , $ account ) { $ query = \ Drupal :: database ( ) -> select ( 'user_activity_send' , 'uas' ) ; $ query -> fields ( 'uas' , [ 'message_template' , 'frequency' ] ) ; $ query -> condition ( 'uas.uid' , $ account -> id ( ) ) ; $ query -> condition ( 'uas.destinati... | Returns notification settings of given user . |
48,690 | public static function setSendUserSettings ( $ destination , $ account , $ values ) { if ( is_object ( $ account ) && ! empty ( $ values ) ) { foreach ( $ values as $ message_template => $ frequency ) { $ query = \ Drupal :: database ( ) -> merge ( 'user_activity_send' ) ; $ query -> fields ( [ 'uid' => $ account -> id... | Set notification settings for given user . |
48,691 | public static function getSendTargetUser ( $ activity ) { if ( isset ( $ activity -> field_activity_recipient_user ) && ! empty ( $ activity -> field_activity_recipient_user -> target_id ) ) { $ target_id = $ activity -> field_activity_recipient_user -> target_id ; $ target_account = \ Drupal :: entityTypeManager ( ) -... | Returns target account . |
48,692 | public static function isUserOffline ( $ account ) { $ query = \ Drupal :: database ( ) -> select ( 'sessions' , 's' ) ; $ query -> addField ( 's' , 'timestamp' ) ; $ query -> condition ( 's.uid' , $ account -> id ( ) ) ; $ last_activity_time = $ query -> execute ( ) -> fetchField ( ) ; $ offline_window = \ Drupal :: c... | Check if user last activity was more than few minutes ago . |
48,693 | public function createInstances ( array $ plugin_ids , array $ configurations = [ ] ) { $ instances = [ ] ; foreach ( $ plugin_ids as $ plugin_id ) { $ configuration = isset ( $ configurations [ $ plugin_id ] ) ? $ configurations [ $ plugin_id ] : [ ] ; $ instances [ $ plugin_id ] = static :: createInstance ( $ plugin_... | Create multiple instances . |
48,694 | public function routes ( ) { $ collection = new RouteCollection ( ) ; if ( $ this -> moduleHandler -> moduleExists ( 'views_bulk_operations' ) ) { $ route = new Route ( '/node/{node}/all-enrollments/configure-action' , [ '_form' => '\Drupal\social_event_managers\Form\SocialEventManagementViewsBulkOperationsConfigureAct... | Returns a set of route objects . |
48,695 | public function massageMessageBody ( array $ message ) { $ line_endings = Settings :: get ( 'mail_line_endings' , PHP_EOL ) ; $ message [ 'body' ] = Markup :: create ( implode ( $ line_endings , array_map ( function ( $ body ) { if ( strlen ( strip_tags ( $ body ) ) === strlen ( $ body ) ) { $ body = str_replace ( "\r"... | Massages the message body into the format expected for rendering . |
48,696 | public function readNotificationCallback ( ) { $ account = \ Drupal :: currentUser ( ) ; $ activity_notifications = \ Drupal :: service ( 'activity_creator.activity_notifications' ) ; $ remaining_notifications = $ activity_notifications -> markAllNotificationsAsSeen ( $ account ) ; $ response = new AjaxResponse ( ) ; $... | Ajax callback to mark notifications as read . |
48,697 | public function commentPermalink ( Request $ request , CommentInterface $ comment ) { if ( $ entity = $ comment -> getCommentedEntity ( ) ) { if ( ! $ entity -> access ( 'view' ) ) { throw new AccessDeniedHttpException ( ) ; } if ( $ url = $ entity -> urlInfo ( 'canonical' ) ) { return $ this -> redirectToOriginalEntit... | Redirects comment links to the correct page depending on permissions . |
48,698 | public function redirectToOriginalEntity ( Url $ url , CommentInterface $ comment = NULL , Entity $ entity = NULL ) { $ options = [ ] ; if ( isset ( $ comment ) ) { $ options = [ 'fragment' => 'comment-' . $ comment -> id ( ) ] ; } return $ this -> redirect ( $ url -> getRouteName ( ) , $ url -> getRouteParameters ( ) ... | Redirects to the original entity when conditions are met . |
48,699 | public function getNotifications ( AccountInterface $ account , array $ status = [ ACTIVITY_STATUS_RECEIVED ] ) { $ ids = $ this -> getNotificationIds ( $ account , $ status ) ; return $ ids ; } | Returns the Notifications for a given account . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.