idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
2,800
public function setTrainingPhrases ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ Intent \ TrainingPhrase :: class ) ; $ this -> training_phrases = $ arr ; return $ this ; }
Optional . The collection of examples that the agent is trained on .
2,801
public function setMessages ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ Intent \ Message :: class ) ; $ this -> messages = $ arr ; return $ this ; }
Optional . The collection of rich messages corresponding to the Response field in the Dialogflow console .
2,802
public function setFollowupIntentInfo ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dialogflow \ V2 \ Intent \ FollowupIntentInfo :: class ) ; $ this -> followup_intent_info = $ arr ; return $ this ; }
Read - only . Information about all followup intents that have this intent as a direct or indirect parent . We populate this field only in the output .
2,803
public function failedRows ( ) { $ rows = [ ] ; if ( $ this -> isSuccessful ( ) ) { return $ rows ; } foreach ( $ this -> info [ 'insertErrors' ] as $ error ) { $ rows [ ] = $ error + [ 'rowData' => $ this -> rows [ $ error [ 'index' ] ] [ 'json' ] ] ; } return $ rows ; }
Returns the rows which failed to insert along with their associated errors and index in the original data set .
2,804
public function setJobs ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ DlpJob :: class ) ; $ this -> jobs = $ arr ; return $ this ; }
A list of DlpJobs that matches the specified filter in the request .
2,805
public function setIdValues ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> id_values = $ arr ; return $ this ; }
Values of identifying columns in the given row . Order of values matches the order of field identifiers specified in the scanning request .
2,806
public function table ( $ instanceId , $ tableId , array $ options = [ ] ) { return new Table ( $ this -> gapicClient , GapicClient :: tableName ( $ this -> projectId , $ instanceId , $ tableId ) , $ options ) ; }
Returns a table instance which can be used to read rows and to perform insert update and delete operations .
2,807
public function UpdateGroup ( \ Google \ Cloud \ ErrorReporting \ V1beta1 \ UpdateGroupRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup' , $ argument , [ '\Google\Cloud\ErrorReporting\V1beta1\ErrorGroup' , 'decode' ] , $ metadata , $ options ) ; }
Replace the data for the specified group . Fails if the group does not exist .
2,808
public function setColumns ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Bigtable \ V2 \ Column :: class ) ; $ this -> columns = $ arr ; return $ this ; }
Must not be empty . Sorted in order of increasing qualifier .
2,809
public function setWarnings ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> warnings = $ arr ; return $ this ; }
Output only . Errors encountered during operation execution .
2,810
public function setDeviceInfo ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ DeviceInfo :: class ) ; $ this -> device_info = $ var ; return $ this ; }
Optional . The type of device used by the job seeker at the time of the call to the service .
2,811
public function setSubscriptions ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ PubSub \ V1 \ Subscription :: class ) ; $ this -> subscriptions = $ arr ; return $ this ; }
The subscriptions that match the request .
2,812
public function setErrorGroupStats ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ ErrorReporting \ V1beta1 \ ErrorGroupStats :: class ) ; $ this -> error_group_stats = $ arr ; return $ this ; }
The error group stats which match the given request .
2,813
public function setSetCell ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Bigtable \ V2 \ Mutation_SetCell :: class ) ; $ this -> writeOneof ( 1 , $ var ) ; return $ this ; }
Set a cell s value .
2,814
public function setDeleteFromColumn ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Bigtable \ V2 \ Mutation_DeleteFromColumn :: class ) ; $ this -> writeOneof ( 2 , $ var ) ; return $ this ; }
Deletes cells from a column .
2,815
public function setDeleteFromFamily ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Bigtable \ V2 \ Mutation_DeleteFromFamily :: class ) ; $ this -> writeOneof ( 3 , $ var ) ; return $ this ; }
Deletes cells from a column family .
2,816
public function setDeleteFromRow ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Bigtable \ V2 \ Mutation_DeleteFromRow :: class ) ; $ this -> writeOneof ( 4 , $ var ) ; return $ this ; }
Deletes cells from the entire row .
2,817
public function setDescription ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Trace \ V2 \ TruncatableString :: class ) ; $ this -> description = $ var ; return $ this ; }
A user - supplied message describing the event . The maximum length for the description is 256 bytes .
2,818
public function setTimestamps ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Timestamp :: class ) ; $ this -> timestamps = $ arr ; return $ this ; }
The times the error occurred .
2,819
private function emulatorGapicConfig ( $ emulatorHost ) { if ( $ scheme = parse_url ( $ emulatorHost , PHP_URL_SCHEME ) ) { $ search = $ scheme . '://' ; $ emulatorHost = str_replace ( $ search , '' , $ emulatorHost ) ; } return [ 'serviceAddress' => $ emulatorHost , 'transportConfig' => [ 'grpc' => [ 'stubOpts' => [ 'credentials' => \ Grpc \ ChannelCredentials :: createInsecure ( ) ] ] ] ] ; }
Configure the gapic configuration to use a service emulator .
2,820
private function emulatorBaseUri ( $ emulatorHost ) { $ emulatorUriComponents = parse_url ( $ emulatorHost ) ; $ emulatorUriComponents = array_merge ( [ 'scheme' => 'http' , 'port' => '' ] , $ emulatorUriComponents ) ; $ baseUri = "{$emulatorUriComponents['scheme']}://{$emulatorUriComponents['host']}" ; $ baseUri .= $ emulatorUriComponents [ 'port' ] ? ":{$emulatorUriComponents['port']}/" : '/' ; return $ baseUri ; }
Retrieve a valid base uri for a service emulator .
2,821
public function getEmulatorBaseUri ( $ baseUri , $ emulatorHost = null ) { if ( $ emulatorHost ) { $ baseUri = $ this -> emulatorBaseUri ( $ emulatorHost ) ; } return $ baseUri ; }
When emulators are enabled use them as the service host .
2,822
public function setLoginProfile ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ OsLogin \ V1 \ LoginProfile :: class ) ; $ this -> login_profile = $ var ; return $ this ; }
The login profile information for the user .
2,823
public function executePartition ( PartitionInterface $ partition , array $ options = [ ] ) { if ( $ partition instanceof QueryPartition ) { return $ this -> executeQuery ( $ partition ) ; } elseif ( $ partition instanceof ReadPartition ) { return $ this -> executeRead ( $ partition ) ; } throw new \ BadMethodCallException ( 'Unsupported partition type.' ) ; }
Read rows from a partition .
2,824
public function serialize ( ) { return base64_encode ( json_encode ( [ 'sessionName' => $ this -> session -> name ( ) , 'transactionId' => $ this -> transactionId , 'readTimestamp' => $ this -> readTimestamp -> formatAsString ( ) ] ) ) ; }
Return a stringified representation of the BatchSnapshot object .
2,825
private function executeQuery ( QueryPartition $ partition ) { return $ this -> execute ( $ partition -> sql ( ) , [ 'partitionToken' => $ partition -> token ( ) ] + $ partition -> options ( ) ) ; }
Run executeStreamingSql with a partition .
2,826
private function executeRead ( ReadPartition $ partition ) { return $ this -> read ( $ partition -> table ( ) , $ partition -> keySet ( ) , $ partition -> columns ( ) , [ 'partitionToken' => $ partition -> token ( ) ] + $ partition -> options ( ) ) ; }
Run streamingRead with a partition .
2,827
public function setCluster ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dataproc \ V1beta2 \ Cluster :: class ) ; $ this -> cluster = $ var ; return $ this ; }
Required . The cluster to create .
2,828
public function setTopic ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ PubSub \ V1 \ Topic :: class ) ; $ this -> topic = $ var ; return $ this ; }
The updated topic object .
2,829
public static function queueName ( $ project , $ location , $ queue ) { return self :: getQueueNameTemplate ( ) -> render ( [ 'project' => $ project , 'location' => $ location , 'queue' => $ queue , ] ) ; }
Formats a string containing the fully - qualified path to represent a queue resource .
2,830
public static function taskName ( $ project , $ location , $ queue , $ task ) { return self :: getTaskNameTemplate ( ) -> render ( [ 'project' => $ project , 'location' => $ location , 'queue' => $ queue , 'task' => $ task , ] ) ; }
Formats a string containing the fully - qualified path to represent a task resource .
2,831
public function setHadoopJob ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dataproc \ V1 \ HadoopJob :: class ) ; $ this -> writeOneof ( 2 , $ var ) ; return $ this ; }
Job is a Hadoop job .
2,832
public function setSparkJob ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dataproc \ V1 \ SparkJob :: class ) ; $ this -> writeOneof ( 3 , $ var ) ; return $ this ; }
Job is a Spark job .
2,833
public function setMin ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ Value :: class ) ; $ this -> min = $ var ; return $ this ; }
Lower bound of the range inclusive . Type should be the same as max if used .
2,834
public function setMax ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ Value :: class ) ; $ this -> max = $ var ; return $ this ; }
Upper bound of the range exclusive ; type must match min .
2,835
public function setReplacementValue ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ Value :: class ) ; $ this -> replacement_value = $ var ; return $ this ; }
Replacement value for this bucket . If not provided the default behavior will be to hyphenate the min - max range .
2,836
public function setDeviceType ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ DeviceInfo_DeviceType :: class ) ; $ this -> device_type = $ var ; return $ this ; }
Optional . Type of the device .
2,837
public static function snapshotName ( $ project , $ instance , $ cluster , $ snapshot ) { return self :: getSnapshotNameTemplate ( ) -> render ( [ 'project' => $ project , 'instance' => $ instance , 'cluster' => $ cluster , 'snapshot' => $ snapshot , ] ) ; }
Formats a string containing the fully - qualified path to represent a snapshot resource .
2,838
public function setSnapshotInspectTemplate ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dlp \ V2 \ InspectTemplate :: class ) ; $ this -> snapshot_inspect_template = $ var ; return $ this ; }
If run with an InspectTemplate a snapshot of its state at the time of this run .
2,839
public function setAudioEncoding ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ TextToSpeech \ V1 \ AudioEncoding :: class ) ; $ this -> audio_encoding = $ var ; return $ this ; }
Required . The format of the requested audio byte stream .
2,840
public function setFamilies ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Bigtable \ V2 \ Family :: class ) ; $ this -> families = $ arr ; return $ this ; }
May be empty but only if the entire row is empty . The mutual ordering of column families is not specified .
2,841
private function operationToArray ( $ operation , $ serializer , array $ lroMappers ) { $ response = $ operation -> getLastProtoResponse ( ) ; if ( is_null ( $ response ) ) { return null ; } $ response = $ serializer -> encodeMessage ( $ response ) ; $ result = null ; if ( $ operation -> isDone ( ) ) { $ type = $ response [ 'metadata' ] [ 'typeUrl' ] ; $ result = $ this -> deserializeResult ( $ operation , $ type , $ serializer , $ lroMappers ) ; } $ error = $ operation -> getError ( ) ; if ( ! is_null ( $ error ) ) { $ error = $ serializer -> encodeMessage ( $ error ) ; } $ response [ 'response' ] = $ result ; $ response [ 'error' ] = $ error ; return $ response ; }
Convert a ApiCore OperationResponse object to an array .
2,842
private function deserializeResult ( $ operation , $ type , $ serializer , array $ mappers ) { $ mappers = array_filter ( $ mappers , function ( $ mapper ) use ( $ type ) { return $ mapper [ 'typeUrl' ] === $ type ; } ) ; if ( count ( $ mappers ) === 0 ) { throw new \ RuntimeException ( sprintf ( 'No mapper exists for operation response type %s.' , $ type ) ) ; } $ mapper = current ( $ mappers ) ; $ message = $ mapper [ 'message' ] ; $ response = new $ message ( ) ; $ anyResponse = $ operation -> getLastProtoResponse ( ) -> getResponse ( ) ; if ( is_null ( $ anyResponse ) ) { return null ; } $ response -> mergeFromString ( $ anyResponse -> getValue ( ) ) ; return $ serializer -> encodeMessage ( $ response ) ; }
Convert an operation response to an array
2,843
public function submit ( RequestParameters $ params ) { $ handle = $ this -> curl -> init ( $ this -> siteVerifyUrl ) ; $ options = array ( CURLOPT_POST => true , CURLOPT_POSTFIELDS => $ params -> toQueryString ( ) , CURLOPT_HTTPHEADER => array ( 'Content-Type: application/x-www-form-urlencoded' ) , CURLINFO_HEADER_OUT => false , CURLOPT_HEADER => false , CURLOPT_RETURNTRANSFER => true , CURLOPT_SSL_VERIFYPEER => true ) ; $ this -> curl -> setoptArray ( $ handle , $ options ) ; $ response = $ this -> curl -> exec ( $ handle ) ; $ this -> curl -> close ( $ handle ) ; if ( $ response !== false ) { return $ response ; } return '{"success": false, "error-codes": ["' . ReCaptcha :: E_CONNECTION_FAILED . '"]}' ; }
Submit the cURL request with the specified parameters .
2,844
public function verify ( $ response , $ remoteIp = null ) { if ( empty ( $ response ) ) { $ recaptchaResponse = new Response ( false , array ( self :: E_MISSING_INPUT_RESPONSE ) ) ; return $ recaptchaResponse ; } $ params = new RequestParameters ( $ this -> secret , $ response , $ remoteIp , self :: VERSION ) ; $ rawResponse = $ this -> requestMethod -> submit ( $ params ) ; $ initialResponse = Response :: fromJson ( $ rawResponse ) ; $ validationErrors = array ( ) ; if ( isset ( $ this -> hostname ) && strcasecmp ( $ this -> hostname , $ initialResponse -> getHostname ( ) ) !== 0 ) { $ validationErrors [ ] = self :: E_HOSTNAME_MISMATCH ; } if ( isset ( $ this -> apkPackageName ) && strcasecmp ( $ this -> apkPackageName , $ initialResponse -> getApkPackageName ( ) ) !== 0 ) { $ validationErrors [ ] = self :: E_APK_PACKAGE_NAME_MISMATCH ; } if ( isset ( $ this -> action ) && strcasecmp ( $ this -> action , $ initialResponse -> getAction ( ) ) !== 0 ) { $ validationErrors [ ] = self :: E_ACTION_MISMATCH ; } if ( isset ( $ this -> threshold ) && $ this -> threshold > $ initialResponse -> getScore ( ) ) { $ validationErrors [ ] = self :: E_SCORE_THRESHOLD_NOT_MET ; } if ( isset ( $ this -> timeoutSeconds ) ) { $ challengeTs = strtotime ( $ initialResponse -> getChallengeTs ( ) ) ; if ( $ challengeTs > 0 && time ( ) - $ challengeTs > $ this -> timeoutSeconds ) { $ validationErrors [ ] = self :: E_CHALLENGE_TIMEOUT ; } } if ( empty ( $ validationErrors ) ) { return $ initialResponse ; } return new Response ( false , array_merge ( $ initialResponse -> getErrorCodes ( ) , $ validationErrors ) , $ initialResponse -> getHostname ( ) , $ initialResponse -> getChallengeTs ( ) , $ initialResponse -> getApkPackageName ( ) , $ initialResponse -> getScore ( ) , $ initialResponse -> getAction ( ) ) ; }
Calls the reCAPTCHA siteverify API to verify whether the user passes CAPTCHA test and additionally runs any specified additional checks
2,845
protected function createSettingsFile ( $ format , $ options ) { $ SettingsClass = ( $ format === 'json' ) ? JsonSettings :: class : YamlSettings :: class ; $ filename = $ this -> exampleSettingsExists ( $ format ) ? "{$this->basePath}/Homestead.{$format}.example" : __DIR__ . "/../resources/Homestead.{$format}" ; $ settings = $ SettingsClass :: fromFile ( $ filename ) ; if ( ! $ this -> exampleSettingsExists ( $ format ) ) { $ settings -> updateName ( $ options [ 'name' ] ) -> updateHostname ( $ options [ 'hostname' ] ) ; } $ settings -> updateIpAddress ( $ options [ 'ip' ] ) -> configureSites ( $ this -> projectName , $ this -> defaultProjectName ) -> configureSharedFolders ( $ this -> basePath , $ this -> defaultProjectName ) -> save ( "{$this->basePath}/Homestead.{$format}" ) ; }
Create the homestead settings file .
2,846
public function update ( $ attributes ) { $ this -> attributes = array_merge ( $ this -> attributes , array_filter ( $ attributes , function ( $ attribute ) { return ! is_null ( $ attribute ) ; } ) ) ; return $ this ; }
Update the homestead settings .
2,847
public function configureSites ( $ projectName , $ projectDirectory ) { $ sites = [ [ 'map' => "{$projectName}.test" , 'to' => "/home/vagrant/{$projectDirectory}/public" , ] , ] ; if ( isset ( $ this -> attributes [ 'sites' ] ) && ! empty ( $ this -> attributes [ 'sites' ] ) ) { foreach ( $ this -> attributes [ 'sites' ] as $ index => $ user_site ) { if ( isset ( $ user_site [ 'map' ] ) ) { $ sites [ $ index ] [ 'map' ] = $ user_site [ 'map' ] ; } if ( isset ( $ user_site [ 'to' ] ) ) { $ sites [ $ index ] [ 'to' ] = $ user_site [ 'to' ] ; } if ( isset ( $ user_site [ 'type' ] ) ) { $ sites [ $ index ] [ 'type' ] = $ user_site [ 'type' ] ; } if ( isset ( $ user_site [ 'schedule' ] ) ) { $ sites [ $ index ] [ 'schedule' ] = $ user_site [ 'schedule' ] ; } if ( isset ( $ user_site [ 'php' ] ) ) { $ sites [ $ index ] [ 'php' ] = $ user_site [ 'php' ] ; } if ( isset ( $ user_site [ 'xhgui' ] ) ) { $ sites [ $ index ] [ 'xhgui' ] = $ user_site [ 'xhgui' ] ; } } } $ this -> update ( [ 'sites' => $ sites ] ) ; return $ this ; }
Configure the nginx sites .
2,848
public function configureSharedFolders ( $ projectPath , $ projectDirectory ) { $ folders = [ [ 'map' => $ projectPath , 'to' => "/home/vagrant/{$projectDirectory}" , ] , ] ; if ( isset ( $ this -> attributes [ 'folders' ] ) && ! empty ( $ this -> attributes [ 'folders' ] ) ) { foreach ( $ this -> attributes [ 'folders' ] as $ index => $ user_folder ) { if ( isset ( $ user_folder [ 'map' ] ) && empty ( $ folders [ $ index ] [ 'map' ] ) ) { $ folders [ $ index ] [ 'map' ] = dirname ( $ projectPath ) . '/' . basename ( $ user_folder [ 'map' ] ) ; } if ( isset ( $ user_folder [ 'to' ] ) ) { $ folders [ $ index ] [ 'to' ] = $ user_folder [ 'to' ] ; } if ( isset ( $ user_folder [ 'type' ] ) ) { $ folders [ $ index ] [ 'type' ] = $ user_folder [ 'type' ] ; } } } $ this -> update ( [ 'folders' => $ folders ] ) ; return $ this ; }
Configure the shared folders .
2,849
public function mergeProperties ( $ object ) { $ defaultValues = get_class_vars ( get_class ( $ this ) ) ; $ currentValues = get_object_vars ( $ this ) ; foreach ( $ object as $ property => $ value ) { if ( $ property === '_context' ) { continue ; } if ( $ currentValues [ $ property ] === $ defaultValues [ $ property ] ) { $ this -> $ property = $ value ; continue ; } if ( $ property === '_unmerged' ) { $ this -> _unmerged = array_merge ( $ this -> _unmerged , $ value ) ; continue ; } if ( $ currentValues [ $ property ] !== $ value ) { if ( $ defaultValues [ $ property ] === $ value ) { continue ; } $ identity = method_exists ( $ object , 'identity' ) ? $ object -> identity ( ) : get_class ( $ object ) ; $ context1 = $ this -> _context ; $ context2 = property_exists ( $ object , '_context' ) ? $ object -> _context : 'unknown' ; if ( is_object ( $ this -> $ property ) && $ this -> $ property instanceof AbstractAnnotation ) { $ context1 = $ this -> $ property -> _context ; } Logger :: warning ( 'Multiple definitions for ' . $ identity . '->' . $ property . "\n Using: " . $ context1 . "\n Skipping: " . $ context2 ) ; } } }
Merge the properties from the given object into this annotation . Prevents overwriting properties that are already configured .
2,850
private static function _validate ( $ fields , $ parents , $ skip , $ baseRef ) { $ valid = true ; $ blacklist = [ ] ; if ( is_object ( $ fields ) ) { if ( in_array ( $ fields , $ skip , true ) ) { return true ; } $ skip [ ] = $ fields ; $ blacklist = property_exists ( $ fields , '_blacklist' ) ? $ fields :: $ _blacklist : [ ] ; } foreach ( $ fields as $ field => $ value ) { if ( $ value === null || is_scalar ( $ value ) || in_array ( $ field , $ blacklist ) ) { continue ; } $ ref = $ baseRef !== '' ? $ baseRef . '/' . urlencode ( ( string ) $ field ) : urlencode ( ( string ) $ field ) ; if ( is_object ( $ value ) ) { if ( method_exists ( $ value , 'validate' ) ) { if ( ! $ value -> validate ( $ parents , $ skip , $ ref ) ) { $ valid = false ; } } elseif ( ! self :: _validate ( $ value , $ parents , $ skip , $ ref ) ) { $ valid = false ; } } elseif ( is_array ( $ value ) && ! self :: _validate ( $ value , $ parents , $ skip , $ ref ) ) { $ valid = false ; } } return $ valid ; }
Recursively validate all annotation properties .
2,851
private function validateType ( $ type , $ value ) : bool { if ( substr ( $ type , 0 , 1 ) === '[' && substr ( $ type , - 1 ) === ']' ) { if ( $ this -> validateType ( 'array' , $ value ) === false ) { return false ; } $ itemType = substr ( $ type , 1 , - 1 ) ; foreach ( $ value as $ i => $ item ) { if ( $ this -> validateType ( $ itemType , $ item ) === false ) { return false ; } } return true ; } if ( is_subclass_of ( $ type , AbstractAnnotation :: class ) ) { $ type = 'object' ; } return $ this -> validateDefaultTypes ( $ type , $ value ) ; }
Validates the matching of the property value to a annotation type
2,852
private function validateDefaultTypes ( $ type , $ value ) : bool { switch ( $ type ) { case 'string' : return is_string ( $ value ) ; case 'boolean' : return is_bool ( $ value ) ; case 'integer' : return is_int ( $ value ) ; case 'number' : return is_numeric ( $ value ) ; case 'object' : return is_object ( $ value ) ; case 'array' : return $ this -> validateArrayType ( $ value ) ; case 'scheme' : return in_array ( $ value , [ 'http' , 'https' , 'ws' , 'wss' ] , true ) ; default : throw new Exception ( 'Invalid type "' . $ type . '"' ) ; } }
Validates default Open Api types
2,853
private function validateArrayType ( $ value ) : bool { if ( is_array ( $ value ) === false ) { return false ; } $ count = 0 ; foreach ( $ value as $ i => $ item ) { if ( $ count !== $ i ) { return false ; } $ count ++ ; } return true ; }
Validate array type
2,854
private function nested ( $ annotation , $ nestedContext ) { if ( property_exists ( $ annotation , '_context' ) && $ annotation -> _context === $ this -> _context ) { $ annotation -> _context = $ nestedContext ; } return $ annotation ; }
Wrap the context with a reference to the annotation it is nested in .
2,855
private function addAllOfProperty ( Schema $ childSchema , Schema $ parentSchema ) { $ currentSchema = new Schema ( [ '_context' => $ childSchema -> _context ] ) ; $ currentSchema -> mergeProperties ( $ childSchema ) ; $ defaultValues = get_class_vars ( Schema :: class ) ; foreach ( get_object_vars ( $ currentSchema ) as $ property => $ val ) { $ childSchema -> { $ property } = $ defaultValues [ $ property ] ; } $ childSchema -> schema = $ currentSchema -> schema ; unset ( $ currentSchema -> schema ) ; if ( $ childSchema -> allOf === UNDEFINED ) { $ childSchema -> allOf = [ ] ; } $ childSchema -> allOf [ ] = new Schema ( [ '_context' => $ parentSchema -> _context , 'ref' => Components :: SCHEMA_REF . $ parentSchema -> schema ] ) ; $ childSchema -> allOf [ ] = $ currentSchema ; }
Add to child schema allOf property
2,856
public function fromComment ( $ comment , $ context = null ) { if ( $ context === null ) { $ context = new Context ( [ 'comment' => $ comment ] ) ; } else { $ context -> comment = $ comment ; } try { self :: $ context = $ context ; if ( $ context -> is ( 'annotations' ) === false ) { $ context -> annotations = [ ] ; } $ comment = preg_replace_callback ( '/^[\t ]*\*[\t ]+/m' , function ( $ match ) { return str_replace ( "\t" , ' ' , $ match [ 0 ] ) ; } , $ comment ) ; $ annotations = $ this -> docParser -> parse ( $ comment , $ context ) ; self :: $ context = null ; return $ annotations ; } catch ( Exception $ e ) { self :: $ context = null ; if ( preg_match ( '/^(.+) at position ([0-9]+) in ' . preg_quote ( ( string ) $ context , '/' ) . '\.$/' , $ e -> getMessage ( ) , $ matches ) ) { $ errorMessage = $ matches [ 1 ] ; $ errorPos = ( int ) $ matches [ 2 ] ; $ atPos = strpos ( $ comment , '@' ) ; $ context -> line += substr_count ( $ comment , "\n" , 0 , $ atPos + $ errorPos ) ; $ lines = explode ( "\n" , substr ( $ comment , $ atPos , $ errorPos ) ) ; $ context -> character = strlen ( array_pop ( $ lines ) ) + 1 ; Logger :: warning ( new Exception ( $ errorMessage . ' in ' . $ context , $ e -> getCode ( ) , $ e ) ) ; } else { Logger :: warning ( $ e ) ; } return [ ] ; } }
Use doctrine to parse the comment block and return the detected annotations .
2,857
public function deserialize ( $ jsonString , $ className ) { if ( ! $ this -> isValidClassName ( $ className ) ) { throw new \ Exception ( $ className . ' is not defined in OpenApi PHP Annotations' ) ; } return $ this -> doDeserialize ( json_decode ( $ jsonString ) , $ className ) ; }
Deserialize a string
2,858
public function deserializeFile ( $ filename , $ className = 'OpenApi\Annotations\OpenApi' ) { if ( ! $ this -> isValidClassName ( $ className ) ) { throw new \ Exception ( $ className . ' is not defined in OpenApi PHP Annotations' ) ; } $ jsonString = file_get_contents ( $ filename ) ; return $ this -> doDeserialize ( json_decode ( $ jsonString ) , $ className ) ; }
Deserialize a file
2,859
private function doDeserialize ( \ stdClass $ c , $ class ) { $ annotation = new $ class ( [ ] ) ; foreach ( $ c as $ property => $ value ) { if ( $ property === '$ref' ) { $ property = 'ref' ; } if ( substr ( $ property , 0 , 2 ) === 'x-' ) { if ( $ annotation -> x === UNDEFINED ) { $ annotation -> x = [ ] ; } $ custom = substr ( $ property , 2 ) ; $ annotation -> x [ $ custom ] = $ value ; } else { $ annotation -> $ property = $ this -> doDeserializeProperty ( $ annotation , $ property , $ value ) ; } } return $ annotation ; }
Do deserialization .
2,860
private function doDeserializeProperty ( Annotations \ AbstractAnnotation $ annotation , $ property , $ value ) { if ( array_key_exists ( $ property , $ annotation :: $ _types ) ) { return $ this -> doDeserializeBaseProperty ( $ annotation :: $ _types [ $ property ] , $ value ) ; } foreach ( $ annotation :: $ _nested as $ class => $ declaration ) { if ( is_string ( $ declaration ) && $ declaration === $ property ) { return $ this -> doDeserialize ( $ value , $ class ) ; } if ( is_array ( $ declaration ) && count ( $ declaration ) === 1 && $ declaration [ 0 ] === $ property ) { $ annotationArr = [ ] ; foreach ( $ value as $ v ) { $ annotationArr [ ] = $ this -> doDeserialize ( $ v , $ class ) ; } return $ annotationArr ; } if ( is_array ( $ declaration ) && count ( $ declaration ) === 2 && $ declaration [ 0 ] === $ property ) { $ key = $ declaration [ 1 ] ; $ annotationHash = [ ] ; foreach ( $ value as $ k => $ v ) { $ annotation = $ this -> doDeserialize ( $ v , $ class ) ; $ annotation -> $ key = $ k ; $ annotationHash [ $ k ] = $ annotation ; } return $ annotationHash ; } } return $ value ; }
Deserialize the annotation s property .
2,861
private function doDeserializeBaseProperty ( $ type , $ value ) { $ isAnnotationClass = is_string ( $ type ) && is_subclass_of ( trim ( $ type , '[]' ) , AbstractAnnotation :: class ) ; if ( $ isAnnotationClass ) { $ isArray = strpos ( $ type , '[' ) === 0 && substr ( $ type , - 1 ) === ']' ; if ( $ isArray ) { $ annotationArr = [ ] ; $ class = trim ( $ type , '[]' ) ; foreach ( $ value as $ v ) { $ annotationArr [ ] = $ this -> doDeserialize ( $ v , $ class ) ; } return $ annotationArr ; } return $ this -> doDeserialize ( $ value , $ type ) ; } return $ value ; }
Deserialize base annotation property
2,862
public function with ( $ property ) { if ( property_exists ( $ this , $ property ) ) { return $ this ; } if ( $ this -> _parent ) { return $ this -> _parent -> with ( $ property ) ; } return false ; }
Return the context containing the specified property .
2,863
public function getDebugLocation ( ) { $ location = '' ; if ( $ this -> class && ( $ this -> method || $ this -> property ) ) { $ location .= $ this -> fullyQualifiedName ( $ this -> class ) ; if ( $ this -> method ) { $ location .= ( $ this -> static ? '::' : '->' ) . $ this -> method . '()' ; } elseif ( $ this -> property ) { $ location .= ( $ this -> static ? '::$' : '->' ) . $ this -> property ; } } if ( $ this -> filename ) { if ( $ location !== '' ) { $ location .= ' in ' ; } $ location .= $ this -> filename ; } if ( $ this -> line ) { if ( $ location !== '' ) { $ location .= ' on' ; } $ location .= ' line ' . $ this -> line ; if ( $ this -> character ) { $ location .= ':' . $ this -> character ; } } return $ location ; }
Export location for debugging .
2,864
public function phpdocSummary ( ) { $ content = $ this -> phpdocContent ( ) ; if ( ! $ content ) { return UNDEFINED ; } $ lines = preg_split ( '/(\n|\r\n)/' , $ content ) ; $ summary = '' ; foreach ( $ lines as $ line ) { $ summary .= $ line . "\n" ; if ( $ line === '' || substr ( $ line , - 1 ) === '.' ) { return trim ( $ summary ) ; } } $ summary = trim ( $ summary ) ; if ( $ summary === '' ) { return UNDEFINED ; } return $ summary ; }
A short piece of text usually one line providing the basic function of the associated element .
2,865
public static function detect ( $ index = 0 ) { $ context = new Context ( ) ; $ backtrace = debug_backtrace ( ) ; $ position = $ backtrace [ $ index ] ; if ( isset ( $ position [ 'file' ] ) ) { $ context -> filename = $ position [ 'file' ] ; } if ( isset ( $ position [ 'line' ] ) ) { $ context -> line = $ position [ 'line' ] ; } $ caller = isset ( $ backtrace [ $ index + 1 ] ) ? $ backtrace [ $ index + 1 ] : null ; if ( isset ( $ caller [ 'function' ] ) ) { $ context -> method = $ caller [ 'function' ] ; if ( isset ( $ caller [ 'type' ] ) && $ caller [ 'type' ] === '::' ) { $ context -> static = true ; } } if ( isset ( $ caller [ 'class' ] ) ) { $ fqn = explode ( '\\' , $ caller [ 'class' ] ) ; $ context -> class = array_pop ( $ fqn ) ; if ( count ( $ fqn ) ) { $ context -> namespace = implode ( '\\' , $ fqn ) ; } } return $ context ; }
Create a Context based on the debug_backtrace
2,866
public function fullyQualifiedName ( $ class ) { if ( $ this -> namespace ) { $ namespace = str_replace ( '\\\\' , '\\' , '\\' . $ this -> namespace . '\\' ) ; } else { $ namespace = '\\' ; } if ( $ this -> class === null ) { $ this -> class = '' ; } if ( $ class === null ) { return '' ; } if ( strcasecmp ( $ class , $ this -> class ) === 0 ) { return $ namespace . $ this -> class ; } $ pos = strpos ( $ class , '\\' ) ; if ( $ pos !== false ) { if ( $ pos === 0 ) { return $ class ; } if ( $ this -> uses ) { foreach ( $ this -> uses as $ alias => $ aliasedNamespace ) { $ alias .= '\\' ; if ( strcasecmp ( substr ( $ class , 0 , strlen ( $ alias ) ) , $ alias ) === 0 ) { return '\\' . $ aliasedNamespace . substr ( $ class , strlen ( $ alias ) - 1 ) ; } } } } elseif ( $ this -> uses ) { foreach ( $ this -> uses as $ alias => $ aliasedNamespace ) { if ( strcasecmp ( $ alias , $ class ) === 0 ) { return '\\' . $ aliasedNamespace ; } } } return $ namespace . $ class ; }
Resolve the fully qualified name .
2,867
public function getTraitsOfClass ( $ class ) { $ definitions = [ ] ; $ classes = $ this -> getSuperClasses ( $ class ) ; if ( is_array ( $ classes ) ) { foreach ( $ classes as $ subClass ) { if ( isset ( $ subClass [ 'traits' ] ) ) { foreach ( $ subClass [ 'traits' ] as $ classTrait ) { foreach ( $ this -> traits as $ trait ) { if ( $ classTrait === $ trait [ 'trait' ] ) { $ traitDefinition [ $ trait [ 'trait' ] ] = $ trait ; $ definitions = array_merge ( $ definitions , $ traitDefinition ) ; } } } } } } $ classDefinition = isset ( $ this -> classes [ $ class ] ) ? $ this -> classes [ $ class ] : null ; if ( ! $ classDefinition || empty ( $ classDefinition [ 'traits' ] ) ) { return $ definitions ; } $ classTraits = $ classDefinition [ 'traits' ] ; foreach ( $ this -> traits as $ trait ) { foreach ( $ classTraits as $ classTrait => $ name ) { if ( $ trait [ 'trait' ] === $ name ) { $ traitDefinition [ $ name ] = $ trait ; $ definitions = array_merge ( $ definitions , $ traitDefinition ) ; } } } return $ definitions ; }
Returns an array of traits used by the given class or by classes which it extends
2,868
public function merged ( ) { if ( ! $ this -> openapi ) { throw new Exception ( 'No openapi target set. Run the MergeIntoOpenApi processor' ) ; } $ unmerged = $ this -> openapi -> _unmerged ; $ this -> openapi -> _unmerged = [ ] ; $ analysis = new Analysis ( [ $ this -> openapi ] ) ; $ this -> openapi -> _unmerged = $ unmerged ; return $ analysis ; }
Build an analysis with only the annotations that are merged into the OpenAPI annotation .
2,869
public function split ( ) { $ result = new stdClass ( ) ; $ result -> merged = $ this -> merged ( ) ; $ result -> unmerged = new Analysis ( ) ; foreach ( $ this -> annotations as $ annotation ) { if ( $ result -> merged -> annotations -> contains ( $ annotation ) === false ) { $ result -> unmerged -> annotations -> attach ( $ annotation , $ this -> annotations [ $ annotation ] ) ; } } return $ result ; }
Split the annotation into two analysis . One with annotations that are merged and one with annotations that are not merged .
2,870
public static function & processors ( ) { if ( ! self :: $ processors ) { self :: $ processors = [ new MergeIntoOpenApi ( ) , new MergeIntoComponents ( ) , new ImportTraits ( ) , new AugmentSchemas ( ) , new AugmentProperties ( ) , new BuildPaths ( ) , new InheritProperties ( ) , new AugmentOperations ( ) , new AugmentParameters ( ) , new MergeJsonContent ( ) , new MergeXmlContent ( ) , new OperationId ( ) , new CleanUnmerged ( ) , ] ; } return self :: $ processors ; }
Get direct access to the processors array .
2,871
public static function unregisterProcessor ( $ processor ) { $ processors = & self :: processors ( ) ; $ key = array_search ( $ processor , $ processors , true ) ; if ( $ key === false ) { throw new Exception ( 'Given processor was not registered' ) ; } unset ( $ processors [ $ key ] ) ; }
Unregister a processor
2,872
public function fromFile ( $ filename ) { if ( function_exists ( 'opcache_get_status' ) && function_exists ( 'opcache_get_configuration' ) ) { if ( empty ( $ GLOBALS [ 'openapi_opcache_warning' ] ) ) { $ GLOBALS [ 'openapi_opcache_warning' ] = true ; $ status = opcache_get_status ( ) ; $ config = opcache_get_configuration ( ) ; if ( $ status [ 'opcache_enabled' ] && $ config [ 'directives' ] [ 'opcache.save_comments' ] == false ) { Logger :: warning ( "php.ini \"opcache.save_comments = 0\" interferes with extracting annotations.\n[LINK] http://php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments" ) ; } } } $ tokens = token_get_all ( file_get_contents ( $ filename ) ) ; return $ this -> fromTokens ( $ tokens , new Context ( [ 'filename' => $ filename ] ) ) ; }
Extract and process all doc - comments from a file .
2,873
public function fromCode ( $ code , $ context ) { $ tokens = token_get_all ( $ code ) ; return $ this -> fromTokens ( $ tokens , $ context ) ; }
Extract and process all doc - comments from the contents .
2,874
private function nextToken ( & $ tokens , $ context ) { while ( true ) { $ token = next ( $ tokens ) ; if ( $ token [ 0 ] === T_WHITESPACE ) { continue ; } if ( $ token [ 0 ] === T_COMMENT ) { $ pos = strpos ( $ token [ 1 ] , '@OA\\' ) ; if ( $ pos ) { $ line = $ context -> line ? $ context -> line + $ token [ 2 ] : $ token [ 2 ] ; $ commentContext = new Context ( [ 'line' => $ line ] , $ context ) ; Logger :: notice ( 'Annotations are only parsed inside `/**` DocBlocks, skipping ' . $ commentContext ) ; } continue ; } return $ token ; } }
The next non - whitespace non - comment token .
2,875
public function saveAs ( $ filename , $ format = 'auto' ) { if ( $ format === 'auto' ) { $ format = strtolower ( substr ( $ filename , - 5 ) ) === '.json' ? 'json' : 'yaml' ; } if ( strtolower ( $ format ) === 'json' ) { $ content = $ this -> toJson ( ) ; } else { $ content = $ this -> toYaml ( ) ; } if ( file_put_contents ( $ filename , $ content ) === false ) { throw new Exception ( 'Failed to saveAs("' . $ filename . '", "' . $ format . '")' ) ; } }
Save the OpenAPI documentation to a file .
2,876
private static function removePrefix ( $ str , $ prefix ) { if ( substr ( $ str , 0 , strlen ( $ prefix ) ) == $ prefix ) { return substr ( $ str , strlen ( $ prefix ) ) ; } return null ; }
Removes a prefix from the start of a string if it exists or null otherwise .
2,877
public function route ( string $ name , array $ parameters = [ ] , bool $ absolute = true ) : self { $ this -> route = route ( $ name , $ parameters , $ absolute ) ; $ this -> active ( [ $ this -> route , $ this -> route . '/*' ] ) ; return $ this ; }
Generate the URL to a named route .
2,878
public function targetId ( ) : self { $ this -> set ( 'target' , 'id' ) ; $ this -> addBeforeRender ( function ( ) { $ value = ( string ) $ this -> get ( 'value' ) ; if ( ! ctype_digit ( $ value ) ) { return ; } $ attach = Dashboard :: model ( Attachment :: class ) ; $ url = optional ( $ attach :: find ( $ value ) ) -> url ( ) ; $ this -> set ( 'url' , $ url ) ; } ) ; return $ this ; }
The stored value will be in the form of id attachment .
2,879
public function add ( string $ place , ItemMenu $ itemMenu ) { $ arg = get_object_vars ( $ itemMenu ) ; if ( array_key_exists ( 'show' , $ arg ) && ! $ arg [ 'show' ] ) { return $ this ; } $ this -> location = $ place ; $ this -> arg = $ arg ; $ this -> sort = $ arg [ 'sort' ] ; $ this -> item = [ 'location' => $ this -> location , 'arg' => $ this -> arg , 'sort' => $ this -> sort , ] ; $ this -> container [ $ this -> arg [ 'slug' ] ] = $ this -> item ; return $ this ; }
Adding a new element to the container .
2,880
public function render ( string $ location , string $ template = 'platform::partials.mainMenu' ) : string { $ this -> checkAccess ( ) ; return $ this -> findAllChildren ( $ location ) -> sortBy ( 'sort' ) -> map ( function ( $ value ) use ( $ template ) { return view ( $ template , $ value ) -> render ( ) ; } ) -> implode ( ' ' ) ; }
Generate on the menu display .
2,881
public function show ( string $ package , string $ path , Dashboard $ dashboard ) { $ dir = $ dashboard -> getPublicDirectory ( ) -> get ( $ package ) ; abort_if ( is_null ( $ dir ) , 404 ) ; $ resources = ( new Finder ( ) ) -> ignoreUnreadableDirs ( ) -> followLinks ( ) -> in ( $ dir ) -> files ( ) -> path ( dirname ( $ path ) ) -> name ( basename ( $ path ) ) ; $ iterator = tap ( $ resources -> getIterator ( ) ) -> rewind ( ) ; $ this -> resource = $ iterator -> current ( ) ; abort_if ( is_null ( $ this -> resource ) , 404 ) ; $ mime = new MimeTypes ( ) ; $ mime = $ mime -> getMimeType ( $ this -> resource -> getExtension ( ) ) ; return response ( ) -> file ( $ this -> resource -> getRealPath ( ) , [ 'Content-Type' => $ mime ?? 'text/plain' , 'Cache-Control' => 'public, max-age=31536000' , ] ) ; }
Serve the requested resource .
2,882
public function getEntityObject ( $ slug = null ) { if ( ! is_null ( $ this -> entity ) ) { return $ this -> entity ; } return $ this -> getEntity ( $ slug ?? $ this -> getAttribute ( 'type' ) ) -> entity ; }
Get Behavior Class .
2,883
public function slug ( $ slug = null ) : self { if ( ! empty ( $ slug ) ) { $ this -> slug = $ slug ; $ exception = function ( $ query ) { $ query -> where ( 'slug' , '=' , $ this -> slug ) ; } ; return $ this -> whereHas ( 'term' , $ exception ) ; } return $ this ; }
Get a term taxonomy by specific slug .
2,884
public function noCalendar ( bool $ noCalendar = true ) : self { $ this -> enableTime ( ) ; $ this -> set ( 'data-fields--datetime-no-calendar' , var_export ( $ noCalendar , true ) ) ; return $ this ; }
Disable calendar for the field and show only time .
2,885
public function getFilters ( ) : Collection { $ filters = collect ( ) ; foreach ( $ this -> filters ( ) as $ filter ) { $ filter = new $ filter ( $ this ) ; $ filters -> push ( $ filter ) ; } return $ filters ; }
Get all the filters .
2,886
public function getStatus ( ) : bool { foreach ( $ this -> requestVersion ( ) as $ key => $ version ) { if ( ! Str :: contains ( $ key , 'dev' ) ) { continue ; } if ( version_compare ( $ version [ 'version' ] , $ this -> currentVersion , '>' ) ) { return true ; } } return false ; }
Verify that the version of the package you are using is the latest version .
2,887
public function requestVersion ( ) : array { try { $ versions = json_decode ( file_get_contents ( $ this -> apiURL ) , true ) [ 'packages' ] [ 'orchid/platform' ] ; return array_reverse ( $ versions ) ; } catch ( \ Exception $ exception ) { Log :: alert ( $ exception -> getMessage ( ) ) ; return [ [ 'version' => '0.0.0' ] ] ; } }
Make a request for Packagist API .
2,888
public function generateForm ( ) : string { foreach ( $ this -> fields as $ field ) { if ( is_array ( $ field ) ) { $ this -> renderGroup ( $ field ) ; continue ; } $ this -> form .= $ this -> render ( $ field ) ; } return $ this -> form ; }
Generate a ready - made html form for display to the user .
2,889
private function render ( Field $ field ) { $ field -> set ( 'lang' , $ this -> language ) ; $ field -> set ( 'prefix' , $ this -> buildPrefix ( $ field ) ) ; foreach ( $ this -> fill ( $ field -> getAttributes ( ) ) as $ key => $ value ) { $ field -> set ( $ key , $ value ) ; } return $ field -> render ( ) ; }
Render field for forms .
2,890
private function getValue ( string $ key , $ value = null ) { if ( ! is_null ( $ this -> language ) ) { $ key = $ this -> language . '.' . $ key ; } if ( ! is_null ( $ this -> prefix ) ) { $ key = $ this -> prefix . '.' . $ key ; } $ data = $ this -> data -> getContent ( $ key ) ; if ( is_null ( $ data ) ) { return $ value ; } if ( $ value instanceof \ Closure ) { return $ value ( $ data , $ this -> data ) ; } return $ data ; }
Gets value of Repository .
2,891
public static function prefix ( string $ path = '' ) : string { $ prefix = config ( 'platform.prefix' ) ; return Str :: start ( $ prefix . $ path , '/' ) ; }
Get the route with the dashboard prefix .
2,892
public static function model ( string $ key , string $ default = null ) { return Arr :: get ( static :: $ options , 'models.' . $ key , $ default ?? $ key ) ; }
Get the class name for a given Dashboard model .
2,893
public function getResource ( $ key = null ) { if ( is_null ( $ key ) ) { return $ this -> resources ; } return $ this -> resources -> get ( $ key ) ; }
Return CSS \ JS .
2,894
public function removeRoleBySlug ( $ slug ) : int { $ role = $ this -> roles ( ) -> where ( 'slug' , $ slug ) -> first ( ) ; return $ this -> roles ( ) -> detach ( $ role ) ; }
Remove Role Slug .
2,895
public function setPermissionsAttribute ( array $ permissions = [ ] ) { foreach ( $ permissions as $ key => $ value ) { $ permissions [ $ key ] = ( bool ) $ value ; } $ this -> attributes [ 'permissions' ] = json_encode ( $ permissions ?? [ ] ) ; }
Set permission as boolean .
2,896
protected function registerConfig ( ) { $ this -> publishes ( [ realpath ( PLATFORM_PATH . '/config/press.php' ) => config_path ( 'press.php' ) , ] , 'config' ) ; $ this -> mergeConfigFrom ( realpath ( PLATFORM_PATH . '/config/press.php' ) , 'press' ) ; return $ this ; }
Register config .
2,897
public function grid ( ) : array { return [ TD :: set ( 'id' , 'ID' ) -> align ( TD :: ALIGN_CENTER ) -> width ( '100px' ) -> filter ( 'numeric' ) -> sort ( ) -> linkPost ( ) , TD :: set ( 'name' , 'Name' ) -> width ( '250px' ) -> locale ( ) -> column ( 'content.name' ) -> filter ( 'text' ) -> sort ( ) -> linkPost ( 'name' ) , TD :: set ( 'status' ) -> sort ( ) , TD :: set ( 'phone' , 'Phone' ) -> locale ( ) -> column ( 'content.phone' ) -> filter ( 'text' ) -> linkPost ( 'phone' ) , TD :: set ( 'publish_at' , 'Date of publication' ) -> filter ( 'date' ) -> sort ( ) -> align ( TD :: ALIGN_RIGHT ) -> render ( function ( $ item ) { return optional ( $ item -> publish_at ) -> toDateString ( ) ; } ) , TD :: set ( 'created_at' , 'Date of creation' ) -> filter ( 'date' ) -> align ( TD :: ALIGN_RIGHT ) -> sort ( ) -> render ( function ( $ item ) { return $ item -> created_at -> toDateString ( ) ; } ) , ] ; }
Grid View for post type .
2,898
public function url ( $ default = null ) : ? string { $ disk = $ this -> getAttribute ( 'disk' ) ; if ( Storage :: disk ( $ disk ) -> exists ( $ this -> physicalPath ( ) ) ) { return Storage :: disk ( $ disk ) -> url ( $ this -> physicalPath ( ) ) ; } return $ default ; }
Return the address by which you can access the file .
2,899
public function getMimeType ( ) : string { $ mimes = new MimeTypes ( ) ; $ type = $ mimes -> getMimeType ( $ this -> getAttribute ( 'extension' ) ) ; return $ type ?? 'unknown' ; }
Get MIME type for file .