idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
46,700
private function getResourceUrlArray ( ) { if ( is_a ( $ this -> target -> urls , Collection :: class ) ) { return $ this -> target -> urls -> toArray ( ) ; } return ( array ) $ this -> target -> urls ; }
Get array of resource urls .
46,701
private function checkWebPage ( $ url , $ ssl = false ) { $ success = $ this -> requestSuccessful ( $ url , $ ssl ) ; return [ $ success , $ success ? '' : $ this -> getErrorMessage ( ) ] ; }
Check web pages .
46,702
private function fetchResponse ( $ url , $ ssl ) { $ this -> url = $ url ; return ( new Guzzle ( ) ) -> request ( 'GET' , $ this -> url , $ this -> getConnectionOptions ( $ ssl ) ) ; }
Send an http request and fetch the response .
46,703
private function getErrorMessage ( ) { $ message = $ this -> target -> resource -> timeoutMessage ; return sprintf ( $ message , $ this -> url , $ this -> totalTime , $ this -> getRoundtripTimeout ( ) ) ; }
Get the error message .
46,704
private function requestSuccessful ( $ url , $ ssl ) { return $ this -> fetchResponse ( $ url , $ ssl ) -> getStatusCode ( ) == 200 && ! $ this -> requestTimedout ( ) ; }
Send a request and get the result .
46,705
public static function factory ( Collection $ data ) { $ instance = new static ( ) ; $ instance -> id = ( string ) Uuid :: uuid4 ( ) ; $ instance -> name = $ data [ 'name' ] ; $ instance -> slug = str_slug ( $ data [ 'name' ] ) ; $ instance -> graphEnabled = isset ( $ data [ 'graph_enabled' ] ) ? $ data [ 'graph_enable...
Resource factory .
46,706
public function instantiateTargets ( Collection $ targets ) { if ( $ targets -> isEmpty ( ) ) { return collect ( [ Target :: factory ( $ this , $ targets ) ] ) ; } $ current = collect ( ) ; $ targets = $ targets -> map ( function ( Collection $ targetList ) { return $ targetList -> map ( function ( $ target , $ name ) ...
Instantiate all checkers for a resource .
46,707
public function check ( $ action = 'resource' ) { $ this -> setCurrentAction ( $ action ) -> targets -> each ( function ( Target $ target ) { $ target -> check ( $ target ) ; } ) ; $ this -> notify ( ) ; return $ this ; }
Check all targets for a resource .
46,708
public function isHealthy ( ) { return $ this -> targets -> reduce ( function ( $ carry , $ target ) { return $ carry && $ target -> result -> healthy ; } , true ) ; }
Check if is healthy .
46,709
public function checkResources ( $ force = false ) { if ( ! ( $ resources = $ this -> getCachedResources ( $ force ) ) -> isEmpty ( ) ) { return $ resources ; } if ( ! $ this -> allResourcesAreGood ( ) ) { return $ this -> resources = collect ( ) ; } $ resources = $ this -> sortResources ( $ this -> getNonGlobalResourc...
Check all resources .
46,710
public function checkResource ( $ resource ) { $ resource = $ resource instanceof Resource ? $ resource : $ this -> getResourceBySlug ( $ resource ) ; $ checked = $ this -> cache -> remember ( $ resource -> slug , function ( ) use ( $ resource ) { return $ resource -> check ( $ this -> getCurrentAction ( ) ) ; } ) ; $ ...
Check a resource .
46,711
protected function makeResult ( $ exception , $ resourceChecker ) { $ message = $ exception -> getMessage ( ) ? $ exception -> getMessage ( ) : static :: UNKNOWN_ERROR ; if ( ! isset ( $ resourceChecker ) ) { return [ null , [ 'healthy' => false , 'message' => $ message , ] , ] ; } $ resourceChecker -> makeResult ( fal...
Make the result array .
46,712
public function flush ( $ force = false , $ key = null ) { if ( ! isset ( $ this -> flushed [ $ key ] ) && ( $ force || $ this -> needsToFlush ( ) ) ) { try { $ this -> forceFlush ( $ key ) ; } catch ( Exception $ exception ) { report ( $ exception ) ; } $ this -> flushed [ $ key ] = true ; } }
Flush cache .
46,713
public function cacheResources ( $ resources ) { if ( $ this -> cacheIsEnabled ( ) ) { IlluminateCache :: put ( config ( 'health.cache.key' ) , $ resources , $ this -> getMinutes ( ) ) ; } return $ resources ; }
Cache all resources .
46,714
private function configurePaths ( ) { $ this -> publishes ( [ __DIR__ . '/config/health.php' => config_path ( 'health/config.php' ) , __DIR__ . '/config/resources/' => config_path ( 'health/resources/' ) , ] , 'config' ) ; $ this -> publishes ( [ __DIR__ . '/resources/views/' => resource_path ( 'views/vendor/pragmarx/h...
Configure package paths .
46,715
private function createHealthService ( ) { $ resourceChecker = call_user_func ( $ this -> resourceCheckerClosure ) ; $ cache = call_user_func ( $ this -> cacheClosure ) ; $ this -> healthServiceClosure = function ( ) use ( $ resourceChecker , $ cache ) { return $ this -> instantiateService ( $ resourceChecker , $ cache...
Create health service .
46,716
private function createResourceChecker ( ) { $ this -> resourceLoader = new ResourceLoader ( new Yaml ( ) ) ; $ this -> cacheClosure = $ this -> getCacheClosure ( ) ; $ this -> resourceCheckerClosure = $ this -> getResourceCheckerClosure ( $ this -> resourceLoader , call_user_func ( $ this -> cacheClosure ) ) ; }
Create resource checker .
46,717
private function getResourceCheckerClosure ( $ resourceLoader , $ cache ) { $ resourceCheckerInstance = function ( ) use ( $ resourceLoader , $ cache ) { return new ResourceChecker ( $ resourceLoader , $ cache ) ; } ; return $ resourceCheckerInstance ; }
Get the resource checker closure for instantiation .
46,718
private function mergeConfig ( ) { if ( file_exists ( config_path ( '/health/config.php' ) ) ) { $ this -> mergeConfigFrom ( config_path ( '/health/config.php' ) , 'health' ) ; } $ this -> mergeConfigFrom ( __DIR__ . '/config/health.php' , 'health' ) ; $ this -> addDistPathToConfig ( ) ; }
Merge configuration .
46,719
private function registerTasks ( ) { if ( config ( 'health.scheduler.enabled' ) && ( $ frequency = config ( 'health.scheduler.frequency' ) ) && config ( 'health.notifications.enabled' ) ) { $ scheduler = instantiate ( Schedule :: class ) ; $ scheduler -> call ( $ this -> healthService -> getSilentChecker ( ) ) -> $ fre...
Register scheduled tasks .
46,720
private function getEnabledResources ( $ resources ) { if ( is_array ( $ filters = config ( $ configKey = 'health.resources.enabled' ) ) ) { return collect ( $ resources ) -> filter ( function ( $ resource , $ name ) use ( $ filters ) { foreach ( $ filters as $ filter ) { if ( preg_match ( "|^$filter$|" , $ name ) ) { ...
Get enabled resources .
46,721
private function loadResourceFiles ( ) { return $ this -> replaceExecutableCode ( $ this -> loadResourcesFiles ( ) ) -> mapWithKeys ( function ( $ value , $ key ) { return [ $ this -> removeExtension ( $ key ) => $ value ] ; } ) ; }
Load resources in files .
46,722
private function replaceExecutableCode ( $ files ) { return $ files -> map ( function ( $ item ) { return collect ( $ item ) -> map ( function ( $ value ) { return ( new Resolver ( ) ) -> recursivelyFindAndReplaceExecutableCode ( $ value ) ; } ) -> all ( ) ; } ) ; }
Replace executable code .
46,723
private function loadResourcesFiles ( ) { $ files = $ this -> yaml -> loadFromDirectory ( config ( 'health.resources.path' ) ) ; $ files = $ files -> count ( ) == 0 ? $ this -> yaml -> loadFromDirectory ( package_resources_dir ( ) ) : $ files ; return $ files ; }
Load resource files .
46,724
private function sanitizeResources ( $ resources ) { return $ resources -> map ( function ( $ resource ) { return collect ( $ resource ) -> mapWithKeys ( function ( $ value , $ key ) { return [ $ this -> sanitizeKey ( $ key ) => $ value ] ; } ) ; } ) ; }
Sanitize resources .
46,725
public static function factory ( $ resource , $ data , $ name = null ) { $ instance = new static ( ) ; $ instance -> id = ( string ) Uuid :: uuid4 ( ) ; $ instance -> name = self :: makeName ( $ data , $ name ) ; $ instance -> display = $ instance -> name ; $ instance -> resource = $ resource ; $ instance -> importProp...
Target factory .
46,726
public function check ( ) { try { try { $ this -> result ( $ this -> resource -> checker -> setTarget ( $ this ) -> checkTarget ( $ this ) ) ; } catch ( \ Exception $ exception ) { report ( $ exception ) ; $ this -> exceptionResult ( $ exception ) ; } } catch ( \ Throwable $ error ) { report ( $ error ) ; $ this -> exc...
Check a resource target .
46,727
protected function moveChecksBackToTarget ( ) { if ( isset ( $ this -> result -> checks ) ) { $ this -> checks = $ this -> result -> checks ; unset ( $ this -> result -> checks ) ; } }
Move checks to target object .
46,728
protected function result ( $ result ) { $ this -> result = $ result instanceof Result ? $ result : new Result ( $ result [ 'healthy' ] , $ result [ 'exception_message' ] ) ; return $ this -> result ; }
Make a result .
46,729
protected function horizonIsRunning ( ) { if ( ! $ masters = app ( MasterSupervisorRepository :: class ) -> all ( ) ) { return false ; } return collect ( $ masters ) -> contains ( function ( $ master ) { return $ master -> status === 'paused' ; } ) ? false : true ; }
Check if Horizon is up .
46,730
protected function outputToCollection ( string $ output ) { if ( $ this -> target -> resource -> jsonResult ) { return collect ( json_decode ( $ output , true ) ?? collect ( [ ] ) ) ; } return $ output ; }
Convert output to array .
46,731
protected function makeCommand ( ) { return sprintf ( '%s %s' , $ this -> target -> resource -> binary , $ this -> target -> resource -> command ) ; }
Get the ping binary .
46,732
protected function executeCommand ( ) { $ process = new SymfonyProcess ( $ this -> makeCommand ( ) , $ this -> target -> workingDir ) ; $ process -> run ( ) ; $ output = $ this -> outputToCollection ( $ process -> getOutput ( ) ) ; if ( $ output -> count ( ) == 0 ) { return $ output ; } if ( $ rootItem = $ this -> targ...
Execute the Composer command .
46,733
public function check ( ) { $ healthy = $ this -> isHealthy ( ) ; return $ this -> makeResult ( $ healthy , $ healthy ? '' : $ this -> target -> getErrorMessage ( ) ) ; }
Check health .
46,734
private function computeHealth ( $ previous , $ resource ) { return $ resource -> isGlobal ? $ previous : $ previous && $ this -> computeHealthForAllTargets ( $ resource ) ; }
Compute health .
46,735
private function computeHealthForAllTargets ( $ resource ) { return $ resource -> targets -> reduce ( function ( $ carry , $ target ) { return $ target -> result -> healthy ; } , true ) ; }
Compute health for targets .
46,736
protected function isHealthy ( ) { $ healthy = $ this -> target -> resource -> resources -> reduce ( function ( $ carry , $ item ) { return $ this -> computeHealth ( $ carry , $ item ) ; } , true ) ; return $ healthy ; }
Check if the resource is healty .
46,737
public function check ( ) { if ( $ this -> portIsNotConnectable ( $ ipAddress = ip_address_from_hostname ( $ this -> target -> hostname ) ) ) { return $ this -> makeFinalResult ( $ ipAddress ) ; } return $ this -> makeHealthyResult ( ) ; }
Check the target .
46,738
protected function makeFinalResult ( $ ipAddress ) { return $ this -> target -> setResult ( $ this -> makeResult ( false , sprintf ( $ this -> target -> getErrorMessage ( ) , $ this -> hosnameAndIp ( $ this -> target -> hostname , $ ipAddress ) , $ this -> target -> port ) ) ) -> getResult ( ) ; }
Make the result .
46,739
public function __getToArrayCallBack ( ) { return function ( $ subject ) { static :: $ __depth ++ ; if ( $ subject instanceof Arrayable ) { $ subject = $ subject -> toArray ( ) ; } if ( is_object ( $ subject ) ) { $ subject = get_object_vars ( $ subject ) ; } if ( is_array ( $ subject ) ) { if ( static :: $ __depth <= ...
Generate a callback to transform object to array .
46,740
protected function dispatchEvent ( ) { event ( new HealthPing ( $ this -> target -> channel , route ( $ this -> target -> routeName , [ $ this -> target -> secret ] ) , $ this -> target ) ) ; }
Dispatch event .
46,741
public function pong ( $ secret ) { $ this -> database = $ this -> database -> map ( function ( $ item ) use ( $ secret ) { if ( $ item [ 'secret' ] == $ secret ) { $ item [ 'ponged_at' ] = Carbon :: now ( ) ; } return $ item ; } ) ; $ this -> persist ( ) ; }
Create and persist pong .
46,742
protected function pingTimedout ( ) { $ timedout = false ; $ this -> database = $ this -> database -> filter ( function ( $ item ) use ( & $ timedout ) { if ( ! $ item [ 'ponged_at' ] ) { if ( Carbon :: now ( ) -> diffInSeconds ( $ this -> parseDate ( $ item [ 'pinged_at' ] ) ) > $ this -> target -> timeout ) { $ timed...
Check if a ping timed out .
46,743
private function checkMail ( ) { $ this -> configureMail ( ) ; try { $ this -> sendMail ( ) ; $ result = $ this -> makeHealthyResult ( ) ; } catch ( \ Exception $ exception ) { report ( $ exception ) ; $ result = $ this -> makeResultFromException ( $ exception ) ; } $ this -> restoreMailConfiguration ( ) ; return $ res...
Send a test e - mail .
46,744
private function sendMail ( ) { IlluminateMail :: send ( $ this -> target -> view , [ ] , function ( $ message ) { $ fromAddress = array_get ( $ this -> target -> config , 'from.address' ) ; $ message -> returnPath ( $ fromAddress ) ; $ message -> cc ( $ fromAddress ) ; $ message -> bcc ( $ fromAddress ) ; $ message ->...
Send a test e - mail message .
46,745
public function toSlack ( $ notifiable ) { return ( new SlackMessage ( ) ) -> error ( ) -> from ( config ( 'health.notifications.from.name' ) , config ( 'health.notifications.from.icon_emoji' ) ) -> content ( $ this -> getMessage ( ) ) -> attachment ( function ( $ attachment ) { $ attachment -> title ( $ this -> getAct...
Create Slack message .
46,746
public function toMail ( $ notifiable ) { return ( new MailMessage ( ) ) -> line ( $ this -> getMessage ( $ notifiable ) ) -> from ( config ( 'health.notifications.from.address' ) , config ( 'health.notifications.from.name' ) ) -> action ( $ this -> getActionTitle ( ) , $ this -> getActionLink ( ) ) ; }
Create Mail message .
46,747
protected function getMessage ( ) { $ domain = Request :: server ( 'SERVER_NAME' ) ; return sprintf ( $ this -> getActionMessage ( $ this ) , studly_case ( $ this -> resource -> name ) , $ domain ? " in {$domain}." : '.' ) ; }
Get failing message .
46,748
protected function sort ( $ builder ) { if ( count ( $ builder -> orders ) == 0 ) { return null ; } return collect ( $ builder -> orders ) -> map ( function ( $ order ) { return [ $ order [ 'column' ] => $ order [ 'direction' ] ] ; } ) -> toArray ( ) ; }
Generates the sort if theres any .
46,749
public function findValidOTP ( $ secret , $ key , $ window , $ startingTimestamp , $ timestamp , $ oldTimestamp = Constants :: ARGUMENT_NOT_SET ) { for ( ; $ startingTimestamp <= $ timestamp + $ this -> getWindow ( $ window ) ; $ startingTimestamp ++ ) { if ( hash_equals ( $ this -> oathHotp ( $ secret , $ startingTime...
Find a valid One Time Password .
46,750
private function makeStartingTimestamp ( $ window , $ timestamp , $ oldTimestamp ) { return $ oldTimestamp === Constants :: ARGUMENT_NOT_SET ? $ timestamp - $ this -> getWindow ( $ window ) : max ( $ timestamp - $ this -> getWindow ( $ window ) , $ oldTimestamp + 1 ) ; }
Make a window based starting timestamp .
46,751
public function oathTruncate ( $ hash ) { $ offset = ord ( $ hash [ 19 ] ) & 0xf ; $ temp = unpack ( 'N' , substr ( $ hash , $ offset , 4 ) ) ; return substr ( $ temp [ 1 ] & 0x7fffffff , - $ this -> getOneTimePasswordLength ( ) ) ; }
Extracts the OTP from the SHA1 hash .
46,752
public function generateBase32RandomKey ( $ length = 16 , $ prefix = '' ) { $ secret = $ prefix ? $ this -> toBase32 ( $ prefix ) : '' ; $ secret = $ this -> strPadBase32 ( $ secret , $ length ) ; $ this -> validateSecret ( $ secret ) ; return $ secret ; }
Generate a digit secret key in base32 format .
46,753
public function base32Decode ( $ b32 ) { $ b32 = strtoupper ( $ b32 ) ; $ this -> validateSecret ( $ b32 ) ; return ParagonieBase32 :: decodeUpper ( $ b32 ) ; }
Decodes a base32 string into a binary string .
46,754
private function strPadBase32 ( $ string , $ length ) { for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ string .= substr ( Constants :: VALID_FOR_B32_SCRAMBLED , $ this -> getRandomNumber ( ) , 1 ) ; } return $ string ; }
Pad string with random base 32 chars .
46,755
public function finalize ( ) { $ this -> query = array_filter ( $ this -> query , function ( $ value ) { return ! empty ( $ value ) || is_bool ( $ value ) || is_numeric ( $ value ) ; } ) ; return $ this ; }
Perform any final clean up . Remove any empty values to avoid errors .
46,756
public function filter ( & $ store ) { foreach ( $ store as $ key => & $ value ) { $ value = is_string ( $ value ) ? trim ( $ value ) : $ value ; $ empty = $ value === null || ( is_array ( $ value ) && empty ( $ value ) ) ; $ empty = $ empty || ( is_scalar ( $ value ) && $ value !== false && ( string ) $ value === '' )...
Set empty values to NULL since DynamoDB does not like empty values .
46,757
public function chunk ( $ chunkSize , callable $ callback ) { while ( true ) { $ results = $ this -> getAll ( [ ] , $ chunkSize , false ) ; if ( ! $ results -> isEmpty ( ) ) { if ( call_user_func ( $ callback , $ results ) === false ) { return false ; } } if ( empty ( $ this -> lastEvaluatedKey ) ) { break ; } } return...
Implements the Query Chunk method
46,758
public function removeAttribute ( ... $ attributes ) { $ keySet = ! empty ( array_filter ( $ this -> model -> getKeys ( ) ) ) ; if ( ! $ keySet ) { $ analyzer = $ this -> getConditionAnalyzer ( ) ; if ( ! $ analyzer -> isExactSearch ( ) ) { throw new InvalidQuery ( 'Need to provide the key in your query' ) ; } $ id = $...
Remove attributes from an existing item
46,759
public function toDynamoDbQuery ( $ columns = [ ] , $ limit = DynamoDbQueryBuilder :: MAX_LIMIT ) { $ this -> applyScopes ( ) ; $ this -> resetExpressions ( ) ; $ op = 'Scan' ; $ queryBuilder = DynamoDb :: table ( $ this -> model -> getTable ( ) ) ; if ( ! empty ( $ this -> wheres ) ) { $ analyzer = $ this -> getCondit...
Return the raw DynamoDb query
46,760
public function saveAsync ( array $ options = [ ] ) { $ create = ! $ this -> exists ; if ( $ this -> fireModelEvent ( 'saving' ) === false ) { return false ; } if ( $ create && $ this -> fireModelEvent ( 'creating' ) === false ) { return false ; } if ( ! $ create && $ this -> fireModelEvent ( 'updating' ) === false ) {...
Saves the model to DynamoDb asynchronously and returns a promise
46,761
public function addCondition ( Filter $ filter , $ attribute , $ partial = false ) { $ value = $ this -> $ attribute ; if ( mb_strpos ( $ value , '>' ) !== false ) { $ value = ( int ) str_replace ( '>' , '' , $ value ) ; $ filter -> addMatcher ( $ attribute , new matchers \ GreaterThan ( [ 'value' => $ value ] ) ) ; } ...
Adds filtering condition for a given attribute
46,762
private function addAccessRules ( ) { $ this -> ruleUserSwitch [ 'controllers' ] = [ $ this -> module -> id . '/user' ] ; $ this -> module -> attachBehavior ( 'access_debug' , [ 'class' => 'yii\filters\AccessControl' , 'only' => [ $ this -> module -> id . '/user' , $ this -> module -> id . '/default' ] , 'user' => $ th...
Add ACF rule . AccessControl attach to debug module . Access rule for main user .
46,763
public function canSearchUsers ( ) { return ( isset ( $ this -> filterModel ) && $ this -> filterModel instanceof Model && $ this -> filterModel -> hasMethod ( 'search' ) ) ; }
Check is available search of users
46,764
public function canSwitchUser ( ) { if ( $ this -> getUser ( ) -> isGuest ) { return false ; } $ allowSwitchUser = false ; $ rule = new AccessRule ( $ this -> ruleUserSwitch ) ; $ userController = null ; $ controller = $ this -> module -> createController ( 'user' ) ; if ( isset ( $ controller [ 0 ] ) && $ controller [...
Check can main user switch identity .
46,765
protected function format ( array $ bundles ) { foreach ( $ bundles as $ bundle ) { array_walk ( $ bundle -> css , function ( & $ file , $ key , $ userData ) { $ file = Html :: a ( $ file , $ userData -> baseUrl . '/' . $ file , [ 'target' => '_blank' ] ) ; } , $ bundle ) ; array_walk ( $ bundle -> js , function ( & $ ...
Additional formatting for view .
46,766
protected function formatOptions ( array & $ params ) { if ( ! is_array ( $ params ) ) { return $ params ; } foreach ( $ params as $ param => $ value ) { $ params [ $ param ] = Html :: tag ( 'strong' , '\'' . $ param . '\' => ' ) . ( string ) $ value ; } return $ params ; }
Format associative array of params to simple value .
46,767
public function actionSetIdentity ( ) { $ user_id = Yii :: $ app -> request -> post ( 'user_id' ) ; $ userSwitch = new UserSwitch ( ) ; $ newIdentity = Yii :: $ app -> user -> identity -> findIdentity ( $ user_id ) ; $ userSwitch -> setUserByIdentity ( $ newIdentity ) ; return Yii :: $ app -> user ; }
Set new identity switch user
46,768
public function getTraceLine ( $ options ) { if ( ! isset ( $ options [ 'text' ] ) ) { $ options [ 'text' ] = "{$options['file']}:{$options['line']}" ; } $ traceLine = $ this -> module -> traceLine ; if ( $ traceLine === false ) { return $ options [ 'text' ] ; } $ options [ 'file' ] = str_replace ( '\\' , '/' , $ optio...
Returns a trace line
46,769
public function calculateTimings ( ) { if ( $ this -> _timings === null ) { $ this -> _timings = Yii :: getLogger ( ) -> calculateTimings ( isset ( $ this -> data [ 'messages' ] ) ? $ this -> data [ 'messages' ] : [ ] ) ; } return $ this -> _timings ; }
Calculates given request profile timings .
46,770
public function sumDuplicateQueries ( $ modelData ) { $ numDuplicates = 0 ; $ duplicates = ArrayHelper :: getColumn ( $ modelData , 'duplicate' ) ; foreach ( $ duplicates as $ duplicate ) { if ( $ duplicate > 1 ) { $ numDuplicates ++ ; } } return $ numDuplicates ; }
Returns sum of all duplicated queries
46,771
protected function getQueryType ( $ timing ) { $ timing = ltrim ( $ timing ) ; preg_match ( '/^([a-zA-z]*)/' , $ timing , $ matches ) ; return count ( $ matches ) ? mb_strtoupper ( $ matches [ 0 ] , 'utf8' ) : '' ; }
Returns database query type .
46,772
public function getTypes ( ) { return array_reduce ( $ this -> _models , function ( $ result , $ item ) { $ result [ $ item [ 'type' ] ] = $ item [ 'type' ] ; return $ result ; } , [ ] ) ; }
Returns array query types
46,773
public function varDump ( $ var ) { if ( is_callable ( $ this -> varDumpCallback ) ) { return call_user_func ( $ this -> varDumpCallback , $ var , $ this ) ; } $ message = VarDumper :: dumpAsString ( $ var , $ this -> depth , $ this -> highlight ) ; if ( ! $ this -> highlight ) { $ message = Html :: encode ( $ message ...
Called by view to format the dumped variable .
46,774
protected function getFlashes ( ) { $ session = Yii :: $ app -> has ( 'session' , true ) ? Yii :: $ app -> get ( 'session' ) : null ; if ( $ session === null || ! $ session -> getIsActive ( ) ) { return [ ] ; } $ counters = $ session -> get ( $ session -> flashParam , [ ] ) ; $ flashes = [ ] ; foreach ( array_keys ( $ ...
Getting flash messages without deleting them or touching deletion counters
46,775
public function setDebugHeaders ( $ event ) { if ( ! $ this -> checkAccess ( ) ) { return ; } $ url = Url :: toRoute ( [ '/' . $ this -> id . '/default/view' , 'tag' => $ this -> logTarget -> tag , ] ) ; $ event -> sender -> getHeaders ( ) -> set ( 'X-Debug-Tag' , $ this -> logTarget -> tag ) -> set ( 'X-Debug-Duration...
Setting headers to transfer debug data in AJAX requests without interfering with the request itself .
46,776
public function getToolbarHtml ( ) { $ url = Url :: toRoute ( [ '/' . $ this -> id . '/default/toolbar' , 'tag' => $ this -> logTarget -> tag , ] ) ; return '<div id="yii-debug-toolbar" data-url="' . Html :: encode ( $ url ) . '" style="display:none" class="yii-debug-toolbar-bottom"></div>' ; }
Gets toolbar HTML
46,777
public function getColor ( $ model ) { $ width = isset ( $ model [ 'css' ] [ 'width' ] ) ? $ model [ 'css' ] [ 'width' ] : $ this -> getWidth ( $ model ) ; foreach ( $ this -> panel -> colors as $ percent => $ color ) { if ( $ width >= $ percent ) { return $ color ; } } return '#d6e685' ; }
Getting HEX color based on model duration
46,778
public function getRulers ( $ line = 10 ) { if ( $ line == 0 ) { return [ ] ; } $ data = [ 0 ] ; $ percent = ( $ this -> panel -> duration / 100 ) ; $ row = $ this -> panel -> duration / $ line ; $ precision = $ row > 100 ? - 2 : - 1 ; for ( $ i = 1 ; $ i < $ line ; $ i ++ ) { $ ms = round ( $ i * $ row , $ precision )...
ruler items key milliseconds value offset left
46,779
protected function gc ( & $ manifest ) { if ( count ( $ manifest ) > $ this -> module -> historySize + 10 ) { $ n = count ( $ manifest ) - $ this -> module -> historySize ; foreach ( array_keys ( $ manifest ) as $ tag ) { $ file = $ this -> module -> dataPath . "/$tag.data" ; @ unlink ( $ file ) ; if ( isset ( $ manife...
Removes obsolete data files
46,780
protected function getSqlTotalCount ( ) { if ( ! isset ( $ this -> module -> panels [ 'db' ] ) ) { return 0 ; } $ profileLogs = $ this -> module -> panels [ 'db' ] -> getProfileLogs ( ) ; return count ( $ profileLogs ) / 2 ; }
Returns total sql count executed in current request . If database panel is not configured returns 0 .
46,781
public function getMainUser ( ) { $ currentUser = $ this -> getUser ( ) ; if ( $ this -> _mainUser === null && $ currentUser -> getIsGuest ( ) === false ) { $ session = Yii :: $ app -> getSession ( ) ; if ( $ session -> has ( 'main_user' ) ) { $ mainUserId = $ session -> get ( 'main_user' ) ; $ mainIdentity = call_user...
Get main user
46,782
public function setUserByIdentity ( IdentityInterface $ identity ) { $ user = clone $ this -> getUser ( ) ; $ user -> setIdentity ( $ identity ) ; $ this -> setUser ( $ user ) ; }
Switch to user by identity
46,783
public function isMainUser ( ) { $ user = $ this -> getUser ( ) ; if ( $ user -> getIsGuest ( ) ) { return true ; } return ( $ user -> getId ( ) === $ this -> getMainUser ( ) -> getId ( ) ) ; }
Checks if current user is main or not .
46,784
public function actionDownloadMail ( $ file ) { $ filePath = Yii :: getAlias ( $ this -> module -> panels [ 'mail' ] -> mailPath ) . '/' . basename ( $ file ) ; if ( ( mb_strpos ( $ file , '\\' ) !== false || mb_strpos ( $ file , '/' ) !== false ) || ! is_file ( $ filePath ) ) { throw new NotFoundHttpException ( 'Mail ...
Download mail action
46,785
private function searchActiveDataProvider ( $ params ) { $ model = $ this -> identityImplement ; $ query = $ model :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , ] ) ; if ( ! ( $ this -> load ( $ params ) && $ this -> validate ( ) ) ) { return $ dataProvider ; } foreach ( $ model :: getT...
Search method for ActiveRecord
46,786
public function addMatcher ( $ name , MatcherInterface $ rule ) { if ( $ rule -> hasValue ( ) ) { $ this -> rules [ $ name ] [ ] = $ rule ; } }
Adds data filtering rule .
46,787
public function filter ( array $ data ) { $ filtered = [ ] ; foreach ( $ data as $ row ) { if ( $ this -> passesFilter ( $ row ) ) { $ filtered [ ] = $ row ; } } return $ filtered ; }
Applies filter on a given array and returns filtered data .
46,788
private function passesFilter ( array $ row ) { foreach ( $ row as $ name => $ value ) { if ( isset ( $ this -> rules [ $ name ] ) ) { foreach ( $ this -> rules [ $ name ] as $ rule ) { if ( ! $ rule -> match ( $ value ) ) { return false ; } } } } return true ; }
Checks if the given data satisfies filters .
46,789
public function getTraceAsString ( ) { $ remove = "Stack trace:\n" ; $ len = strpos ( $ this -> _toString , $ remove ) ; if ( $ len === false ) { return '' ; } return substr ( $ this -> _toString , $ len + strlen ( $ remove ) ) ; }
Gets the stack trace as a string
46,790
private function flattenArgs ( $ args , $ level = 0 , & $ count = 0 ) { $ result = [ ] ; foreach ( $ args as $ key => $ value ) { if ( ++ $ count > 10000 ) { return [ 'array' , '*SKIPPED over 10000 entries*' ] ; } if ( $ value instanceof \ __PHP_Incomplete_Class ) { $ result [ $ key ] = [ 'incomplete-object' , $ this -...
Allows you to sterilize the Exception trace arguments
46,791
protected function buildData ( $ topic , $ message , $ isCondition ) { $ condition = $ isCondition ? [ 'condition' => $ topic ] : [ 'to' => '/topics/' . $ topic ] ; return array_merge ( $ condition , $ this -> buildMessage ( $ message ) ) ; }
Prepare the data to be sent
46,792
public function setService ( $ serviceName ) { if ( ! array_key_exists ( $ serviceName , $ this -> servicesList ) ) { $ serviceName = $ this -> defaultServiceName ; } $ this -> service = new $ this -> servicesList [ $ serviceName ] ; return $ this ; }
Set the Push Service to be used .
46,793
protected function push ( $ service , $ to , $ data , PushMessage $ message ) { $ this -> push -> setMessage ( $ data ) -> setService ( $ service ) -> setDevicesToken ( $ to ) ; if ( ! empty ( $ message -> config ) ) { $ this -> push -> setConfig ( $ message -> config ) ; if ( ! empty ( $ message -> config [ 'apiKey' ]...
Send the push notification .
46,794
protected function buildMessage ( $ notifiable , Notification $ notification ) { $ message = call_user_func_array ( [ $ notification , $ this -> getToMethod ( ) ] , [ $ notifiable ] ) ; if ( is_string ( $ message ) ) { $ message = new PushMessage ( $ message ) ; } return $ message ; }
Format the message .
46,795
protected function broadcast ( ) { if ( function_exists ( 'broadcast' ) ) { broadcast ( new NotificationPushed ( $ this -> push ) ) ; } elseif ( function_exists ( 'event' ) ) { event ( new NotificationPushed ( $ this -> push ) ) ; } }
BroadCast NotificationPushed event
46,796
private function setProperGateway ( ) { if ( isset ( $ this -> config [ 'dry_run' ] ) ) { if ( $ this -> config [ 'dry_run' ] ) { $ this -> setUrl ( $ this -> sandboxUrl ) ; $ this -> feedbackUrl = $ this -> feedbackSandboxUrl ; } else { $ this -> setUrl ( $ this -> productionUrl ) ; $ this -> feedbackUrl = $ this -> f...
Set the correct Gateway url and the Feedback url based on dry_run param .
46,797
private function setRetryAttemptsIfConfigured ( ) { if ( isset ( $ this -> config [ 'connection_attempts' ] ) && is_numeric ( $ this -> config [ 'connection_attempts' ] ) ) { $ this -> maxAttempts = $ this -> config [ 'connection_attempts' ] ; } }
Configure re - try attempts .
46,798
private function canRetry ( ) { if ( $ this -> isUnlimitedAttempts ( ) ) { return true ; } $ this -> attempts ++ ; return $ this -> attempts < $ this -> maxAttempts ; }
Check if can retry a connection
46,799
public function getUnregisteredDeviceTokens ( array $ devices_token ) { $ tokens = [ ] ; if ( ! empty ( $ this -> feedback -> tokenFailList ) ) { $ tokens = $ this -> feedback -> tokenFailList ; } if ( ! empty ( $ this -> feedback -> apnsFeedback ) ) { $ tokens = array_merge ( $ tokens , array_pluck ( $ this -> feedbac...
Provide the unregistered tokens of the notification sent .