idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
1,900
protected function addFormatter ( & $ manager , $ model , $ formatter ) { $ config = ( include $ this -> configPath . '/' . $ model . '.php' ) ; if ( ! isset ( $ config [ $ formatter ] ) ) return ; $ formatterClass = 'kriskbx\mikado\Formatters\\' . $ formatter ; if ( is_array ( $ config [ $ formatter ] ) && count ( $ c...
Add formatter to manager .
1,901
protected function isJson ( $ string ) { if ( ! is_string ( $ string ) || is_numeric ( $ string ) ) { return false ; } $ result = @ json_decode ( $ string ) ; return ( json_last_error ( ) == JSON_ERROR_NONE ) ; }
Check to see if a string is JSON .
1,902
public static function fetchSettings ( $ environment = null , $ website_id = null , $ group = 'config' ) { $ model = static :: where ( 'group' , '=' , $ group ) ; $ model -> where ( function ( $ query ) use ( $ environment ) { if ( empty ( $ environment ) ) { $ query -> whereNull ( 'environment' ) ; } else { $ query ->...
Return the configuration data for a specific environment & group .
1,903
public static function fetchExactSettings ( $ environment = null , $ website_id = null , $ group = 'config' ) { $ model = static :: where ( 'group' , '=' , $ group ) ; $ model -> where ( function ( $ query ) use ( $ environment ) { if ( empty ( $ environment ) ) { $ query -> whereNull ( 'environment' ) ; } else { $ que...
Return the exact configuration data for a specific environment & group .
1,904
public static function fetchAllGroups ( ) { $ model = new self ; $ result = [ ] ; try { foreach ( $ model -> select ( 'group' ) -> distinct ( ) -> get ( ) as $ row ) { $ result [ ] = $ row -> group ; } } catch ( \ Exception $ e ) { } return $ result ; }
Return an array of all groups .
1,905
public static function set ( $ key , $ value , $ group = 'config' , $ environment = null , $ website_id = null , $ type = 'string' ) { $ arrayHandling = false ; $ keyExploded = explode ( '.' , $ key ) ; if ( count ( $ keyExploded ) > 1 ) { $ arrayHandling = true ; $ key = array_shift ( $ keyExploded ) ; if ( $ type == ...
Store a group of settings into the database .
1,906
protected static function buildArrayPath ( $ map , $ value , & $ array ) { $ key = array_shift ( $ map ) ; if ( count ( $ map ) !== 0 ) { $ array [ $ key ] = [ ] ; self :: buildArrayPath ( $ map , $ value , $ array [ $ key ] ) ; } else { $ array [ $ key ] = $ value ; } }
This inserts a value into an array at a point in the array path .
1,907
public function getColumnContent ( $ gridField , $ record , $ columnName ) { if ( ! DataObject :: has_extension ( $ gridField -> getModelClass ( ) , Versioned :: class ) ) { user_error ( $ gridField -> getModelClass ( ) . ' does not have the Versioned extension' , E_USER_WARNING ) ; return ; } $ isDeletedFromDraft = ( ...
Gets the content for the column this basically says if it s deleted from the stage you can t delete it
1,908
public function tokenize ( $ httpField , $ fromField ) { $ quoteSeparators = array ( '"' , "'" ) ; $ tokenList = array ( ) ; $ stringAccumulator = '' ; $ lastQuote = '' ; for ( $ i = 0 ; $ i < strlen ( $ httpField ) ; $ i ++ ) { $ chr = substr ( $ httpField , $ i , 1 ) ; switch ( true ) { case $ chr === $ lastQuote : $...
Tokenize the HTTP field for subsequent processing .
1,909
private function _getRequiredVars ( $ template_identifier ) { if ( ! ( isset ( $ this -> _available_templates [ $ template_identifier ] ) ) ) { trigger_error ( "Template identifier not found." , E_USER_ERROR ) ; } $ template_path = ROOT_PATH . '/' . $ this -> _available_templates [ $ template_identifier ] ; if ( ! ( $ ...
Return the found in use vars in tpl .
1,910
private function createInstaller ( ) { $ this -> say ( "Creating package installer" ) ; $ sourceFolder = $ this -> getSourceFolder ( ) . "/administrator/manifests/packages" ; $ targetFolder = $ this -> getBuildFolder ( ) . "/administrator/manifests/packages" ; $ xmlFile = $ targetFolder . "/pkg_" . $ this -> getExtensi...
Generate the installer xml file for the package
1,911
public static function getConfiguration ( ) { if ( self :: $ configuration === null && file_exists ( self :: $ configFilePath ) ) { $ settings = include __DIR__ . '/../../config/configuration.php' ; self :: $ configuration = DWDUtil :: array_to_object ( $ settings ) ; if ( DWDConfiguration :: $ configuration === null )...
Returns the complete configuration file to the callee
1,912
public function getValidInput ( $ clean = false ) { $ input = array_dot ( $ this -> all ( ) ) ; $ rules = array_keys ( $ this -> rules ( ) ) ; $ keys = collect ( $ rules ) -> map ( function ( string $ rule ) use ( $ input ) { $ regex = '/^' . str_replace ( [ '.' , '*' ] , [ '\.' , '(.*)' ] , $ rule ) . '$/' ; return pr...
Get validated user input .
1,913
public function sanitizeInput ( array $ input ) { return $ input = collect ( $ input ) -> reject ( function ( $ value ) { return is_null ( $ value ) || empty ( $ value ) ; } ) -> toArray ( ) ; }
Remove null and empty values from the input .
1,914
public function instance ( $ name ) { if ( empty ( $ this -> instances [ $ name ] ) ) { if ( empty ( $ this -> aliases [ $ name ] ) ) { $ this -> aliasDefault ( $ name ) ; } $ this -> instances [ $ name ] = new $ this -> aliases [ $ name ] ; } return $ this -> instances [ $ name ] ; }
Get the callable for an Underscore method alias .
1,915
public function alias ( $ name , $ spec ) { if ( is_callable ( $ spec ) ) { $ this -> instances [ $ name ] = $ spec ; } else { $ this -> aliases [ $ name ] = $ spec ; unset ( $ this -> instances [ $ name ] ) ; } }
Alias method name to a callable .
1,916
private function aliasDefault ( $ name ) { $ spec = sprintf ( '\Underscore\Mutator\%sMutator' , ucfirst ( $ name ) ) ; if ( ! class_exists ( $ spec ) ) { $ spec = sprintf ( '\Underscore\Accessor\%sAccessor' , ucfirst ( $ name ) ) ; } if ( ! class_exists ( $ spec ) ) { $ spec = sprintf ( '\Underscore\Initializer\%sIniti...
Define a default mutator accessor or initializer for a method name .
1,917
public function refresh ( ) { $ response = $ this -> client -> get ( $ this -> path ( ) ) ; $ this -> setData ( $ response -> json ( ) ) ; }
Refresh the Command Info
1,918
protected function addCheck ( $ name , $ type , $ args ) { $ func = $ type . 'Check' ; if ( method_exists ( $ this , $ func ) ) { $ type = strtolower ( str_replace ( $ type , '' , $ name ) ) ; $ this -> $ func ( $ type , $ name , $ args ) ; } else { throw new \ InvalidArgumentException ( 'Invalid check type: ' . $ type...
Add a new check to the set
1,919
public static function load ( $ dslString ) { $ policy = self :: instance ( ) ; $ parts = explode ( '||' , $ dslString ) ; foreach ( $ parts as $ match ) { $ args = [ ] ; list ( $ method , $ value ) = explode ( ':' , $ match ) ; if ( preg_match ( '/:\((.+?)\)/' , $ match , $ matches ) > 0 ) { if ( isset ( $ matches [ 1...
Load a policy from a string DSL See the README for formatting
1,920
private function check ( $ matchType , $ type , $ name , $ args ) { $ value = array_shift ( $ args ) ; if ( ! isset ( $ args [ 0 ] ) ) { $ args [ 0 ] = [ 'rule' => Policy :: ANY ] ; } if ( is_string ( $ args [ 0 ] ) && ( $ args [ 0 ] === Policy :: ANY || $ args [ 0 ] === Policy :: ALL ) ) { $ args [ 'rule' ] = $ args [...
Add a new check to the current set for the policy
1,921
private function cannotCheck ( $ type , $ name , $ args ) { if ( isset ( $ args [ 0 ] ) && ( is_object ( $ args [ 0 ] ) && get_class ( $ args [ 0 ] ) === 'Closure' ) ) { $ type = 'closure' ; $ args [ 1 ] = $ args [ 0 ] ; } elseif ( is_string ( $ args [ 0 ] ) && strpos ( $ args [ 0 ] , '::' ) !== false ) { $ type = 'met...
Add a cannot check to the set
1,922
public static function add ( $ method , $ target , $ handler , $ name = null ) { array_push ( static :: $ prefixRoutes , [ 'method' => $ method , 'target' => $ target , 'handler' => $ handler , 'name' => $ name , ] ) ; }
Support method to add group of routes .
1,923
public static function group ( $ prefix , Closure $ callback ) { $ callback -> call ( new static ( ) ) ; foreach ( static :: $ prefixRoutes as $ key => $ prefixRoute ) { $ target = $ prefix . $ prefixRoute [ 'target' ] ; $ handler = $ prefixRoute [ 'handler' ] ; $ name = $ prefixRoute [ 'name' ] ; unset ( static :: $ p...
Route Group .
1,924
public static function resource ( $ target , $ handler ) { $ route = $ target ; $ sanitized = str_replace ( '/' , '' , $ target ) ; static :: get ( $ route , $ handler . '@index' , $ sanitized . '_index' ) ; static :: get ( $ target . '/create' , $ handler . '@showCreateForm' , $ sanitized . '_create_form' ) ; static :...
Create a Rest Resource .
1,925
function file_save_data ( $ data , $ destination = NULL , $ replace = FILE_EXISTS_RENAME ) { return file_save_data ( $ data , $ destination , $ replace ) ; }
Saves a file to the specified destination and creates a database entry .
1,926
public function execute ( InputInterface $ input , OutputInterface $ output ) { chdir ( 'public' ) ; if ( $ input -> hasOption ( 'hostname' ) && $ input -> getOption ( 'hostname' ) != null ) { $ this -> hostname = $ input -> getOption ( 'hostname' ) ; } if ( $ input -> hasOption ( 'port' ) && $ input -> getOption ( 'po...
You command logic .
1,927
public function offsetSet ( $ index , $ value ) : void { if ( ! is_object ( $ value ) ) { throw new \ InvalidArgumentException ( "Excepcted object, got " . gettype ( $ value ) ) ; } if ( ! isset ( $ this -> class ) ) { $ this -> class = get_class ( $ value ) ; } if ( get_class ( $ value ) === $ this -> class ) { parent...
Sets the value at the specified index to value if value s class matches the one set . If a class has not been set it will set the given object s class as the only allowed class .
1,928
private function formatParameter ( ReflectionParameter $ parameter ) : string { return $ parameter -> hasType ( ) ? sprintf ( '%s $%s' , $ parameter -> getType ( ) , $ parameter -> getName ( ) ) : sprintf ( '$%s' , $ parameter -> getName ( ) ) ; }
Formats parameter depending on type
1,929
public function controller ( ) { if ( $ this -> restful ) { return filesystem ( ) -> exists ( realpath ( __DIR__ . '/../../../../../app/controllers' ) ) ? realpath ( __DIR__ . '/../Templates/controller/restful.stub' ) : realpath ( __DIR__ . '/../Templates/controller/restful.core.stub' ) ; } return filesystem ( ) -> exi...
Get the template for creating a controller .
1,930
public static function parseComments ( $ comments ) { $ ret = [ ] ; $ comments = str_replace ( array ( '/*' , '*' , '**' ) , '' , $ comments ) ; $ array_comments = explode ( "\n" , $ comments ) ; foreach ( $ array_comments as $ k => $ line ) { $ line = trim ( $ line ) ; if ( self :: startsWith ( $ line , "@" ) ) { $ pa...
Parse comment used only when generate php
1,931
public function applyConclusiveMatch ( $ userAgent ) { $ tolerance = Utils :: firstCloseParen ( $ userAgent ) ; return $ this -> getDeviceIDFromRIS ( $ userAgent , $ tolerance ) ; }
If UA starts with Mozilla apply LD with tollerance 5 .
1,932
public function getImageData ( ) { if ( $ this -> imageData === null ) { $ this -> imageData = $ this -> download ( $ this -> url ) ; } return $ this -> imageData ; }
Returns the complete image data wherever it may have come from .
1,933
public function read ( $ params , $ data , $ key = false , $ single = false ) { global $ smcFunc ; $ dataResult = [ ] ; $ query = $ smcFunc [ 'db_query' ] ( '' , ' SELECT ' . $ params [ 'rows' ] . ' FROM {db_prefix}' . $ params [ 'table' ] . ' ' . ( ! empty ( $ params [ 'join' ] ) ? 'LEFT JOIN ' . $ params [ 'joi...
Reads data from a table .
1,934
public function delete ( $ value , $ table = '' , $ column = '' ) { global $ smcFunc ; if ( empty ( $ id ) || empty ( $ table ) || empty ( $ column ) ) return false ; return $ smcFunc [ 'db_query' ] ( '' , ' DELETE FROM {db_prefix}' . ( $ table ) . ' WHERE ' . ( $ column ) . ' = ' . ( $ value ) . '' , array ( ) ) ;...
Deletes an entry from X table .
1,935
public function load ( ) { $ data = [ ] ; if ( is_file ( $ this -> filePath ) ) { $ data = json_decode ( file_get_contents ( $ this -> filePath ) , true ) ; } return $ data ; }
Prepare the data for driver operations
1,936
public function setInput ( $ input ) { $ this -> input = preg_replace ( "/\r\n|\r/" , "\n" , $ input ) ; $ this -> lineno = 1 ; $ this -> deferred = array ( ) ; $ this -> indentStack = array ( ) ; $ this -> stash = array ( ) ; }
Set lexer input .
1,937
protected function scan ( $ regex , $ type ) { if ( preg_match ( $ regex , $ this -> input , $ matches ) ) { $ this -> consume ( $ matches [ 0 ] ) ; return $ this -> token ( $ type , isset ( $ matches [ 1 ] ) && mb_strlen ( $ matches [ 1 ] ) > 0 ? $ matches [ 1 ] : '' ) ; } }
Helper to create tokens
1,938
public function lookahead ( $ number = 1 ) { $ fetch = $ number - count ( $ this -> stash ) ; while ( $ fetch -- > 0 ) { $ this -> stash [ ] = $ this -> next ( ) ; } return $ this -> stash [ -- $ number ] ; }
Lookahead token n .
1,939
protected function scanEOS ( ) { if ( ! $ this -> length ( ) ) { if ( count ( $ this -> indentStack ) ) { array_shift ( $ this -> indentStack ) ; return $ this -> token ( 'outdent' ) ; } return $ this -> token ( 'eos' ) ; } }
Scan EOS from input & return it if found .
1,940
protected function scanComment ( ) { if ( preg_match ( '/^ *\/\/(-)?([^\n]*)/' , $ this -> input , $ matches ) ) { $ this -> consume ( $ matches [ 0 ] ) ; $ token = $ this -> token ( 'comment' , isset ( $ matches [ 2 ] ) ? $ matches [ 2 ] : '' ) ; $ token -> buffer = '-' !== $ matches [ 1 ] ; return $ token ; } }
Scan comment from input & return it if found .
1,941
public static function isConstraintsValidationEnabled ( $ objectClasses , $ annotationReader ) { $ enabled = Configuration :: isConstraintsValidationEnabled ( ) ; foreach ( $ objectClasses as $ class ) { if ( $ annotationReader -> getClassAnnotation ( $ class , self :: $ disableConstraintsValidationAnnotationClass ) !=...
Indicates wether the constraints validation is enabled or not for the given object .
1,942
public static function validatePropertyValue ( $ object , $ property , $ value ) { return Configuration :: getConstraintsValidator ( ) -> validatePropertyValue ( $ object , $ property , $ value ) ; }
Validates the given value compared to given property constraints . If the value is valid a call to count to the object returned by this method should give 0 .
1,943
protected function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ this -> Content = str_replace ( '&#13;' , '' , $ this -> Content ) ; $ formatter = $ this -> getFormatter ( ) ; $ formatter -> analyseSavedContent ( $ this ) ; if ( ! $ this -> WikiLockExpiry ) { $ this -> WikiLockExpiry = date ( 'Y-m-d H:i:s' ) ; }...
Before writing convert any page links to appropriate new non - published pages
1,944
public function getCMSFields ( ) { $ fields = parent :: getCMSFields ( ) ; $ options = $ this -> getEditorTypeOptions ( ) ; $ fields -> addFieldToTab ( 'Root.Behaviour' , new OptionsetField ( 'EditorType' , _t ( 'WikiPage.EDITORTYPE' , 'Editor Type' ) , $ options ) ) ; $ formatter = $ this -> getFormatter ( ) ; if ( $ ...
Get the CMS fields
1,945
public function getActualEditorType ( ) { if ( $ this -> EditorType && $ this -> EditorType != 'Inherit' ) { return $ this -> EditorType ; } $ parent = $ this -> getParent ( ) ; $ editorType = 'Wiki' ; while ( $ parent != null && $ parent instanceof WikiPage ) { if ( $ parent -> EditorType && $ parent -> EditorType != ...
Return the editor type to use for this item . Will interrogate parents if needbe
1,946
public function getFormatter ( $ formatter = null ) { if ( ! $ formatter ) { $ formatter = $ this -> getActualEditorType ( ) ; } if ( ! isset ( self :: $ registered_formatters [ $ formatter ] ) ) { throw new Exception ( "Formatter $formatter does not exist" ) ; } return self :: $ registered_formatters [ $ formatter ] ;...
Gets the formatter for a given type . If none specified gets the current formatter
1,947
public function ParsedContent ( ) { $ formatter = $ this -> getFormatter ( ) ; $ content = $ formatter -> formatContent ( $ this ) ; if ( self :: $ purify_output ) { include_once SIMPLEWIKI_DIR . '/thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier.auto.php' ; $ purifier = new HTMLPurifier ( ) ; $ content = $ puri...
Retrieves the page s content passed through any necessary parsing eg Wiki based content
1,948
public function getWikiRoot ( ) { $ current = $ this ; $ parent = $ current -> Parent ( ) ; while ( $ parent instanceof WikiPage ) { $ current = $ parent ; $ parent = $ current -> Parent ( ) ; } return $ current ; }
Get the root of the wiki that this wiki page exists in
1,949
public function lock ( $ member = null ) { if ( ! $ member ) { $ member = Member :: currentUser ( ) ; } $ this -> WikiLastEditor = $ member -> Email ; $ this -> WikiLockExpiry = date ( 'Y-m-d H:i:s' , time ( ) + $ this -> config ( ) -> get ( 'lock_time' ) ) ; $ this -> write ( ) ; }
Lock the page for the current user
1,950
public function edit ( ) { HtmlEditorField :: include_js ( ) ; $ existing = $ this -> getEditingLocks ( $ this -> data ( ) , true ) ; if ( $ existing && $ existing [ 'user' ] != Member :: currentUser ( ) -> Email ) { return $ this -> redirect ( $ this -> data ( ) -> Link ( ) ) ; } if ( ! $ this -> data ( ) -> canEdit (...
Action handler for editing this wiki page
1,951
public function EditForm ( ) { $ record = DataObject :: get_by_id ( 'WikiPage' , $ this -> data ( ) -> ID ) ; $ formatter = $ record -> getFormatter ( ) ; $ editorField = $ formatter -> getEditingField ( $ record ) ; $ helpLink = $ formatter -> getHelpUrl ( ) ; $ fields = FieldList :: create ( new LiteralField ( 'Previ...
Creates the form used for editing the page s content
1,952
public function revert ( ) { if ( $ this -> data ( ) -> IsModifiedOnStage ) { $ this -> data ( ) -> doRevertToLive ( ) ; } return $ this -> redirect ( $ this -> data ( ) -> Link ( ) . '?stage=Live' ) ; }
Option for the user to revert the changes made since it was last published
1,953
public function delete ( ) { $ page = $ this -> data ( ) ; if ( $ page ) { $ parent = $ page -> Parent ( ) ; $ ID = $ page -> ID ; $ page -> deleteFromStage ( 'Live' ) ; if ( WikiPage :: $ auto_publish ) { $ page -> ID = $ ID ; $ page -> deleteFromStage ( 'Stage' ) ; } return $ this -> redirect ( $ parent -> Link ( ) )...
Deletes the current page and returns the user to the parent of the now deleted page .
1,954
public function addpage ( $ args ) { if ( ! Permission :: check ( MANAGE_WIKI_PAGES ) ) { return Security :: permissionFailure ( $ this ) ; } $ pageName = trim ( $ args [ 'NewPageName' ] ) ; $ createType = $ args [ 'CreateType' ] ? $ args [ 'CreateType' ] : 'child' ; if ( ! strlen ( $ pageName ) ) { throw new Exception...
Creates an entirely new page as a child of the current page or after a selected page .
1,955
public function save ( $ data , $ form ) { if ( ! $ this -> data ( ) -> canEdit ( ) ) { return Security :: permissionFailure ( $ this ) ; } $ existing = $ this -> getEditingLocks ( $ this -> data ( ) , true ) ; if ( $ existing && $ existing [ 'user' ] != Member :: currentUser ( ) -> Email ) { return "Someone somehow lo...
Save the submitted data
1,956
public function Form ( ) { $ append = '' ; if ( ! $ this -> form ) { if ( WikiPage :: $ show_edit_button || $ this -> data ( ) -> canEdit ( ) ) { $ this -> form = $ this -> StatusForm ( ) ; } } else { if ( Permission :: check ( MANAGE_WIKI_PAGES ) ) { $ append = $ this -> CreatePageForm ( ) -> forTemplate ( ) ; } } ret...
Return the form to the user if it exists otherwise some information about who is currently editing
1,957
public function StatusForm ( ) { $ existing = $ this -> getEditingLocks ( $ this -> data ( ) ) ; if ( $ existing && $ existing [ 'user' ] != Member :: currentUser ( ) -> Email ) { $ fields = FieldList :: create ( new ReadonlyField ( 'ExistingEditor' , '' , _t ( 'WikiPage.EXISTINGEDITOR' , 'This page is currently locked...
Gets the status form that is used by users to trigger the editing mode if they have the relevant access to it .
1,958
public function updatelock ( $ data ) { if ( $ this -> data ( ) -> ID && $ this -> data ( ) -> canEdit ( ) ) { $ lock = $ this -> getEditingLocks ( $ this -> data ( ) , true ) ; $ response = new stdClass ( ) ; $ response -> status = 1 ; if ( $ lock != null && $ lock [ 'user' ] != Member :: currentUser ( ) -> Email ) { ...
Updates the lock timeout for the given object
1,959
protected function getEditingLocks ( $ page , $ doLock = false ) { $ currentStage = Versioned :: current_stage ( ) ; Versioned :: reading_stage ( 'Stage' ) ; $ filter = array ( 'WikiPage.ID' => $ page -> ID , 'WikiLockExpiry' => date ( 'Y-m-d H:i:s' ) , ) ; $ user = Member :: currentUser ( ) ; $ currentLock = WikiPage ...
Lock the page for editing
1,960
public function objectdetails ( ) { $ response = new stdClass ; if ( isset ( $ _GET [ 'ID' ] ) ) { $ type = null ; if ( isset ( $ _GET [ 'type' ] ) ) { $ type = $ _GET [ 'type' ] == 'href' ? 'SiteTree' : 'File' ; } else { $ type = 'SiteTree' ; } $ object = DataObject :: get_by_id ( $ type , $ _GET [ 'ID' ] ) ; $ respon...
Retrieves information about a selected image for the frontend image insertion tool - hacky for now ideally need to pull through the backend ImageForm
1,961
public function setValue ( string $ rawValue ) : void { if ( strlen ( $ rawValue ) < 8 ) { throw new PasswordPolicyException ( 'Password is too short@' . __METHOD__ ) ; } $ this -> rawValue = $ rawValue ; }
Set password value .
1,962
public function verify ( string $ hash ) : bool { if ( is_null ( $ this -> rawValue ) ) { return false ; } return password_verify ( $ this -> rawValue , $ hash ) ; }
Verify password hash
1,963
public function getParameterNames ( ) { if ( isset ( $ this -> parameterNames ) ) { return $ this -> parameterNames ; } return $ this -> parameterNames = $ this -> compileParameterNames ( ) ; }
Get all of the parameter names for the route .
1,964
public function getParameter ( $ name , $ default = null ) { try { return ArrayHelper :: get ( $ this -> getParameters ( ) , $ name , $ default ) ; } catch ( Exception $ ex ) { return $ default ; } }
Get a given parameter from the route .
1,965
protected function compileRoute ( ) { $ uri = preg_replace ( '/\{(\w+?)\?\}/' , '{$1}' , $ this -> uri ) ; $ this -> compiled = ( new SymfonyRoute ( $ uri , $ optionals = [ ] , $ requirements = [ ] , [ ] , $ domain = '' ) ) -> compile ( ) ; }
Compile the current route .
1,966
protected function runCallable ( ) { $ parameters = $ this -> resolveMethodDependencies ( $ this -> getParametersWithoutNulls ( ) , new ReflectionFunction ( $ this -> action [ 'uses' ] ) ) ; $ callable = $ this -> action [ 'uses' ] ; return call_user_func_array ( $ callable , $ parameters ) ; }
Run the route action as callable and return the response .
1,967
public function getBatchSerial ( $ namespace ) { if ( empty ( $ this -> serials [ $ namespace ] ) ) { $ batch = $ this -> getBatch ( $ namespace ) ; unset ( $ batch [ 'DefinitionRev' ] ) ; $ this -> serials [ $ namespace ] = md5 ( serialize ( $ batch ) ) ; } return $ this -> serials [ $ namespace ] ; }
Returns a md5 signature of a segment of the configuration object that uniquely identifies that particular configuration
1,968
public function getSerial ( ) { if ( empty ( $ this -> serial ) ) { $ this -> serial = md5 ( serialize ( $ this -> getAll ( ) ) ) ; } return $ this -> serial ; }
Returns a md5 signature for the entire configuration object that uniquely identifies that particular configuration
1,969
public function getAll ( ) { if ( ! $ this -> finalized ) $ this -> autoFinalize ( ) ; $ ret = array ( ) ; foreach ( $ this -> plist -> squash ( ) as $ name => $ value ) { list ( $ ns , $ key ) = explode ( '.' , $ name , 2 ) ; $ ret [ $ ns ] [ $ key ] = $ value ; } return $ ret ; }
Retrieves all directives organized by namespace
1,970
public static function prepareArrayFromForm ( $ array , $ index = false , $ allowed = true , $ mq_fix = true , $ schema = null ) { if ( $ index !== false ) $ array = ( isset ( $ array [ $ index ] ) && is_array ( $ array [ $ index ] ) ) ? $ array [ $ index ] : array ( ) ; $ mq = $ mq_fix && function_exists ( 'get_magic_...
Prepares an array from a form into something usable for the more strict parts of HTMLPurifier_Config
1,971
protected function triggerError ( $ msg , $ no ) { $ backtrace = debug_backtrace ( ) ; if ( $ this -> chatty && isset ( $ backtrace [ 1 ] ) ) { $ frame = $ backtrace [ 1 ] ; $ extra = " on line {$frame['line']} in file {$frame['file']}" ; } else { $ extra = '' ; } trigger_error ( $ msg . $ extra , $ no ) ; }
Produces a nicely formatted error message by supplying the stack frame information from two levels up and OUTSIDE of HTMLPurifier_Config .
1,972
public static function send ( $ params ) { $ params = array_merge ( [ 'subject' => '' , 'view' => '' , 'body' => '' , 'bodyHtml' => '' , 'to' => [ ] , 'bcc' => [ ] , 'cc' => [ ] , 'replyTo' => [ ] , 'file' => '' , ] , $ params ) ; $ message = ( new static ( ) ) -> to ( $ params [ 'to' ] ) -> from ( $ params [ 'from' ] ...
Send message using chosen driver .
1,973
protected function build_attachment_fields ( Vulnerabilities $ vulnerabilities ) { $ fields = [ ] ; foreach ( $ vulnerabilities as $ vulnerability ) { $ fixed_in = $ vulnerability -> fixed_in ? 'Fixed in v' . $ vulnerability -> fixed_in : 'Not fixed yet' ; $ wpvdb_url = "https://wpvulndb.com/vulnerabilities/{$vulnerabi...
Generates the fields array for the message attachment .
1,974
public function query ( $ query , $ options = 0 ) { $ result = $ this -> wpdb -> get_results ( ( string ) $ query ) ; $ this -> last_affected_rows = ( int ) $ this -> wpdb -> rows_affected ; $ this -> last_insert_id = ( int ) $ this -> wpdb -> insert_id ; $ this -> last_statement = NULL ; if ( ! is_array ( $ result ) )...
Executes a plain SQL query and return the results
1,975
public function query_statement ( Statement $ statement , array $ data , $ options = 0 ) { $ query = call_user_func_array ( [ $ this -> wpdb , 'prepare' ] , array_merge ( [ ( string ) $ statement ] , $ data ) ) ; $ result = $ this -> query ( $ query ) ; $ this -> last_statement = $ statement ; return $ result ; }
Executes a Statement and return a Result
1,976
public function execute_statement ( Statement $ statement , array $ data , $ options = 0 ) { $ this -> query_statement ( $ statement , $ data , $ options ) ; return $ this -> last_affected_rows ( ) ; }
Executes a Statement and return the number of affected rows
1,977
public function last_insert_id ( Statement $ statement = NULL ) { if ( $ statement && ! $ this -> last_statement === $ statement ) return FALSE ; return $ this -> last_insert_id ; }
Returns the inserted ID of the last executed statement . If a statement is provided it should be verified that it is the same as the last executed one .
1,978
public function last_affected_rows ( Statement $ statement = NULL ) { if ( $ statement && ! $ this -> last_statement === $ statement ) return FALSE ; return $ this -> last_affected_rows ; }
Returns the number of affected rows of the last executed statement . If a statement is provided it should be verified that it is the same as the last executed one .
1,979
public function paramExists ( $ name ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } if ( strlen ( $ name ) == 1 ) { return isset ( $ this -> shortNames [ $ name ] ) ; } else { return isset ( $ this -> longNames [ $ name ] ) ; } }
checks if parameter is allowed
1,980
public function allowsValue ( $ name ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } $ longName = ( strlen ( $ name ) == 1 ? ( isset ( $ this -> shortNames [ $ name ] ) ? $ this -> shortNames [ $ name ] : '' ) : $ name ) ; if ( isset ( $ this -> longNames [ $ longName ] ) ) { return $ this -> longN...
checks if parameter allows a value if so what type
1,981
public function getValueType ( $ name ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } $ longName = ( strlen ( $ name ) == 1 ? ( isset ( $ this -> shortNames [ $ name ] ) ? $ this -> shortNames [ $ name ] : '' ) : $ name ) ; if ( isset ( $ this -> longNames [ $ longName ] [ 'parameterType' ] ) && $ ...
returns the type of value allowed
1,982
public function getShortName ( $ name ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } if ( isset ( $ this -> longNames [ $ name ] ) ) { return $ this -> longNames [ $ name ] [ 'shortName' ] ; } else { return null ; } }
retreive short name of a parameter using its long name
1,983
public function getLongName ( $ name ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } if ( isset ( $ this -> shortNames [ $ name ] ) ) { return $ this -> shortNames [ $ name ] ; } else { return null ; } }
retreive long name of a parameter using its short name
1,984
public function getDescription ( $ name ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } $ longName = ( strlen ( $ name ) == 1 ? ( isset ( $ this -> shortNames [ $ name ] ) ? $ this -> shortNames [ $ name ] : '' ) : $ name ) ; if ( isset ( $ this -> longNames [ $ longName ] ) ) { return $ this -> lo...
retreive description of a paramter
1,985
public function getUsage ( ) { if ( ! $ this -> isParsed ) { $ this -> parseDefinitions ( ) ; } $ firstCol = array ( ) ; $ longestDef = 0 ; foreach ( array_keys ( $ this -> longNames ) as $ longName ) { ob_start ( ) ; echo "--{$longName}|-{$this->getShortName($longName)}" ; if ( $ this -> allowsValue ( $ longName ) ) {...
builds a usage definition based on definition of params
1,986
protected function parseDefinitions ( ) { foreach ( $ this -> definitions as $ nameDef => $ description ) { $ nameParts = explode ( "|" , $ nameDef ) ; if ( sizeof ( $ nameParts ) !== 2 ) { throw new \ UnexpectedValueException ( "Unexpected argument name definition expecting \"longName|char\"" ) ; } $ longName = $ name...
parses the definitions
1,987
public function acquire ( ) { if ( ! $ this -> locked ) { $ this -> fp = @ fopen ( $ this -> filePath , 'a' ) ; if ( ! $ this -> fp || ! flock ( $ this -> fp , LOCK_EX | LOCK_NB ) ) { throw new LockException ( "Could not get lock on {$this->filePath}" ) ; } else { $ this -> locked = true ; } } return $ this ; }
Acquire a lock on the resource .
1,988
public function release ( ) { if ( $ this -> locked ) { flock ( $ this -> fp , LOCK_UN ) ; fclose ( $ this -> fp ) ; $ this -> fp = null ; $ this -> locked = false ; } return $ this ; }
Release the lock on the resource if we have one .
1,989
public function addKeys ( $ keys ) { foreach ( ( array ) $ keys as $ position => $ key ) { $ this -> keys [ $ position ] = $ key ; } return $ this ; }
Sets the keys for the properties Existing keys will be overridden only when necessary
1,990
public function setKey ( $ location , $ key ) { $ this -> keys [ ( integer ) $ location ] = ( string ) $ key ; return $ this ; }
Sets the key for a property
1,991
public function resetModifiers ( $ key = false ) { if ( $ key ) { unset ( $ this -> modifiers [ $ key ] ) ; } else { $ this -> modifiers = array ( ) ; } return $ this ; }
resets the modifiers
1,992
public function parse ( ) { $ lines = str_getcsv ( $ this -> source , $ this -> newline , $ this -> enclosure , $ this -> escape ) ; if ( $ this -> getSourceHasHeadline ( ) ) { $ keys = explode ( $ this -> delimiter , $ lines [ 0 ] ) ; $ this -> addKeys ( $ keys ) ; unset ( $ lines [ 0 ] ) ; } foreach ( $ lines as $ li...
main function parses the source and returns the result array
1,993
public function squash ( $ force = false ) { if ( $ this -> cache !== null && ! $ force ) return $ this -> cache ; if ( $ this -> parent ) { return $ this -> cache = array_merge ( $ this -> parent -> squash ( $ force ) , $ this -> data ) ; } else { return $ this -> cache = $ this -> data ; } }
Squashes this property list and all of its property lists into a single array and returns the array . This value is cached by default .
1,994
public function handleExit ( \ Closure $ callback ) { $ this -> append ( SIGHUP , $ callback ) ; $ this -> append ( SIGINT , $ callback ) ; $ this -> append ( SIGQUIT , $ callback ) ; $ this -> append ( SIGTERM , $ callback ) ; }
Handle application exit signals
1,995
public function append ( $ signal , Closure $ callback ) { if ( empty ( $ this -> listeners ) ) { declare ( ticks = 1 ) ; } $ this -> listeners [ $ signal ] = $ callback ; pcntl_signal ( $ signal , [ $ this , "executeListener" ] ) ; return $ this ; }
Add signal listener
1,996
public function executeListener ( $ signal , $ exit = true ) { $ return = null ; if ( isset ( $ this -> listeners [ $ signal ] ) ) { $ return = call_user_func_array ( $ this -> listeners [ $ signal ] , [ $ signal ] ) ; } if ( true === $ exit ) { posix_kill ( posix_getpid ( ) , SIGKILL ) ; } return $ return ; }
Method which is executed when a signal is received
1,997
public static function create ( $ type , $ value , $ extra = null ) { switch ( strtolower ( $ type ) ) { case 'int' : case 'integer' : return self :: createInt ( $ value ) ; case 'float' : case 'double' : return self :: createFloat ( $ value ) ; case 'string' : return self :: createString ( $ value ) ; case 'bool' : ca...
Generic type factory
1,998
public static function createInt ( $ value ) { if ( $ value instanceof NumericTypeInterface ) { return $ value -> asIntType ( ) ; } if ( ! is_numeric ( $ value ) ) { throw new \ InvalidArgumentException ( "'{$value}' is no valid numeric for IntType" ) ; } if ( self :: getRequiredType ( ) == self :: TYPE_GMP ) { return ...
Create an IntType
1,999
public static function createFloat ( $ value ) { if ( $ value instanceof NumericTypeInterface ) { return $ value -> asFloatType ( ) ; } if ( ! is_numeric ( $ value ) ) { throw new \ InvalidArgumentException ( "'{$value}' is no valid numeric for FloatType" ) ; } if ( self :: getRequiredType ( ) == self :: TYPE_GMP ) { r...
Create a FloatType