idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
19,600 | public function getContainer ( ) { if ( ! $ this -> container ) { $ this -> container = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; } return $ this -> container ; } | Get container for scripts |
19,601 | public function getLibSrc ( $ ver = null ) { if ( $ ver == null ) { $ ver = $ this -> getVersion ( ) ; } if ( ! $ ver ) { $ ver = $ this -> defVersion ; } $ return = false ; foreach ( $ this -> getLibDelivers ( ) as $ name => $ service ) { $ return = $ service -> getLibSrc ( $ ver ) ; if ( $ return ) { break ; } } if ( ! $ return ) { throw new \ Exception ( 'Can`t resolve to library.' ) ; } return $ return ; } | Get jquery lib src from deliveries |
19,602 | public function addLibDeliver ( InterfaceDelivery $ deliverance ) { $ name = $ deliverance -> getName ( ) ; $ this -> delivLibs [ $ name ] = $ deliverance ; return $ this ; } | Add a deliverance of library |
19,603 | protected function createData ( $ mode , $ content = null , array $ attributes = array ( ) ) { $ data = array ( ) ; $ data [ 'mode' ] = $ mode ; $ data [ 'content' ] = $ content ; $ data [ 'attributes' ] = array_merge ( $ attributes , array ( 'type' => 'text/javascript' ) ) ; return $ data ; } | Create data item containing all necessary components of script |
19,604 | public static function compose ( callable ... $ callables ) : \ Closure { $ callables = array_reverse ( $ callables ) ; return function ( ... $ args ) use ( $ callables ) { foreach ( $ callables as $ callable ) { $ args = [ $ callable ( ... $ args ) ] ; } return current ( $ args ) ; } ; } | Returns a Closure which once invoked applies each given callable to the result of the previous callable in right - to - left order . As such the arguments passed to the Closure are passed through to the last callable given to the composition . |
19,605 | public static function memoize ( callable $ callback , $ key = null ) : \ Closure { return function ( ... $ args ) use ( $ callback , $ key ) { $ key = null === $ key ? static :: hash ( $ callback , $ args ) : ( string ) ( is_callable ( $ key ) ? $ key ( $ callback , ... $ args ) : $ key ) ; if ( ! array_key_exists ( $ key , static :: $ memory ) ) { static :: $ memory [ $ key ] = $ callback ( ... $ args ) ; } return static :: $ memory [ $ key ] ; } ; } | Creates a Closure that memoizes the result of the wrapped callable and returns it once the wrapper gets called . |
19,606 | public static function partial ( callable $ callback , ... $ prependedArgs ) : \ Closure { return function ( ... $ args ) use ( $ callback , $ prependedArgs ) { return $ callback ( ... $ prependedArgs , ... $ args ) ; } ; } | Creates a Closure that when called invokes the wrapped callable with any additional partial arguments prepended to those provided to the new Closure . |
19,607 | public static function partialRight ( callable $ callback , ... $ appendedArgs ) : \ Closure { return function ( ... $ args ) use ( $ callback , $ appendedArgs ) { return $ callback ( ... $ args , ... $ appendedArgs ) ; } ; } | Creates a Closure that when called invokes the wrapped callable with any additional partial arguments appended to those provided to the new Closure . |
19,608 | public static function getAssetFolderName ( $ file_name ) { $ file_extension = strtolower ( substr ( strrchr ( $ file_name , "." ) , 1 ) ) ; if ( preg_match ( '/jpg|jpeg|gif|png|ico/' , $ file_extension ) ) { return 'img' ; } if ( $ file_extension === 'js' ) { return 'js' ; } if ( $ file_extension === 'css' ) { return 'css' ; } if ( $ file_extension === 'pdf' ) { return 'pdf' ; } return false ; } | Return the folder name for a given file |
19,609 | public function getAssetPath ( ) { $ url_frags = parse_url ( $ _SERVER [ 'REQUEST_URI' ] ) ; if ( ! array_key_exists ( 'query' , $ url_frags ) ) return false ; parse_str ( $ url_frags [ 'query' ] , $ query_vars ) ; if ( ! array_key_exists ( 'asset' , $ query_vars ) ) return false ; $ folder_name = self :: getAssetFolderName ( $ query_vars [ 'asset' ] ) ; $ file_name = sprintf ( $ this -> actual_path . '/assets/%s/%s' , $ folder_name , $ query_vars [ 'asset' ] ) ; if ( file_exists ( $ file_name ) ) { return $ file_name ; } return $ false ; } | Determine the path for an asset using the query string |
19,610 | public static function getAssetFileName ( ) { $ url_frags = parse_url ( $ _SERVER [ 'REQUEST_URI' ] ) ; if ( ! array_key_exists ( 'query' , $ url_frags ) ) return false ; parse_str ( $ url_frags [ 'query' ] , $ query_vars ) ; if ( ! array_key_exists ( 'asset' , $ query_vars ) ) return false ; return $ query_vars [ 'asset' ] ; } | Get the file from a the query string |
19,611 | public function fileServe ( $ query , $ callback = null ) { if ( ! array_key_exists ( 'REQUEST_URI' , $ _SERVER ) ) return $ query ; $ path_prefix = $ this -> getPathPrefix ( ) ; if ( ! preg_match ( "/$path_prefix\/assets\/(.*)$/i" , $ _SERVER [ 'REQUEST_URI' ] ) ) return $ query ; $ file_path = self :: getAssetPath ( ) ; if ( ! $ file_path ) return $ query ; if ( ! $ this -> shouldLoadFile ( $ this -> getAssetFileName ( ) ) ) return $ query ; $ content_type = self :: getContentType ( $ file_path ) ; header ( 'Content-type: ' . $ content_type ) ; header ( 'Content-Length: ' . filesize ( $ file_path ) ) ; http_response_code ( 200 ) ; readfile ( $ file_path ) ; if ( $ callback ) { $ callback ( ) ; } exit ; return $ query ; } | Return a file given the query string |
19,612 | function it_compiles_nodes_using_a_generic_solution ( $ node ) { $ node -> compile ( $ this ) -> will ( function ( $ args ) { $ args [ 0 ] -> write ( 'echo $message' ) ; } ) ; $ this -> repr ( $ node ) -> getSource ( ) -> shouldMatch ( '/echo \$message/' ) ; } | It compiles nodes using a generic solution . |
19,613 | function it_compiles_nodes ( $ node ) { $ node -> compile ( $ this ) -> will ( function ( $ args ) { $ args [ 0 ] -> write ( 'echo $message' ) ; } ) ; $ this -> compile ( $ node ) -> getSource ( ) -> shouldMatch ( '/\Recho \$message/' ) ; } | It compiles nodes . |
19,614 | function it_can_execute_functions_conditionally_to_not_break_the_fluent_interface ( ) { $ this -> runIf ( false , function ( ) { $ this -> write ( 'echo $message' ) ; } ) -> getSource ( ) -> shouldReturn ( '<?php' . PHP_EOL ) ; $ this -> runIf ( true , function ( ) { $ this -> write ( 'echo $message' ) ; } ) -> getSource ( ) -> shouldMatch ( '/\Recho \$message/' ) ; } | It can execute functions conditionally to not break the fluent interface . |
19,615 | function it_can_execute_functions_for_each_item_in_a_collection ( ) { $ collection = [ 1 , 2 , 3 ] ; $ this -> each ( $ collection , function ( $ item ) { $ this -> raw ( $ item ) ; } ) -> getSource ( ) -> shouldMatch ( '/123/' ) ; } | It can execute functions for each item in a collection . |
19,616 | public static function getSupportedEncodings ( ) { if ( static :: $ encodings === null ) { static :: $ encodings = array_map ( 'strtoupper' , mb_list_encodings ( ) ) ; $ indexIso885916 = array_search ( 'ISO-8859-16' , static :: $ encodings , true ) ; if ( $ indexIso885916 !== false ) { unset ( static :: $ encodings [ $ indexIso885916 ] ) ; } } return static :: $ encodings ; } | Get a list of supported character encodings |
19,617 | public function convert ( $ str , $ reverse = false ) { $ encoding = $ this -> getEncoding ( ) ; $ convertEncoding = $ this -> getConvertEncoding ( ) ; if ( $ convertEncoding === null ) { throw new Exception \ LogicException ( 'No convert encoding defined' ) ; } if ( $ encoding === $ convertEncoding ) { return $ str ; } $ fromEncoding = $ reverse ? $ convertEncoding : $ encoding ; $ toEncoding = $ reverse ? $ encoding : $ convertEncoding ; return mb_convert_encoding ( $ str , $ toEncoding , $ fromEncoding ) ; } | Convert a string from defined encoding to the defined convert encoding |
19,618 | protected function splitPath ( $ path ) { $ chunks = array_map ( [ $ this , 'unescape' ] , preg_split ( '#(?<!\\\)\/#' , ltrim ( $ path , '/' ) ) ) ; if ( empty ( $ chunks ) || ( array_filter ( $ chunks ) !== $ chunks ) ) { throw new \ InvalidArgumentException ( 'Invalid path provided:' . $ path ) ; } return $ chunks ; } | Split the path into chunks . |
19,619 | public function get ( $ path , $ forceArray = false ) { if ( $ path === '/' ) { return $ this -> data ; } $ chunks = $ this -> splitPath ( $ path ) ; $ scope = $ this -> data ; while ( null !== ( $ sub = array_shift ( $ chunks ) ) ) { if ( isset ( $ scope [ $ sub ] ) ) { if ( $ forceArray ) { $ scope = ( array ) $ scope [ $ sub ] ; } else { $ scope = $ scope [ $ sub ] ; } } else { if ( $ forceArray ) { return [ ] ; } else { return null ; } } } return $ scope ; } | Retrieve a value . |
19,620 | public function has ( $ path ) { $ chunks = $ this -> splitPath ( $ path ) ; $ scope = $ this -> data ; while ( null !== ( $ sub = array_shift ( $ chunks ) ) ) { if ( isset ( $ scope [ $ sub ] ) ) { $ scope = $ scope [ $ sub ] ; } else { return false ; } } return true ; } | Check if a value exists . |
19,621 | public function getEntries ( $ path ) { $ entries = $ this -> get ( $ path ) ; $ result = [ ] ; $ prefix = trim ( $ path , '/' ) ; if ( strlen ( $ prefix ) ) { $ prefix .= '/' ; } if ( is_array ( $ entries ) ) { foreach ( array_keys ( $ entries ) as $ key ) { $ result [ ] = $ prefix . $ this -> escape ( $ key ) ; } } return $ result ; } | Retrieve the contained keys at the given path . |
19,622 | public function uasort ( $ callback , $ path = '/' ) { $ value = $ this -> get ( $ path ) ; if ( null === $ value || ! is_array ( $ value ) ) { return ; } uasort ( $ value , $ callback ) ; $ this -> set ( $ path , $ value ) ; } | Sort the array by the provided user function . |
19,623 | public static function collapse ( string $ str , string $ encoding = null ) : string { $ encoding = $ encoding ? : static :: encoding ( $ str ) ; return static :: trim ( static :: replace ( $ str , '[[:space:]]+' , ' ' , 'msr' , $ encoding ) , null , $ encoding ) ; } | Trims the given string and replaces multiple consecutive whitespaces with a single whitespace . |
19,624 | public static function eachLine ( string $ str , callable $ callable , ... $ args ) : string { if ( $ str === '' ) { return $ str ; } $ lines = mb_split ( '[\r\n]{1,2}' , $ str ) ; foreach ( $ lines as $ number => & $ line ) { $ lines [ $ number ] = ( string ) call_user_func ( $ callable , $ line , $ number , ... $ args ) ; } return implode ( "\n" , $ lines ) ; } | Runs the given callable over each line of the given string and returns the resulting string . |
19,625 | public static function encoding ( string $ str = null ) : string { if ( true === static :: $ autoDetectEncoding && null !== $ str && false !== $ encoding = mb_detect_encoding ( $ str ) ) { return $ encoding ; } return static :: $ encoding ? : 'utf-8' ; } | Attempts to determine the encoding of a string if a string is given . |
19,626 | public static function length ( string $ str , string $ encoding = null ) : int { return mb_strlen ( $ str , $ encoding ? : static :: encoding ( $ str ) ) ; } | Determines the length of a given string . Counts multi - byte characters as single characters . |
19,627 | public static function matches ( string $ str , string $ pattern ) : bool { if ( $ pattern === $ str ) { return true ; } return ( bool ) preg_match ( '#^' . str_replace ( '\*' , '.*' , preg_quote ( $ pattern , '#' ) ) . '\z' . '#' , $ str ) ; } | Determines whether the given string matches the given pattern . Asterisks are translated into zero or more regexp wildcards allowing for glob - style patterns . |
19,628 | public static function slug ( string $ str , string $ delimiter = '-' ) : string { $ str = static :: toAscii ( $ str ) ; $ str = preg_replace ( '![^' . preg_quote ( $ delimiter ) . '\pL\pN\s]+!u' , '' , mb_strtolower ( $ str ) ) ; $ flip = $ delimiter == '-' ? '_' : '-' ; $ str = preg_replace ( '![' . preg_quote ( $ flip ) . ']+!u' , $ delimiter , $ str ) ; $ str = preg_replace ( '![' . preg_quote ( $ delimiter ) . '\s]+!u' , $ delimiter , $ str ) ; return trim ( $ str , $ delimiter ) ; } | Generates a URL - friendly slug from the given string . |
19,629 | public static function toAscii ( string $ str ) : string { if ( preg_match ( "/[\x80-\xFF]/" , $ str ) ) { if ( null === static :: $ ascii ) { static :: $ ascii = unserialize ( file_get_contents ( __DIR__ . '/str/resources/transliteration_table.ser' ) ) ; } $ str = \ Normalizer :: normalize ( $ str , \ Normalizer :: NFKD ) ; $ str = preg_replace ( '/\p{Mn}+/u' , '' , $ str ) ; $ str = str_replace ( static :: $ ascii [ 0 ] , static :: $ ascii [ 1 ] , $ str ) ; $ str = iconv ( 'UTF-8' , 'ASCII' . ( 'glibc' !== ICONV_IMPL ? '//IGNORE' : '' ) . '//TRANSLIT' , $ str ) ; } return $ str ; } | Transliterates an UTF - 8 encoded string to its ASCII equivalent . |
19,630 | public static function toBool ( string $ str , string $ encoding = null ) : bool { static $ map = [ 'true' => true , 'false' => false , '1' => true , '0' => false , 'on' => true , 'off' => false , 'yes' => true , 'no' => false , 'y' => true , 'n' => false ] ; $ encoding = $ encoding ? : static :: encoding ( $ str ) ; return $ map [ mb_strtolower ( $ str , $ encoding ) ] ?? ( bool ) static :: replace ( $ str , '[[:space:]]' , '' , 'msr' , $ encoding ) ; } | Checks whether the given string represents a boolean value . Case insensitive . |
19,631 | public static function words ( string $ str , int $ words = 100 , string $ encoding = null , string $ end = '...' ) : string { $ encoding = $ encoding ? : static :: encoding ( $ str ) ; preg_match ( '/^\s*+(?:\S++\s*+){1,' . $ words . '}/u' , $ str , $ matches ) ; if ( ! isset ( $ matches [ 0 ] ) || mb_strlen ( $ str , $ encoding ) === mb_strlen ( $ matches [ 0 ] , $ encoding ) ) { return $ str ; } return rtrim ( $ matches [ 0 ] ) . $ end ; } | Limits the number of words in the given string . |
19,632 | public function reset ( ) { $ this -> isUserSubmitted = false ; $ this -> isProcessed = false ; $ this -> isCallbacksubmitted = false ; parent :: reset ( ) ; } | Resets state and field values . DOES NOT remove validators and callbacks |
19,633 | public function f ( $ query , $ includeInactiveFields = false ) { $ minLength = - 1 ; $ match = null ; foreach ( $ this -> getFields ( $ includeInactiveFields ) as $ field ) if ( preg_match ( "/^(.*)" . preg_quote ( $ query ) . "$/" , $ field -> getGlobalSlug ( ) , $ matches ) ) { $ l = strlen ( $ matches [ 1 ] ) ; if ( $ l < $ minLength || $ minLength == - 1 ) { $ minLength = $ l ; $ match = $ field ; } } return $ match ; } | Searches form fields |
19,634 | public function v ( $ query , $ default = '' ) { $ f = $ this -> f ( $ query ) ; if ( $ f !== null ) return $ f -> getValue ( ) ; else return $ default ; } | Searches form fields and returns its value |
19,635 | public function c ( ) { $ fields = array ( ) ; foreach ( $ this -> getFields ( ) as $ field ) if ( $ field -> getCollectData ( ) ) $ fields [ ] = $ field ; return $ fields ; } | Returns an array of fields of which data is to be collected |
19,636 | public function addValidator ( FormValidator $ validator , $ unshift = false ) { if ( $ unshift ) array_unshift ( $ this -> validators , $ validator ) ; else $ this -> validators [ ] = $ validator ; return $ this ; } | Adds a new form - level validator |
19,637 | public function getField ( $ localSlug ) { foreach ( $ this -> getFields ( ) as $ field ) if ( $ field -> getLocalSlug ( ) == $ localSlug ) return $ field ; return null ; } | Finds a field by its localslug value |
19,638 | public function getFormErrors ( ) { return array_map ( function ( FormValidator $ formValidator ) { return $ formValidator -> getErrorMsg ( ) ; } , array_filter ( $ this -> validators , function ( FormValidator $ validator ) { return ! $ validator -> isValid ( ) ; } ) ) ; } | Get all the error messages for form - wide validators that returned invalid |
19,639 | public function getWrapBefore ( ) { $ dataFields = $ this -> getDataFieldsHTML ( ) ; $ errors = join ( array_map ( function ( $ errorMsg ) { return Form :: renderFormError ( $ errorMsg ) ; } , $ this -> getFormErrors ( ) ) ) ; return "<form " . $ this -> getAttributesString ( ) . ">" . $ errors . $ dataFields ; } | Gets the markup that is to be outputted before the actual contents of the form . This method could be used for even more manual control over outputting with a custom markup . |
19,640 | public function getFields ( $ includeInactiveFields = false ) { $ fields = array ( ) ; foreach ( $ this -> getChildren ( true , $ includeInactiveFields ) as $ component ) if ( $ component instanceof Field ) array_push ( $ fields , $ component ) ; return $ fields ; } | Retrieves an array of this form s fields |
19,641 | private function submit ( ) { foreach ( $ this -> getFields ( ) as $ field ) $ field -> submit ( ) ; $ this -> isCallbacksubmitted = true ; foreach ( $ this -> callback as $ callback ) if ( is_callable ( $ callback ) ) call_user_func ( $ callback , $ this ) ; } | Submits the form internally . You re not usually supposed to call this function directly . |
19,642 | public function process ( ) { if ( $ this -> isProcessed ) return ; $ this -> isProcessed = true ; foreach ( $ this -> getFields ( ) as $ field ) $ field -> preprocess ( ) ; $ this -> isUserSubmitted = $ this -> getValue ( $ this -> getSubmitConfirmFieldName ( ) , 'false' ) == 'true' || $ this -> forceSubmit ; if ( $ this -> isUserSubmitted ) { foreach ( $ this -> getFields ( ) as $ field ) $ field -> restoreValue ( $ this -> method ) ; $ this -> activateHandlers ( ) ; if ( $ this -> isValid ( ) ) { $ this -> submit ( ) ; } } } | Check if form was activated then validates calls handlers then submits . Call this function before displaying the form . |
19,643 | function getValues ( $ useName = true , $ includeDataFields = true ) { $ values = array ( ) ; foreach ( $ this -> getFields ( ) as $ field ) if ( $ field -> getCollectData ( ) ) { $ key = $ useName ? $ field -> getName ( ) : $ field -> getLocalSlug ( ) ; $ values [ $ key ] = $ field -> getValue ( ) ; } if ( $ includeDataFields ) $ values = array_merge ( $ values , $ this -> dataFields ) ; return $ values ; } | Gets a complete associated array containing all the data that needs to be stored |
19,644 | function setValues ( array $ values = array ( ) ) { foreach ( $ this -> getFields ( ) as $ field ) if ( array_key_exists ( $ field -> getName ( ) , $ values ) ) $ field -> setValue ( $ values [ $ field -> getName ( ) ] ) ; foreach ( $ this -> dataFields as $ dataKey => $ dataVal ) if ( array_key_exists ( $ dataKey , $ values ) ) $ this -> dataFields [ $ dataKey ] = $ values [ $ dataKey ] ; } | Restores the values from an associated array . Only defined properties will be overwritten |
19,645 | public function display ( $ layout = null , $ env = array ( ) ) { if ( $ layout === NULL ) { throw new \ Exception ( "Invalid Rendering Model" ) ; } $ rendering = $ this -> getCurrentRendering ( ) ; if ( $ rendering ) { $ env += $ rendering [ 1 ] ; } $ prevLayouts = count ( static :: $ layoutStack ) ; $ this -> pushToStack ( $ layout , $ env ) ; extract ( $ env , EXTR_SKIP ) ; include $ this -> getLayoutPath ( $ layout ) ; $ this -> pullFromStack ( ) ; $ currentLayouts = count ( static :: $ layoutStack ) ; while ( $ currentLayouts > $ prevLayouts && static :: endCurrentLayout ( $ env ) ) { $ currentLayouts -- ; } } | Display the model allow an absolute path to the template file . |
19,646 | public static function renderReport ( $ report , $ domain , $ type , $ stream ) { $ report = nl2br ( $ report ) ; $ rendering = new static ( ) ; if ( $ rendering -> existsLayoutPath ( 'report-' . $ type ) ) { return $ rendering -> render ( 'report-' . $ type , array ( 'Report' => $ report , 'Domain' => $ domain , 'Type' => $ type , 'Stream' => $ stream ) ) ; } if ( $ rendering -> existsLayoutPath ( 'report' ) ) { return $ rendering -> render ( 'report' , array ( 'Report' => $ report , 'Domain' => $ domain , 'Type' => $ type , 'Stream' => $ stream ) ) ; } return ' <div class="report report_' . $ stream . ' ' . $ type . ' ' . $ domain . '">' . nl2br ( $ report ) . '</div>' ; } | Render the given report as HTML |
19,647 | public function addThemeCSSFile ( $ filename , $ type = null ) { $ this -> addCSSURL ( $ this -> getCSSURL ( ) . $ filename , $ type ) ; } | Add a theme css file to the list |
19,648 | public function addThemeJSFile ( $ filename , $ type = null ) { $ this -> addJSURL ( $ this -> getJSURL ( ) . $ filename , $ type ) ; } | Add a theme js file to the list |
19,649 | public static function & initInstance ( EntityAuthData $ platform ) { if ( NULL === self :: $ _instance ) { self :: $ _instance = new Sonic ( ) ; } self :: $ _instance -> platformAuthData = $ platform ; self :: $ logger = new Logger ( 'sonic' ) ; self :: $ logger -> pushHandler ( new StreamHandler ( Configuration :: getLogfile ( ) ) ) ; self :: $ _instance -> setContext ( Sonic :: CONTEXT_PLATFORM ) ; return self :: $ _instance ; } | initializes the Sonic SDK using EntityAuthData of the platform |
19,650 | public function setSocialRecordCaching ( ISocialRecordCaching $ srCachingObject ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; if ( ! array_key_exists ( 'sgoendoer\Sonic\Identity\ISocialRecordCaching' , class_implements ( $ srCachingObject ) ) ) { throw new SonicRuntimeException ( 'SocialRecordCaching must implement goendoer\Sonic\Identity\ISocialRecordCaching' ) ; } else $ this -> socialRecordCache = $ srCachingObject ; return $ this ; } | sets the SocialRecordCaching instance |
19,651 | public static function socialRecordCachingEnabled ( ) { if ( self :: $ _instance === NULL ) return false ; if ( self :: $ _instance -> socialRecordCache === NULL ) return false ; else return true ; } | determines if SocialRecordCaching is enabled |
19,652 | public static function getSocialRecordCaching ( ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; if ( self :: $ _instance -> socialRecordCache != NULL ) return self :: $ _instance -> socialRecordCache ; else return NULL ; } | returns the SocialRecordCaching instance |
19,653 | public function setUniqueIDManager ( IUniqueIDManager $ uniqueIDManagerObject ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; if ( ! array_key_exists ( 'sgoendoer\Sonic\Crypt\IUniqueIDManager' , class_implements ( $ uniqueIDManagerObject ) ) ) { throw new SonicRuntimeException ( 'UniqueIDManager must implement sgoendoer\Sonic\Crypt\IUniqueIDManager' ) ; } else $ this -> uniqueIDManager = $ uniqueIDManagerObject ; return self :: $ _instance ; } | sets the UniqueIDManager |
19,654 | public static function getUniqueIDManager ( ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; if ( self :: $ _instance -> uniqueIDManager != NULL ) return self :: $ _instance -> uniqueIDManager ; else return NULL ; } | returns the UniqueIDManager instance if set |
19,655 | public function setAccessControlManager ( AccessControlManager $ accessControlManagerObject ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; if ( ! array_key_exists ( 'sgoendoer\Sonic\AccessControl\AccessControlManager' , class_parents ( $ accessControlManagerObject ) ) ) { throw new SonicRuntimeException ( 'AccessControlManager must implement sgoendoer\Sonic\AccessControl\AccessControlManager' ) ; } else $ this -> accessControlManager = $ accessControlManagerObject ; return self :: $ _instance ; } | sets the AccessControlManager |
19,656 | public static function getAccessControlManager ( ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; if ( self :: $ _instance -> accessControlManager != NULL ) return self :: $ _instance -> accessControlManager ; else throw new AccessControlManagerException ( 'AccessControlManager instance not found' ) ; } | returns the AccessControlManager instance |
19,657 | public static function setPlatformAuthData ( EntityAuthData $ entityAuthData ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; self :: $ _instance -> platformAuthData = $ entityAuthData ; return self :: $ _instance ; } | set the platform s AuthData |
19,658 | public static function setUserAuthData ( EntityAuthData $ entityAuthData ) { if ( self :: $ _instance === NULL ) throw new SonicRuntimeException ( 'Sonic instance not initialized' ) ; self :: $ _instance -> userAuthData = $ entityAuthData ; self :: $ _instance -> setContext ( Sonic :: CONTEXT_USER ) ; return self :: $ _instance ; } | set the user s AuthData |
19,659 | public static function getLogger ( ) { if ( self :: $ logger === NULL ) { self :: $ logger = new Logger ( 'sonic' ) ; self :: $ logger -> pushHandler ( new StreamHandler ( Configuration :: getLogfile ( ) ) ) ; } return self :: $ logger ; } | return the monolog logger instance |
19,660 | public function setCookies ( $ cookies = [ ] ) { $ this -> cookies = ( $ cookies instanceof Parameters ) ? $ cookies : new Parameters ( "cookies" , ( array ) $ cookies ) ; return $ this ; } | Sets the response cookies . Be warned that this replaces all cookies ; |
19,661 | public function setHeaders ( array $ headers = [ ] ) { $ this -> headers = ( $ headers instanceof Headers ) ? $ headers : new Headers ( ( array ) $ headers ) ; return $ this ; } | Sets a HeaderBag containing all headers ; |
19,662 | public function addHeader ( $ key , $ value = null ) { $ headers = $ this -> getHeaders ( ) ; $ headers -> set ( $ key , $ value ) ; return $ this ; } | Add a header to the Header bag ; |
19,663 | public function getContent ( $ packetId = null ) { if ( ! isset ( $ this -> packetId ) ) { return $ content = implode ( "/n" , $ this -> content ) ; } return isset ( $ this -> content [ $ packetId ] ) ? $ this -> content [ $ packetId ] : "" ; } | Gets content with specified Id or all the content for buffering ; |
19,664 | public static function forge ( $ data = null , $ from_type = null , $ param = null ) { return new static ( $ data , $ from_type , $ param ) ; } | Returns an instance of the Format object . |
19,665 | public function set_cookie ( $ name , $ value = null ) { is_null ( $ value ) ? $ this -> connection ( ) -> __setCookie ( $ name ) : $ this -> connection ( ) -> __setCookie ( $ name , $ value ) ; } | Set cookie for subsequent requests |
19,666 | public function createTable ( ) { $ file_info = FileInfo :: Create ( $ this -> table_file_path ) ; if ( $ file_info -> isFile ( ) ) { include $ file_info -> getPathname ( ) ; $ class_name = substr ( $ file_info -> getFilename ( ) , 0 , - 4 ) ; $ table_object = new $ class_name ( ) ; return $ this -> getColumns ( $ table_object ) -> createSQL ( ) -> executeCreate ( ) ; } else { } } | This method creates a new table associated with this model . |
19,667 | public function updateTable ( ) { $ file_info = FileInfo :: Create ( $ this -> table_file_path ) ; if ( $ file_info -> isFile ( ) ) { include $ file_info -> getPathname ( ) ; $ class_name = substr ( $ file_info -> getFilename ( ) , 0 , - 4 ) ; $ table_object = new $ class_name ( ) ; $ this -> getColumns ( $ table_object ) -> updateSQL ( ) -> executeUpdate ( ) ; } else { } } | This model updates a table structure in the database . |
19,668 | public function createSQL ( ) { try { $ lines = array ( ) ; $ indices = array ( ) ; $ columns = $ this -> columns ; $ template = "CREATE TABLE %s (\n%s,\n%s\n) ENGINE=%s DEFAULT CHARSET=%s;" ; foreach ( $ this -> columns as $ column_name => $ column ) { $ data_type = $ column [ "type" ] ; $ length = $ column [ "length" ] ; if ( $ column [ "primary" ] ) $ indices [ ] = "PRIMARY KEY ({$column_name})" ; if ( $ column [ "index" ] ) $ indices [ ] = "KEY {$column_name} ({$column_name})" ; switch ( $ data_type ) { case "autonumber" : $ lines [ ] = "{$column_name} INT(11) NOT NULL AUTO_INCREMENT" ; break ; case "text" : if ( $ length !== null && $ length <= 255 ) $ lines [ ] = "{$column_name} VARCHAR({$length}) DEFAULT NULL" ; else $ lines [ ] = "{$column_name} text" ; break ; case "integer" : $ lines [ ] = "{$column_name} INT(11) DEFAULT NULL" ; break ; case "decimal" : $ lines [ ] = "{$column_name} FLOAT DEFAULT NULL" ; break ; case "boolean" : $ lines [ ] = "{$column_name} TINYINT(4) DEFAULT NULL" ; break ; case "datetime" : $ lines [ ] = "{$column_name} DATETIME DEFAULT NULL" ; break ; } } $ this -> query_string = sprintf ( $ template , $ this -> table , join ( ",\n" , $ lines ) , join ( ",\n" , $ indices ) , 'InnoDB' , 'utf8' ) ; return $ this ; } catch ( MySQLException $ e ) { $ e -> errorShow ( ) ; } } | This method generates query string for creating the database table . |
19,669 | public static function register_widgets ( ) { foreach ( self :: $ _widgets [ 'lean' ] as $ widget ) { self :: register_widget ( __NAMESPACE__ . '\\Collection\\' . $ widget ) ; } foreach ( self :: $ _widgets [ 'custom' ] as $ widget ) { self :: register_widget ( $ widget ) ; } } | Register required widgets . |
19,670 | private static function register_widget ( $ widget_class ) { register_widget ( $ widget_class ) ; $ callback = [ $ widget_class , 'post_registration' ] ; if ( is_callable ( $ callback , true ) ) { call_user_func ( $ callback ) ; } } | Register a widget and run its post_registration function . |
19,671 | public static function get_widget_instance ( $ widget_id ) { global $ wp_registered_widgets ; if ( ! isset ( $ wp_registered_widgets [ $ widget_id ] ) ) { return false ; } $ model = $ wp_registered_widgets [ $ widget_id ] [ 'callback' ] [ 0 ] ; if ( ! is_a ( $ model , 'Lean\Widgets\Models\AbstractWidget' ) ) { return false ; } $ key = $ wp_registered_widgets [ $ widget_id ] [ 'params' ] [ 0 ] [ 'number' ] ; $ model -> _set ( $ key ) ; return $ model ; } | Gets a specific instance of a widget |
19,672 | public static function formats ( $ format = null , $ handler = null ) { if ( $ format === null ) { return static :: $ _formats ; } if ( $ format === false ) { return static :: $ _formats = [ 'array' => 'Lead\Collection\Collection::toArray' ] ; } if ( $ handler === false ) { unset ( static :: $ _formats [ $ format ] ) ; return ; } return static :: $ _formats [ $ format ] = $ handler ; } | Accessor method for adding format handlers to Collection instances . |
19,673 | public function each ( $ callback ) { foreach ( $ this -> _data as $ key => $ val ) { $ this -> _data [ $ key ] = $ callback ( $ val , $ key , $ this ) ; } return $ this ; } | Applies a callback to all items in the collection . |
19,674 | public static function toArray ( $ data , $ options = [ ] ) { $ defaults = [ 'key' => true , 'handlers' => [ ] ] ; $ options += $ defaults ; $ result = [ ] ; foreach ( $ data as $ key => $ item ) { switch ( true ) { case is_array ( $ item ) : $ result [ $ key ] = static :: toArray ( $ item , $ options ) ; break ; case ( ! is_object ( $ item ) ) : $ result [ $ key ] = $ item ; break ; case ( isset ( $ options [ 'handlers' ] [ $ class = get_class ( $ item ) ] ) ) : $ result [ $ key ] = $ options [ 'handlers' ] [ $ class ] ( $ item ) ; break ; case ( $ item instanceof static ) : $ result [ $ key ] = static :: toArray ( $ item , $ options ) ; break ; case ( method_exists ( $ item , '__toString' ) ) : $ result [ $ key ] = ( string ) $ item ; break ; default : $ result [ $ key ] = $ item ; break ; } } return $ options [ 'key' ] ? $ result : array_values ( $ result ) ; } | Exports a Collection instance to an array . |
19,675 | public function push ( string $ value ) : core \ collections \ interfaces \ Map { if ( ! $ argument = $ this -> definitions -> getNextDefinition ( $ this ) ) { throw new exceptions \ ArgumentsTooMany ( $ this ) ; } return $ this -> set ( $ argument -> getName ( ) , $ value ) ; } | Adds an argument s value to the collection . |
19,676 | public static function dump ( $ var ) { $ flags = 0 ; if ( Config :: get ( 'debug.dump_show_string_length' ) ) { $ flags = $ flags | AbstractDumper :: DUMP_STRING_LENGTH ; } $ cloner = new VarCloner ( ) ; if ( ! \ in_array ( \ PHP_SAPI , array ( 'cli' , 'phpdbg' ) , true ) ) { $ dumper = new HtmlDumper ( null , null , $ flags ) ; $ dumper -> setStyles ( self :: get_styles ( ) ) ; if ( Config :: get ( 'debug.dump_include_trace' ) ) { $ dumper -> setDumpBoundaries ( '<pre class=sf-dump id=%s data-indent-pad="%s">' . self :: additional_output ( ) , '</pre><script>Sfdump(%s)</script>' ) ; } } else { $ dumper = new CliDumper ( null , null , $ flags ) ; } $ dumper -> dump ( $ cloner -> cloneVar ( $ var ) ) ; } | The dump replacement . |
19,677 | private static function get_styles ( ) { $ style = Config :: get ( 'debug.dump_set_style' , 'snap' ) ; if ( \ is_array ( $ style ) ) { return $ style ; } if ( \ array_key_exists ( $ style , self :: $ schemes ) ) { return self :: $ schemes [ $ style ] ; } return self :: $ schemes [ 'snap' ] ; } | Ensures the dump output uses the correct styles for Snap . |
19,678 | private static function additional_output ( ) { $ backtrace = \ debug_backtrace ( ) [ 3 ] ; $ root = \ realpath ( __DIR__ . '/../../../../../../' ) ; return '<span class="sf-dump-lineinfo">' . \ ltrim ( \ str_replace ( $ root , '' , $ backtrace [ 'file' ] ) , '/\\' ) . ':' . $ backtrace [ 'line' ] . '</span>' ; } | Gets the line and file of where the dump was called . |
19,679 | public static function Apcg13 ( $ date1 , $ date2 , iauASTROM & $ astrom ) { $ ehpv = [ ] ; $ ebpv = [ ] ; IAU :: Epv00 ( $ date1 , $ date2 , $ ehpv , $ ebpv ) ; IAU :: Apcg ( $ date1 , $ date2 , $ ebpv , $ ehpv [ 0 ] , $ astrom ) ; } | - - - - - - - - - - i a u A p c g 1 3 - - - - - - - - - - |
19,680 | public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( StructureNodeParentTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ gossi \ trixionary \ model \ StructureNodeParent ) { $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( StructureNodeParentTableMap :: DATABASE_NAME ) ; if ( count ( $ values ) == count ( $ values , COUNT_RECURSIVE ) ) { $ values = array ( $ values ) ; } foreach ( $ values as $ value ) { $ criterion = $ criteria -> getNewCriterion ( StructureNodeParentTableMap :: COL_STRUCTURE_NODE_ID , $ value [ 0 ] ) ; $ criterion -> addAnd ( $ criteria -> getNewCriterion ( StructureNodeParentTableMap :: COL_PARENT_ID , $ value [ 1 ] ) ) ; $ criteria -> addOr ( $ criterion ) ; } } $ query = StructureNodeParentQuery :: create ( ) -> mergeWith ( $ criteria ) ; if ( $ values instanceof Criteria ) { StructureNodeParentTableMap :: clearInstancePool ( ) ; } elseif ( ! is_object ( $ values ) ) { foreach ( ( array ) $ values as $ singleval ) { StructureNodeParentTableMap :: removeInstanceFromPool ( $ singleval ) ; } } return $ query -> delete ( $ con ) ; } | Performs a DELETE on the database given a StructureNodeParent or Criteria object OR a primary key value . |
19,681 | public static function doInsert ( $ criteria , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( StructureNodeParentTableMap :: DATABASE_NAME ) ; } if ( $ criteria instanceof Criteria ) { $ criteria = clone $ criteria ; } else { $ criteria = $ criteria -> buildCriteria ( ) ; } $ query = StructureNodeParentQuery :: create ( ) -> mergeWith ( $ criteria ) ; return $ con -> transaction ( function ( ) use ( $ con , $ query ) { return $ query -> doInsert ( $ con ) ; } ) ; } | Performs an INSERT on the database given a StructureNodeParent or Criteria object . |
19,682 | public static function toInt ( string $ str ) : int { $ result = 0 ; $ str = mb_convert_kana ( self :: replaceRoman ( $ str ) , 'a' ) ; foreach ( self :: $ romans as $ key => $ value ) { while ( mb_strpos ( $ str , $ key ) === 0 ) { $ result += $ value ; $ str = mb_substr ( $ str , strlen ( $ key ) ) ; } } return $ result ; } | convert roman numerals to decimal |
19,683 | public static function toRoman ( int $ num ) : string { $ result = '' ; foreach ( self :: $ romans as $ roman => $ value ) { $ matches = intval ( $ num / $ value ) ; $ result .= str_repeat ( $ roman , $ matches ) ; $ num = $ num % $ value ; } return $ result ; } | convert decimal to roman numerals |
19,684 | public function solr_client ( ) { if ( ! isset ( $ this -> _solrclient ) ) { $ this -> _solrclient = new \ Solarium \ Client ( array ( 'endpoint' => array ( 'localhost' => array ( 'host' => $ this -> _url , 'port' => $ this -> _solr_port , 'path' => '/solr/' . $ this -> _collection . '/' ) ) ) ) ; } return $ this -> _solrclient ; } | Returns the SOLR client . |
19,685 | protected function build_rest_url ( $ url , $ params = array ( ) ) { $ base = '' ; if ( substr ( $ this -> _url , 0 , 4 ) !== 'http' ) { $ base .= 'http://' ; } $ base .= $ this -> _url ; if ( $ this -> _port != 80 ) { $ base .= ':' . $ this -> _port ; } $ rurl = new \ Rapid \ URL ( $ base . '/api/' . $ url , $ params ) ; return $ rurl -> out ( ) ; } | Build a REST URL . |
19,686 | protected function api_call ( $ url , $ params ) { $ url = $ this -> build_rest_url ( $ url , $ params ) ; $ result = $ this -> curl ( $ url ) ; return json_decode ( $ result ) ; } | Shorthand for API call . |
19,687 | public function get_images ( ) { $ results = $ this -> api_call ( 'images.php' , array ( 'collection' => $ this -> get_type ( ) ) ) ; return array_map ( function ( $ o ) { return $ this -> get_image ( $ o ) ; } , $ results ) ; } | Returns a list of images in the collection . |
19,688 | public function setShared ( $ name , $ isShared ) { $ cName = $ this -> canonicalizeName ( $ name ) ; $ this -> shared [ $ cName ] = ( bool ) $ isShared ; return $ this ; } | Custom setShared implementation . |
19,689 | public function setInvokableClass ( $ name , $ invokableClass , $ shared = null ) { $ invokableClass = strtr ( $ invokableClass , '.' , '\\' ) ; return parent :: setInvokableClass ( $ name , $ invokableClass , $ shared ) ; } | Auto convert dottet class names to PHP class names |
19,690 | protected function parseParameters ( $ parsed ) { $ command = strtoupper ( $ parsed [ 'command' ] ) ; if ( ! array_key_exists ( $ command , $ this -> paramsRegex ) ) { return $ parsed ; } if ( ! preg_match ( $ this -> paramsRegex [ $ command ] , $ parsed [ 'params' ] , $ params ) ) { return $ parsed ; } $ parsed = array_merge ( $ parsed , $ params ) ; if ( $ command == 353 && array_key_exists ( 'users' , $ parsed ) ) { $ parsed [ 'users' ] = explode ( ' ' , $ parsed [ 'users' ] ) ; } return $ this -> removeIntegerKeys ( $ parsed ) ; } | Checks each message and runs the parameters through regex . |
19,691 | public function parse ( $ message ) { if ( strpos ( $ message , "\r\n" ) === false ) { return ; } if ( ! preg_match ( $ this -> messageRegex , $ message , $ parsed ) ) { $ parsed = [ 'invalid' => $ message ] ; return $ parsed ; } $ parsed [ 'raw' ] = $ parsed [ 0 ] ; $ parsed = $ this -> parseParameters ( $ parsed ) ; return $ this -> removeIntegerKeys ( $ parsed ) ; } | Main parsing function . |
19,692 | public function setMenu ( DropDownMenu $ menu ) { if ( $ this -> menu instanceof DropDownMenu ) { Checkers :: notice ( 'A dropdown menu already exists. The old one will be delete.' ) ; } $ this -> menu = $ menu ; return $ this ; } | Attach a dropdown menu |
19,693 | public function getMenuAttributes ( ) : array { if ( $ this -> menu !== null ) { $ attrs = [ ] ; if ( $ this -> menu -> getOrientationClass ( ) == 'dropdown' ) { $ attrs [ 'id' ] = $ this -> menu -> getLabelledBy ( ) ; } $ attrs [ 'data-toggle' ] = 'dropdown' ; $ attrs [ 'aria-haspopup' ] = 'true' ; $ attrs [ 'aria-expanded' ] = 'false' ; return $ attrs ; } return [ ] ; } | Attributes to add to attached element |
19,694 | public function setEnableAll ( ) { foreach ( $ this -> snippets as $ name => $ config ) { $ this -> setEnabled ( $ name ) ; } return $ this ; } | Set Enable All |
19,695 | public function setDisableAll ( ) { foreach ( $ this -> snippets as $ name => $ config ) { $ this -> setDisabled ( $ name ) ; } return $ this ; } | Set Disable All |
19,696 | public function renderSnippet ( $ name ) { if ( ! isset ( $ this -> snippets [ $ name ] ) ) { throw new InvalidArgumentException ( sprintf ( "Cannot find a snippet with name '%s'" , $ name ) ) ; } return $ this -> getView ( ) -> render ( $ this -> snippets [ $ name ] [ 'template' ] , $ this -> snippets [ $ name ] [ 'values' ] ) ; } | Render a single snippet |
19,697 | protected function splitText ( $ part ) { if ( $ part === 'before' || $ part === 'rest' ) { $ parts = explode ( static :: separator , $ this -> text ) ; if ( count ( $ parts ) === 1 && $ part === 'rest' ) { return null ; } return ( $ part === 'before' ) ? current ( $ parts ) : end ( $ parts ) ; } return str_replace ( static :: separator , '' , $ this -> text ) ; } | Splits the text into given part |
19,698 | public function handle ( Client $ client , $ index ) { $ index = $ client -> getIndex ( $ index ) ; if ( ! $ index -> exists ( ) ) { throw new IndexNotFoundException ( $ index ) ; } $ index -> delete ( ) ; } | Handle index deletion command |
19,699 | public function getGuzzleClient ( ) { $ guzzle = $ this -> guzzleClient ; if ( $ this -> retry ) { $ guzzle = $ this -> addRetrySubscriber ( $ guzzle ) ; } return $ guzzle ; } | Getter for guzzle client . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.