idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
12,200
protected function logToFile ( $ message ) { if ( isset ( $ this -> logger ) && $ this -> logger instanceof \ sb \ Logger \ Base ) { return $ this -> logger -> { $ this -> log_name } ( $ message ) ; } }
Logs to file
12,201
public function getCommandlineInvocation ( $ method_name , $ http_host = null , $ http_args = [ ] ) { $ command_prefix = "php " . ROOT . "/public/index.php" ; preg_match ( '/Controllers.([^:]+)::([A-Za-z_]+)/' , $ method_name , $ matches ) ; if ( count ( $ matches ) !== 3 ) { return '' ; } $ class_name = strtolower ( $...
Returns the name of a controller method in a format that can be used in a commandline invocation .
12,202
private function load_cache_settings ( ) { if ( $ this -> app -> isset_shared_object ( 'is_valid_hook_cache' ) ) { return ; } $ this -> app -> set_shared_object ( 'is_valid_hook_cache' , ! empty ( $ this -> app -> get_config ( 'config' , 'cache_filter_result' ) ) ) ; $ prevent_cache = $ this -> app -> get_config ( 'con...
load cache settings
12,203
public function getSourceInstance ( $ type , $ name , array $ parameters , array $ globalParameters = array ( ) ) { $ sourceObj = null ; $ sourceConfig = $ this -> getSourceConfig ( $ name , $ type , $ parameters , $ globalParameters ) ; if ( $ sourceConfig instanceof SourceConfig ) { switch ( $ type ) { case SourceCon...
Gets a Source instance according to the type .
12,204
public function buildOrder ( $ meta , $ tableAlias = null ) { $ metaFields = $ meta ? $ meta -> fields : null ; $ order = $ this -> order ; if ( $ meta && $ meta -> defaultOrder && $ order !== null ) { $ order = $ meta -> defaultOrder ; } if ( $ order ) { if ( is_array ( $ order ) ) { $ oClauses = '' ; foreach ( $ orde...
damn this is pretty much identical to the above . FIXME etc .
12,205
protected function queueHandler ( $ class , $ method , $ arguments ) { list ( $ listener , $ job ) = $ this -> createListenerAndJob ( $ class , $ method , $ arguments ) ; $ connection = $ this -> resolveQueue ( ) -> connection ( isset ( $ listener -> connection ) ? $ listener -> connection : null ) ; $ queue = isset ( ...
Queue the handler class .
12,206
protected function createListenerAndJob ( $ class , $ method , $ arguments ) { $ listener = ( new ReflectionClass ( $ class ) ) -> newInstanceWithoutConstructor ( ) ; return [ $ listener , $ this -> propogateListenerOptions ( $ listener , new CallQueuedListener ( $ class , $ method , $ arguments ) ) ] ; }
Create the listener and job for a queued listener .
12,207
protected function propogateListenerOptions ( $ listener , $ job ) { return tap ( $ job , function ( $ job ) use ( $ listener ) { $ job -> tries = isset ( $ listener -> tries ) ? $ listener -> tries : null ; $ job -> timeout = isset ( $ listener -> timeout ) ? $ listener -> timeout : null ; } ) ; }
Propogate listener options to the job .
12,208
public static function isAccessTokenValid ( $ token ) { if ( empty ( $ token ) ) { return false ; } $ data = Yii :: $ app -> jwt -> getValidationData ( ) ; $ data -> setIssuer ( Yii :: getAlias ( "@restIssuer" ) ) ; $ data -> setAudience ( Yii :: getAlias ( "@restAudience" ) ) ; $ data -> setId ( Yii :: getAlias ( "@re...
Validates access_token .
12,209
public function generateAccessToken ( ) { $ signer = new Sha256 ( ) ; $ token = Yii :: $ app -> jwt -> getBuilder ( ) -> setIssuer ( Yii :: getAlias ( "@restIssuer" ) ) -> setAudience ( Yii :: getAlias ( "@restAudience" ) ) -> setId ( Yii :: getAlias ( "@restId" ) + strtotime ( date ( 'Y-m-d' , time ( ) ) ) , true ) ->...
Generates new api access token .
12,210
public function getAst ( Node \ Node $ b , $ path = '' ) { $ ret = array ( 'type' => str_replace ( 'Zicht\Tool\Script\Node\\' , '' , get_class ( $ b ) ) ) ; if ( $ b instanceof Node \ Branch ) { if ( count ( $ b -> nodes ) ) { $ ret [ 'nodes' ] = array ( ) ; foreach ( $ b -> nodes as $ n ) { if ( null === $ n ) { $ ret...
Returns the AST for a specified node as an array representation
12,211
public function isDue ( ) { $ expression = $ this -> getExpression ( ) ; $ cron = CronExpression :: factory ( $ expression ) ; return $ cron -> isDue ( ) ; }
Check cron expression
12,212
public function getExpression ( ) { $ expression = array ( $ this -> minute , $ this -> hour , $ this -> dayOfMonth , $ this -> month , $ this -> dayOfWeek ) ; return implode ( ' ' , $ expression ) ; }
Return the cron expression
12,213
public function getArgument ( InputInterface $ input , $ key ) { if ( $ input -> hasArgument ( $ key ) ) { return $ input -> getArgument ( $ key ) ; } if ( isset ( $ this -> arguments [ $ key ] ) ) { return $ this -> arguments [ $ key ] ; } return false ; }
Get Cron arguments
12,214
public function execute ( $ cmd , & $ captureOutput = null ) { $ isInteractive = $ this -> container -> get ( 'INTERACTIVE' ) ; $ process = $ this -> createProcess ( $ isInteractive ) ; if ( $ isInteractive ) { $ process -> setCommandLine ( sprintf ( '/bin/bash -c \'%s\'' , $ cmd ) ) ; } else { $ process -> setInput ( ...
Executes the passed command line in the shell .
12,215
protected function createProcess ( $ interactive = false ) { $ process = new Process ( $ this -> container -> resolve ( 'SHELL' ) , null , null , null , null , [ ] ) ; if ( $ interactive ) { $ process -> setTty ( true ) ; } else { if ( $ this -> container -> has ( 'TIMEOUT' ) && $ timeout = $ this -> container -> get (...
Create the process instance to use for non - interactive handling
12,216
public function processCallback ( $ mode , $ data ) { if ( isset ( $ this -> container -> output ) ) { $ this -> container -> output -> write ( $ data ) ; } }
The callback used for the process executed by Process
12,217
protected function addCommands ( Application $ app ) { $ app -> command ( new Command \ Manual \ ToHtmlCommand ( null , $ app [ self :: TEMPLATE_FACTORY ] , $ app [ self :: CONVERTER_FACTORY ] ) ) ; }
Method responsible for adding the commands for this application .
12,218
public function get ( Container $ container ) { if ( $ this -> scope === null ) { $ this -> scope = $ this -> getDefaultScope ( ) ; } return $ this -> scope -> get ( $ this , $ container ) ; }
Resolves the value of this definition according to the current scope .
12,219
private function reconnect ( ) { if ( 0 === ( int ) $ this -> getOption ( self :: OPT_MAX_RECONNECT_ATTEMPTS ) ) { throw new MaxConnectAttempsException ( "Connection lost." ) ; } elseif ( $ this -> reconnectAttempts === ( int ) $ this -> getOption ( self :: OPT_MAX_RECONNECT_ATTEMPTS ) ) { throw new MaxConnectAttempsEx...
Tries to reconnect to database .
12,220
public function translation ( ) { if ( is_null ( $ this -> translationsClass ) ) $ this -> translationsClass = get_class ( $ this ) . 'Translations' ; return $ this -> hasOne ( $ this -> translationsClass , 'record_id' , 'id' ) -> where ( 'language_code' , app ( ) -> getLocale ( ) ) ; }
Single translation only
12,221
public static function translatedList ( string $ nameKey = "name" ) { return ( new static ( ) ) -> with ( 'translations' ) -> get ( ) -> map ( function ( $ item , $ key ) use ( $ nameKey ) { return [ 'id' => $ item -> id , 'label' => get_translation_name ( $ nameKey , app ( ) -> getLocale ( ) , array_get ( $ item , 'tr...
Get translated id - > value names
12,222
public function insert ( string $ from , array $ data , array $ options = [ ] ) { if ( ! $ data ) { throw new \ RuntimeException ( 'The data inserted into the database cannot be empty' ) ; } list ( $ statement , $ bindings ) = $ this -> compileInsert ( $ from , $ data ) ; if ( isset ( $ options [ 'dumpSql' ] ) ) { retu...
Run a statement for insert a row
12,223
public function ping ( ) { try { $ this -> connect ( ) ; $ this -> pdo -> query ( 'select 1' ) -> fetchColumn ( ) ; } catch ( \ PDOException $ e ) { if ( strpos ( $ e -> getMessage ( ) , 'server has gone away' ) !== false ) { return false ; } } return true ; }
Check whether the connection is available
12,224
public function isEnabled ( ) { if ( $ this -> enabled === null ) { $ environments = config ( 'songshenzong-log.env' , [ 'dev' , 'local' , 'production' ] ) ; $ this -> enabled = in_array ( env ( 'APP_ENV' ) , $ environments , true ) ; } return $ this -> enabled ; }
Check if is enabled
12,225
protected function getProcesses ( ) { $ data = $ this -> getCommand ( ) -> run ( ) ; $ parser = new TopProcessParser ( $ data ) ; $ parser -> parse ( ) ; return $ parser -> getProcesses ( ) ; }
Return parsed data for processes
12,226
protected function aggregateCpu ( $ processes ) { $ cpus = array ( ) ; foreach ( $ processes as $ process ) { if ( isset ( $ cpus [ $ process -> getName ( ) ] ) ) { $ cpus [ $ process -> getName ( ) ] += $ process -> getCpu ( ) ; } else { $ cpus [ $ process -> getName ( ) ] = $ process -> getCpu ( ) ; } } return $ cpus...
Aggregate CPU for processes with the same name
12,227
protected function aggregateMemory ( $ processes ) { $ memory = array ( ) ; foreach ( $ processes as $ process ) { if ( isset ( $ memory [ $ process -> getName ( ) ] ) ) { $ memory [ $ process -> getName ( ) ] += $ process -> getMemory ( ) ; } else { $ memory [ $ process -> getName ( ) ] = $ process -> getMemory ( ) ; ...
Aggregate memory for processes with the same name
12,228
protected function persistCollection ( $ collection ) { $ cache = new FilesystemAdapter ( $ this -> namespace ) ; $ item = $ cache -> getItem ( 'collection' ) ; $ item -> set ( $ collection ) ; $ cache -> save ( $ item ) ; }
Persist collection values to a temporary storage key is the command string value
12,229
protected function retrieveCollection ( ) { $ cache = new FilesystemAdapter ( $ this -> namespace ) ; $ item = $ cache -> getItem ( 'collection' ) ; $ collection = null ; if ( $ item -> isHit ( ) ) { $ collection = $ item -> get ( 'collection' ) ; } if ( empty ( $ collection ) || ! $ collection instanceof ValuesCollect...
\ Retrieve a new collection of a previous collection
12,230
protected function removeEmpty ( $ collection ) { foreach ( $ collection as $ key => $ value ) { if ( empty ( $ value ) ) { unset ( $ collection [ $ key ] ) ; } } return $ collection ; }
Remove empty values from collection
12,231
public function getTeams ( $ params = [ ] ) { $ defaults = [ 'limit' => 25 , 'offset' => 0 , ] ; return $ this -> wrapper -> request ( 'GET' , 'teams' , [ 'query' => $ this -> resolveOptions ( $ params , $ defaults ) ] ) ; }
Returns a list of active teams .
12,232
protected function build_input ( $ data , array $ fields = [ ] ) { return parent :: build_input ( $ data , $ fields ) . $ this -> length_helper ( $ data ) ; }
Return input field
12,233
protected function length_helper ( $ data ) { if ( ( $ this -> min || $ this -> max ) && $ this -> length_helper ) { $ notice = [ ] ; $ class_name = 'ok' ; if ( $ this -> min ) { $ notice [ ] = sprintf ( $ this -> __ ( '%s chars or more' ) , number_format ( $ this -> min ) ) ; if ( $ this -> min > mb_strlen ( $ data , ...
Returns length helper
12,234
public function get ( string $ key , $ default = null ) { $ result = $ this -> iterateConfig ( $ key ) ; return is_null ( $ result ) ? $ default : $ result ; }
Return given key from array .
12,235
public function has ( string $ key ) : bool { $ result = $ this -> iterateConfig ( $ key ) ; return ! ( $ result === null ) ; }
Return of givent key is present .
12,236
protected function iterateConfig ( string $ key ) { $ result = $ this -> config ; foreach ( explode ( '.' , $ key ) as $ p ) { if ( ! isset ( $ result [ $ p ] ) ) { return null ; } $ result = $ result [ $ p ] ; } return $ result ; }
Iterate through configuration .
12,237
public function addMeta ( array $ data ) : SuccessResponseBuilder { $ this -> meta = array_merge ( $ this -> meta , $ data ) ; return $ this ; }
Add data to the meta data appended to the response data .
12,238
public function transform ( $ data = null , $ transformer = null , string $ resourceKey = null ) : SuccessResponseBuilder { $ resource = $ this -> resourceFactory -> make ( $ data ) ; if ( ! is_null ( $ resource -> getData ( ) ) ) { $ model = $ this -> resolveModel ( $ resource -> getData ( ) ) ; $ transformer = $ this...
Set the transformation data . This will set a new resource instance on the response builder depending on what type of data is provided .
12,239
public function getResource ( ) : ResourceInterface { $ this -> manager -> parseIncludes ( $ this -> relations ) ; $ transformer = $ this -> resource -> getTransformer ( ) ; if ( $ transformer instanceof Transformer && $ transformer -> allRelationsAllowed ( ) ) { $ this -> resource -> setTransformer ( $ transformer -> ...
Get the Fractal resource instance .
12,240
protected function resolveSerializer ( $ serializer ) : SerializerAbstract { if ( is_string ( $ serializer ) ) { $ serializer = new $ serializer ; } if ( ! $ serializer instanceof SerializerAbstract ) { throw new InvalidSerializerException ( ) ; } return $ serializer ; }
Resolve a serializer instance from the value .
12,241
protected function resolveModel ( $ data ) : Model { if ( $ data instanceof Model ) { return $ data ; } $ model = array_values ( $ data ) [ 0 ] ; if ( ! $ model instanceof Model ) { throw new InvalidArgumentException ( 'You can only transform data containing Eloquent models.' ) ; } return $ model ; }
Resolve a model instance from the data .
12,242
protected function resolveTransformer ( Model $ model , $ transformer = null ) { $ transformer = $ transformer ? : $ this -> resolveTransformerFromModel ( $ model ) ; if ( is_string ( $ transformer ) ) { $ transformer = new $ transformer ; } return $ this -> parseTransformer ( $ transformer , $ model ) ; }
Resolve a transformer .
12,243
protected function resolveTransformerFromModel ( Model $ model ) { if ( ! $ model instanceof Transformable ) { return function ( $ model ) { return $ model -> toArray ( ) ; } ; } return $ model :: transformer ( ) ; }
Resolve a transformer from the model . If the model is not transformable a closure based transformer will be created instead from the model s fillable attributes .
12,244
protected function parseTransformer ( $ transformer , Model $ model ) { if ( $ transformer instanceof Transformer ) { $ relations = $ transformer -> allRelationsAllowed ( ) ? $ this -> resolveRelations ( $ model ) : $ transformer -> getRelations ( ) ; $ transformer = $ transformer -> setRelations ( $ relations ) ; } el...
Parse a transformer class and set relations .
12,245
protected function resolveNestedRelations ( $ data ) : array { if ( is_null ( $ data ) ) { return [ ] ; } $ data = $ data instanceof Model ? [ $ data ] : $ data ; return collect ( $ data ) -> flatMap ( function ( $ model ) { $ relations = collect ( $ model -> getRelations ( ) ) ; return $ relations -> keys ( ) -> merge...
Resolve eager loaded relations from the model including any nested relations .
12,246
protected function resolveResourceKey ( Model $ model , string $ resourceKey = null ) : string { if ( ! is_null ( $ resourceKey ) ) { return $ resourceKey ; } if ( method_exists ( $ model , 'getResourceKey' ) ) { return $ model -> getResourceKey ( ) ; } return $ model -> getTable ( ) ; }
Resolve the resource key from the model .
12,247
private static function add_view ( $ path , $ mode , mvc \ view $ view ) { if ( ! isset ( self :: $ loaded_views [ $ mode ] [ $ path ] ) ) { self :: $ loaded_views [ $ mode ] [ $ path ] = $ view ; } return self :: $ loaded_views [ $ mode ] [ $ path ] ; }
This function gets the content of a view file and adds it to the loaded_views array .
12,248
public function get_external_view ( string $ full_path , string $ mode = 'html' , array $ data = null ) { if ( ! router :: is_mode ( $ mode ) ) { die ( "Incorrect mode $full_path $mode" ) ; } if ( ( $ this -> get_mode ( ) === 'dom' ) && ( ! defined ( 'BBN_DEFAULT_MODE' ) || ( BBN_DEFAULT_MODE !== 'dom' ) ) ) { $ full_p...
This will get a view from a different root .
12,249
public function get_cached_model ( $ path , array $ data , mvc \ controller $ ctrl , $ ttl = 10 ) { if ( \ is_null ( $ data ) ) { $ data = $ this -> data ; } if ( $ route = $ this -> router -> route ( $ path , 'model' ) ) { $ model = new mvc \ model ( $ this -> db , $ route , $ ctrl , $ this ) ; return $ model -> get_f...
This will get the model as it is in cache if any and otherwise will save it in cache then return it
12,250
public function set_cached_model ( $ path , array $ data , mvc \ controller $ ctrl , $ ttl = 10 ) { if ( \ is_null ( $ data ) ) { $ data = $ this -> data ; } if ( $ route = $ this -> router -> route ( $ path , 'model' ) ) { $ model = new mvc \ model ( $ this -> db , $ route , $ ctrl , $ this ) ; return $ model -> set_c...
This will set the model in cache
12,251
public function delete_cached_model ( $ path , array $ data , mvc \ controller $ ctrl ) { if ( \ is_null ( $ data ) ) { $ data = $ this -> data ; } if ( $ route = $ this -> router -> route ( $ path , 'model' ) ) { $ model = new mvc \ model ( $ this -> db , $ route , $ ctrl , $ this ) ; return $ model -> delete_cache ( ...
This will unset the model in cache
12,252
public function add_inc ( $ name , $ obj ) { if ( ! isset ( $ this -> inc -> { $ name } ) ) { $ this -> inc -> { $ name } = $ obj ; } }
Adds a property to the MVC object inc if it has not been declared .
12,253
function csrf ( ) { return Cache :: instance ( ) -> exists ( ( $ this -> sid ? : session_id ( ) ) . '.@' , $ data ) ? $ data [ 'csrf' ] : FALSE ; }
Return anti - CSRF token
12,254
function parseRateLimit ( Response $ response ) { $ newRateLimit = \ GithubService \ RateLimit :: createFromResponse ( $ response ) ; if ( $ newRateLimit != null ) { $ this -> rateLimit = $ newRateLimit ; } }
Try to get some rate limiting info from the response and store it if it is available .
12,255
function createOrRetrieveAuth ( $ username , $ password , callable $ enterPasswordCallback , $ scopes , $ note , $ noteURL = "http://www.github.com/danack/GithubArtaxService" , $ maxAttempts = 3 ) { $ basicToken = new BasicAuthToken ( $ username , $ password ) ; $ otp = false ; for ( $ i = 0 ; $ i < $ maxAttempts ; $ i...
Creates an Oauth token for a named application .
12,256
public function getSource ( ) { $ field = $ this -> getForm ( ) -> Fields ( ) -> dataFieldByName ( $ this -> country_field ) ; if ( empty ( $ field ) || empty ( $ field -> Value ( ) ) ) { $ locale = strtoupper ( Locale :: getRegion ( i18n :: get_locale ( ) ) ) ; } else { $ locale = $ field -> Value ( ) ; } return $ thi...
Overwrite default get source to return custom list of regions
12,257
public function Field ( $ properties = [ ] ) { Requirements :: javascript ( "silvercommerce/geozones: client/dist/js/RegionSelectionField.min.js" ) ; $ country_field = $ this -> country_field ; $ field = $ this -> getForm ( ) -> Fields ( ) -> dataFieldByName ( $ country_field ) ; $ this -> setAttribute ( "data-region-f...
Render the final field
12,258
public function getList ( $ country ) { $ list = Region :: get ( ) -> filter ( "CountryCode" , strtoupper ( $ country ) ) ; if ( ! $ list -> exists ( ) && $ this -> getCreateEmptyDefault ( ) ) { $ countries = i18n :: getData ( ) -> getCountries ( ) ; if ( isset ( $ countries [ strtolower ( $ country ) ] ) ) { $ name = ...
Get a list of regions filtered by the provided country code
12,259
public function regionslist ( ) { $ id = $ this -> getRequest ( ) -> param ( "ID" ) ; $ data = $ this -> getList ( $ id ) -> map ( "Code" , "Name" ) -> toArray ( ) ; return json_encode ( $ data ) ; }
Return a list of regions based on the supplied country ID
12,260
protected function is_sub_class_of ( $ class_name , $ should , $ allow_abstract = false ) { if ( class_exists ( $ class_name ) ) { $ refl = new \ ReflectionClass ( $ class_name ) ; return ( $ allow_abstract || ! $ refl -> isAbstract ( ) ) && $ refl -> isSubclassOf ( $ should ) ; } return false ; }
Detect if specifies class is subclass
12,261
public static function clean ( $ request = null ) { switch ( $ request ) { case 'post' : unset ( $ _POST ) ; break ; case 'get' : unset ( $ _GET ) ; break ; case 'any' : unset ( $ _REQUEST ) ; break ; default : unset ( $ _POST ) ; unset ( $ _REQUEST ) ; unset ( $ _GET ) ; } }
limpa toda requisicao passada
12,262
public function getInvoices ( Get \ RequestData $ requestData ) { $ request = new Get \ Request ( $ requestData ) ; $ apiResponse = $ this -> sendRequest ( $ request , Get \ ApiResponse :: class ) ; $ response = $ apiResponse -> getResponse ( ) ; foreach ( $ response -> getInvoices ( ) as $ invoice ) { $ invoiceDate = ...
Get the invoices .
12,263
public function create ( ServerRequestInterface $ request ) : CallbackInterface { $ callbacks = [ XmlCallback :: class , FormCallback :: class , RedirectCallback :: class ] ; foreach ( $ callbacks as $ callback ) { if ( call_user_func ( [ $ callback , 'initable' ] , $ request ) ) { return new $ callback ( $ request ) ;...
Will take a Psr Server Request and return a Form Xml or Redirect callback object that represent the actual callback
12,264
public function generate ( array $ config ) { $ defaultHTTPCodes = $ this -> getDefaultHTTPCodes ( $ config ) ; $ defaultOptions = $ this -> getDefaultOptions ( $ config ) ; return $ this -> createUrlChainFromConfig ( $ config , $ defaultHTTPCodes , $ defaultOptions ) ; }
Given a configuration array generates a chain of urls
12,265
protected function getDefaultHTTPCodes ( $ config ) { $ defaultHttpCodes = ( isset ( $ config [ 'defaults' ] ) && is_array ( $ config [ 'defaults' ] ) && isset ( $ config [ 'defaults' ] [ 'http_codes' ] ) && ! empty ( $ config [ 'defaults' ] [ 'http_codes' ] ) ) ? $ config [ 'defaults' ] [ 'http_codes' ] : [ 200 ] ; if...
Get default http Codes
12,266
protected function getDefaultOptions ( $ config ) { $ defaultOptions = ( isset ( $ config [ 'defaults' ] ) && is_array ( $ config [ 'defaults' ] ) && isset ( $ config [ 'defaults' ] [ 'options' ] ) && is_array ( $ config [ 'defaults' ] [ 'options' ] ) ) ? $ config [ 'defaults' ] [ 'options' ] : [ ] ; return $ defaultOp...
Get default options
12,267
protected function createUrlChainFromConfig ( array $ config , array $ defaultHTTPCodes , array $ defaultOptions ) { $ urlChain = $ this -> urlChainFactory -> create ( ) ; if ( ! isset ( $ config [ 'urls' ] ) || ! is_array ( $ config [ 'urls' ] ) ) { return $ urlChain ; } $ profiles = ( isset ( $ config [ 'profiles' ] ...
Given a config array create an URLChain instance filled with all defined URL instances .
12,268
protected function getUrlInstanceFromConfig ( $ urlConfig , array $ defaultHTTPCodes , array $ defaultOptions , array $ profiles ) { $ url = $ this -> getUrlPathFromConfig ( $ urlConfig ) ; $ urlHTTPCodes = $ this -> getUrlHTTPCodesFromConfig ( $ urlConfig , $ defaultHTTPCodes ) ; $ urlOptions = $ this -> getUrlOptions...
Get Url instance given its configuration
12,269
protected function getUrlHTTPCodesFromConfig ( $ urlConfig , array $ defaultHTTPCodes ) { $ HTTPCodes = ( is_array ( $ urlConfig ) && isset ( $ urlConfig [ 1 ] ) && ! empty ( $ urlConfig [ 1 ] ) ) ? $ urlConfig [ 1 ] : $ defaultHTTPCodes ; return is_array ( $ HTTPCodes ) ? $ HTTPCodes : [ $ HTTPCodes ] ; }
Get url HTTP Codes given its configuration
12,270
protected function getUrlOptionsFromConfig ( $ urlConfig , array $ defaultOptions ) { $ urlOptions = ( is_array ( $ urlConfig ) && isset ( $ urlConfig [ 2 ] ) && is_array ( $ urlConfig [ 2 ] ) ) ? $ urlConfig [ 2 ] : [ ] ; return array_merge ( $ defaultOptions , $ urlOptions ) ; }
Get url options
12,271
public function count ( $ entityType , $ filter = '' ) { $ params = array ( 'type_name' => $ entityType ) ; if ( ! empty ( $ filter ) ) { $ params [ 'filter' ] = $ filter ; } return $ this -> post ( 'entity.count' , $ params ) ; }
Count the number of records in an entityType .
12,272
public function delete ( $ uuid , array $ params = array ( ) ) { $ params [ 'uuid' ] = $ uuid ; if ( ! isset ( $ params [ 'type_name' ] ) ) { throw new MissingArgumentException ( 'type_name' ) ; } return $ this -> _del ( $ params ) ; }
Default by UUID .
12,273
public function replaceByAttribute ( $ attributeKey , $ attributeValue , array $ params ) { $ params [ 'key_attribute' ] = $ attributeKey ; $ params [ 'key_value' ] = $ this -> wrapAttributeValueWithQuotes ( $ attributeValue ) ; return $ this -> _replace ( $ params ) ; }
Replace part of an entity by attribute .
12,274
public function updateByAttribute ( $ attributeKey , $ attributeValue , array $ params ) { $ params [ 'key_attribute' ] = $ attributeKey ; $ params [ 'key_value' ] = $ this -> wrapAttributeValueWithQuotes ( $ attributeValue ) ; return $ this -> _update ( $ params ) ; }
Update entity by attribute
12,275
public function send ( $ printaitorViewObj ) { $ dv = $ printaitorViewObj -> dataToView ; $ factura [ 'AfipFactura' ] = array ( 'json_data' => $ printaitorViewObj -> viewTextRender , 'mesa_id' => Hash :: get ( $ dv , 'Mesa.id' ) , 'importe_total' => Hash :: get ( $ dv , 'Mesa.total' ) , 'importe_neto' => Hash :: get ( ...
Crea un archivo y lo guarda en la tabla afip_facturas
12,276
private function show_plugin_update_notices ( ) { add_action ( 'in_plugin_update_message-' . $ this -> app -> define -> plugin_base_name , function ( $ data , $ r ) { $ new_version = $ r -> new_version ; $ url = $ this -> app -> utility -> array_get ( $ data , 'PluginURI' ) ; $ notices = $ this -> get_upgrade_notices (...
show plugin upgrade notices
12,277
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ config = $ serviceLocator -> get ( 'Configuration' ) ; if ( ! isset ( $ config [ 'ocr' ] ) ) { throw new Exception \ RuntimeException ( 'No "ocr" section available in configuration.' ) ; } if ( ! isset ( $ config [ 'ocr' ] [ 'service' ] ) ) ...
Create OCR service
12,278
public function hasEndpoint ( $ uri ) { $ urlsFound = $ this -> getEndpoints ( ) -> filter ( function ( Endpoint $ endpoint ) use ( $ uri ) { return ( string ) $ endpoint -> getUri ( ) === $ uri ; } ) ; return $ urlsFound -> isEmpty ( ) === false ; }
Checks if the given uri is already added to collection .
12,279
public function addEndpoint ( Endpoint $ newEndpoint ) { if ( $ this -> hasEndpoint ( ( string ) $ newEndpoint -> getUri ( ) ) ) { throw new InputException ( 'Endpoint already added' ) ; } $ status = $ this -> getEndpoints ( ) -> isEmpty ( ) ? Endpoint :: STATUS_ACTIVE : Endpoint :: STATUS_DISABLED ; $ newEndpoint -> s...
Add Endpoint into the pool .
12,280
public function activateEndpoint ( Endpoint $ newActive , $ force = false ) { if ( ! $ this -> getEndpoints ( ) -> contains ( $ newActive ) ) { throw new InputException ( 'Endpoint is not part of this manager' ) ; } if ( $ force === false && $ this -> canBeActivated ( $ newActive ) === false ) { throw new InputExceptio...
Try to activate an Endpoint as the active endpoint . If endpoint status is Error first check if it can be safely enabled .
12,281
private function canBeActivated ( Endpoint $ newActive ) { if ( $ newActive -> isError ( ) === true ) { $ offlineInterval = new \ DateTime ( ) ; $ offlineInterval -> modify ( '-60 minutes' ) ; return $ newActive -> getLastConnected ( ) !== null && $ newActive -> getLastConnected ( ) <= $ offlineInterval ; } return true...
Determine if this endpoint can re - enabled .
12,282
private function disableAll ( ) { $ this -> getEndpoints ( ) -> map ( function ( Endpoint $ endpoint ) { if ( $ endpoint -> isError ( ) === false ) { $ endpoint -> setStatus ( Endpoint :: STATUS_DISABLED ) ; } } ) ; }
Disable all endpoints except the ones in error .
12,283
public function getActiveEndpoint ( ) { $ active = $ this -> getEndpoints ( ) -> filter ( function ( Endpoint $ endpoint ) { return $ endpoint -> isActive ( ) ; } ) ; if ( $ active -> isEmpty ( ) === true ) { $ active = $ this -> getEndpoints ( ) -> filter ( function ( Endpoint $ endpoint ) { return $ this -> canBeActi...
Returns a active endpoint . Tries to find the current active endpoint or enable one .
12,284
public function connect ( ) { if ( ! preg_match ( '/([0-9]{1,3}\\.){3,3}[0-9]{1,3}/' , $ this -> host ) ) { $ ip = gethostbyname ( $ this -> host ) ; if ( $ this -> host == $ ip ) { throw new \ Exception ( "Cannot resolve $this->host" ) ; } else { $ this -> host = $ ip ; } } $ this -> socket = fsockopen ( $ this -> hos...
Attempts connection to remote host . Returns TRUE if sucessful .
12,285
public function disconnect ( ) { if ( $ this -> socket ) { if ( ! fclose ( $ this -> socket ) ) { throw new \ Exception ( "Error while closing telnet socket" ) ; } $ this -> socket = NULL ; } return true ; }
Closes IP socket
12,286
public function readTo ( $ prompt ) { if ( ! $ this -> socket ) { throw new \ Exception ( "Telnet connection closed" ) ; } $ this -> clearBuffer ( ) ; $ until_t = time ( ) + $ this -> timeout ; do { if ( time ( ) > $ until_t ) { throw new \ Exception ( "Couldn't find the requested : '$prompt' within {$this->timeout} se...
Reads characters from the socket and adds them to command buffer . Handles telnet control characters . Stops when prompt is ecountered .
12,287
public function write ( $ buffer , $ addNewLine = true ) { if ( ! $ this -> socket ) { throw new \ Exception ( "Telnet connection closed" ) ; } $ this -> clearBuffer ( ) ; if ( $ addNewLine == true ) { $ buffer .= "\n" ; } $ this -> global_buffer .= $ buffer ; if ( $ this -> debug_mode === 2 || $ this -> debug_mode ===...
Write command to a socket
12,288
public function getBuffer ( ) { $ buf = explode ( "\n" , $ this -> buffer ) ; unset ( $ buf [ count ( $ buf ) - 1 ] ) ; $ buf = implode ( "\n" , $ buf ) ; return trim ( $ buf ) ; }
Returns the content of the command buffer
12,289
public function negotiateTelnetOptions ( ) { $ c = $ this -> getc ( ) ; if ( $ c != $ this -> IAC ) { if ( ( $ c == $ this -> DO ) || ( $ c == $ this -> DONT ) ) { $ opt = $ this -> getc ( ) ; fwrite ( $ this -> socket , $ this -> IAC . $ this -> WONT . $ opt ) ; } else if ( ( $ c == $ this -> WILL ) || ( $ c == $ this...
Telnet control character magic
12,290
public function changeUsername ( ) { if ( $ this -> validate ( ) ) { $ username = $ this -> user -> createUsername ( $ this -> username ) ; if ( ! $ username ) { return false ; } return $ username -> save ( ) ; } return false ; }
Change username .
12,291
private function buildUrl ( $ endpoint , array $ additional_parameters = [ ] ) { $ base = ( $ this -> use_stage ? 'stg.' : '' ) . $ this -> domain ; $ parameters = [ 'passKey=' . $ this -> apiKey , 'ApiVersion=' . self :: $ api_version , ] ; if ( ! empty ( $ additional_parameters ) ) { foreach ( $ additional_parameters...
Create Bazaarvoice URL with added parameters .
12,292
private function splitConfiguration ( array $ options ) { $ return_array = [ 'method' => 'GET' , 'arguments' => [ ] , 'options' => [ ] , ] ; if ( isset ( $ options [ 'method' ] ) ) { $ return_array [ 'method' ] = $ options [ 'method' ] ; } if ( isset ( $ options [ 'arguments' ] ) ) { $ return_array [ 'arguments' ] = $ ...
Splits API request options array into main buckets .
12,293
private function buildResponse ( $ response_type , $ method , $ status_code , $ request_url , array $ configuration = [ ] , array $ response_data = [ ] ) { $ object = FALSE ; if ( is_string ( $ response_type ) ) { if ( class_exists ( $ response_type ) ) { if ( is_subclass_of ( $ response_type , 'BazaarvoiceRequest\\Res...
Returns a BazaarvoiceRequest \ Response object .
12,294
protected function getDestinationPath ( Transformation $ transformation ) { $ artifact = $ transformation -> getTransformer ( ) -> getTarget ( ) . DIRECTORY_SEPARATOR . $ transformation -> getArtifact ( ) ; return $ artifact ; }
Retrieves the destination location for this artifact .
12,295
public function getQueryParams ( array $ list = null ) { return isset ( $ list ) ? $ this -> listQueryParams ( $ list ) : ( array ) $ this -> getRequest ( ) -> getQueryParams ( ) ; }
Get the request query parameters .
12,296
protected function listQueryParams ( array $ list ) { $ result = [ ] ; $ params = $ this -> getRequest ( ) -> getQueryParams ( ) ; foreach ( $ list as $ key => $ value ) { if ( is_int ( $ key ) ) { $ key = $ value ; $ value = null ; } $ result [ ] = isset ( $ params [ $ key ] ) ? $ params [ $ key ] : $ value ; } return...
Apply list to query params
12,297
public function getQueryParam ( $ param , $ default = null , $ filter = null , $ filterOptions = null ) { $ params = $ this -> getQueryParams ( ) ; $ value = isset ( $ params [ $ param ] ) ? $ params [ $ param ] : $ default ; if ( isset ( $ filter ) && isset ( $ value ) ) { $ value = filter_var ( $ value , $ filter , $...
Get a query parameter .
12,298
public function getInput ( ) { $ data = $ this -> getRequest ( ) -> getParsedBody ( ) ; if ( is_array ( $ data ) ) { $ files = $ this -> getRequest ( ) -> getUploadedFiles ( ) ; $ data = array_replace_recursive ( $ data , ( array ) $ files ) ; } return $ data ; }
Get parsed body and uploaded files as input
12,299
public static function isSupported ( string $ driver ) : bool { if ( $ driver === self :: DRIVER_MONGO_DB ) { return \ extension_loaded ( 'mongodb' ) ; } if ( $ driver === self :: DRIVER_MONGO ) { return \ extension_loaded ( 'mongo' ) ; } return false ; }
Is this driver supported .