idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
24,000
public function setOrdering ( $ order ) { if ( is_array ( $ order ) ) { $ order = implode ( '' , $ order ) ; } $ this -> setParam ( 'ordering' , $ order ) ; }
Defines the order in which results should be returned .
24,001
public function getDocuments ( $ type = DOC_TYPE_SIMPLEXML ) { if ( isset ( $ this -> _simpleXml -> cursor_id ) ) return $ this -> getCursor ( $ type ) ; return parent :: getRawDocuments ( $ type ) ; }
Returns the documents from the response as an associative array where keys are document IDs and values area document contents
24,002
public function getWordCount ( $ word ) { if ( is_null ( $ this -> _localWords ) ) { $ this -> _localWords = $ this -> getRawWordCounts ( ) ; } return isset ( $ this -> _localWords [ $ word ] ) ? $ this -> _localWords [ $ word ] : 0 ; }
Gets the occurence count of a particular word from the original query
24,003
public function getIdentifierReference ( $ manager ) { if ( ! isset ( $ this -> identifierReferences [ $ manager ] ) ) { $ rule = new \ stdClass ( ) ; $ rule -> referenceField = $ this -> identifierField ; $ rule -> field = $ this -> identifierField ; return $ rule ; } return $ this -> identifierReferences [ $ manager ] ; }
Returns field idendifier given by manager . If manager not specific returns identifier field of model reference .
24,004
public function addModel ( $ field , $ modelName , array $ subFields = array ( ) , $ repository_method = null ) { $ mapping = new ModelDefinition ( $ modelName , $ field , $ subFields ) ; $ mapping -> setRepositoryMethod ( $ repository_method ) ; $ this -> fieldMappings [ $ field ] = $ mapping ; return $ mapping ; }
Map fields per model .
24,005
public function addAssociation ( $ isCollection , $ field , $ targetMultiModel , array $ compatible = array ( ) , array $ references = array ( ) ) { $ mapping = new AssociationDefinition ( $ field , $ targetMultiModel , $ isCollection ) ; $ mapping -> setCompatible ( $ compatible ) ; $ mapping -> setReferences ( $ references ) ; $ this -> associationMappings [ $ field ] = $ mapping ; return $ mapping ; }
Adding associtation mapping between multi - model .
24,006
public function getAssociationReferenceNames ( ) { $ referenceNames = array ( ) ; foreach ( $ this -> associationMappings as $ assoc ) { $ referenceNames [ ] = $ assoc -> getReferenceField ( $ this -> getManagerIdentifier ( ) ) ? : $ assoc -> getField ( ) ; } return $ referenceNames ; }
Returns list of association field per reference model .
24,007
public function getValue ( $ post_ID ) { if ( $ post_ID === self :: SITE ) return get_option ( $ this -> identifier , $ this -> default ) ; else { $ value = get_post_meta ( $ post_ID , $ this -> identifier , true ) ; return $ value === '' ? $ this -> default : $ value ; } }
Gets the value of this field for a given post
24,008
public function display ( $ post ) { echo '<div class="wrap-meta-field type-' . $ this -> getType ( ) . '">' ; $ this -> outputLabel ( ) ; $ identifier = $ post instanceof WP_Post ? $ post -> ID : $ post ; $ this -> output ( $ this -> getValue ( $ identifier ) ) ; echo '</div>' ; }
Displays the field control for a given post
24,009
public function save ( $ post_ID ) { if ( ! $ this -> doSave ( ) ) return ; if ( $ post_ID === self :: SITE ) update_option ( $ this -> identifier , $ this -> getPostValue ( ) ) ; else update_post_meta ( $ post_ID , $ this -> identifier , $ this -> getPostValue ( ) ) ; }
Saves the updated meta value to the database
24,010
public function onContentBeforeDelete ( $ context , $ data ) { if ( $ context != 'com_categories.category' ) { return true ; } if ( ! $ this -> params -> def ( 'check_categories' , 1 ) ) { return true ; } $ extension = JFactory :: getApplication ( ) -> input -> getString ( 'extension' ) ; $ result = true ; $ tableInfo = array ( 'com_content' => array ( 'table_name' => '#__content' ) , ) ; if ( isset ( $ tableInfo [ $ extension ] ) ) { $ table = $ tableInfo [ $ extension ] [ 'table_name' ] ; $ count = $ this -> _countItemsInCategory ( $ table , $ data -> get ( 'id' ) ) ; if ( $ count === false ) { $ result = false ; } else { if ( $ count > 0 ) { $ msg = JText :: sprintf ( 'COM_CATEGORIES_DELETE_NOT_ALLOWED' , $ data -> get ( 'title' ) ) . JText :: plural ( 'COM_CATEGORIES_N_ITEMS_ASSIGNED' , $ count ) ; JError :: raiseWarning ( 403 , $ msg ) ; $ result = false ; } if ( ! $ data -> isLeaf ( ) ) { $ count = $ this -> _countItemsInChildren ( $ table , $ data -> get ( 'id' ) , $ data ) ; if ( $ count === false ) { $ result = false ; } elseif ( $ count > 0 ) { $ msg = JText :: sprintf ( 'COM_CATEGORIES_DELETE_NOT_ALLOWED' , $ data -> get ( 'title' ) ) . JText :: plural ( 'COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS' , $ count ) ; JError :: raiseWarning ( 403 , $ msg ) ; $ result = false ; } } } return $ result ; } }
Don t allow categories to be deleted if they contain items or subcategories with items
24,011
private function _countItemsInCategory ( $ table , $ catid ) { $ db = JFactory :: getDbo ( ) ; $ query = $ db -> getQuery ( true ) ; $ query -> select ( 'COUNT(id)' ) -> from ( $ table ) -> where ( 'catid = ' . $ catid ) ; $ db -> setQuery ( $ query ) ; try { $ count = $ db -> loadResult ( ) ; } catch ( RuntimeException $ e ) { JError :: raiseWarning ( 500 , $ e -> getMessage ( ) ) ; return false ; } return $ count ; }
Get count of items in a category
24,012
private function _countItemsInChildren ( $ table , $ catid , $ data ) { $ db = JFactory :: getDbo ( ) ; $ childCategoryTree = $ data -> getTree ( ) ; unset ( $ childCategoryTree [ 0 ] ) ; $ childCategoryIds = array ( ) ; foreach ( $ childCategoryTree as $ node ) { $ childCategoryIds [ ] = $ node -> id ; } if ( count ( $ childCategoryIds ) ) { $ query = $ db -> getQuery ( true ) -> select ( 'COUNT(id)' ) -> from ( $ table ) -> where ( 'catid IN (' . implode ( ',' , $ childCategoryIds ) . ')' ) ; $ db -> setQuery ( $ query ) ; try { $ count = $ db -> loadResult ( ) ; } catch ( RuntimeException $ e ) { JError :: raiseWarning ( 500 , $ e -> getMessage ( ) ) ; return false ; } return $ count ; } else { return 0 ; } }
Get count of items in a category s child categories
24,013
public function add ( $ name , RouteInterface $ route ) { $ this -> routes [ ( string ) $ name ] = $ route ; return $ this ; }
Adds the route .
24,014
public function remove ( $ name ) { if ( isset ( $ this -> routes [ $ name ] ) ) { unset ( $ this -> routes [ $ name ] ) ; } return $ this ; }
Removes the route .
24,015
public function get ( $ name ) { if ( ! isset ( $ this -> routes [ $ name ] ) ) { throw new InvalidArgumentException ( sprintf ( 'The route with given name "%s" not exists.' , $ name ) ) ; } return $ this -> routes [ $ name ] ; }
Gets the route .
24,016
public function merge ( RouterInterface $ source = null ) { if ( null == $ source ) { return [ $ this -> routes , $ this -> defaultParams , ] ; } list ( $ routes , $ params ) = $ source -> merge ( ) ; $ this -> routes = array_merge ( $ this -> routes , $ routes ) ; $ this -> defaultParams = array_merge ( $ this -> defaultParams , $ params ) ; }
Merges with other router .
24,017
protected function _retrieveAll ( string $ internally , string $ graphql , string $ class ) : array { if ( isset ( $ this -> $ internally ) ) { return $ this -> $ internally ; } $ sought = $ this -> def [ $ graphql ] ; if ( ! is_array ( $ sought ) ) { $ this -> $ internally = [ ] ; return [ ] ; } $ class = "\\" . __NAMESPACE__ . "\\" . $ class ; foreach ( $ sought as $ s ) { $ this -> $ internally [ ] = new $ class ( $ s ) ; } return $ this -> $ internally ; }
A helper method to retrieve an array of a specific type from the given GraphQL definition .
24,018
protected function _retrieveOne ( string $ internally , string $ graphql , string $ class , int $ n ) { if ( isset ( $ this -> $ internally [ $ n ] ) ) { return $ this -> $ internally [ $ n ] ; } if ( isset ( $ this -> def [ $ graphql ] [ $ n ] ) ) { $ class = "\\" . __NAMESPACE__ . "\\" . $ class ; return new $ class ( $ this -> def [ $ graphql ] [ $ n ] ) ; } return new $ class ( ) ; }
A helper method to retrieve a single object of a specific type at given position from the given GraphQL definition .
24,019
public function scopeSearch ( $ query , $ keyword ) { $ columns = $ this -> searchColumns ( ) ; foreach ( $ columns as $ column ) { if ( $ columns === reset ( $ columns ) ) { $ query -> where ( $ column , 'like' , "%{$keyword}%" ) ; } $ query -> orWhere ( $ column , 'like' , "%{$keyword}%" ) ; } return $ query ; }
Scope a query to search for a keyword .
24,020
public static function parse ( $ p_string , $ p_data = array ( ) , $ p_regex = null ) { if ( ! is_array ( $ p_data ) ) { if ( is_object ( $ p_data ) && method_exists ( $ p_data , '__toArray' ) ) { $ datas = $ p_data -> __toArray ( ) ; } } else { $ datas = $ p_data ; } if ( $ p_regex === null ) { $ p_regex = self :: REGEX_PARAM_PLACEHOLDER ; } if ( 0 < preg_match_all ( $ p_regex , $ p_string , $ matches , PREG_SET_ORDER ) ) { foreach ( $ matches as $ match ) { $ replace = '' ; if ( array_key_exists ( $ match [ 1 ] , $ datas ) ) { $ replace = $ datas [ $ match [ 1 ] ] ; } $ p_string = str_replace ( $ match [ 0 ] , $ replace , $ p_string ) ; } return self :: parse ( $ p_string , $ datas , $ p_regex ) ; } return $ p_string ; }
Parse et remplace suivant les marqueur
24,021
public static function toCamelCase ( $ p_str , $ p_first = false , $ p_glue = '_' ) { if ( trim ( $ p_str ) == '' ) { return $ p_str ; } if ( $ p_first ) { $ p_str [ 0 ] = strtoupper ( $ p_str [ 0 ] ) ; } return preg_replace_callback ( "|{$p_glue}([a-z])|" , function ( $ matches ) use ( $ p_glue ) { return str_replace ( $ p_glue , '' , strtoupper ( $ matches [ 0 ] ) ) ; } , $ p_str ) ; }
Conversion en CamelCase
24,022
public static function removeComments ( $ output ) { $ lines = explode ( "\n" , $ output ) ; $ output = "" ; $ linecount = count ( $ lines ) ; $ in_comment = false ; for ( $ i = 0 ; $ i < $ linecount ; $ i ++ ) { if ( preg_match ( "/^\/\*/" , $ lines [ $ i ] ) ) { $ in_comment = true ; } if ( ! $ in_comment ) { $ output .= $ lines [ $ i ] . "\n" ; } if ( preg_match ( "/\*\/$/" , $ lines [ $ i ] ) ) { $ in_comment = false ; } } unset ( $ lines ) ; return $ output ; }
Remove comments from string
24,023
public static function jsonToList ( $ p_json ) { $ str = '' ; $ arr = json_decode ( $ p_json , true ) ; foreach ( $ arr as $ key => $ value ) { if ( $ str == '' ) { $ str = $ str . $ key . '=' . $ value ; } else { $ str = $ str . ', ' . $ key . '=' . $ value ; } } return $ str ; }
Transforme un json en liste
24,024
public static function hidePart ( $ p_string , $ p_replace = 'X' , $ p_left = 4 , $ p_right = 4 ) { $ len = strlen ( $ p_string ) ; $ str = substr ( $ p_string , 0 , $ p_left ) . str_pad ( '' , $ len - $ p_left - $ p_right , $ p_replace ) . substr ( $ p_string , $ len - $ p_right ) ; return $ str ; }
Hide part of string with a caracter
24,025
public function run ( $ require = false ) { foreach ( $ this -> const as $ name => $ val ) define ( self :: nameEncode ( $ name , self :: NAMESPACE_SEPERATOR ) , self :: encode ( $ val ) ) ; foreach ( $ this -> ini as $ name => $ val ) ini_set ( self :: nameEncode ( $ name , self :: INI_SEPERATOR ) , self :: encode ( $ val ) ) ; $ GLOBALS [ "constants" ] = $ this -> public ; if ( $ require ) foreach ( $ this -> require as $ file ) require $ file ; }
Adds the constants for the current app
24,026
public function prepareForConsoleCommand ( ) { $ this -> withFacades ( ) ; $ this -> make ( 'cache' ) ; $ this -> make ( 'queue' ) ; $ this -> configure ( 'database' ) ; $ this -> register ( 'Illuminate\Queue\ConsoleServiceProvider' ) ; }
Prepare the application to execute a console command . Removed migration and seeding providers
24,027
public function pop ( ) { if ( isset ( $ this -> input [ $ this -> pos ] ) ) { return $ this -> input [ $ this -> pos ++ ] ; } return null ; }
Return the current element and advance the sequence position .
24,028
public function createRepository ( $ model , $ config ) { $ defaults = [ 'type' => 'db-soft' , 'key' => 'id' , 'deleted' => 'deleted' ] ; $ config = array_merge ( $ defaults , $ config ) ; switch ( $ config [ 'type' ] ) { case 'db' : $ repo = new DbRepository ( $ config [ 'db' ] , $ config [ 'table' ] , $ model , $ config [ 'key' ] ) ; break ; case 'db-soft' : $ repo = new SoftDbRepository ( $ config [ 'db' ] , $ config [ 'table' ] , $ model , $ config [ 'deleted' ] , $ config [ 'key' ] ) ; break ; default : throw new RepositoryException ( "Repository type '" . $ config [ 'type' ] . "' not implemented" ) ; } $ this -> addRepository ( $ repo ) ; return $ repo ; }
Create a new repository and add it to the manager .
24,029
public function addRepository ( $ repository ) { $ class = $ repository -> getModelClass ( ) ; if ( $ this -> getByClass ( $ class ) ) { throw new RepositoryException ( "The manager already contains a repository for the model class '$class'" ) ; } $ repository -> setManager ( $ this ) ; $ this -> repositories [ $ class ] = $ repository ; }
Register a repository with the manager .
24,030
public function getCustomByName ( $ name = null ) { if ( $ name === null ) { return $ this -> _customByName ; } else { if ( array_key_exists ( $ name , $ this -> customByName ) ) { return $ this -> _customByName [ $ name ] ; } else { return null ; } } }
Gets a single row element contained by this list entry using its name .
24,031
public function setCustom ( $ custom ) { $ this -> _custom = array ( ) ; foreach ( $ custom as $ c ) { $ this -> addCustom ( $ c ) ; } return $ this ; }
Sets the row elements contained by this list entry . If any custom row elements were previously stored they will be overwritten .
24,032
public function addCustom ( $ custom ) { $ this -> _custom [ ] = $ custom ; $ this -> _customByName [ $ custom -> getColumnName ( ) ] = $ custom ; return $ this ; }
Add an individual custom row element to this list entry .
24,033
public function removeCustom ( $ index ) { if ( array_key_exists ( $ index , $ this -> _custom ) ) { $ element = $ this -> _custom [ $ index ] ; unset ( $ this -> _custom [ $ index ] ) ; $ this -> _custom = array_values ( $ this -> _custom ) ; $ key = array_search ( $ element , $ this -> _customByName ) ; unset ( $ this -> _customByName [ $ key ] ) ; } else { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Element does not exist.' ) ; } return $ this ; }
Remove an individual row element from this list entry by index . This will cause the array to be re - indexed .
24,034
public function removeCustomByName ( $ name ) { if ( array_key_exists ( $ name , $ this -> _customByName ) ) { $ element = $ this -> _customByName [ $ name ] ; unset ( $ this -> _customByName [ $ name ] ) ; $ key = array_search ( $ element , $ this -> _custom ) ; unset ( $ this -> _custom [ $ key ] ) ; } else { require_once 'Zend/Gdata/App/InvalidArgumentException.php' ; throw new Zend_Gdata_App_InvalidArgumentException ( 'Element does not exist.' ) ; } return $ this ; }
Remove an individual row element from this list entry by name .
24,035
public function embedJs ( $ src , $ opts = array ( ) , $ in_admin = false ) { $ js = new Script ( $ src , $ opts , $ in_admin ) ; if ( $ js -> getInAdmin ( ) ) { array_push ( $ this -> scripts_admin , $ js ) ; } else { array_push ( $ this -> scripts_frontend , $ js ) ; } }
Permite agregar un js a la pila de scripts para ser cargado en el punto espesificado
24,036
public function embedCss ( $ src , $ opts = array ( ) , $ in_admin = false ) { $ css = new Style ( $ src , $ opts , $ in_admin ) ; if ( $ css -> getInAdmin ( ) ) { array_push ( $ this -> styles_admin , $ css ) ; } else { array_push ( $ this -> styles_frontend , $ css ) ; } }
Permite agregar un css a la pila de styles para ser cargado en el punto espesificado
24,037
protected function get_plugin_name ( ) { $ path = $ this -> get_path ( ) ; $ array = explode ( '/' , $ path ) ; unset ( $ array [ count ( $ array ) - 1 ] ) ; unset ( $ array [ count ( $ array ) - 1 ] ) ; return end ( $ array ) . '/' . DIRECTORY_APP_NAME ; }
get folder name of plugin builder_complex_app
24,038
public function boot ( ) { $ this -> emitter = new Emitter ; $ this -> query = new QueryRepository ( ) ; $ this -> add_actions ( ) ; add_action ( 'cmb2_admin_init' , array ( $ this , 'add_metaboxes' ) , 1000 ) ; }
Boot class Inicializa el plugin
24,039
public function add_metaboxes ( ) { $ methos = $ this -> getMethods ( "/^metabox_/" ) ; sort ( $ methos ) ; if ( $ methos ) { foreach ( $ methos as $ metabox ) { call_user_func ( array ( $ this , $ metabox ) ) ; } } }
Registra y encola todos los metabox para los metodos definidos
24,040
protected function add_actions ( ) { do_action ( 'app_before_actions' ) ; $ actionMethos = $ this -> getMethods ( "/^action_/" ) ; sort ( $ actionMethos ) ; $ actions = array_map ( array ( $ this , 'describeActions' ) , $ actionMethos ) ; if ( $ actions ) { foreach ( $ actions as $ action ) { add_action ( $ action -> tag , array ( $ this , $ action -> method ) , $ act -> priority , 1 ) ; } do_action ( 'app_after_textdomain' ) ; } }
Registra las acciones para los metodos definidos en el plugin
24,041
private function getMethods ( $ pattern = "/^action_/" ) { $ methos = get_class_methods ( $ this -> class ) ; $ actions = array ( ) ; foreach ( $ methos as $ methodName ) { if ( preg_match ( $ pattern , $ methodName ) ) { array_push ( $ actions , $ methodName ) ; } } return $ actions ; }
Obtiene un array con las acciones que se encuentras definidas en la clase del plugin
24,042
private function describeActions ( $ action = "" ) { if ( ! empty ( $ action ) ) { $ parts = explode ( '_' , $ action ) ; unset ( $ parts [ 0 ] ) ; $ parts = array_values ( $ parts ) ; $ act = new \ stdClass ( ) ; $ act -> method = $ action ; switch ( count ( $ parts ) ) { case 1 : case 2 : case 3 : $ act -> name = $ parts [ 0 ] ; case 2 : case 3 : $ act -> tag = $ parts [ 1 ] ; case 3 : $ act -> priority = intval ( $ parts [ 2 ] ) ; break ; } if ( count ( $ parts ) == 1 ) { $ act -> tag = 'initi' ; $ act -> priority = 10 ; } return $ act ; } return null ; }
Descrive una accion para el nombre del metodo de la accion resibido
24,043
public function writeHex ( string $ value ) : self { $ this -> bytes .= Writer :: high ( $ value , strlen ( $ value ) ) ; return $ this ; }
Write the given hex value as binary with a high nibble .
24,044
protected function getDefault ( int $ type = Variables :: TYPE_STRING ) { switch ( $ type ) { case Variables :: TYPE_INT : $ value = ( int ) 0 ; break ; case Variables :: TYPE_FLOAT : $ value = ( float ) 0 ; break ; case Variables :: TYPE_STRING : $ value = '' ; break ; case Variables :: TYPE_ARRAY : $ value = [ ] ; break ; case Variables :: TYPE_JSON_DECODED : $ value = '' ; break ; case Variables :: TYPE_AUTO : $ value = '' ; break ; default : throw new DomainException ( 'Invalid variable type specified' ) ; break ; } return $ value ; }
Returns default value for specified type
24,045
protected function cast ( $ value = null , int $ type = Variables :: TYPE_STRING ) { if ( $ value === null ) { return $ this -> getDefault ( $ type ) ; } switch ( $ type ) { case Variables :: TYPE_INT : $ value = @ \ intval ( $ value ) ; break ; case Variables :: TYPE_FLOAT : $ value = @ \ floatval ( $ value ) ; break ; case Variables :: TYPE_STRING : $ value = @ \ strval ( $ value ) ; break ; case Variables :: TYPE_ARRAY : $ value = ( array ) $ value ; break ; case Variables :: TYPE_JSON_DECODED : $ value = @ \ json_decode ( @ \ strval ( $ value ) , true , 512 ) ? : '' ; break ; case Variables :: TYPE_AUTO : break ; default : throw new DomainException ( 'Invalid variable type specified' ) ; break ; } return $ value ; }
Method casting value to specified type . If provided value is null then default value for specified type will be returned .
24,046
protected function _setLineNumber ( $ lineNumber ) { if ( $ lineNumber !== null ) { try { $ lineNumber = $ this -> _normalizeInt ( $ lineNumber ) ; } catch ( RootException $ e ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid line number' ) , null , $ e , $ lineNumber ) ; } if ( $ lineNumber < 1 ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Line number must be positive' ) , null , null , $ lineNumber ) ; } } $ this -> lineNumber = $ lineNumber ; }
Assigns a line number to this instance .
24,047
public static function get ( array $ nested , $ key , $ delimiter = '.' ) { if ( is_null ( $ key ) ) return $ nested ; if ( isset ( $ nested [ $ key ] ) ) return $ nested [ $ key ] ; foreach ( explode ( $ delimiter , $ key ) as $ segment ) { if ( ! is_array ( $ nested ) || ! array_key_exists ( $ segment , $ nested ) ) { return ; } $ nested = $ nested [ $ segment ] ; } return $ nested ; }
Get a key from a nested array . Query a deeply nested array with property . child . name
24,048
public function getServerParam ( $ name , $ default = null ) { if ( isset ( $ this -> serverParams [ $ name ] ) ) { return $ this -> serverParams [ $ name ] ; } return $ default ; }
Gets the server parameter .
24,049
public function getCookieParam ( $ name , $ default = null ) { if ( isset ( $ this -> cookieParams [ $ name ] ) ) { return $ this -> cookieParams [ $ name ] ; } return $ default ; }
Gets the cookie parameter .
24,050
public function getQueryParam ( $ name , $ default = null ) { if ( isset ( $ this -> queryParams [ $ name ] ) ) { return $ this -> queryParams [ $ name ] ; } return $ default ; }
Gets the query parameter .
24,051
protected function setParsedBody ( $ data ) { if ( ! is_null ( $ data ) && ! is_array ( $ data ) && ! is_object ( $ data ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid parsed body provided; must be an null, or array, ' . 'or object, "%s" provided.' , gettype ( $ data ) ) ) ; } $ this -> parsedBody = $ data ; return $ this ; }
Sets the parsed body .
24,052
public static function log ( ... $ data ) { $ filename = static :: options ( 'root' ) . '/storage/log/access' ; if ( is_array ( $ data ) && count ( $ data ) === 1 ) { $ data = $ data [ 0 ] ; } return File :: write ( $ filename , $ data , true ) ; }
Create a file with data to be analysed
24,053
public function pipe ( Middleware $ middleware , string $ alias = '' ) : App { $ alias = $ alias ? $ alias : $ middleware -> alias ( ) ; if ( isset ( $ this -> pipe [ $ alias ] ) ) { throw new SimplesAlreadyRegisteredError ( "The middleware `{$alias}` is already registered" ) ; } $ this -> pipe [ $ alias ] = $ middleware ; return $ this ; }
Add middleware s to pipe
24,054
public function pipes ( array $ middlewares ) : App { foreach ( $ middlewares as $ key => $ middleware ) { if ( is_numeric ( $ key ) ) { $ this -> pipe ( $ middleware ) ; continue ; } $ this -> pipe ( $ middleware , $ key ) ; } return $ this ; }
Add a list of middlewares to pipe
24,055
protected function setError ( $ error ) { if ( ! is_int ( $ error ) || 0 > $ error || 8 < $ error ) { throw new InvalidArgumentException ( 'Invalid error status provided; must be an UPLOAD_ERR_* constant.' ) ; } $ this -> error = $ error ; }
Sets the error .
24,056
protected function getConfig ( $ name ) { $ config = $ this -> app [ 'config' ] [ 'picture' ] ; $ driverConfig = isset ( $ config [ 'disks' ] [ $ name ] ) ? $ config [ 'disks' ] [ $ name ] : [ ] ; if ( ! isset ( $ driverConfig [ 'sizeList' ] ) ) { $ driverConfig [ 'sizeList' ] = $ config [ 'sizeList' ] ; } if ( ! isset ( $ driverConfig [ 'quality' ] ) ) { $ driverConfig [ 'quality' ] = $ config [ 'quality' ] ; } return $ driverConfig ; }
Get configuration .
24,057
public static function create ( $ handler , $ xml ) { switch ( $ handler ) { case 'Search' : return new SearchResponseHandler ( $ xml ) ; case 'FullSearch' : return new FullSearchResponseHandler ( $ xml ) ; case 'ShowInfo' : return new ShowInfoResponseHandler ( $ xml ) ; case 'EpisodeList' : return new EpisodeListResponseHandler ( $ xml ) ; case 'EpisodeInfo' : return new EpisodeInfoResponseHandler ( $ xml ) ; default : throw new InvalidHandlerException ( 'Unknown handler ' . $ handler ) ; } }
Creates an instance of ResponseHandler
24,058
public function registerModules ( $ modules = [ ] ) { for ( $ i = 0 ; $ i < sizeof ( $ modules ) ; $ i ++ ) { $ moduleName = $ modules [ $ i ] ; $ module = $ this -> createNew ( $ moduleName ) ; if ( ! $ module instanceof ModuleInterface ) { throw new InvalidModuleException ( 'The module at position ' . ( $ i + 1 ) . ' is invalid' ) ; } $ serviceProvider = $ module -> getServiceProvider ( ) ; $ this -> getContainer ( ) -> registerServices ( $ serviceProvider ) ; } }
Register some modules
24,059
public function Stash ( ) { $ this -> DeliveryType ( DELIVERY_TYPE_BOOL ) ; $ this -> DeliveryMethod ( DELIVERY_METHOD_JSON ) ; $ Name = TrueStripSlashes ( GetValue ( 'Name' , $ _POST , '' ) ) ; $ Value = TrueStripSlashes ( GetValue ( 'Value' , $ _POST , '' ) ) ; $ Response = Gdn :: Session ( ) -> Stash ( $ Name , $ Value ) ; if ( $ Name != '' && $ Value == '' ) $ this -> SetJson ( 'Unstash' , $ Response ) ; $ this -> Render ( ) ; }
Stash a value in the user s session or unstash it if no value was provided to stash .
24,060
public function persist ( Response $ response ) { $ trackingParameters = $ this -> trackingParameters -> all ( ) ; foreach ( $ trackingParameters as $ trackingParameter => $ value ) { if ( ( null !== $ value ) && ( true === in_array ( $ trackingParameter , $ this -> cookiesToSave ) ) ) { $ response -> headers -> setCookie ( new Cookie ( $ trackingParameter , $ value , new \ DateTime ( '+1 year' ) , '/' , null , false , false ) ) ; } } return $ response ; }
Persists tracking parameters in cookies .
24,061
public function getInitUrl ( ) { $ host = Maestrano :: with ( $ this -> _preset ) -> param ( 'app.host' ) ; $ path = $ this -> getInitPath ( ) ; return "${host}${path}" ; }
Return where the app should redirect internally to initiate SSO request
24,062
public function getConsumeUrl ( ) { $ host = Maestrano :: with ( $ this -> _preset ) -> param ( 'app.host' ) ; $ path = $ this -> getConsumePath ( ) ; return "${host}${path}" ; }
The URL where the SSO response will be posted and consumed .
24,063
public function getIdpUrl ( ) { $ host = Maestrano :: with ( $ this -> _preset ) -> param ( 'sso.idp' ) ; $ api_base = Maestrano :: with ( $ this -> _preset ) -> param ( 'api.base' ) ; $ endpoint = 'auth/saml' ; return "${host}${api_base}${endpoint}" ; }
Maestrano Single Sign - On processing URL
24,064
public function getSessionCheckUrl ( $ user_id , $ sso_session ) { $ host = Maestrano :: with ( $ this -> _preset ) -> param ( 'sso.idp' ) ; $ api_base = Maestrano :: with ( $ this -> _preset ) -> param ( 'api.base' ) ; $ endpoint = 'auth/saml' ; return "${host}${api_base}${endpoint}/${user_id}?session=${sso_session}" ; }
The Maestrano endpoint in charge of providing session information
24,065
public function getSamlSettings ( ) { $ settings = new Maestrano_Saml_Settings ( ) ; $ settings -> idpPublicCertificate = Maestrano :: with ( $ this -> _preset ) -> param ( 'sso.x509_certificate' ) ; $ settings -> spIssuer = Maestrano :: with ( $ this -> _preset ) -> param ( 'api.id' ) ; $ settings -> idpSingleSignOnUrl = $ this -> getIdpUrl ( ) ; $ settings -> spReturnUrl = $ this -> getConsumeUrl ( ) ; return $ settings ; }
Return a settings object for php - saml
24,066
protected function log ( $ query , $ parameters , $ startTimestamp , $ exception = null ) { $ endTimestamp = time ( ) ; $ duration = $ endTimestamp - $ startTimestamp ; $ user = \ Phramework \ Phramework :: getUser ( ) ; $ user_id = ( $ user ? $ user -> id : null ) ; list ( $ URI ) = \ Phramework \ URIStrategy \ URITemplate :: URI ( ) ; $ method = \ Phramework \ Phramework :: getMethod ( ) ; $ debugBacktrace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; $ adapterFunction = $ debugBacktrace [ 1 ] [ 'function' ] ; array_splice ( $ debugBacktrace , 0 , 2 ) ; foreach ( $ debugBacktrace as $ k => & $ v ) { if ( isset ( $ v [ 'class' ] ) ) { $ class = $ v [ 'class' ] ; $ function = $ v [ 'function' ] ; if ( property_exists ( $ this -> matrix , $ class ) ) { $ matrixEntry = $ this -> matrix -> { $ class } ; if ( is_object ( $ matrixEntry ) || is_array ( $ matrixEntry ) ) { if ( is_array ( $ matrixEntry ) ) { $ matrixEntry = ( object ) $ matrixEntry ; } if ( property_exists ( $ matrixEntry , $ function ) ) { if ( ! $ matrixEntry -> { $ function } ) { return self :: LOG_INGORED ; } } } else { if ( ! $ matrixEntry ) { return self :: LOG_INGORED ; } } } $ v = $ v [ 'class' ] . '::' . $ v [ 'function' ] ; } else { $ v = $ v [ 'function' ] ; } } $ schemaTable = ( $ this -> schema ? '"' . $ this -> schema . '"."' . $ this -> table . '"' : '"' . $ this -> table . '"' ) ; return $ this -> logAdapter -> execute ( 'INSERT INTO ' . $ schemaTable . '( "request_id", "query", "parameters", "start_timestamp", "duration", "function", "URI", "method", "additional_parameters", "call_trace", "user_id", "exception" ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' , [ \ Phramework \ Phramework :: getRequestUUID ( ) , $ query , ( $ parameters ? json_encode ( $ parameters ) : null ) , $ startTimestamp , $ duration , $ adapterFunction , $ URI , $ method , ( $ this -> additionalParameters ? json_encode ( $ this -> additionalParameters ) : null ) , json_encode ( $ debugBacktrace ) , $ user_id , ( $ exception ? serialize ( QueryLog :: flattenExceptionBacktrace ( $ exception ) ) : null ) ] ) ; }
Log query to database
24,067
public function serverSelect ( $ sid , $ virtual = null ) { if ( $ this -> whoami !== null && $ this -> serverSelectedId ( ) == $ sid ) return ; $ virtual = ( $ virtual !== null ) ? $ virtual : $ this -> start_offline_virtual ; $ getargs = func_get_args ( ) ; $ this -> execute ( "use" , array ( "sid" => $ sid , $ virtual ? "-virtual" : null ) ) ; if ( $ sid != 0 && $ this -> predefined_query_name !== null ) { $ this -> execute ( "clientupdate" , array ( "client_nickname" => ( string ) $ this -> predefined_query_name ) ) ; } $ this -> whoamiReset ( ) ; $ this -> setStorage ( "_server_use" , array ( __FUNCTION__ , $ getargs ) ) ; TeamSpeak3_Helper_Signal :: getInstance ( ) -> emit ( "notifyServerselected" , $ this ) ; }
Selects a virtual server by ID to allow further interaction .
24,068
public function serverSelectByPort ( $ port , $ virtual = null ) { if ( $ this -> whoami !== null && $ this -> serverSelectedPort ( ) == $ port ) return ; $ virtual = ( $ virtual !== null ) ? $ virtual : $ this -> start_offline_virtual ; $ getargs = func_get_args ( ) ; $ this -> execute ( "use" , array ( "port" => $ port , $ virtual ? "-virtual" : null ) ) ; if ( $ port != 0 && $ this -> predefined_query_name !== null ) { $ this -> execute ( "clientupdate" , array ( "client_nickname" => ( string ) $ this -> predefined_query_name ) ) ; } $ this -> whoamiReset ( ) ; $ this -> setStorage ( "_server_use" , array ( __FUNCTION__ , $ getargs ) ) ; TeamSpeak3_Helper_Signal :: getInstance ( ) -> emit ( "notifyServerselected" , $ this ) ; }
Selects a virtual server by UDP port to allow further interaction .
24,069
public function ngettext ( $ singular , $ plural , $ count ) { $ domain = $ this -> getDefaultDomain ( ) ; return $ this -> dngettext ( $ domain , $ singular , $ plural , $ count ) ; }
Plural version of gettext . Some languages have more than one form for plural messages dependent on the count .
24,070
public function npgettext ( $ context , $ singular , $ plural , $ count ) { $ domain = $ this -> getDefaultDomain ( ) ; return $ this -> dnpgettext ( $ domain , $ context , $ singular , $ plural , $ count ) ; }
Plural version of pgettext . Some languages have more than one form for plural messages dependent on the count .
24,071
public static function inEnum ( $ value ) { $ allItems = array_flip ( self :: toArray ( ) ) ; return isset ( $ allItems [ $ value ] ) ? true : false ; }
Check if a value is in enum
24,072
public static function resetView ( ModeBasedUrlProvider $ urlProvider ) { $ redirectHeader = 'Location: ' . $ urlProvider -> getModeUrl ( self :: MODE_DEFAULT ) ; header ( $ redirectHeader ) ; exit ; }
Redirect to the default view
24,073
public function renderLog ( ) { $ output = '' ; foreach ( $ this -> log as $ message ) $ output .= $ message -> render ( ) ; return $ output ; }
Gets the HTML markup to display of all consecutive log messages
24,074
protected function addActions ( ) { add_action ( Hooks :: ADMIN_MENU , array ( $ this , 'addPage' ) ) ; if ( $ this -> currentlyOnPage ( ) ) { add_action ( Hooks :: ADMIN_INIT , [ $ this , 'adminInit' ] ) ; } }
Sets up the WP hooks
24,075
private function doUserFunc ( $ getMode ) { if ( ( $ activeMode = $ this -> getActiveMode ( ) ) !== null && ( $ userFunc = call_user_func ( $ getMode , $ activeMode ) ) !== null ) { call_user_func ( $ userFunc , $ activeMode ) ; } }
Performs a user func on the active mode
24,076
public function removeMode ( $ mode ) { if ( $ mode instanceof AdminPageMode ) $ mode = $ mode -> getSlug ( ) ; unset ( $ this -> modes [ $ mode ] ) ; }
Removes a display mode
24,077
public function onMessage ( ConnectionInterface $ from , $ message ) { $ message = json_decode ( $ message ) ; $ channel = $ message -> message -> channel ; if ( $ message -> event == 'subscribe' ) { $ this -> subscribedTopics [ $ channel ] [ ] = $ from ; } }
Client - side message from Echo
24,078
public function onEntry ( $ entry ) { if ( is_array ( $ entry ) ) { $ channel = $ entry [ 0 ] ; $ entry = json_decode ( $ entry [ 1 ] , true ) ; $ entry [ 'channel' ] = $ channel ; $ entry = json_encode ( $ entry ) ; } if ( ! $ channel || ! array_key_exists ( $ channel , $ this -> subscribedTopics ) ) { return ; } if ( starts_with ( $ channel , 'private-' ) ) { $ subs = $ this -> subscribedTopics [ $ channel ] ; foreach ( $ subs as $ to ) { $ this -> send ( $ to , $ entry ) ; } } else { $ this -> sendAll ( $ entry ) ; } }
Server - side message from ZMQ
24,079
public function postPostalAddress ( Request $ request ) { $ this -> validates ( $ request -> all ( ) , [ 'name' => 'required' , 'street1' => 'required' , 'city' => 'required' , 'county' => 'required' , 'postcode' => 'required' , 'country' => 'required' , ] ) ; $ pa = new PostalAddress ; $ pa -> name = $ request -> input ( 'name' ) ; $ pa -> street1 = $ request -> input ( 'street1' ) ; $ pa -> street2 = $ request -> input ( 'street2' ) ; $ pa -> city = $ request -> input ( 'city' ) ; $ pa -> county = $ request -> input ( 'county' ) ; $ pa -> postcode = $ request -> input ( 'postcode' ) ; $ pa -> country = $ this -> country ( $ request -> input ( 'country' ) ) [ 'alpha2' ] ; $ pa -> added = time ( ) ; $ pa -> user ( ) -> associate ( Auth :: user ( ) ) ; $ pa -> save ( ) ; return redirect ( '/account/postal-addresses' ) -> withStatus ( 'Postal address added.' ) ; }
Add a postal address .
24,080
public function postDeletePostalAddress ( Request $ request ) { $ pa = PostalAddress :: findOrFail ( $ request -> input ( 'postal_address_id' ) ) ; if ( $ pa -> user -> userId != Auth :: user ( ) -> userId ) { return redirect ( '/account/postal-addresses' ) -> withErrors ( [ "You can only delete your own postal addresses." ] ) ; } if ( $ pa -> purchases ( ) -> count ( ) ) { return redirect ( '/account/postal-addresses' ) -> withErrors ( [ "You cannot delete postal addresses that are associated with purchases." ] ) ; } $ pa -> delete ( ) ; return redirect ( '/account/postal-addresses' ) -> withStatus ( 'Postal address deleted.' ) ; }
Delete a postal address .
24,081
public function postBankDetails ( Request $ request ) { $ this -> validates ( $ request -> all ( ) , [ 'account_number' => 'required|accountnumber' , 'sort_code' => 'required|sortcode' , ] ) ; $ bank_details = Auth :: user ( ) -> bankDetails ? Auth :: user ( ) -> bankDetails : new BankDetail ; $ bank_details -> accountNumber = $ request -> input ( 'account_number' ) ; $ bank_details -> sortCode = $ request -> input ( 'sort_code' ) ; if ( ! $ bank_details -> exists ) { $ bank_details -> user ( ) -> associate ( Auth :: user ( ) ) ; } $ bank_details -> save ( ) ; Auth :: user ( ) -> sendEmail ( 'Your bank details have been changed' , 'emails.account.bank-details-changed' ) ; return redirect ( '/account/bank-details' ) -> withStatus ( 'Your bank details have been changed.' ) ; }
Add bank details .
24,082
public function clearListeners ( ) { foreach ( $ this -> listeners as $ listener ) { $ listener -> detach ( $ this -> getEventManager ( ) ) ; } $ this -> listeners = [ ] ; }
Detach an clear listeners array
24,083
public function fructifyInstall ( string $ versionContraint = '*' ) { if ( ! file_exists ( './wp-includes/version.php' ) ) { $ version = $ this -> wpResolveVersionNo ( $ versionContraint ) ; $ this -> _exec ( './vendor/bin/wp core download --version=' . $ version ) ; @ unlink ( './license.txt' ) ; @ unlink ( './readme.html' ) ; @ unlink ( './wp-config-sample.php' ) ; @ unlink ( './wp-content/plugins/hello.php' ) ; $ composer = Str :: s ( file_get_contents ( './composer.json' ) ) ; if ( ! $ composer -> contains ( 'wpackagist-plugin/akismet' ) ) { $ this -> _deleteDir ( [ './wp-content/plugins/akismet' ] ) ; } if ( ! $ composer -> contains ( 'wpackagist-theme/twentyseventeen' ) ) { $ this -> _deleteDir ( [ './wp-content/themes/twentyseventeen' ] ) ; } if ( ! $ composer -> contains ( 'wpackagist-theme/twentysixteen' ) ) { $ this -> _deleteDir ( [ './wp-content/themes/twentysixteen' ] ) ; } if ( ! $ composer -> contains ( 'wpackagist-theme/twentyfifteen' ) ) { $ this -> _deleteDir ( [ './wp-content/themes/twentyfifteen' ] ) ; } if ( ! $ composer -> contains ( 'wpackagist-theme/twentyfourteen' ) ) { $ this -> _deleteDir ( [ './wp-content/themes/twentyfourteen' ] ) ; } } }
Installs Wordpress .
24,084
public function fructifyUpdate ( string $ versionContraint = '*' ) { if ( file_exists ( './wp-includes/version.php' ) ) { require ( './wp-includes/version.php' ) ; $ installed_version = $ wp_version ; $ new_version = $ this -> wpResolveVersionNo ( $ versionContraint ) ; if ( $ installed_version == $ new_version ) return ; $ temp = sys_get_temp_dir ( ) . '/' . md5 ( microtime ( ) ) ; $ this -> _mkdir ( $ temp ) ; $ this -> _exec ( './vendor/bin/wp core download' . ' --version=' . $ installed_version . ' --path=' . $ temp ) ; $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ temp ) ; foreach ( $ finder as $ file ) { if ( file_exists ( $ file -> getRelativePathname ( ) ) ) { unlink ( $ file -> getRelativePathname ( ) ) ; } } $ this -> _deleteDir ( [ './wp-admin' , './wp-includes' , $ temp ] ) ; } $ this -> fructifyInstall ( $ versionContraint ) ; }
Updates Wordpress .
24,085
public function fructifySalts ( ) { $ this -> taskWriteToFile ( './.salts.php' ) -> line ( '<?php' ) -> text ( ( new Http ) -> request ( 'GET' , self :: $ WP_SALTS_URL ) -> getBody ( ) ) -> run ( ) ; }
Creates New Salts used for encryption by Wordpress .
24,086
public function fructifyPermissions ( ) { $ folders = [ './wp-content/uploads' ] ; foreach ( $ folders as $ folder ) { $ this -> taskFileSystemStack ( ) -> mkdir ( $ folder ) -> chmod ( $ folder , 0777 ) -> run ( ) ; } }
Sets permissions on special Wordpress folders .
24,087
private function wpResolveVersionNo ( string $ versionContraint ) { $ versionContraint = str_replace ( 'v' , '' , $ versionContraint ) ; if ( $ versionContraint == '*' ) { $ json = ( new Http ) -> request ( 'GET' , self :: $ WP_VERSION_URL ) -> getBody ( ) ; return json_decode ( $ json , true ) [ 'offers' ] [ 0 ] [ 'version' ] ; } $ html = ( new Http ) -> request ( 'GET' , self :: $ WP_RELEASES_URL ) -> getBody ( ) -> getContents ( ) ; preg_match_all ( "#><a href='https://wordpress\.org/wordpress-[^>]+#" , $ html , $ matches ) ; $ versions = Linq :: from ( $ matches [ 0 ] ) -> select ( function ( string $ v ) { return Str :: s ( $ v ) ; } ) -> where ( function ( Str $ v ) { return $ v -> endsWith ( ".zip'" ) ; } ) -> where ( function ( Str $ v ) { return ! $ v -> contains ( 'IIS' ) ; } ) -> where ( function ( Str $ v ) { return ! $ v -> contains ( 'mu' ) ; } ) -> select ( function ( Str $ v ) { return $ v -> between ( 'wordpress-' , '.zip' ) ; } ) -> where ( function ( Str $ v ) { if ( $ v -> contains ( '-' ) ) { return preg_match ( "#.*-(dev|beta|alpha|rc).*#i" , ( string ) $ v ) === 1 ; } return true ; } ) -> toArray ( ) ; return ( string ) Semver :: satisfiedBy ( $ versions , $ versionContraint ) [ 0 ] ; }
Resolves a Wordpress Version Contraint .
24,088
public static function files ( $ filepattern , $ directory = [ __DIR__ ] , $ excludepattern = false ) { return new self ( $ filepattern , $ directory , $ excludepattern ) ; }
Factory method . Return a new instance of the Beverage task runner
24,089
public function then ( Module $ module ) { $ this -> current_state = $ module -> process ( $ this -> current_state ) ; return $ this ; }
Run the modules
24,090
public function destination ( $ directory ) { $ filesystem = new Filesystem ( ) ; foreach ( $ this -> current_state as $ filename => $ file_content ) { $ filesystem -> dumpFile ( $ directory . '/' . $ filename , $ file_content ) ; } unset ( $ this -> current_state ) ; return $ this ; }
Define the directory where the files will be saved .
24,091
public static function registerTypeAlias ( $ alias , $ type ) { Assert :: notBlank ( $ alias , 'Alias name cannot be blank' ) ; Assert :: notBlank ( $ type , 'Target type name cannot be blank' ) ; self :: $ aliases [ strtolower ( $ alias ) ] = $ type ; }
Registers alias for a type
24,092
public function getPlugin ( $ name , array $ options = [ ] ) { $ plugin = $ this -> get ( $ name ) ; if ( ! empty ( $ options ) && is_callable ( [ $ plugin , 'setOptions' ] ) ) { $ plugin -> setOptions ( $ options ) ; } return $ plugin ; }
Gets the plugin and sets its options .
24,093
public function start ( $ callback = null ) { if ( self :: $ os === "linux" || self :: $ os === "mac" ) { return $ this -> startOnNix ( $ callback ) ; } else if ( self :: $ os === "windows" ) { return $ this -> startOnWindows ( $ callback ) ; } }
Callback is called when process is started
24,094
protected function resolveFieldOption ( array $ fields , $ option , $ expected = true ) { foreach ( $ fields as $ field ) { if ( $ field -> getOption ( $ option ) === $ expected ) { return $ expected ; } } return null ; }
Resolves option from fields
24,095
private function orderQueryBuilderBy ( QueryBuilder $ queryBuilder , TableInterface $ table , $ sort ) { if ( ! is_array ( $ sort ) ) { $ sort = array ( $ sort => $ table -> getOption ( 'order' , 'DESC' ) ) ; } foreach ( $ sort as $ fieldName => $ order ) { $ field = $ table -> getField ( $ fieldName ) ; if ( ! $ field -> getOption ( 'sortable' ) ) { throw new InvalidArgumentException ( "Field $fieldName is not sortable in table " . $ table -> getName ( ) ) ; } foreach ( ( array ) $ field -> getOption ( 'order_path' ) as $ orderBy ) { $ queryBuilder -> addOrderBy ( $ this -> fixQueryPath ( $ orderBy , $ field ) , $ order ) ; } } }
Sets the order by
24,096
public function fieldFilter ( QueryBuilder $ queryBuilder , FieldInterface $ field , $ value ) { if ( $ value ) { $ name = $ field -> getName ( ) ; $ path = $ field -> getOption ( 'association_path' ) ; if ( is_array ( $ value ) || $ value instanceof \ Traversable ) { $ expr = $ queryBuilder -> expr ( ) -> orX ( ) ; foreach ( $ value as $ index => $ v ) { $ param = 'filter_' . $ name . '_' . $ index ; $ queryBuilder -> setParameter ( $ param , $ v ) ; if ( is_object ( $ v ) ) { $ expr -> add ( ":$param MEMBER OF $path" ) ; } else { $ expr -> add ( "$path = :$param" ) ; } } $ queryBuilder -> andWhere ( $ expr ) ; } else { $ operator = $ field -> getOption ( 'filter_operator' ) ; $ comparison = new Query \ Expr \ Comparison ( $ path , $ operator , ':filter_' . $ name ) ; if ( $ operator == 'LIKE' || $ operator == 'NOT LIKE' ) { $ value = '%' . $ value . '%' ; } $ queryBuilder -> andWhere ( $ comparison ) -> setParameter ( 'filter_' . $ name , $ value ) ; } } }
Default field filter implementation .
24,097
public static function floatalize ( $ value ) { $ value = strtoupper ( $ value ) ; if ( strpos ( $ value , 'E' ) === false ) { return $ value ; } $ number = substr ( $ value , 0 , strpos ( $ value , 'E' ) ) ; if ( strpos ( $ number , '.' ) !== false ) { $ post = strlen ( substr ( $ number , strpos ( $ number , '.' ) + 1 ) ) ; $ mantis = substr ( $ value , strpos ( $ value , 'E' ) + 1 ) ; if ( $ mantis < 0 ) { $ post += abs ( ( int ) $ mantis ) ; } $ value = number_format ( $ value , $ post , '.' , '' ) ; } else { $ value = number_format ( $ value , 0 , '.' , '' ) ; } return $ value ; }
Convert a scientific notation to float Additionally fixed a problem with PHP < = 5 . 2 . x with big integers
24,098
public static function normalize ( $ value ) { $ convert = localeconv ( ) ; $ value = str_replace ( $ convert [ 'thousands_sep' ] , "" , ( string ) $ value ) ; $ value = str_replace ( $ convert [ 'positive_sign' ] , "" , $ value ) ; $ value = str_replace ( $ convert [ 'decimal_point' ] , "." , $ value ) ; if ( ! empty ( $ convert [ 'negative_sign' ] ) and ( strpos ( $ value , $ convert [ 'negative_sign' ] ) ) ) { $ value = str_replace ( $ convert [ 'negative_sign' ] , "" , $ value ) ; $ value = "-" . $ value ; } return $ value ; }
Normalizes an input to standard english notation Fixes a problem of BCMath with setLocale which is PHP related
24,099
public static function localize ( $ value ) { $ convert = localeconv ( ) ; $ value = str_replace ( "." , $ convert [ 'decimal_point' ] , ( string ) $ value ) ; if ( ! empty ( $ convert [ 'negative_sign' ] ) and ( strpos ( $ value , "-" ) ) ) { $ value = str_replace ( "-" , $ convert [ 'negative_sign' ] , $ value ) ; } return $ value ; }
Localizes an input from standard english notation Fixes a problem of BCMath with setLocale which is PHP related