idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
3,200
private function dynamicFormCheck ( ) { if ( $ this -> field -> hasDynamicForms ( ) ) { $ this -> dynamicFormParentName = $ this -> field -> getName ( ) ; $ value = $ this -> field -> getValue ( ) ; $ forms = $ this -> field -> getDynamicForms ( ) ; $ this -> includeDynamicFormJavascript = true ; foreach ( $ forms as $...
Checks current field being processed for dynamic sub forms
3,201
protected function prepareArrays ( array $ items = [ ] ) { $ items = array_map ( function ( $ item ) { return trim ( $ item ) ; } , $ items ) ; return array_filter ( $ items , function ( $ item ) { return ! empty ( $ item ) ; } ) ; }
Prepare arrays before accepting
3,202
public function parseWidget ( $ widget ) { if ( ! isset ( $ _SESSION [ 'FILES' ] [ $ this -> field -> getColName ( ) ] ) ) { return false ; } $ ext = pathinfo ( $ _SESSION [ 'FILES' ] [ $ this -> field -> getColName ( ) ] [ 'name' ] , PATHINFO_EXTENSION ) ; $ name = $ this -> field -> uploadPath . '/' . $ this -> item ...
Parses the widget and returns either the uuid of the file or false if moving the file failed
3,203
public function boot ( ) { $ this -> bootBlade ( ) ; $ this -> bootDatatable ( ) ; $ this -> bootModal ( ) ; $ this -> bootMail ( ) ; $ this -> bootValidator ( ) ; $ this -> publish ( ) ; }
Boot principale du service
3,204
public function bootValidator ( ) { \ Validator :: extend ( 'not_exists' , function ( $ attribute , $ value , $ parameters ) { $ row = \ DB :: table ( $ parameters [ 0 ] ) -> where ( $ parameters [ 1 ] , '=' , $ value ) -> first ( ) ; return empty ( $ row ) ; } ) ; }
Ajoute de nouveau validateur
3,205
public function bootMail ( ) { Response :: macro ( 'mail' , function ( $ view , $ data = [ ] , $ from = [ ] , $ to = [ ] , $ subject = '' , $ attach = [ ] ) { if ( $ from instanceof Mail \ Message ) { \ Mail :: send ( $ view , $ data , function ( Mail \ Message $ message ) use ( $ from , $ attach ) { $ swift = $ from -...
Permet d utiliser la reponse pour envoyer un mail
3,206
public function interceptMethodCall ( ProceedingJoinPointInterface $ jointPoint ) { if ( $ this -> breaker -> isAvailable ( $ this -> serviceName ) ) { try { $ result = $ jointPoint -> proceed ( ) ; $ this -> breaker -> reportSuccess ( $ this -> serviceName ) ; return $ result ; } catch ( Exception $ e ) { if ( $ this ...
In this implementation we ask CircuitBreaker implementation if it is safe to proceed with the service call .
3,207
public function getColumn ( string $ name ) : AbstractColumnDefinition { if ( ! $ this -> offsetExists ( $ name ) ) { throw new Exception \ UnexistentColumnException ( "Column '$name' does not exists in metadata" ) ; } return $ this -> offsetGet ( $ name ) ; }
Return specific column metadata .
3,208
public function parse ( $ selector ) { if ( '/' === $ selector ) { return array ( ) ; } if ( '/' !== substr ( $ selector , 0 , 1 ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Path "%s" must be absolute' , $ selector ) ) ; } $ selector = substr ( $ selector , 1 ) ; $ segments = array ( ) ; $ elements = explode...
Parse the given selector .
3,209
public function makeAuthenticatedApiRequest ( $ resource , array $ params = array ( ) , $ method = 'GET' ) { $ this -> assertHasActiveUser ( ) ; $ params [ 'oauth_token' ] = $ this -> token ; return $ this -> makeApiRequest ( $ resource , $ params , $ method ) ; }
make an authenticated request to the api
3,210
public function makeApiRequest ( $ resource , array $ params = array ( ) , $ method = 'GET' ) { $ uri = $ this -> requestUri . '/' . ltrim ( $ resource , '/' ) ; if ( $ this -> hasValidToken ( ) ) { $ params [ 'oauth_token' ] = $ this -> token ; } else { $ params [ 'client_id' ] = $ this -> clientId ; $ params [ 'clien...
make a generic request to the api
3,211
protected function getCssContent ( ) { $ styleString = "" ; if ( class_exists ( "\\DOMDocument" ) ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadHTMLFile ( $ this -> getFilename ( ) ) ; foreach ( $ doc -> getElementsByTagName ( 'style' ) as $ styleNode ) { $ styleString .= $ styleNode -> nodeValue . "\r\n" ; } } else...
Gets the CSS content from the HTML source .
3,212
public function retrieveItemPrices ( $ itemsData , $ currency , $ locale ) { $ items = [ ] ; $ previousItem = null ; foreach ( $ itemsData as $ itemData ) { $ useProductsPrice = false ; if ( isset ( $ itemData [ 'useProductsPrice' ] ) && $ itemData [ 'useProductsPrice' ] == true ) { $ useProductsPrice = $ itemData [ 'u...
Calculates total prices of all items given in data array .
3,213
public function getMetadataForClass ( $ className ) { if ( ! class_exists ( $ className ) ) { throw new \ Exception ( "Class $className does not exist!" ) ; } if ( isset ( $ this -> loadedMetadatas [ $ className ] ) ) { return $ this -> loadedMetadatas [ $ className ] ; } return $ this -> loadedMetadatas [ $ className ...
Allow to get class metadata for specified class
3,214
protected function setValue ( $ value ) { if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; if ( $ value !== "" ) { $ this -> value = $ value ; } else { throw new \ InvalidArgumentException ( "Invalid value for argument 'value' given." ) ; } } else { throw new \ InvalidArgumentException ( "Invalid type '" . g...
Sets the value for the charset rule .
3,215
public function start ( $ environment = null , $ configLocation = null ) { $ config = $ this -> loadConfig ( $ environment , $ configLocation ) ; $ this -> loadErrorHandler ( $ config , $ environment ) ; $ instantiator = $ this -> loadContainer ( $ config , $ environment ) ; $ middleware = $ instantiator ( Middleware \...
The starting point for any Weave App .
3,216
protected static function encodePart ( & $ input ) { $ codePoints = & static :: codePoints ( $ input ) ; $ n = static :: INITIAL_N ; $ bias = static :: INITIAL_BIAS ; $ delta = 0 ; $ h = $ b = count ( $ codePoints [ 'basic' ] ) ; $ output = static :: getString ( $ codePoints [ 'basic' ] ) ; if ( $ input === $ output ) ...
Encode a part of a domain name such as tld to its Punycode version
3,217
public function blockOne ( $ host ) { return $ this -> exists ( $ host ) ? $ this -> updateOne ( $ host ) : $ this -> addOne ( $ host ) ; }
Add a host to a blacklist collection .
3,218
public function allowOne ( $ host ) { return $ this -> exists ( $ host ) ? $ this -> updateOne ( $ host , false ) : $ this -> addOne ( $ host , false ) ; }
Add a host to a whitelist collection .
3,219
private function addOne ( $ host , $ blocked = true ) { $ spammer = Spammer :: make ( $ host , $ blocked ) ; return $ this -> put ( $ spammer -> host ( ) , $ spammer ) ; }
Add a host to the collection .
3,220
public function whereHostIn ( array $ hosts , $ strict = false ) { $ values = $ this -> getArrayableItems ( $ hosts ) ; return $ this -> filter ( function ( Spammer $ spammer ) use ( $ values , $ strict ) { return in_array ( $ spammer -> host ( ) , $ values , $ strict ) ; } ) ; }
Filter the spammer by the given hosts .
3,221
public function updatePermissions ( Request $ request , Role $ role ) { $ this -> authorize ( 'manage_permissions' , Role :: class ) ; $ permissions = Permission :: all ( ) ; foreach ( $ permissions as $ permission ) { if ( array_key_exists ( $ permission -> id , $ request -> all ( ) ) ) { $ role -> addPermission ( $ p...
Update the role permissions .
3,222
public function contactUs ( Request $ request ) { $ this -> validate ( $ request , [ 'full_name' => 'required' , 'email' => 'required' , 'subject' => 'required' , 'message' => 'required' ] ) ; Mail :: send ( 'page::emails.contact-info' , [ 'data' => $ request -> all ( ) ] , function ( Message $ message ) use ( $ reques...
Process the contact form name .
3,223
protected function writeLog ( $ message ) { $ fileName = 'app/logs/mail/error.log' ; $ log = sprintf ( "[%s]: %s\n" , date_format ( new \ DateTime ( ) , 'Y-m-d H:i:s' ) , $ message ) ; file_put_contents ( $ fileName , $ log , FILE_APPEND ) ; }
Writes a new line to mail error log
3,224
protected function author_traversal ( $ field , $ post ) { $ parts = explode ( '.' , $ field ) ; $ author = get_user_by ( 'id' , $ post -> post_author ) ; $ parts = explode ( '.' , $ field ) ; $ author = get_user_by ( 'id' , $ post -> post_author ) ; if ( is_object ( $ author ) && isset ( $ parts [ 1 ] ) && 'posts_url'...
Handle author . field traversals
3,225
public function filter_post ( $ in_params ) { $ params = explode ( ':' , $ in_params ) ; if ( isset ( $ params [ 1 ] ) ) { $ post = get_post ( $ params [ 0 ] ) ; $ field = $ params [ 1 ] ; } else { global $ post ; $ field = $ params [ 0 ] ; } return $ this -> get_post_value ( $ field , $ in_params , $ post ) ; }
Filters a post magic tag
3,226
public function filter_get_var ( $ params ) { if ( isset ( $ _GET [ $ params ] ) ) { return wp_slash ( $ _GET [ $ params ] ) ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_REFERER' ] ) ) { return $ this -> filter_get_referr_var ( $ params ) ; } return $ params ; }
Filters a GET magic tag
3,227
private function filter_get_referr_var ( $ params ) { $ referer = parse_url ( $ _SERVER [ 'HTTP_REFERER' ] ) ; if ( ! empty ( $ referer [ 'query' ] ) ) { parse_str ( $ referer [ 'query' ] , $ get_vars ) ; if ( isset ( $ get_vars [ $ params ] ) ) { return wp_slash ( $ get_vars [ $ params ] ) ; } } return $ params ; }
Filters a GET from a referrer
3,228
public function filter_user ( $ params ) { if ( ! is_user_logged_in ( ) ) { return $ params ; } $ user = get_userdata ( get_current_user_id ( ) ) ; if ( isset ( $ user -> data -> { $ params } ) ) { $ params = $ user -> data -> { $ params } ; } $ is_meta = get_user_meta ( $ user -> ID , $ params , true ) ; if ( ! empty ...
Filters a user magic tag
3,229
public function filter_ip ( ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; if ( ! empty ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { $ ip = $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } return $ ip ; }
Filters a ip magic tag
3,230
private function maybe_do_post_thumbnail ( $ field , $ post ) { if ( 'post_thumbnail' == $ field || false !== strpos ( $ field , 'post_thumbnail.' ) ) { $ size = 'thumbnail' ; if ( false !== ( $ pos = strpos ( $ field , '.' ) ) ) { $ size = substr ( $ field , $ pos + 1 ) ; } $ id = get_post_thumbnail_id ( $ post -> ID ...
If field is post_thumbnail return image source URL
3,231
private function maybe_do_featured ( $ field , $ post ) { if ( 'post_featured' == $ field ) { $ id = get_post_thumbnail_id ( $ post -> ID ) ; if ( 0 < absint ( $ id ) ) { return wp_get_attachment_image ( $ id , 'large' ) ; } return '' ; } }
Handle post_featured tags
3,232
public function send ( Message $ mail ) { $ mails = array ( ) ; if ( $ this -> sessionSection -> offsetExists ( 'sentMessages' ) ) { $ mails = $ this -> sessionSection -> sentMessages ; } if ( count ( $ mails ) === $ this -> limit ) { array_pop ( $ mails ) ; } $ reflectionMethod = $ mail -> getReflection ( ) -> getMeth...
Sends given message via this mailer
3,233
public function removeNotReplacedChar ( $ notReplaced ) { if ( empty ( $ notReplaced ) ) { throw new \ Exception ( 'Not replaced character cannot be null.' ) ; } if ( is_array ( $ notReplaced ) ) { foreach ( $ notReplaced as $ n ) { $ this -> removeNotReplacedChar ( $ n ) ; } } else { if ( ! in_array ( $ notReplaced , ...
Remove not replaced character
3,234
public function addWordDelimiter ( $ delimiter ) { if ( in_array ( $ delimiter , $ this -> getWordDelimiters ( ) ) ) { throw new \ Exception ( "Word delimiter '$delimiter' is already there." ) ; } if ( empty ( $ delimiter ) ) { throw new \ Exception ( 'Word delimiter cannot be null.' ) ; } if ( is_array ( $ delimiter )...
Add word delimiter
3,235
public function ActiveCollabDatabaseStructureBehaviourPositionInterfaceImplementation ( ) { $ this -> registerEventHandler ( 'on_before_save' , function ( ) { if ( ! $ this -> getPosition ( ) ) { $ table_name = $ this -> connection -> escapeTableName ( $ this -> getTableName ( ) ) ; $ conditions = $ this -> getPosition...
Say hello to the parent class .
3,236
private function getPositionContextConditions ( ) { $ pattern = $ this -> pool -> getTypeProperty ( get_class ( $ this ) , 'position_context_conditions_pattern' , function ( ) { $ conditions = [ ] ; foreach ( $ this -> getPositionContext ( ) as $ field_name ) { $ conditions [ ] = $ this -> connection -> escapeFieldName...
Return position context conditions .
3,237
public function next ( ) { $ this -> position ++ ; $ this -> generator -> next ( ) ; $ this -> currentData = $ this -> generator -> current ( ) ; }
Moves forward to next element .
3,238
public function removeStatus ( ApiItemInterface $ item , $ status , $ flush = false ) { $ currentBitmaskStatus = $ item -> getBitmaskStatus ( ) ; if ( $ currentBitmaskStatus && $ currentBitmaskStatus & $ status ) { $ item -> setBitmaskStatus ( $ currentBitmaskStatus & ~ $ status ) ; } if ( $ flush === true ) { $ this -...
Converts status of an item
3,239
public function findByIdAndLocale ( $ id , $ locale ) { $ item = $ this -> itemRepository -> findByIdAndLocale ( $ id , $ locale ) ; if ( $ item ) { return $ this -> itemFactory -> createApiEntity ( $ item , $ locale ) ; } else { return null ; } }
Finds an item by id and locale
3,240
protected function setItemByProductData ( $ productData , ApiItemInterface $ item , $ locale ) { $ productId = $ this -> getProductId ( $ productData ) ; $ product = $ this -> productRepository -> find ( $ productId ) ; if ( ! $ product ) { throw new ProductNotFoundException ( self :: $ productEntityName , $ productId ...
Sets item based on given product data
3,241
protected function setItemSupplier ( $ item , $ product ) { if ( $ product -> getSupplier ( ) ) { $ item -> setSupplier ( $ product -> getSupplier ( ) ) ; $ item -> setSupplierName ( $ product -> getSupplier ( ) -> getName ( ) ) ; } else { $ item -> setSupplier ( null ) ; $ item -> setSupplierName ( '' ) ; } }
Set supplier of an item
3,242
private function updatePrices ( ApiItemInterface $ item , $ data ) { $ currency = null ; if ( $ item -> getUseProductsPrice ( ) === false ) { $ item -> setPrice ( $ this -> getProperty ( $ data , 'price' , $ item -> getPrice ( ) ) ) ; } $ price = $ this -> itemPriceCalculator -> calculate ( $ item , $ currency , $ item...
Function updates item prices its product data
3,243
public function process ( \ ECL \ SymbolTable $ table ) { $ results = [ ] ; for ( $ i = 0 ; $ i < count ( $ this -> commands ) ; ++ $ i ) { $ command = $ this -> commands [ $ i ] ; $ curr_result = $ command -> process ( $ table ) ; $ table [ \ ECL \ SymbolTable :: DEFAULT_SYMBOL ] = $ curr_result ; if ( $ i + 1 >= coun...
Process the list of Commands .
3,244
public function getRouteCollectionForRequest ( Request $ request ) { $ collection = new RouteCollection ( ) ; $ path = $ this -> getNormalizedPath ( $ request ) ; $ resource = $ this -> repository -> findOneBy ( [ 'path' => $ path ] ) ; if ( $ resource ) { $ route = $ this -> createRoute ( $ resource ) ; $ collection -...
Returns route collection for current request
3,245
public function getRouteByName ( $ identifier ) { $ id = str_replace ( self :: DYNAMIC_PREFIX , '' , $ identifier ) ; $ resource = $ this -> repository -> find ( $ id ) ; if ( $ resource instanceof Route ) { return $ this -> createRoute ( $ resource ) ; } return null ; }
Returns route by its identifier
3,246
private function getNormalizedPath ( Request $ request ) { $ path = ltrim ( $ request -> getPathInfo ( ) , '/' ) ; $ paths = explode ( self :: PATH_PARAMS_SEPARATOR , $ path ) ; return current ( $ paths ) ; }
Returns normalized path used in resource query
3,247
public function linkUrlsAndEscapeHtml ( $ text ) { if ( strpos ( $ text , '.' ) === false ) { return $ this -> escapeHtml ( $ text ) ; } $ html = '' ; $ position = 0 ; $ match = array ( ) ; while ( preg_match ( $ this -> buildRegex ( ) , $ text , $ match , PREG_OFFSET_CAPTURE , $ position ) ) { list ( $ url , $ urlPosi...
Transforms plain text into valid HTML escaping special characters and turning URLs into links .
3,248
private function exportOrder ( Order $ order , int $ foundOrder ) { $ logger = $ this -> getLogger ( ) ; try { $ eventDispatcher = $ this -> getEventDispatcher ( ) ; $ filesystem = $ this -> getFilesystem ( ) ; $ event = $ eventDispatcher -> dispatch ( EventStore :: PRE_ORDER_EXPORT , new PrepareOrderExportEvent ( $ fi...
Exports the given order .
3,249
public function exportOrders ( OrderVisitor $ orderVisitor , ProgressBar $ bar ) : bool { $ logger = $ this -> getLogger ( ) ; $ bar -> start ( $ count = count ( $ orderVisitor ) ) ; $ logger -> debug ( 'Started the order export.' , [ 'count' => $ count ] ) ; foreach ( $ orderVisitor ( ) as $ num => $ order ) { set_tim...
Exports the given orders .
3,250
public function createRepositoryTransformer ( string $ alias ) : DataTransformerInterface { if ( ! $ this -> collection -> has ( $ alias ) ) { throw new MissingFormDataTransformerException ( $ alias ) ; } $ serviceId = $ this -> collection -> get ( $ alias ) ; return $ this -> get ( $ serviceId ) ; }
Creates and returns a new instance of form data transformer
3,251
public function embed ( ? string $ url = null , ? string $ id = null ) : ? string { $ hasMultiple = function ( string $ url , string $ pattern ) : bool { return false !== strpos ( $ url , $ pattern ) ; } ; if ( isset ( $ url , $ id ) ) { $ ripple = new static ( $ url ) ; if ( null !== $ ripple -> provider ) { $ class =...
Returns HTML embed of the track .
3,252
public function validateTokenHash ( $ tokenHash ) { $ tokenData = $ this -> tokenCache -> get ( $ tokenHash ) ; if ( $ tokenData === false ) { $ this -> logger -> log ( sprintf ( 'Validation of token hash %s failed' , $ tokenHash ) , LOG_INFO ) ; return null ; } $ preset = $ this -> getPreset ( $ tokenData [ 'presetNam...
This checks if a given hash is known and still valid before returning the associated Token .
3,253
public function invalidateToken ( Token $ token ) { $ this -> tokenCache -> remove ( $ token -> getHash ( ) ) ; $ this -> logger -> log ( sprintf ( 'Deleted token %s.' , $ token -> getIdentifier ( ) ) , LOG_INFO ) ; }
Removes the given token from the token cache .
3,254
public function devMode ( $ args ) { if ( empty ( $ args [ 0 ] ) ) { $ mode = \ Disco \ manage \ Manager :: devMode ( ) ; echo 'DEV_MODE : ' . ( ( $ mode ) ? 'true' : 'false' ) . PHP_EOL ; exit ; } else if ( $ args [ 0 ] != 'true' && $ args [ 0 ] != 'false' ) { echo 'Mode takes one of two values: true | false' . PHP_EO...
Get the current dev mode optionally setting it .
3,255
public function dbRestore ( $ args ) { $ path = '/app/db/' ; if ( isset ( $ args [ 0 ] ) ) { $ path = $ args [ 0 ] ; } $ path = \ App :: path ( ) . '/' . trim ( $ path , '/' ) . '/' ; $ fileName = \ App :: config ( 'DB_DB' ) ; if ( isset ( $ args [ 1 ] ) ) { $ fileName = $ args [ 1 ] ; } $ fileName = $ path . $ fileNam...
Restore the DB from a backup .
3,256
public function create ( $ args ) { if ( $ args [ 0 ] == 'model' ) { if ( ! isset ( $ args [ 1 ] ) ) { echo 'You must specify a table to build the model from' . PHP_EOL ; exit ; } $ table = $ args [ 1 ] ; $ templatePath = isset ( $ args [ 2 ] ) ? $ args [ 2 ] : 'app/config/model.format' ; $ outputPath = isset ( $ args ...
Create a model or a record . Use the special keyword all in place of a table name to generate records or models for all tables .
3,257
public static function consoleQuestion ( $ question , $ options ) { @ ob_flush ( ) ; $ orgQuestion = $ question ; $ opts = '' ; foreach ( $ options as $ value => $ statement ) { $ opts .= "'{$value}') echo '{$value}'; break;;" ; $ question .= PHP_EOL . "($value) - {$statement}" ; } $ question .= PHP_EOL . 'Your answer?...
Prompt the user at the console with a question and the valid options that serve as an answer to that question .
3,258
public function consolePrompt ( $ question , $ cannotBeBlank = false ) { @ ob_flush ( ) ; exec ( "read -p '{$question} ' answer; echo \$answer;" , $ answer ) ; if ( ! $ answer [ 0 ] && $ cannotBeBlank === true ) { echo PHP_EOL . 'Answer cannot be blank! Try again...' . PHP_EOL . PHP_EOL ; return self :: consolePrompt (...
Prompt the user at the console to enter a free form text response to a question .
3,259
public function getOutputParam ( $ key ) { if ( isset ( $ this -> _output_params [ $ key ] ) ) { return $ this -> _output_params [ $ key ] ; } return null ; }
Get an output parameter .
3,260
public function validate ( ) { $ retval = false ; $ params = array ( 'output_type' => $ this -> _output_type ) ; foreach ( $ this -> _output_params as $ key => $ val ) { $ params [ self :: OUTPUT_PARAMS_PREFIX . $ key ] = $ val ; } try { $ retval = $ this -> _user -> post ( 'push/validate' , $ params ) ; } catch ( Data...
Validate the output type and parameters with the DataSift API .
3,261
protected function subscribe ( $ hash_type , $ hash , $ name ) { $ retval = false ; $ params = array ( 'name' => $ name , $ hash_type => $ hash , 'output_type' => $ this -> _output_type , ) ; foreach ( $ this -> _output_params as $ key => $ val ) { $ params [ self :: OUTPUT_PARAMS_PREFIX . $ key ] = $ val ; } if ( strl...
Subscribe this endpoint to a stream hash or historic playback ID . Note that this will activate the subscription if the initial status is set to active .
3,262
public function activate ( Composer $ composer , IOInterface $ ioc ) { $ installer = new Installer ( $ ioc , $ composer ) ; $ manager = $ composer -> getInstallationManager ( ) ; $ manager -> addInstaller ( $ installer ) ; }
Activates plugin and registers installer .
3,263
public function hasPermission ( $ permission ) { $ permission = ! is_string ( $ permission ) ? : Permission :: where ( [ 'slug' => $ permission ] ) -> first ( ) ; if ( config ( 'laralum.superadmin_bypass_haspermission' ) ) { return true ; } if ( $ permission ) { foreach ( $ this -> roles as $ role ) { if ( $ role -> ha...
Returns true if the role has a permission .
3,264
public function postProcess ( Request $ request , Response $ response ) { if ( empty ( $ this -> allowedOriginHosts ) || ! $ request -> hasHeader ( 'HTTP_ORIGIN' ) ) { return ; } $ originHost = $ request -> readHeader ( 'HTTP_ORIGIN' ) -> unsecure ( ) ; foreach ( $ this -> allowedOriginHosts as $ allowedOriginHost ) { ...
does the postprocessing stuff
3,265
public function checkProperty ( & $ property ) { if ( is_string ( $ property ) ) { $ property = Placeholder :: replaceStringsAndComments ( $ property ) ; $ property = Placeholder :: removeCommentPlaceholders ( $ property , true ) ; $ property = Placeholder :: replaceStringPlaceholders ( $ property , true ) ; return tru...
Sets the declaration property .
3,266
public function checkValue ( & $ value ) { if ( is_string ( $ value ) ) { $ value = Placeholder :: replaceStringsAndComments ( $ value ) ; $ value = Placeholder :: removeCommentPlaceholders ( $ value , true ) ; $ value = Placeholder :: replaceStringPlaceholders ( $ value , true ) ; $ value = trim ( $ value ) ; if ( $ v...
Checks the declaration value .
3,267
public function handle ( Client $ client , $ index , $ type , $ alias = null ) { $ alias = $ alias ? : $ index ; $ entries = $ this -> registry -> get ( $ alias , $ type ) ; $ this -> dispatchHandlingStartedEvent ( $ entries ) ; foreach ( $ entries as $ entry ) { $ this -> dispatchProvidingStartedEvent ( $ entry ) ; $ ...
Handle provide command
3,268
private function isUserTokenAuthenticated ( ) { try { $ token = $ this -> TokenUser -> getTokenInterface ( ) -> get ( ) ; $ this -> TokenUser -> validate ( $ token ) ; } catch ( Exception $ exception ) { return $ exception ; } return true ; }
Validates an authentication token if provided otherwise returns an exception that can be re - thrown later .
3,269
public function getFields ( ) { return [ ( new IntegerField ( $ this -> getName ( ) ) ) -> unsigned ( true ) -> size ( $ this -> getSize ( ) ) -> required ( $ this -> isRequired ( ) ) ] ; }
Return fields that this field is composed of .
3,270
public function toQuery ( ) : array { $ array = [ ] ; foreach ( get_object_vars ( $ this ) as $ name => $ value ) { if ( null === $ value ) { continue ; } if ( is_array ( $ value ) ) { if ( count ( $ value ) ) { foreach ( $ value as $ v ) { $ array [ ] = [ 'name' => $ name . '[]' , 'contents' => $ v ] ; } } } else { $ ...
Convert tye object to query string .
3,271
public function getId ( $ format = 'bytes' ) { return static :: isUuid ( ) && $ format != false ? uuid ( $ format , $ this -> id ) : $ this -> id ; }
Getter for ID
3,272
public function getModel ( $ reload = false ) { if ( ! isset ( $ this -> model ) || $ reload ) { $ class = static :: $ modelClass ; $ this -> model = $ class :: findOrFail ( $ this -> getId ( ) ) ; } return $ this -> model ; }
return the main model
3,273
static public function exists ( $ id ) { try { $ class = static :: $ modelClass ; $ class :: findOrFail ( static :: isUuid ( ) ? uuid ( 'bytes' , $ id ) : $ id ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
return true id user exist
3,274
protected function getOAuthToken ( ) { if ( $ this -> client_id and $ this -> client_secret ) { $ response = $ this -> httpQuery ( 'POST' , 'https://orcid.org/oauth/token' , [ 'Accept' => 'application/json' , 'Content-Type' => 'application/x-www-form-urlencoded' ] , http_build_query ( [ 'client_id' => $ this -> client_...
Get an OAuth access token
3,275
protected function getProfile ( $ id ) { $ token = $ this -> getOAuthToken ( ) ; if ( ! $ token ) return ; $ response = $ this -> httpQuery ( 'GET' , "https://pub.orcid.org/v1.2/$id/orcid-bio/" , [ 'Authorization' => "Bearer $token" , 'Accept' => 'application/json' , ] ) ; if ( $ response ) { return $ response -> { 'or...
get an indentified profile by ORCID ID
3,276
protected function searchProfiles ( $ query ) { $ token = $ this -> getOAuthToken ( ) ; if ( ! $ token ) return ; $ response = Unirest \ Request :: get ( "https://pub.orcid.org/v1.2/search/orcid-bio/" , [ 'Authorization' => "Bearer $token" , 'Content-Type' => 'application/orcid+json' ] , [ 'q' => luceneQuery ( 'text' ,...
search for an ORCID profile
3,277
public function getList ( array $ options = array ( ) ) { $ uri = $ this -> buildListResourceUri ( $ this -> listId ) ; $ response = $ this -> makeApiRequest ( $ uri , $ options ) ; return $ response -> list ; }
Get a List .
3,278
function resolve ( $ url = '' , Array $ query_string_vars = [ ] ) { if ( $ this -> done && empty ( $ this -> error ) ) { return $ this -> query_vars ; } $ this -> parseUrl ( $ url , $ query_string_vars ) ; $ rewrite = ( array ) $ this -> resolver -> getRewrite ( ) ; if ( ! empty ( $ rewrite ) ) { list ( $ matches , $ q...
Resolve an url to an array of WP_Query arguments for main query .
3,279
private function parseUrl ( $ url = '' , Array $ query_string_vars = [ ] ) { parse_str ( parse_url ( $ url , PHP_URL_QUERY ) , $ this -> query_string ) ; $ request_uri = trim ( parse_url ( $ url , PHP_URL_PATH ) , '/' ) ; $ this -> request = trim ( preg_replace ( '#^/*index\.php#' , '' , $ request_uri ) , '/' ) ; if ( ...
Parse the url to be resolved taking only relative part and stripping out query vars .
3,280
private function parseRewriteRules ( Array $ rewrite ) { $ this -> error = '404' ; $ request_match = $ this -> request ; if ( empty ( $ request_match ) && isset ( $ rewrite [ '$' ] ) ) { $ this -> matched_rule = '$' ; $ matches = [ '' ] ; $ query = $ rewrite [ '$' ] ; } else { foreach ( ( array ) $ rewrite as $ match =...
Loop throught registered rewrite rule and check them against the url to resolve .
3,281
private function setMatchedQuery ( $ matches = [ ] , $ query = '' ) { if ( ! is_null ( $ this -> matched_rule ) ) { $ mathed = \ WP_MatchesMapRegex :: apply ( preg_replace ( "!^.+\?!" , '' , $ query ) , $ matches ) ; $ this -> matched_query = addslashes ( $ mathed ) ; parse_str ( $ this -> matched_query , $ this -> per...
When a rute matches save matched query string and matched query array .
3,282
private function maybeAdmin ( ) { if ( empty ( $ this -> request ) || strpos ( $ this -> request , 'wp-admin/' ) !== FALSE ) { $ this -> error = NULL ; if ( ! is_null ( $ this -> perma_q_vars ) && strpos ( $ this -> request , 'wp-admin/' ) !== FALSE ) { $ this -> perma_q_vars = NULL ; } } }
Check if the url is for admin in that case unset all the frontend query variables
3,283
private function resolveVars ( ) { $ this -> setCptQueryVars ( ) ; $ wp = $ this -> resolver -> getWp ( ) ; $ public_query_vars = ( array ) apply_filters ( 'query_vars' , $ wp -> public_query_vars ) ; $ extra_query_vars = ( array ) $ this -> resolver -> getExtraQueryVars ( ) ; $ this -> parseQueryVars ( $ public_query_...
Setup the query variables if a rewrite rule matched or if some variables are passed as query string . Strips out not registered query variables and perform the request filter before saving and return found query vars .
3,284
private function setCptQueryVars ( ) { foreach ( get_post_types ( [ ] , 'objects' ) as $ post_type => $ t ) { if ( $ t -> query_var ) $ this -> post_type_query_vars [ $ t -> query_var ] = $ post_type ; } }
Store all the query rewrite slugs for all registered post types
3,285
private function parseQueryVar ( $ wpvar = '' ) { if ( ! is_array ( $ this -> query_vars [ $ wpvar ] ) ) { $ this -> query_vars [ $ wpvar ] = ( string ) $ this -> query_vars [ $ wpvar ] ; } else { foreach ( $ this -> query_vars [ $ wpvar ] as $ vkey => $ v ) { if ( ! is_object ( $ v ) ) { $ this -> query_vars [ $ wpvar...
Parse a query variable flattening it if is an array or an object also set post_type and name query var if a slug of a registered post type is present among query vars
3,286
private function parseTaxQueryVars ( ) { foreach ( get_taxonomies ( [ ] , 'objects' ) as $ t ) { if ( $ t -> query_var && isset ( $ this -> query_vars [ $ t -> query_var ] ) ) { $ encoded = str_replace ( ' ' , '+' , $ this -> query_vars [ $ t -> query_var ] ) ; $ this -> query_vars [ $ t -> query_var ] = $ encoded ; } ...
Convert spacet to + in the query variables for custom taxonomies
3,287
private function parseCptQueryVars ( ) { if ( isset ( $ this -> query_vars [ 'post_type' ] ) ) { $ queryable = get_post_types ( [ 'publicly_queryable' => TRUE ] ) ; if ( ! is_array ( $ this -> query_vars [ 'post_type' ] ) && ! in_array ( $ this -> query_vars [ 'post_type' ] , $ queryable , TRUE ) ) { unset ( $ this -> ...
Remove from query variables any non publicly queriable post type rewrite slug
3,288
private function parsePrivateQueryVars ( Array $ extra = [ ] , Array $ private = [ ] ) { if ( ! empty ( $ extra ) ) { foreach ( $ private as $ var ) { if ( isset ( $ extra [ $ var ] ) ) { $ this -> query_vars [ $ var ] = $ extra [ $ var ] ; } } } }
Look in extra query variables passed to resolver and compare to WP object private variables if some variables are found they are added to query variables to be returned
3,289
public function getFileSystem ( ) { if ( empty ( $ this -> fileSystem ) ) { $ this -> fileSystem = \ Drupal :: service ( 'file_system' ) ; } return $ this -> fileSystem ; }
Gets the file system .
3,290
public function recaptcha ( $ response , $ ipClient = null ) { if ( $ this -> getOptions ( ) -> getGRecaptchaKey ( ) ) { $ client = new \ Zend \ Http \ Client ( $ this -> getOptions ( ) -> getGRecaptchaUrl ( ) ) ; $ client -> setParameterPost ( array ( 'secret' => $ this -> getOptions ( ) -> getGRecaptchaKey ( ) , 'res...
This method calls Google ReCaptcha .
3,291
protected function checkSetUserFrontendLogin ( ) { if ( FE_USER_LOGGED_IN ) { $ this -> import ( 'FrontendUser' , 'User' ) ; if ( $ this -> arrCategoryValues [ 'banner_protected' ] == 1 && $ this -> arrCategoryValues [ 'banner_group' ] > 0 ) { if ( $ this -> User -> isMemberOf ( $ this -> arrCategoryValues [ 'banner_gr...
Check if FE User loggen in and banner category is protected
3,292
protected function setRandomBlockerId ( $ BannerID = 0 ) { if ( $ BannerID == 0 ) { return ; } $ this -> statusRandomBlocker = true ; $ this -> setSession ( 'RandomBlocker' . $ this -> module_id , array ( $ BannerID => time ( ) ) ) ; return ; }
Random Blocker Set Banner - ID
3,293
protected function getRandomBlockerId ( ) { $ this -> getSession ( 'RandomBlocker' . $ this -> module_id ) ; if ( count ( $ this -> _session ) ) { $ key = key ( $ this -> _session ) ; $ value = current ( $ this -> _session ) ; unset ( $ value ) ; reset ( $ this -> _session ) ; return $ key ; } return 0 ; }
Random Blocker Get Banner - ID
3,294
protected function setFirstViewBlockerId ( $ banner_categorie = 0 ) { if ( $ banner_categorie == 0 ) { return ; } $ this -> statusFirstViewBlocker = true ; $ this -> setSession ( 'FirstViewBlocker' . $ this -> module_id , array ( $ banner_categorie => time ( ) ) ) ; return ; }
First View Blocker Set Banner Categorie - ID and timestamp
3,295
protected function removeOldFirstViewBlockerId ( $ key , $ tstmap ) { $ FirstViewBlockTime = time ( ) - 60 * 5 ; if ( $ tstmap > $ FirstViewBlockTime ) { return true ; } else { \ Session :: getInstance ( ) -> remove ( $ key ) ; } return false ; }
First View Blocker Remove old Banner Categorie - ID
3,296
protected function getSetFirstView ( ) { if ( $ this -> banner_firstview != 1 ) { return false ; } $ this -> BannerReferrer = new \ Banner \ BannerReferrer ( ) ; $ this -> BannerReferrer -> checkReferrer ( ) ; $ ReferrerDNS = $ this -> BannerReferrer -> getReferrerDNS ( ) ; if ( $ ReferrerDNS === 'o' ) { $ this -> stat...
Get FirstViewBanner status and set cat id as blocker
3,297
protected function setStatViewUpdateBlockerId ( $ banner_id = 0 ) { if ( $ banner_id == 0 ) { return ; } $ this -> setSession ( 'StatViewUpdateBlocker' . $ this -> module_id , array ( $ banner_id => time ( ) ) , true ) ; return ; }
StatViewUpdate Blocker Set Banner ID and timestamp
3,298
protected function removeStatViewUpdateBlockerId ( $ banner_id , $ tstmap ) { $ BannerBlockTime = time ( ) - 60 * 5 ; if ( isset ( $ GLOBALS [ 'TL_CONFIG' ] [ 'mod_banner_block_time' ] ) && intval ( $ GLOBALS [ 'TL_CONFIG' ] [ 'mod_banner_block_time' ] ) > 0 ) { $ BannerBlockTime = time ( ) - 60 * 1 * intval ( $ GLOBAL...
StatViewUpdate Blocker Remove old Banner ID
3,299
public function get ( $ id , $ invalidBehavior = self :: EXCEPTION_ON_INVALID_REFERENCE ) { if ( $ this -> isSilverStripeServiceRequest ( $ id ) ) { return $ this -> getSilverStripeService ( $ id ) ; } else { return parent :: get ( $ id , $ invalidBehavior ) ; } }
Use SilverStripe s Dependency Injection system if the service is namespaced silverstripe