idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
52,400
|
protected function extractPaperclipVariantInfo ( PaperclipAttachmentInstance $ paperclip , $ variant ) { $ config = $ paperclip -> getNormalizedConfig ( ) ; $ variantSteps = array_get ( $ config , "variants.{$variant}" , [ ] ) ; $ dimensions = array_get ( $ variantSteps , 'resize.dimensions' ) ; $ extension = array_get ( $ variantSteps , "extensions.{$variant}" ) ; $ mimeType = array_get ( $ variantSteps , "types.{$variant}" ) ; return compact ( 'dimensions' , 'extension' , 'mimeType' ) ; }
|
Returns extracted data from the paperclip instance for a variant .
|
52,401
|
protected function insertInArray ( $ array , $ key , $ value , $ beforeKey ) { $ position = array_search ( $ beforeKey , array_keys ( $ array ) ) ; if ( false === $ position ) { $ array [ $ key ] = $ value ; return $ array ; } if ( 0 === $ position ) { return [ $ key => $ value ] + $ array ; } return array_slice ( $ array , 0 , $ position , true ) + [ $ key => $ value ] + array_slice ( $ array , $ position , count ( $ array ) - $ position , true ) ; }
|
Insert an item into an associative array at the position before a given key .
|
52,402
|
protected function updateAttributesWithTranslated ( ) { $ translationInfo = $ this -> translationAnalyzer ( ) -> analyze ( $ this -> model ( ) ) ; $ attributes = $ this -> info [ 'attributes' ] ; foreach ( $ translationInfo [ 'attributes' ] as $ key => $ attribute ) { if ( ! $ attribute -> translated ) { continue ; } if ( ! isset ( $ attributes [ $ key ] ) ) { $ attributes [ $ key ] = $ attribute ; } $ attributeData = $ attributes [ $ key ] ; $ attributeData -> merge ( $ attribute ) ; $ attributes [ $ key ] = $ attributeData ; } $ this -> info [ 'attributes' ] = $ attributes ; }
|
Updates model information attributes with translated attribute data .
|
52,403
|
protected function applyRepositoryContext ( ModelRepositoryInterface $ repository = null , ModelInformationInterface $ information = null ) { $ repository = $ repository ? : call_user_func ( [ $ this , 'getModelRepository' ] ) ; $ information = $ information ? : call_user_func ( [ $ this , 'getModelInformation' ] ) ; $ this -> prepareRepositoryContextStrategy ( $ repository , $ information ) -> disableGlobalScopes ( $ repository , $ information ) -> applyIncludesToRepository ( $ repository , $ information ) ; return $ this ; }
|
Applies criteria - based repository context strategies .
|
52,404
|
protected function applyNullLastQuery ( $ query , $ column ) { if ( $ this -> databaseSupportsIf ( $ query ) ) { $ query = $ query -> orderBy ( DB :: raw ( "IF(`{$column}` IS NULL,1,0)" ) ) ; } return $ query ; }
|
Applies logic to query builder to sort null or empty fields last .
|
52,405
|
public function modules ( ) { $ modules = new Collection ; $ modules -> push ( $ this -> makeMetaModuleInstance ( ) ) ; foreach ( $ this -> repository -> getAll ( ) as $ modelInformation ) { $ modules -> push ( $ this -> makeModuleInstance ( $ modelInformation ) ) ; } return $ modules ; }
|
Generates and returns module instances .
|
52,406
|
protected function makeModuleInstance ( ModelInformationInterface $ information ) { $ modelClass = $ information -> modelClass ( ) ; $ module = new ModelModule ( app ( ModelInformationRepositoryInterface :: class ) , $ this -> moduleHelper , app ( RouteHelperInterface :: class ) , $ this -> makeModuleKey ( $ modelClass ) , $ this -> makeModuleName ( $ modelClass ) ) ; $ module -> setAssociatedClass ( $ modelClass ) ; if ( $ information -> meta -> controller ) { $ module -> setWebController ( $ information -> meta -> controller ) ; } if ( $ information -> meta -> controller_api ) { $ module -> setApiController ( $ information -> meta -> controller_api ) ; } return $ module ; }
|
Makes a model module instance for model information .
|
52,407
|
public function flush ( ) { $ result = $ this -> bucket -> manager ( ) -> flush ( ) ; if ( isset ( $ result [ '_' ] ) ) { throw new FlushException ( $ result ) ; } }
|
flush bucket .
|
52,408
|
protected function writeCsvContent ( $ resource ) { $ columns = $ this -> exportInfo -> columns ; $ strategies = $ this -> getColumnStrategyInstances ( ) ; $ delimiter = $ this -> getDelimiterSymbol ( ) ; $ enclosure = $ this -> getEnclosureSymbol ( ) ; $ escape = $ this -> getEscapeSymbol ( ) ; if ( $ this -> shouldHaveHeaderRow ( ) ) { $ headers = array_map ( function ( ModelExportColumnDataInterface $ column ) { return $ column -> header ( ) ; } , $ columns ) ; fputcsv ( $ resource , $ headers , $ delimiter , $ enclosure , $ escape ) ; } $ this -> query -> chunk ( static :: CHUNK_SIZE , function ( $ records ) use ( $ resource , $ columns , $ strategies , $ delimiter , $ enclosure , $ escape ) { foreach ( $ records as $ record ) { $ fields = [ ] ; foreach ( $ strategies as $ key => $ strategy ) { $ fields [ ] = $ strategy -> render ( $ record , $ columns [ $ key ] -> source ) ; } fputcsv ( $ resource , $ fields , $ delimiter , $ enclosure , $ escape ) ; } } ) ; }
|
Writes CSV content to given file handle resource .
|
52,409
|
protected function initializeDefaultValues ( ) { $ defaults = [ ] ; $ filters = $ this -> getFilterInformation ( ) ; foreach ( array_keys ( $ filters ) as $ key ) { $ defaults [ $ key ] = null ; } $ this -> defaults = $ defaults ; return $ this ; }
|
Sets default values based on model information .
|
52,410
|
public function getOptionsModel ( ) { $ model = $ this -> options ; if ( is_string ( $ model ) ) { $ model = app ( $ model ) ; } if ( ! ( $ model instanceof Model ) ) { throw new InvalidArgumentException ( sprintf ( 'The %s element[%s] options class must be instanced of "%s".' , $ this -> getType ( ) , $ this -> getName ( ) , Model :: class ) ) ; } return $ model ; }
|
Get the options model .
|
52,411
|
protected function getOptionsFromModel ( ) { if ( is_null ( ( $ label = $ this -> getOptionsLabelAttribute ( ) ) ) ) { throw new InvalidArgumentException ( sprintf ( 'The %s element[%s] options must set label attribute' , $ this -> getType ( ) , $ this -> getName ( ) ) ) ; } $ model = $ this -> getOptionsModel ( ) ; $ results = $ model -> get ( ) ; $ key = $ this -> getOptionsValueAttribute ( ) ? : $ model -> getKeyName ( ) ; return $ results -> pluck ( $ label , $ key ) ; }
|
Get the options from model .
|
52,412
|
public function create ( $ collection , Closure $ callback = null ) { $ blueprint = $ this -> createBlueprint ( $ collection ) ; $ blueprint -> create ( ) ; sleep ( 10 ) ; if ( $ callback ) { $ callback ( $ blueprint ) ; } }
|
needs administrator password user
|
52,413
|
public function key ( ) { if ( ! $ this -> isTranslated ( ) ) { return $ this -> key ; } $ parts = explode ( '.' , $ this -> key ) ; array_splice ( $ parts , $ this -> localeIndex , 0 , $ this -> getLocalePlaceholder ( ) ) ; return trim ( implode ( '.' , $ parts ) , '.' ) ; }
|
Returns the key in dot notation with locale placeholder where relevant .
|
52,414
|
public function prefixKey ( $ prefix ) { if ( empty ( $ this -> key ) ) { $ this -> key = $ prefix ; } else { $ this -> key = $ prefix . '.' . $ this -> key ; } return $ this ; }
|
Prefixes the currently set key with a dot - notation parent .
|
52,415
|
public function initialize ( ) { if ( $ this -> isInformationCached ( ) ) { $ this -> information = $ this -> retrieveInformationFromCache ( ) ; } else { $ this -> information = $ this -> collector -> collect ( ) ; } $ this -> fillModelClassIndex ( ) ; $ this -> initialized = true ; return $ this ; }
|
Initializes the repository so it may provide model information .
|
52,416
|
public function getByModelClass ( $ class ) { $ this -> checkInitialization ( ) ; if ( ! array_key_exists ( $ class , $ this -> modelClassIndex ) ) { return false ; } return $ this -> getByKey ( $ this -> modelClassIndex [ $ class ] ) ; }
|
Returns model information by the model s FQN .
|
52,417
|
public function writeCache ( ) { $ this -> getFileSystem ( ) -> put ( $ this -> getCachePath ( ) , $ this -> serializedInformationForCache ( $ this -> information ) ) ; return $ this ; }
|
Caches model information .
|
52,418
|
protected function fillModelClassIndex ( ) { $ this -> modelClassIndex = [ ] ; foreach ( $ this -> information as $ index => $ information ) { $ this -> modelClassIndex [ $ information -> modelClass ( ) ] = $ index ; } return $ this ; }
|
Populates the index for associated class FQNs with the loaded information .
|
52,419
|
public function getDefaultAction ( ) { if ( ! $ this -> default_action ) { return null ; } $ actions = $ this -> default_action ; if ( ! is_array ( $ actions ) ) { $ actions = [ new ModelActionReferenceData ( [ 'strategy' => $ actions , ] ) , ] ; } $ core = $ this -> getCore ( ) ; foreach ( $ actions as $ action ) { $ permissions = $ action -> permissions ( ) ; if ( ! count ( $ permissions ) || $ core -> auth ( ) -> user ( ) -> isAdmin ( ) || $ core -> auth ( ) -> user ( ) -> can ( $ permissions ) ) { return $ action ; } } return null ; }
|
Returns the default action for list rows .
|
52,420
|
protected function getVerboseChildrenName ( $ modelClass ) { $ info = $ this -> getInformationRepository ( ) -> getByModelClass ( $ modelClass ) ; if ( ! $ info ) { return cms_trans ( 'models.list-parents.models' ) ; } return $ info -> labelPlural ( ) ; }
|
Returns name plural for child records .
|
52,421
|
protected function fireEvent ( $ event , $ halt = true ) { if ( ! isset ( static :: $ dispatcher ) ) { return true ; } $ method = $ halt ? 'until' : 'fire' ; return static :: $ dispatcher -> { $ method } ( "admin.component.{$event}: " . static :: class , $ this ) ; }
|
Fire the given event for the component
|
52,422
|
public function analyze ( $ modelClass ) { $ information = new ModelInformation ; $ information -> model = $ modelClass ; $ information -> original_model = $ modelClass ; $ this -> makeModelInstance ( $ modelClass ) ; foreach ( $ this -> getSteps ( ) as $ stepClass ) { $ step = app ( $ stepClass ) ; $ information = $ step -> setAnalyzer ( $ this ) -> analyze ( $ information ) ; } return $ information ; }
|
Analyzes a model and returns normalized information about it .
|
52,423
|
protected function makeModelInstance ( $ class ) { if ( ! class_exists ( $ class ) ) { throw new UnexpectedValueException ( "Class '{$class}' does not exist" ) ; } $ instance = new $ class ; if ( ! $ instance instanceof Model ) { throw new UnexpectedValueException ( "Instance of '{$class}' is not a model" ) ; } $ this -> modelInstance = $ instance ; $ this -> modelReflection = new ReflectionClass ( $ class ) ; return $ this ; }
|
Makes and sets instance of the model class and stores it .
|
52,424
|
public function hasTimestamps ( string $ createdAttribute = null , string $ updatedAttribute = null ) : Model { $ this -> main [ 'timestamps' ] = true ; $ this -> main [ 'timestamp_created' ] = $ createdAttribute ? : 'created_at' ; $ this -> main [ 'timestamp_updated' ] = $ updatedAttribute ? : 'updated_at' ; return $ this ; }
|
Model has timestamp columns
|
52,425
|
protected function storeActivePageValuesInSession ( ) { $ this -> getListMemory ( ) -> setPage ( $ this -> activePage ) ; $ this -> getListMemory ( ) -> setPageSize ( $ this -> activePageSize ) ; }
|
Stores the currently active page settings for the session .
|
52,426
|
protected function getModelPageSize ( ) { $ pageSize = $ this -> getModelInformation ( ) -> list -> page_size ; if ( is_array ( $ pageSize ) ) { return ( int ) head ( $ pageSize ) ; } return ( int ) $ pageSize ; }
|
Returns model defined default page size .
|
52,427
|
protected function getPageSizeOptions ( ) { $ pageSizes = $ this -> getModelInformation ( ) -> list -> page_size ; if ( is_array ( $ pageSizes ) ) { return $ pageSizes ; } return config ( 'cms-models.strategies.list.page-size-options' , false ) ; }
|
Returns the page size options that users can choose from .
|
52,428
|
public function decorate ( array $ rules , Model $ model = null ) { $ this -> rules = $ rules ; $ this -> model = $ model ; $ this -> replaceTranslationPlaceholders ( ) -> replaceKeyPlaceholders ( ) ; return $ this -> rules ; }
|
Decorates given validation rules
|
52,429
|
protected function replaceKeyPlaceholders ( ) { if ( ! $ this -> model ) { return $ this ; } $ placeholder = static :: MODEL_KEY_PLACEHOLDER ; foreach ( $ this -> rules as $ key => & $ ruleSet ) { if ( is_string ( $ ruleSet ) ) { $ ruleSet = str_replace ( $ placeholder , $ this -> model -> getKey ( ) , $ ruleSet ) ; continue ; } if ( is_array ( $ ruleSet ) ) { foreach ( $ ruleSet as & $ rule ) { $ rule = str_replace ( $ placeholder , $ this -> model -> getKey ( ) , $ rule ) ; } unset ( $ rule ) ; } } unset ( $ ruleSet ) ; return $ this ; }
|
Decorates rules by replacing a model key value placeholder .
|
52,430
|
protected function replaceTranslationPlaceholders ( ) { $ locales = $ this -> getTranslationLocales ( ) ; $ placeholder = $ this -> getTranslatedRulePlaceHolder ( ) ; $ processed = [ ] ; foreach ( $ this -> rules as $ key => $ ruleSet ) { if ( false === strpos ( $ key , $ placeholder ) ) { $ processed [ $ key ] = $ ruleSet ; continue ; } foreach ( $ locales as $ locale ) { $ localizedKey = str_replace ( $ placeholder , $ locale , $ key ) ; $ localizedRule = $ ruleSet ; if ( is_array ( $ localizedRule ) ) { $ localizedRule = array_map ( function ( $ part ) use ( $ placeholder , $ locale ) { return str_replace ( $ placeholder , $ locale , $ part ) ; } , $ localizedRule ) ; } else { $ localizedRule = str_replace ( $ placeholder , $ locale , $ localizedRule ) ; } $ processed [ $ localizedKey ] = $ localizedRule ; } } $ this -> rules = $ processed ; return $ this ; }
|
Decorates rules by replacing translation placeholders and create rules per locale .
|
52,431
|
protected function checkFilters ( ) { if ( $ this -> getModelInformation ( ) -> list -> disable_filters ) { return $ this ; } if ( $ this -> getListMemory ( ) -> hasFilters ( ) ) { $ this -> retrieveFiltersFromSession ( ) ; } return $ this ; }
|
Checks and loads filters from the session .
|
52,432
|
protected function applyFilter ( $ query ) { if ( $ this -> getModelInformation ( ) -> list -> disable_filters ) { return $ this ; } $ filter = $ this -> makeFilter ( ) ; if ( $ filter ) { $ filter -> apply ( $ query ) ; } return $ this ; }
|
Applies the current filters if any to the model s query builder .
|
52,433
|
protected function makeFilter ( ) { $ data = new ModelFilterData ( $ this -> getModelInformation ( ) , $ this -> filters ) ; return new ModelFilter ( $ this -> getModelInformation ( ) , $ data ) ; }
|
Makes and returns filter instance given current context .
|
52,434
|
public function getReferenceForModel ( Model $ model , $ strategy = null , $ source = null ) { return $ this -> getReferenceValue ( $ model , $ strategy , $ source ) ; }
|
Returns reference for a given model instance .
|
52,435
|
public function getReferencesForModels ( $ models , $ strategy = null , $ source = null ) { $ references = new Collection ; if ( ! count ( $ models ) ) { return $ references ; } if ( $ models instanceof Collection ) { $ firstModel = $ models -> first ( ) ; } else { $ firstModel = head ( $ models ) ; } $ strategy = $ this -> determineModelReferenceStrategy ( $ firstModel , $ strategy ) ; if ( ! $ source ) { $ source = $ this -> determineModelReferenceSource ( $ firstModel ) ; } foreach ( $ models as $ model ) { if ( ! $ strategy ) { $ references -> put ( $ model -> getKey ( ) , $ this -> getReferenceFallback ( $ model ) ) ; continue ; } $ references -> put ( $ model -> getKey ( ) , $ strategy -> render ( $ model , $ source ) ) ; } return $ references ; }
|
Returns list of references for a collection of model instances .
|
52,436
|
public function getReferenceForModelMetaReferenceByKey ( ModelMetaReferenceInterface $ referenceData , $ key ) { $ query = $ this -> getQueryBuilderForModelClass ( $ referenceData -> model ( ) ) ; $ model = $ query -> find ( $ key ) ; if ( ! $ model ) return false ; return $ this -> getReferenceForModelMetaReferenceByModel ( $ referenceData , $ model ) ; }
|
Returns a reference for a model class by meta reference data .
|
52,437
|
public function getReferenceForModelMetaReferenceByModel ( ModelMetaReferenceInterface $ referenceData , Model $ model ) { return $ this -> getReferenceForModel ( $ model , $ referenceData -> strategy ( ) , $ referenceData -> source ( ) ) ; }
|
Returns a reference for a model instance by meta reference data .
|
52,438
|
public function getReferencesForModelMetaReference ( ModelMetaReferenceInterface $ referenceData , $ search = null ) { $ modelClass = $ referenceData -> model ( ) ; $ query = $ this -> getQueryBuilderForModelClass ( $ modelClass ) ; $ this -> applySortingToQueryBuilder ( $ query , $ referenceData -> source ( ) , $ referenceData -> sortDirection ( ) , $ referenceData -> sortStrategy ( ) ) ; if ( null !== $ search ) { $ this -> applySearchTermFilterToQueryBuilder ( $ query , $ referenceData -> target ( ) , $ search ) ; } if ( $ referenceData -> contextStrategy ( ) ) { $ this -> applyContextStrategyToQueryBuilder ( $ query , $ referenceData -> contextStrategy ( ) , $ referenceData -> parameters ( ) ) ; } $ models = $ query -> get ( ) ; $ references = [ ] ; foreach ( $ models as $ model ) { $ references [ $ model -> getKey ( ) ] = $ this -> getReferenceForModel ( $ model , $ referenceData -> strategy ( ) , $ referenceData -> source ( ) ) ; } return new Collection ( $ references ) ; }
|
Returns references for models by meta reference data keyed by the model keys .
|
52,439
|
protected function getQueryBuilderForNonCmsModelClass ( $ modelClass ) { if ( ! is_a ( $ modelClass , Model :: class , true ) ) { throw new UnexpectedValueException ( "{$modelClass} is not an Eloquent model" ) ; } $ model = new $ modelClass ; return $ model :: query ( ) ; }
|
Returns a query builder instance for a given model class .
|
52,440
|
protected function applyContextStrategyToQueryBuilder ( $ query , $ strategy , array $ parameters = [ ] ) { $ strategy = $ this -> resolveContextStrategy ( $ strategy ) ; if ( ! $ strategy ) return ; $ strategy -> apply ( $ query , $ parameters ) ; }
|
Applies a context strategy to a model query builder .
|
52,441
|
protected function applySearchTermFilterToQueryBuilder ( $ query , $ target , $ search ) { $ target = $ target ? : $ query -> getModel ( ) -> getKeyName ( ) ; $ this -> applyFilterStrategyToQuery ( $ query , $ target , $ search ) ; return $ this ; }
|
Applies search term based filtering to a query builder .
|
52,442
|
protected function applyFilterStrategyToQuery ( $ query , $ target , $ value , $ strategy = null ) { if ( null === $ strategy ) { $ strategy = config ( 'cms-models.meta-references.filter-strategy' ) ; } $ filter = $ this -> getFilterFactory ( ) -> make ( $ strategy ) ; $ filter -> apply ( $ query , $ target , $ value ) ; }
|
Applies a filter strategy for searching on the model query .
|
52,443
|
protected function applySortingToQueryBuilder ( $ query , $ source , $ direction = 'asc' , $ strategy = null ) { $ source = $ source ? : $ query -> getModel ( ) -> getKeyName ( ) ; if ( null === $ strategy ) { $ strategy = config ( 'cms-models.meta-references.sort-strategy' ) ; } if ( ! $ strategy ) return $ this ; $ strategyInstance = new $ strategy ; if ( ! ( $ strategyInstance instanceof SortStrategyInterface ) ) { throw new UnexpectedValueException ( "{$strategy} is not a sort strategy" ) ; } foreach ( explode ( ',' , $ source ) as $ sourcePart ) { $ query = $ strategyInstance -> apply ( $ query , $ sourcePart , $ direction ) ; } return $ this ; }
|
Applies sorting to a query builder based on source string .
|
52,444
|
protected function getModelRepositoryForInformation ( ModelInformationInterface $ information ) { $ factory = app ( ModelRepositoryFactoryInterface :: class ) ; $ modelRepository = $ factory -> make ( $ information -> modelClass ( ) ) ; $ this -> applyRepositoryContext ( $ modelRepository , $ information ) ; return $ modelRepository ; }
|
Returns instance of a model repository for given model information .
|
52,445
|
public function defaultSortingStrategy ( string $ strategy ) : ModelList { if ( is_string ( $ this -> main [ 'default_sort' ] ) ) { $ this -> main [ 'default_sort' ] = [ $ this -> main [ 'default_sort' ] ] ; $ this -> main [ 'default_sort' ] [ ] = $ strategy ; return $ this ; } $ this -> main [ 'default_sort' ] = $ strategy ; return $ this ; }
|
Set a sorting strategy to enable by default
|
52,446
|
public function rowClickAction ( string $ action ) : ModelList { if ( ! array_has ( $ this -> main , 'default_action' ) ) { $ this -> main [ 'default_action' ] = [ ] ; } $ this -> main [ 'default_action' ] [ ] = $ action ; return $ this ; }
|
Adds an action to be performed when clicking a row .
|
52,447
|
public function parentRelationActiveByDefault ( string $ relation ) : ModelList { $ this -> main [ 'default_top_relation' ] = $ relation ; if ( ! array_get ( $ this -> main , 'parents' ) ) { $ this -> main [ 'parents' ] = [ [ 'relation' => $ relation , 'field' => $ relation , ] , ] ; } return $ this ; }
|
Hide everything but top - level list parents by default to this relation
|
52,448
|
public function parentRelations ( array $ relations ) : ModelList { $ this -> main [ 'parents' ] = [ ] ; foreach ( $ relations as $ key => $ value ) { if ( is_string ( $ key ) ) { $ parent = [ 'relation' => $ key , 'field' => $ value , ] ; } else { $ parent = [ 'relation' => $ value , 'field' => $ value , ] ; } $ this -> main [ 'parents' ] [ ] = $ parent ; } return $ this ; }
|
List parents for list hierarchy handling
|
52,449
|
public function enrich ( ModelInformationInterface $ information ) { $ this -> info = $ information ; try { foreach ( $ this -> steps as $ step ) { $ instance = app ( $ step ) ; $ this -> info = $ instance -> setEnricher ( $ this ) -> enrich ( $ this -> info ) ; } } catch ( Exception $ e ) { $ key = null ; $ section = null ; $ message = $ e -> getMessage ( ) ; if ( $ e instanceof ModelInformationEnrichmentException ) { $ key = $ e -> getKey ( ) ; $ section = $ e -> getSection ( ) ; } elseif ( $ e instanceof ModelConfigurationDataException ) { $ message .= " ({$e->getDotKey()})" ; } throw ( new ModelInformationEnrichmentException ( "{$information->modelClass()} model configuration issue: \n{$message}" , ( int ) $ e -> getCode ( ) , $ e ) ) -> setModelClass ( $ information -> modelClass ( ) ) -> setSection ( $ section ) -> setKey ( $ key ) ; } return $ information ; }
|
Enriches a single model s information .
|
52,450
|
public function availableLocales ( ) { $ locales = $ this -> getCore ( ) -> config ( 'locale.translation-locales' ) ; if ( is_array ( $ locales ) ) { return $ locales ; } return $ this -> getLocaleRepository ( ) -> getAvailable ( ) ; }
|
Returns list of locales available for content transla
|
52,451
|
public function defaultLocale ( ) { $ locale = $ this -> getCore ( ) -> config ( 'locale.translation-default' ) ; if ( $ locale ) { return $ locale ; } $ locale = app ( ) -> getLocale ( ) ; $ available = $ this -> availableLocales ( ) ; if ( ! count ( $ available ) || in_array ( $ locale , $ available ) ) { return $ locale ; } return head ( $ available ) ; }
|
Returns default translation locale .
|
52,452
|
public function activeLocale ( ) { $ active = $ this -> getCore ( ) -> session ( ) -> get ( static :: ACTIVE_LOCALE_SESSION_KEY ) ; if ( $ active && in_array ( $ active , $ this -> availableLocales ( ) ) ) { return $ active ; } return $ this -> defaultLocale ( ) ; }
|
Returns currently active translation locale .
|
52,453
|
public function setActiveLocale ( $ locale ) { if ( empty ( $ locale ) ) { $ this -> getCore ( ) -> session ( ) -> forget ( static :: ACTIVE_LOCALE_SESSION_KEY ) ; } else { $ this -> getCore ( ) -> session ( ) -> put ( static :: ACTIVE_LOCALE_SESSION_KEY , $ locale ) ; } return $ this ; }
|
Set currently active translation locale .
|
52,454
|
protected function fillDataForEmpty ( ) { $ fields = [ ] ; foreach ( $ this -> info -> attributes as $ attribute ) { if ( $ attribute -> hidden || ! $ this -> shouldAttributeBeEditableByDefault ( $ attribute , $ this -> info ) ) { continue ; } $ fields [ $ attribute -> name ] = $ this -> makeModelFormFieldDataForAttributeData ( $ attribute ) ; } foreach ( $ this -> info -> relations as $ relation ) { $ fields [ $ relation -> name ] = $ this -> makeModelFormFieldDataForRelationData ( $ relation ) ; } $ this -> info -> form -> fields = $ fields ; }
|
Fills form field data if no field data is set .
|
52,455
|
protected function enrichField ( $ key , ModelFormFieldDataInterface $ field , array & $ fields ) { $ normalizedRelationName = $ this -> normalizeRelationName ( $ key ) ; if ( ! isset ( $ this -> info -> attributes [ $ key ] ) && ! isset ( $ this -> info -> relations [ $ normalizedRelationName ] ) ) { if ( ! $ field -> key ( ) ) { $ field -> key = $ key ; } $ fields [ $ key ] = $ field ; return ; } if ( isset ( $ this -> info -> attributes [ $ key ] ) ) { $ enrichFieldInfo = $ this -> makeModelFormFieldDataForAttributeData ( $ this -> info -> attributes [ $ key ] ) ; } else { $ enrichFieldInfo = $ this -> makeModelFormFieldDataForRelationData ( $ this -> info -> relations [ $ normalizedRelationName ] , $ key ) ; } if ( null === $ field -> update && null === $ field -> create ) { $ field -> update = true ; $ field -> create = true ; } $ enrichFieldInfo -> merge ( $ field ) ; $ fields [ $ key ] = $ enrichFieldInfo ; }
|
Enriches a single form field and saves the data .
|
52,456
|
protected function shouldAttributeBeEditableByDefault ( ModelAttributeData $ attribute , ModelInformationInterface $ info ) { if ( $ attribute -> name === $ this -> model -> getKeyName ( ) && $ info -> incrementing ) { return false ; } if ( $ info -> list -> activatable && $ info -> list -> active_column == $ attribute -> name ) { return false ; } if ( $ info -> list -> orderable && $ info -> list -> order_column == $ attribute -> name ) { return false ; } if ( $ this -> model -> timestamps && ( $ attribute -> name == $ this -> model -> getCreatedAtColumn ( ) || $ attribute -> name == $ this -> model -> getUpdatedAtColumn ( ) ) ) { return false ; } if ( preg_match ( '#^(?<field>[^_]+)_(file_name|file_size|content_type|updated_at)$#' , $ attribute -> name , $ matches ) && array_has ( $ info -> attributes , $ matches [ 'field' ] ) ) { return $ info -> attributes [ $ matches [ 'field' ] ] -> cast !== AttributeCast :: PAPERCLIP_ATTACHMENT ; } return ! $ this -> isAttributeForeignKey ( $ attribute -> name , $ info ) ; }
|
Returns whether an attribute should be editable if no user - defined fields are configured .
|
52,457
|
protected function makeModelFormFieldDataForAttributeData ( ModelAttributeData $ attribute ) { $ strategy = $ this -> determineFormDisplayStrategyForAttribute ( $ attribute ) ; return new ModelFormFieldData ( [ 'key' => $ attribute -> name , 'display_strategy' => $ strategy , 'store_strategy' => $ this -> determineFormStoreStrategyForAttribute ( $ attribute ) , 'translated' => $ attribute -> translated , 'required' => $ this -> shouldModelFormFieldBeRequired ( $ attribute , $ strategy ) , 'options' => $ this -> determineFormFieldOptions ( $ attribute ) , ] ) ; }
|
Makes data set for form field given attribute data .
|
52,458
|
protected function makeModelFormFieldDataForRelationData ( ModelRelationData $ relation , $ key = null ) { $ required = ( in_array ( $ relation -> type , [ RelationType :: BELONGS_TO , RelationType :: BELONGS_TO_THROUGH , RelationType :: MORPH_TO , ] ) && ! $ relation -> nullable_key ) ; return new ModelFormFieldData ( [ 'key' => $ key ? : $ relation -> name , 'source' => $ relation -> method , 'required' => $ required , 'translated' => $ relation -> translated , 'display_strategy' => $ this -> determineFormDisplayStrategyForRelation ( $ relation ) , 'store_strategy' => $ this -> determineFormStoreStrategyForRelation ( $ relation ) , 'options' => $ this -> determineFormStoreOptionsForRelation ( $ relation ) , ] ) ; }
|
Makes data set for form field given relation data .
|
52,459
|
public function strategy ( string $ strategy , array $ options = [ ] ) : ListFilter { $ this -> main [ 'strategy' ] = $ strategy ; if ( count ( $ options ) ) { $ this -> main [ 'options' ] = $ options ; } return $ this ; }
|
Set the filter strategy
|
52,460
|
protected function renderedFormFieldStrategies ( Model $ model , array $ fields , array $ values , array $ errors = [ ] ) { $ views = [ ] ; foreach ( $ fields as $ key => $ field ) { try { $ instance = $ this -> getFormFieldStrategyFactory ( ) -> make ( $ field -> display_strategy ) ; } catch ( Exception $ e ) { $ message = "Failed to make form field strategy for '{$key}': \n{$e->getMessage()}" ; throw new StrategyRenderException ( $ message , $ e -> getCode ( ) , $ e ) ; } try { $ views [ $ key ] = $ instance -> render ( $ model , $ fields [ $ key ] , old ( ) ? old ( $ key ) : array_get ( $ values , $ key ) , array_get ( $ values , $ key ) , array_get ( $ errors , $ key , [ ] ) ) ; } catch ( Exception $ e ) { $ message = "Failed to render form field '{$key}' for strategy " . get_class ( $ instance ) . ": \n{$e->getMessage()}" ; throw new StrategyRenderException ( $ message , $ e -> getCode ( ) , $ e ) ; } } return $ views ; }
|
Renders Vies or HTML for form field strategies .
|
52,461
|
protected function resolveContextStrategy ( $ strategy ) { if ( ! $ strategy ) { $ strategy = config ( 'cms-models.strategies.repository.default-strategy' ) ; } if ( ! ( $ strategyClass = $ this -> resolveContextStrategyClass ( $ strategy ) ) ) { return null ; } return app ( $ strategyClass ) ; }
|
Resolves the context strategy if possible .
|
52,462
|
protected function isScopeMethodUsable ( ReflectionMethod $ method ) { if ( $ method -> getNumberOfRequiredParameters ( ) != 1 ) { return false ; } if ( ! ( $ firstParameter = head ( $ method -> getParameters ( ) ) ) || $ firstParameter -> isOptional ( ) ) { return false ; } $ scopeName = camel_case ( substr ( $ method -> name , 5 ) ) ; $ cmsTags = $ this -> getCmsDocBlockTags ( $ method ) ; if ( array_get ( $ cmsTags , 'ignore' ) || ( ! array_get ( $ cmsTags , 'scope' ) && in_array ( $ scopeName , $ this -> getIgnoredScopeNames ( ) ) ) ) { return false ; } return true ; }
|
Returns whether a reflection method is usabled as a CMS scope .
|
52,463
|
private function parsed ( $ now = null ) { $ chars = 0 ; foreach ( $ this -> isbnSplit as $ key => $ split ) { if ( isset ( $ now ) === false or $ key < $ now ) { $ chars = $ chars + strlen ( $ split ) ; } } return $ chars ; }
|
Get Parsed Length
|
52,464
|
private function getRegistrationGroupElement ( ) { if ( isset ( $ this -> isbnSplit [ 0 ] ) === false or $ this -> isbnSplit [ 0 ] === '978' ) { $ this -> range ( "0000000" , "5999999" , 1 , 1 ) ; $ this -> range ( "6000000" , "6499999" , 3 , 1 ) ; $ this -> range ( "6500000" , "6999999" , 0 , 1 ) ; $ this -> range ( "7000000" , "7999999" , 1 , 1 ) ; $ this -> range ( "8000000" , "9499999" , 2 , 1 ) ; $ this -> range ( "9500000" , "9899999" , 3 , 1 ) ; $ this -> range ( "9900000" , "9989999" , 4 , 1 ) ; $ this -> range ( "9990000" , "9999999" , 5 , 1 ) ; } if ( isset ( $ this -> isbnSplit [ 0 ] ) === true and $ this -> isbnSplit [ 0 ] === '979' ) { $ this -> range ( "0000000" , "0999999" , 0 , 1 ) ; $ this -> range ( "1000000" , "1199999" , 2 , 1 ) ; $ this -> range ( "1200000" , "9999999" , 0 , 1 ) ; } return ( isset ( $ this -> isbnSplit [ 1 ] ) ) ; }
|
Get Registration Group Element
|
52,465
|
public function identify ( $ isbn ) { if ( $ this -> is10 ( $ isbn ) === true ) { return 10 ; } return ( $ this -> is13 ( $ isbn ) === true ? 13 : false ) ; }
|
Identifies the ISBN format and returns the corresponding number or false if no pattern matches .
|
52,466
|
public function aroundGetConfigurationDesignTheme ( Design $ subject , callable $ proceed , ... $ args ) { $ forceLuma = $ this -> scopeConfig -> getValue ( self :: CONFIG_PATH_FORCE_LUMA_CHECKOUT , ScopeInterface :: SCOPE_STORE ) ; if ( $ forceLuma && $ this -> httpRequest -> getModuleName ( ) === 'checkout' && $ this -> httpRequest -> getControllerName ( ) === 'index' ) { return $ this -> getLumaThemeId ( ) ; } return $ proceed ( ... $ args ) ; }
|
Forces the Luma theme when httpRequest is being handled by checkout .
|
52,467
|
public function load ( ) { foreach ( $ this -> config [ 'autoload' ] as $ file ) { if ( ! locate_template ( $ this -> getRelativePath ( $ file ) , true , true ) ) { throw new FileNotFoundException ( "Autoloaded file [{$this->getPath($file)}] cannot be found. Please, check your autoloaded entries in `config/app.php` file." ) ; } } }
|
Localize and autoloads files .
|
52,468
|
public function getClientIp ( ) { $ ipaddress = getenv ( 'HTTP_CLIENT_IP' ) ? : getenv ( 'HTTP_X_FORWARDED_FOR' ) ? : getenv ( 'HTTP_X_FORWARDED' ) ? : getenv ( 'HTTP_FORWARDED_FOR' ) ? : getenv ( 'HTTP_FORWARDED' ) ? : getenv ( 'REMOTE_ADDR' ) ; if ( ! $ ipaddress ) { return $ this -> getClientIpFromServerVar ( ) ; } return $ ipaddress ; }
|
Get the customers IP Address
|
52,469
|
public function getClientIpFromServerVar ( ) { $ ipaddress = '' ; if ( isset ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) $ ipaddress = $ _SERVER [ 'HTTP_CLIENT_IP' ] ; else if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) $ ipaddress = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; else if ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED' ] ) ) $ ipaddress = $ _SERVER [ 'HTTP_X_FORWARDED' ] ; else if ( isset ( $ _SERVER [ 'HTTP_FORWARDED_FOR' ] ) ) $ ipaddress = $ _SERVER [ 'HTTP_FORWARDED_FOR' ] ; else if ( isset ( $ _SERVER [ 'HTTP_FORWARDED' ] ) ) $ ipaddress = $ _SERVER [ 'HTTP_FORWARDED' ] ; else if ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) $ ipaddress = $ _SERVER [ 'REMOTE_ADDR' ] ; else $ ipaddress = 'UNKNOWN' ; return $ ipaddress ; }
|
Get the customers IP address from server variables
|
52,470
|
public function get ( $ key , array $ parameters = [ ] ) { if ( isset ( $ this -> factories [ $ key ] ) ) { return $ this -> resolve ( $ this -> factories [ $ key ] , $ parameters ) ; } if ( isset ( $ this -> services [ $ key ] ) ) { if ( ! isset ( $ this -> deposit [ $ key ] ) ) { $ this -> deposit [ $ key ] = $ this -> resolve ( $ this -> services [ $ key ] , $ parameters ) ; } return $ this -> deposit [ $ key ] ; } throw new BindingResolutionException ( "Unresolvable resolution. The [{$key}] binding is not registered." ) ; }
|
Resolve service form container .
|
52,471
|
public function has ( $ key ) { return isset ( $ this -> factories [ $ key ] ) || isset ( $ this -> services [ $ key ] ) ; }
|
Determine if the given service exists .
|
52,472
|
protected function _getElementHtml ( AbstractElement $ element ) { $ element -> addData ( [ 'wysiwyg' => true , 'config' => $ this -> wysiwygConfig -> getConfig ( $ element ) ] ) ; return parent :: _getElementHtml ( $ element ) ; }
|
Enable wysiwyg editor for the element .
|
52,473
|
public function doActions ( ) { if ( $ this -> isNamed ( ) ) { list ( $ slug , $ name ) = $ this -> file ; do_action ( "get_template_part_{$slug}" , $ slug , $ name ) ; return ; } if ( is_array ( $ this -> file ) && isset ( $ this -> file [ 0 ] ) ) { return do_action ( "get_template_part_{$this->file[0]}" , $ this -> file [ 0 ] , null ) ; } do_action ( "get_template_part_{$this->file}" , $ this -> file , null ) ; }
|
Calls before including template actions .
|
52,474
|
public function getFilename ( $ extension = '.php' ) { if ( $ this -> isNamed ( ) ) { return join ( '-' , $ this -> file ) . $ extension ; } if ( is_array ( $ this -> file ) && isset ( $ this -> file [ 0 ] ) ) { return "{$this->file[0]}{$extension}" ; } return apply_filters ( 'tonik/gin/template/filename' , "{$this->file}{$extension}" ) ; }
|
Gets template name .
|
52,475
|
public function isNamed ( ) { if ( ! is_array ( $ this -> file ) ) { return false ; } if ( isset ( $ this -> file [ 1 ] ) && is_bool ( $ this -> file [ 1 ] ) || null === $ this -> file [ 1 ] || empty ( $ this -> file [ 1 ] ) ) { return false ; } return true ; }
|
Checks if temlate has variant name .
|
52,476
|
protected function isDatabaseReady ( ) { if ( ! DB :: is_active ( ) ) { return false ; } if ( ! ( DB :: get_conn ( ) instanceof MySQLDatabase ) ) { throw new Exception ( 'HybridSessions\Store\DatabaseStore currently only works with MySQL databases' ) ; } return ClassInfo :: hasTable ( 'HybridSessionDataObject' ) ; }
|
Determine if the DB is ready to use .
|
52,477
|
protected function getLifetime ( ) { $ params = session_get_cookie_params ( ) ; $ cookieLifetime = ( int ) $ params [ 'lifetime' ] ; $ gcLifetime = ( int ) ini_get ( 'session.gc_maxlifetime' ) ; return $ cookieLifetime ? min ( $ cookieLifetime , $ gcLifetime ) : $ gcLifetime ; }
|
Get lifetime in number of seconds
|
52,478
|
public static function init ( $ key = null ) { $ instance = Injector :: inst ( ) -> get ( __CLASS__ ) ; if ( empty ( $ key ) ) { user_error ( 'HybridSession::init() was not given a $key. Disabling cookie-based storage' , E_USER_WARNING ) ; } else { $ instance -> setKey ( $ key ) ; } session_set_save_handler ( $ instance , true ) ; self :: $ enabled = true ; }
|
Register the session handler as the default
|
52,479
|
public function setIpinfoConfig ( $ token = null , $ debug = false ) { $ this -> ipinfo -> __construct ( compact ( 'token' , 'debug' ) ) ; return $ this ; }
|
Set token for Ipinfo if exists .
|
52,480
|
public function getInfo ( ) { $ this -> hostIpinfo ( ) ; $ this -> clientIpinfo ( ) ; $ this -> getServerInfoSoftware ( ) ; $ this -> serverInfoHardware ( ) ; $ this -> uptime ( ) ; $ this -> databaseInfo ( ) ; return $ this -> results ; }
|
Get all info .
|
52,481
|
protected function databaseInfo ( ) { $ pdo = $ this -> database -> getConnection ( ) -> getPdo ( ) ; $ version = $ this -> ifExists ( $ pdo -> getAttribute ( PDO :: ATTR_SERVER_VERSION ) ) ; $ driver = $ this -> ifExists ( $ pdo -> getAttribute ( PDO :: ATTR_DRIVER_NAME ) ) ; $ driver = $ this -> ifExists ( ( ! empty ( $ this -> databases [ $ driver ] ) ? $ this -> databases [ $ driver ] : null ) ) ; $ this -> results [ 'database' ] = compact ( 'driver' , 'version' ) ; return $ this ; }
|
Get database info .
|
52,482
|
protected function hostIpinfo ( ) { $ ipinfo = $ this -> ipinfo -> getYourOwnIpDetails ( ) -> getProperties ( ) ; $ this -> results [ 'host' ] = $ ipinfo ; return $ this ; }
|
Parse host info .
|
52,483
|
protected function clientIpinfo ( ) { $ ip = $ this -> request -> getClientIp ( ) ; $ ipinfo = $ this -> ipinfo -> getFullIpDetails ( $ ip ) -> getProperties ( ) ; $ this -> results [ 'client' ] = $ ipinfo ; return $ this ; }
|
Parse client info .
|
52,484
|
protected function getDiskSpace ( $ mounts = [ ] ) { $ total = $ free = 0 ; if ( empty ( $ mounts ) ) { return compact ( 'total' , 'free' ) ; } foreach ( $ mounts as $ mount ) { $ total += $ mount [ 'size' ] ; $ free += $ mount [ 'free' ] ; } return compact ( 'total' , 'free' ) ; }
|
Get disk space string .
|
52,485
|
protected function serverInfoSoftware ( ) { $ linfo = $ this -> linfo -> getParser ( ) ; $ os = $ this -> ifExists ( $ linfo -> getOS ( ) ) ; $ kernel = $ this -> ifExists ( $ linfo -> getKernel ( ) ) ; $ arc = $ this -> ifExists ( $ linfo -> getCPUArchitecture ( ) ) ; $ webserver = $ this -> ifExists ( $ linfo -> getWebService ( ) ) ; $ php = $ this -> ifExists ( $ linfo -> getPhpVersion ( ) ) ; $ distro = '' ; if ( method_exists ( $ linfo , 'getDistro' ) ) { $ distro = $ this -> getDistroString ( $ this -> ifExists ( $ linfo -> getDistro ( ) ) ) ; } $ this -> results [ 'server' ] [ 'software' ] = compact ( 'os' , 'distro' , 'kernel' , 'arc' , 'webserver' , 'php' ) ; return $ this ; }
|
Parse server software .
|
52,486
|
protected function serverInfoHardware ( ) { $ linfo = $ this -> linfo -> getParser ( ) ; $ CPUs = $ this -> ifExists ( $ linfo -> getCPU ( ) ) ; $ cpu = $ this -> getCPUString ( $ CPUs ) ; $ cpu_count = count ( $ CPUs ) ; $ model = $ this -> ifExists ( $ linfo -> getModel ( ) ) ; $ virtualization = $ this -> getVirtualizationString ( $ this -> ifExists ( $ linfo -> getVirtualization ( ) ) ) ; $ memory = $ this -> ifExists ( $ linfo -> getRam ( ) ) ; $ ram = [ 'total' => ( int ) $ this -> ifExists ( $ memory [ 'total' ] ) , 'free' => ( int ) $ this -> ifExists ( $ memory [ 'free' ] ) , ] ; $ swap = [ 'total' => ( int ) $ this -> ifExists ( $ memory [ 'swapTotal' ] ) , 'free' => ( int ) $ this -> ifExists ( $ memory [ 'swapFree' ] ) , ] ; $ disk = $ this -> getDiskSpace ( $ linfo -> getMounts ( ) ) ; $ this -> results [ 'server' ] [ 'hardware' ] = compact ( 'cpu' , 'cpu_count' , 'model' , 'virtualization' , 'ram' , 'swap' , 'disk' ) ; return $ this ; }
|
Parse server hardware .
|
52,487
|
protected function uptime ( ) { $ linfo = $ this -> linfo -> getParser ( ) ; $ uptime = $ booted_at = null ; $ systemUptime = $ this -> ifExists ( $ linfo -> getUpTime ( ) ) ; if ( ! empty ( $ systemUptime [ 'text' ] ) ) { $ uptime = $ systemUptime [ 'text' ] ; } if ( ! empty ( $ systemUptime [ 'bootedTimestamp' ] ) ) { $ booted_at = date ( 'Y-m-d H:i:s' , $ systemUptime [ 'bootedTimestamp' ] ) ; } $ this -> results [ 'server' ] [ 'uptime' ] = compact ( 'uptime' , 'booted_at' ) ; return $ this ; }
|
Parse uptime .
|
52,488
|
protected function resolveDispositionHeaderFilename ( $ filename ) { $ userAgent = $ this -> request -> headers -> get ( 'User-Agent' ) ; if ( preg_match ( '#MSIE|Safari|Konqueror#' , $ userAgent ) ) { return "filename=" . rawurlencode ( $ filename ) ; } return "filename*=UTF-8''" . rawurlencode ( $ filename ) ; }
|
Algorithm inspired by phpBB3
|
52,489
|
protected function getCrypto ( $ session_id ) { $ key = $ this -> getKey ( ) ; if ( ! $ key ) { return null ; } if ( ! $ this -> crypto || $ this -> crypto -> getSalt ( ) != $ session_id ) { $ this -> crypto = Injector :: inst ( ) -> create ( CryptoHandler :: class , $ key , $ session_id ) ; } return $ this -> crypto ; }
|
Get the cryptography store for the specified session
|
52,490
|
public static function authenticateWithToken ( $ token ) { $ pkeyResource = openssl_pkey_new ( array ( "digest_alg" => "sha256" , "private_key_bits" => 2048 ) ) ; openssl_pkey_export ( $ pkeyResource , $ generatedPrivateKey ) ; $ pkeyResourceDetails = openssl_pkey_get_details ( $ pkeyResource ) ; $ generatedPublicKey = $ pkeyResourceDetails [ "key" ] ; $ requestResult = Request :: post ( "/g_business/v1/authentication_keys" , array ( "body" => array ( "public_key" => $ generatedPublicKey , "token" => $ token ) ) ) ; self :: $ privateKey = $ generatedPrivateKey ; self :: $ publicKey = $ generatedPublicKey ; self :: $ keyId = $ requestResult -> key_id ; $ returnClass = new ApiAuthentication ( ) ; $ returnClass -> privateKey = $ generatedPrivateKey ; $ returnClass -> publicKey = $ generatedPublicKey ; $ returnClass -> keyId = $ requestResult -> key_id ; return $ returnClass ; }
|
Generate new keys and authenticate with token
|
52,491
|
protected function url ( $ path , array $ parameters = null ) { $ query = [ 'client_id' => $ this -> client_key , 'redirect_uri' => $ this -> redirect_uri , 'response_type' => 'code' ] ; if ( $ parameters ) $ query = array_merge ( $ query , $ parameters ) ; $ query = http_build_query ( $ query ) ; return sprintf ( '%s%s?%s' , self :: API_HOST , $ path , $ query ) ; }
|
Make URLs for user browser navigation .
|
52,492
|
public function post ( $ path , array $ parameters , $ authorization = false ) { $ query = [ ] ; if ( $ authorization ) $ query = [ 'client_id' => $ this -> client_key , 'client_secret' => $ this -> client_secret , 'redirect_uri' => $ this -> redirect_uri , 'grant_type' => 'authorization_code' , ] ; if ( $ parameters ) $ query = array_merge ( $ query , $ parameters ) ; try { $ response = $ this -> client -> request ( 'POST' , $ path , [ 'form_params' => $ query , 'timeout' => self :: TIMEOUT ] ) ; return $ this -> toArray ( $ response ) ; } catch ( ClientException $ e ) { return $ this -> toArray ( $ e -> getResponse ( ) ) ; } }
|
Make POST calls to the API
|
52,493
|
public function get ( $ path , array $ parameters ) { try { $ response = $ this -> client -> request ( 'GET' , $ path , [ 'query' => $ parameters ] ) ; return $ this -> toArray ( $ response ) ; } catch ( ClientException $ e ) { return $ this -> toArray ( $ e -> getResponse ( ) ) ; } }
|
Make GET calls to the API
|
52,494
|
public function makeAllSearchable ( ) { $ this -> chunk ( 100 , function ( Collection $ models ) { $ models = $ models -> map ( function ( Searchable $ model ) { $ model -> setSearchableAs ( $ this -> searchableAs ( ) ) ; $ model -> setClassMetaData ( $ this -> getClassMetadata ( ) ) ; return $ model ; } ) ; $ this -> searchableUsing ( ) -> update ( $ models ) ; event ( new ModelsImported ( $ models ) ) ; } ) ; }
|
Make all searchable
|
52,495
|
public function checkCronExt ( ) { $ result = 0 ; $ objDB = \ Database :: getInstance ( ) ; if ( $ objDB -> tableExists ( 'tl_crontab' ) ) { $ result = 1 ; $ objJob = $ objDB -> execute ( "SELECT * FROM tl_crontab WHERE job='system/modules/BackupDB/public/AutoBackupDB.php' LIMIT 1" ) ; if ( $ objJob -> next ( ) ) { $ result = $ objJob -> enabled ? 3 : 2 ; } } return $ result ; }
|
Function check cron job
|
52,496
|
public function configureServers ( array $ servers ) : array { return array_map ( static function ( $ item ) { if ( $ item [ 'basic' ] ) { $ item [ 'basic' ] = base64_encode ( $ item [ 'basic' ] ) ; } return $ item ; } , $ servers ) ; }
|
Returns servers list with hash for basic auth computed if provided .
|
52,497
|
public function AutoBackupAction ( ) { $ this -> container -> get ( 'contao.framework' ) -> initialize ( ) ; $ controller = new \ Softleister \ BackupDB \ AutoBackupDb ( ) ; return $ controller -> run ( ) ; }
|
Renders the alerts content .
|
52,498
|
private function cancelPending ( ) { if ( ! $ this -> busyQueue -> isEmpty ( ) ) { $ exception = new WorkerException ( 'Worker was shut down.' ) ; do { $ this -> busyQueue -> dequeue ( ) -> cancel ( $ exception ) ; } while ( ! $ this -> busyQueue -> isEmpty ( ) ) ; } }
|
Cancels all pending tasks .
|
52,499
|
public function setPriority ( float $ priority ) : float { if ( $ priority < 0 || $ priority > 1 ) { throw new InvalidArgumentError ( 'Priority value must be between 0.0 and 1.0.' ) ; } $ nice = round ( 19 - ( $ priority * 39 ) ) ; if ( ! pcntl_setpriority ( $ nice , $ this -> pid , PRIO_PROCESS ) ) { throw new ForkException ( 'Failed to set the fork\'s priority.' ) ; } }
|
Sets the fork s scheduling priority as a percentage .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.