idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
28,500 | public function processInputControlSpecification ( \ SimpleXMLElement $ specification ) { $ collection = array ( ) ; foreach ( $ specification -> inputControl as $ key => $ value ) { if ( $ value -> type == 'bool' ) { $ value -> type = 'checkbox' ; } $ inputClass = $ this -> inputControlTypeNamespace . ucfirst ( $ value -> type ) ; try { $ collection [ ] = new $ inputClass ( ( string ) $ value -> id , ( string ) $ value -> label , filter_var ( $ value -> mandatory , FILTER_VALIDATE_BOOLEAN ) , filter_var ( $ value -> readOnly , FILTER_VALIDATE_BOOLEAN ) , ( string ) $ value -> type , ( string ) $ value -> uri , filter_var ( $ value -> visible , FILTER_VALIDATE_BOOLEAN ) , ( object ) $ value -> state , $ this -> getICFrom , $ this -> optionsHandler ) ; } catch ( \ Exception $ e ) { throw $ e ; } } return $ collection ; } | Processes the XML return from the getInputControls call in the client and constructs the collection of input controls as needed |
28,501 | public function hasPushService ( $ host ) : bool { foreach ( $ this -> pushServices as $ pushService ) { if ( $ pushService -> supportsHost ( $ host ) ) { return true ; } } return false ; } | Check whether a push service exists in the registry . |
28,502 | public function getPushService ( $ host ) : PushService { foreach ( $ this -> pushServices as $ pushService ) { if ( $ pushService -> supportsHost ( $ host ) ) { return $ pushService ; } } throw UnsupportedPushService :: forHost ( $ host ) ; } | Get a push service from the registry . |
28,503 | protected function getHash ( ) { return md5 ( sprintf ( '%s %s %s %s' , $ this -> getMethod ( ) , $ this -> getPath ( ) , json_encode ( $ this -> getHeaders ( ) ) , json_encode ( $ this -> getQueryString ( ) ) ) ) ; } | Get a Hash which identify the request |
28,504 | protected function getCacheLifetime ( ResponseHeaderBag $ headers ) { $ maxAge = 0 ; if ( $ headers -> hasCacheControlDirective ( 'max-age' ) ) { $ maxAge = $ headers -> getCacheControlDirective ( 'max-age' ) ; } return $ maxAge ; } | Get the cache lifetime based on the response headers |
28,505 | public function parse ( $ string ) { $ string = $ this -> normalizeWhitespaces ( $ string ) ; if ( $ string === '' ) { throw new arbitCommitParserException ( 'Empty commit message.' ) ; } $ string = $ this -> removeComments ( $ string ) ; if ( $ string === '' ) { return array ( ) ; } return $ this -> parseStatements ( $ string ) ; } | Parse a commit message |
28,506 | protected function parseStatements ( $ string ) { $ lines = explode ( "\n" , $ string ) ; $ statements = array ( ) ; $ statement = null ; foreach ( $ lines as $ line ) { if ( trim ( $ line ) === '' ) { continue ; } $ line = rtrim ( $ line ) ; $ echodLine = '"' . substr ( $ line , 0 , 30 ) . '..."' ; if ( strlen ( $ line ) > 79 ) { throw new arbitCommitParserException ( "Too long line: $echodLine" ) ; } if ( preg_match ( '(^-\\x20 (?# Type of statement ) (?P<type>Refs|Fixed|Closed|Implemented|Documented|Tested) (?# Match optional bug number ) (?:\\x20\\#(?P<bug>[1-9]+[0-9]*))? (?# Match required text line ) (?::\\x20(?P<text>[\x20-\x7E]+))? $)x' , $ line , $ match ) ) { if ( ! isset ( $ match [ 'text' ] ) || empty ( $ match [ 'text' ] ) ) { throw new arbitCommitParserException ( "Textual description missing in line $echodLine" ) ; } if ( in_array ( $ match [ 'type' ] , array ( 'Refs' , 'Fixed' , 'Closed' , ) ) ) { if ( ! isset ( $ match [ 'bug' ] ) || empty ( $ match [ 'bug' ] ) ) { throw new arbitCommitParserException ( "Missing bug number in line: $echodLine" ) ; } } if ( in_array ( $ match [ 'type' ] , array ( 'Tested' , ) ) ) { if ( isset ( $ match [ 'bug' ] ) && ! empty ( $ match [ 'bug' ] ) ) { throw new arbitCommitParserException ( "Superflous bug number in line: $echodLine" ) ; } $ match [ 'bug' ] = null ; } if ( $ statement !== null ) { $ statements [ ] = $ statement ; } $ statement = array ( 'type' => str_replace ( 'Closed' , 'Fixed' , $ match [ 'type' ] ) , 'bug' => $ match [ 'bug' ] , 'text' => $ match [ 'text' ] , ) ; } elseif ( preg_match ( '(^ (?P<text>[\x20-\x7E]+)$)' , $ line , $ match ) ) { if ( $ statement == null ) { throw new arbitCommitParserException ( "No statement precedes text line: $echodLine" ) ; } $ statement [ 'text' ] .= ' ' . $ match [ 'text' ] ; } else { throw new arbitCommitParserException ( "Invalid commit message: $echodLine" ) ; } } return $ statements ; } | Parse all statements |
28,507 | public static function fromString ( $ string ) { try { $ lineBreak = StringUtil :: detectLineBreak ( $ string ) ; } catch ( DifferentLineBreaksFoundException $ e ) { $ lineBreak = $ e -> getNumberLineBreakOther ( ) >= $ e -> getNumberLineBreakWindows ( ) ? StringUtil :: LINE_BREAK_OTHER : StringUtil :: LINE_BREAK_WINDOWS ; } return new static ( StringUtil :: breakIntoLines ( $ string ) , $ lineBreak ) ; } | Creates a Text instance from a string . |
28,508 | public function map ( $ callback ) { if ( ! is_callable ( $ callback ) ) { throw new InvalidArgumentException ( 'Callback has to be a valid callable, ' . gettype ( $ callback ) . ' given.' ) ; } for ( $ i = 0 ; $ this -> checkIfLineNumberIsValid ( $ i , false ) ; $ i ++ ) { $ this -> setCurrentLineNumber ( $ i ) ; call_user_func ( $ callback , $ this -> getLine ( $ i ) , $ i , $ this ) ; } } | Calls the given callback for each line in Text . |
28,509 | private function connect ( ) { if ( ! empty ( $ this -> token ) ) { return ; } $ this -> token = $ this -> soapClient -> login ( $ this -> user , $ this -> password ) ; } | Login to Jira |
28,510 | protected function getJql ( $ timestamp ) { if ( ! isset ( $ timestamp ) ) { return $ this -> jql ; } return $ this -> jql . " AND updated > '" . date ( 'Y-m-d H:i' , $ timestamp ) . "'" ; } | Get JQL query |
28,511 | public function fetchIssues ( $ timestamp = null ) { $ this -> connect ( ) ; $ issues = $ this -> soapClient -> getIssuesFromJqlSearch ( $ this -> token , $ this -> getJql ( $ timestamp ) , self :: MAX_ISSUES ) ; return $ issues ; } | Fetch issues matching jql and resource |
28,512 | private function getReopenActionId ( $ id ) { $ actions = $ this -> soapClient -> getAvailableActions ( $ this -> token , $ id ) ; foreach ( $ actions as $ action ) { if ( strpos ( strtolower ( $ action -> name ) , 'reopen' ) !== false ) { return $ action -> id ; } } } | Get reopen action ID |
28,513 | public function reopenIssue ( $ id ) { $ this -> connect ( ) ; $ action = $ this -> getReopenActionId ( $ id ) ; if ( isset ( $ action ) ) { $ this -> soapClient -> progressWorkflowAction ( $ this -> token , $ id , $ action , array ( ) ) ; } } | Re - open issue |
28,514 | public function getIssue ( $ resource ) { $ hashPosition = strpos ( $ resource , '#' ) ; if ( $ hashPosition !== false ) { $ resource = substr ( $ resource , 0 , $ hashPosition ) ; } $ url = $ this -> host . '/browse/' ; if ( strncmp ( $ resource , $ url , strlen ( $ url ) ) === 0 ) { return substr ( $ resource , strlen ( $ url ) ) ; } } | Get Jira issue from URL |
28,515 | public function postReportExecution ( $ resource , $ options , $ response ) { $ rh = new ReportHistory ( ) ; if ( isset ( $ options [ 'parameters' ] ) ) { $ rh -> setParameters ( json_encode ( $ options [ 'parameters' ] ) ) ; } else { $ rh -> setParameters ( '{}' ) ; } $ rh -> setFormats ( '{}' ) ; $ rh -> setRequestId ( JasperHelper :: getRequestIdFromDetails ( $ response ) ) ; $ rh -> setDate ( new \ DateTime ( ) ) ; $ rh -> setReportUri ( $ resource ) ; $ rh -> setUsername ( $ this -> securityContext -> getToken ( ) -> getUsername ( ) ) ; $ rh -> setStatus ( 'executed' ) ; $ this -> em -> persist ( $ rh ) ; $ this -> em -> flush ( $ rh ) ; } | The function to be invoked once the report has been executed |
28,516 | protected function renderTargets ( $ builders ) { $ this -> writeTitle ( 'Build Targets' ) ; $ table = new Table ( $ this -> output ) ; $ table -> setHeaders ( array ( '#' , 'Builder' , 'Deps' ) ) ; foreach ( $ builders as $ i => $ builder ) { $ table -> addRow ( array ( $ i , $ builder -> getName ( ) , implode ( ', ' , $ builder -> getDependencies ( ) ) ) ) ; } $ table -> render ( ) ; $ this -> output -> writeln ( '' ) ; $ this -> output -> writeln ( '<info>Options:</info>' ) ; $ this -> output -> writeln ( '' ) ; foreach ( $ this -> input -> getOptions ( ) as $ optionName => $ optionValue ) { $ this -> output -> writeln ( sprintf ( ' - <info>%s</info>: %s' , $ optionName , var_export ( $ optionValue , true ) ) ) ; } $ this -> output -> writeln ( '' ) ; } | Render the target list |
28,517 | protected function runBuilders ( $ builders ) { $ this -> writeTitle ( 'Executing builders' ) ; $ builderContext = new BuilderContext ( $ this -> input , $ this -> output , $ this -> getApplication ( ) ) ; foreach ( $ builders as $ builder ) { $ this -> output -> getFormatter ( ) -> setIndentLevel ( 0 ) ; if ( $ builder instanceof ContainerAwareInterface ) { $ builder -> setContainer ( $ this -> container ) ; } $ builder -> setContext ( $ builderContext ) ; $ this -> output -> writeln ( sprintf ( '<info>Target: </info>%s' , $ builder -> getName ( ) ) ) ; $ this -> output -> writeln ( '' ) ; $ this -> output -> getFormatter ( ) -> setIndentLevel ( 1 ) ; $ builder -> build ( ) ; } } | Execute the builders |
28,518 | public function escape ( $ text , $ profile = array ( 'htmlspecialchars' , 'nl2br' ) ) { if ( ! is_array ( $ profile ) ) { if ( ( $ functions = Atomik :: get ( "helpers.escape.$profile" , false ) ) === false ) { if ( function_exists ( $ profile ) ) { $ functions = array ( $ profile ) ; } else { throw new AtomikException ( "No profile or functions named '$profile' in escape()" ) ; } } } else { $ functions = $ profile ; } foreach ( ( array ) $ functions as $ function ) { $ text = call_user_func ( $ function , $ text ) ; } return $ text ; } | Escapes text so it can be outputted safely |
28,519 | public function resolveFilename ( $ extension = null ) { if ( $ extension === null ) { $ extension = $ this -> extension ; } return $ this -> name . '-' . $ this -> id . '.' . $ extension ; } | Returns the full filename for this file . |
28,520 | public function setAccessor ( NameValue $ name , callable $ getter , callable $ setter , $ settings = AccessControl :: DEFAULT_ACCESS , $ attributes = PropertyAttribute :: NONE , FunctionTemplate $ receiver ) { } | Sets an accessor on the object template . |
28,521 | public function authenticate ( IRequest $ request ) { $ id = $ request -> request ( 'client_id' ) ; $ secret = $ request -> request ( 'client_secret' ) ; if ( ! $ id ) { throw new InvalidClientException ( 'Client id is missing.' ) ; } if ( ! $ client = $ this -> clientStorage -> get ( $ id ) ) { throw new InvalidClientException ( 'Invalid client credentials.' ) ; } if ( ( string ) $ secret !== ( string ) $ client -> getSecret ( ) ) { throw new InvalidClientException ( 'Invalid client credentials.' ) ; } return $ client ; } | Authenticates client and returns it |
28,522 | protected function checkSuccess ( $ response ) { if ( ! isset ( $ response [ 'ACK' ] ) ) { $ this -> _success = false ; $ this -> addErrorMessage ( 'ACK key not found in response.' ) ; return ; } else if ( $ response [ 'ACK' ] == "Success" || $ response [ 'ACK' ] == "SuccessWithWarning" ) { $ this -> _success = true ; return ; } if ( isset ( $ response [ 'ERRORS' ] ) ) { foreach ( $ response [ 'ERRORS' ] as $ error ) { if ( isset ( $ error [ 'LONGMESSAGE' ] ) ) { $ this -> addErrorMessage ( $ error [ 'LONGMESSAGE' ] ) ; } } } else { $ this -> addErrorMessage ( 'Unknown error has occurred.' ) ; } $ this -> _success = false ; } | Determine if the response was successful |
28,523 | private function deformatNVP ( $ nvpstr ) { $ intial = 0 ; $ nvpArray = array ( ) ; $ paymentRequests = array ( ) ; while ( strlen ( $ nvpstr ) ) { $ keypos = strpos ( $ nvpstr , '=' ) ; $ valuepos = strpos ( $ nvpstr , '&' ) ? strpos ( $ nvpstr , '&' ) : strlen ( $ nvpstr ) ; $ keyval = urldecode ( substr ( $ nvpstr , $ intial , $ keypos ) ) ; $ valval = urldecode ( substr ( $ nvpstr , $ keypos + 1 , $ valuepos - $ keypos - 1 ) ) ; $ matches = array ( ) ; if ( preg_match ( "/^(L_PAYMENTREQUEST|PAYMENTREQUEST|L_PAYMENTINFO|PAYMENTINFO)_([0-9])_/" , $ keyval , $ matches ) ) { $ idx = $ matches [ 2 ] ; $ newParentKey = str_replace ( "L_" , "" , $ matches [ 1 ] ) ; if ( ! isset ( $ nvpArray [ $ newParentKey ] ) ) { $ nvpArray [ $ newParentKey ] = array ( ) ; $ nvpArray [ $ newParentKey ] [ $ idx ] = array ( ) ; } $ keyval = str_replace ( "{$newParentKey}_{$idx}_" , "" , $ keyval ) ; $ targetArray = & $ nvpArray [ $ newParentKey ] [ $ idx ] ; } else { $ targetArray = & $ nvpArray ; } if ( false !== strpos ( $ keyval , "L_" ) ) { list ( $ subNum , $ subParentKey , $ subKey ) = $ this -> extractKeyValues ( $ keyval ) ; if ( ! isset ( $ targetArray [ $ subParentKey ] ) ) { $ targetArray [ $ subParentKey ] = array ( ) ; $ targetArray [ $ subParentKey ] [ $ subNum ] = array ( ) ; } $ targetArray [ $ subParentKey ] [ $ subNum ] [ $ subKey ] = $ valval ; } else { $ targetArray [ $ keyval ] = $ valval ; } $ nvpstr = substr ( $ nvpstr , $ valuepos + 1 , strlen ( $ nvpstr ) ) ; } return array_merge ( $ nvpArray , $ paymentRequests ) ; } | Parse the return string from Paypal into an Array . |
28,524 | protected function extractKeyValues ( $ key ) { $ formattedKey = substr ( str_replace ( "L_" , "" , $ key ) , 0 , - preg_match_all ( "/[0-9]/" , $ key ) ) ; return array ( substr ( $ key , - preg_match_all ( "/[0-9]/" , $ key ) ) , $ this -> getMappedKeyName ( $ formattedKey ) , $ formattedKey ) ; } | Parse out a key passed from deformatNVP . This method returns an array with 3 values . |
28,525 | protected function getMappedKeyName ( $ field ) { $ keyName = "OTHER" ; foreach ( $ this -> _multiFieldMap as $ key => $ value ) { if ( in_array ( $ field , $ value ) ) { $ keyName = $ key ; break ; } } return $ keyName ; } | Take a field and attempt to map it to a particular key in the map array . |
28,526 | public function installRepository ( string $ name , string $ type , string $ url ) { if ( array_key_exists ( 'repositories' , $ this -> definition ) && array_key_exists ( $ name , $ this -> definition [ 'repositories' ] ) ) { return ; } $ application = new Application ( ) ; $ command = new ConfigCommand ( ) ; $ definition = clone $ application -> getDefinition ( ) ; $ definition -> addArguments ( $ command -> getDefinition ( ) -> getArguments ( ) ) ; $ definition -> addOptions ( $ command -> getDefinition ( ) -> getOptions ( ) ) ; $ input = new ArrayInput ( [ 'command' => 'config' , 'setting-key' => 'repositories.' . $ name , 'setting-value' => [ $ type , $ url ] , '--working-dir' => $ this -> workingDir ] , $ definition ) ; $ application -> setAutoExit ( false ) ; $ application -> run ( $ input , $ this -> output ) ; } | Install a repository . |
28,527 | public function installPackage ( string $ name , string $ version , bool $ dev = true ) { $ node = $ dev ? 'require-dev' : 'require' ; if ( array_key_exists ( $ node , $ this -> definition ) && array_key_exists ( $ name , $ this -> definition [ $ node ] ) ) { return ; } $ application = new Application ( ) ; $ command = new RequireCommand ( ) ; $ definition = clone $ application -> getDefinition ( ) ; $ definition -> addArguments ( $ command -> getDefinition ( ) -> getArguments ( ) ) ; $ definition -> addOptions ( $ command -> getDefinition ( ) -> getOptions ( ) ) ; $ input = new ArrayInput ( [ 'command' => 'require' , 'packages' => [ $ name . ':' . $ version ] , '--dev' => $ dev , '--no-scripts' => true , '--no-interaction' => true , '--no-plugins' => true , '--working-dir' => $ this -> workingDir ] , $ definition ) ; $ application -> setAutoExit ( false ) ; $ application -> run ( $ input , $ this -> output ) ; } | Install a composer package . |
28,528 | public function init ( array $ options = [ ] ) { if ( ! $ this -> isOnline ( ) ) { return false ; } $ options = $ this -> mergeConfig ( $ options ) ; $ room = $ this -> createRoom ( $ options [ 'room_name' ] , $ options [ 'owner_user_id' ] ) ; $ room -> hipsupport_hash = $ this -> getHashFromUrl ( $ room -> guest_access_url ) ; $ room -> hipsupport_url = $ this -> appendUrlOptions ( $ room -> guest_access_url , $ options ) ; $ this -> notify ( $ options , $ room ) ; return $ room ; } | Initiate HipSupport chat session . Create new room return the web client URL to the room . |
28,529 | public function createRoom ( $ name , $ owner_user_id = null ) { $ i = 1 ; $ room_name = $ name ; $ owner_user_id = $ owner_user_id ? : $ this -> config -> get ( 'hipsupport::config.owner_user_id' ) ; while ( $ this -> hipchat -> room_exists ( $ room_name ) ) { $ room_name = $ name . ' ' . $ i ++ ; } $ room = $ this -> hipchat -> create_room ( $ room_name , $ owner_user_id , null , null , true ) ; return $ room -> room ; } | Create a public new room with guest access on . |
28,530 | public function online ( $ minutes = null ) { if ( ! $ minutes ) { return $ this -> cache -> forever ( 'hipsupport' , true ) ; } return $ this -> cache -> put ( 'hipsupport' , true , $ minutes ) ; } | Take HipSupport online . |
28,531 | protected function mergeConfig ( $ options ) { $ options = array_merge ( $ this -> config -> get ( 'hipsupport::config' ) , $ options ) ; if ( isset ( $ options [ 'notification' ] ) and is_array ( $ options [ 'notification' ] ) ) { $ options [ 'notification' ] = array_merge ( ( array ) $ this -> config -> get ( 'hipsupport::config.notification' ) , $ options [ 'notification' ] ) ; } return $ options ; } | Merge config array with given options . |
28,532 | protected function appendUrlOptions ( $ url , $ options ) { $ options = array_only ( $ options , [ 'welcome_msg' , 'timezone' , 'anonymous' , 'minimal' ] ) ; $ boolean_keys = [ 'minimal' , 'anonymous' ] ; foreach ( $ boolean_keys as $ key ) { if ( isset ( $ options [ $ key ] ) ) { $ options [ $ key ] = $ this -> booleanToString ( $ options [ $ key ] ) ; } else { $ options [ $ key ] = 'true' ; } } return $ url . '?' . http_build_query ( $ options ) ; } | Get the hash from a Guest Access URL |
28,533 | protected function notify ( $ options , $ room = null ) { if ( ! isset ( $ options [ 'notification' ] ) or ! $ options [ 'notification' ] ) { return false ; } extract ( $ options [ 'notification' ] ) ; if ( ! isset ( $ room_id ) or ! $ room_id ) { return false ; } if ( $ room ) { $ message = str_replace ( '[room_name]' , $ room -> name , $ message ) ; } return ( boolean ) $ this -> hipchat -> message_room ( $ room_id , $ from , $ message , $ notify , $ color , $ message_format ) ; } | Send notification that a new room has been created . |
28,534 | public function index ( JobRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Career \ Repositories \ Presenter \ JobPresenter :: class ) -> $ function ( ) ; } $ jobs = $ this -> repository -> paginate ( ) ; return $ this -> response -> title ( trans ( 'career::job.names' ) ) -> view ( 'career::job.index' , true ) -> data ( compact ( 'jobs' ) ) -> output ( ) ; } | Display a list of job . |
28,535 | public function show ( JobRequest $ request , Job $ job ) { if ( $ job -> exists ) { $ view = 'career::job.show' ; } else { $ view = 'career::job.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'career::job.name' ) ) -> data ( compact ( 'job' ) ) -> view ( $ view , true ) -> output ( ) ; } | Display job . |
28,536 | public function edit ( JobRequest $ request , Job $ job ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'career::job.name' ) ) -> view ( 'career::job.edit' , true ) -> data ( compact ( 'job' ) ) -> output ( ) ; } | Show job for editing . |
28,537 | public function update ( JobRequest $ request , Job $ job ) { try { $ attributes = $ request -> all ( ) ; $ job -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'career::job.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( guard_url ( 'career/job/' . $ job -> getRouteKey ( ) ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'career/job/' . $ job -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Update the job . |
28,538 | public function destroy ( JobRequest $ request , Job $ job ) { try { $ job -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'career::job.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'career/job/0' ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'career/job/' . $ job -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Remove the job . |
28,539 | public function setup ( string $ type = "all" ) : AbstractEdge { $ fields = function ( ) : AbstractEdge { $ this -> fields = Loaders \ FieldsLoader :: fetchArray ( $ this ) ; return $ this ; } ; $ notification = function ( ) : AbstractEdge { $ is_a_notification = function ( string $ class_name ) : bool { if ( ! class_exists ( $ class_name ) ) return false ; $ reflector = new \ ReflectionClass ( $ class_name ) ; return $ reflector -> isSubclassOf ( AbstractNotification :: class ) ; } ; $ notification_class = get_class ( $ this ) . "Notification" ; if ( $ is_a_notification ( $ notification_class ) ) { $ this -> notification = new $ notification_class ( $ this ) ; } return $ this ; } ; $ all = function ( ) use ( $ fields , $ notification ) : AbstractEdge { $ fields ( ) ; return $ notification ( ) ; } ; if ( $ type != "type" && in_array ( $ type , get_defined_vars ( ) ) ) return $ $ type ( ) ; } | All methods related to setting up this object |
28,540 | public function return ( ) : \ Pho \ Lib \ Graph \ EntityInterface { if ( $ this -> predicate ( ) -> consumer ( ) ) { return $ this -> head ( ) -> node ( ) ; } return $ this ; } | Returns the edge s value |
28,541 | protected function fill ( array $ args ) : AbstractEdge { if ( count ( $ this -> fields ) <= 0 ) { return $ this ; } $ methods = array_keys ( $ this -> fields ) ; $ args_count = count ( $ args ) ; $ fields_count = count ( $ this -> fields ) ; $ n = 0 ; while ( $ n < $ args_count ) { $ key = sprintf ( "set%s" , $ methods [ $ n ] ) ; $ this -> $ key ( $ args [ $ n ++ ] ) ; } for ( $ n = $ args_count ; $ n < $ fields_count ; $ n ++ ) { $ method = $ methods [ $ n ] ; if ( isset ( $ this -> fields [ $ method ] [ "directives" ] [ "now" ] ) && $ this -> fields [ $ method ] [ "directives" ] [ "now" ] == true ) { $ key = sprintf ( "set%s" , $ method ) ; $ this -> $ key ( time ( ) ) ; } elseif ( isset ( $ this -> fields [ $ method ] [ "directives" ] [ "default" ] ) && $ this -> fields [ $ method ] [ "directives" ] [ "default" ] != "|_~_~NO!-!VALUE!-!SET~_~_|" ) { $ key = sprintf ( "set%s" , $ method ) ; $ this -> $ key ( $ this -> fields [ $ method ] [ "directives" ] [ "default" ] ) ; } } return $ this ; } | Sets up the edge s foundational fields . |
28,542 | public function disableStripWhitespace ( $ flag = null ) { if ( null === $ flag ) { return ! $ this -> stripWhitespaceFlag ; } $ this -> stripWhitespaceFlag = ! ( bool ) $ flag ; return $ this ; } | Set or get the flag indicating whether or not to strip whitespace |
28,543 | private function stripWhitespace ( & $ tokens , $ position ) { switch ( $ tokens [ $ position ] [ 0 ] ) { case self :: TOKEN_PLACEHOLDER : case self :: TOKEN_SECTION : case self :: TOKEN_SECTION_INVERT : $ sectionTokens = $ tokens [ $ position ] [ 1 ] [ 'content' ] ; if ( 0 === count ( $ sectionTokens ) ) { break ; } $ token = $ sectionTokens [ 0 ] ; if ( $ token [ 0 ] === self :: TOKEN_CONTENT ) { $ content = preg_replace ( '/^\s*?(\r\n?|\n)/s' , '' , $ token [ 1 ] ) ; $ token = [ self :: TOKEN_CONTENT , $ content , 'original_content' => $ token [ 1 ] , ] ; $ sectionTokens [ 0 ] = $ token ; $ tokens [ $ position ] [ 1 ] [ 'content' ] = $ sectionTokens ; break ; } break ; default : break ; } if ( ( $ position - 1 ) > - 1 ) { $ previous = $ tokens [ $ position - 1 ] ; $ type = $ previous [ 0 ] ; if ( $ type === self :: TOKEN_CONTENT ) { $ content = preg_replace ( '/(\r\n?|\n)\s+$/s' , '$1' , $ previous [ 1 ] ) ; $ previous = [ self :: TOKEN_CONTENT , $ content , 'original_content' => $ previous [ 1 ] , ] ; $ tokens [ $ position - 1 ] = $ previous ; } } if ( isset ( $ tokens [ $ position + 1 ] ) ) { $ next = $ tokens [ $ position + 1 ] ; $ type = $ next [ 0 ] ; if ( $ type === self :: TOKEN_CONTENT ) { $ content = preg_replace ( '/^\s*?(\r\n?|\n)/s' , '' , $ next [ 1 ] ) ; $ next = [ self :: TOKEN_CONTENT , $ content , 'original_content' => $ next [ 1 ] , ] ; $ tokens [ $ position + 1 ] = $ next ; } } } | Strip whitespace in content tokens surrounding a given token |
28,544 | private function replaceTokens ( array $ originalTokens , array $ replacements ) { $ tokens = [ ] ; foreach ( $ originalTokens as $ key => $ token ) { if ( ! array_key_exists ( $ key , $ replacements ) ) { $ tokens [ ] = $ token ; continue ; } foreach ( $ replacements [ $ key ] as $ replacementToken ) { $ tokens [ ] = $ replacementToken ; } } return $ tokens ; } | Inject replacements from template inheritance |
28,545 | private function parseViaPragmas ( array $ tokenStruct , Pragma \ PragmaCollection $ pragmas , array $ scopedPragmas ) { $ token = $ tokenStruct [ 0 ] ; foreach ( $ this -> filterPragmasByToken ( $ token , $ pragmas , $ scopedPragmas ) as $ pragma ) { $ data = $ tokenStruct [ 1 ] ; $ tokenStruct = $ pragma -> parse ( $ tokenStruct ) ; $ this -> assertTokenStruct ( $ tokenStruct ) ; } return $ tokenStruct ; } | Parse a token via a pragma . |
28,546 | private function filterPragmasByToken ( $ token , Pragma \ PragmaCollection $ pragmas , array $ scopedPragmas ) { foreach ( $ pragmas as $ pragma ) { if ( in_array ( $ pragma -> getName ( ) , $ scopedPragmas , true ) && $ pragma -> handlesToken ( $ token ) ) { yield $ pragma ; } } } | Generator for filtering pragmas by those matching a given token . |
28,547 | private function assertTokenStruct ( $ tokenStruct ) { if ( ! is_array ( $ tokenStruct ) ) { throw new Exception \ InvalidTokenException ( 'Invalid token struct; must be an array' ) ; } if ( 2 > count ( $ tokenStruct ) ) { throw new Exception \ InvalidTokenException ( 'Invalid token struct; missing data' ) ; } if ( ! isset ( $ tokenStruct [ 0 ] ) || ! isset ( $ tokenStruct [ 1 ] ) ) { throw new Exception \ InvalidTokenException ( 'Invalid token struct; missing either index 0 or 1' ) ; } if ( ! in_array ( $ tokenStruct [ 0 ] , $ this -> validTokens , true ) ) { throw new Exception \ InvalidTokenException ( 'Invalid token struct; invalid token at position 0' ) ; } } | Assert that a token struct is valid . |
28,548 | public function isValid ( ) { $ checkEmpty = array ( $ this -> profileStartDate , $ this -> desc , $ this -> billingPeriod , $ this -> billingFrequency , $ this -> amt , $ this -> currencyCode , $ this -> acct , $ this -> email , ) ; if ( ! $ this -> checkEmpty ( $ checkEmpty ) || is_null ( $ this -> _address ) ) { return false ; } $ address = $ this -> _address ; $ test = array ( $ address -> getStreet ( ) , $ address -> getCity ( ) , $ address -> getState ( ) , $ address -> getCountryCode ( ) , $ address -> getZip ( ) ) ; if ( ! $ this -> checkEmpty ( $ test ) ) { return false ; } return true ; } | Validate the minimum set of required values . |
28,549 | public function index ( ResumeRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Career \ Repositories \ Presenter \ ResumePresenter :: class ) -> $ function ( ) ; } $ resumes = $ this -> repository -> paginate ( ) ; return $ this -> response -> title ( trans ( 'career::resume.names' ) ) -> view ( 'career::resume.index' , true ) -> data ( compact ( 'resumes' ) ) -> output ( ) ; } | Display a list of resume . |
28,550 | public function show ( ResumeRequest $ request , Resume $ resume ) { if ( $ resume -> exists ) { $ view = 'career::resume.show' ; } else { $ view = 'career::resume.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'career::resume.name' ) ) -> data ( compact ( 'resume' ) ) -> view ( $ view , true ) -> output ( ) ; } | Display resume . |
28,551 | public function edit ( ResumeRequest $ request , Resume $ resume ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'career::resume.name' ) ) -> view ( 'career::resume.edit' , true ) -> data ( compact ( 'resume' ) ) -> output ( ) ; } | Show resume for editing . |
28,552 | public function update ( ResumeRequest $ request , Resume $ resume ) { try { $ attributes = $ request -> all ( ) ; $ resume -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'career::resume.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( guard_url ( 'career/resume/' . $ resume -> getRouteKey ( ) ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'career/resume/' . $ resume -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Update the resume . |
28,553 | public function destroy ( ResumeRequest $ request , Resume $ resume ) { try { $ resume -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'career::resume.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'career/resume/0' ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'career/resume/' . $ resume -> getRouteKey ( ) ) ) -> redirect ( ) ; } } | Remove the resume . |
28,554 | public function get ( $ url , array $ options = [ ] ) { if ( ! is_array ( $ options ) ) { $ options = [ ] ; } return $ this -> embed -> get ( $ url , $ options ) ; } | Get info from a specify url . |
28,555 | public function cache ( $ url , array $ options = null ) { $ lifetime = array_get ( $ options , 'lifetime' , 60 ) ; array_forget ( $ options , 'lifetime' ) ; $ self = $ this ; return $ this -> cache -> remember ( $ url , $ lifetime , function ( ) use ( $ self , $ url , $ options ) { return $ self -> get ( $ url , $ options ) ; } ) ; } | Get info from a specify url and cache that using laravel cache manager . |
28,556 | public function issueToken ( IAccessToken $ accessToken ) { $ scopes = $ accessToken -> getScopes ( ) ; if ( $ scopes instanceof \ Traversable ) { $ scopes = iterator_to_array ( $ scopes ) ; } return $ this -> refreshTokenStorage -> generate ( $ accessToken -> getUser ( ) , $ accessToken -> getClient ( ) , $ scopes ) ; } | Issues refresh token for given access token |
28,557 | public function match ( IRequest $ request ) { $ header = $ request -> headers ( 'authorization' ) ; if ( $ header ) { if ( ! preg_match ( '~Bearer\s(\S+)~' , $ header , $ matches ) ) { throw new MalformedTokenException ; } $ this -> identifier = $ matches [ 1 ] ; return true ; } if ( $ accessToken = $ request -> request ( 'access_token' ) ) { if ( ! ( $ request -> isMethod ( 'post' ) || $ request -> isMethod ( 'put' ) ) ) { throw new InvalidHttpMethodException ; } $ contentType = $ request -> headers ( 'content_type' ) ; if ( ! $ contentType || strpos ( $ contentType , 'application/x-www-form-urlencoded' ) !== 0 ) { throw new InvalidContentTypeException ; } $ this -> identifier = $ accessToken ; return true ; } if ( $ accessToken = $ request -> query ( 'access_token' ) ) { $ this -> identifier = $ accessToken ; return true ; } return false ; } | Matches token type against request and returns if it matches |
28,558 | public function open ( $ filename ) { if ( ! $ this -> exists ( $ filename ) || false === $ content = file_get_contents ( $ filename ) ) { throw new FileNotFoundException ( $ filename ) ; } return $ this -> makeFile ( $ filename , $ content ) ; } | Makes a File out of an existing file . |
28,559 | public function create ( $ filename ) { if ( $ this -> exists ( $ filename ) ) { $ message = sprintf ( 'Failed to create "%s" because its path is not accessible.' , $ filename ) ; throw new IOException ( $ filename , $ message ) ; } return $ this -> makeFile ( $ filename , '' ) ; } | Makes a File out of a new file . |
28,560 | public function write ( File $ file ) { $ filename = $ file -> getFilename ( ) ; if ( null === $ filename ) { throw new NoFilenameGivenException ( ) ; } $ content = $ this -> contentFactory -> make ( $ file ) ; try { $ this -> symfonyFilesystem -> dumpFile ( $ filename , $ content , null ) ; } catch ( SymfonyIOException $ e ) { $ message = sprintf ( 'Failed to write "%s".' , $ filename ) ; throw new IOException ( $ filename , $ message , $ e ) ; } } | Atomically writes the given File s content on the actual file . |
28,561 | protected function beforeValidate ( $ event ) { if ( $ this -> autoSave ) { $ this -> owner -> { $ this -> uploadAttribute } = $ this -> getUploadedFile ( ) ; } } | Actions to take before validating the owner of this behavior . |
28,562 | protected function beforeSave ( $ event ) { if ( $ this -> autoSave ) { $ this -> saveFile ( $ this -> owner -> { $ this -> uploadAttribute } , $ this -> name , $ this -> path ) ; } } | Actions to take before saving the owner of this behavior . |
28,563 | public function deleteFile ( ) { if ( ! $ this -> getManager ( ) -> deleteModel ( $ this -> owner -> { $ this -> idAttribute } ) ) { throw new CException ( 'Failed to delete file.' ) ; } $ this -> owner -> { $ this -> idAttribute } = null ; if ( ! $ this -> owner -> save ( false ) ) { throw new CException ( 'Failed to remove file id from owner.' ) ; } } | Deletes the file associated with the owner . |
28,564 | protected static function edgeCallableExists ( array $ pack , string $ name , ID $ id , Direction $ direction ) : bool { return ! is_null ( $ pack [ ( string ) $ direction ] -> callable_edge_singularLabels ) && in_array ( $ name , $ pack [ ( string ) $ direction ] -> callable_edge_singularLabels ) ; } | Whether the given method is available for incoming or outgoing edge callables . |
28,565 | protected static function checkEdgeNode ( ParticleInterface $ particle , array $ pack , string $ name , ID $ id , Direction $ direction ) : bool { $ direction = ( string ) $ direction ; $ node_adj = static :: ADJACENCY_EQUIVALENT [ $ direction ] ; $ cargo = $ pack [ $ direction ] ; $ edges = $ particle -> edges ( ) -> $ direction ( ) ; foreach ( $ edges as $ edge ) { if ( $ edge instanceof $ cargo -> singularLabel_class_pairs [ $ name ] && $ edge -> $ node_adj ( ) -> equals ( $ id ) ) { return true ; } } return false ; } | Has Catcher for Edges |
28,566 | protected static function checkEdgeItself ( ParticleInterface $ particle , array $ pack , string $ name , ID $ id , Direction $ direction ) : bool { $ direction = ( string ) $ direction ; $ cargo = $ pack [ $ direction ] ; $ edges = $ particle -> edges ( ) -> $ direction ( ) ; foreach ( $ edges as $ edge ) { if ( $ edge -> id ( ) -> equals ( $ id ) && $ edge instanceof $ cargo -> callable_edge_singularLabel_class_pairs [ $ name ] ) { return true ; } } return false ; } | Has Catcher for Edge Callables |
28,567 | public function validate ( $ input ) { if ( ( $ this -> min !== false ) && ( $ input < $ this -> min ) ) { throw new phpillowValidationException ( 'Input value %input is not bigger or equal then %minimum.' , array ( 'input' => $ input , 'minimum' => $ this -> min , ) ) ; } if ( ( $ this -> max !== false ) && ( $ input > $ this -> max ) ) { throw new phpillowValidationException ( 'Input value %input is not lesser or equal then %maximum.' , array ( 'input' => $ input , 'maximum' => $ this -> max , ) ) ; } return ( int ) $ input ; } | Validate input as integer |
28,568 | public function init ( ) { if ( $ this -> securityFile ) { if ( ! $ this -> loadSecurityConfiguration ( ) ) { $ this -> config = array ( ) ; } } else { $ this -> config = array ( ) ; } $ this -> ready = true ; } | Loads the data and prepares this class |
28,569 | public function saveSecurityConfiguration ( $ pathOverride = null , $ debug = false ) { if ( ! $ this -> ready ) { return false ; } $ path = $ pathOverride ? : $ this -> securityFile ; $ dumper = new Dumper ( ) ; $ output = $ dumper -> dump ( $ this -> config , $ this -> determineMaxDepthOfConfig ( ) ) ; try { file_put_contents ( $ path , $ output ) ; } catch ( \ Exception $ e ) { if ( $ debug ) { throw $ e ; } else { return false ; } } return true ; } | Saves the security configuration settings to a file |
28,570 | public function canView ( $ resourceUri ) { if ( ! $ this -> ready ) { $ this -> init ( ) ; } if ( $ this -> maxLevelSetAtDefault ) { if ( false === strpos ( $ resourceUri , $ this -> defaultFolder ) ) { return false ; } } try { $ roles = array_map ( function ( $ role ) { if ( $ role instanceof \ Symfony \ Component \ Security \ Core \ Role \ SwitchUserRole || $ role instanceof \ Symfony \ Component \ Security \ Core \ Role \ Role ) { return $ role -> getRole ( ) ; } else { return ( string ) $ role ; } } , $ this -> securityContext -> getToken ( ) -> getRoles ( ) ) ; } catch ( \ Exception $ e ) { throw new \ Exception ( 'The Report Bundle requires the roles to either be in string format or castable to a string' ) ; } return $ this -> checkNode ( $ resourceUri , $ roles ) ; } | Determines whether the current user can view the resource with the given uri |
28,571 | public function setRoles ( $ resourceUri , $ roles = null ) { if ( ! $ this -> ready ) { $ this -> init ( ) ; } $ roles = $ roles ? : $ this -> defaultRoles ; return $ this -> createNode ( $ resourceUri , $ roles ) ; } | Sets the roles that can view a resource |
28,572 | public function checkIfExists ( $ resourceUri ) { $ nodes = preg_split ( '/(\\\|\\/)/' , $ resourceUri , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ ptr = & $ this -> config ; foreach ( $ nodes as $ node ) { if ( ! isset ( $ ptr [ $ node ] ) ) { return false ; } } return true ; } | Checks whether a requested node currently exists in the security configuration |
28,573 | protected function arrayDepth ( $ element , $ depth = 1 ) { if ( is_array ( $ element ) ) { $ maxDepth = $ depth ; foreach ( $ element as $ el ) { $ d = $ this -> arrayDepth ( $ el , $ depth + 1 ) ; if ( $ d > $ maxDepth ) { $ maxDepth = $ d ; } } return $ maxDepth ; } else { return $ depth ; } } | Recursively called function to determine the depth of an array |
28,574 | protected function createNode ( $ resourceUri , $ roles ) { $ nodes = preg_split ( '/(\\\|\\/)/' , $ resourceUri , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ ptr = & $ this -> config ; foreach ( $ nodes as $ node ) { if ( ! isset ( $ ptr [ $ node ] ) ) { $ ptr [ $ node ] = array ( '_roles' => $ roles ) ; } $ ptr = & $ ptr [ $ node ] ; } } | Creates a node in the configuration |
28,575 | protected function checkNode ( $ resourceUri , $ roles ) { $ nodes = preg_split ( '/(\\\|\\/)/' , $ resourceUri , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ valid = false ; $ ptr = & $ this -> config ; foreach ( $ nodes as $ node ) { if ( isset ( $ ptr [ $ node ] ) ) { $ ptr = & $ ptr [ $ node ] ; if ( isset ( $ ptr [ '_roles' ] ) ) { if ( 0 < count ( array_intersect ( $ ptr [ '_roles' ] , $ roles ) ) ) { $ valid = true ; } else { $ valid = false ; } } } else { break ; } } return $ valid ; } | Checks whether a resource can be viewed with the given roles |
28,576 | public function afterScenario ( ScenarioEvent $ event ) { $ scenario = $ event -> getScenario ( ) ; $ feature = $ scenario -> getFeature ( ) ; $ url = $ feature -> getFile ( ) ; $ issue = $ this -> jiraService -> getIssue ( $ url ) ; if ( $ issue ) { $ this -> postComment ( $ issue , $ event -> getResult ( ) , $ scenario -> getTitle ( ) ) ; $ this -> updateIssue ( $ issue , $ event -> getResult ( ) ) ; } } | After Scenario hook |
28,577 | private function postComment ( $ issue , $ result , $ title ) { if ( $ result === StepEvent :: PASSED && $ this -> commentOnPass ) { $ this -> jiraService -> postComment ( $ issue , sprintf ( 'Scenario "%s" passed' , $ title ) ) ; } elseif ( $ result === StepEvent :: FAILED && $ this -> commentOnFail ) { $ this -> jiraService -> postComment ( $ issue , sprintf ( 'Scenario "%s" failed' , $ title ) ) ; } } | Post comment in corresponding Jira issue |
28,578 | private function updateIssue ( $ issue , $ result ) { if ( $ result === StepEvent :: FAILED && $ this -> reopenOnFail ) { $ this -> jiraService -> reopenIssue ( $ issue ) ; } } | Update Jira issue status |
28,579 | public function getAuthority ( ) { $ authority = null ; if ( null !== $ this -> host ) { if ( null !== $ this -> userinfo ) { $ authority .= $ this -> userinfo . '@' ; } $ authority .= $ this -> host ; if ( null !== $ this -> port ) { $ authority .= ':' . $ this -> port ; } } return $ authority ; } | Get the authority |
28,580 | public function getAbsoluteIri ( ) { if ( false === $ this -> isAbsolute ( ) ) { throw new \ UnexpectedValueException ( 'Cannot get the absolute IRI of a relative IRI.' ) ; } $ absolute = clone $ this ; $ absolute -> fragment = null ; return $ absolute ; } | Get as absolute IRI i . e . without fragment identifier |
28,581 | public function relativeTo ( $ base , $ schemaRelative = false ) { if ( false === ( $ base instanceof IRI ) ) { $ base = new IRI ( $ base ) ; } $ relative = clone $ this ; if ( $ relative -> scheme !== $ base -> scheme ) { return $ relative ; } if ( $ relative -> getAuthority ( ) !== $ base -> getAuthority ( ) ) { if ( true === $ schemaRelative ) { $ relative -> scheme = null ; } return $ relative ; } $ relative -> scheme = null ; $ relative -> host = null ; $ relative -> userinfo = null ; $ relative -> port = null ; $ baseSegments = explode ( '/' , $ base -> path ) ; $ relativeSegments = explode ( '/' , $ relative -> path ) ; $ len = min ( count ( $ baseSegments ) , count ( $ relativeSegments ) ) - 1 ; $ pos = 0 ; while ( ( $ baseSegments [ $ pos ] === $ relativeSegments [ $ pos ] ) && ( $ pos < $ len ) ) { $ pos ++ ; } $ relative -> path = '' ; $ numBaseSegments = count ( $ baseSegments ) - $ pos - 1 ; if ( $ numBaseSegments > 0 ) { $ relative -> path .= str_repeat ( '../' , $ numBaseSegments ) ; } if ( ( $ baseSegments [ $ pos ] !== $ relativeSegments [ $ pos ] ) || ( ( null === $ relative -> query ) && ( null === $ relative -> fragment ) ) || ( $ base -> path === '' ) ) { if ( ( $ relative -> path === '' ) && ( false !== strpos ( $ relativeSegments [ $ pos ] , ':' ) ) ) { $ relative -> path .= './' ; } $ relative -> path .= implode ( '/' , array_slice ( $ relativeSegments , $ pos ) ) ; if ( ( $ relative -> path === '' ) ) { $ relative -> path .= './' ; } } if ( $ relative -> query !== $ base -> query ) { return $ relative ; } if ( null !== $ relative -> fragment ) { $ relative -> query = null ; } return $ relative ; } | Transform this IRI to a IRI reference relative to the passed base IRI |
28,582 | public function baseFor ( $ iri , $ schemaRelative = false ) { if ( false === ( $ iri instanceof IRI ) ) { $ iri = new IRI ( $ iri ) ; } return $ iri -> relativeTo ( $ this , $ schemaRelative ) ; } | Convert an IRI to a relative IRI reference using this IRI as base |
28,583 | protected function parse ( $ iri ) { $ regex = '|^((?P<scheme>[^:/?#]+):)?' . '((?P<doubleslash>//)(?P<authority>[^/?#]*))?(?P<path>[^?#]*)' . '((?P<querydef>\?)(?P<query>[^#]*))?(#(?P<fragment>.*))?|' ; preg_match ( $ regex , $ iri , $ match ) ; if ( false === empty ( $ match [ 'scheme' ] ) ) { $ this -> scheme = $ match [ 'scheme' ] ; } if ( '//' === $ match [ 'doubleslash' ] ) { if ( 0 === strlen ( $ match [ 'authority' ] ) ) { $ this -> host = '' ; } else { $ authority = $ match [ 'authority' ] ; if ( false !== ( $ pos = strrpos ( $ authority , '@' ) ) ) { $ this -> userinfo = substr ( $ authority , 0 , $ pos ) ; $ authority = substr ( $ authority , $ pos + 1 ) ; } $ hostEnd = 0 ; if ( ( strlen ( $ authority ) > 0 ) && ( '[' === $ authority [ 0 ] ) && ( false !== ( $ pos = strpos ( $ authority , ']' ) ) ) ) { $ hostEnd = $ pos ; } if ( ( false !== ( $ pos = strrpos ( $ authority , ':' ) ) ) && ( $ pos > $ hostEnd ) ) { $ this -> host = substr ( $ authority , 0 , $ pos ) ; $ this -> port = substr ( $ authority , $ pos + 1 ) ; } else { $ this -> host = $ authority ; } } } $ this -> path = $ match [ 'path' ] ; if ( false === empty ( $ match [ 'querydef' ] ) ) { $ this -> query = $ match [ 'query' ] ; } if ( isset ( $ match [ 'fragment' ] ) ) { $ this -> fragment = $ match [ 'fragment' ] ; } } | Parse an IRI into it s components |
28,584 | private static function removeDotSegments ( $ input ) { $ output = '' ; while ( strlen ( $ input ) > 0 ) { if ( ( '../' === substr ( $ input , 0 , 3 ) ) || ( './' === substr ( $ input , 0 , 2 ) ) ) { $ input = substr ( $ input , strpos ( $ input , '/' ) ) ; } elseif ( '/./' === substr ( $ input , 0 , 3 ) ) { $ input = substr ( $ input , 2 ) ; } elseif ( '/.' === $ input ) { $ input = '/' ; } elseif ( ( '/../' === substr ( $ input , 0 , 4 ) ) || ( '/..' === $ input ) ) { if ( $ input == '/..' ) { $ input = '/' ; } else { $ input = substr ( $ input , 3 ) ; } if ( false !== ( $ end = strrpos ( $ output , '/' ) ) ) { $ output = substr ( $ output , 0 , $ end ) ; } else { $ output = '' ; } } elseif ( ( '..' === $ input ) || ( '.' === $ input ) ) { $ input = '' ; } else { if ( false === ( $ end = strpos ( $ input , '/' , 1 ) ) ) { $ output .= $ input ; $ input = '' ; } else { $ output .= substr ( $ input , 0 , $ end ) ; $ input = substr ( $ input , $ end ) ; } } } return $ output ; } | Remove dot - segments |
28,585 | public function from_post ( $ object ) { if ( is_array ( $ object ) ) { $ this -> attributes = $ object ; } else if ( is_a ( $ object , 'WP_Post' ) ) { $ this -> attributes = $ object -> to_array ( ) ; } if ( ! empty ( $ this -> attributes ) ) { $ this -> load_meta ( ) ; } return $ this ; } | Constructs object based on passed object . Should be an array of attributes or a WP_Post . |
28,586 | public function sort_by ( $ attribute , $ sort_flag = SORT_REGULAR ) { $ values = array ( ) ; for ( $ i = count ( $ this ) - 1 ; $ i >= 0 ; -- $ i ) { $ values [ ] = $ this [ $ i ] -> $ attribute ; } $ values = array_unique ( $ values ) ; sort ( $ values , $ sort_flag ) ; $ new = new self ( ) ; foreach ( $ values as $ value ) { for ( $ i = count ( $ this ) - 1 ; $ i >= 0 ; -- $ i ) { if ( $ value == $ this [ $ i ] -> $ attribute ) { $ new [ ] = $ this [ $ i ] ; } } } return $ new ; } | Sorts results by specific field and direction . |
28,587 | public function group_by ( $ attribute ) { $ new = new self ( ) ; for ( $ i = 0 ; $ i < count ( $ this ) ; ++ $ i ) { $ key = ( string ) $ this [ $ i ] -> $ attribute ; if ( ! isset ( $ new [ $ key ] ) ) $ new [ $ key ] = new self ( ) ; $ new [ $ key ] [ ] = $ this [ $ i ] ; } return $ new ; } | Groups collection by attribute name |
28,588 | public function isCoreFile ( $ file ) { return true ; return $ file === null || strpos ( realpath ( $ file ) , YII2_PATH . DIRECTORY_SEPARATOR ) === 0 ; } | Determines whether given name of the file belongs to the framework . |
28,589 | public function send ( AbstractRequest $ request ) { try { $ client = $ this -> client ; $ config = $ this -> config ; if ( false === $ config -> isValid ( ) ) { throw new \ Exception ( "Configuration is not valid." ) ; } if ( is_null ( $ client ) ) { throw new \ Exception ( 'Zend\Http\Client must be set and must be valid.' ) ; } if ( false === $ request -> isValid ( ) ) { throw new \ Exception ( get_class ( $ request ) . " is invalid." ) ; } $ client -> setMethod ( 'POST' ) ; $ client -> setUri ( new \ Zend \ Uri \ Http ( $ config -> getEndpoint ( ) ) ) ; $ client -> setRawBody ( $ config . $ request ) ; $ httpResponse = $ client -> send ( ) ; $ response = Response :: factory ( $ request -> getMethod ( ) , $ httpResponse -> getBody ( ) ) ; } catch ( \ Exception $ e ) { $ response = new Response ( ) ; $ response -> addErrorMessage ( $ e -> getMessage ( ) ) ; } return $ response ; } | Make the paypal request and return a Response object |
28,590 | public function addDefaultScope ( IScope $ scope ) { if ( ! $ this -> defaultScopes -> contains ( $ scope ) ) { $ this -> defaultScopes -> attach ( $ scope ) ; } else { throw new \ InvalidArgumentException ( "Scope '{$scope->getId()}' is already registered as default scope." ) ; } } | Adds scope to default scopes |
28,591 | public function intersect ( $ requestedScopes , $ availableScopes = [ ] ) { if ( $ availableScopes instanceof \ Traversable ) { $ availableScopes = iterator_to_array ( $ availableScopes ) ; } else if ( ! is_array ( $ availableScopes ) ) { throw new \ InvalidArgumentException ( 'Available scopes has to be array or traversable. But ' . gettype ( $ availableScopes ) . ' was given.' ) ; } $ intersection = [ ] ; if ( empty ( $ availableScopes ) ) { throw new InvalidArgumentException ( 'Available scopes has to be array of OAuth2\Storage\IScope instances. Empty was given.' ) ; } foreach ( $ availableScopes as $ scope ) { if ( ! $ scope instanceof IScope ) { throw new \ InvalidArgumentException ( 'Available scopes has to be array of OAuth2\Storage\IScope instances.' ) ; } } if ( empty ( $ requestedScopes ) ) { return $ availableScopes ; } else if ( is_string ( $ requestedScopes ) ) { $ requestedScopes = explode ( ' ' , $ requestedScopes ) ; } else if ( $ requestedScopes instanceof IScope ) { $ requestedScopes = [ $ requestedScopes -> getId ( ) ] ; } else if ( $ requestedScopes instanceof \ Traversable ) { $ requestedScopes = $ this -> parseScopeArray ( iterator_to_array ( $ requestedScopes ) ) ; } else if ( is_array ( $ requestedScopes ) ) { $ requestedScopes = $ this -> parseScopeArray ( $ requestedScopes ) ; } foreach ( $ requestedScopes as $ requestedScope ) { foreach ( $ availableScopes as $ index => $ availableScope ) { if ( $ availableScope -> getId ( ) === $ requestedScope ) { unset ( $ availableScopes [ $ index ] ) ; $ intersection [ ] = $ availableScope ; continue 2 ; } } throw new InvalidScopeException ( "Scope '$requestedScope' is invalid." ) ; } return $ intersection ; } | Are all requested scopes in available scopes? |
28,592 | protected function parseScopeArray ( array $ scopes ) { $ parsedScopes = [ ] ; foreach ( $ scopes as $ scope ) { if ( is_string ( $ scope ) && $ scope != '' ) { $ parsedScopes [ ] = $ scope ; } else if ( $ scope instanceof IScope ) { $ parsedScopes [ ] = $ scope -> getId ( ) ; } else { throw new \ InvalidArgumentException ( 'Scopes has to be array of strings or OAuth2\Storage\IScope instances.' ) ; } } return $ parsedScopes ; } | Parses scopes from array of scopes and returns array of scope identifiers |
28,593 | public static function create ( $ url , $ content = null , $ status = 200 , $ headers = array ( ) ) { return new static ( $ url , $ content , $ status , $ headers ) ; } | Factory method for chainability |
28,594 | public function decodeContent ( ) { $ contentType = $ this -> headers -> get ( 'content-type' , 'text/plain' ) ; if ( $ contentType === 'application/json' || $ contentType === 'application/json; charset=UTF-8' ) { return json_decode ( $ this -> content , true ) ; } if ( $ contentType === 'text/xml' || $ contentType === 'text/xml; charset=UTF-8' ) { $ xml = simplexml_load_string ( $ this -> content ) ; $ json = json_encode ( $ xml ) ; return json_decode ( $ json , true ) ; } return $ this -> content ; } | Decode the content |
28,595 | public function getBarCharacter ( ) { if ( null === $ this -> barChar ) { return $ this -> max ? '=' : $ this -> emptyBarChar ; } return $ this -> barChar ; } | Gets the bar character . |
28,596 | private function setRealFormat ( $ format ) { if ( ! $ this -> max && null !== self :: getFormatDefinition ( $ format . '_nomax' ) ) { $ this -> format = self :: getFormatDefinition ( $ format . '_nomax' ) ; } elseif ( null !== self :: getFormatDefinition ( $ format ) ) { $ this -> format = self :: getFormatDefinition ( $ format ) ; } else { $ this -> format = $ format ; } $ this -> formatLineCount = substr_count ( $ this -> format , "\n" ) ; } | Sets the progress bar format . |
28,597 | public static function work ( array $ options , callable $ callable ) { if ( ! extension_loaded ( 'pcntl' ) ) { throw new \ Exception ( 'pcntl extension required' ) ; } if ( ! extension_loaded ( 'posix' ) ) { throw new \ Exception ( 'posix extension required' ) ; } if ( ! isset ( $ options [ 'pid' ] ) ) { throw new \ Exception ( 'pid not specified' ) ; } $ options = $ options + array ( 'stdin' => '/dev/null' , 'stdout' => '/dev/null' , 'stderr' => 'php://stdout' , ) ; if ( ( $ lock = @ fopen ( $ options [ 'pid' ] , 'c+' ) ) === false ) { throw new \ Exception ( 'unable to open pid file ' . $ options [ 'pid' ] ) ; } if ( ! flock ( $ lock , LOCK_EX | LOCK_NB ) ) { throw new \ Exception ( 'could not acquire lock for ' . $ options [ 'pid' ] ) ; } switch ( $ pid = pcntl_fork ( ) ) { case - 1 : throw new \ Exception ( 'unable to fork' ) ; case 0 : break ; default : fseek ( $ lock , 0 ) ; ftruncate ( $ lock , 0 ) ; fwrite ( $ lock , $ pid ) ; fflush ( $ lock ) ; return ; } if ( posix_setsid ( ) === - 1 ) { throw new \ Exception ( 'failed to setsid' ) ; } fclose ( STDIN ) ; fclose ( STDOUT ) ; fclose ( STDERR ) ; if ( ! ( $ stdin = fopen ( $ options [ 'stdin' ] , 'r' ) ) ) { throw new \ Exception ( 'failed to open STDIN ' . $ options [ 'stdin' ] ) ; } if ( ! ( $ stdout = fopen ( $ options [ 'stdout' ] , 'w' ) ) ) { throw new \ Exception ( 'failed to open STDOUT ' . $ options [ 'stdout' ] ) ; } if ( ! ( $ stderr = fopen ( $ options [ 'stderr' ] , 'w' ) ) ) { throw new \ Exception ( 'failed to open STDERR ' . $ options [ 'stderr' ] ) ; } pcntl_signal ( SIGTSTP , SIG_IGN ) ; pcntl_signal ( SIGTTOU , SIG_IGN ) ; pcntl_signal ( SIGTTIN , SIG_IGN ) ; pcntl_signal ( SIGHUP , SIG_IGN ) ; call_user_func ( $ callable , $ stdin , $ stdout , $ stderr ) ; } | Daemonize a Closure object . |
28,598 | public static function isRunning ( $ file ) { if ( ! extension_loaded ( 'posix' ) ) { throw new \ Exception ( 'posix extension required' ) ; } if ( ! is_readable ( $ file ) ) { return false ; } if ( ( $ lock = @ fopen ( $ file , 'c+' ) ) === false ) { throw new \ Exception ( 'unable to open pid file ' . $ file ) ; } if ( flock ( $ lock , LOCK_EX | LOCK_NB ) ) { return false ; } else { flock ( $ lock , LOCK_UN ) ; return true ; } } | Checks whether a daemon process specified by its PID file is running . |
28,599 | public static function kill ( $ file , $ delete = false ) { if ( ! extension_loaded ( 'posix' ) ) { throw new \ Exception ( 'posix extension required' ) ; } if ( ! is_readable ( $ file ) ) { throw new \ Exception ( 'unreadable pid file ' . $ file ) ; } if ( ( $ lock = @ fopen ( $ file , 'c+' ) ) === false ) { throw new \ Exception ( 'unable to open pid file ' . $ file ) ; } if ( flock ( $ lock , LOCK_EX | LOCK_NB ) ) { flock ( $ lock , LOCK_UN ) ; throw new \ Exception ( 'process not running' ) ; } $ pid = fgets ( $ lock ) ; if ( posix_kill ( $ pid , SIGTERM ) ) { if ( $ delete ) unlink ( $ file ) ; return true ; } else { return false ; } } | Kills a daemon process specified by its PID file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.