idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
11,800
public function run ( $ id = null ) { if ( $ id === null ) { $ model = new Measure ; $ model -> loadDefaultValues ( ) ; } else { $ model = $ this -> controller -> findModel ( $ id ) ; } $ isLoaded = $ model -> load ( \ Yii :: $ app -> request -> post ( ) ) ; $ hasAccess = ( $ model -> isNewRecord && \ Yii :: $ app -> u...
Updates an existing Measure model . If update is successful the browser will be redirected to the view page .
11,801
public function avatar ( $ size = 100 ) { if ( Utilities :: validGravatar ( $ this -> email ) ) { return Utilities :: gavatar ( $ this -> email ) ; } $ color = Packages :: installed ( 'customization' ) ? \ Laralum \ Customization \ Models \ Customization :: first ( ) -> navbar_color : '#1e87f0' ; return MaterialFunctio...
Returns the user avatar .
11,802
public function getLastToken ( $ type , $ key = 'type' ) { return $ this -> token ( ) -> orderBy ( 'tokens.created_at' , 'desc' ) -> where ( $ key , $ type ) -> first ( ) ; }
Get the last Token by the type .
11,803
public function checkToken ( $ token ) { return ( bool ) $ this -> token ( ) -> where ( 'token' , $ token ) -> where ( 'expiration_date' , '>' , Carbon :: now ( ) ) -> count ( ) ; }
Check the token .
11,804
public function createToken ( $ type , $ expire = 60 , $ length = 48 , $ customProperties = null ) { return $ this -> token ( ) -> create ( [ 'token' => $ this -> generateTokenString ( $ length ) , 'expiration_date' => Carbon :: now ( ) -> addMinutes ( $ expire ) , 'type' => $ type , 'custom_properties' => $ customProp...
Create new token and return the instance .
11,805
public static function route ( ) { if ( defined ( 'DACHI_CLI' ) ) return false ; $ uri = Request :: getFullUri ( ) ; $ route = self :: findRoute ( $ uri ) ; self :: performRoute ( $ route ) ; return Template :: render ( ) ; }
Performs routing based upon the loaded routing information and the incoming request
11,806
public static function findRoute ( $ uri ) { if ( self :: $ routes === array ( ) ) self :: load ( ) ; $ count = count ( $ uri ) ; $ position = & self :: $ routes ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( $ i == $ count - 1 ) { if ( isset ( $ position [ $ uri [ $ i ] ] ) && isset ( $ position [ $ uri [ $ i ] ] [...
Find and process a valid route from the uri
11,807
public static function performRoute ( $ route ) { $ api_mode = isset ( $ route [ "api-mode" ] ) ; Request :: setRequestVariables ( $ route [ "variables" ] , $ api_mode ) ; $ controller = new $ route [ "class" ] ; $ response = $ controller -> $ route [ "method" ] ( ) ; if ( ! Request :: isAjax ( ) && ! Request :: isAPI ...
Perform routing based upon the discovered route
11,808
public function readProperties ( $ root = null , $ web = null , $ vendor = null ) { if ( ! $ this -> propertiesRead ) { if ( is_null ( $ root ) ) { if ( is_callable ( [ $ this , 'taskDetermineProjectRoot' ] ) ) { $ this -> taskDetermineProjectRoot ( ) -> run ( ) ; } $ root = $ this -> getConfig ( ) -> get ( 'digipolis....
Read the properties from the YAML files . Determine project and web root if needed .
11,809
public function generateWizard ( $ dataContainer ) { if ( ! isset ( $ GLOBALS [ 'TL_DCA' ] [ $ dataContainer -> table ] [ 'fields' ] [ $ dataContainer -> field ] [ 'eval' ] [ 'coordinates' ] ) ) { return '' ; } return sprintf ( '<a href="#" onclick="$(\'ctrl_%s_toggle\').click();return false;"><img src="%s"></a>' , $ G...
Generate the wizard for the radius widget .
11,810
public static function pull ( $ arr , $ name , $ type = null ) { $ ret = [ ] ; if ( $ type == self :: GETTER ) { $ method = 'get' . $ name ; foreach ( $ arr as $ elem ) { $ ret [ ] = $ elem -> $ method ( ) ; } } elseif ( $ type == self :: OBJ ) { foreach ( $ arr as $ elem ) { $ ret [ ] = $ elem -> $ name ; } } else { f...
Collects value from array
11,811
public static function assoc ( $ arr , $ name , $ type = null ) { $ ret = [ ] ; if ( empty ( $ arr ) ) { return $ ret ; } if ( $ type == self :: GETTER ) { $ method = 'get' . $ name ; foreach ( $ arr as $ elem ) { $ ret [ $ elem -> $ method ( ) ] = $ elem ; } } elseif ( $ type == self :: OBJ ) { foreach ( $ arr as $ el...
Creates associated array
11,812
public static function select ( $ arr , $ includedKeys ) { $ ret = [ ] ; foreach ( $ includedKeys as $ key ) { if ( array_key_exists ( $ key , $ arr ) ) { $ ret [ $ key ] = $ arr [ $ key ] ; } } return $ ret ; }
Create array with given keys
11,813
public function MicroImage ( ) { $ pixel = $ this -> config ( ) -> pixelate ; $ blur = $ this -> config ( ) -> blur ; $ quality = $ this -> config ( ) -> quality ; $ scale = $ this -> config ( ) -> scale ; $ variant = $ this -> owner -> variantName ( __FUNCTION__ , $ pixel , $ blur , $ quality , $ scale ) ; return $ th...
Generates a reduced quality version of the current image
11,814
public function addVisitor ( $ callable , $ condition , $ when = self :: BEFORE ) { $ this -> visitors [ ] = array ( $ when , $ condition , $ callable ) ; return $ this ; }
Add a visitor to the traverser . The node being visited is passed to the second callback to determine whether the first callback should be called with the node . The arguments passed to both callbacks are the current node and the path to the node . The result of the first callback is used to replace the node in the tre...
11,815
private function doTraverse ( $ node , $ path = array ( ) ) { foreach ( $ node as $ name => $ value ) { $ path [ ] = $ name ; $ value = $ this -> doVisit ( $ path , $ value , self :: BEFORE ) ; if ( is_array ( $ value ) ) { $ value = $ this -> doTraverse ( $ value , $ path ) ; } $ value = $ this -> doVisit ( $ path , $...
Recursive traversal implementation
11,816
private function doVisit ( $ path , $ value , $ when ) { foreach ( $ this -> visitors as $ visitor ) { if ( $ visitor [ 0 ] === $ when && call_user_func ( $ visitor [ 1 ] , $ path , $ value ) ) { try { $ value = call_user_func ( $ visitor [ 2 ] , $ path , $ value ) ; } catch ( \ Exception $ e ) { if ( $ path ) { $ path...
Visits the node with all visitors at the specified time .
11,817
protected function get_data ( ) { $ post_type = $ this -> input -> get ( 'post_type' ) ; if ( ! post_type_exists ( $ post_type ) ) { $ this -> error ( sprintf ( $ this -> __ ( 'Post type %s does not exist.' ) , $ post_type ) , 404 ) ; } if ( ! current_user_can ( 'edit_posts' ) ) { $ this -> error ( $ this -> __ ( 'Sorr...
Returns data as array .
11,818
public function reverseTransform ( $ modelData , PropertyPathInterface $ propertyPath , $ value ) { $ unmodified = intval ( $ value [ 'unmodified' ] ) ; if ( $ unmodified === 1 ) { return ; } $ item = null ; if ( isset ( $ value [ 0 ] ) ) { $ id = $ value [ 0 ] ; $ item = $ this -> getRepository ( ) -> find ( $ id ) ; ...
Transforms identifier to entity
11,819
public static function filter ( $ value , bool $ allowNull = false , DateTimeZoneStandard $ timezone = null ) { if ( self :: valueIsNullAndValid ( $ allowNull , $ value ) ) { return null ; } if ( $ value instanceof DateTimeStandard ) { return $ value ; } if ( is_int ( $ value ) || ctype_digit ( $ value ) ) { $ value = ...
Filters the given value into a \ DateTime object .
11,820
public static function format ( DateTimeInterface $ dateTime , string $ format = 'c' ) : string { if ( empty ( trim ( $ format ) ) ) { throw new \ InvalidArgumentException ( '$format is not a non-empty string' ) ; } return $ dateTime -> format ( $ format ) ; }
Filters the give \ DateTime object to a formatted string .
11,821
public function disconnect ( ) { if ( $ this -> state !== self :: STATE_NOT_CONNECTED && $ this -> connection -> isConnected ( ) === true ) { $ tag = $ this -> getNextTag ( ) ; $ this -> connection -> sendData ( "{$tag} LOGOUT" ) ; $ this -> getResponse ( $ tag ) ; $ this -> state = self :: STATE_LOGOUT ; $ this -> sel...
Disconnects the transport from the IMAP server .
11,822
public function listMailboxes ( $ reference = '' , $ mailbox = '*' ) { if ( $ this -> state != self :: STATE_AUTHENTICATED && $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call listMailboxes() when not successfully logged...
Returns an array with the names of the available mailboxes for the user currently authenticated on the IMAP server .
11,823
public function getHierarchyDelimiter ( ) { if ( $ this -> state != self :: STATE_AUTHENTICATED && $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call getDelimiter() when not successfully logged in." ) ; } $ tag = $ this -...
Returns the hierarchy delimiter of the IMAP server useful for handling nested IMAP folders .
11,824
public function listMessages ( $ contentType = null ) { if ( $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call listMessages() on the IMAP transport when a mailbox is not selected." ) ; } $ messageList = array ( ) ; $ mes...
Returns a list of the not deleted messages in the current mailbox .
11,825
public function status ( & $ numMessages , & $ sizeMessages , & $ recent = 0 , & $ unseen = 0 ) { if ( $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call status() on the IMAP transport when a mailbox is not selected." ) ;...
Returns information about the messages in the current mailbox .
11,826
public function listUniqueIdentifiers ( $ msgNum = null ) { if ( $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call listUniqueIdentifiers() on the IMAP transport when a mailbox is not selected." ) ; } $ result = array ( )...
Returns the unique identifiers for the messages from the current mailbox .
11,827
public function countByFlag ( $ flag ) { $ flag = $ this -> normalizeFlag ( $ flag ) ; $ messages = $ this -> searchByFlag ( $ flag ) ; return count ( $ messages ) ; }
Wrapper function to fetch count of messages by a certain flag .
11,828
protected function searchByFlag ( $ flag ) { $ uid = ( $ this -> options -> uidReferencing ) ? self :: UID : self :: NO_UID ; if ( $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Can't call searchByFlag() on the IMAP transport wh...
Returns an array of message numbers from the selected mailbox which have a certain flag set .
11,829
public function capability ( ) { if ( $ this -> state != self :: STATE_NOT_AUTHENTICATED && $ this -> state != self :: STATE_AUTHENTICATED && $ this -> state != self :: STATE_SELECTED && $ this -> state != self :: STATE_SELECTED_READONLY ) { throw new ezcMailTransportException ( "Trying to request capability when not c...
Returns an array with the capabilities of the IMAP server .
11,830
public function expunge ( ) { if ( $ this -> state != self :: STATE_SELECTED ) { throw new ezcMailTransportException ( "Can not issue EXPUNGE command if a mailbox is not selected." ) ; } $ tag = $ this -> getNextTag ( ) ; $ this -> connection -> sendData ( "{$tag} EXPUNGE" ) ; $ response = trim ( $ this -> getResponse ...
Sends an EXPUNGE command to the server .
11,831
protected function getNextTag ( ) { $ tagLetter = substr ( $ this -> currentTag , 0 , 1 ) ; $ tagNumber = intval ( substr ( $ this -> currentTag , 1 ) ) ; $ tagNumber ++ ; if ( $ tagLetter == 'Z' && $ tagNumber == 10000 ) { $ tagLetter = 'A' ; $ tagNumber = 1 ; } if ( $ tagNumber == 10000 ) { $ tagLetter ++ ; $ tagNumb...
Generates the next IMAP tag to prepend to client commands .
11,832
protected function getMessageSectionSize ( $ response ) { $ size = 0 ; preg_match ( '/\{(.*)\}/' , $ response , $ matches ) ; if ( count ( $ matches ) > 0 ) { $ size = ( int ) $ matches [ 1 ] ; } return $ size ; }
Returns the size of a FETCH section in bytes .
11,833
protected function registerEvent ( $ name , Closure $ callback ) { if ( ! isset ( static :: $ dispatcher ) ) { $ this -> initEventDispatcher ( ) ; } static :: $ dispatcher -> listen ( $ name , $ callback ) ; }
Register an event for the dispatcher to listen for .
11,834
protected function fireEvent ( $ name , $ payload = null ) { if ( ! isset ( static :: $ dispatcher ) ) { $ this -> initEventDispatcher ( ) ; } static :: $ dispatcher -> fire ( $ name , $ payload ) ; }
Fire off an event .
11,835
public function clean ( Composer $ composer ) { $ rootPkg = $ composer -> getPackage ( ) ; $ extra = $ rootPkg -> getExtra ( ) ; if ( ! isset ( $ extra [ 'wordpress-install-dir' ] ) ) { return ; } $ filesystem = new Filesystem ( ) ; $ filesystem -> remove ( $ extra [ 'wordpress-install-dir' ] . '/wp-content' ) ; }
Clean up the WordPress installation directory .
11,836
public function copy ( $ target ) { if ( ! parent :: copy ( $ target ) ) return false ; return file_put_contents ( $ target , $ this -> content ) !== false ; }
Copies the text file s content to the local filesystem .
11,837
public function setPermissionNames ( $ any , $ none , $ user , $ anon ) { if ( $ any ) { $ this -> any = $ any ; } if ( $ none ) { $ this -> none = $ none ; } if ( $ user ) { $ this -> user = $ user ; } if ( $ anon ) { $ this -> anon = $ anon ; } }
Set the names of the permissions to use for any none user and anonymous rules . Set any of these to null to continue using the current name .
11,838
public function check ( Request $ request ) { foreach ( $ this -> exemptions as $ exemption ) { try { if ( true === $ this -> checkRule ( $ request , $ exemption ) ) { return true ; } } catch ( BlockadeException $ e ) { } } foreach ( $ this -> rules as $ rule ) { $ this -> checkRule ( $ request , $ rule ) ; } return fa...
Check if a Request has permission to access a resource .
11,839
protected function _commentCB ( $ m ) { $ hasSurroundingWs = ( trim ( $ m [ 0 ] ) !== $ m [ 1 ] ) ; $ m = $ m [ 1 ] ; if ( $ m === 'keep' ) { return '/**/' ; } if ( $ m === '" "' ) { return '/*" "*/' ; } if ( preg_match ( '@";\\}\\s*\\}/\\*\\s+@' , $ m ) ) { return '/*";}}/* */' ; } if ( $ this -> _inHack ) { if ( preg...
Process a comment and return a replacement
11,840
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( $ request -> isMethod ( 'post' ) ) { $ formId = $ request -> request -> getInt ( 'form[form_id]' , 0 , true ) ; if ( $ formId > 0 ) { $ form = $ this -> container -> get ( 'netvlies.form' ) -> get ( $ formId ) ; ...
Checks if a form post request was mad . If so it validates the form input and upon success dispatches the form success event which can be used for further custom handling of the received data .
11,841
public static function is_spam ( array $ values = [ ] ) { $ query_string = self :: make_request ( $ values ) ; if ( ! class_exists ( 'Akismet' ) || ! \ Akismet :: get_api_key ( ) ) { return new \ WP_Error ( 500 , 'Akismet is not active.' ) ; } add_filter ( 'akismet_ua' , [ static :: class , 'get_ua' ] , 9 ) ; $ respons...
Check if data is spam
11,842
public static function make_request ( array $ args = [ ] ) { $ args = wp_parse_args ( [ 'blog' => get_option ( 'home' ) , 'blog_lang' => get_locale ( ) , 'blog_charset' => get_option ( 'blog_charset' ) , 'user_ip' => isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ? $ _SERVER [ 'REMOTE_ADDR' ] : '' , 'user_agent' => isset ( $ _S...
Make request arguments
11,843
public function get ( $ url , $ data = [ ] , $ method = 'post' ) { $ ch = curl_init ( $ this -> gitlab_host . '/api/v3' . $ url ) ; curl_setopt ( $ ch , CURLOPT_HEADER , 0 ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , array ( 'PRIVATE-TOKEN:' . $ this -> private_key ) ) ; if ( $ this -> debug ) { curl_setopt ( $ ch , C...
GRabs data from a URL and json_decodes it
11,844
private function getExampleFileContents ( $ filename ) { $ normalizedPath = null ; foreach ( $ this -> exampleDirectories as $ directory ) { $ exampleFileFromConfig = $ this -> constructExamplePath ( $ directory , $ filename ) ; if ( is_readable ( $ exampleFileFromConfig ) ) { $ normalizedPath = $ exampleFileFromConfig...
Attempts to find the requested example file and returns its contents or null if no file was found .
11,845
public function addGraphMetadata ( GraphNode $ node , GraphMetadataInterface $ data ) { $ this -> nodes [ ] = [ 'node' => $ node , 'object' => $ data , ] ; return $ this ; }
Add OpenGraph metadata
11,846
public function match ( $ method , $ path , callable $ callback ) { $ route = new Route ( mb_strtoupper ( $ method ) , $ path , $ callback ) ; $ this -> _routes [ ] = $ route ; return $ route ; }
Maps a request to a callable .
11,847
public function check ( $ file , $ verify = null ) { if ( $ this -> prepareFile ( $ file ) ) { $ leads = $ this -> leads ( ) ; if ( ! is_null ( $ verify ) ) { if ( isset ( $ leads [ $ verify ] ) ) { return $ this -> checkLead ( $ leads [ $ verify ] ) ; } return false ; } else { foreach ( $ leads as $ lead ) { $ results...
Check the the file against our leads .
11,848
protected function closeCase ( $ ext , $ mime , array $ meta = array ( ) ) { $ this -> caseClosed = true ; $ this -> extension = $ ext ; $ this -> mime = $ mime ; $ this -> metadata = $ meta ; return true ; }
Closes the case by setting protected properties .
11,849
protected function leads ( ) { $ leads = preg_grep ( '/^lead(?<ext>[A-Z0-9]+)$/' , get_class_methods ( $ this ) ) ; $ leads = array_combine ( $ leads , $ leads ) ; $ ext = "lead" . strtoupper ( pathinfo ( $ this -> file , PATHINFO_EXTENSION ) ) ; if ( isset ( $ leads [ $ ext ] ) ) { $ newLeads = [ $ ext => $ leads [ $ ...
Returns an array of file extensions this detective has leads on .
11,850
public function actionCreate ( ) { $ model = new Country ; try { if ( $ model -> load ( $ _POST ) && $ model -> save ( ) ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } elseif ( ! \ Yii :: $ app -> request -> isPost ) { $ model -> load ( $ _GET ) ; } } catch ( \ Exception $ e ) { $ msg = ( isse...
Creates a new Country model . If creation is successful the browser will be redirected to the view page .
11,851
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; if ( $ model -> load ( $ _POST ) && $ model -> save ( ) ) { return $ this -> redirect ( Url :: previous ( ) ) ; } else { return $ this -> render ( 'update' , [ 'model' => $ model , ] ) ; } }
Updates an existing Country model . If update is successful the browser will be redirected to the view page .
11,852
public function actionDelete ( $ id ) { try { $ this -> findModel ( $ id ) -> delete ( ) ; } catch ( \ Exception $ e ) { $ msg = ( isset ( $ e -> errorInfo [ 2 ] ) ) ? $ e -> errorInfo [ 2 ] : $ e -> getMessage ( ) ; \ Yii :: $ app -> getSession ( ) -> addFlash ( 'error' , $ msg ) ; return $ this -> redirect ( Url :: p...
Deletes an existing Country model . If deletion is successful the browser will be redirected to the index page .
11,853
public static function create ( array $ params = [ ] ) { $ assembler = new static ( ) ; if ( ! empty ( $ params ) ) { array_walk ( $ params , function ( $ v , $ k ) use ( $ assembler ) { $ assembler -> $ k ( function ( ) use ( $ v ) { return $ v ; } ) ; } ) ; $ assembler -> assemble ( ) ; } return $ assembler ; }
Static Assembler constructor Returns a new Assembler
11,854
public static function get ( array $ params = [ ] ) { if ( empty ( self :: $ singleton ) ) { self :: $ singleton = static :: create ( $ params ) ; } return self :: $ singleton ; }
Return Singleton instance of Assembler
11,855
public function assemble ( ) { foreach ( $ this -> placeHolders as $ name => $ placeholder ) { if ( ! isset ( $ this -> values [ $ name ] ) ) { $ this -> values [ $ name ] = $ this -> addVars ( $ placeholder ) ; } } return $ this ; }
Run the Assembly not returning any value . Assembly will not overwrite anything already assembled
11,856
public function merge ( Assembler $ other ) { $ refl = new \ ReflectionObject ( $ other ) ; $ reflValues = $ refl -> getProperty ( 'values' ) ; $ reflValues -> setAccessible ( true ) ; $ oValues = $ reflValues -> getValue ( $ other ) ; if ( count ( $ oValues ) == 0 ) { return $ this ; } $ this -> values = array_merge (...
Merge this assembly with another . Obeys the rules of array_merge
11,857
protected function addVars ( \ Closure $ func ) { $ args = ( new \ ReflectionFunction ( $ func ) ) -> getParameters ( ) ; if ( count ( $ args ) === 0 ) { return $ func ( ) ; } $ fArgs = array_map ( function ( $ key ) { return $ this -> values [ $ key ] ; } , array_map ( function ( $ arg ) { return $ arg -> getName ( ) ...
Execute the function assigned to the value binding in values created earlier in the assembly
11,858
protected function leadSVG ( ) { $ sanitizer = new Sanitizer ( ) ; $ dirtySVG = file_get_contents ( $ this -> file ) ; $ cleanSVG = $ sanitizer -> sanitize ( $ dirtySVG ) ; if ( is_string ( $ cleanSVG ) ) { return $ this -> closeCase ( "svg" , "image/svg+xml" ) ; } return false ; }
Checks if thise file is a valid SVG .
11,859
public static function resolve ( $ key ) { if ( $ key == 'B' ) return 0 ; $ dict = static :: $ metric ; if ( preg_match ( static :: IEC_PATTERN , $ key ) ) $ dict = static :: $ binary ; if ( array_key_exists ( $ key , $ dict ) ) return $ dict [ $ key ] ; throw new UnitNotFoundException ( sprintf ( 'Unit "%s" not found'...
Lookup the exponent based on prefix
11,860
public static function unitsAreDifferent ( $ first , $ second ) { return ( preg_match ( UnitResolver :: SI_PATTERN , $ first ) && preg_match ( UnitResolver :: IEC_PATTERN , $ second ) ) || ( preg_match ( UnitResolver :: IEC_PATTERN , $ first ) && preg_match ( UnitResolver :: SI_PATTERN , $ second ) ) ; }
Check if two units are in the same family
11,861
static function getAttributes ( $ obj , $ visibilityFlags = null , $ getterPrefix = 'get' , $ useCamelCase = true , $ convertInternalObjects = false ) { if ( ! isset ( $ obj ) ) { return array ( ) ; } $ flags = null === $ visibilityFlags ? self :: allFlags ( ) : $ visibilityFlags ; $ attributes = array ( ) ; $ reflecti...
Retrieve names and values from the attributes of a object as a map .
11,862
static function getPrivateAttributes ( $ obj , $ getterPrefix = 'get' , $ useCamelCase = true ) { return self :: getAttributes ( $ obj , self :: IS_PRIVATE , $ getterPrefix , $ useCamelCase ) ; }
Retrieve names and values from the private attributes of a object as a map . This method has been kept for backward compatibility .
11,863
static function setAttributes ( array $ map , & $ obj , $ visibilityFlags = null , $ setterPrefix = 'set' , $ useCamelCase = true ) { $ flags = null === $ visibilityFlags ? self :: allFlags ( ) : $ visibilityFlags ; $ reflectionObject = new \ ReflectionObject ( $ obj ) ; $ currentClass = new \ ReflectionClass ( $ obj )...
Set the attribute values of a object .
11,864
static function setPrivateAttributes ( array $ map , & $ obj , $ setterPrefix = 'set' , $ useCamelCase = true ) { self :: setAttributes ( $ map , $ obj , \ RTTI :: IS_PRIVATE , $ setterPrefix , $ useCamelCase ) ; }
Set the attribute values of a object . This method has been kept for backward compatibility .
11,865
public function getResourceIdentifier ( ) { if ( $ this -> resolvedPath !== null ) { return $ this -> resolvedPath ; } elseif ( $ this -> includePath === null ) { return $ this -> file ; } else { foreach ( $ this -> includePath as $ path ) { $ path = rtrim ( $ path , DIRECTORY_SEPARATOR ) ; if ( file_exists ( $ path . ...
returns this template s source filename
11,866
private function read ( ) { $ files = $ this -> getFilesystem ( ) -> allFiles ( app_path ( ) . '/database/seeds' ) ; $ filtered = [ ] ; foreach ( $ files as $ file ) { if ( strpos ( file_get_contents ( $ file -> getPathName ( ) ) , 'extends Seeder' ) != false ) { if ( $ file -> getFileName ( ) != 'DatabaseSeeder.php' )...
Get an array of all the files that is actually compatible with the files we re looking for .
11,867
private function write ( ) { $ content = '' ; foreach ( $ this -> getFiles ( ) as $ file ) { $ content .= '$this->call(\'' . str_replace ( '.php' , '' , $ file ) . '\');' ; } $ databaseSeeder = str_replace ( '{calls}' , $ content , $ this -> getPattern ( ) ) ; $ this -> getFilesystem ( ) -> put ( app_path ( ) . '/datab...
Write the new DatabaseSeeder . php
11,868
public function restore ( ) { $ this -> getFilesystem ( ) -> put ( app_path ( ) . '/database/seeds/DatabaseSeeder.php' , $ this -> getCopied ( ) ) ; $ this -> getFilesystem ( ) -> delete ( app_path ( ) . '/database/seeds/DatabaseSeeder.old' ) ; }
Restore the DatabaseSeeder . php file to it s previous version .
11,869
public function getList ( $ list ) { $ filteredList = [ ] ; foreach ( explode ( ',' , $ list ) as $ item ) { if ( $ item != '' ) { $ filteredList [ ] = $ item ; } } return $ filteredList ; }
Recieves the string list entered by the developer explode it and only return the ones filtered .
11,870
public function only ( $ list ) { $ this -> copy ( ) ; $ this -> readForOnly ( $ list ) ; $ this -> write ( ) ; $ this -> setSeeded ( count ( $ this -> getFiles ( ) ) ) ; return true ; }
Copy the current DatabaseSeeder . php file loop through each file and verify it s idententy with ther files array write the new DatabaseSeeder . php file and return true if it s alright .
11,871
public function get ( $ content , array $ variables = [ ] ) { $ replacements = [ ] ; $ instruction = 'foreach' ; foreach ( $ variables as $ key => $ values ) { $ inner = $ this -> getInnerInstruction ( $ content , $ instruction ) ; foreach ( $ inner as $ config ) { if ( ! str_contains ( $ config [ 'cleared' ] , $ key )...
Gets variables filled notification content
11,872
public function fill ( $ content ) { if ( $ this -> hasInstructions ( $ content ) ) { $ instructions = $ this -> getInstructions ( ) ; foreach ( $ instructions as $ instruction ) { $ content = $ this -> parseInstructions ( $ content , $ instruction ) ; } } return $ this -> fillContent ( $ content ) ; }
fill notification notification content with variables
11,873
protected function hasInstructions ( $ content ) { $ instructionKeys = $ this -> getInstructions ( ) ; foreach ( $ instructionKeys as $ instructionKey ) { if ( str_contains ( $ content , [ '[[' . $ instructionKey . ']]' , '[[/' . $ instructionKey . ']]' ] ) ) { return true ; } } return false ; }
whether notification has instructions
11,874
protected function parseInstructions ( $ content , $ instruction ) { $ twig = new Twig_Environment ( new Twig_Loader_String ( ) ) ; $ sources = $ this -> getStringsBetween ( $ content , "[[{$instruction}]]" , "[[/{$instruction}]]" ) ; foreach ( $ sources as $ source ) { $ toReplace = $ source ; $ source = $ this -> cle...
parsing instructions in notification content
11,875
protected function clearCondition ( $ source ) { $ line = $ this -> getStringBetween ( $ source , '{%' , '%}' ) ; if ( strlen ( $ line ) > 0 ) { return str_replace ( [ '&#39;' , '&nbsp;' ] , [ "'" , ' ' ] , $ source ) ; } return $ source ; }
clear conditions in notification
11,876
public function getStringsBetween ( $ string , $ start , $ end ) { $ lastPos = 0 ; $ positions = array ( ) ; while ( ( $ lastPos = strpos ( $ string , $ start , $ lastPos ) ) !== false ) { $ positions [ ] = $ lastPos ; $ lastPos += strlen ( $ start ) ; } $ lastPos = 0 ; $ positionsEnd = array ( ) ; while ( ( $ lastPos ...
gets list of occurences between two strings
11,877
protected function extractVariables ( $ content ) { preg_match_all ( '/\[\[(.*?)\]\]/' , $ content , $ matches ) ; if ( ! isset ( $ matches [ 0 ] , $ matches [ 1 ] ) ) { return [ ] ; } $ return = [ ] ; $ notifications = \ Antares \ Foundation \ Notification :: getInstance ( ) -> all ( ) ; foreach ( $ matches [ 1 ] as $...
extract variables from notification
11,878
protected function fillContent ( $ content ) { preg_match_all ( '/\[\[(.*?)\]\]/' , $ content , $ matches ) ; if ( ! isset ( $ matches [ 0 ] ) or ! isset ( $ matches [ 1 ] ) ) { return $ content ; } $ notifications = \ Antares \ Foundation \ Notification :: getInstance ( ) -> all ( ) ; foreach ( ( array ) $ matches [ 1...
fills content with notification variables values
11,879
protected function resolveValue ( $ name , $ variables ) { if ( ! empty ( $ variables ) ) { foreach ( $ variables as $ container => $ vars ) { foreach ( $ vars as $ subname => $ var ) { $ value = $ var [ 'value' ] ; if ( is_callable ( $ value ) && $ var [ 'name' ] === $ name ) { return $ value ( $ this -> variables ) ;...
resolve notification variable value
11,880
protected function resolveDataProviderValue ( $ dataProvider ) { preg_match ( "/(.*)@(.*)/" , $ dataProvider , $ matches ) ; if ( ! isset ( $ matches [ 1 ] ) and ! isset ( $ matches [ 2 ] ) ) { return false ; } if ( ! class_exists ( $ matches [ 1 ] ) ) { return false ; } try { $ instance = app ( $ matches [ 1 ] ) ; $ r...
resolve notification variable value from data provider
11,881
protected function findExtensionName ( $ name ) { if ( $ name == 'foundation' ) { return $ name ; } $ extensions = app ( 'antares.memory' ) -> make ( 'component' ) -> get ( 'extensions.active' ) ; foreach ( $ extensions as $ keyname => $ extension ) { if ( $ name == $ extension [ 'name' ] ) { return $ keyname ; } } ret...
get extension key name by name from manifest
11,882
protected function searchCookiesInHeaders ( ) { $ headers = $ this -> holder -> getHeaders ( ) -> get ( 'set-cookie' ) ; foreach ( $ headers as $ header ) { $ cookie = $ this -> createCookieFromHeader ( $ header ) ; if ( $ cookie !== null ) { $ this -> storeCookie ( $ cookie ) ; } } }
Parse headers for cookies .
11,883
public function save ( $ log_dir = '' ) { if ( empty ( $ log_dir ) ) { $ log_dir = \ ROOT . '/private/logs/syslog/' ; } if ( ! is_dir ( $ log_dir ) ) { mkdir ( $ log_dir , 0777 , true ) ; } return file_put_contents ( $ log_dir . date ( 'Y_m_d' ) . '.log' , $ this -> message . "\n" , \ FILE_APPEND ) ; }
Saves data to local logs dir when syslog server is not available
11,884
protected function checkLength ( $ str , $ max_length = '' , $ type = 'packet' ) { $ max_length = $ max_length ? $ max_length : $ this -> max_length ; if ( $ max_length == - 1 ) { return $ str ; } $ strlen = strlen ( $ str ) ; if ( $ strlen > $ max_length ) { throw new \ Exception ( "Syslog " . $ type . " is > " . $ ma...
Checks to make sure the length of something is expected or warn and truncate
11,885
public static function parse ( $ input , $ exceptionOnInvalidType = false , $ objectSupport = false ) { $ file = '' ; if ( strpos ( $ input , "\n" ) === false && is_file ( $ input ) ) { if ( false === is_readable ( $ input ) ) { throw new ParseException ( sprintf ( 'Unable to parse "%s" as the file is not readable.' , ...
Parses YAML into a PHP array .
11,886
protected function getSpacerType ( ) { $ type = "" ; if ( ! $ this -> currObj instanceof Channel || ! $ this -> currObj -> isSpacer ( ) ) { return "none" ; } switch ( $ this -> currObj -> spacerGetType ( ) ) { case ( string ) TeamSpeak3 :: SPACER_SOLIDLINE : $ type .= "solidline" ; break ; case ( string ) TeamSpeak3 ::...
Returns an individual type for a spacer .
11,887
protected function getName ( ) { if ( $ this -> currObj instanceof Channel && $ this -> currObj -> isSpacer ( ) ) { return $ this -> currObj [ "channel_name" ] -> section ( "]" , 1 , 99 ) -> toString ( ) ; } elseif ( $ this -> currObj instanceof Client ) { $ before = array ( ) ; $ behind = array ( ) ; foreach ( $ this ...
Returns a string for the current corpus element which contains the display name for the current TeamSpeak_Node_Abstract object .
11,888
public function store ( $ key , $ data , $ lifetime = 0 ) { $ key = $ this -> namespace . $ key ; $ store = apc_store ( $ key , $ data , $ lifetime ) ; if ( $ store && $ key != $ this -> namespace . $ this -> catalog_key ) { $ this -> catalogKeyAdd ( $ key , $ lifetime ) ; } return $ store ; }
Store the cache data in APC
11,889
private function catalogKeyAdd ( $ key , $ lifetime ) { $ catalog = $ this -> fetch ( $ this -> catalog_key ) ; $ catalog = is_array ( $ catalog ) ? $ catalog : Array ( ) ; $ catalog [ $ key ] = ( $ lifetime == 0 ) ? $ lifetime : $ lifetime + time ( ) ; return $ this -> store ( $ this -> catalog_key , $ catalog ) ; }
Keeps track of the data stored in the cache to make deleting groups of data possible
11,890
public function getOptions ( ) { $ options = array ( ) ; foreach ( $ this -> commandOptions as $ key => $ value ) { $ options [ $ key ] = $ this -> $ value ; } return $ options ; }
Returns a two dimensional array of options to pass to the command The key is the
11,891
public function getArguments ( ) { $ arguments = array ( ) ; foreach ( $ this -> commandArguments as $ argument ) { $ arguments [ ] = $ this -> $ argument ; } return $ arguments ; }
Returns a one dimensional array of arguments to pass to the command
11,892
public function commonApplicationAttributes ( ) { return [ 'modules' => [ 'users' => [ 'emailConfirmationNeeded' => ( bool ) $ this -> emailConfirmationNeeded , 'allowLoginInactiveAccounts' => ( bool ) $ this -> allowLoginInactiveAccounts , 'enableSocialNetworks' => ( bool ) $ this -> enableSocialNetworks , 'logLastLog...
Returns array of module configuration that should be stored in application config . Array should be ready to merge in app config . Used both for web and console .
11,893
public function socialLogin ( $ serviceName ) { if ( config ( 'services.' . $ serviceName ) ) { $ this -> setDynamicRedirectUrl ( $ serviceName ) ; return $ this -> socialite -> driver ( $ serviceName ) -> redirect ( ) ; } return redirect ( '/' ) ; }
Function responsible for login the user by the given social service .
11,894
public function socialCallback ( Request $ request , $ serviceName ) { try { $ this -> setDynamicRedirectUrl ( $ serviceName ) ; $ user = $ this -> socialite -> driver ( $ serviceName ) -> user ( ) ; $ this -> authService -> login ( $ serviceName , $ user ) ; return redirect ( session ( 'url.intended' , '/' ) ) ; } cat...
Function responsible for handle a callback request from the given social service .
11,895
protected function registerPlugin ( ) { $ id = $ this -> options [ 'id' ] ; $ view = $ this -> getView ( ) ; yii2instafeedAsset :: register ( $ view ) ; $ js = array ( ) ; $ options = Json :: encode ( $ this -> clientOptions ) ; $ js [ ] = "var feed$id = new Instafeed($options);" ; $ js [ ] = "feed$id.run();" ; $ view ...
Registers a specific dhtmlx widget and the related events
11,896
public function salvarArquivo ( $ arquivo ) { $ this -> verificaChaveNula ( ) ; $ xml = file_get_contents ( __DIR__ . '/../Templates/certificado.xml' ) ; $ xml = str_replace ( '{{chave_pub}}' , $ this -> chavePub , $ xml ) ; $ xml = str_replace ( '{{chave_pri}}' , $ this -> chavePri , $ xml ) ; file_put_contents ( $ ar...
Salva um arquivo com as propriedades do certificado .
11,897
public function getValidade ( ) { $ this -> verificaChaveNula ( ) ; $ data = openssl_x509_read ( $ this -> chavePub ) ; $ certData = openssl_x509_parse ( $ data ) ; return Carbon :: createFromFormat ( 'ymdHis' , str_replace ( 'Z' , '' , $ certData [ 'validTo' ] ) ) ; }
Retorna a data e hora da validade do certificado .
11,898
public function getFollows ( $ user , $ params = [ ] ) { $ defaults = [ 'limit' => 25 , 'offset' => 0 , 'direction' => 'desc' , 'sortby' => 'created_at' , ] ; return $ this -> wrapper -> request ( 'GET' , "users/$user/follows/channels" , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults ) ] ) ; }
Returns a list of follows objects .
11,899
public function channel ( $ bind = [ ] ) : Observable { $ this -> bunny = $ this -> bunny ?? new BaseAsynchClient ( $ this -> loop , $ this -> configuration ) ; if ( ! \ is_array ( $ bind ) ) { $ bind = \ func_get_args ( ) ; } return Observable :: fromPromise ( $ this -> bunny -> connect ( ) -> then ( function ( BaseAs...
Open a new channel and attribute it to given queues or exchanges .