idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
16,200
public function fetchByName ( $ str_name ) { return $ this -> obj_gateway -> withSchema ( $ this -> obj_schema ) -> withTransaction ( $ this -> str_transaction_id ) -> fetchByName ( $ str_name ) ; }
Fetch a single Entity from the Datastore by it s Key Name
16,201
public function fetchByNames ( array $ arr_names ) { return $ this -> obj_gateway -> withSchema ( $ this -> obj_schema ) -> withTransaction ( $ this -> str_transaction_id ) -> fetchByNames ( $ arr_names ) ; }
Fetch one or more Entities from the Datastore by their Key Name
16,202
public function query ( $ str_query , $ arr_params = null ) { $ this -> str_last_query = $ str_query ; $ this -> arr_last_params = $ arr_params ; $ this -> str_last_cursor = null ; return $ this ; }
Fetch Entities based on a GQL query
16,203
public function fetchEntityGroup ( Entity $ obj_entity ) { $ arr_results = $ this -> obj_gateway -> withSchema ( $ this -> obj_schema ) -> withTransaction ( $ this -> str_transaction_id ) -> gql ( "SELECT * FROM `" . $ this -> obj_schema -> getKind ( ) . "` WHERE __key__ HAS ANCESTOR @ancestorKey" , [ 'ancestorKey' => ...
Fetch all of the entities in a particular group
16,204
public final function createEntity ( $ arr_data = null ) { $ obj_entity = $ this -> obj_schema -> createEntity ( ) ; if ( null !== $ arr_data ) { foreach ( $ arr_data as $ str_property => $ mix_value ) { $ obj_entity -> __set ( $ str_property , $ mix_value ) ; } } return $ obj_entity ; }
Create a new instance of this GDS Entity class
16,205
public function mapToGoogle ( Entity $ obj_gds_entity , \ google \ appengine \ datastore \ v4 \ Entity $ obj_entity ) { $ this -> configureGoogleKey ( $ obj_entity -> mutableKey ( ) , $ obj_gds_entity ) ; $ arr_field_defs = $ this -> obj_schema -> getProperties ( ) ; foreach ( $ obj_gds_entity -> getData ( ) as $ str_f...
Map from GDS to Google Protocol Buffer
16,206
public function mapOneFromResult ( $ obj_result ) { list ( $ obj_gds_entity , $ bol_schema_match ) = $ this -> createEntityWithKey ( $ obj_result ) ; $ arr_property_definitions = $ this -> obj_schema -> getProperties ( ) ; foreach ( $ obj_result -> getEntity ( ) -> getPropertyList ( ) as $ obj_property ) { $ str_field ...
Map a single result out of the Raw response data into a supplied Entity object
16,207
public function configureGoogleKey ( Key $ obj_key , Entity $ obj_gds_entity ) { $ mix_ancestry = $ obj_gds_entity -> getAncestry ( ) ; if ( is_array ( $ mix_ancestry ) ) { foreach ( $ mix_ancestry as $ arr_ancestor_element ) { $ this -> configureGoogleKeyPathElement ( $ obj_key -> addPathElement ( ) , $ arr_ancestor_e...
Populate a ProtoBuf Key from a GDS Entity
16,208
private function configureGoogleKeyPathElement ( Key \ PathElement $ obj_path_element , array $ arr_kpe ) { $ obj_path_element -> setKind ( $ arr_kpe [ 'kind' ] ) ; isset ( $ arr_kpe [ 'id' ] ) && $ obj_path_element -> setId ( $ arr_kpe [ 'id' ] ) ; isset ( $ arr_kpe [ 'name' ] ) && $ obj_path_element -> setName ( $ ar...
Configure a Google Key Path Element object
16,209
private function configureGooglePropertyValue ( Value $ obj_val , array $ arr_field_def , $ mix_value ) { $ bol_index = TRUE ; if ( isset ( $ arr_field_def [ 'index' ] ) && FALSE === $ arr_field_def [ 'index' ] ) { $ bol_index = FALSE ; } $ obj_val -> setIndexed ( $ bol_index ) ; if ( null === $ mix_value ) { return ; ...
Populate a ProtoBuf Property Value from a GDS Entity field definition & value
16,210
public function mapOneFromResult ( $ obj_result ) { list ( $ obj_gds_entity , $ bol_schema_match ) = $ this -> createEntityWithKey ( $ obj_result ) ; if ( isset ( $ obj_result -> entity -> properties ) ) { $ arr_property_definitions = $ this -> obj_schema -> getProperties ( ) ; foreach ( $ obj_result -> entity -> prope...
Map a single result out of the Raw response data array FROM Google TO a GDS Entity
16,211
public function mapToGoogle ( Entity $ obj_gds_entity ) { $ obj_rest_entity = ( object ) [ 'key' => ( object ) [ 'path' => $ this -> buildKeyPath ( $ obj_gds_entity ) ] , 'properties' => ( object ) [ ] ] ; $ arr_field_defs = $ this -> bestEffortFieldDefs ( $ obj_gds_entity ) ; foreach ( $ obj_gds_entity -> getData ( ) ...
Create a REST representation of a GDS entity
16,212
public function buildKeyPath ( Entity $ obj_gds_entity , $ bol_first_node = true ) { $ str_kind = $ obj_gds_entity -> getKind ( ) ; if ( null === $ str_kind ) { if ( $ bol_first_node ) { if ( $ this -> obj_schema instanceof Schema ) { $ str_kind = $ this -> obj_schema -> getKind ( ) ; } else { throw new \ Exception ( '...
Create a fully qualified Key path
16,213
protected function createKeyPathElement ( array $ arr_kpe ) { $ obj_element = ( object ) [ 'kind' => $ arr_kpe [ 'kind' ] ] ; if ( isset ( $ arr_kpe [ 'id' ] ) ) { $ obj_element -> id = $ arr_kpe [ 'id' ] ; } elseif ( isset ( $ arr_kpe [ 'name' ] ) ) { $ obj_element -> name = $ arr_kpe [ 'name' ] ; } return $ obj_eleme...
Create a Key Path Element from array
16,214
protected function createPropertyValue ( array $ arr_field_def , $ mix_value ) { $ obj_property_value = new \ stdClass ( ) ; $ bol_index = TRUE ; if ( isset ( $ arr_field_def [ 'index' ] ) && FALSE === $ arr_field_def [ 'index' ] ) { $ bol_index = FALSE ; } $ obj_property_value -> excludeFromIndexes = ! $ bol_index ; s...
Create a property object
16,215
public function addProperty ( $ str_name , $ int_type = self :: PROPERTY_STRING , $ bol_index = TRUE ) { $ this -> arr_defined_properties [ $ str_name ] = [ 'type' => $ int_type , 'index' => $ bol_index ] ; return $ this ; }
Add a field to the known field array
16,216
public function addString ( $ str_name , $ bol_index = TRUE ) { return $ this -> addProperty ( $ str_name , self :: PROPERTY_STRING , $ bol_index ) ; }
Add a string field to the schema
16,217
public function addInteger ( $ str_name , $ bol_index = TRUE ) { return $ this -> addProperty ( $ str_name , self :: PROPERTY_INTEGER , $ bol_index ) ; }
Add an integer field to the schema
16,218
public function addDatetime ( $ str_name , $ bol_index = TRUE ) { return $ this -> addProperty ( $ str_name , self :: PROPERTY_DATETIME , $ bol_index ) ; }
Add a datetime field to the schema
16,219
public function addFloat ( $ str_name , $ bol_index = TRUE ) { return $ this -> addProperty ( $ str_name , self :: PROPERTY_FLOAT , $ bol_index ) ; }
Add a float|double field to the schema
16,220
public function addBoolean ( $ str_name , $ bol_index = TRUE ) { return $ this -> addProperty ( $ str_name , self :: PROPERTY_BOOLEAN , $ bol_index ) ; }
Add a boolean field to the schema
16,221
public function addGeopoint ( $ str_name , $ bol_index = TRUE ) { return $ this -> addProperty ( $ str_name , self :: PROPERTY_GEOPOINT , $ bol_index ) ; }
Add a geopoint field to the schema
16,222
public final function setEntityClass ( $ str_class ) { if ( class_exists ( $ str_class ) ) { if ( is_a ( $ str_class , '\\GDS\\Entity' , TRUE ) ) { $ this -> str_entity_class = $ str_class ; } else { throw new \ InvalidArgumentException ( 'Cannot set an Entity class that does not extend "GDS\Entity": ' . $ str_class ) ...
Set the class to use when instantiating new Entity objects
16,223
protected function httpClient ( ) { if ( null === $ this -> obj_http_client ) { $ this -> obj_http_client = $ this -> initHttpClient ( ) ; } return $ this -> obj_http_client ; }
Lazily initialise the HTTP Client when needed . Once .
16,224
protected function initHttpClient ( ) { $ obj_stack = HandlerStack :: create ( ) ; $ obj_stack -> push ( ApplicationDefaultCredentials :: getMiddleware ( [ 'https://www.googleapis.com/auth/datastore' ] ) ) ; $ str_base_url = self :: DEFAULT_BASE_URL ; if ( getenv ( "DATASTORE_EMULATOR_HOST" ) !== FALSE ) { $ str_base_u...
Configure HTTP Client
16,225
private function executePostRequest ( $ str_action , $ obj_request_body = null ) { $ arr_options = [ ] ; if ( null !== $ obj_request_body ) { $ arr_options [ 'json' ] = $ obj_request_body ; } $ obj_response = $ this -> httpClient ( ) -> post ( $ this -> actionUrl ( $ str_action ) , $ arr_options ) ; $ this -> obj_last_...
Execute a POST request against the API
16,226
public function deleteMulti ( array $ arr_entities ) { $ obj_request = $ this -> buildCommitRequest ( ) ; foreach ( $ arr_entities as $ obj_gds_entity ) { $ obj_rest_key = ( object ) [ 'path' => $ this -> createMapper ( ) -> buildKeyPath ( $ obj_gds_entity ) ] ; $ this -> applyPartition ( $ obj_rest_key ) ; $ obj_reque...
Delete 1 - many entities
16,227
private function applyPartition ( \ stdClass $ obj_request ) { $ obj_request -> partitionId = ( object ) [ 'projectId' => $ this -> str_dataset_id ] ; if ( null !== $ this -> str_namespace ) { $ obj_request -> partitionId -> namespaceId = $ this -> str_namespace ; } return $ obj_request ; }
Apply project and namespace to a query
16,228
private function applyTransaction ( \ stdClass $ obj_request ) { if ( null !== $ this -> str_next_transaction ) { $ obj_request -> readOptions = ( object ) [ "transaction" => $ this -> str_next_transaction ] ; $ this -> str_next_transaction = null ; } return $ obj_request ; }
If we are in a transaction apply it to the request object
16,229
private function buildQueryParamValue ( $ mix_value ) { $ obj_val = new \ stdClass ( ) ; $ str_type = gettype ( $ mix_value ) ; switch ( $ str_type ) { case 'boolean' : $ obj_val -> booleanValue = $ mix_value ; break ; case 'integer' : $ obj_val -> integerValue = $ mix_value ; break ; case 'double' : $ obj_val -> doubl...
Build a JSON representation of a value
16,230
public function getEndCursor ( ) { if ( isset ( $ this -> obj_last_response -> batch ) && isset ( $ this -> obj_last_response -> batch -> endCursor ) ) { return $ this -> obj_last_response -> batch -> endCursor ; } return null ; }
Get the end cursor from the last response
16,231
protected function getBaseUrl ( ) { $ str_base_url = $ this -> obj_http_client -> getConfig ( self :: CONFIG_CLIENT_BASE_URL ) ; if ( ! empty ( $ str_base_url ) ) { return $ str_base_url ; } return self :: DEFAULT_BASE_URL ; }
Get the base url from the client object .
16,232
private function applyTransaction ( $ obj ) { if ( null !== $ this -> str_next_transaction ) { $ obj -> setTransaction ( $ this -> str_next_transaction ) ; $ this -> str_next_transaction = null ; } return $ obj ; }
Apply a transaction to an object
16,233
private function setupRunQuery ( ) { $ obj_request = ( $ this -> applyNamespace ( new RunQueryRequest ( ) ) ) ; $ obj_request -> setSuggestedBatchSize ( self :: BATCH_SIZE ) ; $ this -> applyTransaction ( $ obj_request -> mutableReadOptions ( ) ) ; return $ obj_request ; }
Set up a RunQueryRequest
16,234
private function setupCommit ( ) { $ obj_commit_request = new CommitRequest ( ) ; if ( null === $ this -> str_next_transaction ) { $ obj_commit_request -> setMode ( Mode :: NON_TRANSACTIONAL ) ; } else { $ obj_commit_request -> setMode ( Mode :: TRANSACTIONAL ) ; $ this -> applyTransaction ( $ obj_commit_request ) ; } ...
Set up a commit request
16,235
private function execute ( $ str_method , ProtocolMessage $ obj_request , ProtocolMessage $ obj_response ) { try { ApiProxy :: makeSyncCall ( 'datastore_v4' , $ str_method , $ obj_request , $ obj_response , 60 ) ; $ this -> obj_last_response = $ obj_response ; } catch ( ApplicationError $ obj_exception ) { $ this -> ob...
Execute a method against the Datastore
16,236
public function deleteMulti ( array $ arr_entities ) { $ obj_mapper = $ this -> createMapper ( ) ; $ obj_request = $ this -> setupCommit ( ) ; $ obj_mutation = $ obj_request -> mutableDeprecatedMutation ( ) ; foreach ( $ arr_entities as $ obj_gds_entity ) { $ this -> applyNamespace ( $ obj_mapper -> configureGoogleKey ...
Delete 1 or many entities using their Keys
16,237
private function executeGqlAsBasicQuery ( ProtocolMessage $ obj_gql_request ) { $ obj_query_request = $ this -> setupRunQuery ( ) ; $ obj_query = $ obj_query_request -> mutableQuery ( ) ; if ( $ obj_gql_request -> mutableReadOptions ( ) -> hasTransaction ( ) ) { $ obj_query_request -> mutableReadOptions ( ) -> setTrans...
Take a GQL RunQuery request and convert to a standard RunQuery request
16,238
public function setSchema ( Schema $ obj_schema ) { $ this -> obj_schema = $ obj_schema ; $ this -> setKind ( $ obj_schema -> getKind ( ) ) ; return $ this ; }
Set the Schema for the Entity
16,239
public function parse ( $ str_gql , $ arr_named_params = [ ] ) { foreach ( $ arr_named_params as $ obj_param ) { if ( $ obj_param -> hasValue ( ) ) { $ this -> arr_named_params [ $ obj_param -> getName ( ) ] = $ obj_param -> getValue ( ) ; } else if ( $ obj_param -> hasCursor ( ) ) { $ this -> arr_named_params [ $ obj_...
Turn a GQL string and parameter array into a lookup query
16,240
private function tokenizeQuoted ( $ arr ) { $ str_token = self :: TOKEN_PREFIX . ++ $ this -> int_token_count ; $ this -> arr_tokens [ $ str_token ] = $ arr [ 'quoted' ] ; return $ str_token ; }
Record quoted strings return simple tokens
16,241
private function recordOffset ( $ arr ) { list ( $ this -> int_offset , $ this -> str_start_cursor ) = $ this -> getIntStringFromValue ( $ this -> lookupToken ( $ arr [ 'offset' ] ) ) ; return '' ; }
Record the offset
16,242
private function recordLimit ( $ arr ) { list ( $ this -> int_limit , $ this -> str_end_cursor ) = $ this -> getIntStringFromValue ( $ this -> lookupToken ( $ arr [ 'limit' ] ) ) ; return '' ; }
Record the limit
16,243
private function recordOrder ( $ arr ) { $ arr_order_bys = explode ( ',' , $ arr [ 'order' ] ) ; foreach ( $ arr_order_bys as $ str_order_by ) { $ arr_matches = [ ] ; preg_match ( '/\s?(?<field>[^\s]*)\s*(?<dir>ASC|DESC)?/i' , $ str_order_by , $ arr_matches ) ; if ( isset ( $ arr_matches [ 'field' ] ) ) { $ str_directi...
Process the ORDER BY clause
16,244
private function recordWhere ( $ arr ) { $ arr_conditions = explode ( 'AND' , $ arr [ 'where' ] ) ; $ str_regex = '/(?<lhs>[^\s<>=]*)\s*(?<comp>=|<|<=|>|>=|IN|CONTAINS|HAS ANCESTOR|HAS DESCENDANT)\s*(?<rhs>[^\s<>=]+)/i' ; foreach ( $ arr_conditions as $ str_condition ) { $ arr_matches = [ ] ; if ( preg_match ( $ str_re...
Process the WHERE clause
16,245
private function lookupToken ( $ str_val ) { if ( '__key__' === $ str_val ) { return $ str_val ; } if ( '_' === $ str_val [ 0 ] ) { if ( isset ( $ this -> arr_tokens [ $ str_val ] ) ) { return $ this -> arr_tokens [ $ str_val ] ; } } if ( '@' === $ str_val [ 0 ] ) { $ str_bind_name = substr ( $ str_val , 1 ) ; if ( iss...
Lookup the field in our token & named parameter list
16,246
public function fetchById ( $ int_key_id ) { $ arr_results = $ this -> fetchByIds ( [ $ int_key_id ] ) ; if ( count ( $ arr_results ) > 0 ) { return $ arr_results [ 0 ] ; } return null ; }
Fetch one entity by Key ID
16,247
public function fetchByName ( $ str_key_name ) { $ arr_results = $ this -> fetchByNames ( [ $ str_key_name ] ) ; if ( count ( $ arr_results ) > 0 ) { return $ arr_results [ 0 ] ; } return null ; }
Fetch entity data by Key Name
16,248
public function putMulti ( array $ arr_entities ) { $ this -> ensureSchema ( $ arr_entities ) ; $ this -> mapAutoIDs ( $ this -> upsert ( $ arr_entities ) ) ; $ this -> obj_schema = null ; $ this -> arr_kind_mappers = [ ] ; }
Put an array of Entities into the Datastore
16,249
protected function ensureSchema ( $ arr_entities ) { foreach ( $ arr_entities as $ obj_gds_entity ) { if ( $ obj_gds_entity instanceof Entity ) { if ( null === $ obj_gds_entity -> getKind ( ) ) { $ obj_gds_entity -> setSchema ( $ this -> obj_schema ) ; } } else { throw new \ InvalidArgumentException ( 'You gave me some...
Default Kind & Schema support for new Entities
16,250
protected function mapAutoIDs ( array $ arr_auto_id_requested ) { if ( ! empty ( $ arr_auto_id_requested ) ) { $ arr_auto_ids = $ this -> extractAutoIDs ( ) ; if ( count ( $ arr_auto_id_requested ) === count ( $ arr_auto_ids ) ) { foreach ( $ arr_auto_id_requested as $ int_idx => $ obj_gds_entity ) { $ obj_gds_entity -...
Record the Auto - generated Key IDs against the GDS Entities .
16,251
protected function configureValueParamForQuery ( $ obj_val , $ mix_value ) { $ str_type = gettype ( $ mix_value ) ; switch ( $ str_type ) { case 'boolean' : $ obj_val -> setBooleanValue ( $ mix_value ) ; break ; case 'integer' : $ obj_val -> setIntegerValue ( $ mix_value ) ; break ; case 'double' : $ obj_val -> setDoub...
Part of our add parameters to query sequence .
16,252
public function setConfig ( $ store_leases_disk ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> addCommand ( "/ip/dhcp-server/config/set" ) ; $ sentence -> setAttribute ( "store-leases-disk" , $ store_leases_disk ) ; $ this -> talker -> send ( $ sentence ) ; return "Sucsess" ; }
This methode is used to set ip dhcp server config
16,253
public function setAccounting ( $ account_local_traffic , $ enabled , $ threshold ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> addCommand ( "/ip/accounting/set" ) ; $ sentence -> setAttribute ( "account-local-traffic" , $ account_local_traffic ) ; $ sentence -> setAttribute ( "enabled" , $ enabled ) ; $ senten...
This method is used to set or edit ip accountng
16,254
public function set_identity ( $ name ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> addCommand ( "/system/identity/set" ) ; $ sentence -> setAttribute ( "name" , $ name ) ; $ this -> talker -> send ( $ sentence ) ; return "Sucsess" ; }
This method is used to set systemn identity
16,255
public function get_all_identity ( ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> fromCommand ( "/system/identity/getall" ) ; $ this -> talker -> send ( $ sentence ) ; $ rs = $ this -> talker -> getResult ( ) ; return $ rs -> getResultArray ( ) ; }
This method is used to display all system identiy
16,256
public function reset ( $ keep_users , $ no_defaults , $ skip_backup ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> addCommand ( "/ip/address/add" ) ; $ sentence -> setAttribute ( "keep-users" , $ keep_users ) ; $ sentence -> setAttribute ( "no-defaults" , $ no_defaults ) ; $ sentence -> setAttribute ( "skip-bac...
This method is used to system reset configuration
16,257
public function set ( $ use_radius , $ accounting , $ interim_update ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> addCommand ( "/ppp/aaa/set" ) ; $ sentence -> setAttribute ( "use-radius" , $ use_radius ) ; $ sentence -> setAttribute ( "accounting" , $ accounting ) ; $ sentence -> setAttribute ( "interim-updat...
This method is used to set ppp aaa
16,258
public function set_bridge_settings ( $ use_ip_firewall , $ use_ip_firewall_for_vlan , $ use_ip_firewall_for_pppoe ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> fromCommand ( "/interface/bridge/settings/set" ) ; $ sentence -> setAttribute ( "use-ip-firewall" , $ use_ip_firewall ) ; $ sentence -> setAttribute ( ...
This method used for set interface Bridge Settings
16,259
public function get_all_bridge_settings ( ) { $ sentence = new SentenceUtil ( ) ; $ sentence -> fromCommand ( "/interface/bridge/settings/getall" ) ; $ this -> talker -> send ( $ sentence ) ; $ rs = $ this -> talker -> getResult ( ) ; $ i = 0 ; if ( $ i < $ rs -> size ( ) ) { return $ rs -> getResultArray ( ) ; } else ...
This method used for get all interface Bridge Settings
16,260
public function checkUserCredentials ( $ username , $ password ) { try { $ user = $ this -> up -> loadUserByUsername ( $ username ) ; } catch ( \ Symfony \ Component \ Security \ Core \ Exception \ UsernameNotFoundException $ e ) { return false ; } if ( $ user instanceof AdvancedUserInterface ) { if ( $ user -> isAccou...
Grant access tokens for basic user credentials .
16,261
public function scopeExists ( $ scope , $ client_id = null ) { $ scopes = explode ( ' ' , $ scope ) ; if ( $ client_id ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } $ valid_scopes = $ client -> getScopes ( ) ; foreach ( $ scop...
Check if the provided scope exists .
16,262
public function getDescriptionForScope ( $ scope ) { $ scopeObject = $ this -> sm -> findScopeByScope ( $ scope ) ; if ( ! $ scopeObject ) { return $ scope ; } return $ scopeObject -> getDescription ( ) ; }
Gets the description of a given scope key if available otherwise the key is returned .
16,263
public function setPublicKey ( \ OAuth2 \ ServerBundle \ Entity \ ClientPublicKey $ public_key = null ) { $ this -> public_key = $ public_key ; return $ this ; }
Set public key
16,264
public function checkClientCredentials ( $ client_id , $ client_secret = null ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( $ client ) { return $ client -> getClientSecret ( ) === $ client_secret ; } return false ; }
Make sure that the client credentials is valid .
16,265
public function getClientDetails ( $ client_id ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } return array ( 'redirect_uri' => implode ( ' ' , $ client -> getRedirectUri ( ) ) , 'client_id' => $ client -> getClientId ( ) , 'gra...
Get client details corresponding client_id .
16,266
public function checkRestrictedGrantType ( $ client_id , $ grant_type ) { $ client = $ this -> getClientDetails ( $ client_id ) ; if ( ! $ client ) { return false ; } if ( empty ( $ client [ 'grant_types' ] ) ) { return true ; } if ( in_array ( $ grant_type , $ client [ 'grant_types' ] ) ) { return true ; } return fals...
Check restricted grant types of corresponding client identifier .
16,267
public function isPublicClient ( $ client_id ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } $ secret = $ client -> getClientSecret ( ) ; return empty ( $ secret ) ; }
Determine if the client is a public client and therefore does not require passing credentials for certain grant types
16,268
public function getClientScope ( $ client_id ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) { return false ; } return implode ( ' ' , $ client -> getScopes ( ) ) ; }
Get the scope associated with this client
16,269
public function createScope ( $ scope , $ description = null ) { if ( $ scopeObject = $ this -> findScopeByScope ( $ scope ) ) { return $ scopeObject ; } $ scopeObject = new \ OAuth2 \ ServerBundle \ Entity \ Scope ( ) ; $ scopeObject -> setScope ( $ scope ) ; $ scopeObject -> setDescription ( $ description ) ; $ this ...
Creates a new scope
16,270
public function findScopesByScopes ( array $ scopes ) { $ scopeObjects = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Scope' ) -> createQueryBuilder ( 'a' ) -> where ( 'a.scope in (?1)' ) -> setParameter ( 1 , $ scopes ) -> getQuery ( ) -> getResult ( ) ; return $ scopeObjects ; }
Find all the scopes by an array of scopes
16,271
public function createClient ( $ identifier , array $ redirect_uris = array ( ) , array $ grant_types = array ( ) , array $ scopes = array ( ) ) { $ client = new \ OAuth2 \ ServerBundle \ Entity \ Client ( ) ; $ client -> setClientId ( $ identifier ) ; $ client -> setClientSecret ( $ this -> generateSecret ( ) ) ; $ cl...
Creates a new client
16,272
public function setAuthorizationCode ( $ code , $ client_id , $ user_id , $ redirect_uri , $ expires , $ scope = null ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) throw new \ Exception ( 'Unknown client identifier' ) ; $ authorizationCode = new...
Take the provided authorization code values and store them somewhere .
16,273
public function expireAuthorizationCode ( $ code ) { $ code = $ this -> em -> getRepository ( 'OAuth2ServerBundle:AuthorizationCode' ) -> find ( $ code ) ; $ this -> em -> remove ( $ code ) ; $ this -> em -> flush ( ) ; }
once an Authorization Code is used it must be exipired
16,274
public function getRefreshToken ( $ refresh_token ) { $ refreshToken = $ this -> em -> getRepository ( 'OAuth2ServerBundle:RefreshToken' ) -> find ( $ refresh_token ) ; if ( ! $ refreshToken ) { return null ; } $ client = $ refreshToken -> getClient ( ) ; return array ( 'refresh_token' => $ refreshToken -> getToken ( )...
Grant refresh access tokens .
16,275
public function setRefreshToken ( $ refresh_token , $ client_id , $ user_id , $ expires , $ scope = null ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) { return null ; } $ refreshToken = new \ OAuth2 \ ServerBundle \ Entity \ RefreshToken ( ) ; $...
Take the provided refresh token values and store them somewhere .
16,276
public function unsetRefreshToken ( $ refresh_token ) { $ refreshToken = $ this -> em -> getRepository ( 'OAuth2ServerBundle:RefreshToken' ) -> find ( $ refresh_token ) ; $ this -> em -> remove ( $ refreshToken ) ; $ this -> em -> flush ( ) ; }
Expire a used refresh token .
16,277
public function verifyAction ( ) { $ server = $ this -> get ( 'oauth2.server' ) ; if ( ! $ server -> verifyResourceRequest ( $ this -> get ( 'oauth2.request' ) , $ this -> get ( 'oauth2.response' ) ) ) { return $ server -> getResponse ( ) ; } $ tokenData = $ server -> getAccessTokenData ( $ this -> get ( 'oauth2.reques...
This is called with an access token details about the access token are then returned . Used for verification purposes .
16,278
public function getAccessToken ( $ oauth_token ) { $ accessToken = $ this -> em -> getRepository ( 'OAuth2ServerBundle:AccessToken' ) -> find ( $ oauth_token ) ; if ( ! $ accessToken ) { return null ; } $ client = $ accessToken -> getClient ( ) ; return array ( 'client_id' => $ client -> getClientId ( ) , 'user_id' => ...
Look up the supplied oauth_token from storage .
16,279
public function setAccessToken ( $ oauth_token , $ client_id , $ user_id , $ expires , $ scope = null ) { $ client = $ this -> em -> getRepository ( 'OAuth2ServerBundle:Client' ) -> find ( $ client_id ) ; if ( ! $ client ) { return null ; } $ accessToken = new \ OAuth2 \ ServerBundle \ Entity \ AccessToken ( ) ; $ acce...
Store the supplied access token values to storage .
16,280
public function getRoute ( string $ routeKey , array $ params = [ ] ) : string { $ this -> checkRouteIsDefined ( $ routeKey ) ; return route ( $ this -> getAttribute ( 'routes' ) [ $ routeKey ] [ 'alias' ] , array_merge ( $ this -> getAttribute ( 'routes' ) [ $ routeKey ] [ 'parameters' ] , $ params ) ) ; }
Get the route from its key .
16,281
public function navigationStatus ( ) : string { return trans ( 'tablelist::tablelist.tfoot.nav' , [ 'start' => ( $ this -> getAttribute ( 'list' ) -> perPage ( ) * ( $ this -> getAttribute ( 'list' ) -> currentPage ( ) - 1 ) ) + 1 , 'stop' => $ this -> getAttribute ( 'list' ) -> count ( ) + ( ( $ this -> getAttribute (...
Get the navigation status from the table list .
16,282
public function render ( ) : string { $ this -> checkRoutesValidity ( $ this -> getAttribute ( 'routes' ) ) ; $ this -> checkIfAtLeastOneColumnIsDeclared ( ) ; $ this -> checkDestroyAttributesDefinition ( ) ; $ this -> handleRequest ( ) ; $ this -> generateEntitiesListFromQuery ( ) ; return view ( 'tablelist::table' , ...
Generate the table list html .
16,283
protected function handleRequest ( ) : void { $ validator = Validator :: make ( $ this -> getAttribute ( 'request' ) -> only ( 'rowsNumber' , 'search' , 'sortBy' , 'sortDir' ) , [ 'rowsNumber' => 'required|numeric' , 'search' => 'nullable|string' , 'sortBy' => 'nullable|string|in:' . $ this -> getAttribute ( 'columns' ...
Handle the request treatments .
16,284
protected function generateEntitiesListFromQuery ( ) : void { $ query = $ this -> getAttribute ( 'tableModel' ) -> query ( ) ; $ this -> applyQueryClosure ( $ query ) ; $ this -> checkColumnsValidity ( ) ; $ this -> applySearchClauses ( $ query ) ; $ this -> applySortClauses ( $ query ) ; $ this -> paginateList ( $ que...
Generate the entities list .
16,285
protected function applySearchClauses ( Builder $ query ) : void { if ( $ searched = $ this -> getAttribute ( 'request' ) -> search ) { $ this -> getAttribute ( 'searchableColumns' ) -> map ( function ( TableListColumn $ column , int $ key ) use ( & $ query , $ searched ) { $ table = $ column -> getAttribute ( 'customC...
Apply search clauses
16,286
protected function applySortClauses ( Builder $ query ) : void { $ sortBy = $ this -> getAttribute ( 'request' ) -> get ( 'sortBy' , $ this -> getAttribute ( 'sortBy' ) ) ; $ sortDir = $ this -> getAttribute ( 'request' ) -> get ( 'sortDir' , $ this -> getAttribute ( 'sortDir' ) ) ; if ( $ sortBy && $ sortDir ) { $ que...
Apply sort clauses .
16,287
protected function paginateList ( Builder $ query ) : void { $ this -> setAttribute ( 'list' , $ query -> paginate ( $ this -> getAttribute ( 'rowsNumber' ) ) ) ; $ this -> getAttribute ( 'list' ) -> appends ( [ 'rowsNumber' => $ this -> getAttribute ( 'rowsNumber' ) , 'search' => $ this -> getAttribute ( 'search' ) , ...
Paginate the list from the query .
16,288
protected function applyClosuresOnPaginatedList ( ) : void { $ disableLinesClosure = $ this -> getAttribute ( 'disableLinesClosure' ) ; $ highlightLinesClosure = $ this -> getAttribute ( 'highlightLinesClosure' ) ; $ this -> getAttribute ( 'list' ) -> getCollection ( ) -> transform ( function ( $ model ) use ( $ disabl...
Apply the closures on the paginated list .
16,289
public function isRouteDefined ( string $ routeKey ) : bool { return ( isset ( $ this -> getAttribute ( 'routes' ) [ $ routeKey ] ) || ! empty ( $ this -> getAttribute ( 'routes' ) [ $ routeKey ] ) ) ; }
Check if a route is defined from its key .
16,290
protected function checkRoutesValidity ( array $ routes ) : void { $ requiredRouteKeys = [ 'index' ] ; $ optionalRouteKeys = [ 'create' , 'edit' , 'destroy' ] ; $ allowedRouteKeys = array_merge ( $ requiredRouteKeys , $ optionalRouteKeys ) ; $ this -> checkRequiredRoutesValidity ( $ routes , $ requiredRouteKeys ) ; $ t...
Check routes validity .
16,291
protected function checkRequiredRoutesValidity ( array $ routes , array $ requiredRouteKeys ) : void { $ routeKeys = array_keys ( $ routes ) ; foreach ( $ requiredRouteKeys as $ requiredRouteKey ) { if ( ! in_array ( $ requiredRouteKey , $ routeKeys ) ) { throw new ErrorException ( 'The required « ' r equiredRouteKe...
Check required routes validity .
16,292
protected function checkRoutesStructureValidity ( array $ routes ) : void { $ requiredRouteParams = [ 'alias' , 'parameters' ] ; foreach ( $ routes as $ routeKey => $ route ) { foreach ( $ requiredRouteParams as $ requiredRouteParam ) { if ( ! in_array ( $ requiredRouteParam , array_keys ( $ route ) ) ) { throw new Err...
Check routes structure validity .
16,293
protected function checkColumnsValidity ( ) : void { $ this -> getAttribute ( 'columns' ) -> map ( function ( TableListColumn $ column ) { $ this -> checkSortableColumnHasAttribute ( $ column ) ; $ isSearchable = in_array ( $ column -> getAttribute ( 'attribute' ) , $ this -> getAttribute ( 'searchableColumns' ) -> plu...
Check the columns validity .
16,294
private function createResponse ( $ content , $ headers , \ stdClass $ curlMetaData ) { $ response = new Response ( ) ; $ response -> setContent ( $ content ) ; $ response -> headers -> add ( $ headers ) ; $ response -> setStatusCode ( $ curlMetaData -> http_code ) ; return $ response ; }
Maps the curl response to a Symfony response
16,295
private function getError ( ) { if ( ! curl_errno ( $ this -> curl ) ) return array ( ) ; return array ( 'error_no' => curl_errno ( $ this -> curl ) , 'error' => curl_error ( $ this -> curl ) ) ; }
Returns the errors
16,296
public static function parse ( $ headers ) { $ fields = explode ( "\r\n" , preg_replace ( '/\x0D\x0A[\x09\x20]+/' , ' ' , $ headers ) ) ; if ( empty ( $ fields ) ) return [ ] ; return array_reduce ( $ fields , function ( $ carry , $ field ) { $ match = [ ] ; if ( ! preg_match ( '/([^:]+): (.+)/m' , $ field , $ match ) ...
Parse Http Headers in array
16,297
private function validateOptions ( array $ options ) { foreach ( $ options as $ key => $ value ) { if ( ! is_int ( $ key ) ) return $ this -> invalidArgumentException ( 'Error while setting a curl option (http://php.net/manual/de/function.curl-setopt.php). Tried to set ' . $ key . ' on curl resource.' ) ; } return $ th...
validates the given options
16,298
private function curlException ( $ message , $ code ) { if ( ! array_key_exists ( $ code , $ this -> getExceptionCodeMappings ( ) ) ) throw new CurlExceptions \ CurlException ( "Error: {$message} and the Error no is: {$code} " , $ code ) ; $ exceptionClass = $ this -> exceptionsNamespace . '\\' . $ this -> getException...
throws a curl exception
16,299
public static function create ( $ curlResponse , $ headerSize ) { $ headers = substr ( $ curlResponse , 0 , $ headerSize ) ; return function_exists ( 'http_parse_headers' ) ? http_parse_headers ( $ headers ) : HTTPHeadersParser :: parse ( $ headers ) ; }
Creates Header array from a Response string