idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
44,200 | public function selectedChoices ( ) { $ val = $ this -> parsedVal ( ) ; if ( $ val !== null ) { if ( ! $ this -> p ( ) -> multiple ( ) ) { $ val = [ $ val ] ; } $ choices = iterator_to_array ( parent :: choices ( ) ) ; foreach ( $ val as $ v ) { if ( isset ( $ choices [ $ v ] ) ) { yield $ choices [ $ v ] ; } } } } | Retrieve the selected options . |
44,201 | public function reorderable ( ) { if ( $ this -> reorderable === null ) { if ( isset ( $ this -> dualSelectOptions [ 'reorderable' ] ) ) { $ this -> reorderable = boolval ( $ this -> dualSelectOptions [ 'reorderable' ] ) ; } else { $ this -> reorderable = false ; } } return $ this -> reorderable ; } | Determine if the right - side can be manually sorted . |
44,202 | public function dualSelectOptions ( ) { if ( $ this -> dualSelectOptions === null ) { $ this -> dualSelectOptions = $ this -> defaultDualSelectOptions ( ) ; } return $ this -> dualSelectOptions ; } | Retrieve the dual - select s options . |
44,203 | public function headerMenu ( ) { if ( $ this -> headerMenu === null ) { $ dashboardConfig = $ this -> dashboardConfig ( ) ; if ( isset ( $ dashboardConfig [ 'secondary_menu' ] ) ) { $ this -> headerMenu = $ this -> createHeaderMenu ( $ dashboardConfig [ 'secondary_menu' ] ) ; } else { $ this -> headerMenu = $ this -> c... | Retrieve the header menu . |
44,204 | public static function get ( ContainerInterface $ container ) { $ test_mode = $ container -> get ( 'config.factory' ) -> get ( 'acm.connector' ) -> get ( 'test_mode' ) ; if ( $ test_mode ) { return $ container -> get ( 'acm.test_agent_api' ) ; } return $ container -> get ( 'acm.agent_api' ) ; } | Creates an APIWrapperInterface object . |
44,205 | public function getDashboardItems ( ) { $ instances = [ ] ; $ sortedDefinitions = [ ] ; $ definitions = $ this -> getDefinitions ( ) ; foreach ( $ definitions as $ id => $ definition ) { $ sortedDefinitions [ $ definition [ 'group' ] ] [ $ id ] = $ definition ; } foreach ( $ sortedDefinitions as & $ localSortedDefiniti... | Creates pre - configured instances of all plugins . |
44,206 | public static function loadFromSku ( $ sku , $ langcode = '' , $ log_not_found = TRUE , $ create_translation = FALSE ) { $ skus_static_cache = & drupal_static ( __FUNCTION__ , [ ] ) ; $ is_multilingual = \ Drupal :: languageManager ( ) -> isMultilingual ( ) ; if ( $ is_multilingual && empty ( $ langcode ) ) { $ langcod... | Loads a SKU Entity from SKU . |
44,207 | public function getThumbnail ( ) { $ media = $ this -> getMedia ( ) ; foreach ( $ media as $ media_item ) { if ( isset ( $ media_item [ 'media_type' ] ) && $ media_item [ 'media_type' ] == 'image' ) { return $ media_item ; } } return [ ] ; } | Function to return first image from media files for a SKU . |
44,208 | public function getMedia ( $ download_media = TRUE , $ reset = FALSE ) { if ( ! $ reset && ! empty ( $ this -> mediaData ) ) { return $ this -> mediaData ; } if ( $ media_data = $ this -> get ( 'media' ) -> getString ( ) ) { $ update_sku = FALSE ; $ media_data = unserialize ( $ media_data ) ; if ( empty ( $ media_data ... | Function to return media files for a SKU . |
44,209 | protected function processMediaItem ( & $ update_sku , array & $ data , $ download = FALSE ) { $ media_item = $ data ; if ( isset ( $ data [ 'media_type' ] ) && $ data [ 'media_type' ] == 'image' ) { if ( ! empty ( $ data [ 'fid' ] ) ) { $ file = File :: load ( $ data [ 'fid' ] ) ; if ( ! ( $ file instanceof FileInterf... | Function to get processed media item with File entity in array . |
44,210 | protected function downloadMediaImage ( array $ data ) { $ args = [ '@file' => $ data [ 'file' ] , '@sku_id' => $ this -> id ( ) ] ; try { $ file_data = \ Drupal :: httpClient ( ) -> get ( $ data [ 'file' ] ) -> getBody ( ) ; } catch ( RequestException $ e ) { watchdog_exception ( 'acq_commerce' , $ e ) ; } if ( empty ... | Function to save image file into public dir . |
44,211 | public function updateCartObject ( $ cart ) { if ( isset ( $ cart -> customer_id ) ) { $ cart -> customer_id = ( string ) $ cart -> customer_id ; } $ current_billing = $ this -> getBilling ( ) ; if ( ! empty ( $ current_billing ) && empty ( $ cart -> billing ) ) { $ cart -> billing = $ current_billing ; } if ( isset ( ... | Function to update cart object . |
44,212 | public function updateCartItemsCount ( ) { $ this -> cartTotalCount = 0 ; foreach ( $ this -> items ( ) as $ item ) { $ this -> cartTotalCount += $ item [ 'qty' ] ; } } | Calculate the cart items quantity . |
44,213 | private function normalizeAddress ( $ address ) { if ( isset ( $ address -> extension ) ) { if ( ! is_object ( $ address -> extension ) ) { $ anObject = ( object ) $ address -> extension ; $ address -> extension = $ anObject ; } } return $ address ; } | Address normalizer . |
44,214 | protected function createProductOption ( $ langcode , $ option_id , $ option_value , $ attribute_id , $ attribute_code , $ weight ) { if ( strlen ( $ option_value ) == 0 ) { $ this -> logger -> warning ( 'Got empty value while syncing production options: @data' , [ '@data' => json_encode ( [ 'langcode' => $ langcode , ... | Create product option if not available or update the name . |
44,215 | public function showSidebarActions ( ) { $ actions = array_filter ( $ this -> sidebarActions ( ) , function ( $ action ) { return $ action [ 'active' ] === true ; } ) ; return count ( $ actions ) > 0 ; } | Determine if the sidebar s actions should be shown . |
44,216 | public function sidebarActions ( ) { if ( $ this -> sidebarActions === null ) { $ this -> setSidebarActions ( [ ] ) ; } if ( $ this -> parsedSidebarActions === false ) { $ this -> parsedSidebarActions = true ; $ this -> sidebarActions = $ this -> createSidebarActions ( $ this -> sidebarActions ) ; } return $ this -> si... | Retrieve the sidebar s actions . |
44,217 | protected function setSidebarActions ( array $ actions ) { $ this -> parsedSidebarActions = false ; $ this -> sidebarActions = $ this -> mergeActions ( $ this -> defaultSidebarActions ( ) , $ actions ) ; return $ this ; } | Set the sidebar s actions . |
44,218 | protected function createSidebarActions ( array $ actions ) { $ this -> actionsPriority = $ this -> defaultActionPriority ( ) ; $ sidebarActions = $ this -> parseAsSidebarActions ( $ actions ) ; return $ sidebarActions ; } | Build the sidebar s actions . |
44,219 | protected function parseAsSidebarActions ( array $ actions ) { $ sidebarActions = [ ] ; foreach ( $ actions as $ ident => $ action ) { $ ident = $ this -> parseActionIdent ( $ ident , $ action ) ; $ action = $ this -> parseActionItem ( $ action , $ ident , true ) ; if ( ! isset ( $ action [ 'priority' ] ) ) { $ action ... | Parse the given actions as object actions . |
44,220 | protected function defaultSidebarActions ( ) { if ( $ this -> defaultSidebarActions === null ) { $ this -> defaultSidebarActions = [ ] ; if ( $ this -> form ( ) ) { $ save = [ 'label' => $ this -> form ( ) -> submitLabel ( ) , 'ident' => 'save' , 'buttonType' => 'submit' , 'priority' => 90 ] ; $ this -> defaultSidebarA... | Retrieve the sidebar s default actions . |
44,221 | public function isObjDeletable ( ) { if ( $ this -> isObjDeletable === null ) { if ( ! $ this -> checkPermission ( 'delete' ) || ! $ this -> form ( ) ) { $ this -> isObjDeletable = false ; } else { $ obj = $ this -> form ( ) -> obj ( ) ; $ this -> isObjDeletable = ! ! $ obj -> id ( ) ; $ method = [ $ obj , 'isDeletable... | Determine if the object can be deleted . |
44,222 | public function isObjRevisionable ( ) { if ( $ this -> isObjRevisionable === null ) { if ( ! $ this -> checkPermission ( 'revision' ) || ! $ this -> form ( ) ) { $ this -> isObjRevisionable = false ; } else { $ obj = $ this -> form ( ) -> obj ( ) ; if ( ! $ obj -> id ( ) ) { $ this -> isObjRevisionable = false ; return... | Determine if the object has revisions . |
44,223 | public function isObjResettable ( ) { if ( $ this -> isObjResettable === null ) { if ( ! $ this -> checkPermission ( 'reset' ) || ! $ this -> form ( ) ) { $ this -> isObjResettable = false ; } else { $ this -> isObjResettable = true ; $ obj = $ this -> form ( ) -> obj ( ) ; $ method = [ $ obj , 'isResettable' ] ; if ( ... | Determine if the object can be reset . |
44,224 | public function isObjSavable ( ) { if ( $ this -> isObjSavable === null ) { if ( ! $ this -> checkPermission ( 'save' ) || ! $ this -> form ( ) ) { $ this -> isObjSavable = false ; } else { $ this -> isObjSavable = true ; $ obj = $ this -> form ( ) -> obj ( ) ; $ method = [ $ obj , 'isSavable' ] ; if ( is_callable ( $ ... | Determine if the object can be saved . |
44,225 | public function showFooter ( ) { if ( ! $ this -> checkPermission ( 'footer' ) ) { return false ; } if ( ! $ this -> isObjDeletable ( ) && ! $ this -> isObjResettable ( ) && ! $ this -> isObjRevisionable ( ) ) { return false ; } return $ this -> showFooter ; } | Determine if the sidebar s footer is visible . |
44,226 | protected function checkPermission ( $ permissionName ) { if ( isset ( $ this -> requiredGlobalAclPermissions [ $ permissionName ] ) ) { $ permissions = $ this -> requiredGlobalAclPermissions [ $ permissionName ] ; } elseif ( isset ( $ this -> requiredAclPermissions ( ) [ $ permissionName ] ) ) { $ permissions = $ this... | Return true if the user as required permissions . |
44,227 | public static function calculateDynamicParts ( $ country ) { $ dynamic_parts = [ ] ; $ addressFormatRepository = \ Drupal :: service ( 'address.address_format_repository' ) ; $ address_format = $ addressFormatRepository -> get ( $ country ) ; $ subdivisionRepository = \ Drupal :: service ( 'address.subdivision_reposito... | Calculate dynamic address parts per country . |
44,228 | public static function validateAddress ( & $ element , FormStateInterface $ form_state , & $ complete_form ) { $ address = $ element [ '#value' ] ; $ address_review_text = $ element [ '#address_review_text' ] ; $ address_failed_text = $ element [ '#address_failed_text' ] ; $ required_fields = [ 'street' , 'city' , 'reg... | Validates an acm_address element . |
44,229 | public static function addressAjaxCallback ( array $ form , FormStateInterface $ form_state , Request $ request ) { $ form_parents = explode ( '/' , $ request -> query -> get ( 'element_parents' ) ) ; $ form = NestedArray :: getValue ( $ form , $ form_parents ) ; $ values = $ form_state -> getValue ( $ form [ '#parents... | Ajax handler for country selector . |
44,230 | protected function processPageId ( $ page_id ) { $ page_ids = array_keys ( $ this -> getVisiblePages ( ) ) ; if ( empty ( $ page_id ) || ! in_array ( $ page_id , $ page_ids ) ) { $ page_id = reset ( $ page_ids ) ; } return $ page_id ; } | Processes the requested page ID . |
44,231 | protected function getFormConfiguration ( $ form_id ) { $ form_configuration = [ ] ; if ( isset ( $ this -> configuration [ 'child_forms' ] [ $ form_id ] ) ) { $ form_configuration = $ this -> configuration [ 'child_forms' ] [ $ form_id ] ; } return $ form_configuration ; } | Gets the configuration for the given form . |
44,232 | public function pushCustomersData ( ) { $ query = $ this -> connection -> select ( 'users_field_data' , 'user' ) ; $ query -> addField ( 'user' , 'mail' ) ; $ query -> condition ( 'status' , 0 , '>' ) ; $ query -> condition ( 'acm_customer_id' , 0 , '>' ) ; $ result = $ query -> countQuery ( ) -> execute ( ) -> fetchAs... | Push all the customers available in Drupal to upstream system . |
44,233 | public function pushCustomerData ( string $ mail ) { self :: pushCustomerDataToUpstream ( $ mail ) ; $ this -> logger ( ) -> info ( 'Pushed customer data for @mail, please check logs for more details.' , [ '@mail' => $ mail , ] ) ; } | Push specific customer available in Drupal to upstream system . |
44,234 | public static function pushCustomerDataToUpstream ( string $ mail ) { $ logger = \ Drupal :: logger ( 'AcmCustomerDrushCommands' ) ; $ user = user_load_by_mail ( $ mail ) ; if ( empty ( $ user ) ) { $ logger -> warning ( 'User with @mail not found, skipping.' , [ '@mail' => $ mail , ] ) ; } elseif ( empty ( $ user -> g... | Wrapper function to push data for particular customer . |
44,235 | public function setTemplateProperty ( $ propertyIdent ) { if ( $ propertyIdent === null ) { $ this -> templateProperty = null ; return $ this ; } $ property = null ; if ( $ propertyIdent instanceof PropertyInterface ) { $ property = $ propertyIdent ; $ propertyIdent = $ property -> ident ( ) ; } elseif ( ! is_string ( ... | Set the form object s property for template controller choices . |
44,236 | public function templateProperty ( ) { if ( $ this -> templateProperty === null ) { $ obj = $ this -> obj ( ) ; if ( $ obj instanceof TemplateableInterface ) { $ this -> setTemplateProperty ( $ obj -> property ( 'template_ident' ) ) ; } else { throw new RuntimeException ( sprintf ( 'Storage property owner is not define... | Retrieve form object s property for template controller choices . |
44,237 | public function displayVal ( ) { $ prop = $ this -> p ( ) ; $ val = $ this -> propertyVal ( ) ; if ( $ val !== null ) { return $ prop -> displayVal ( $ val ) ; } if ( $ prop -> allowNull ( ) ) { $ nil = $ this -> emptyChoice ( ) ; return ( string ) $ nil [ 'label' ] ; } return '' ; } | Retrieve display value . |
44,238 | public function addFormProperties ( array $ properties ) { foreach ( $ properties as $ propertyIdent => $ property ) { $ this -> addFormProperty ( $ propertyIdent , $ property ) ; } return $ this ; } | Add property controls to the form . |
44,239 | public function formProperties ( ) { $ sidebars = $ this -> sidebars ; if ( ! is_array ( $ sidebars ) ) { yield null ; } else { foreach ( $ this -> formProperties as $ formProperty ) { if ( $ formProperty -> active ( ) === false ) { continue ; } $ GLOBALS [ 'widget_template' ] = $ formProperty -> inputType ( ) ; yield ... | Yield the form s property controls . |
44,240 | public function addHiddenProperties ( array $ properties ) { foreach ( $ properties as $ propertyIdent => $ property ) { $ this -> addHiddenProperty ( $ propertyIdent , $ property ) ; } return $ this ; } | Add hidden property controls to the form . |
44,241 | public function addHiddenProperty ( $ propertyIdent , $ formProperty ) { if ( ! is_string ( $ propertyIdent ) ) { throw new InvalidArgumentException ( 'Property ident must be a string' ) ; } if ( is_array ( $ formProperty ) ) { $ this -> getOrCreateFormProperty ( $ propertyIdent , $ formProperty ) ; } elseif ( ! $ form... | Add a hidden property control to the form . |
44,242 | public function hiddenProperties ( ) { foreach ( $ this -> hiddenProperties as $ formProperty ) { if ( $ formProperty -> active ( ) === false ) { continue ; } yield $ formProperty -> propertyIdent ( ) => $ formProperty ; } } | Yield the form s hidden property controls . |
44,243 | public function getParentSku ( SKU $ sku ) { $ static = & drupal_static ( __FUNCTION__ , [ ] ) ; $ langcode = $ sku -> language ( ) -> getId ( ) ; $ sku_string = $ sku -> getSku ( ) ; if ( isset ( $ static [ $ langcode ] , $ static [ $ langcode ] [ $ sku_string ] ) ) { return $ static [ $ langcode ] [ $ sku_string ] ; ... | Get parent of current product . |
44,244 | public function getAllParentSkus ( string $ sku ) { $ static = & drupal_static ( __FUNCTION__ , [ ] ) ; if ( isset ( $ static [ $ sku ] ) ) { return $ static [ $ sku ] ; } $ query = $ this -> connection -> select ( 'acm_sku_field_data' , 'acm_sku' ) ; $ query -> addField ( 'acm_sku' , 'sku' ) ; $ query -> addField ( 'a... | Get all parent skus of a given sku . |
44,245 | public function mapObjects ( ) { if ( $ this -> mapObjects === null ) { $ objType = $ this -> objType ( ) ; if ( ! $ objType ) { throw new UnexpectedValueException ( sprintf ( '%1$s cannot create collection map. Object type is not defined.' , get_class ( $ this ) ) ) ; } $ loader = $ this -> collectionLoader ( ) ; $ lo... | Return all the objs with geographical information |
44,246 | public function getMiniCart ( ) { $ cart = $ this -> cartStorage -> getCart ( FALSE ) ; $ output = [ '#theme' => 'acm_cart_mini_cart' , '#attached' => [ 'library' => [ 'acm_cart/minicart' ] , ] , '#prefix' => '<div id="mini-cart-wrapper">' , '#suffix' => '</div><div id="cart_notification"></div>' , ] ; if ( ! $ this ->... | Helper function to get Mini cart . |
44,247 | protected function registerAdminServices ( Container $ container ) { $ container [ 'admin/config' ] = function ( Container $ container ) { $ appConfig = $ container [ 'config' ] ; $ extraConfigs = ( array ) $ appConfig [ 'admin_config' ] ; $ moduleAdminConfigs = [ ] ; foreach ( $ container [ 'module/classes' ] as $ mod... | Registers admin services . |
44,248 | protected function registerMetadataExtensions ( Container $ container ) { if ( ! isset ( $ container [ 'metadata/config' ] ) ) { $ container [ 'metadata/config' ] = function ( ) { return new MetadataConfig ( ) ; } ; } $ container -> extend ( 'metadata/config' , function ( MetadataConfig $ metaConfig , Container $ conta... | Registers metadata extensions . |
44,249 | protected function registerAuthExtensions ( Container $ container ) { $ container [ 'admin/authenticator' ] = function ( Container $ container ) { return new Authenticator ( [ 'logger' => $ container [ 'logger' ] , 'user_type' => User :: class , 'user_factory' => $ container [ 'model/factory' ] , 'token_type' => AuthTo... | Registers user - authentication extensions . |
44,250 | protected function registerViewExtensions ( Container $ container ) { if ( ! isset ( $ container [ 'view/mustache/helpers' ] ) ) { $ container [ 'view/mustache/helpers' ] = function ( ) { return [ ] ; } ; } $ container -> extend ( 'view/mustache/helpers' , function ( array $ helpers , Container $ container ) { $ adminU... | Registers view extensions . |
44,251 | protected function registerFactoryServices ( Container $ container ) { $ container [ 'property/input/factory' ] = function ( Container $ container ) { return new Factory ( [ 'base_class' => PropertyInputInterface :: class , 'arguments' => [ [ 'container' => $ container , 'logger' => $ container [ 'logger' ] ] ] , 'reso... | Registers the admin factories . |
44,252 | public function addFields ( ) { $ this -> logger -> info ( 'addFields() invoked to add newly added base fields to SKU.' ) ; $ fields = $ this -> getAllCustomFields ( ) ; $ config = $ this -> configFactory -> getEditable ( self :: BASE_FIELD_ADDITIONS_CONFIG ) ; $ existing_fields = $ config -> getRawData ( ) ; $ fields ... | Function to add all new field definitions from custom modules to SKU Base . |
44,253 | public function removeField ( $ field_code ) { $ config = $ this -> configFactory -> getEditable ( self :: BASE_FIELD_ADDITIONS_CONFIG ) ; $ fields = $ config -> getRawData ( ) ; if ( ! isset ( $ fields [ $ field_code ] ) ) { return ; } $ field = $ fields [ $ field_code ] ; unset ( $ fields [ $ field_code ] ) ; $ confi... | Remove base field from SKU entity . |
44,254 | public function updateFieldMetaInfo ( $ field_code , array $ field ) { $ config = $ this -> configFactory -> getEditable ( self :: BASE_FIELD_ADDITIONS_CONFIG ) ; $ existing_fields = $ config -> getRawData ( ) ; if ( empty ( $ existing_fields [ $ field_code ] ) ) { throw new \ Exception ( 'Field not available, try addi... | Function to update field definitions for the additional SKU base fields . |
44,255 | private function getAllCustomFields ( ) { $ fields = [ ] ; $ this -> moduleHandler -> alter ( 'acm_sku_base_field_additions' , $ fields ) ; foreach ( $ fields as $ field_code => $ field ) { $ fields [ $ field_code ] = $ this -> applyDefaults ( $ field_code , $ field ) ; } return $ fields ; } | Get all fields defined in custom modules . |
44,256 | private function applyDefaults ( $ field_code , array $ field ) { $ defaults = $ this -> getDefaults ( ) ; if ( empty ( $ field [ 'source' ] ) ) { $ field [ 'source' ] = $ field_code ; } if ( empty ( $ field [ 'label' ] ) ) { $ field [ 'label' ] = $ field_code ; } if ( empty ( $ field [ 'description' ] ) ) { $ field [ ... | Function to apply defaults and complete field definition . |
44,257 | public function silentRequest ( $ method , array $ params = [ ] ) { $ response = NULL ; if ( ! method_exists ( $ this , $ method ) ) { throw new \ InvalidArgumentException ( "Method {$method} doesn't exist." ) ; } $ this -> turnRouteEventsOff ( ) ; try { $ response = call_user_func_array ( [ $ this , $ method ] , $ par... | Perform a silent request . |
44,258 | public function getProductPosition ( $ category_id ) { $ endpoint = $ this -> apiVersion . "/agent/category/$category_id/position" ; $ doReq = function ( $ client , $ opt ) use ( $ endpoint ) { return ( $ client -> get ( $ endpoint , $ opt ) ) ; } ; $ result = [ ] ; try { $ result = $ this -> tryAgentRequest ( $ doReq ... | Get position of the products in a category . |
44,259 | public function setObjId ( $ objId ) { if ( ! is_scalar ( $ objId ) ) { throw new InvalidArgumentException ( sprintf ( 'Object ID must be a string or numerical value, received %s.' , ( is_object ( $ objId ) ? get_class ( $ objId ) : gettype ( $ objId ) ) ) ) ; } $ this -> objId = $ objId ; return $ this ; } | Set the object ID . |
44,260 | public function obj ( ) { if ( $ this -> obj === null ) { $ this -> obj = $ this -> createOrLoadObj ( ) ; if ( $ this -> obj instanceof ModelInterface ) { $ this -> objId = $ this -> obj -> id ( ) ; } else { $ this -> objId = null ; } } return $ this -> obj ; } | Retrieve the object . |
44,261 | protected function createOrLoadObj ( ) { if ( $ this -> objId ( ) ) { return $ this -> loadObj ( ) ; } elseif ( ! empty ( $ _GET [ 'clone_id' ] ) ) { return $ this -> cloneObj ( ) ; } elseif ( ! empty ( $ _GET [ 'blueprint_id' ] ) ) { return $ this -> createObjFromBluePrint ( ) ; } else { return $ this -> createObj ( )... | Create or load the object . |
44,262 | public static function processEmailUpdate ( & $ element , FormStateInterface $ form_state , & $ complete_form ) { $ element [ 'email' ] = [ '#type' => 'email' , '#title' => isset ( $ element [ '#title' ] ) ? $ element [ '#title' ] : '' , '#value' => isset ( $ element [ '#value' ] [ 'email' ] ) ? $ element [ '#value' ] ... | Expand an acm_email_update field into two text boxes . |
44,263 | protected function setRevNum ( $ revNum ) { if ( ! is_numeric ( $ revNum ) ) { throw new InvalidArgumentException ( sprintf ( 'Revision must be an integer, received %s.' , ( is_object ( $ revNum ) ? get_class ( $ revNum ) : gettype ( $ revNum ) ) ) ) ; } $ this -> revNum = ( int ) $ revNum ; return $ this ; } | Set the revision number to restore . |
44,264 | public function render ( $ address ) { $ element = [ '#prefix' => '<p class="address" translate="no">' , '#suffix' => '</p>' , '#post_render' => [ [ get_class ( $ this ) , 'postRender' ] , ] , '#cache' => [ 'contexts' => [ 'languages:' . LanguageInterface :: TYPE_INTERFACE , ] , ] , ] + $ this -> viewElement ( $ addres... | Render address . |
44,265 | protected function viewElement ( $ address , $ langcode ) { $ country_code = $ address -> country_id ; $ country_repository = \ Drupal :: service ( 'address.country_repository' ) ; $ countries = $ country_repository -> getList ( ) ; $ address_format_repository = \ Drupal :: service ( 'address.address_format_repository'... | Builds a renderable array for a single address item . |
44,266 | protected function getValues ( $ address , $ country_code , AddressFormat $ address_format ) { $ values = [ ] ; $ values [ 'title' ] = isset ( $ address -> title ) ? $ address -> title : '' ; $ values [ 'givenName' ] = isset ( $ address -> firstname ) ? $ address -> firstname : '' ; $ values [ 'familyName' ] = isset ( ... | Gets the address values used for rendering . |
44,267 | public static function postRender ( $ content , array $ element ) { $ address_format = $ element [ 'address_format' ] [ '#value' ] ; $ locale = $ element [ 'locale' ] [ '#value' ] ; if ( Locale :: match ( $ address_format -> getLocale ( ) , $ locale ) ) { $ format_string = '%country' . "\n" . $ address_format -> getLoc... | Inserts the rendered elements into the format string . |
44,268 | public static function replacePlaceholders ( $ string , array $ replacements ) { $ replacements = array_map ( 'trim' , $ replacements ) ; $ string = strtr ( $ string , $ replacements ) ; $ lines = explode ( "\n" , $ string ) ; foreach ( $ lines as $ index => $ line ) { $ line = trim ( preg_replace ( '/^[-,]+/' , '' , $... | Replaces placeholders in the given string . |
44,269 | protected function getAccessToken ( ) { $ cookies = $ _COOKIE ; if ( isset ( \ Drupal :: request ( ) -> cookies ) ) { $ cookies = \ Drupal :: request ( ) -> cookies -> all ( ) ; } $ cookie_name = 'Drupal_visitor_' . $ this -> accessTokenCookie ; if ( isset ( $ cookies [ $ cookie_name ] ) ) { return $ cookies [ $ cookie... | Gets a user access token . |
44,270 | public function setAccessToken ( $ token = NULL , $ expire = 0 ) { if ( ! empty ( $ expire ) ) { $ expire = REQUEST_TIME + $ expire ; } if ( isset ( \ Drupal :: request ( ) -> cookies ) ) { \ Drupal :: request ( ) -> cookies -> set ( 'Drupal_visitor_' . $ this -> accessTokenCookie , $ token ) ; } setrawcookie ( 'Drupal... | Sets the customer access token . |
44,271 | public function getWidget ( ) { if ( $ this -> widget === null ) { $ this -> widget = $ this -> createWidget ( ) ; } return $ this -> widget ; } | Retrieve the nested widget . |
44,272 | public function widgetData ( $ key = null , $ default = null ) { if ( $ this -> widgetData === null ) { $ this -> widgetData = $ this -> defaultWidgetData ( ) ; } if ( $ key ) { if ( isset ( $ this -> widgetData [ $ key ] ) ) { return $ this -> widgetData [ $ key ] ; } else { if ( ! is_string ( $ default ) && is_callab... | Retrieve the nested widget s options or a single option . |
44,273 | protected function renderDataRecursive ( $ data ) { if ( ! is_array ( $ data ) && ! ( $ data instanceof Traversable ) ) { throw new InvalidArgumentException ( 'The renderable data must be iterable.' ) ; } if ( ! $ this -> form ( ) instanceof ObjectContainerInterface ) { throw new RuntimeException ( sprintf ( 'The [%s] ... | Render the given data recursively . |
44,274 | protected function renderData ( $ data ) { $ obj = $ this -> form ( ) -> obj ( ) ; if ( $ obj instanceof ViewableInterface && $ obj -> view ( ) ) { $ data = $ obj -> view ( ) -> render ( $ data , $ obj -> viewController ( ) ) ; } else { $ data = preg_replace_callback ( '~\{\{\s*(.*?)\s*\}\}~i' , [ $ this , 'parseDataTo... | Render the given data . |
44,275 | public function getValue ( SKUInterface $ sku , string $ field_code , string $ context , $ value ) { $ event = new ProductInfoRequestedEvent ( $ sku , $ field_code , $ context , $ value ) ; $ this -> eventDispatcher -> dispatch ( ProductInfoRequestedEvents :: EVENT_NAME , $ event ) ; return $ event -> getValue ( ) ; } | Dispatch event and get updated value for specific field and context . |
44,276 | public function getTitle ( SKUInterface $ sku , string $ context ) { $ default = $ sku -> label ( ) ; return $ this -> getValue ( $ sku , 'title' , $ context , $ default ) ; } | Get title for particular SKU . |
44,277 | public function buildAddressOptions ( ) { $ address_formatter = new ACMAddressFormatter ( ) ; $ user = $ this -> getCurrentCommerceUser ( ) ; $ addresses = $ user -> getAddresses ( ) ; foreach ( $ addresses as $ address ) { $ option_id = $ address [ 'address_id' ] ; $ options [ $ option_id ] = [ 'id' => $ option_id , '... | Builds the address options list . |
44,278 | protected function getDefaultAddressOption ( $ type , array $ options ) { $ default_option = NULL ; foreach ( $ options as $ option_id => $ option ) { $ key = "default-{$type}" ; if ( isset ( $ option [ $ key ] ) && $ option [ $ key ] ) { $ default_option = $ option_id ; break ; } } if ( ! $ default_option || ! isset (... | Finds the default address option . |
44,279 | public static function findAddress ( $ address_id ) { $ found_address = NULL ; $ user = \ Drupal :: service ( 'acm.commerce_user_manager' ) -> getAccount ( ) ; $ addresses = $ user -> getAddresses ( ) ; $ extra_keys = [ 'customer_id' , 'customer_address_id' , 'region_id' , 'default_billing' , 'default_shipping' , 'exte... | Finds an address by id . |
44,280 | protected function buildStoredAddressOptions ( array $ pane_form , FormStateInterface $ form_state , $ type = 'billing' , array $ current_address = [ ] ) { $ field_name = "{$type}_address_options" ; $ options = $ this -> buildAddressOptions ( ) ; $ user_input = $ form_state -> getUserInput ( ) ; $ values = NestedArray ... | Decorates the form with the stored address options . |
44,281 | private function updateCart ( FormStateInterface $ form_state ) { try { $ cart = $ this -> cartStorage -> updateCart ( ) ; $ response_message = $ cart -> get ( 'response_message' ) ; if ( ! empty ( $ response_message [ 1 ] ) ) { if ( $ response_message [ 1 ] == 'success' ) { $ this -> successMessage = $ response_messag... | Cart update utility . |
44,282 | public function setData ( array $ data ) { $ keys = $ this -> validDataFromRequest ( ) ; $ data = array_intersect_key ( $ data , array_flip ( $ keys ) ) ; $ this -> mergeData ( $ data ) ; return $ this ; } | Sets the action data . |
44,283 | public function getParams ( array $ keys = null ) { $ params = $ this -> params ; if ( $ keys ) { $ subset = [ ] ; foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ params ) ) { $ subset [ $ key ] = $ params [ $ key ] ; } } return $ subset ; } return $ params ; } | Get the associative array of request parameters . |
44,284 | public function getParam ( $ key , $ default = null ) { $ params = $ this -> params ; if ( is_array ( $ params ) && isset ( $ params [ $ key ] ) ) { $ result = $ params [ $ key ] ; } else { if ( ! is_string ( $ default ) && is_callable ( $ default ) ) { $ result = $ default ( ) ; } else { $ result = $ default ; } } ret... | Get the request parameter value . |
44,285 | protected function assertValidDisk ( $ disk ) { $ translator = $ this -> translator ( ) ; if ( $ disk === null ) { $ message = $ translator -> translate ( 'Default filesystem [{{ defaultFilesystemConnection }}] is not defined' , [ '{{ defaultFilesystemConnection }}' => 'config.filesystem.default_connection' ] ) ; throw... | Asserts that the filesystem connection is valid throws an exception if not . |
44,286 | protected function assertValidPath ( $ path ) { $ translator = $ this -> translator ( ) ; if ( empty ( $ path ) && ! is_numeric ( $ path ) ) { $ message = $ translator -> translate ( '{{ parameter }} required and must be a {{ expectedType }}' , [ '{{ parameter }}' => '"path"' , '{{ expectedType }}' => 'string' , ] ) ; ... | Asserts that the path is valid throws an exception if not . |
44,287 | protected function assertValidName ( $ name ) { if ( ! is_string ( $ name ) && $ name !== null ) { $ actualType = is_object ( $ name ) ? get_class ( $ name ) : gettype ( $ name ) ; $ message = $ this -> translator ( ) -> translate ( '{{ parameter }} must be a {{ expectedType }}, received {{ actualType }}' , [ '{{ param... | Asserts that the custom file name is valid throws an exception if not . |
44,288 | protected function assertValidDisposition ( $ disposition ) { $ translator = $ this -> translator ( ) ; if ( ! in_array ( $ disposition , [ self :: DISPOSITION_ATTACHMENT , self :: DISPOSITION_INLINE ] ) ) { throw new InvalidArgumentException ( sprintf ( 'The disposition must be either "%s" or "%s".' , self :: DISPOSIT... | Asserts that the response disposition is valid throws an exception if not . |
44,289 | public function setMapOptions ( array $ settings ) { if ( isset ( $ settings [ 'api_key' ] ) ) { $ this -> setApiKey ( $ settings [ 'api_key' ] ) ; } if ( $ this -> mapOptions ) { $ this -> mapOptions = array_replace_recursive ( $ this -> mapOptions , $ settings ) ; } else { $ this -> mapOptions = array_replace_recursi... | Set the map widget s options . |
44,290 | public function mapOptions ( ) { if ( $ this -> mapOptions === null ) { $ this -> mapOptions = $ this -> defaultMapOptions ( ) ; } return $ this -> mapOptions ; } | Retrieve the map widget s options . |
44,291 | private function booleanInput ( PropertyInterface $ prop , $ label ) { $ climate = $ this -> climate ( ) ; $ opts = [ 1 => $ prop -> trueLabel ( ) , 0 => $ prop -> falseLabel ( ) ] ; $ input = $ climate -> radio ( $ label , $ opts ) ; return $ input ; } | Get a CLI input from a boolean property . |
44,292 | public function checkAccess ( AccountInterface $ account ) { $ cart = $ this -> cartStorage ; if ( empty ( $ cart ) || $ cart -> isEmpty ( ) ) { return AccessResult :: forbidden ( 'Invalid cart' ) ; } return AccessResult :: allowedIfHasPermission ( $ account , 'access checkout' ) ; } | Checks access for the form page . |
44,293 | protected function loadCheckoutFlowPlugin ( ) { $ checkoutFlowPlugin = $ this -> config -> get ( 'checkout_flow_plugin' ) ? : 'multistep_default' ; return $ this -> acmCheckoutFlowManager -> createInstance ( $ checkoutFlowPlugin , [ 'validate_current_step' => TRUE ] ) ; } | Loads the configured CheckoutFlow plugin . |
44,294 | public function errorHandler ( int $ error_number , string $ error_message ) { switch ( $ error_number ) { case E_RECOVERABLE_ERROR : throw new Exception ( $ error_message , $ error_number ) ; } } | Custom error handler that converts E_RECOVERABLE_ERROR into an exception . |
44,295 | public function oppositeLanguages ( ) { $ cfg = $ this -> app ( ) -> config ( ) ; $ locales = $ this -> locales ( ) ; $ languages = $ locales [ 'languages' ] ; $ opposite = [ ] ; $ orig = $ this -> origLanguage ( ) ; foreach ( $ languages as $ ident => $ opts ) { if ( $ ident != $ orig ) { $ opposite [ ] = $ ident ; } ... | Get opposite languages from DATABASE |
44,296 | public function locales ( ) { if ( $ this -> locales ) { return $ this -> locales ; } $ cfg = $ this -> app ( ) -> config ( ) ; $ locales = isset ( $ cfg [ 'locales' ] ) ? $ cfg [ 'locales' ] : [ ] ; $ languages = isset ( $ locales [ 'languages' ] ) ? $ locales [ 'languages' ] : [ ] ; $ file = isset ( $ locales [ 'file... | Locales set in config . json Expects languages | file | default_language |
44,297 | public function columns ( ) { $ orig = $ this -> origLanguage ( ) ; $ opposites = $ this -> oppositeLanguages ( ) ; $ columns = [ $ orig ] ; foreach ( $ opposites as $ lang ) { $ columns [ ] = $ lang ; } $ columns [ ] = 'context' ; return $ columns ; } | Columns of CSV file This is already built to take multiple languages |
44,298 | public function export ( ) { $ headers = $ this -> fileHeaders ( ) ; $ rows = $ this -> rows ( ) ; $ writer = Writer :: createFromFileObject ( new SplTempFileObject ( ) ) ; $ writer -> setNewline ( "\r\n" ) ; $ writer -> setOutputBOM ( Writer :: BOM_UTF8 ) ; $ writer -> insertOne ( $ headers ) ; foreach ( $ rows as $ r... | Export to CSV |
44,299 | public function collection ( ) { if ( $ this -> collection ) { return $ this -> collection ; } if ( ! $ this -> collectionConfig ( ) ) { throw new Exception ( sprintf ( 'Collection Config required for "%s"' , get_class ( $ this ) ) ) ; } $ collection = new CollectionLoader ( [ 'logger' => $ this -> logger , 'factory' =... | Actual object collection |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.