idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
47,100
public function configure ( ) { $ gitHubUser = $ this -> arguments -> getOpt ( 'github-user' , null ) ; if ( is_null ( $ gitHubUser ) ) { $ gitHubUser = exec ( 'whoami' ) ; if ( $ this -> output -> getMode ( ) != 'minimal' ) { $ this -> output -> addLine ( "Assuming {$gitHubUser} as your GitHub username. To override, please specify the '--github-user' flag" , 'info' ) ; } } else { if ( $ this -> output -> getMode ( ) != 'minimal' ) { $ this -> output -> addLine ( "Using the provided GitHub username: {$gitHubUser}" , 'info' ) ; } } $ gitHubUser = escapeshellarg ( $ gitHubUser ) ; if ( $ this -> output -> getMode ( ) != 'minimal' ) { $ this -> output -> addLine ( 'Updating the framework repository to point to your GitHub fork' , 'success' ) ; } $ workTree = PATH_CORE . DS . 'vendor' . DS . 'hubzero' . DS . 'framework' ; $ dir = $ workTree . DS . '.git' ; $ cmd = "git --git-dir={$dir} --work-tree={$workTree} remote set-url --push origin git@github.com:{$gitHubUser}/framework.git 2>&1" ; $ result = shell_exec ( $ cmd ) ; }
Configures the package repository setup for use in a given environment
47,101
public function anchor ( $ matches ) { if ( empty ( $ matches ) ) { return '' ; } $ whole = $ matches [ 0 ] ; $ prtcl = rtrim ( $ matches [ 1 ] , ':' ) ; $ url = $ matches [ 3 ] ; $ url .= ( isset ( $ matches [ 4 ] ) ) ? $ matches [ 4 ] : '' ; $ url .= ( isset ( $ matches [ 5 ] ) ) ? $ matches [ 5 ] : '' ; $ url .= ( isset ( $ matches [ 6 ] ) ) ? $ matches [ 6 ] : '' ; $ prfx = preg_replace ( '/^([\s]*)(.*)/i' , "$1" , $ whole ) ; $ href = trim ( $ whole ) ; if ( substr ( $ href , 0 , 1 ) == '>' ) { $ href = ltrim ( $ href , '>' ) ; $ prfx .= '>' ; } $ txt = $ href ; if ( $ prtcl == 'mailto' ) { $ txt = $ url ; $ href = 'mailto:' . Str :: obfuscate ( $ url ) ; } return $ prfx . '<a class="ext-link" href="' . $ href . '" rel="external">' . $ txt . '</a>' ; }
Automatically links any strings matching a URL or email pattern
47,102
public static function between ( $ check , $ min , $ max ) { $ length = mb_strlen ( $ check ) ; return ( $ length >= $ min && $ length <= $ max ) ; }
Checks that a string length is within s specified range . Spaces are included in the character count . Returns true is string matches value min max or between min and max
47,103
public static function blank ( $ check ) { if ( is_array ( $ check ) ) { extract ( self :: _defaults ( $ check ) ) ; } return ! self :: _check ( $ check , '/[^\\s]/' ) ; }
Returns true if field is left blank - OR - only whitespace characters are present in its value Whitespace characters include Space Tab Carriage Return Newline
47,104
public static function username ( $ x ) { if ( ! preg_match ( "/^[0-9a-z]+[_0-9a-z]*$/" , $ x ) ) { return false ; } if ( self :: nonNegativeInteger ( $ x ) ) { return false ; } if ( self :: reserved ( 'username' , $ x ) ) { return false ; } return true ; }
Check if a username is valid .
47,105
public static function group ( $ cn , $ allowDashes = false ) { $ pattern = '/^[0-9a-z]+[' . ( $ allowDashes ? '-' : '' ) . '_0-9a-z]*$/' ; if ( ! preg_match ( $ pattern , $ cn ) ) { return false ; } if ( self :: nonNegativeInteger ( $ cn ) ) { return false ; } if ( self :: reserved ( 'group' , $ cn ) ) { return false ; } return true ; }
Check if a group alias is valid
47,106
public static function email ( $ check , $ deep = false , $ regex = null ) { if ( is_array ( $ check ) ) { extract ( self :: _defaults ( $ check ) ) ; } if ( $ regex === null ) { $ regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self :: $ _pattern [ 'hostname' ] . '$/i' ; } $ return = self :: _check ( $ check , $ regex ) ; if ( $ deep === false || $ deep === null ) { return $ return ; } if ( $ return === true && preg_match ( '/@(' . self :: $ _pattern [ 'hostname' ] . ')$/i' , $ check , $ regs ) ) { if ( function_exists ( 'getmxrr' ) && getmxrr ( $ regs [ 1 ] , $ mxhosts ) ) { return true ; } if ( function_exists ( 'checkdnsrr' ) && checkdnsrr ( $ regs [ 1 ] , 'MX' ) ) { return true ; } return is_array ( gethostbynamel ( $ regs [ 1 ] ) ) ; } return false ; }
Validates for an email address .
47,107
public static function ip ( $ check , $ type = 'both' ) { return with ( new \ Hubzero \ Utility \ Ip ( $ check ) ) -> isValid ( $ type ) ; }
Validates an IP address
47,108
public static function phone ( $ check , $ regex = null , $ country = 'all' ) { if ( is_array ( $ check ) ) { extract ( self :: _defaults ( $ check ) ) ; } if ( $ regex === null ) { switch ( $ country ) { case 'us' : case 'ca' : case 'can' : case 'all' : $ regex = '/^(?:(?:\+?1\s*(?:[.-]\s*)?)?' ; $ areaCode = '(?![2-9]11)(?!555)([2-9][0-8][0-9])' ; $ regex .= '(?:\(\s*' . $ areaCode . '\s*\)|' . $ areaCode . ')' ; $ regex .= '\s*(?:[.-]\s*)?)' ; $ regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))' ; $ regex .= '(?!(555(01([0-9][0-9])|1212)))' ; $ regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)' ; $ regex .= '?([0-9]{4})' ; $ regex .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/' ; break ; } } if ( empty ( $ regex ) ) { return self :: _pass ( 'phone' , $ check , $ country ) ; } return self :: _check ( $ check , $ regex ) ; }
Check that a value is a valid phone number .
47,109
protected static function _defaults ( $ params ) { $ defaults = array ( 'check' => null , 'regex' => null , 'country' => null , 'deep' => false , 'type' => null ) ; $ params = array_merge ( $ defaults , $ params ) ; if ( $ params [ 'country' ] !== null ) { $ params [ 'country' ] = mb_strtolower ( $ params [ 'country' ] ) ; } return $ params ; }
Get the values to use when value sent to validation method is an array .
47,110
public function sort ( $ key , $ asc = true ) { return $ this -> sortByCallback ( function ( $ a , $ b ) use ( $ key , $ asc ) { if ( ! isset ( $ a -> $ key ) || ! isset ( $ b -> $ key ) ) { if ( ! isset ( $ a -> $ key ) ) { return ( $ asc ) ? - 1 : 1 ; } if ( ! isset ( $ b -> $ key ) ) { return ( $ asc ) ? 1 : - 1 ; } return 0 ; } if ( $ asc ) { return strnatcmp ( $ a -> $ key , $ b -> $ key ) ; } else { return strnatcmp ( $ b -> $ key , $ a -> $ key ) ; } } ) ; }
Sorts items by a given field and direction
47,111
public function find ( $ name , $ return = true ) { foreach ( $ this as $ entity ) { if ( $ entity -> isFile ( ) ) { if ( $ entity -> getName ( ) == $ name ) { return ( $ return ) ? $ entity : true ; } } else { foreach ( $ entity -> listContents ( true ) as $ sub ) { if ( $ sub -> getName ( ) == $ name ) { return ( $ return ) ? $ sub : true ; } } } } return false ; }
Finds the first entity with a given name optionally returning it
47,112
public function hasExtensions ( $ requirements ) { $ files = $ this -> getFlatListOfFiles ( ) ; $ extensions = $ this -> getFlatListOfExtensions ( ) ; foreach ( $ requirements as $ type => $ constraint ) { if ( is_numeric ( $ constraint ) ) { if ( ! array_key_exists ( $ type , $ extensions ) || $ extensions [ $ type ] < $ constraint ) { return false ; } } else if ( is_callable ( $ constraint ) ) { if ( call_user_func_array ( $ constraint , [ $ extensions , $ files ] ) === false ) { return false ; } } } return true ; }
Checks to see whether or not the required extensions are in the current collection
47,113
public function findFirstWithExtension ( $ extension ) { foreach ( $ this -> getFlatListOfFiles ( ) as $ file ) { if ( $ file -> hasExtension ( $ extension ) ) { return $ file ; } } return false ; }
Finds the first item with the given extension
47,114
public function findAllWithExtension ( $ extensions ) { $ found = [ ] ; if ( ! is_array ( $ extensions ) ) { $ extensions = [ $ extensions ] ; } foreach ( $ this -> getFlatListOfFiles ( ) as $ file ) { $ ext = $ file -> getExtension ( ) ; if ( in_array ( $ ext , $ extensions ) ) { $ found [ ] = $ file ; } } return $ found ; }
Finds all items with the given extension
47,115
public function getFlatListOfFiles ( ) { if ( ! isset ( $ this -> flatData ) ) { $ this -> flatData = [ ] ; foreach ( $ this as $ entity ) { if ( $ entity -> isFile ( ) ) { $ this -> flatData [ ] = $ entity ; } else { foreach ( $ entity -> listContents ( true ) as $ sub ) { if ( $ sub -> isfile ( ) ) { $ this -> flatData [ ] = $ sub ; } } } } } return $ this -> flatData ; }
Builds a flat list of files by diving down recursively
47,116
public function getFlatListOfExtensions ( ) { if ( ! isset ( $ this -> flatExtentions ) ) { $ this -> flatExtentions = [ ] ; foreach ( $ this -> getFlatListOfFiles ( ) as $ file ) { $ this -> flatExtentions [ ] = $ file -> getExtension ( ) ; } $ this -> flatExtentions = array_count_values ( $ this -> flatExtentions ) ; } return $ this -> flatExtentions ; }
Builds a flat list of extensions based on files list
47,117
public function call ( $ class , $ task , Arguments $ arguments , Output $ output ) { $ class = Arguments :: routeCommand ( $ class ) ; $ backtrace = debug_backtrace ( ) ; $ previous = $ backtrace [ 1 ] ; $ prevClass = $ previous [ 'class' ] ; $ prevTask = $ previous [ 'function' ] ; if ( $ prevClass == $ class && $ prevTask == $ task ) { $ output -> error ( 'You\'ve attempted to enter an infinite loop. We\'ve stopped you. You\'re welcome.' ) ; } if ( $ task == 'help' ) { $ output = $ output -> getHelpOutput ( ) ; } $ command = new $ class ( $ output , $ arguments ) ; $ command -> { $ task } ( ) ; }
Method to call another console command
47,118
public function getCacheContent ( ) { $ content = '' ; if ( ! App :: has ( 'cache.store' ) || ! $ this -> params -> get ( 'cache' ) ) { return $ content ; } $ debug = App :: get ( 'config' ) -> get ( 'debug' ) ; $ key = 'modules.' . $ this -> module -> id ; $ ttl = intval ( $ this -> params -> get ( 'cache_time' , 0 ) ) ; if ( $ debug || ! $ ttl ) { return $ content ; } if ( ! ( $ content = App :: get ( 'cache.store' ) -> get ( $ key ) ) ) { ob_start ( ) ; $ this -> run ( ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; $ content .= '<!-- cached ' . with ( new Date ( 'now' ) ) -> toSql ( ) . ' ; $ ttl = $ ttl <= 120 ? $ ttl : ( $ ttl / 60 ) ; App :: get ( 'cache.store' ) -> put ( $ key , $ content , $ ttl ) ; } return $ content ; }
Get the cached contents of a module caching it if it doesn t already exist
47,119
public function history ( ) { $ migration = new \ Hubzero \ Content \ Migration ( ) ; $ history = $ migration -> history ( ) ; $ items = [ ] ; $ maxFile = 0 ; $ maxUser = 0 ; $ maxScope = 0 ; if ( $ history && count ( $ history ) > 0 ) { $ items [ ] = [ 'File' , 'By' , 'Direction' , 'Date' ] ; foreach ( $ history as $ entry ) { $ items [ ] = [ $ entry -> scope . DS . $ entry -> file , $ entry -> action_by , $ entry -> direction , $ entry -> date ] ; } $ this -> output -> addTable ( $ items , true ) ; } else { $ this -> addLine ( 'No history to display.' ) ; } }
Report migration run info
47,120
public function addPluginMessage ( $ message , $ type = 'message' ) { if ( ! count ( $ this -> pluginMessageQueue ) ) { $ session = \ App :: get ( 'session' ) ; $ pluginMessage = $ session -> get ( 'plugin.message.queue' ) ; if ( count ( $ pluginMessage ) ) { $ this -> pluginMessageQueue = $ pluginMessage ; $ session -> set ( 'plugin.message.queue' , null ) ; } } if ( $ message != '' ) { $ this -> pluginMessageQueue [ ] = array ( 'message' => $ message , 'type' => strtolower ( $ type ) , 'option' => $ this -> option , 'plugin' => $ this -> _name ) ; } return $ this ; }
Method to add a message to the component message que
47,121
public function getPluginMessage ( ) { if ( ! count ( $ this -> pluginMessageQueue ) ) { $ session = \ App :: get ( 'session' ) ; $ pluginMessage = $ session -> get ( 'plugin.message.queue' ) ; if ( count ( $ pluginMessage ) ) { $ this -> pluginMessageQueue = $ pluginMessage ; $ session -> set ( 'plugin.message.queue' , null ) ; } } foreach ( $ this -> pluginMessageQueue as $ k => $ cmq ) { if ( $ cmq [ 'option' ] != $ this -> option ) { $ this -> pluginMessageQueue [ $ k ] = array ( ) ; } } return $ this -> pluginMessageQueue ; }
Method to get component messages
47,122
public static function getParams ( $ name , $ folder ) { $ database = \ App :: get ( 'db' ) ; $ sql = "SELECT params FROM `#__extensions` WHERE folder=" . $ database -> quote ( $ folder ) . " AND element=" . $ database -> quote ( $ name ) . " AND enabled=1" ; $ database -> setQuery ( $ sql ) ; $ result = $ database -> loadResult ( ) ; $ params = new Registry ( $ result ) ; return $ params ; }
Method to get plugin params
47,123
public function prepare ( $ string ) { if ( $ this -> asciiConversion ) { setlocale ( LC_ALL , 'en_us.UTF8' ) ; $ string = iconv ( 'UTF-8' , 'ASCII//TRANSLIT' , $ string ) ; } if ( $ this -> aggressive ) { $ string = str_replace ( array ( '@' , '$' , '[dot]' , '(dot)' ) , array ( 'at' , 's' , '.' , '.' ) , $ string ) ; $ string = preg_replace ( "/[^a-zA-Z0-9-\.]/" , '' , $ string ) ; $ string = preg_replace ( "/\.{2,}/" , '.' , $ string ) ; } $ string = trim ( strtolower ( $ string ) ) ; $ string = str_replace ( array ( "\t" , "\r\n" , "\r" , "\n" ) , '' , $ string ) ; return $ string ; }
Prepare a string
47,124
protected function getInput ( ) { $ size = $ this -> element [ 'size' ] ? ' size="' . ( int ) $ this -> element [ 'size' ] . '"' : '' ; $ maxLength = $ this -> element [ 'maxlength' ] ? ' maxlength="' . ( int ) $ this -> element [ 'maxlength' ] . '"' : '' ; $ class = $ this -> element [ 'class' ] ? ' ' . ( string ) $ this -> element [ 'class' ] : '' ; $ readonly = ( ( string ) $ this -> element [ 'readonly' ] == 'true' ) ? ' readonly="readonly"' : '' ; $ disabled = ( ( string ) $ this -> element [ 'disabled' ] == 'true' ) ? ' disabled="disabled"' : '' ; $ this -> value = str_replace ( array ( '"' , '\\' ) , '' , $ this -> value ) ; $ onchange = $ this -> element [ 'onchange' ] ? ' onchange="' . ( string ) $ this -> element [ 'onchange' ] . '"' : '' ; return '<input type="text" name="' . $ this -> name . '" class="validate-email' . $ class . '" id="' . $ this -> id . '"' . ' value="' . htmlspecialchars ( $ this -> value , ENT_COMPAT , 'UTF-8' ) . '"' . $ size . $ disabled . $ readonly . $ onchange . $ maxLength . '/>' ; }
Method to get the field input markup for e - mail addresses .
47,125
public function put ( $ key , $ fragment ) { $ key = $ this -> normalizeCacheKey ( $ key ) ; return $ this -> cache -> tags ( 'views' ) -> rememberForever ( $ key , function ( ) use ( $ fragment ) { return $ fragment ; } ) ; }
Put to the cache .
47,126
public function has ( $ key ) { $ key = $ this -> normalizeCacheKey ( $ key ) ; return $ this -> cache -> tags ( 'views' ) -> has ( $ key ) ; }
Check if the given key exists in the cache .
47,127
protected function normalizeKey ( $ item , $ key = null ) { if ( is_string ( $ item ) || is_string ( $ key ) ) { return is_string ( $ item ) ? $ item : $ key ; } if ( is_object ( $ item ) && method_exists ( $ item , 'getCacheKey' ) ) { return $ item -> getCacheKey ( ) ; } if ( $ item instanceof \ Illuminate \ Support \ Collection ) { return md5 ( $ item ) ; } throw new Exception ( 'Could not determine an appropriate cache key.' ) ; }
Normalize the cache key .
47,128
public function setLevel ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ LabelLevel :: class ) ; $ this -> level = $ var ; return $ this ; }
Label level .
47,129
public function setEntries ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Bigtable \ V2 \ MutateRowsResponse_Entry :: class ) ; $ this -> entries = $ arr ; return $ this ; }
One or more results for Entries from the batch request .
47,130
public function setItems ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ Intent_Message_ListSelect_Item :: class ) ; $ this -> items = $ arr ; return $ this ; }
Required . List items .
47,131
public function setTimeEvent ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Trace \ V2 \ Span_TimeEvent :: class ) ; $ this -> time_event = $ arr ; return $ this ; }
A collection of TimeEvent s .
47,132
public function setEntities ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ EntityType_Entity :: class ) ; $ this -> entities = $ arr ; return $ this ; }
Optional . The collection of entities associated with the entity type .
47,133
public function setBuckets ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ BucketingConfig_Bucket :: class ) ; $ this -> buckets = $ arr ; return $ this ; }
Set of buckets . Ranges must be non - overlapping .
47,134
public function setParameters ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ Intent_Parameter :: class ) ; $ this -> parameters = $ arr ; return $ this ; }
Optional . The collection of parameters associated with the intent .
47,135
public function setBoundingBox ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ BoundingBox :: class ) ; $ this -> bounding_box = $ var ; return $ this ; }
Bounding box in a frame .
47,136
public function setLocations ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ LabelLocation :: class ) ; $ this -> locations = $ arr ; return $ this ; }
Where the label was detected and with what confidence .
47,137
public function setAnnotationResults ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ VideoAnnotationResults :: class ) ; $ this -> annotation_results = $ arr ; return $ this ; }
Annotation results for all videos specified in AnnotateVideoRequest .
47,138
public function setBestGuessLabels ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ WebDetection_WebLabel :: class ) ; $ this -> best_guess_labels = $ arr ; return $ this ; }
Best guess text labels for the request image .
47,139
public function setLabelAnnotations ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ LabelAnnotation :: class ) ; $ this -> label_annotations = $ arr ; return $ this ; }
Label annotations . There is exactly one element for each unique label .
47,140
public function setSafeSearchAnnotations ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ SafeSearchAnnotation :: class ) ; $ this -> safe_search_annotations = $ arr ; return $ this ; }
Safe search annotations .
47,141
public function setCidrBlocks ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Container \ V1 \ MasterAuthorizedNetworksConfig_CidrBlock :: class ) ; $ this -> cidr_blocks = $ arr ; return $ this ; }
cidr_blocks define up to 10 external networks that could access Kubernetes master through HTTPS .
47,142
public function setInternalCheckers ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Monitoring \ V3 \ UptimeCheckConfig_InternalChecker :: class ) ; $ this -> internal_checkers = $ arr ; return $ this ; }
The internal checkers that this check will egress from .
47,143
public function setFrame ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Trace \ V2 \ StackTrace_StackFrame :: class ) ; $ this -> frame = $ arr ; return $ this ; }
Stack frames in this call stack .
47,144
public function setPath ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ Key_PathElement :: class ) ; $ this -> path = $ arr ; return $ this ; }
The entity path . An entity path consists of one or more elements composed of a kind and a string or numerical identifier which identify entities . The first element identifies a _root entity_ the second element identifies a _child_ of the root entity the third element identifies a child of the second entity and so forth . The entities identified by all prefixes of the path are called the element s _ancestors_ . A path can never be empty and a path can have at most 100 elements .
47,145
public function setAnnotationProgress ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ VideoAnnotationProgress :: class ) ; $ this -> annotation_progress = $ arr ; return $ this ; }
Progress metadata for all videos specified in AnnotateVideoRequest .
47,146
public function setAdult ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ Likelihood :: class ) ; $ this -> adult = $ var ; return $ this ; }
Likelihood of adult content .
47,147
public function setSpoof ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ Likelihood :: class ) ; $ this -> spoof = $ var ; return $ this ; }
Likelihood that an obvious modification was made to the original version to make it appear funny or offensive .
47,148
public function setMedical ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ Likelihood :: class ) ; $ this -> medical = $ var ; return $ this ; }
Likelihood of medical content .
47,149
public function setViolent ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ Likelihood :: class ) ; $ this -> violent = $ var ; return $ this ; }
Likelihood of violent content .
47,150
public function setRacy ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ VideoIntelligence \ V1beta1 \ Likelihood :: class ) ; $ this -> racy = $ var ; return $ this ; }
Likelihood of racy content .
47,151
protected function logReferenceNotFound ( $ path , $ reference , $ absoluteReference ) { $ this -> log ( LogLevel :: WARNING , sprintf ( 'The reference "%s"%s mapped by the path %s could not be found.' , $ reference , $ reference !== $ absoluteReference ? ' (' . $ absoluteReference . ')' : '' , $ path ) ) ; }
Logs a warning that a reference could not be found .
47,152
protected function addFilesystemResource ( $ path , FilesystemResource $ resource ) { $ resource = clone $ resource ; $ resource -> attachTo ( $ this , $ path ) ; $ relativePath = Path :: makeRelative ( $ resource -> getFilesystemPath ( ) , $ this -> baseDirectory ) ; $ this -> insertReference ( $ path , $ relativePath ) ; $ this -> storeVersion ( $ resource ) ; }
Adds a filesystem resource to the JSON file .
47,153
protected function flush ( ) { if ( ! isset ( $ this -> json [ '/' ] ) ) { $ this -> json [ '/' ] = null ; } krsort ( $ this -> json ) ; $ json = ( object ) $ this -> json ; if ( isset ( $ json -> { '_order' } ) ) { $ order = $ json -> { '_order' } ; foreach ( $ order as $ path => $ entries ) { foreach ( $ entries as $ key => $ entry ) { $ order [ $ path ] [ $ key ] = ( object ) $ entry ; } } $ json -> { '_order' } = ( object ) $ order ; } $ this -> encoder -> encodeFile ( $ json , $ this -> path , $ this -> schemaPath ) ; }
Writes the JSON file .
47,154
protected function createResource ( $ path , $ reference ) { if ( null === $ reference ) { $ resource = new GenericResource ( ) ; } elseif ( isset ( $ reference [ 0 ] ) && '@' === $ reference [ 0 ] ) { $ resource = new LinkResource ( substr ( $ reference , 1 ) ) ; } elseif ( is_dir ( $ reference ) ) { $ resource = new DirectoryResource ( $ reference ) ; } elseif ( is_file ( $ reference ) ) { $ resource = new FileResource ( $ reference ) ; } else { throw new RuntimeException ( sprintf ( 'Trying to create a FilesystemResource on a non-existing file or directory "%s"' , $ reference ) ) ; } $ resource -> attachTo ( $ this , $ path ) ; return $ resource ; }
Turns a reference into a resource .
47,155
private function createResources ( array $ references ) { foreach ( $ references as $ path => $ reference ) { $ references [ $ path ] = $ this -> createResource ( $ path , $ reference ) ; } return $ references ; }
Turns a list of references into a list of resources .
47,156
private function ensureDirectoryExists ( $ path ) { if ( array_key_exists ( $ path , $ this -> json ) ) { return ; } if ( '/' !== $ path ) { $ this -> ensureDirectoryExists ( Path :: getDirectory ( $ path ) ) ; } $ this -> json [ $ path ] = null ; }
Adds all ancestor directories of a path to the repository .
47,157
private function addResource ( $ path , $ resource ) { if ( ! $ resource instanceof FilesystemResource && ! $ resource instanceof LinkResource ) { throw new UnsupportedResourceException ( sprintf ( 'The %s only supports adding FilesystemResource and ' . 'LinkedResource instances. Got: %s' , $ this -> getShortClassName ( get_class ( $ this ) ) , $ this -> getShortClassName ( get_class ( $ resource ) ) ) ) ; } if ( $ resource instanceof LinkResource ) { $ resource = clone $ resource ; $ resource -> attachTo ( $ this , $ path ) ; $ this -> insertReference ( $ path , '@' . $ resource -> getTargetPath ( ) ) ; $ this -> storeVersion ( $ resource ) ; } else { $ this -> addFilesystemResource ( $ path , $ resource ) ; } }
Adds a resource to the repository .
47,158
private function getShortClassName ( $ className ) { if ( false !== ( $ pos = strrpos ( $ className , '\\' ) ) ) { return substr ( $ className , $ pos + 1 ) ; } return $ className ; }
Returns the short name of a fully - qualified class name .
47,159
protected function sanitizePath ( $ path ) { Assert :: stringNotEmpty ( $ path , 'The path must be a non-empty string. Got: %s' ) ; Assert :: startsWith ( $ path , '/' , 'The path %s is not absolute.' ) ; return Path :: canonicalize ( $ path ) ; }
Sanitize a given path and check its validity .
47,160
public function getFilesystemPaths ( ) { return array_map ( function ( FilesystemResource $ resource ) { return $ resource -> getFilesystemPath ( ) ; } , array_filter ( $ this -> toArray ( ) , function ( PuliResource $ r ) { return $ r instanceof FilesystemResource && null !== $ r -> getFilesystemPath ( ) ; } ) ) ; }
Returns the filesystem paths of all contained resources .
47,161
private function flatten ( array $ references ) { $ result = array ( ) ; foreach ( $ references as $ currentPath => $ currentReferences ) { if ( ! isset ( $ result [ $ currentPath ] ) ) { $ result [ $ currentPath ] = reset ( $ currentReferences ) ; } } return $ result ; }
Flattens a two - level reference array into a one - level array .
47,162
private function flattenWithFilter ( array $ references , $ regex , $ flags = 0 , $ maxDepth = 0 ) { $ result = array ( ) ; foreach ( $ references as $ currentPath => $ currentReferences ) { if ( ! isset ( $ result [ $ currentPath ] ) && preg_match ( $ regex , $ currentPath ) ) { $ result [ $ currentPath ] = reset ( $ currentReferences ) ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } if ( $ flags & self :: NO_SEARCH_FILESYSTEM ) { continue ; } $ currentReferences = $ this -> followLinks ( $ currentReferences ) ; $ currentPath = rtrim ( $ currentPath , '/' ) ; foreach ( $ currentReferences as $ baseFilesystemPath ) { if ( ! is_dir ( $ baseFilesystemPath ) ) { continue ; } $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ baseFilesystemPath , RecursiveDirectoryIterator :: CURRENT_AS_PATHNAME | RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FIRST ) ; if ( 0 !== $ maxDepth ) { $ currentDepth = $ this -> getPathDepth ( $ currentPath ) ; $ maxIteratorDepth = $ maxDepth - $ currentDepth ; if ( $ maxIteratorDepth < 1 ) { continue ; } $ iterator -> setMaxDepth ( $ maxIteratorDepth ) ; } $ basePathLength = strlen ( $ baseFilesystemPath ) ; foreach ( $ iterator as $ nestedFilesystemPath ) { $ nestedPath = substr_replace ( $ nestedFilesystemPath , $ currentPath , 0 , $ basePathLength ) ; if ( ! isset ( $ result [ $ nestedPath ] ) && preg_match ( $ regex , $ nestedPath ) ) { $ result [ $ nestedPath ] = $ nestedFilesystemPath ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } } } } return $ result ; }
Flattens a two - level reference array into a one - level array and filters out any references that don t match the given regular expression .
47,163
private function followLinks ( array $ references , $ flags = 0 ) { $ result = array ( ) ; foreach ( $ references as $ key => $ reference ) { if ( ! $ this -> isLinkReference ( $ reference ) ) { $ result [ ] = $ reference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } continue ; } $ referencedPath = substr ( $ reference , 1 ) ; foreach ( $ this -> searchReferences ( $ referencedPath , $ flags ) as $ referencedReferences ) { $ referencedReferences = $ this -> followLinks ( $ referencedReferences ) ; foreach ( $ referencedReferences as $ referencedReference ) { $ result [ ] = $ referencedReference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } } } return $ result ; }
Follows any link in a list of references .
47,164
private function appendPathAndFilterExisting ( array $ references , $ nestedPath , $ flags = 0 ) { $ result = array ( ) ; foreach ( $ references as $ reference ) { if ( null === $ reference ) { continue ; } $ nestedReference = rtrim ( $ reference , '/' ) . '/' . $ nestedPath ; if ( file_exists ( $ nestedReference ) ) { $ result [ ] = $ nestedReference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } } return $ result ; }
Appends nested paths to references and filters out the existing ones .
47,165
private function resolveReferences ( $ path , $ references , $ flags = 0 ) { $ result = array ( ) ; if ( ! is_array ( $ references ) ) { $ references = array ( $ references ) ; } foreach ( $ references as $ key => $ reference ) { if ( ! $ this -> isFilesystemReference ( $ reference ) ) { $ result [ ] = $ reference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } continue ; } $ absoluteReference = Path :: makeAbsolute ( $ reference , $ this -> baseDirectory ) ; $ referenceExists = file_exists ( $ absoluteReference ) ; if ( ( $ flags & self :: NO_CHECK_FILE_EXISTS ) || $ referenceExists ) { $ result [ ] = $ absoluteReference ; if ( $ flags & self :: STOP_ON_FIRST ) { return $ result ; } } if ( ! $ referenceExists ) { $ this -> logReferenceNotFound ( $ path , $ reference , $ absoluteReference ) ; } } return $ result ; }
Resolves a list of references stored in the JSON .
47,166
private function prependOrderEntry ( $ path , $ prependedPath ) { $ lastEntry = reset ( $ this -> json [ '_order' ] [ $ path ] ) ; if ( $ prependedPath === $ lastEntry [ 'path' ] ) { ++ $ lastEntry [ 'references' ] ; } else { array_unshift ( $ this -> json [ '_order' ] [ $ path ] , array ( 'path' => $ prependedPath , 'references' => 1 , ) ) ; } }
Inserts a path at the beginning of the order list of a mapped path .
47,167
private function initWithParentOrder ( $ path , array $ parentReferences ) { foreach ( $ parentReferences as $ parentPath => $ _ ) { if ( isset ( $ this -> json [ '_order' ] [ $ parentPath ] ) ) { $ this -> json [ '_order' ] [ $ path ] = $ this -> json [ '_order' ] [ $ parentPath ] ; return ; } } }
Initializes a path with the order of the closest parent path .
47,168
private function initWithDefaultOrder ( $ path , $ insertedPath , $ references ) { $ this -> json [ '_order' ] [ $ path ] = array ( ) ; $ parentPath = $ path ; while ( true ) { if ( isset ( $ references [ $ parentPath ] ) ) { $ parentEntry = array ( 'path' => $ parentPath , 'references' => count ( $ references [ $ parentPath ] ) , ) ; if ( $ parentPath === $ insertedPath ) { -- $ parentEntry [ 'references' ] ; } if ( 0 !== $ parentEntry [ 'references' ] ) { $ this -> json [ '_order' ] [ $ path ] [ ] = $ parentEntry ; } } if ( '/' === $ parentPath ) { break ; } $ parentPath = Path :: getDirectory ( $ parentPath ) ; } }
Initializes the order of a path with the default order .
47,169
private function load ( ) { foreach ( $ this -> resources as $ key => $ resource ) { if ( ! $ resource instanceof PuliResource ) { $ this -> resources [ $ key ] = $ this -> repo -> get ( $ resource ) ; } } $ this -> loaded = true ; }
Loads the complete collection .
47,170
protected function postUnserialize ( array $ data ) { $ this -> repoPath = array_pop ( $ data ) ; $ this -> path = array_pop ( $ data ) ; }
Invoked after unserializing a resource .
47,171
public function getResources ( ) { if ( null === $ this -> repo ) { throw new NotInitializedException ( 'The repository of the resource binding must be set before accessing resources.' ) ; } return $ this -> repo -> find ( $ this -> query , $ this -> language ) ; }
Returns the bound resources .
47,172
protected function storeVersion ( PuliResource $ resource ) { if ( null !== $ this -> changeStream ) { $ this -> changeStream -> append ( $ resource ) ; } }
Stores a version of a resource in the change stream .
47,173
public static function isSymlinkSupported ( ) { if ( null === self :: $ symlinkSupported ) { if ( defined ( 'PHP_WINDOWS_VERSION_MAJOR' ) ) { self :: $ symlinkSupported = PHP_WINDOWS_VERSION_MAJOR >= 6 ; } else { self :: $ symlinkSupported = true ; } } return self :: $ symlinkSupported ; }
Returns whether symlinks are supported in the local environment .
47,174
public static function register ( $ scheme , $ repositoryFactory ) { if ( ! $ repositoryFactory instanceof ResourceRepository && ! is_callable ( $ repositoryFactory ) ) { throw new InvalidArgumentException ( sprintf ( 'The repository factory should be a callable or an instance ' . 'of ResourceRepository. Got: %s' , $ repositoryFactory ) ) ; } Assert :: string ( $ scheme , 'The scheme must be a string. Got: %s' ) ; Assert :: alnum ( $ scheme , 'The scheme %s should consist of letters and digits only.' ) ; Assert :: startsWithLetter ( $ scheme , 'The scheme %s should start with a letter.' ) ; if ( isset ( self :: $ repos [ $ scheme ] ) ) { throw new StreamWrapperException ( sprintf ( 'The scheme "%s" has already been registered.' , $ scheme ) ) ; } self :: $ repos [ $ scheme ] = $ repositoryFactory ; stream_wrapper_register ( $ scheme , __CLASS__ ) ; }
Registers a repository as PHP stream wrapper .
47,175
public static function unregister ( $ scheme ) { if ( ! isset ( self :: $ repos [ $ scheme ] ) ) { return ; } unset ( self :: $ repos [ $ scheme ] ) ; stream_wrapper_unregister ( $ scheme ) ; }
Unregisters the given scheme .
47,176
public function accept ( ) { if ( $ this -> mode & self :: FILTER_BY_PATH ) { $ value = $ this -> getCurrentResource ( ) -> getPath ( ) ; } else { $ value = $ this -> getCurrentResource ( ) -> getName ( ) ; } if ( $ this -> mode & self :: MATCH_PREFIX ) { return 0 === strpos ( $ value , $ this -> pattern ) ; } elseif ( $ this -> mode & self :: MATCH_SUFFIX ) { return $ this -> pattern === substr ( $ value , - $ this -> patternLength ) ; } else { return preg_match ( $ this -> pattern , $ value ) ; } }
Returns whether the current element should be accepted .
47,177
public function current ( ) { if ( $ this -> mode & self :: CURRENT_AS_RESOURCE ) { return current ( $ this -> resources ) ; } if ( $ this -> mode & self :: CURRENT_AS_PATH ) { return current ( $ this -> resources ) -> getPath ( ) ; } return current ( $ this -> resources ) -> getName ( ) ; }
Returns the current value of the iterator .
47,178
public function key ( ) { if ( null === ( $ key = key ( $ this -> resources ) ) ) { return null ; } if ( $ this -> mode & self :: KEY_AS_PATH ) { return $ this -> resources [ $ key ] -> getPath ( ) ; } return $ key ; }
Returns the current key of the iterator .
47,179
private function ensureDirectoryExists ( $ path ) { if ( ! isset ( $ this -> resources [ $ path ] ) ) { if ( $ path !== '/' ) { $ this -> ensureDirectoryExists ( Path :: getDirectory ( $ path ) ) ; } $ this -> resources [ $ path ] = new GenericResource ( $ path ) ; $ this -> resources [ $ path ] -> attachTo ( $ this ) ; return ; } }
Recursively creates a directory for a path .
47,180
private function getChildIterator ( PuliResource $ resource ) { $ staticPrefix = rtrim ( $ resource -> getPath ( ) , '/' ) . '/' ; $ regExp = '~^' . preg_quote ( $ staticPrefix , '~' ) . '[^/]+$~' ; return new RegexFilterIterator ( $ regExp , $ staticPrefix , new ArrayIterator ( $ this -> resources ) , RegexFilterIterator :: FILTER_KEY ) ; }
Returns an iterator for the children of a resource .
47,181
public function get ( $ version ) { if ( ! isset ( $ this -> versions [ $ version ] ) ) { throw new OutOfBoundsException ( sprintf ( 'The version %s of path %s does not exist.' , $ version , $ this -> path ) ) ; } return $ this -> versions [ $ version ] ; }
Returns a specific version of the resource .
47,182
public function context ( Context $ context = null ) : Context { if ( ! $ this -> context ) { $ this -> context = $ context ? : new SimpleContext ; } return $ this -> context ; }
Get or set or create a context object for request or reply
47,183
protected function normalizeStaticRoutes ( array $ routes ) { foreach ( \ array_keys ( $ routes ) as $ key ) { if ( $ this -> stringIsHttpMethod ( $ key ) ) { return $ routes ; } } $ normalized = [ ] ; foreach ( $ routes as $ uri => $ value ) { foreach ( $ value as $ method => $ route ) { $ normalized [ $ method ] [ $ uri ] = $ route ; } } return $ normalized ; }
Normalize the FastRoute static routes so they re the same across multiple versions .
47,184
protected function instantiateConfigValue ( $ item , $ value ) { if ( \ is_string ( $ value ) && \ in_array ( $ item , $ this -> instantiable ) ) { return $ this -> app -> make ( $ value ) ; } return $ value ; }
Instantiate an instantiable configuration value .
47,185
public function formatArray ( $ content ) { $ content = $ this -> morphToArray ( $ content ) ; \ array_walk_recursive ( $ content , function ( & $ value ) { $ value = $ this -> morphToArray ( $ value ) ; } ) ; return $ this -> encode ( $ content ) ; }
Format an array or instance implementing Arrayable .
47,186
public function getRateLimiter ( ) { return \ call_user_func ( $ this -> limiter ? : function ( $ container , $ request ) { return $ request -> getClientIp ( ) ; } , $ this -> container , $ this -> request ) ; }
Get the rate limiter .
47,187
public function setThrottle ( $ throttle ) { if ( \ is_string ( $ throttle ) ) { $ throttle = $ this -> container -> make ( $ throttle ) ; } $ this -> throttle = $ throttle ; }
Set the throttle to use for rate limiting .
47,188
public function parse ( Request $ request , $ strict = false ) { $ pattern = '/application\/' . $ this -> standardsTree . '\.(' . $ this -> subtype . ')\.([\w\d\.\-]+)\+([\w]+)/' ; if ( ! \ preg_match ( $ pattern , $ request -> header ( 'accept' ) , $ matches ) ) { if ( $ strict ) { throw new BadRequestHttpException ( 'Accept header could not be properly parsed because of a strict matching process.' ) ; } $ default = 'application/' . $ this -> standardsTree . '.' . $ this -> subtype . '.' . $ this -> version . '+' . $ this -> format ; \ preg_match ( $ pattern , $ default , $ matches ) ; } return \ array_combine ( [ 'subtype' , 'version' , 'format' ] , \ array_slice ( $ matches , 1 ) ) ; }
Parse the accept header on the incoming request . If strict is enabled then the accept header must be available and must be a valid match .
47,189
protected function createRequest ( $ verb , $ uri , $ parameters ) { $ parameters = \ array_merge ( $ this -> parameters , ( array ) $ parameters ) ; $ uri = $ this -> addPrefixToUri ( $ uri ) ; $ rootUrl = $ this -> getRootRequest ( ) -> root ( ) ; if ( ( ! \ parse_url ( $ uri , PHP_URL_SCHEME ) ) && \ parse_url ( $ rootUrl ) !== false ) { $ uri = \ rtrim ( $ rootUrl , '/' ) . '/' . ltrim ( $ uri , '/' ) ; } $ request = InternalRequest :: create ( $ uri , $ verb , $ parameters , $ this -> cookies , $ this -> uploads , $ this -> container [ 'request' ] -> server -> all ( ) , $ this -> content ) ; $ request -> headers -> set ( 'host' , $ this -> getDomain ( ) ) ; foreach ( $ this -> headers as $ header => $ value ) { $ request -> headers -> set ( $ header , $ value ) ; } $ request -> headers -> set ( 'accept' , $ this -> getAcceptHeader ( ) ) ; return $ request ; }
Create a new internal request from an HTTP verb and URI .
47,190
protected function getAcceptHeader ( ) { return \ sprintf ( 'application/%s.%s.%s+%s' , $ this -> getStandardsTree ( ) , $ this -> getSubtype ( ) , $ this -> getVersion ( ) , $ this -> getFormat ( ) ) ; }
Build the Accept header .
47,191
protected function refreshRequestStack ( ) { if ( ! $ this -> persistAuthentication ) { $ this -> auth -> setUser ( null ) ; $ this -> persistAuthentication = true ; } if ( $ route = \ array_pop ( $ this -> routeStack ) ) { $ this -> router -> setCurrentRoute ( $ route ) ; } $ this -> replaceRequestInstance ( ) ; $ this -> clearCachedFacadeInstance ( ) ; $ this -> raw = false ; $ this -> version = $ this -> domain = $ this -> content = null ; $ this -> parameters = $ this -> uploads = [ ] ; }
Refresh the request stack .
47,192
protected function replaceRequestInstance ( ) { \ array_pop ( $ this -> requestStack ) ; $ this -> container -> instance ( 'request' , \ end ( $ this -> requestStack ) ) ; }
Replace the request instance with the previous request instance .
47,193
public function setAdapter ( $ adapter ) { if ( \ is_callable ( $ adapter ) ) { $ adapter = \ call_user_func ( $ adapter , $ this -> container ) ; } $ this -> adapter = $ adapter ; }
Set the transformation layer at runtime .
47,194
public function transform ( $ response , $ transformer , Binding $ binding , Request $ request ) { $ this -> parseFractalIncludes ( $ request ) ; $ resource = $ this -> createResource ( $ response , $ transformer , $ parameters = $ binding -> getParameters ( ) ) ; if ( $ response instanceof IlluminatePaginator ) { $ paginator = $ this -> createPaginatorAdapter ( $ response ) ; $ resource -> setPaginator ( $ paginator ) ; } if ( $ this -> shouldEagerLoad ( $ response ) ) { $ eagerLoads = $ this -> mergeEagerLoads ( $ transformer , $ this -> fractal -> getRequestedIncludes ( ) ) ; if ( $ transformer instanceof TransformerAbstract ) { $ eagerLoads = \ array_intersect ( $ eagerLoads , $ transformer -> getAvailableIncludes ( ) ) ; } $ response -> load ( $ eagerLoads ) ; } foreach ( $ binding -> getMeta ( ) as $ key => $ value ) { $ resource -> setMetaValue ( $ key , $ value ) ; } $ binding -> fireCallback ( $ resource , $ this -> fractal ) ; $ identifier = $ parameters [ 'identifier' ] ?? null ; return $ this -> fractal -> createData ( $ resource , $ identifier ) -> toArray ( ) ; }
Transform a response with a transformer .
47,195
public function validate ( Request $ request ) { return ! \ is_null ( $ this -> domain ) && $ request -> getHost ( ) === $ this -> getStrippedDomain ( ) ; }
Validate that the request domain matches the configured domain .
47,196
protected function stripProtocol ( $ domain ) { if ( Str :: contains ( $ domain , '://' ) ) { $ domain = \ substr ( $ domain , \ strpos ( $ domain , '://' ) + 3 ) ; } return $ domain ; }
Strip the protocol from a domain .
47,197
protected function stripPort ( $ domain ) { if ( $ domainStripped = \ preg_replace ( self :: PATTERN_STRIP_PROTOCOL , null , $ domain ) ) { return $ domainStripped ; } return $ domain ; }
Strip the port from a domain .
47,198
protected function encode ( $ content ) { $ jsonString = parent :: encode ( $ content ) ; if ( $ this -> hasValidCallback ( ) ) { return \ sprintf ( '%s(%s);' , $ this -> getCallback ( ) , $ jsonString ) ; } return $ jsonString ; }
Encode the content to its JSONP representation .
47,199
public function morph ( $ format = 'json' ) { $ this -> content = $ this -> getOriginalContent ( ) ; $ this -> fireMorphingEvent ( ) ; if ( isset ( static :: $ transformer ) && static :: $ transformer -> transformableResponse ( $ this -> content ) ) { $ this -> content = static :: $ transformer -> transform ( $ this -> content ) ; } $ formatter = static :: getFormatter ( $ format ) ; $ formatter -> setOptions ( static :: getFormatsOptions ( $ format ) ) ; $ defaultContentType = $ this -> headers -> get ( 'Content-Type' ) ; $ this -> headers -> set ( 'Content-Type' , $ formatter -> getContentType ( ) ) ; $ this -> fireMorphedEvent ( ) ; if ( $ this -> content instanceof EloquentModel ) { $ this -> content = $ formatter -> formatEloquentModel ( $ this -> content ) ; } elseif ( $ this -> content instanceof EloquentCollection ) { $ this -> content = $ formatter -> formatEloquentCollection ( $ this -> content ) ; } elseif ( \ is_array ( $ this -> content ) || $ this -> content instanceof ArrayObject || $ this -> content instanceof Arrayable ) { $ this -> content = $ formatter -> formatArray ( $ this -> content ) ; } else { $ this -> headers -> set ( 'Content-Type' , $ defaultContentType ) ; } return $ this ; }
Morph the API response to the appropriate format .