idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
44,300
private function prepareOptions ( ) { $ metadata = $ this -> metadata ( ) ; if ( ! $ this -> exportIdent ( ) ) { $ exportIdent = $ this -> exportIdent ( ) ? : $ this -> metadata ( ) -> get ( 'admin.default_export' ) ; if ( ! $ exportIdent ) { throw new Exception ( sprintf ( 'No export ident defined for "%s" in %s' , $ ...
Set all data from the metadata .
44,301
private function rows ( ) { $ collection = $ this -> collection ( ) ; $ properties = $ this -> properties ( ) ; $ metadata = $ this -> metadata ( ) ; foreach ( $ collection as $ c ) { $ row = [ ] ; foreach ( $ properties as $ p ) { $ propertyMetadata = $ metadata -> get ( 'properties.' . $ p ) ; $ prop = $ this -> prop...
CSV rows from collection
44,302
private function stripContent ( $ text ) { if ( $ this -> convertBrToNewlines ( ) ) { $ text = $ this -> brToNewline ( $ text ) ; } if ( $ this -> stripTags ( ) ) { $ text = strip_tags ( $ text ) ; } return $ text ; }
Clean output content .
44,303
public function baseUrl ( $ targetPath = null ) { if ( ! isset ( $ this -> baseUrl ) ) { throw new RuntimeException ( sprintf ( 'The base URI is not defined for [%s]' , get_class ( $ this ) ) ) ; } if ( $ targetPath !== null ) { return $ this -> createAbsoluteUrl ( $ this -> baseUrl , $ targetPath ) ; } return rtrim ( ...
Retrieve the base URI of the application .
44,304
public function adminUrl ( $ targetPath = null ) { if ( ! isset ( $ this -> adminUrl ) ) { throw new RuntimeException ( sprintf ( 'The Admin URI is not defined for [%s]' , get_class ( $ this ) ) ) ; } if ( $ targetPath !== null ) { return $ this -> createAbsoluteUrl ( $ this -> adminUrl , $ targetPath ) ; } return rtri...
Retrieve the URI of the administration - area .
44,305
protected function isRelativeUri ( $ uri ) { if ( $ uri && ! parse_url ( $ uri , PHP_URL_SCHEME ) ) { if ( ! in_array ( $ uri [ 0 ] , [ '/' , '#' , '?' ] ) ) { return true ; } } return false ; }
Determine if the given URI is relative .
44,306
protected function pager ( ) { if ( $ this -> pager === null ) { $ this -> pager = $ this -> createPagination ( ) ; } return $ this -> pager ; }
Retrieve the Paginationb object .
44,307
private function createUser ( ) { $ this -> climate ( ) -> underline ( ) -> out ( $ this -> translator ( ) -> translate ( 'Create a new Charcoal Administrator User' ) ) ; $ user = $ this -> modelFactory ( ) -> create ( User :: class ) ; $ prompts = $ this -> userPrompts ( ) ; $ properties = $ user -> properties ( array...
Create a new user in the database
44,308
public function dataSourceFilter ( $ sourceIdent ) { if ( ! is_string ( $ sourceIdent ) ) { throw new InvalidArgumentException ( 'Data source identifier must be a string' ) ; } $ filters = array_merge ( $ this -> defaultDataSourceFilters ( ) , $ this -> dataSourceFilters ) ; if ( isset ( $ filters [ $ sourceIdent ] ) )...
Retrieve the callable filter for the given data source .
44,309
public function setup ( ) { $ container = $ this -> app ( ) -> getContainer ( ) ; if ( substr ( ltrim ( $ container [ 'request' ] -> getUri ( ) -> getPath ( ) , '/' ) , 0 , 5 ) !== 'admin' ) { return $ this ; } if ( session_id ( ) === '' ) { session_start ( ) ; } $ container -> register ( new AdminServiceProvider ( ) )...
Charcoal Administration Setup .
44,310
public function setupRoutes ( ) { if ( $ this -> routeManager === null ) { parent :: setupRoutes ( ) ; $ this -> app ( ) -> any ( '{catchall:.*}' , 'notFoundHandler' ) ; } return $ this ; }
Set up the module s routes and handlers .
44,311
public function access ( Route $ route , RouteMatchInterface $ route_match , AccountInterface $ account ) { return AccessResult :: allowedIf ( $ this -> cartStorage -> getCart ( ) && $ this -> cartStorage -> getCart ( ) -> getCartItemsCount ( ) > 0 ) ; }
Determine access by ensuring that the cart object has items .
44,312
public function isProductInStock ( SKU $ sku ) { $ sku_string = $ sku -> getSku ( ) ; $ static = & drupal_static ( self :: class . '_' . __FUNCTION__ , [ ] ) ; if ( isset ( $ static [ $ sku_string ] ) ) { return $ static [ $ sku_string ] ; } $ static [ $ sku_string ] = FALSE ; $ stock = $ this -> getStock ( $ sku_strin...
Check if product is in stock .
44,313
public function getStockQuantity ( string $ sku ) { $ stock = $ this -> getStock ( $ sku ) ; if ( empty ( $ stock [ 'status' ] ) ) { return 0 ; } return ( int ) $ stock [ 'quantity' ] ; }
Get stock quantity .
44,314
public function getStock ( string $ sku ) { $ query = $ this -> connection -> select ( 'acm_sku_stock' ) ; $ query -> fields ( 'acm_sku_stock' ) ; $ query -> condition ( 'sku' , $ sku ) ; $ result = $ query -> execute ( ) -> fetchAll ( ) ; if ( empty ( $ result ) ) { return [ ] ; } if ( count ( $ result ) > 1 ) { $ thi...
Get current stock data for SKU from DB .
44,315
public function refreshStock ( string $ sku ) { try { $ stock = $ this -> apiWrapper -> skuStockCheck ( $ sku ) ; $ this -> processStockMessage ( $ stock ) ; } catch ( \ Exception $ e ) { $ this -> logger -> error ( 'Exception occurred while resetting stock for sku: @sku, message: @message' , [ '@sku' => $ sku , '@mess...
Refresh stock for an SKU from API .
44,316
public function updateStock ( $ sku , $ quantity , $ status ) { $ this -> acquireLock ( $ sku ) ; $ current = $ this -> getStock ( $ sku ) ; if ( empty ( $ current ) || $ current [ 'status' ] != $ status || $ current [ 'quantity' ] != $ quantity ) { $ new = [ 'quantity' => $ quantity , 'status' => $ status , ] ; $ this...
Update stock data for particular sku .
44,317
public function processStockMessage ( array $ stock , $ store_id = 0 ) { if ( ! isset ( $ stock [ 'sku' ] ) || ! strlen ( $ stock [ 'sku' ] ) ) { $ this -> logger -> error ( 'Invalid or empty product SKU. Stock message: @message' , [ '@message' => json_encode ( $ stock ) , ] ) ; return ; } $ langcode = NULL ; if ( empt...
Process stock message received in API .
44,318
private function acquireLock ( string $ sku ) { $ lock_key = self :: class . ':' . $ sku ; do { $ lock_acquired = $ this -> lock -> acquire ( $ lock_key ) ; if ( ! $ lock_acquired ) { usleep ( 500000 ) ; } } while ( ! $ lock_acquired ) ; }
Helper function to acquire lock .
44,319
private function releaseLock ( string $ sku ) { $ lock_key = self :: class . ':' . $ sku ; $ this -> lock -> release ( $ lock_key ) ; }
Helper function to release lock .
44,320
private function isStockStatusChanged ( array $ old , array $ new ) { if ( $ old [ 'status' ] != $ new [ 'status' ] ) { return TRUE ; } $ had_quantity = ( bool ) $ old [ 'quantity' ] ; $ has_quantity = ( bool ) $ new [ 'quantity' ] ; if ( $ new [ 'status' ] && $ had_quantity != $ has_quantity ) { return TRUE ; } return...
Get field code for which value is requested .
44,321
public function removeStockEntry ( string $ sku ) { if ( empty ( $ sku ) ) { return ; } $ query = $ this -> connection -> select ( 'acm_sku_field_data' , 'sku' ) ; $ query -> condition ( 'sku' , $ sku ) ; $ query -> addField ( 'sku' , 'sku' ) ; $ result = $ query -> execute ( ) -> fetchAssoc ( ) ; if ( ! empty ( $ resu...
Remove stock entry .
44,322
public function displayName ( ) { if ( $ this -> displayName ) { $ name = $ this -> displayName ; } else { $ name = $ this -> propertyIdent ( ) ; } if ( $ this -> p ( ) -> l10n ( ) ) { $ name .= '[' . $ this -> lang ( ) . ']' ; } if ( $ this -> multiple ( ) ) { $ name .= '[]' ; } return $ name ; }
Retrieve the display name .
44,323
public function cleanCustomerData ( array $ customer ) { if ( isset ( $ customer [ 'customer_id' ] ) ) { $ customer [ 'customer_id' ] = ( string ) $ customer [ 'customer_id' ] ; } if ( isset ( $ customer [ 'addresses' ] ) ) { $ customer [ 'addresses' ] = array_values ( $ customer [ 'addresses' ] ) ; foreach ( $ custome...
Clean customer data before sending to API .
44,324
public function cleanCustomerAddress ( array $ address ) { if ( isset ( $ address [ 'customer_address_id' ] ) && empty ( $ address [ 'address_id' ] ) ) { $ address [ 'address_id' ] = $ address [ 'customer_address_id' ] ; } return $ this -> cleanAddress ( $ address ) ; }
Get cleaned customer address .
44,325
public function cleanCartAddress ( $ address ) { $ address = ( array ) $ address ; $ address = $ this -> cleanAddress ( $ address ) ; if ( isset ( $ address [ 'customer_address_id' ] ) ) { $ address [ 'customer_address_id' ] = ( int ) $ address [ 'customer_address_id' ] ; } if ( isset ( $ address [ 'address_id' ] ) ) {...
Get cleaned cart address .
44,326
public function normaliseExtension ( $ data ) { if ( is_object ( $ data ) ) { if ( isset ( $ data -> extension ) ) { $ data -> extension = ( object ) $ data -> extension ; } } elseif ( is_array ( $ data ) ) { if ( isset ( $ data [ 'extension' ] ) ) { $ data [ 'extension' ] = ( object ) $ data [ 'extension' ] ; } } retu...
Extensions must always be objects and not arrays .
44,327
public function cleanCart ( $ cart ) { if ( isset ( $ cart -> customer_id ) && empty ( $ cart -> customer_id ) ) { unset ( $ cart -> customer_id ) ; } elseif ( isset ( $ cart -> customer_id ) ) { $ cart -> customer_id = ( string ) $ cart -> customer_id ; } if ( isset ( $ cart -> customer_email ) && empty ( $ cart -> cu...
Clean up cart data .
44,328
public function defaultArguments ( ) { $ arguments = [ 'email' => [ 'prefix' => 'e' , 'longPrefix' => 'email' , 'description' => 'The user email' ] , 'password' => [ 'prefix' => 'p' , 'longPrefix' => 'password' , 'description' => 'The user password' , 'inputType' => 'password' ] , 'sendEmail' => [ 'longPrefix' => 'send...
Retrieve the available default arguments of this action .
44,329
protected function loadUser ( $ handle ) { if ( ! $ handle ) { return null ; } $ user = $ this -> modelFactory ( ) -> create ( User :: class ) ; $ user -> load ( $ handle ) ; if ( $ user -> id ( ) !== null ) { return $ user ; } $ user -> loadFrom ( 'email' , $ handle ) ; if ( $ user -> id ( ) !== null ) { return $ user...
Retrieve the user with the given login handle .
44,330
public function access ( ) { $ version = $ this -> configFactory -> get ( 'acm.connector' ) -> get ( 'api_version' ) ; if ( ( $ version === 'v2' ) && ( $ this -> account -> hasPermission ( 'access commerce administration pages' ) ) ) { return AccessResult :: allowed ( ) ; } return AccessResult :: forbidden ( ) ; }
Check if v2 is set up and user can access commerce admin pages .
44,331
public function selectOptions ( ) { if ( $ this -> selectOptions === null ) { $ this -> selectOptions = $ this -> defaultSelectOptions ( ) ; } return $ this -> selectOptions ; }
Retrieve the select picker s options .
44,332
public function build ( ) { $ route_name = $ this -> routeMatch -> getRouteName ( ) ; if ( $ route_name !== 'acm_checkout.form' ) { return [ ] ; } $ config = \ Drupal :: config ( 'acm_checkout.settings' ) ; $ checkout_flow_plugin = $ config -> get ( 'checkout_flow_plugin' ) ? : 'multistep_default' ; $ plugin_manager = ...
Builds the checkout progress block .
44,333
private function getExceptionScenarios ( ) { $ scenarios = [ ] ; $ api_wrapper_interface = class_implements ( $ this -> apiWrapper ) ; if ( $ api_wrapper_interface ) { $ scenarios = get_class_methods ( array_shift ( $ api_wrapper_interface ) ) ; } return $ scenarios ; }
Fetches exception scenarios .
44,334
public function propertiesOptions ( ) { if ( $ this -> propertiesOptions === null ) { $ this -> propertiesOptions = $ this -> defaultPropertiesOptions ( ) ; } return $ this -> propertiesOptions ; }
Retrieve the property customizations for the collection .
44,335
public function viewOptions ( $ propertyIdent ) { if ( ! $ propertyIdent ) { return [ ] ; } if ( $ propertyIdent instanceof PropertyInterface ) { $ propertyIdent = $ propertyIdent -> ident ( ) ; } $ options = $ this -> propertiesOptions ( ) ; if ( isset ( $ options [ $ propertyIdent ] [ 'view_options' ] ) ) { return $ ...
Retrieve the view options for the given property .
44,336
public function collectionProperties ( ) { $ props = $ this -> properties ( ) ; foreach ( $ props as $ propertyIdent => $ property ) { $ propertyMetadata = $ props [ $ propertyIdent ] ; $ p = $ this -> propertyFactory ( ) -> create ( $ propertyMetadata [ 'type' ] ) ; $ p -> setIdent ( $ propertyIdent ) ; $ p -> setData...
Properties to display in collection template and their order as set in object metadata
44,337
public function objectActions ( ) { $ this -> rawObjectActions ( ) ; $ objectActions = [ ] ; if ( is_array ( $ this -> objectActions ) ) { $ objectActions = $ this -> parseAsObjectActions ( $ this -> objectActions ) ; } return $ objectActions ; }
Retrieve the table s object actions .
44,338
public function rawObjectActions ( ) { if ( $ this -> objectActions === null ) { $ parsed = $ this -> parsedObjectActions ; $ collectionConfig = $ this -> collectionConfig ( ) ; if ( isset ( $ collectionConfig [ 'object_actions' ] ) ) { $ actions = $ collectionConfig [ 'object_actions' ] ; } else { $ actions = [ ] ; } ...
Retrieve the table s object actions without rendering it .
44,339
public function setObjectActions ( array $ actions ) { $ this -> parsedObjectActions = false ; $ actions = $ this -> mergeActions ( $ this -> defaultObjectActions ( ) , $ actions ) ; if ( isset ( $ actions [ 'edit' ] ) ) { $ actions [ 'edit' ] [ 'actionType' ] = 'seamless' ; } $ this -> objectActions = $ actions ; retu...
Set the table s object actions .
44,340
public function emptyListActions ( ) { $ actions = $ this -> listActions ( ) ; $ filteredArray = array_filter ( $ actions , function ( $ action ) { return $ action [ 'empty' ] ; } ) ; return array_values ( $ filteredArray ) ; }
Retrieve the table s empty collection actions .
44,341
public function listActions ( ) { if ( $ this -> listActions === null ) { $ collectionConfig = $ this -> collectionConfig ( ) ; if ( isset ( $ collectionConfig [ 'list_actions' ] ) ) { $ actions = $ collectionConfig [ 'list_actions' ] ; } else { $ actions = [ ] ; } $ this -> setListActions ( $ actions ) ; } if ( $ this...
Retrieve the table s collection actions .
44,342
public function objectEditUrl ( ) { $ model = $ this -> proto ( ) ; $ url = 'object/edit?main_menu={{ main_menu }}&obj_type=' . $ this -> objType ( ) ; if ( $ model -> view ( ) ) { $ url = $ model -> render ( ( string ) $ url ) ; } else { $ url = preg_replace ( '~{{\s*id\s*}}~' , $ this -> currentObjId , $ url ) ; } re...
Generate URL for editing an object
44,343
public function objectCreateUrl ( ) { $ actions = $ this -> listActions ( ) ; if ( $ actions ) { foreach ( $ actions as $ action ) { if ( isset ( $ action [ 'ident' ] ) && $ action [ 'ident' ] === 'create' ) { if ( isset ( $ action [ 'url' ] ) ) { $ model = $ this -> proto ( ) ; if ( $ model -> view ( ) ) { $ action [ ...
Generate URL for creating an object
44,344
public function isObjCreatable ( ) { $ model = $ this -> proto ( ) ; $ method = [ $ model , 'isCreatable' ] ; if ( is_callable ( $ method ) ) { return call_user_func ( $ method ) ; } return true ; }
Determine if the object can be created .
44,345
public function isObjEditable ( ) { $ model = ( $ this -> currentObj ) ? $ this -> currentObj : $ this -> proto ( ) ; $ method = [ $ model , 'isEditable' ] ; if ( is_callable ( $ method ) ) { return call_user_func ( $ method ) ; } return true ; }
Determine if the object can be modified .
44,346
protected function createCollectionLoader ( ) { $ loader = $ this -> createCollectionLoaderFromTrait ( ) ; $ mainMenu = filter_input ( INPUT_GET , 'main_menu' , FILTER_SANITIZE_STRING ) ; if ( $ mainMenu ) { $ loader -> setCallback ( function ( & $ obj ) use ( $ mainMenu ) { if ( ! $ obj [ 'main_menu' ] ) { $ obj [ 'ma...
Create a collection loader .
44,347
protected function setListActions ( array $ actions ) { $ this -> parsedListActions = false ; $ this -> listActions = $ this -> mergeActions ( $ this -> defaultListActions ( ) , $ actions ) ; return $ this ; }
Set the table s collection actions .
44,348
protected function createListActions ( array $ actions ) { $ this -> actionsPriority = $ this -> defaultActionPriority ( ) ; $ listActions = $ this -> parseAsListActions ( $ actions ) ; return $ listActions ; }
Build the table collection actions .
44,349
protected function parseAsListActions ( array $ actions ) { $ listActions = [ ] ; foreach ( $ actions as $ ident => $ action ) { $ ident = $ this -> parseActionIdent ( $ ident , $ action ) ; $ action = $ this -> parseActionItem ( $ action , $ ident , true ) ; if ( ! isset ( $ action [ 'priority' ] ) ) { $ action [ 'pri...
Parse the given actions as collection actions .
44,350
protected function defaultObjectActions ( ) { if ( $ this -> defaultObjectActions === null ) { $ edit = [ 'label' => $ this -> translator ( ) -> translation ( 'Modify' ) , 'url' => $ this -> objectEditUrl ( ) . '&obj_id={{id}}' , 'ident' => 'edit' , 'priority' => 1 ] ; $ this -> defaultObjectActions = [ $ edit ] ; } re...
Retrieve the table s default object actions .
44,351
protected function parsePropertyCellClasses ( PropertyInterface $ property , ModelInterface $ object = null ) { unset ( $ object ) ; $ ident = $ property -> ident ( ) ; $ classes = [ sprintf ( 'property-%s' , $ ident ) ] ; $ options = $ this -> viewOptions ( $ ident ) ; if ( isset ( $ options [ 'classes' ] ) ) { if ( i...
Filter the table cell s CSS classes before the property is assigned to the object row .
44,352
public function httpRequest ( ) { if ( $ this -> httpRequest === null ) { throw new RuntimeException ( sprintf ( 'PSR-7 HTTP Request is not defined for "%s"' , get_class ( $ this ) ) ) ; } return $ this -> httpRequest ; }
Retrieve the HTTP request .
44,353
public function httpResponse ( ) { if ( $ this -> httpResponse === null ) { throw new RuntimeException ( sprintf ( 'PSR-7 HTTP Response is not defined for "%s"' , get_class ( $ this ) ) ) ; } return $ this -> httpResponse ; }
Retrieve the HTTP response .
44,354
protected function setOwnerReference ( $ uid , $ owner_id ) { $ key = $ uid . ':' . self :: OWNER_REFERENCE_NAMESPACE ; if ( ! $ this -> lockBackend -> acquire ( $ key ) ) { $ this -> lockBackend -> wait ( $ key ) ; if ( ! $ this -> lockBackend -> acquire ( $ key ) ) { throw new TempStoreException ( "Couldn't acquire l...
Stores a reference to the current store owner for a particular user .
44,355
protected function getOwnerReference ( $ uid ) { $ key = $ uid . ':' . self :: OWNER_REFERENCE_NAMESPACE ; if ( ( $ object = $ this -> storage -> get ( $ key ) ) && ( $ object -> owner == $ uid ) ) { return $ object -> data ; } }
Gets the reference to the current store owner for a particular user .
44,356
protected function loadObjectCollection ( $ objType ) { $ proto = $ this -> modelFactory ( ) -> get ( $ objType ) ; $ loader = $ this -> collectionLoader ( ) ; $ loader -> setModel ( $ proto ) ; $ loader -> addFilter ( 'active' , true ) ; $ this -> objCollection = $ loader -> load ( ) ; return $ this -> objCollection ;...
Load Object Collection
44,357
public function add ( SKUTypeInterface $ acm_sku_type ) { $ sku = $ this -> entityManager ( ) -> getStorage ( 'acm_sku' ) -> create ( [ 'type' => $ acm_sku_type -> id ( ) ] ) ; $ form = $ this -> entityFormBuilder ( ) -> getForm ( $ sku ) ; return $ form ; }
Provides the SKU submission form .
44,358
public function addPage ( ) { $ build = [ '#theme' => 'sku_add_list' , '#cache' => [ 'tags' => $ this -> entityManager ( ) -> getDefinition ( 'acm_sku_type' ) -> getListCacheTags ( ) , ] , ] ; $ content = [ ] ; foreach ( $ this -> entityManager ( ) -> getStorage ( 'acm_sku_type' ) -> loadMultiple ( ) as $ type ) { $ co...
Displays add SKU links for available SKU types .
44,359
protected function adminConfig ( $ key = null , $ default = null ) { if ( $ key ) { if ( isset ( $ this -> adminConfig [ $ key ] ) ) { return $ this -> adminConfig [ $ key ] ; } else { if ( ! is_string ( $ default ) && is_callable ( $ default ) ) { return $ default ( ) ; } else { return $ default ; } } } return $ this ...
Retrieve the admin s configset .
44,360
protected function appConfig ( $ key = null , $ default = null ) { if ( $ key ) { if ( isset ( $ this -> appConfig [ $ key ] ) ) { return $ this -> appConfig [ $ key ] ; } else { if ( ! is_string ( $ default ) && is_callable ( $ default ) ) { return $ default ( ) ; } else { return $ default ; } } } return $ this -> app...
Retrieve the application s configset .
44,361
protected function apiConfig ( $ key , $ default = null ) { $ key = 'apis.' . $ key ; if ( isset ( $ this -> adminConfig [ $ key ] ) ) { return $ this -> adminConfig [ $ key ] ; } elseif ( isset ( $ this -> appConfig [ $ key ] ) ) { return $ this -> appConfig [ $ key ] ; } elseif ( ! is_string ( $ default ) && is_calla...
Retrieve a value from the API configset .
44,362
public function setData ( array $ data ) { if ( isset ( $ data [ 'selectizeOptions' ] ) ) { $ selectizeOptions = $ data [ 'selectizeOptions' ] ; unset ( $ data [ 'selectizeOptions' ] ) ; $ data [ 'selectizeOptions' ] = $ selectizeOptions ; } parent :: setData ( $ data ) ; return $ this ; }
This function takes an array and fill the model object with its value .
44,363
protected function setDataFromRequest ( RequestInterface $ request ) { $ keys = $ this -> validDataFromRequest ( ) ; $ data = $ request -> getParams ( $ keys ) ; if ( isset ( $ data [ 'obj_type' ] ) ) { $ this -> objType = filter_var ( $ data [ 'obj_type' ] , FILTER_SANITIZE_STRING ) ; } if ( isset ( $ data [ 'obj_id' ...
Sets the template data from a PSR Request object .
44,364
public function setLocalizations ( array $ localizations ) { $ this -> localizations = new ArrayIterator ( ) ; foreach ( $ localizations as $ ident => $ translations ) { $ this -> addLocalization ( $ ident , $ translations ) ; } return $ this ; }
Set the custom localization messages .
44,365
public function addLocalization ( $ ident , $ translations ) { if ( ! is_string ( $ ident ) ) { throw new InvalidArgumentException ( sprintf ( 'Translation key must be a string, received %s' , ( is_object ( $ ident ) ? get_class ( $ ident ) : gettype ( $ ident ) ) ) ) ; } $ this -> localizations [ $ ident ] = $ this ->...
Add a custom localization message .
44,366
public function removeLocalization ( $ ident ) { if ( ! is_string ( $ ident ) ) { throw new InvalidArgumentException ( sprintf ( 'Translation key must be a string, received %s' , ( is_object ( $ ident ) ? get_class ( $ ident ) : gettype ( $ ident ) ) ) ) ; } unset ( $ this -> localizations [ $ ident ] ) ; return $ this...
Remove the translations for the given message ID .
44,367
public function localizations ( ) { if ( $ this -> localizations === null ) { $ this -> setLocalizations ( $ this -> defaultLocalizations ( ) ) ; } return $ this -> localizations ; }
Retrieve the localizations .
44,368
public function localization ( $ ident ) { if ( ! is_string ( $ ident ) ) { throw new InvalidArgumentException ( sprintf ( 'Translation key must be a string, received %s' , ( is_object ( $ ident ) ? get_class ( $ ident ) : gettype ( $ ident ) ) ) ) ; } if ( isset ( $ this -> localizations [ $ ident ] ) ) { return $ thi...
Retrieve the translations for the given message ID .
44,369
public function elfinderLocalizationsAsJson ( ) { $ i18n = [ ] ; foreach ( $ this -> localizations ( ) as $ id => $ translations ) { foreach ( $ translations -> data ( ) as $ language => $ message ) { $ i18n [ $ language ] [ $ id ] = $ message ; } } return json_encode ( $ i18n , ( JSON_UNESCAPED_SLASHES | JSON_UNESCAPE...
Retrieve the custom localizations for elFinder .
44,370
public function elfinderConfigAsJson ( ) { $ property = $ this -> formProperty ( ) ; $ settings = [ ] ; if ( $ this -> elfinderConfig [ 'client' ] ) { $ settings = $ this -> elfinderConfig [ 'client' ] ; } $ settings [ 'lang' ] = $ this -> translator ( ) -> getLocale ( ) ; if ( $ property ) { $ mimeTypes = filter_input...
Retrieve the current property s client - side settings for elFinder .
44,371
public static function get ( ContainerInterface $ container ) { $ use_ecomm_sessions = $ container -> get ( 'config.factory' ) -> get ( 'acm.commerce_users' ) -> get ( 'use_ecomm_sessions' ) ; if ( $ use_ecomm_sessions ) { return $ container -> get ( 'acm.external_commerce_account_proxy' ) ; } return $ container -> get...
Creates an AccountProxyInterface object .
44,372
public function startAllProcesses ( $ wait = true ) { if ( empty ( $ this -> groups ) ) { return parent :: startAllProcesses ( $ wait ) ; } $ results = [ ] ; foreach ( $ this -> groups as $ group ) { $ results = array_merge ( $ results , parent :: startProcessGroup ( $ group , $ wait ) ) ; } return $ results ; }
Start all processes listed in the configuration file .
44,373
public function stopAllProcesses ( $ wait = true ) { if ( empty ( $ this -> groups ) ) { return parent :: stopAllProcesses ( $ wait ) ; } $ results = [ ] ; foreach ( $ this -> groups as $ group ) { $ results = array_merge ( $ results , parent :: stopProcessGroup ( $ group , $ wait ) ) ; } return $ results ; }
Stop all processes listed in the configuration file .
44,374
public function buildSummary ( array $ addresses = [ ] , $ show_add = TRUE ) { $ build = [ ] ; if ( $ show_add ) { $ build [ 'add_address' ] = [ '#type' => 'acm_composite' , '#field_type' => 'acm_address' , '#default_value' => empty ( $ addresses ) ? $ this -> t ( 'You have no saved addresses.' ) : '' , '#form_mode' =>...
Builds a summary of addresses .
44,375
protected function buildAddressFields ( array & $ form , array & $ complete_form , array $ address = [ ] ) { $ form [ 'address_wrapper' ] = [ '#type' => 'container' , '#attributes' => [ 'id' => [ 'address_wrapper' ] , 'class' => [ 'customer-address-form' ] , ] , ] ; $ checkout_config = \ Drupal :: config ( 'acm_checkou...
Builds the address fields .
44,376
public function run ( RequestInterface $ request , ResponseInterface $ response ) { unset ( $ request ) ; try { $ this -> start ( ) ; } catch ( Exception $ e ) { $ this -> climate ( ) -> error ( $ e -> getMessage ( ) ) ; } return $ response ; }
Run the script .
44,377
protected function prepareProperties ( $ oldKey , $ newKey , & $ oldProp = null , & $ newProp = null ) { $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ oldKeyExists = null ; if ( $ this -> isPrimaryKeyDifferent ( ) ) { $ newProp = $ model -> property ( $ newKey ) -> setAllowNull ( false ) ; ...
Retrieve the old and new ID properties .
44,378
protected function labelFromMode ( $ mode ) { if ( $ mode instanceof IdProperty ) { $ mode = $ mode -> mode ( ) ; } switch ( $ mode ) { case IdProperty :: MODE_AUTO_INCREMENT : return 'auto-increment' ; case IdProperty :: MODE_UNIQID : return 'uniqid()' ; case IdProperty :: MODE_UUID : return 'RFC-4122 UUID' ; case IdP...
Retrieve a label for the ID s mode .
44,379
protected function labelFromProp ( IdProperty $ prop ) { $ mode = $ prop -> mode ( ) ; switch ( $ mode ) { case IdProperty :: MODE_AUTO_INCREMENT : return 'auto-increment ID' ; case IdProperty :: MODE_CUSTOM : return 'custom ID' ; default : $ label = $ this -> labelFromMode ( $ mode ) ; if ( $ label ) { return sprintf ...
Retrieve a label for the property .
44,380
protected function describeConversion ( IdProperty $ newProp , IdProperty $ oldProp = null ) { if ( $ oldProp ) { $ new = $ this -> labelFromProp ( $ newProp ) ; $ old = $ this -> labelFromProp ( $ oldProp ) ; $ desc = sprintf ( 'Converting to %s from %s.' , $ new , $ old ) ; } else { $ new = $ this -> labelFromProp ( ...
Describe what we are converting to .
44,381
private function fetchTargetRows ( ) { $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ sql = strtr ( 'SELECT %key FROM `%table`' , [ '%table' => $ source -> table ( ) , '%key' => $ this -> oldPrimaryKey ( ) , ] ) ; return $ source -> db ( ) -> query ( $ sql , PDO :: FETCH_ASSOC ) ; }
Retrieve the target model s rows .
44,382
private function oldPrimaryKey ( ) { if ( $ this -> oldPrimaryKey === null ) { if ( $ this -> isPrimaryKeyDifferent ( ) ) { $ oldKey = $ this -> climate ( ) -> arguments -> get ( 'old_key' ) ; } else { $ oldKey = $ this -> targetModel ( ) -> key ( ) ; } $ this -> oldPrimaryKey = $ oldKey ; } return $ this -> oldPrimary...
Retrieve the target model s old primary key name .
44,383
private function describeCount ( $ rows = null ) { if ( $ rows === null ) { $ rows = $ this -> fetchTargetRows ( ) ; } if ( ! is_array ( $ rows ) && ! ( $ rows instanceof Traversable ) ) { throw new InvalidArgumentException ( sprintf ( 'The rows must be iterable; received %s' , is_object ( $ rows ) ? get_class ( $ rows...
Describe the given count .
44,384
private function insertNewField ( PropertyField $ field , IdProperty $ prop ) { unset ( $ prop ) ; $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ extra = $ field -> extra ( ) ; $ field -> setExtra ( '' ) ; $ sql = strtr ( 'SHOW COLUMNS FROM `%table` LIKE "%key"' , [ '%table' => $ source -> t...
Insert the given field .
44,385
private function dropPrimaryKey ( PropertyField $ field , IdProperty $ prop ) { $ keepId = $ this -> climate ( ) -> arguments -> defined ( 'keep_id' ) ; $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ dbh = $ source -> db ( ) ; $ key = $ prop -> ident ( ) ; if ( $ keepId ) { $ field -> setIde...
Drop the primary key from the given field .
44,386
private function applyPrimaryKey ( PropertyField $ field , IdProperty $ prop ) { unset ( $ prop ) ; $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ sql = strtr ( 'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)' , [ '%table' => $ source -> table ( ) , '%key' => $ field -> ident ( ) , ] ) ; $ so...
Set the given field as the primary key .
44,387
private function renameColumn ( PropertyField $ field , $ from , $ to ) { $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ field -> setIdent ( $ to ) ; $ sql = strtr ( 'ALTER TABLE `%table` CHANGE COLUMN `%from` %field' , [ '%table' => $ source -> table ( ) , '%field' => $ field -> sql ( ) , '...
Rename the given field .
44,388
private function removeColumn ( PropertyField $ field ) { $ source = $ this -> targetModel ( ) -> source ( ) ; $ sql = strtr ( 'ALTER TABLE `%table` DROP COLUMN `%key`' , [ '%table' => $ source -> table ( ) , '%key' => $ field -> ident ( ) , ] ) ; $ source -> db ( ) -> query ( $ sql ) ; return $ this ; }
Remove the given field .
44,389
protected function syncRelatedFields ( IdProperty $ newProp , PropertyField $ newField , IdProperty $ oldProp , PropertyField $ oldField ) { unset ( $ newProp , $ oldProp , $ oldField ) ; $ cli = $ this -> climate ( ) ; if ( ! $ this -> quiet ( ) ) { $ cli -> br ( ) ; $ cli -> comment ( 'Syncing new IDs to related tabl...
Sync the new primary keys to related models .
44,390
public function parseIdGenerator ( $ callable ) { if ( $ callable instanceof Closure ) { return $ callable ; } $ class = null ; $ method = null ; $ isMethod = false ; $ isModel = false ; $ bail = false ; if ( is_array ( $ callable ) && count ( $ callable ) === 2 ) { list ( $ class , $ func ) = $ callable ; $ isMethod =...
Parse and validate the given function is callable .
44,391
public function setTargetModel ( $ model ) { if ( is_string ( $ model ) ) { $ model = $ this -> modelFactory ( ) -> get ( $ model ) ; } if ( ! $ model instanceof ModelInterface ) { throw new InvalidArgumentException ( sprintf ( 'The model must be an instance of "%s"' , ModelInterface :: class ) ) ; } $ this -> targetMo...
Set the model to alter .
44,392
public function setRelatedModels ( $ models ) { $ models = $ this -> parseAsArray ( $ models ) ; foreach ( $ models as $ i => $ model ) { if ( is_string ( $ model ) ) { list ( $ model , $ prop ) = $ this -> resolveRelatedModel ( $ model ) ; $ models [ $ i ] = $ model ; $ this -> relatedProperties [ $ model -> objType (...
Set the related models to update .
44,393
protected function resolveRelatedModel ( $ pattern ) { list ( $ class , $ prop ) = array_pad ( $ this -> parseAsArray ( $ pattern , ':' ) , 2 , null ) ; $ model = $ this -> modelFactory ( ) -> get ( $ class ) ; if ( ! $ prop ) { throw new InvalidArgumentException ( sprintf ( 'The related model [%s] requires a target pr...
Resolve the given related model .
44,394
public function mainMenu ( ) { if ( $ this -> mainMenu === null ) { $ options = null ; if ( $ this instanceof DashboardContainerInterface ) { $ dashboardConfig = $ this -> dashboardConfig ( ) ; if ( isset ( $ dashboardConfig [ 'secondary_menu' ] ) ) { $ options = $ dashboardConfig [ 'secondary_menu' ] ; } } $ this -> m...
Yield the main menu .
44,395
public function visitSiteLabel ( ) { $ label = $ this -> adminConfig ( 'main_menu.visit_site' ) ; if ( $ label === false ) { return false ; } if ( empty ( $ label ) || $ label === true ) { $ label = $ this -> translator ( ) -> translate ( 'Visit Site' ) ; } else { $ label = $ this -> translator ( ) -> translate ( $ lab...
Get the Visit website label .
44,396
public function locale ( ) { $ lang = $ this -> lang ( ) ; $ locales = $ this -> translator ( ) -> locales ( ) ; if ( isset ( $ locales [ $ lang ] [ 'locale' ] ) ) { $ locale = $ locales [ $ lang ] [ 'locale' ] ; if ( is_array ( $ locale ) ) { $ locale = implode ( ' ' , $ locale ) ; } } else { $ locale = 'en-US' ; } re...
Retrieve the current language .
44,397
public function recaptchaInvisible ( ) { $ recaptcha = $ this -> apiConfig ( 'google.recaptcha' ) ; $ hasInvisible = isset ( $ recaptcha [ 'invisible' ] ) ; if ( $ hasInvisible && $ recaptcha [ 'invisible' ] === true ) { return true ; } $ hasSize = isset ( $ recaptcha [ 'size' ] ) ; if ( $ hasSize && $ recaptcha [ 'siz...
Determine if the CAPTCHA test is invisible .
44,398
public function recaptchaHtmlAttr ( ) { $ params = $ this -> recaptchaParameters ( ) ; $ attributes = [ ] ; foreach ( $ params as $ key => $ val ) { if ( $ val !== null ) { $ attributes [ ] = sprintf ( 'data-%s="%s"' , $ key , htmlspecialchars ( $ val , ENT_QUOTES ) ) ; } } return implode ( ' ' , $ attributes ) ; }
Generate a string representation of HTML attributes for the Google reCAPTCHA tag .
44,399
protected function createMainMenu ( $ options = null ) { $ mainMenuConfig = $ this -> adminConfig ( 'main_menu' ) ; if ( ! isset ( $ mainMenuConfig [ 'items' ] ) ) { throw new InvalidArgumentException ( 'Missing "admin.main_menu.items"' ) ; } $ mainMenuIdent = $ this -> mainMenuIdent ( $ options ) ; $ menu = $ this -> ...
Create the main menu using the admin config .