idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
55,500
protected function createApiClientException ( $ statusCode , $ message , $ requestContents , $ responseContents ) : ApiClientException { return ExceptionFactory :: create ( $ statusCode , $ message , $ requestContents , $ responseContents ) ; }
Creates an API exception to throw .
55,501
protected function processApiClientException ( ApiClientException $ exception , RequestInterface $ request ) : ResponseInterface { if ( ! $ exception instanceof UnauthorizedException ) { throw $ exception ; } $ this -> clearAuthorizationToken ( ) ; $ promise = $ this -> createPromiseForRequest ( $ request , false ) ; r...
Processes an API client exception checking if authorization has to be renewed .
55,502
protected function castPropertiesMeta ( array $ meta ) : array { $ properties = [ ] ; foreach ( $ meta [ '@properties' ] ?? [ ] as $ name => $ data ) { $ properties [ $ name ] = new MetaProperty ( $ data ) ; } return $ properties ; }
Cast properties meta to MetaProperty class
55,503
public function getAllByPostType ( $ type , array $ queryVars = array ( ) ) { $ q = new WP_Query ( array_merge ( array ( 'post_type' => $ type , 'nopaging' => true ) , $ queryVars ) ) ; $ posts = array ( ) ; foreach ( $ q -> get_posts ( ) as $ p ) { $ posts [ ] = $ this -> postFactory -> create ( $ p ) ; } return $ pos...
Get all posts of the given type .
55,504
public function getYears ( ) { $ years = array ( ) ; foreach ( $ this -> getAllByPostType ( 'post' ) as $ post ) { $ year = ( int ) $ post -> getPublishedDate ( ) -> format ( 'Y' ) ; if ( ! in_array ( $ year , $ years ) ) { $ years [ ] = $ year ; } } rsort ( $ years ) ; return $ years ; }
Get array of post years in descending order .
55,505
private function setName ( $ name ) { $ this -> checkName ( $ name ) ; $ this -> name = $ name ; $ this -> singleValued = in_array ( $ name , $ this -> singles ) ; return $ this ; }
Set attribute name
55,506
private function setValues ( $ values ) { $ values = $ this -> checkContent ( $ values ) ; if ( $ this -> isSingleValued ( ) ) { return $ this -> addValue ( $ values [ 0 ] , true ) ; } return $ this -> addManyValues ( $ values ) ; }
Set attribute content
55,507
private function addValue ( $ value , $ erase = false ) { if ( $ erase ) { $ this -> values = [ ] ; } if ( ! in_array ( $ value , $ this -> values ) ) { $ this -> values [ ] = $ value ; } return $ this ; }
Add value to values property
55,508
public function forgetValue ( $ value ) { $ key = array_search ( $ value , $ this -> values ) ; if ( $ key !== false ) { unset ( $ this -> values [ $ key ] ) ; } return $ this ; }
Remove a value from attribute
55,509
private function checkName ( & $ name ) { if ( ! is_string ( $ name ) ) { throw new InvalidTypeException ( 'The name must be a string value, ' . gettype ( $ name ) . ' is given.' ) ; } $ name = strtolower ( trim ( $ name ) ) ; if ( empty ( $ name ) ) { throw new Exception ( 'The attribute name must not be empty.' ) ; }...
Check attribute name
55,510
private function checkContent ( $ content ) { if ( ! is_array ( $ content ) and ! is_string ( $ content ) ) { throw new InvalidTypeException ( 'The content must be an array or string value, ' . gettype ( $ content ) . ' is given.' ) ; } $ this -> checkSingleValuedContent ( $ content ) ; return is_array ( $ content ) ? ...
Check attribute content
55,511
private function checkSingleValuedContent ( & $ content ) { if ( is_string ( $ content ) and ! $ this -> isSingleValued ( ) ) { $ content = array_map ( 'trim' , explode ( ' ' , $ content ) ) ; } }
Check if content is single valued
55,512
public function token ( ) { if ( ! $ this -> session -> has ( 'token' ) ) { $ this -> session -> create ( 'token' , Str :: random ( 40 ) ) ; } return $ this -> session -> get ( 'token' ) ; }
To generate token
55,513
public function check ( ) { if ( $ this -> session -> get ( 'token' ) === $ this -> request -> input ( 'token' ) || $ this -> session -> get ( 'token' ) === $ this -> request -> header ( 'X-CSRF-TOKEN' ) ) { return true ; } return false ; }
To check token
55,514
private function processServerVariables ( array $ server ) { foreach ( $ server as $ key => $ value ) { $ this -> server [ $ key ] = $ value ; if ( strpos ( $ key , 'HTTP_' ) === 0 ) { $ key = str_replace ( '_' , '-' , substr ( $ key , 5 ) ) ; $ this -> headers [ $ key ] = $ value ; } } $ uri = $ server [ 'REQUEST_URI'...
Processes the server variables
55,515
public function server ( string $ key ) : string { if ( array_key_exists ( $ key , $ this -> server ) ) { return $ this -> server [ $ key ] ; } return '' ; }
Gets a server variable
55,516
public function header ( string $ key ) : string { if ( array_key_exists ( $ key , $ this -> headers ) ) { return $ this -> headers [ $ key ] ; } return '' ; }
Gets a header
55,517
public function get ( string $ key ) { if ( array_key_exists ( $ key , $ this -> get ) ) { return $ this -> get [ $ key ] ; } return '' ; }
Gets a get variable
55,518
public function post ( string $ key ) { if ( array_key_exists ( $ key , $ this -> post ) ) { return $ this -> post [ $ key ] ; } return '' ; }
Gets a post variable
55,519
public function files ( string $ key ) : array { if ( array_key_exists ( $ key , $ this -> files ) ) { return $ this -> files [ $ key ] ; } return [ ] ; }
Gets an item from the files
55,520
public function getBaseUrl ( ) : string { $ schemeAndHttpHost = 'http' ; if ( $ this -> isEncrypted ( ) ) { $ schemeAndHttpHost .= 's' ; } $ schemeAndHttpHost .= '://' . $ this -> server ( 'SERVER_NAME' ) ; if ( ( ! $ this -> isEncrypted ( ) && $ this -> server ( 'SERVER_PORT' ) !== '80' ) || ( $ this -> isEncrypted ( ...
Gets the base URL of the request
55,521
public function getFlaggedNice ( ) { $ obj = HTMLText :: create ( ) ; $ obj -> setValue ( ( $ this -> Flag ) ? '<span class="red">&#10033;</span>' : '' ) ; $ this -> extend ( "updateFlaggedNice" , $ obj ) ; return $ obj ; }
Has this note been flagged? If so return a HTML Object that can be loaded into a gridfield .
55,522
public function formatException ( \ Exception $ ex ) { return sprintf ( $ this -> errorMessageFormat , $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex -> getFile ( ) , $ ex -> getLine ( ) , get_class ( $ ex ) ) ; }
Pass the given exception into the error message format string .
55,523
public function registerAssetFiles ( $ view ) { $ language = Yii :: $ app -> language ; if ( file_exists ( $ this -> sourcePath . "/$language.js" ) !== false ) { $ this -> js = [ "$language.js" ] ; } parent :: registerAssetFiles ( $ view ) ; }
This function extends default AssetBundle behavior - this will dynamically add needed file with js translation based on current requested language .
55,524
protected function setStream ( $ type , StreamInterface $ stream ) { $ this -> streams [ $ type ] = $ stream ; $ callback = array ( $ this , 'on' . ucfirst ( $ type ) . 'Message' ) ; $ stream -> addListener ( StreamInterface :: MESSAGE , $ this -> createEventListenerForStream ( $ callback ) ) ; return $ this ; }
Add the given stream and register it to the EventDispatcher .
55,525
private function createEventListenerForStream ( $ callback ) { $ logger = $ this -> getLogger ( ) ; $ function = function ( MessageEvent $ event ) use ( $ callback , $ logger ) { $ protocol = $ event -> getProtocolMessage ( ) ; if ( $ protocol === null ) { $ logger -> debug ( 'Incompatable message: ' . $ event -> getMe...
Creates an event listener for a stream .
55,526
public function onClientMessage ( MessageInterface $ msg , $ routing ) { $ client = $ this -> client ( array_shift ( $ routing ) ) ; if ( $ msg instanceof ExecuteRequest ) { $ this -> clientRequest ( $ client , $ msg ) ; return ; } if ( $ msg instanceof FetchRequest ) { $ this -> clientFetch ( $ client , $ msg ) ; retu...
Handle a message from a Client .
55,527
public function onWorkerHandlerMessage ( ClientHandlerJobResponse $ msg ) { $ this -> workerHandlerReady = true ; $ requestId = $ msg -> getRequestId ( ) ; if ( isset ( $ this -> workerHandlerQueue [ $ requestId ] ) ) { unset ( $ this -> workerHandlerQueue [ $ requestId ] ) ; } $ workerHandler = $ msg -> getWorkerHandl...
Handle the result of a Job that a WorkerHandler processed .
55,528
public function onWorkerHandlerStatusMessage ( WorkerHandlerStatus $ msg ) { $ handlerId = $ msg -> getWorkerHandlerId ( ) ; if ( isset ( $ this -> workerHandlers [ $ handlerId ] ) ) { unset ( $ this -> workerHandlers [ $ handlerId ] ) ; } $ this -> workerHandlers [ $ handlerId ] = microtime ( true ) ; $ requestId = $ ...
Handle a status message from the WorkerHandler .
55,529
public function handleWorkerHandlerQueue ( ) { if ( ! $ this -> workerHandlerReady || count ( $ this -> workerHandlerQueue ) == 0 ) { return ; } $ requestId = array_shift ( $ this -> workerHandlerQueue ) ; $ request = $ this -> getRequest ( $ requestId ) ; if ( $ request === null ) { return ; } $ this -> getLogger ( ) ...
Processes all new messages in the WorkerHandler queue .
55,530
public function hasExpiredWorkerHandler ( ) { $ hasExpired = false ; $ timeout = AlphaRPC :: WORKER_HANDLER_TIMEOUT ; $ validTime = microtime ( true ) - ( $ timeout / 1000 ) ; foreach ( $ this -> workerHandlers as $ handlerId => $ time ) { if ( $ time >= $ validTime ) { break ; } unset ( $ this -> workerHandlers [ $ ha...
Checks and removes all expired WorkerHandlers .
55,531
public function clientRequest ( Client $ client , ExecuteRequest $ msg ) { $ requestId = $ msg -> getRequestId ( ) ; if ( ! $ requestId ) { do { $ requestId = sha1 ( uniqid ( ) ) ; } while ( isset ( $ this -> request [ $ requestId ] ) ) ; } if ( $ this -> storage -> has ( $ requestId ) ) { $ this -> getLogger ( ) -> in...
Handle a request form a Client .
55,532
protected function clientFetch ( Client $ client , FetchRequest $ msg ) { $ requestId = $ msg -> getRequestId ( ) ; $ waitForResult = $ msg -> getWaitForResult ( ) ; $ client -> setRequest ( $ requestId , $ waitForResult ) ; $ this -> getLogger ( ) -> debug ( sprintf ( 'Client %s is requesting the result of request %s....
Handle a Fetch Request from a Client .
55,533
public function handle ( ) { $ this -> getStream ( 'client' ) -> handle ( new TimeoutTimer ( $ this -> delay / 4 ) ) ; $ this -> getStream ( 'workerHandler' ) -> handle ( new TimeoutTimer ( $ this -> delay / 4 ) ) ; $ this -> handleWorkerHandlerQueue ( ) ; $ this -> getStream ( 'workerHandlerStatus' ) -> handle ( new T...
Contains the main loop of the Client Handler .
55,534
public function handleExpired ( ) { $ expired = $ this -> clients -> getExpired ( AlphaRPC :: CLIENT_PING ) ; foreach ( $ expired as $ client ) { $ this -> reply ( $ client , new TimeoutResponse ( ) ) ; } }
Send a reply to expired clients .
55,535
public function handleExpiredWorkerHandlers ( ) { if ( ! $ this -> hasExpiredWorkerHandler ( ) ) { return ; } foreach ( $ this -> request as $ request ) { $ worker_handler_id = $ request -> getWorkerHandlerId ( ) ; if ( $ this -> hasWorkerHandler ( $ worker_handler_id ) ) { continue ; } $ this -> addWorkerQueue ( $ req...
Queue requests again for expired WorkerHandlers .
55,536
public function getRequest ( $ id ) { if ( ! isset ( $ this -> request [ $ id ] ) ) { return null ; } return $ this -> request [ $ id ] ; }
Returns the Request with the given ID .
55,537
public function removeRequest ( $ requestId ) { if ( isset ( $ this -> request [ $ requestId ] ) ) { unset ( $ this -> request [ $ requestId ] ) ; } return $ this ; }
Remove the given request .
55,538
public function reply ( Client $ client , MessageInterface $ msg ) { $ this -> getStream ( 'client' ) -> send ( $ msg , $ client -> getId ( ) ) ; $ this -> remove ( $ client ) ; }
Send the given message to the Client .
55,539
public function setLogger ( LoggerInterface $ logger ) { $ this -> logger = $ logger ; $ this -> getLogger ( ) -> info ( 'ClientHandler is started with pid ' . getmypid ( ) ) ; }
Set the Logger
55,540
public function getQuery ( ) { if ( ! $ this -> query instanceof Query ) { $ this -> query = $ this -> query === null ? new Query ( ) : Query :: fromString ( $ this -> query ) ; } return $ this -> query ; }
Get the query part of the URL as a Query object
55,541
public function setQuery ( $ query , $ rawString = false ) { if ( $ query instanceof Query ) { $ this -> query = $ query ; } elseif ( is_string ( $ query ) ) { if ( ! $ rawString ) { $ this -> query = Query :: fromString ( $ query ) ; } else { $ this -> query = preg_replace_callback ( self :: $ queryPattern , [ __CLASS...
Set the query part of the URL .
55,542
private function process ( ViewSource $ source , ContextInterface $ context ) : ViewSource { foreach ( $ this -> processors as $ processor ) { $ source = $ processor -> process ( $ source , $ context ) ; } return $ source ; }
Process given view source using set of associated processors .
55,543
public function getRequestUri ( ) { if ( isset ( $ this -> env [ 'REQUEST_URI' ] ) ) { $ uri = $ this -> env [ 'REQUEST_URI' ] ; } else { $ uri = "/" ; } if ( strstr ( $ uri , "?" ) ) { $ uri = strstr ( $ uri , "?" , true ) ; } return $ uri ; }
Retrieve the REQUEST_URI without and GET parameters
55,544
public function getHeader ( $ name , $ default = null ) { if ( empty ( $ name ) ) { return $ default ; } $ temp = 'HTTP_' . strtoupper ( str_replace ( '-' , '_' , $ name ) ) ; if ( isset ( $ this -> env [ $ temp ] ) ) { return $ this -> env [ $ temp ] ; } if ( function_exists ( 'apache_request_headers' ) ) { $ method =...
Retrieve a header from the request header stack and optionally set a default value to use if key isn t found .
55,545
public function getBody ( ) { if ( $ this -> body == false ) { $ body = @ file_get_contents ( 'php://input' ) ; if ( $ body != false && strlen ( trim ( $ body ) ) > 0 ) { $ this -> body = $ body ; } else { $ this -> body = false ; } } if ( $ this -> body == false ) { return false ; } return $ body ; }
Get the raw body if any .
55,546
public function getIp ( ) { if ( isset ( $ this -> env [ 'HTTP_X_FORWARDED_FOR' ] ) ) { return $ this -> env [ 'HTTP_X_FORWARDED_FOR' ] ; } elseif ( isset ( $ this -> env [ 'HTTP_CLIENT_IP' ] ) ) { return $ this -> env [ 'HTTP_CLIENT_IP' ] ; } return $ this -> env [ 'REMOTE_ADDR' ] ; }
Return the users IP Address
55,547
protected function buildParams ( ) { if ( empty ( $ this -> get ) ) { foreach ( @ $ _GET as $ k => $ v ) { $ this -> get [ $ k ] = $ v ; $ this -> params [ $ k ] = $ v ; } } if ( empty ( $ this -> post ) ) { foreach ( @ $ _POST as $ k => $ v ) { $ this -> post [ $ k ] = $ v ; $ this -> params [ $ k ] = $ v ; } } foreac...
Assign the GET POST and User Params to the main Params
55,548
public function collect ( $ callback ) { $ items = $ this -> crawler -> crawl ( ) ; $ articles = array ( ) ; foreach ( ( array ) $ items as $ item ) { $ article = $ this -> scraper -> scrape ( $ item ) ; $ articles [ ] = $ callback ( $ article , $ item ) ; } return $ articles ; }
Returns an array of article instances .
55,549
public static function getEventNames ( ) { $ names = [ ] ; $ reflection = new \ ReflectionClass ( self :: class ) ; foreach ( $ reflection -> getConstants ( ) as $ constant => $ value ) { if ( 'REPEATED_' === substr ( $ constant , 0 , 9 ) ) { $ names [ ] = $ value ; } } return $ names ; }
Get Event Names
55,550
public static function getDateInterval ( $ type ) { $ types = [ self :: REPEATED_EVERY_MINUTE => 'PT1M' , self :: REPEATED_TWO_MINUTES => 'PT2M' , self :: REPEATED_FIVE_MINUTES => 'PT5M' , self :: REPEATED_TEN_MINUTES => 'PT10M' , self :: REPEATED_TWENTY_MINUTES => 'PT20M' , self :: REPEATED_EVERY_HOUR => 'PT60M' , sel...
Get DateInterval Names
55,551
protected static function mimetypeInternalDetect ( $ path ) { $ pinfo = pathinfo ( $ path ) ; $ ext = isset ( $ pinfo [ 'extension' ] ) ? strtolower ( $ pinfo [ 'extension' ] ) : '' ; return isset ( elFinderVolumeDriver :: $ mimetypes [ $ ext ] ) ? elFinderVolumeDriver :: $ mimetypes [ $ ext ] : 'unknown' ; }
Detect file mimetype using internal method
55,552
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( SmartyFilterI18nTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ Smart...
Performs a DELETE on the database given a SmartyFilterI18n or Criteria object OR a primary key value .
55,553
private function getTblStructure ( ) { if ( strpos ( $ this -> tbl , '{db_prefix}' ) !== 0 || strpos ( $ this -> tbl , $ this -> prefix ) !== 0 ) { $ this -> tbl = $ this -> prefix . $ this -> tbl ; } else { $ this -> tbl = str_replace ( '{db_prefix}' , $ this -> prefix , $ this -> tbl ) ; } $ driver_class = '\Core\Dat...
Get complex table structure .
55,554
public function replaceHashableAttributes ( $ attributes ) { $ hash_id = $ this -> generateHashId ( $ attributes ) ; if ( $ hash_id ) { $ attributes [ 'hash_id' ] = $ hash_id ; foreach ( $ this -> hashableAttributes as $ value ) { unset ( $ attributes [ $ value ] ) ; } } return $ attributes ; }
Returns an array of attributes where the hashable attributes are replaced by the hash_id
55,555
public function generateHashId ( $ attributes ) { $ hashable_string = $ this -> getHashableString ( $ attributes ) ; if ( $ hashable_string ) return $ this -> hash ( $ hashable_string ) ; return null ; }
Get a hash id string from the set of hashable attributes .
55,556
public function getHashableString ( $ attributes ) { $ string = null ; if ( ! empty ( $ this -> hashableAttributes ) ) { foreach ( $ this -> hashableAttributes as $ value ) { if ( isset ( $ attributes [ $ value ] ) ) $ string .= $ attributes [ $ value ] ; else return null ; } } return $ string ; }
Get a hashable string from the hashable attributes .
55,557
public function resolve ( ) { $ this -> template = $ this -> createTemplate ( $ this -> templateClass ) ; $ this -> template -> setZones ( $ this -> zones ) ; $ this -> assertEntityIsValid ( $ this -> template , array ( 'Template' , 'creation' ) ) ; $ this -> eventDispatcher -> addListener ( TemplateEvents :: TEMPLATE_...
Template creation method .
55,558
public function encode ( $ data ) { list ( $ data , $ consumed , $ error ) = $ this -> encodeTransform ( ) -> transform ( $ data , $ context , true ) ; if ( null !== $ error ) { throw $ error ; } return $ data ; }
Encode the supplied data .
55,559
public function decode ( $ data ) { list ( $ data , $ consumed , $ error ) = $ this -> decodeTransform ( ) -> transform ( $ data , $ context , true ) ; if ( null !== $ error ) { throw $ error ; } return $ data ; }
Decode the supplied data .
55,560
protected function createMySQLDatabase ( ) { $ this -> checkParameters ( ) ; $ this -> url = $ this -> obtainAPIURLEndpoint ( ) ; try { $ this -> http -> post ( $ this -> url , [ 'form_params' => $ data = $ this -> getData ( ) , 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest' , 'Authorization' => 'Bearer ' . fp_e...
Create MySQL database .
55,561
protected function listMySQLDatabases ( ) { $ databases = $ this -> fetchMySQLDatabases ( ) ; if ( $ this -> option ( 'dump' ) ) { dump ( $ databases ) ; } if ( empty ( $ databases ) ) { $ this -> error ( 'No databases found.' ) ; die ( ) ; } $ headers = [ 'Id' , 'Server Id' , 'Name' , 'Status' , 'Created at' ] ; $ row...
List MySQL databases .
55,562
public static function lowerCaseFirst ( $ str , $ encoding = null ) { return ( string ) Stringy :: create ( $ str , $ encoding ) -> lowerCaseFirst ( ) ; }
Converts the first character of the supplied string to lower case .
55,563
public static function upperCamelize ( $ str , $ encoding = null ) { return ( string ) Stringy :: create ( $ str , $ encoding ) -> upperCamelize ( ) ; }
Returns an UpperCamelCase version of the supplied string . It trims surrounding spaces capitalizes letters following digits spaces dashes and underscores and removes spaces dashes underscores .
55,564
public static function format_background ( $ value , $ post_id , $ field ) { if ( self :: BACKGROUND !== $ field [ 'key' ] ) { return $ value ; } $ new_value = [ ] ; foreach ( $ value as $ index => $ item ) { $ new_value [ $ index ] = [ 'type' => $ item [ 'type' ] , ] ; if ( 'images' === $ item [ 'type' ] ) { $ new_val...
Format the background field .
55,565
public function key ( $ type , $ columns , $ name ) { $ parameters = array ( 'name' => $ name , 'columns' => ( array ) $ columns ) ; return $ this -> command ( $ type , $ parameters ) ; }
Create a command for creating any index .
55,566
protected function command ( $ type , $ parameters = array ( ) ) { $ parameters = array_merge ( compact ( 'type' ) , $ parameters ) ; $ this -> commands [ ] = new Fluent ( $ parameters ) ; return end ( $ this -> commands ) ; }
Create a new fluent command instance .
55,567
protected function column ( $ type , $ parameters = array ( ) ) { $ parameters = array_merge ( compact ( 'type' ) , $ parameters ) ; $ this -> columns [ ] = new Fluent ( $ parameters ) ; return end ( $ this -> columns ) ; }
Create a new fluent column instance .
55,568
protected function sendRequest ( RequestInterface $ request , $ responseClass ) { if ( ! in_array ( ApiResponseInterface :: class , class_implements ( $ responseClass ) ) ) { throw new \ InvalidArgumentException ( 'The response class must implement "' . ApiResponseInterface :: class . '".' ) ; } $ body = $ this -> seri...
Send a request to fastbill .
55,569
public function resolveClauses ( array & $ parameters ) { $ parameters = array_merge ( $ parameters , $ this -> parameters ) ; $ filter = function ( $ clause ) use ( $ parameters ) { $ is_exist = true ; if ( preg_match_all ( '/@(?P<type>.):(?P<name>.+?)@/' , $ clause , $ match ) > 0 ) { foreach ( $ match [ 'name' ] as ...
Resolve clauses .
55,570
public function addClause ( $ sql , array $ parameters , $ is_inclusive ) { $ this -> clauses [ $ is_inclusive ] [ ] = $ sql ; $ this -> parameters = array_merge ( $ this -> parameters , $ parameters ) ; }
Add a clause to the list of clauses .
55,571
public function at ( $ head , ... $ tail ) { if ( '@' == $ head [ 0 ] ) $ head = $ this -> marks [ $ head ] ; return $ head . self :: DS . join ( self :: DS , $ tail ) ; }
get the path .
55,572
public function copy ( $ source , $ target ) { if ( '@' == $ source [ 0 ] ) $ source = $ this -> as ( $ source ) ; if ( '@' == $ target [ 0 ] ) $ target = $ this -> as ( $ target ) ; if ( is_file ( $ source ) ) return copy ( $ source , $ target ) ; $ handle = opendir ( $ source ) ; while ( false !== ( $ name = readdir ...
copy file or directory .
55,573
public function remove ( $ path ) { if ( '@' == $ path [ 0 ] ) $ path = $ this -> as ( $ path ) ; if ( is_file ( $ path ) ) return unlink ( $ path ) ; $ handle = opendir ( $ path ) ; while ( false !== ( $ name = readdir ( $ handle ) ) ) { if ( '.' == $ name or '..' == $ name ) continue ; if ( ! $ this -> remove ( $ pat...
remove file or directory .
55,574
public function fill ( array $ values ) { foreach ( $ values as $ key => $ value ) { callback ( $ this , 'fill' . ucfirst ( $ key ) ) -> invoke ( $ value ) ; } return $ this ; }
Calls fill method for each item .
55,575
private function checkTagNameAndAttributes ( Element $ element , $ shortcutId , $ expectedTagName , $ expectedAttribs ) { $ actualTagName = $ element -> name ( ) ; if ( isset ( $ expectedTagName ) && $ actualTagName !== $ expectedTagName ) { throw new ViewStateException ( __METHOD__ . ": Element '$shortcutId' is expect...
Checks element name and attributes .
55,576
private function getNextPageFromList ( $ possibleReturnTypes , $ definingClass ) { foreach ( $ possibleReturnTypes as $ returnType ) { if ( $ returnType { 0 } !== '\\' ) { $ absolutizedReturnType = '\\' . ClassType :: from ( $ definingClass ) -> getNamespaceName ( ) . '\\' . $ returnType ; $ returnType = class_exists (...
This method can find out on which of named page object types we are .
55,577
public function toArray ( ) { return array ( 'age' => $ this -> getAge ( ) , 'quarter' => $ this -> getQuarter ( ) , 'day' => $ this -> getDay ( ) , 'month' => $ this -> getMonth ( ) , 'year' => $ this -> getYear ( ) , 'hour' => $ this -> getHour ( ) , 'minute' => $ this -> getMinute ( ) , 'second' => $ this -> getSeco...
Returns an array representation of the object
55,578
public function finish ( Request $ request ) : Response { if ( $ this -> finished ) { throw new \ LogicException ( 'The response has already finished.' ) ; } $ this -> request = $ request ; $ this -> headers -> set ( 'content-length' , strlen ( $ this -> body ) ) ; $ this -> setEmptyResponse ( ) ; $ this -> writeHeader...
Finish the response and return the object .
55,579
public function setBody ( $ body ) : Response { if ( is_null ( $ body ) || is_scalar ( $ body ) ) { $ this -> body = ( string ) $ body ; return $ this ; } $ prefix = 'Body must be null or scalar, ' ; $ suffix = gettype ( $ body ) . ' given.' ; throw new \ InvalidArgumentException ( "{$prefix}{$suffix}" ) ; }
Set the response body .
55,580
public function setHeader ( string $ key , $ value ) : Response { $ this -> headers -> set ( $ key , $ value ) ; return $ this ; }
Set a response header .
55,581
protected function setEmptyResponse ( ) { $ empty = in_array ( $ this -> status , static :: NO_BODY_STATUSES ) ; if ( $ this -> request -> isHead ( ) || $ empty ) { $ this -> body = null ; } if ( $ empty ) { $ this -> headers -> delete ( 'content-length' ) ; $ this -> headers -> delete ( 'content-type' ) ; } }
Set the correct behaviour for empty and no - body responses .
55,582
protected function writeHeaders ( ) { if ( headers_sent ( ) === false ) { $ status = static :: RESPONSE_STATUSES [ $ this -> status ] ; header ( "{$this->request->protocol} {$status}" ) ; foreach ( $ this -> headers -> all ( ) as $ key => $ value ) { header ( "{$key}: {$value}" , false ) ; } } }
Send response headers .
55,583
public function getRSmartLoad ( ) { if ( $ this -> _rSmartLoad === null ) { $ smartLoadClassName = $ this -> smartLoadConfig [ 'class' ] ; $ config = base \ Helper :: filterByKeys ( $ this -> smartLoadConfig , null , [ 'class' , 'disableNativeScriptFilter' ] ) ; $ this -> _rSmartLoad = new $ smartLoadClassName ( $ this...
Returns RSmartLoad instance
55,584
public static function rewindEntityBody ( RequestInterface $ redirectRequest ) { if ( $ body = $ redirectRequest -> getBody ( ) ) { if ( $ body -> tell ( ) && ! $ body -> seek ( 0 ) ) { throw new CouldNotRewindStreamException ( 'Unable to rewind the non-seekable request body after redirecting' , $ redirectRequest ) ; }...
Rewind the entity body of the request if needed
55,585
public function getRoute ( ) { $ route = substr ( $ this -> route , strlen ( $ this -> prefix ) ) ; if ( strlen ( $ route ) > 1 && $ route [ strlen ( $ route ) - 1 ] == '/' ) { $ route = substr ( $ route , 0 , strlen ( $ route ) - 1 ) ; } return $ route ; }
Gets the current route without prefix .
55,586
protected function parsevars ( array $ s ) { $ this -> method = strtoupper ( $ this -> arrayGet ( 'REQUEST_METHOD' , $ s ) ) ; $ this -> host = $ this -> arrayGet ( 'HTTP_HOST' , $ s ) ; $ this -> user_agent = $ this -> arrayGet ( 'HTTP_USER_AGENT' , $ s , false , false ) ; $ this -> accept = $ this -> arrayGet ( 'HTTP...
Parses server variables into this class .
55,587
protected function arrayGet ( $ key , array $ array , $ split = false , $ clean = true ) { if ( isset ( $ array [ $ key ] ) ) { if ( $ split ) { if ( $ clean ) { $ data = explode ( ',' , $ this -> clean ( $ array [ $ key ] ) ) ; } else { $ data = explode ( ',' , $ array [ $ key ] ) ; } $ data = array_map ( function ( $...
Gets checks and cleans an array entry . Avoids warnings and simplifies use .
55,588
protected function clean ( $ serverstring ) { $ scol_id = strpos ( $ serverstring , ';' ) ; if ( $ scol_id !== false ) { return substr ( $ serverstring , 0 , $ scol_id ) ; } else { return $ serverstring ; } }
Cleans up server entries .
55,589
public function getFullUploadStorePath ( $ model ) { $ path = strtr ( $ this -> fullUploadStoreDirPattern , [ "{uploadDir}" => $ this -> getUploadStorePath ( ) . '/' , "{logicPath}" => $ model -> getLogicPath ( ) , "{filename}" => $ model -> getHashFileName ( ) , ] ) ; return $ path ; }
return file store path by EntityFile model
55,590
public function getUploadPath ( $ isAbs = false , $ createMode = 0775 ) { if ( $ isAbs && isset ( $ this -> _data [ 'ABS_UPLOAD_PATH' ] ) ) { return $ this -> _data [ 'ABS_UPLOAD_PATH' ] ; } elseif ( ! $ isAbs && isset ( $ this -> _data [ 'REV_UPLOAD_PATH' ] ) ) { return $ this -> _data [ 'REV_UPLOAD_PATH' ] ; } $ path...
Return upload path
55,591
public function getCmsUploadTempPath ( $ isAbs = false , $ createMode = 0775 , $ model = null ) { return $ this -> getScalableUploadPath ( 'CmsTemp' , 'ABS_CMS_TEMP' , 'REV_CMS_TEMP' , $ isAbs , $ createMode , $ model ) ; }
return cms upload temporary folder
55,592
protected function getScalableUploadPath ( $ defaultName , $ absKey , $ revKey , $ isAbs = false , $ createMode = 0775 , $ model = null ) { if ( $ isAbs && isset ( $ this -> _data [ $ absKey ] ) ) { return $ this -> _data [ $ absKey ] ; } elseif ( ! $ isAbs && isset ( $ this -> _data [ $ revKey ] ) ) { return $ this ->...
get scalable folder under upload
55,593
public function load ( $ config = array ( ) ) { $ openid = new LightOpenID ( ) ; if ( ! empty ( $ config ) ) { foreach ( $ config as $ key => $ val ) { $ openid -> $ key = $ val ; } } return $ openid ; }
Main extension loader
55,594
private function setFormName ( ) : void { $ this -> key = 'form_' . $ this -> name . '_' . bin2hex ( random_bytes ( 16 ) ) ; if ( isset ( $ _SESSION [ $ this -> key ] ) ) { $ this -> setFormName ( ) ; } $ prev_form_keys = preg_grep ( '/^form_' . preg_quote ( $ this -> name , '/' ) . '_[a-f0-9]+$/' , array_keys ( $ _SES...
Set the form name to save in session
55,595
public function getFieldKey ( string $ name ) : string { $ name = trim ( $ name ) ; $ key = array_search ( $ name , $ _SESSION [ $ this -> key ] ) ; if ( $ key === false ) { throw new \ LogicException ( 'Field ' . $ name . ' does not exist' ) ; } return $ key ; }
Get a generated field key
55,596
public function parse ( $ query , $ secret = null ) { $ secret = $ secret ? Secret :: create ( $ secret ) : $ this -> secret ; if ( null === $ secret ) { throw new \ RuntimeException ( 'Secret not set on instance, be sure to pass it on parse.' ) ; } $ query = is_array ( $ query ) ? new QueryString ( $ query ) : QuerySt...
Converts query string parameters into a Payload .
55,597
protected function getModelTpl ( $ modelClassName , $ tableName ) { $ modelTpl = str_replace ( CodeTpl :: CLASS_NAME_TAG , $ modelClassName , CodeTpl :: MODEL_TPL ) ; $ statement = Connection :: component ( ) -> read_conn -> prepare ( 'desc ' . $ tableName ) ; if ( $ result = $ statement -> execute ( ) ) { $ fields = $...
Get model template
55,598
protected function formatLabel ( $ attrName ) { if ( strpos ( $ attrName , '_' ) !== false ) { $ tempArr = explode ( '_' , $ attrName ) ; foreach ( $ tempArr as $ key => $ item ) { $ tempArr [ $ key ] = ucfirst ( strtolower ( $ item ) ) ; } $ attrName = implode ( ' ' , $ tempArr ) ; } else { $ capitals = [ ] ; for ( $ ...
Format attribute label
55,599
protected function getCommentType ( $ propertyType ) { $ commentType = 'string' ; if ( stripos ( $ propertyType , 'int' ) !== false ) { $ commentType = 'integer' ; } else if ( stripos ( $ propertyType , 'float' ) !== false ) { $ commentType = 'float' ; } else if ( stripos ( $ propertyType , 'decimal' ) !== false ) { $ ...
Get comment property variable type