idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
19,400
public static function Format ( $ str = '' , array $ args = [ ] ) { foreach ( $ args as $ key => $ value ) { $ pos = strpos ( $ str , '{' . $ key . '}' ) ; if ( $ pos !== FALSE ) $ str = substr ( $ str , 0 , $ pos ) . $ value . substr ( $ str , $ pos + strlen ( $ key ) + 2 ) ; } return $ str ; }
Format string function .
19,401
public function verifyAuthenticationRequest ( SsoClient $ ssoClient , \ TYPO3 \ Flow \ Http \ Request $ request , $ argumentName , $ signature ) { $ uri = clone $ request -> getUri ( ) ; $ arguments = $ uri -> getArguments ( ) ; unset ( $ arguments [ $ argumentName ] ) ; if ( isset ( $ arguments [ '__csrfToken' ] ) ) { unset ( $ arguments [ '__csrfToken' ] ) ; } $ uri -> setQuery ( http_build_query ( $ arguments ) ) ; $ originalUri = ( string ) $ uri ; return $ this -> rsaWalletService -> verifySignature ( $ originalUri , base64_decode ( $ signature ) , $ ssoClient -> getPublicKey ( ) ) ; }
Verifies the authenticity of an request to the authentication endpoint
19,402
public function buildCallbackRedirectUri ( SsoClient $ ssoClient , AccessToken $ accessToken , $ callbackUri ) { $ accessTokenCipher = $ this -> rsaWalletService -> encryptWithPublicKey ( $ accessToken -> getIdentifier ( ) , $ ssoClient -> getPublicKey ( ) ) ; $ signature = $ this -> rsaWalletService -> sign ( $ accessTokenCipher , $ this -> keyPairFingerprint ) ; $ uri = new Uri ( $ ssoClient -> getServiceBaseUri ( ) . 'authentication/callback' ) ; $ query = $ uri -> getQuery ( ) ; if ( $ query !== '' ) { $ query = $ query . '&' ; } $ query .= 'callbackUri=' . urlencode ( $ callbackUri ) . '&__flowpack[singlesignon][accessToken]=' . urlencode ( base64_encode ( $ accessTokenCipher ) ) . '&__flowpack[singlesignon][signature]=' . urlencode ( base64_encode ( $ signature ) ) ; $ uri -> setQuery ( $ query ) ; return $ uri ; }
Builds the callback URI to the client after authentication on the server
19,403
public function createAccessToken ( SsoClient $ ssoClient , \ TYPO3 \ Flow \ Security \ Account $ account ) { $ accessToken = new \ Flowpack \ SingleSignOn \ Server \ Domain \ Model \ AccessToken ( ) ; $ accessToken -> setAccount ( $ account ) ; $ accessToken -> setExpiryTime ( time ( ) + \ Flowpack \ SingleSignOn \ Server \ Domain \ Model \ AccessToken :: DEFAULT_VALIDITY_TIME ) ; $ accessToken -> setSessionId ( $ this -> session -> getId ( ) ) ; $ accessToken -> setSsoClient ( $ ssoClient ) ; return $ accessToken ; }
Create an access token for the given SSO client
19,404
public static function getReference ( $ name ) { if ( isset ( self :: $ customer_references [ $ name ] ) ) { return self :: $ customer_references [ $ name ] ; } else { return null ; } }
Get the target static from the manager
19,405
public function token ( Request $ request ) { $ bridgeResponse = new BridgeResponse ; $ oauthRequest = OAuthRequest :: createFromRequest ( $ request ) ; $ response = $ this -> server -> handleTokenRequest ( $ oauthRequest , $ bridgeResponse ) ; if ( $ response -> isOk ( ) ) { $ user = $ this -> userService -> findById ( $ response -> getParameter ( 'user_id' ) ) ; if ( ! $ user ) { return $ this -> createInvalidCredentialResponse ( ) ; } if ( ! $ user -> getEnabled ( ) ) { return $ this -> createInvalidCredentialResponse ( ) ; } if ( $ this -> requireVerification && ! $ user -> getVerified ( ) ) { return $ this -> createSimpleResponse ( 422 , 'Unverified user' ) ; } $ userId = $ response -> getParameter ( 'user_id' ) ; $ this -> setLastLogin ( $ userId ) ; $ this -> session -> set ( 'user' , $ userId ) ; } return $ response ; }
Handle an OAuth token request
19,406
protected function setLastLogin ( $ userId ) { $ user = $ this -> userService -> findById ( $ userId ) ; $ result = $ this -> userService -> update ( $ user , [ 'last_login' => time ( ) ] ) ; }
Set the last_login timestamp in the database
19,407
public function logout ( Request $ request ) { $ content = json_decode ( $ request -> getContent ( ) , true ) ; $ securityToken = $ this -> security -> getToken ( ) ; $ user = $ securityToken -> getUser ( ) ; $ accessToken = $ securityToken -> getOAuthToken ( ) ; $ refreshToken = Arr :: get ( $ content , 'refresh_token' ) ; $ this -> session -> set ( 'user' , null ) ; if ( ! $ refreshToken ) { return new Response ( 'Refresh token not provided' , 422 ) ; } try { $ this -> expireAccessToken ( $ accessToken ) ; $ this -> expireRefreshToken ( $ refreshToken , $ user ) ; } catch ( OutOfBoundsException $ e ) { return new Response ( $ e -> getMessage ( ) , 422 ) ; } return new Response ( '' , 200 ) ; }
Handle logout request
19,408
protected function expireAccessToken ( $ accessToken ) { $ token = $ this -> accessTokenMapper -> findBy ( [ 'access_token' => $ accessToken ] ) ; if ( ! $ token ) { throw new OutOfBoundsException ( 'Access token not found.' ) ; } $ token -> setExpires ( date ( "Y-m-d H:i:s" , time ( ) ) ) ; $ this -> accessTokenMapper -> update ( $ token ) ; }
Expire an access token
19,409
protected function expireRefreshToken ( $ refreshToken , $ user ) { $ token = $ this -> refreshTokenMapper -> findBy ( [ 'refresh_token' => $ refreshToken , 'user_id' => $ user -> getId ( ) , ] ) ; if ( ! $ token ) { throw new OutOfBoundsException ( 'Refresh token not found.' ) ; } $ token -> setExpires ( date ( "Y-m-d H:i:s" , time ( ) ) ) ; $ this -> refreshTokenMapper -> update ( $ token ) ; }
Expire a refresh token
19,410
protected function getUserFromRequest ( Request $ request ) { $ username = $ request -> get ( 'username' ) ; return $ this -> userService -> findByEmail ( $ username ) ; }
Get the user from the request
19,411
public function cardType ( Int $ type ) { if ( ! isset ( $ this -> cardTypes [ $ type ] ) ) { throw new Exception \ InvalidCardTypeException ( NULL , $ type ) ; } $ this -> settings [ 'cardType' ] = $ type ; return $ this ; }
Sets card type .
19,412
public function returnUrl ( String $ success , String $ fail = NULL ) { $ this -> settings [ 'okUrl' ] = URL :: site ( $ success ) ; $ this -> settings [ 'failUrl' ] = URL :: site ( $ fail ?? $ success ) ; return $ this ; }
Sets return url .
19,413
protected function prep_contents ( ) { $ properties = array ( 'created' => $ this -> created , 'expiration' => $ this -> expiration , 'dependencies' => $ this -> dependencies , 'content_handler' => $ this -> content_handler ) ; $ properties = '{{' . self :: PROPS_TAG . '}}' . json_encode ( $ properties ) . '{{/' . self :: PROPS_TAG . '}}' ; return $ properties . $ this -> contents ; }
Prepend the cache properties
19,414
protected function unprep_contents ( $ payload ) { $ properties_end = strpos ( $ payload , '{{/' . self :: PROPS_TAG . '}}' ) ; if ( $ properties_end === false ) { throw new \ UnexpectedValueException ( 'Cache has bad formatting' ) ; } $ this -> contents = substr ( $ payload , $ properties_end + strlen ( '{{/' . self :: PROPS_TAG . '}}' ) ) ; $ props = substr ( substr ( $ payload , 0 , $ properties_end ) , strlen ( '{{' . self :: PROPS_TAG . '}}' ) ) ; $ props = json_decode ( $ props , true ) ; if ( $ props === null ) { throw new \ UnexpectedValueException ( 'Cache properties retrieval failed' ) ; } $ this -> created = $ props [ 'created' ] ; $ this -> expiration = is_null ( $ props [ 'expiration' ] ) ? null : ( int ) ( $ props [ 'expiration' ] - time ( ) ) ; $ this -> dependencies = $ props [ 'dependencies' ] ; $ this -> content_handler = $ props [ 'content_handler' ] ; }
Remove the prepended cache properties and save them in class properties
19,415
public function listAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ usageManager = $ this -> get ( 'phlexible_elementtype.usage_manager' ) ; $ elementtype = $ elementtypeService -> findElementtype ( $ id ) ; $ usages = [ ] ; foreach ( $ usageManager -> getUsage ( $ elementtype ) as $ usage ) { $ usages [ ] = [ 'type' => $ usage -> getType ( ) , 'as' => $ usage -> getAs ( ) , 'id' => $ usage -> getId ( ) , 'title' => $ usage -> getTitle ( ) , 'latest_version' => $ usage -> getLatestVersion ( ) , ] ; } return new JsonResponse ( [ 'list' => $ usages , 'total' => count ( $ usages ) ] ) ; }
Show Usage of an Element Type .
19,416
public function addPages ( ArrayCollection $ pages ) { foreach ( $ pages as $ page ) { $ page -> addApp ( $ this ) ; $ this -> pages -> add ( $ page ) ; } }
Add pages to the app .
19,417
public function removePages ( ArrayCollection $ pages ) { foreach ( $ pages as $ page ) { $ page -> removeApp ( $ this ) ; $ this -> pages -> removeElement ( $ page ) ; } }
Remove pages from the app .
19,418
public static function init ( JSONObject $ json ) { $ object = NULL ; if ( ! $ json -> has ( "@type" ) ) throw new ModelFormatException ( "Not a valid object" ) ; try { switch ( strtolower ( $ json -> get ( "@type" ) ) ) { case "comment" : $ object = CommentObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "like" : $ object = LikeObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "image" : $ object = ImageObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "profile" : $ object = ProfileObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation" : $ object = ConversationObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation-status" : $ object = ConversationStatusObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation-message" : $ object = ConversationMessageObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "conversation-message-status" : $ object = ConversationMessageStatusObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "accesscontrolgroup" : $ object = AccessControlGroupObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "accesscontrolrule" : $ object = AccessControlRuleObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "link" : $ object = LinkObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "link-request" : $ object = LinkRequesObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "link-response" : $ object = LinkResponseObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "response" : $ object = ResponseObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "search-query" : $ object = SearchQueryObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "search-result" : $ object = SearchResultObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "search-result-collection" : $ object = SearchResultCollectionObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "activity" : $ object = StreamItemObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; case "tag" : $ object = TagObjectBuilder :: buildFromJSON ( $ json -> __toString ( ) ) ; break ; default : throw new ModelFormatException ( "Not a valid object type" ) ; break ; } } catch ( Exception $ e ) { throw new ModelFormatException ( "Could not init object for " . strtolower ( $ json -> get ( "@type" ) ) . ": " . $ e -> getMessage ( ) ) ; } return $ object ; }
Parses the JSONObject and creates a matching Sonic object
19,419
public static function extractValueFromEntity ( $ entity , $ property ) { $ getter = self :: createGetter ( $ entity , $ property ) ; return $ entity -> $ getter ( ) ; }
Extract the value of a property from an entity .
19,420
public function install ( TaskReposity $ job ) { if ( ! $ this -> getBasic ( ) -> jobExists ( $ job -> buildCommandWithExpression ( ) ) ) { $ this -> getBasic ( ) -> event ( function ( ) use ( $ job ) { return $ job ; } ) ; $ this -> getBasic ( ) -> run ( ) ; } }
install the default cron
19,421
public function event ( Closure $ command ) { $ response = $ command ( ) ; if ( $ this -> resolveCommandResponse ( $ response ) ) { EventReposity :: add ( $ response ) ; } }
add a new event to reposity
19,422
public function run ( ) { $ events = $ this -> dueEvents ( EventReposity :: getEvents ( ) ) ; foreach ( $ events as $ event ) { $ event -> execute ( ) ; } }
run the all commands
19,423
public static function targetNotFound ( $ targetName , Exception $ cause = null ) { return new static ( sprintf ( 'The install target "%s" does not exist.' , $ targetName ) , self :: TARGET_NOT_FOUND , $ cause ) ; }
Creates an exception for a target name that was not found .
19,424
public static function addTo ( $ key , $ value ) { if ( isset ( self :: $ vars [ $ key ] ) ) { self :: $ vars [ $ key ] .= $ value ; } else { self :: $ vars [ $ key ] = $ value ; } }
Add content to an existing variable
19,425
public static function get ( $ key , $ nullIfUndefined = true , $ defaultValueIfUndefined = null ) { if ( ! isset ( self :: $ vars [ $ key ] ) ) { if ( $ nullIfUndefined ) { if ( $ defaultValueIfUndefined ) { return $ defaultValueIfUndefined ; } return null ; } else { throw new \ Exception ( 'Valeur ' . $ key . ' non définie') ; } } else { return self :: $ vars [ $ key ] ; } }
Get a variable s content
19,426
public static function bytesToHuman ( $ bytes , $ decimals = 2 ) { $ bytes = max ( $ bytes , 0 ) ; $ pow = floor ( ( $ bytes ? log ( $ bytes ) : 0 ) / log ( self :: KILOBYTE ) ) ; $ pow = min ( $ pow , count ( self :: $ byte_units ) - 1 ) ; $ bytes /= pow ( self :: KILOBYTE , $ pow ) ; return self :: numberFormat ( $ bytes , $ decimals ) . self :: $ byte_units [ $ pow ] ; }
Converts a byte number into a human readable format
19,427
protected function apply ( $ pinocchio ) { $ variables = array ( 'configuration' => $ this -> configuration , 'pinocchio' => $ pinocchio , ) ; ob_start ( ) ; extract ( $ variables ) ; include ( $ this -> configuration -> get ( 'template' ) ) ; return ob_get_clean ( ) ; }
Apply the formatter to the given Pinocchio instance . Returns the resulting HTML page .
19,428
public function factory ( $ namespace , array $ args = [ ] ) { $ namespace = $ this -> checkOverrider ( $ namespace ) ; $ this -> classExists ( $ namespace ) -> callEvent ( 'register_before_create' , [ $ namespace , $ args ] ) ; try { $ object = new $ namespace ( ... $ args ) ; } catch ( \ Exception $ exception ) { throw new RegisterException ( $ exception ) ; } $ this -> callEvent ( 'register_after_create' , [ $ object ] ) ; $ this -> setClassCounter ( $ namespace ) ; $ this -> registeredObjects [ $ namespace ] = get_class ( $ object ) ; $ this -> makeLog ( [ 'Object created: ' . $ namespace . '. With args:' , $ args ] ) ; return $ object ; }
create new instance of given class
19,429
public function singletonFactory ( $ namespace , array $ args = [ ] , $ name = null ) { if ( is_null ( $ name ) ) { $ name = $ namespace ; } if ( ! isset ( $ this -> singletons [ $ name ] ) ) { $ this -> singletons [ $ name ] = $ this -> factory ( $ namespace , $ args ) ; } $ this -> callEvent ( 'register_before_return_singleton' , [ $ this -> singletons [ $ name ] , $ args , $ name ] ) ; return $ this -> singletons [ $ name ] ; }
create singleton instance of given class
19,430
protected function checkOverrider ( $ namespace ) { if ( $ this -> allowOverride && isset ( $ this -> overrides [ $ namespace ] ) ) { $ oldNamespace = $ namespace ; $ namespace = $ this -> overrides [ $ namespace ] [ 'overrider' ] ; $ this -> classExists ( $ namespace ) ; if ( $ this -> overrides [ $ oldNamespace ] [ 'only_once' ] ) { $ this -> unsetOverrider ( $ oldNamespace ) ; } } return $ namespace ; }
check that given class should be replaced by some other
19,431
public function destroySingleton ( $ name = null ) { if ( is_null ( $ name ) ) { $ this -> singletons = [ ] ; } if ( isset ( $ this -> singletons [ $ name ] ) ) { unset ( $ this -> singletons [ $ name ] ) ; } $ this -> makeLog ( 'Destroy singleton: ' . ( is_null ( $ name ) ? 'all' : $ name ) ) ; return $ this ; }
destroy called object
19,432
public function unsetOverrider ( $ namespace = null ) { if ( is_null ( $ namespace ) ) { $ this -> overrides = [ ] ; } else { unset ( $ this -> overrides [ $ namespace ] ) ; } $ this -> makeLog ( 'Override unset for: ' . $ namespace ) ; return $ this ; }
disable given or all overriders
19,433
function ctc_redirect_taxonomy ( ) { $ id = isset ( $ _GET [ 'id' ] ) ? ( int ) $ _GET [ 'id' ] : '' ; if ( is_front_page ( ) && ! empty ( $ _GET [ 'redirect_taxonomy' ] ) && taxonomy_exists ( $ _GET [ 'redirect_taxonomy' ] ) && ! empty ( $ id ) ) { $ taxonomy = $ _GET [ 'redirect_taxonomy' ] ; $ term_url = get_term_link ( $ id , $ taxonomy ) ; wp_redirect ( $ term_url , 301 ) ; } }
Redirect Dropdown URL
19,434
public function toDBObject ( ) { $ info = pathinfo ( $ this -> path ) ; switch ( $ info [ 'extension' ] ) { case 'yaml' : case 'yml' : return DBField :: create_field ( 'YAMLField' , file_get_contents ( $ this -> path ) ) ; case 'json' : return DBField :: create_field ( 'JSONField' , file_get_contents ( $ this -> path ) ) ; default : return null ; } }
Converts the file content into a SerialisedDBField
19,435
public function actionInit ( ) { $ rbac = new Rbac ( ) ; $ rbac -> initRolesAndActions ( ) ; $ this -> stdout ( Yii :: t ( 'users' , 'Roles updated' ) . "\n" , Console :: FG_GREEN ) ; }
Init all roles
19,436
public function equals ( $ value ) { if ( is_object ( $ value ) && get_class ( $ value ) == get_class ( $ this ) ) { $ equals = $ value -> value ( ) === $ this -> value ( ) ; } else { $ equals = $ this -> value ( ) === ( ( string ) $ value ) ; } return $ equals ; }
Returns whether the value is equal to this value
19,437
private static function validate ( ) { $ me = get_called_class ( ) ; if ( ! isset ( self :: $ consts [ $ me ] ) ) { $ constants = self :: constants ( ) ; if ( ! isset ( $ constants [ "__DEFAULT" ] ) ) { self :: toss ( "UndefinedConstantException" , "Class {me} does have a __DEFAULT constant." ) ; } foreach ( $ constants as $ name => $ value ) { if ( "__DEFAULT" !== $ name && $ name !== $ value ) { self :: toss ( "LogicException" , "Constant {me}:{0} does not match value {1}." , $ name , $ value ) ; } } self :: $ consts [ $ me ] = $ constants ; } return self :: $ consts [ $ me ] ; }
Validates the enum class definition for correctness
19,438
public function fortypeAction ( Request $ request ) { $ elementtypeService = $ this -> get ( 'phlexible_elementtype.elementtype_service' ) ; $ for = $ request -> get ( 'type' , Elementtype :: TYPE_FULL ) ; $ elementtypes = $ elementtypeService -> findAllElementtypes ( ) ; $ allowedForFull = $ allowedForStructure = $ allowedForArea = [ Elementtype :: TYPE_FULL , Elementtype :: TYPE_STRUCTURE , ] ; $ allowedForContainer = $ allowedForPart = [ Elementtype :: TYPE_LAYOUTAREA , Elementtype :: TYPE_LAYOUTCONTAINER , ] ; $ list = [ ] ; foreach ( $ elementtypes as $ elementtype ) { $ type = $ elementtype -> getType ( ) ; if ( $ for === Elementtype :: TYPE_FULL && ! in_array ( $ type , $ allowedForFull ) ) { continue ; } elseif ( $ for === Elementtype :: TYPE_STRUCTURE && ! in_array ( $ type , $ allowedForStructure ) ) { continue ; } elseif ( $ for === Elementtype :: TYPE_REFERENCE ) { continue ; } elseif ( $ for === Elementtype :: TYPE_LAYOUTAREA && ! in_array ( $ type , $ allowedForArea ) ) { continue ; } elseif ( $ for === Elementtype :: TYPE_LAYOUTCONTAINER && ! in_array ( $ type , $ allowedForContainer ) ) { continue ; } elseif ( $ for === Elementtype :: TYPE_PART && ! in_array ( $ type , $ allowedForPart ) ) { continue ; } $ list [ ] = [ 'id' => $ elementtype -> getId ( ) , 'type' => $ elementtype -> getType ( ) , 'title' => $ elementtype -> getTitle ( ) , 'icon' => $ elementtype -> getIcon ( ) , 'version' => $ elementtype -> getRevision ( ) , ] ; } return new JsonResponse ( [ 'elementtypes' => $ list , 'total' => count ( $ list ) ] ) ; }
List Element Types .
19,439
public static function createArgs ( array $ pointer , array $ context ) { if ( array_key_exists ( 'args' , $ pointer ) ) { $ args = $ pointer [ 'args' ] ; if ( ! is_array ( $ args ) ) { throw new InvalidPointer ( 'args must be an array' ) ; } } elseif ( array_key_exists ( 'options' , $ pointer ) ) { $ args = [ $ pointer [ 'options' ] ] ; } else { $ args = [ ] ; } if ( ! empty ( $ pointer [ 'reset_args' ] ) ) { return $ args ; } if ( ! empty ( $ context [ 'args' ] ) ) { $ args = array_merge ( $ context [ 'args' ] , $ args ) ; } if ( ! empty ( $ context [ 'append_args' ] ) ) { $ args = array_merge ( $ args , $ context [ 'append_args' ] ) ; } return $ args ; }
Creates a arguments list
19,440
public static function resolveRelatedPath ( $ from , $ to ) { $ from_parts = array_filter ( explode ( '/' , $ from ) ) ; $ to_parts = array_filter ( explode ( '/' , $ to ) ) ; foreach ( $ from_parts as $ i => $ path ) { if ( in_array ( $ path , $ to_parts ) ) { $ from_parts [ $ i ] = null ; $ to_parts [ $ i ] = null ; } } $ from_parts = array_filter ( $ from_parts ) ; $ to_parts = array_filter ( $ to_parts ) ; for ( $ i = 0 ; $ i < count ( $ from_parts ) ; $ i ++ ) { array_unshift ( $ to_parts , '..' ) ; } return join ( '/' , $ to_parts ) ; }
Returns a relative path between two filesystem realpaths
19,441
public function map ( array & $ row ) { $ inputs = $ this -> parse ( $ this -> inputsParams , $ row ) ; $ outputs = $ this -> parse ( $ this -> outputParams , $ row ) ; return $ inputs && $ outputs ? [ $ inputs , $ outputs ] : null ; }
Creates an Instance class from an array using the inputKeys and outputKeys specified in the construct
19,442
public static function Trxpv ( array $ r , array $ pv , array & $ trpv ) { $ tr = [ ] ; IAU :: Tr ( $ r , $ tr ) ; IAU :: Rxpv ( $ tr , $ pv , $ trpv ) ; return ; }
- - - - - - - - - i a u T r x p v - - - - - - - - -
19,443
protected function trashCurrentItems ( ) { $ trash = $ this -> entity -> getEntityAttributeValueTrash ( ) ; foreach ( $ this -> items as $ value ) { $ trash -> push ( $ value ) ; } }
Trash the current values by queuing into entity object these trashed values will physically deleted on entity save .
19,444
public function record ( EventMessage $ message ) : void { $ eventRecord = new EventRecord ( $ message , $ this -> aggregateId , $ this -> aggregateType , $ this -> nextSequence ( ) ) ; $ this -> lastSequence = $ eventRecord -> sequenceNumber ( ) ; $ this -> eventRecords -> add ( $ eventRecord ) ; }
Records an event message
19,445
public function initializeSequence ( int $ committedSequence ) : void { assert ( $ this -> isEmpty ( ) , 'Cannot initialize sequence after adding events' ) ; $ this -> committedSequence = $ committedSequence ; }
Initializes the committed sequence
19,446
public function commit ( ) : void { $ this -> committedSequence = $ this -> lastSequence ( ) ; $ this -> eventRecords = SortedSet :: comparable ( EventRecord :: class ) ; }
Clears events and updates committed sequence number
19,447
public function count ( ) : int { if ( ! is_null ( $ this -> count ) ) { return $ this -> count ; } $ count = 0 ; foreach ( $ this as $ entity ) { $ count ++ ; } $ this -> count = $ count ; return $ count ; }
Get the count of entities .
19,448
function it_can_be_compared_to_other_template_fragments ( $ sameValue , $ differentValue , $ differentType ) { $ sameValue -> getValueMask ( ) -> willReturn ( [ '1' , '2' ] ) ; $ sameValue -> getTypeMask ( ) -> willReturn ( '[..]' ) ; $ this -> equals ( $ sameValue ) -> shouldReturn ( true ) ; $ differentValue -> getValueMask ( ) -> willReturn ( [ '3' , '4' ] ) ; $ differentValue -> getTypeMask ( ) -> willReturn ( '[..]' ) ; $ this -> equals ( $ differentValue ) -> shouldReturn ( false ) ; $ differentType -> getValueMask ( ) -> willReturn ( [ '1' , '2' ] ) ; $ differentType -> getTypeMask ( ) -> willReturn ( '[##]' ) ; $ this -> equals ( $ differentType ) -> shouldReturn ( false ) ; }
It can be compared to other template fragments .
19,449
public function dispatch ( $ function , $ args ) { $ class_name = get_class ( $ this ) ; $ class = new \ ReflectionClass ( $ class_name ) ; if ( $ function == '' ) { $ function = $ class -> getConstant ( 'DEFAULT_FUNCTION' ) ; } $ function = str_replace ( '.' , '' , $ function ) ; if ( $ function == '' ) { return $ this -> show_404 ( ) ; } $ function = 'c_' . $ function ; if ( ! $ class -> hasMethod ( $ function ) ) { return $ this -> show_404 ( ) ; } $ func = $ class -> getMethod ( $ function ) ; $ func -> setAccessible ( true ) ; try { $ func -> invoke ( $ this , $ args ) ; } catch ( \ Exception $ ex ) { if ( DEBUG === 1 ) { return $ this -> show_msg ( $ ex -> getMessage ( ) , 'Error' ) ; } else { return $ this -> show_404 ( ) ; } } }
Call controler function according to the given name .
19,450
public static function Era00 ( $ dj1 , $ dj2 ) { $ d1 ; $ d2 ; $ t ; $ f ; $ theta ; if ( $ dj1 < $ dj2 ) { $ d1 = $ dj1 ; $ d2 = $ dj2 ; } else { $ d1 = $ dj2 ; $ d2 = $ dj1 ; } $ t = $ d1 + ( $ d2 - DJ00 ) ; $ f = fmod ( $ d1 , 1.0 ) + fmod ( $ d2 , 1.0 ) ; $ theta = IAU :: Anp ( D2PI * ( $ f + 0.7790572732640 + 0.00273781191135448 * $ t ) ) ; return $ theta ; }
- - - - - - - - - i a u E r a 0 0 - - - - - - - - -
19,451
public static function on ( $ class , $ name , callable $ handler ) { $ class = ObjectHelper :: getClass ( $ class ) ; if ( ! isset ( static :: $ events [ $ class ] [ $ name ] ) ) { static :: $ events [ $ class ] [ $ name ] = [ ] ; } static :: $ events [ $ class ] [ $ name ] [ ] = $ handler ; }
Subscribing in event .
19,452
public static function trigger ( $ class , $ name , Event $ event = null ) { if ( empty ( static :: $ events ) ) { return ; } if ( $ event === null ) { $ event = new static ; } $ event -> handled = false ; $ event -> name = $ name ; if ( is_object ( $ class ) ) { if ( $ event -> owner === null ) { $ event -> owner = $ class ; } $ class = get_class ( $ class ) ; } else { $ class = ltrim ( $ class , '\\' ) ; } do { if ( ! empty ( static :: $ events [ $ class ] [ $ name ] ) ) { foreach ( static :: $ events [ $ class ] [ $ name ] as $ handler ) { call_user_func ( $ handler , $ event ) ; if ( $ event -> handled ) { return ; } } } } while ( ( $ class = get_parent_class ( $ class ) ) !== false ) ; }
Publishing event .
19,453
public static function off ( $ class , $ name , callable $ handler = null ) { $ class = ObjectHelper :: getClass ( $ class ) ; if ( $ handler === null ) { unset ( static :: $ events [ $ class ] [ $ name ] ) ; if ( empty ( static :: $ events [ $ class ] ) ) { unset ( static :: $ events [ $ class ] ) ; } return true ; } $ removed = false ; foreach ( self :: $ events [ $ class ] [ $ name ] as $ i => $ event ) { if ( $ event === $ handler ) { unset ( self :: $ events [ $ class ] [ $ name ] [ $ i ] ) ; $ removed = true ; } } if ( $ removed ) { self :: $ events [ $ class ] [ $ name ] = array_values ( self :: $ events [ $ class ] [ $ name ] ) ; } return $ removed ; }
Detach event .
19,454
public static function offMulti ( array $ names ) { foreach ( $ names as $ value ) { list ( $ class , $ name ) = $ value ; static :: off ( $ class , $ name ) ; } }
Detach events .
19,455
public static function get ( $ class , $ name ) { $ class = ObjectHelper :: getClass ( $ class ) ; return ! empty ( static :: $ events [ $ class ] [ $ name ] ) ? static :: $ events [ $ class ] [ $ name ] : null ; }
Get event .
19,456
public static function exists ( $ class , $ name ) { $ class = ObjectHelper :: getClass ( $ class ) ; do { if ( ! empty ( self :: $ events [ $ class ] [ $ name ] ) ) { return true ; } } while ( ( $ class = get_parent_class ( $ class ) ) !== false ) ; return false ; }
Exists event .
19,457
public static function countHandlers ( $ class , $ name ) { $ class = ObjectHelper :: getClass ( $ class ) ; $ count = 0 ; do { if ( ! empty ( self :: $ events [ $ class ] [ $ name ] ) ) { $ count += count ( static :: $ events [ $ class ] [ $ name ] ) ; } } while ( ( $ class = get_parent_class ( $ class ) ) !== false ) ; return $ count ; }
Count handlers of events .
19,458
public function toHuman ( ) { $ units = array ( "week" => 7 * 24 * 3600 , "day" => 24 * 3600 , "hour" => 3600 , "minute" => 60 , "second" => 1 , ) ; if ( $ this -> seconds == 0 ) return "0 seconds" ; $ s = "" ; foreach ( $ units as $ name => $ divisor ) { if ( $ quot = intval ( $ this -> seconds / $ divisor ) ) { $ s .= "$quot $name" ; $ s .= ( abs ( $ quot ) > 1 ? "s" : "" ) . ", " ; $ this -> seconds -= $ quot * $ divisor ; } } return substr ( $ s , 0 , - 2 ) ; }
Convert seconds to human readable text .
19,459
public function findAsset ( $ url ) { if ( empty ( $ url ) ) { return false ; } $ this -> asset = $ this -> processUrl ( $ url ) ; if ( $ this -> asset === false ) { return false ; } $ mainAsset = $ this -> findMainAsset ( $ this -> docRoot . DS . $ this -> assetDir . DS . $ this -> asset [ 'asset' ] ) ; if ( $ mainAsset !== false ) { return $ mainAsset ; } $ themeAsset = $ this -> findThemeAsset ( $ this -> asset [ 'folder' ] , $ this -> assetDir . DS . $ this -> asset [ 'asset' ] ) ; if ( $ themeAsset !== false ) { return $ themeAsset ; } return $ this -> findFallbackAsset ( $ this -> assetDir . DS . $ this -> asset [ 'asset' ] , $ this -> Folder ) ; }
find the asset and create symlink
19,460
public function findMainAsset ( $ asset ) { if ( file_exists ( $ asset ) && $ this -> checkLink ( $ asset ) ) { return '/' . $ this -> assetDir . '/' . $ this -> asset [ 'asset' ] ; } return false ; }
check for a main asset
19,461
public function findThemeAsset ( $ theme , $ asset ) { if ( ! empty ( $ theme ) ) { $ Folders = $ this -> engine -> getFolders ( ) ; if ( $ Folders -> exists ( $ theme ) ) { $ this -> Folder = $ Folders -> get ( $ theme ) ; $ folderPath = rtrim ( $ this -> Folder -> getPath ( ) , '/' ) ; $ folderPath = $ this -> removeViewFromPath ( $ folderPath ) ; if ( file_exists ( $ folderPath . DS . $ asset ) ) { $ this -> createSymlink ( $ folderPath ) ; return '/' . $ this -> assetDir . '/' . $ this -> asset [ 'asset' ] ; } } } return false ; }
check for a theme asset
19,462
public function findFallbackAsset ( $ asset , $ Folder = null ) { $ folderEmpty = empty ( $ Folder ) ; $ folderAllowFallback = ! empty ( $ Folder ) && $ Folder -> getFallback ( ) ; if ( $ folderEmpty || $ folderAllowFallback ) { $ fallbackPath = $ this -> engine -> getDirectory ( ) ; $ fallbackPath = $ this -> removeViewFromPath ( $ fallbackPath ) ; if ( file_exists ( $ fallbackPath . DS . $ asset ) ) { $ this -> createSymlink ( $ fallbackPath ) ; return '/' . $ this -> assetDir . '/' . $ this -> asset [ 'asset' ] ; } } return false ; }
find the fallback asset
19,463
public function removeViewFromPath ( $ path ) { $ folderBits = explode ( '/' , $ path ) ; if ( strtolower ( end ( $ folderBits ) ) === 'views' ) { array_pop ( $ folderBits ) ; $ path = implode ( '/' , $ folderBits ) ; } return $ path ; }
remove views from any folder path
19,464
public function setDocRoot ( $ docRoot ) { if ( empty ( $ docRoot ) || ! file_exists ( $ docRoot ) || ! is_dir ( $ docRoot ) ) { throw new \ InvalidArgumentException ( 'The document root set is not a valid directory.' ) ; } $ this -> docRoot = rtrim ( $ docRoot , '/' ) ; }
set the document root
19,465
public function setFileSystem ( $ fileSystem ) { if ( ! is_object ( $ fileSystem ) || ! is_a ( $ fileSystem , 'Symfony\Component\Filesystem\Filesystem' ) ) { throw new \ InvalidArgumentException ( 'The File System was not a valid object.' ) ; } $ this -> fileSystem = $ fileSystem ; }
set the file system
19,466
public function setAssetDir ( $ assetDir ) { $ emptyAssetDir = empty ( $ assetDir ) ; $ folderNotExists = ! file_exists ( $ this -> docRoot . DS . $ assetDir ) ; $ folderNotDir = ! is_dir ( $ this -> docRoot . DS . $ assetDir ) ; if ( $ emptyAssetDir || $ folderNotExists || $ folderNotDir ) { throw new \ InvalidArgumentException ( 'The asset directory set is not a valid directory.' ) ; } if ( ! is_writable ( $ this -> docRoot . DS . $ assetDir ) ) { throw new \ LogicException ( 'The folder "' . $ this -> docRoot . DS . $ assetDir . '" must be writable.' ) ; } $ this -> assetDir = $ assetDir ; }
set the asset container folder
19,467
public static function compare ( ComparableInterface $ first = null , ComparableInterface $ second = null , $ nullGreater = false ) { if ( $ first === $ second ) { return self :: EQUAL ; } elseif ( null === $ first ) { return $ nullGreater ? self :: FIRST_GT_SECOND : self :: FIRST_LT_SECOND ; } elseif ( null === $ second ) { return $ nullGreater ? self :: FIRST_LT_SECOND : self :: FIRST_GT_SECOND ; } return $ first -> compareTo ( $ second ) ; }
Compares an object with another object for order .
19,468
public function setTemplates ( array $ templates ) { if ( $ templates !== null && is_array ( $ templates ) ) { $ this -> _userChangedTemplates = array_merge ( array_keys ( $ templates ) , $ this -> _userChangedTemplates ) ; } $ this -> _setTemplatesWrapper ( $ templates ) ; }
Sets templates to use .
19,469
protected function _setTemplatesInternal ( array $ templates ) { if ( is_array ( $ templates ) ) { foreach ( $ this -> _userChangedTemplates as $ key ) { if ( array_key_exists ( $ key , $ templates ) ) { unset ( $ templates [ $ key ] ) ; } } } $ this -> _setTemplatesWrapper ( $ templates ) ; }
Set templates after removing the ones previously set by the user this is to protect against overriding the users wishes
19,470
public function submit ( $ caption = null , array $ options = [ ] ) { if ( ! preg_match ( '/\.(jpg|jpe|jpeg|gif|png|ico)$/' , $ caption ) ) { $ options = $ this -> parseButtonClass ( $ options ) ; } if ( ! empty ( $ this -> getConfig ( 'layout.classes.submitContainer' ) ) ) { $ this -> _setTemplatesInternal ( [ 'submitContainer' => '<div{{attrs}}>{{content}}</div>' , ] ) ; $ options [ 'templateVars' ] [ 'attrs' ] = $ this -> templater ( ) -> formatAttributes ( [ 'class' => $ this -> getConfig ( 'layout.classes.submitContainer' ) , ] ) ; } $ options = $ this -> cleanArray ( $ options ) ; return parent :: submit ( $ caption , $ options ) ; }
Creates submit button but adds bootstrap styling
19,471
protected function _bootstrapTypeMap ( $ type ) { $ map = $ this -> _bootstrapTypeMap ; return isset ( $ map [ $ type ] ) ? $ map [ $ type ] : 'text' ; }
Maps the type to bootstrap else text
19,472
protected function _parseOptions ( $ fieldName , $ options ) { $ needsMagicType = false ; if ( empty ( $ options [ 'type' ] ) ) { $ needsMagicType = true ; $ context = $ this -> _getContext ( ) ; $ internalType = $ context -> type ( $ fieldName ) ; if ( $ this -> isHtml5Render ( $ options ) && in_array ( $ internalType , [ 'date' , 'datetime' , 'time' ] ) ) { $ options [ 'type' ] = $ this -> _bootstrapTypeMap ( $ internalType ) ; } else { $ options [ 'type' ] = $ this -> _inputType ( $ fieldName , $ options ) ; } } else { if ( $ this -> isHtml5Render ( $ options ) && in_array ( $ options [ 'type' ] , [ 'date' , 'datetime' , 'time' ] ) ) { $ options [ 'type' ] = $ this -> _bootstrapTypeMap ( $ options [ 'type' ] ) ; } } $ options = $ this -> _magicOptions ( $ fieldName , $ options , $ needsMagicType ) ; return $ options ; }
In case the type is defined manually by the user we need to map it
19,473
static function getSession ( ) { if ( self :: $ session == null ) { $ sessionImplClassName = Settings :: getSettings ( 'php-platform/session' , "session.class" ) ; try { $ sessionImplReflectionClass = new \ ReflectionClass ( $ sessionImplClassName ) ; } catch ( \ ReflectionException $ re ) { throw new ProgrammingError ( "session implementation class is not configured or invalid" ) ; } $ sessionInterfaceName = 'PhpPlatform\Session\Session' ; if ( ! $ sessionImplReflectionClass -> implementsInterface ( $ sessionInterfaceName ) ) { throw new ProgrammingError ( "$sessionImplClassName does not implement $sessionInterfaceName" ) ; } $ sessionGetInstanceReflectionMethod = $ sessionImplReflectionClass -> getMethod ( 'getInstance' ) ; self :: $ session = $ sessionGetInstanceReflectionMethod -> invokeArgs ( null , array ( ) ) ; } return self :: $ session ; }
This method returns Session singleton object
19,474
public function findColumn ( $ label ) { $ column = false ; foreach ( $ this -> getColumns ( ) as $ col ) { if ( $ col -> getLabel ( ) == $ label ) { $ column = $ col ; break ; } } return $ column ; }
Finds the column with the specified label
19,475
public static function insert ( & $ arr , $ path , $ value , $ delimiter = '.' ) { if ( ! static :: exists ( $ arr , $ path , $ delimiter ) ) { static :: set ( $ arr , $ path , $ value , $ delimiter ) ; } }
Inserts a new value into a key or path only if the key or path does not yet exists .
19,476
public static function exists ( array & $ arr , $ path , $ delimiter = '.' ) { if ( array_key_exists ( $ path , $ arr ) ) { return true ; } $ segments = explode ( $ delimiter , $ path ) ; $ cur = $ arr ; foreach ( $ segments as $ segment ) { if ( ! is_array ( $ cur ) or ! array_key_exists ( $ segment , $ cur ) ) { return false ; } $ cur = $ cur [ $ segment ] ; } return true ; }
Tests if a key or path exists in a specified array . If the specified key or path exists this method will return TRUE otherwise FALSE .
19,477
public static function keys ( $ array , $ prefix = null ) { $ keys = array_keys ( $ array ) ; if ( ! empty ( $ prefix ) ) { $ keys = static :: prefix ( $ keys , $ prefix ) ; } return $ keys ; }
This method will return all the keys of a given array and optionally prefix each key with a specified prefix .
19,478
public static function values ( $ array , $ prefix = null ) { $ values = array_values ( $ array ) ; if ( ! empty ( $ prefix ) ) { $ values = static :: prefix ( $ values , $ prefix ) ; } return $ values ; }
This method will return all values of a given array and optionally prefix each value with a specified prefix .
19,479
public static function map ( $ callbacks , $ arr , $ keys = null ) { foreach ( $ arr as $ key => $ val ) { if ( is_array ( $ val ) ) { $ arr [ $ key ] = static :: map ( $ callbacks , $ arr [ $ key ] ) ; } elseif ( ! is_array ( $ keys ) or in_array ( $ key , $ keys ) ) { if ( is_array ( $ callbacks ) ) { foreach ( $ callbacks as $ callback ) { $ arr [ $ key ] = call_user_func ( $ callback , $ arr [ $ key ] ) ; } } else { $ arr [ $ key ] = call_user_func ( $ callbacks , $ arr [ $ key ] ) ; } } } return $ arr ; }
Recursive version of array_map applies one or more callbacks to all elements in an array including sub - arrays .
19,480
public static function remapCollection ( array $ collection , array $ map , $ createMode = true ) { $ results = array ( ) ; foreach ( $ collection as $ item ) { $ results [ ] = self :: remap ( $ item , $ map , $ createMode ) ; } return $ results ; }
Remaps a collection .
19,481
public static function extract ( array & $ arr , $ path , $ default = null , $ delimiter = '.' ) { $ value = static :: get ( $ arr , $ path , $ default , $ delimiter ) ; static :: delete ( $ arr , $ path , $ delimiter ) ; return $ value ; }
Returns a value for a specified array key and deletes the key .
19,482
public static function getFromHeaderLine ( $ header_line , $ source_url ) { $ parts = explode ( ';' , trim ( $ header_line ) ) ; $ name = '' ; $ value = '' ; $ expires = null ; $ path = null ; $ domain = '' ; preg_match ( '#([^=]*)=(.*)#' , $ parts [ 0 ] , $ match ) ; $ name = trim ( $ match [ 1 ] ) ; $ value = trim ( $ match [ 2 ] ) ; for ( $ x = 1 ; $ x < count ( $ parts ) ; ++ $ x ) { $ parts [ $ x ] = trim ( $ parts [ $ x ] ) ; if ( preg_match ( "#^expires\s*=(.*)# i" , $ parts [ $ x ] , $ match ) ) { $ expires = trim ( $ match [ 1 ] ) ; } if ( preg_match ( "#^path\s*=(.*)# i" , $ parts [ $ x ] , $ match ) ) { $ path = trim ( $ match [ 1 ] ) ; } if ( preg_match ( "#^domain\s*=(.*)# i" , $ parts [ $ x ] , $ match ) ) { $ domain = trim ( $ match [ 1 ] ) ; } } $ expires = str_replace ( '"' , '' , $ expires ) ; $ path = str_replace ( '"' , '' , $ path ) ; $ domain = str_replace ( '"' , '' , $ domain ) ; return new self ( $ source_url , $ name , $ value , $ expires , $ path , $ domain ) ; }
Returns a CookieDescriptor - object initiated by the given cookie - header - line .
19,483
protected function validateDate ( string & $ strDate ) { if ( ! preg_match ( "/\d{4}\-\d{2}-\d{2}/" , $ strDate ) ) { if ( $ iTime = strtotime ( $ strDate ) ) { $ strDate = date ( 'Y-m-d' , $ iTime ) ; } else { throw new \ Exception ( 'Invalid date string given to ' . debug_backtrace ( ) [ 1 ] [ 'function' ] . '. Use format YYYY-MM-DD.' ) ; } } }
Verifies that the given date string is in format YYYY - MM - DD .
19,484
public function transform ( $ entity ) { if ( $ entity === NULL ) { return NULL ; } $ getter = 'get' . ucfirst ( $ this -> identifierName ) ; return array ( '__class' => $ this -> entityClass , $ this -> identifierName => $ entity -> $ getter ( ) ) ; }
Transforms an entity to its json object
19,485
public function reverseTransform ( $ properties ) { if ( ! is_array ( $ properties ) ) { return NULL ; } if ( ! isset ( $ properties [ $ this -> identifierName ] ) ) { throw new TransformationFailedException ( sprintf ( 'Identifier (%s) for entity %s is not set in properties %s' , $ this -> identifierName , $ this -> entityClass , json_encode ( $ properties , JSON_PRETTY_PRINT ) ) ) ; } $ identifier = $ properties [ $ this -> identifierName ] ; $ entity = $ this -> om -> getRepository ( $ this -> entityClass ) -> findOneBy ( array ( $ this -> identifierName => $ identifier ) ) ; if ( ! ( $ entity instanceof $ this -> entityClass ) ) { throw new TransformationFailedException ( sprintf ( 'Entity %s with identifier (%s) "%s" cannot be found' , $ this -> entityClass , $ this -> identifierName , $ identifier ) ) ; } return $ entity ; }
Transforms an json object to an entity
19,486
public function moveTo ( string $ destination ) : void { $ destination = is_dir ( $ destination ) ? ( "$destination/{$this->clientName}" ) : $ destination ; Filesystem :: checkWritable ( dirname ( $ destination ) ) ; if ( ! move_uploaded_file ( $ this -> path , $ destination ) ) { throw new FilesystemException ( "Failed to move file {$this->path} to {$destination}" ) ; } }
Move the uploaded file safely to another location . Ensures that files were actually uploaded through PHP before moving them .
19,487
public static function create ( $ className , $ level ) { $ event = new LogEvent ( ) ; $ event -> _setLevel ( LogLevel :: create ( $ level ) ) ; $ event -> _setDate ( DateMilli :: create ( ) ) ; $ trace = debug_backtrace ( DEBUG_BACKTRACE_PROVIDE_OBJECT , 4 ) ; $ trace [ 'class' ] = $ className ; $ trace [ 'file' ] = $ trace [ 2 ] [ 'file' ] ; $ trace [ 'line' ] = $ trace [ 2 ] [ 'line' ] ; $ event -> _setTrace ( $ trace ) ; return $ event ; }
Create a new log event and return it
19,488
private function scandir ( $ dir ) { $ dir = trim ( $ dir , '/' ) . '/' ; $ absolute = $ this -> absolute ( $ dir ) ; $ files = scandir ( $ absolute ) ; foreach ( $ files as $ file ) { if ( $ file === "." || $ file === ".." ) { continue ; } if ( is_dir ( $ absolute . $ file ) ) { $ this -> scandir ( $ dir . $ file ) ; } else { $ path = preg_replace ( "#^" . Config :: get ( 'input_dir' ) . "#" , "" , $ dir . $ file ) ; $ this -> paths [ ] = array ( 'path' => $ path ) ; } } }
recursively scan the directory for any files
19,489
public function createInstruction ( InputDescriptor $ input , TemplateInterface $ template , array $ flags = [ ] ) { if ( ! $ template -> getManaged ( ) ) { return null ; } $ cacheItem = $ this -> cacheManager -> findByTemplateAndFile ( $ template -> getKey ( ) , $ input -> getFileId ( ) , $ input -> getFileVersion ( ) ) ; if ( in_array ( Batch :: FILTER_ERROR , $ flags ) && $ cacheItem && ! $ this -> isError ( $ cacheItem ) ) { $ this -> logger -> info ( 'Skipping non-error item' ) ; return null ; } if ( in_array ( Batch :: FILTER_MISSING , $ flags ) && $ cacheItem && ! $ this -> isMissing ( $ cacheItem ) ) { $ this -> logger -> info ( 'Skipping non-missing item' ) ; return null ; } if ( in_array ( Batch :: FILTER_UNCACHED , $ flags ) && $ cacheItem && $ this -> isCached ( $ cacheItem ) ) { $ this -> logger -> info ( 'Skipping cached item' ) ; return null ; } if ( ! $ cacheItem ) { $ cacheItem = new CacheItem ( ) ; $ cacheItem -> setId ( $ this -> cacheIdStrategy -> createCacheId ( $ template , $ input ) ) -> setVolumeId ( $ input -> getVolumeId ( ) ) -> setFileId ( $ input -> getFileId ( ) ) -> setFileVersion ( $ input -> getFileVersion ( ) ) -> setTemplateKey ( $ template -> getKey ( ) ) -> setTemplateRevision ( $ template -> getRevision ( ) ) -> setCacheStatus ( CacheItem :: STATUS_WAITING ) -> setQueueStatus ( CacheItem :: QUEUE_WAITING ) -> setCreatedAt ( new \ DateTime ( ) ) ; } $ cacheItem -> setQueuedAt ( new \ DateTime ( ) ) ; return new Instruction ( $ input , $ template , $ cacheItem ) ; }
Resolve batch to queue items .
19,490
public function prepareHeaders ( $ requestHeaders ) { $ responseHeaders = [ ] ; if ( isset ( $ requestHeaders [ 'Origin' ] , $ this -> _cors [ 'Origin' ] ) ) { if ( in_array ( '*' , $ this -> _cors [ 'Origin' ] ) || in_array ( $ requestHeaders [ 'Origin' ] , $ this -> _cors [ 'Origin' ] ) ) { $ responseHeaders [ 'Access-Control-Allow-Origin' ] = $ requestHeaders [ 'Origin' ] ; } } $ this -> prepareAllowHeaders ( 'Headers' , $ requestHeaders , $ responseHeaders ) ; if ( isset ( $ requestHeaders [ 'Access-Control-Request-Method' ] ) ) { $ responseHeaders [ 'Access-Control-Allow-Methods' ] = implode ( ', ' , $ this -> _cors [ 'Access-Control-Request-Method' ] ) ; } if ( isset ( $ this -> _cors [ 'Access-Control-Allow-Credentials' ] ) ) { $ responseHeaders [ 'Access-Control-Allow-Credentials' ] = $ this -> _cors [ 'Access-Control-Allow-Credentials' ] ? 'true' : 'false' ; } if ( isset ( $ this -> _cors [ 'Access-Control-Max-Age' ] ) && $ this -> isOptions ( ) ) { $ responseHeaders [ 'Access-Control-Max-Age' ] = $ this -> _cors [ 'Access-Control-Max-Age' ] ; } if ( isset ( $ this -> _cors [ 'Access-Control-Expose-Headers' ] ) ) { $ responseHeaders [ 'Access-Control-Expose-Headers' ] = implode ( ', ' , $ this -> _cors [ 'Access-Control-Expose-Headers' ] ) ; } return $ responseHeaders ; }
For each CORS headers create the specific response .
19,491
protected function prepareAllowHeaders ( $ type , $ requestHeaders , & $ responseHeaders ) { $ requestHeaderField = 'Access-Control-Request-' . $ type ; $ responseHeaderField = 'Access-Control-Allow-' . $ type ; if ( ! isset ( $ requestHeaders [ $ requestHeaderField ] , $ this -> _cors [ $ requestHeaderField ] ) ) { return ; } if ( isset ( $ this -> _cors [ $ requestHeaderField ] ) && in_array ( '*' , $ this -> _cors [ $ requestHeaderField ] ) ) { $ responseHeaders [ $ responseHeaderField ] = $ this -> headerize ( $ requestHeaders [ $ requestHeaderField ] ) ; } else { $ requestedData = preg_split ( '/[\\s,]+/' , $ requestHeaders [ $ requestHeaderField ] , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ acceptedData = array_uintersect ( $ requestedData , $ this -> _cors [ $ requestHeaderField ] , 'strcasecmp' ) ; if ( ! empty ( $ acceptedData ) ) { $ responseHeaders [ $ responseHeaderField ] = implode ( ', ' , $ acceptedData ) ; } } }
Handle classic CORS request to avoid duplicate code .
19,492
private function createClientDefinition ( $ rootDir ) { $ bugsnagClient = new Definition ( Client :: class , [ $ this -> configuration -> getApiKey ( ) , ] ) ; $ bugsnagClient -> setFactory ( [ Client :: class , "make" ] ) ; $ bugsnagClient -> setPublic ( false ) ; $ rootDir = dirname ( $ rootDir ) ; $ bugsnagClient -> addMethodCall ( "setProjectRoot" , [ $ rootDir ] ) ; $ bugsnagClient -> addMethodCall ( "setStripPath" , [ $ rootDir ] ) ; $ bugsnagClient -> addMethodCall ( "setFilters" , [ [ 'clientIp' ] ] ) ; return $ bugsnagClient ; }
Creates the bugsnag client
19,493
private function addLoggerReferenceToContainer ( Definition $ handlerDefinition , ContainerBuilder $ container ) { $ monitoringDefinition = new Definition ( FingersCrossedHandler :: class , [ $ handlerDefinition , Logger :: WARNING ] ) ; $ monitoringDefinition -> setPublic ( false ) ; $ container -> setDefinition ( self :: MONOLOG_HANDLER_SERVICE_ID , $ monitoringDefinition ) ; }
Adds the monolog handler to the service container
19,494
private function collectReportTransformers ( Definition $ handler , ContainerBuilder $ container ) { $ taggedServices = $ container -> findTaggedServiceIds ( self :: REPORT_TRANSFORMER_TAG ) ; foreach ( $ taggedServices as $ serviceId => $ tags ) { $ handler -> addMethodCall ( "addReportTransformer" , [ new Reference ( $ serviceId ) ] ) ; } }
Collects all report transformers and registers them in the handler
19,495
private function registerMonologHandlerInAllChannels ( ContainerBuilder $ container ) { $ monitoringReference = new Reference ( self :: MONOLOG_HANDLER_SERVICE_ID ) ; foreach ( $ container -> getDefinitions ( ) as $ key => $ definition ) { if ( 0 === strpos ( $ key , "monolog.logger." ) ) { $ definition -> addMethodCall ( "pushHandler" , [ $ monitoringReference ] ) ; } } }
Registers the monolog handler in all channels
19,496
public static function create ( Comparator $ comparator , ? string $ keyType = null , ? string $ valueType = null ) : SortedTable { return new static ( $ comparator , $ keyType , $ valueType ) ; }
Creates collection with a custom comparator
19,497
public static function comparable ( ? string $ keyType = null , ? string $ valueType = null ) : SortedTable { assert ( Validate :: isNull ( $ keyType ) || Validate :: implementsInterface ( $ keyType , Comparable :: class ) , sprintf ( '%s expects $keyType to implement %s' , __METHOD__ , Comparable :: class ) ) ; return new static ( new ComparableComparator ( ) , $ keyType , $ valueType ) ; }
Creates collection with comparable keys
19,498
public function addGlobals ( $ globals ) { foreach ( $ globals as $ name => $ value ) { if ( ! is_object ( $ value ) ) { $ value = new ViewRendererStaticClassProxy ( $ value ) ; } $ this -> twig -> addGlobal ( $ name , $ value ) ; } }
Adds a global objects or static classes
19,499
public function addLexerOptions ( $ options ) { $ lexer = new \ Twig_Lexer ( $ this -> twig , $ options ) ; $ this -> twig -> setLexer ( $ lexer ) ; }
Sets a Twig lexer options to change templates syntax