idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
56,400
protected static function populateElement ( ElementInterface $ elm , array $ data ) { self :: setValue ( $ elm , $ data ) ; $ hasAttributes = isset ( $ data [ 'attributes' ] ) && is_array ( $ data [ 'attributes' ] ) ; if ( ! $ hasAttributes ) { return ; } foreach ( $ data [ 'attributes' ] as $ attribute => $ value ) { $ elm -> setAttribute ( $ attribute , $ value ) ; } }
Sets the properties and dependencies for HTML elements
56,401
protected static function getClassName ( $ type ) { if ( in_array ( $ type , array_keys ( self :: $ elements ) ) ) { $ type = self :: $ elements [ $ type ] ; } if ( ! class_exists ( $ type ) ) { throw new InvalidArgumentException ( "Input class '{$type}' does not exists." ) ; } if ( ! is_subclass_of ( $ type , ElementInterface :: class ) ) { throw new InvalidArgumentException ( "The class '{$type}' does not implement the " . "Slick\\Form\\ElementInterface interface." ) ; } return $ type ; }
Check the element alias or FQ class name
56,402
protected static function setFilters ( InputInterface $ input , array $ data ) { $ hasFilters = isset ( $ data [ 'filters' ] ) && is_array ( $ data [ 'filters' ] ) ; if ( ! $ hasFilters ) { return ; } foreach ( $ data [ 'filters' ] as $ filter ) { $ input -> addFilter ( $ filter ) ; } }
Add filter to the input filter chain
56,403
protected static function addValidators ( InputInterface $ input , array $ data ) { $ hasValidators = isset ( $ data [ 'validates' ] ) && is_array ( $ data [ 'validates' ] ) ; if ( ! $ hasValidators ) { return ; } foreach ( $ data [ 'validates' ] as $ validator => $ message ) { self :: checkIfRequired ( $ validator , $ input ) ; if ( ! is_array ( $ message ) ) { $ message = [ 'message' => $ message ] ; } $ message [ 'form' ] = self :: $ form ; $ input -> addValidator ( $ validator , $ message ) ; } }
Add validators to the input validator chain
56,404
protected static function addLabel ( InputInterface $ input , array $ data ) { if ( ! isset ( $ data [ 'label' ] ) ) { return ; } if ( is_string ( $ data [ 'label' ] ) ) { $ input -> setLabel ( $ data [ 'label' ] ) ; return ; } $ label = new Label ( '' , $ data [ 'label' ] [ 'value' ] ) ; self :: populateElement ( $ label , $ data [ 'label' ] ) ; $ input -> setLabel ( $ label ) ; }
Adds the html Label element to input
56,405
protected static function checkIfRequired ( $ name , InputInterface $ input ) { if ( in_array ( $ name , self :: $ triggerRequired ) ) { $ input -> setAttribute ( 'required' ) ; } }
Check if validator triggers the required attribute
56,406
protected static function addOptions ( InputInterface $ input , $ data ) { if ( ! $ input instanceof ChoiceAwareElementInterface || ! isset ( $ data [ 'options' ] ) ) { return ; } $ input -> setOptions ( $ data [ 'options' ] ) ; }
Set options for ChoiceAwareElementInterface input types like Select
56,407
function withMeta ( $ data ) { $ meta = $ this -> _assertMetaData ( $ data ) ; $ new = clone $ this ; $ new -> meta = array_merge ( $ this -> meta , $ meta ) ; return $ new ; }
Set Meta Data Headers
56,408
function getMeta ( $ metaKey = null ) { if ( $ metaKey !== null ) return ( isset ( $ this -> meta [ $ metaKey ] ) ) ? $ this -> meta [ $ metaKey ] : null ; return $ this -> meta ; }
Meta Data Or Headers
56,409
protected function _assertMetaData ( $ meta ) { if ( $ meta instanceof \ Traversable ) $ meta = iterator_to_array ( $ meta ) ; $ exception = new \ InvalidArgumentException ( sprintf ( 'Meta Must be Array Or Traversable Associated Key/Value Pair; given: (%s).' , \ Poirot \ Std \ flatten ( $ meta ) ) ) ; if ( ! is_array ( $ meta ) ) throw $ exception ; if ( ! empty ( $ meta ) && array_values ( $ meta ) === $ meta ) throw $ exception ; return $ meta ; }
Assert Given Meta Data
56,410
public function getModelsToUpdate ( ) { return $ this -> models -> filter ( function ( AbstractModel $ model ) { return ( $ model -> isChanged ( ) and ( $ model -> isSaved ( ) or $ model -> isSoftDeleted ( ) ) ) ; } ) ; }
Return all the models that are both saved and changed
56,411
public function add ( AbstractModel $ model ) { if ( ! $ this -> has ( $ model ) ) { $ this -> addShallow ( $ model ) ; $ modelLinks = $ model -> getRepo ( ) -> getLinkMap ( ) -> get ( $ model ) ; foreach ( $ modelLinks -> getModels ( ) as $ linkedModel ) { $ this -> add ( $ linkedModel ) ; } } return $ this ; }
Add a model traverse all the linked models recursively and add them too .
56,412
public function eachLink ( Closure $ yield ) { foreach ( $ this -> models as $ model ) { $ linkMap = $ model -> getRepo ( ) -> getLinkMap ( ) ; if ( $ linkMap -> has ( $ model ) ) { $ links = $ linkMap -> get ( $ model ) -> all ( ) ; foreach ( $ links as $ link ) { if ( ( $ new = $ yield ( $ link ) ) ) { $ this -> addAll ( $ new ) ; } } } } }
Iterate over all the links of the models Each callback may return a Models object in which case these models are added too . This is useful for relations that modify additional models
56,413
public function execute ( ) { $ this -> addFromDeleteRels ( ) ; $ this -> getModelsToDelete ( ) -> byRepo ( function ( Repo $ repo , Models $ models ) { $ repo -> deleteModels ( $ models ) ; } ) ; $ this -> addFromInsertRels ( ) ; $ this -> getModelsToInsert ( ) -> assertValid ( ) -> byRepo ( function ( Repo $ repo , Models $ models ) { $ repo -> insertModels ( $ models ) ; } ) ; $ this -> addFromUpdateRels ( ) ; $ this -> getModelsToUpdate ( ) -> assertValid ( ) -> byRepo ( function ( Repo $ repo , Models $ models ) { $ repo -> updateModels ( $ models ) ; } ) ; }
Save all the models to the storage mechanism
56,414
public function addArray ( array $ param = null ) { $ this -> param = array_merge ( $ this -> param , $ param ) ; return $ this ; }
adds a array as normal properties
56,415
public function send_error_mail ( ) { if ( Config :: get ( 'exception_mail' ) == '' ) return false ; $ error_msg = ( string ) "Script Name: {$_SERVER['SCRIPT_NAME']}\n" ; $ error_msg .= ( string ) "Port: {$_SERVER['SERVER_PORT']}\n" ; $ error_msg .= ( string ) "Query String: {$_SERVER['QUERY_STRING']}\n" ; $ error_msg .= ( string ) "Server Name: {$_SERVER['SERVER_NAME']}\n" ; $ error_msg .= ( string ) "Request URI: {$_SERVER['REQUEST_URI']}\n" ; $ error_msg .= ( string ) "Exception Message: $this->message\n" ; $ error_msg .= ( string ) "Remote User: {$_SERVER['REMOTE_ADDR']}\n" ; $ error_msg .= ( string ) "Client: {$_SERVER['HTTP_USER_AGENT']}\n" ; $ error_msg .= ( string ) 'Referer: ' . ( isset ( $ _SERVER [ 'HTTP_REFERER' ] ) ? $ _SERVER [ 'HTTP_REFERER' ] : null ) . "\n" ; $ error_msg .= ( string ) "Request Time: {$_SERVER['REQUEST_TIME']}\n" ; $ error_msg .= ( string ) "debug_backtrace: $this->backtrace\n" ; return mail ( $ this -> fatal_recipient , $ this -> fatal_subject , $ error_msg , $ this -> fatal_from ) ; }
sends out the error mail based on the exception
56,416
function setDomains ( $ domains ) { if ( is_array ( $ domains ) ) $ domains = implode ( ' ' , $ domains ) ; $ this -> domains = ( string ) $ domains ; return $ this ; }
Space - separated list of URIs that define the protection space .
56,417
public function setLogType ( $ type ) { if ( empty ( $ type ) ) { $ type = 'log' ; } $ this -> log_type = $ type ; $ this -> function = 'console.' . $ this -> log_type ; }
Sets the console logging type like log info debug etc
56,418
public function setLength ( int $ length ) : self { $ this -> minLength = $ length ; $ this -> maxLength = $ length ; return $ this ; }
Sets an exact length .
56,419
public function transformParams ( array $ params ) : array { $ newParams = [ ] ; foreach ( $ params as $ key => $ value ) { $ newParams [ '%' . $ key . '%' ] = $ value ; } return $ newParams ; }
Transform params .
56,420
public function format ( string $ message ) : string { if ( null === $ this -> params ) { return $ message ; } foreach ( $ this -> transformParams ( $ this -> params ) as $ key => $ value ) { $ message = str_replace ( $ key , $ value , $ message ) ; } return $ message ; }
Get formatted message .
56,421
public function sayHello ( \ GearmanJob $ Job ) { $ this -> countJob ( ) ; $ params = json_decode ( $ Job -> workload ( ) , true ) ; return "Hello World!" ; }
A dummy methods . Says hello ...
56,422
public function is_valid ( ) { $ ret = false ; if ( is_null ( $ this -> name ) === false && is_null ( $ this -> type ) === false && ( is_null ( $ this -> subtype ) === false || $ this -> type !== 'DISTRIBUTIONLIST' ) && is_null ( $ this -> subscriberList ) === false ) { $ ret = true ; } return $ ret ; }
Validates a modify list
56,423
public function Upload ( $ file ) { $ this -> upload = $ file ; if ( $ this -> upload [ 'error' ] != UPLOAD_ERR_OK ) { new \ Sonic \ Message ( 'error' , self :: _uploadError ( $ this -> upload [ 'error' ] ) ) ; return FALSE ; } $ this -> filename = $ this -> upload [ 'name' ] ; $ this -> extension = self :: _getExtension ( $ this -> filename ) ; $ this -> name = self :: _getFilename ( $ this -> filename ) ; return TRUE ; }
Set the file upload and check for any errors
56,424
public function Save ( $ path , $ name = FALSE , $ extension = FALSE ) { if ( ! $ this -> setPath ( $ path ) ) { return FALSE ; } if ( $ name ) { $ this -> name = $ name ; } if ( $ extension ) { $ this -> extension = $ extension ; } $ this -> filename = $ this -> name . '.' . $ this -> extension ; $ tmpPath = $ this -> tmpPath ( ) ; if ( ! $ tmpPath ) { return FALSE ; } if ( ! move_uploaded_file ( $ tmpPath , $ this -> path . $ this -> filename ) ) { new \ Sonic \ Message ( 'error' , 'Cannot save uploaded file!' ) ; return FALSE ; } return TRUE ; }
Save the uploaded file to a new location
56,425
public function setPath ( $ path ) { if ( ! is_dir ( $ path ) && ! mkdir ( $ path , 0755 , TRUE ) ) { return FALSE ; } if ( ! is_writable ( $ path ) ) { return FALSE ; } $ this -> path = $ path ; return TRUE ; }
Set absolute directory path
56,426
public static function _uploadError ( $ error ) { switch ( $ error ) { case UPLOAD_ERR_INI_SIZE : return 'The filesize cannot be more than ' . ini_get ( 'post_max_size' ) ; break ; case UPLOAD_ERR_FORM_SIZE : return 'The filesize cannot be more than ' . $ _POST [ 'MAX_FILE_SIZE' ] ; break ; case UPLOAD_ERR_PARTIAL : return 'The file was only partially uploaded. Please try again.' ; break ; case UPLOAD_ERR_NO_FILE : return 'No file was selected to upload!' ; break ; case UPLOAD_ERR_NO_TMP_DIR : return 'There is no temporary folder to upload the file to. Please inform the site administrator.' ; break ; case UPLOAD_ERR_CANT_WRITE : return 'Failed to write the file to disk.' ; break ; default : return 'Unknown error.' ; break ; } }
Return an upload error string
56,427
public static function _getExtension ( $ file ) { $ base = basename ( $ file ) ; $ arr = explode ( '.' , $ base ) ; $ ext = strtolower ( array_pop ( $ arr ) ) ; return $ ext ; }
Return the file extension
56,428
public static function _getFilename ( $ file ) { $ base = basename ( $ file ) ; $ arr = explode ( '.' , $ base ) ; array_pop ( $ arr ) ; $ file = NULL ; foreach ( $ arr as $ part ) { $ file .= $ part ; } return $ file ; }
Return the filename without the extension
56,429
public function createMigrationsTable ( ) { SchemaManager :: table ( 'migrations' ) -> create ( function ( $ scheme ) { $ scheme -> integer ( 'id' , 11 , false , true , [ 'primary' => true ] ) ; $ scheme -> varchar ( 'class_name' , 255 , false ) ; $ scheme -> varchar ( 'status' , 25 , false ) ; $ scheme -> varchar ( 'path' , 255 , false ) ; } ) ; }
Creates migrations table if it does not exist .
56,430
protected function getMigrationFilesFromDirectory ( String $ directory ) : Array { $ files = [ ] ; $ tableMigrationsClassFile = $ directory . '/' . Migration :: DEFAULT_MIGRATION_FILENAME . '.php' ; foreach ( glob ( $ directory . '/*' . '.php' ) as $ file ) { if ( $ file !== $ tableMigrationsClassFile ) { $ files [ ] = $ file ; } } return $ files ; }
Returns migration files from migrations directory .
56,431
public function runMigrations ( ) { $ migrations = Model :: where ( 'status' , 'pending' ) ; if ( $ migrations -> get ( ) -> size ( ) > 0 ) { foreach ( $ migrations -> get ( ) -> all ( ) as $ migration ) { $ this -> runSingleMigration ( $ migration ) ; } } }
Runs all migration classes with pending status .
56,432
public function runSingleMigration ( $ migration ) { require_once $ migration -> path ; $ migrationClass = $ migration -> class_name ; if ( ! class_exists ( $ migrationClass ) ) { throw new MigrationClassNotFoundException ( sprintf ( 'Migration class [%s] does not exist' , $ migrationClass ) ) ; } $ class = new $ migrationClass ( ) ; if ( Migration :: migrationType ( ) == Attribute :: DOWNGRADE ) { $ class -> down ( ) ; } else { $ class -> up ( ) ; } $ migration = Model :: findById ( $ migration -> id ) ; $ migration -> status = 'migrated' ; $ migration -> save ( ) ; $ this -> env -> sendOutput ( sprintf ( '[%s] migration was successful' , $ migration -> class_name ) , 'green' ) ; }
Runs a specific migration class .
56,433
public function addPaths ( array $ paths ) { $ this -> currentCollectorData = $ this -> filePathCollector -> collect ( ) ; foreach ( $ paths as $ path ) { $ this -> addPath ( $ path ) ; } }
Adds paths to the underlying collectors and tree generators .
56,434
private function addPath ( $ path ) { $ paths = $ this -> analyzer -> analyze ( $ path ) ; $ newPaths = [ ] ; foreach ( $ paths as $ filePath ) { $ newPathInformation = $ filePath ; $ newPathInformation [ 'original' ] = $ filePath [ 'path' ] ; if ( $ this -> getCollectorValue ( $ filePath [ 'path' ] ) !== null ) { $ newPathInformation [ 'path' ] = $ this -> templateRenderer -> renderString ( $ this -> getCollectorValue ( $ filePath [ 'path' ] ) ) ; } else { $ newPathInformation [ 'path' ] = $ this -> parser -> processPath ( $ filePath [ 'path' ] ) ; } $ newPaths [ ] = $ newPathInformation ; $ this -> paths [ ] = $ newPathInformation ; $ this -> addRawToCollector ( $ filePath [ 'path' ] , $ newPathInformation [ 'path' ] ) ; } $ this -> templateRenderer -> addPath ( $ path ) ; return $ newPaths ; }
Adds a single path to the underlying collectors and tree generators .
56,435
private function getCollectorValue ( $ key ) { if ( isset ( $ this -> currentCollectorData [ 'sys_pathNames' ] ) ) { if ( array_key_exists ( $ key , $ this -> currentCollectorData [ 'sys_pathNames' ] ) ) { return $ this -> currentCollectorData [ 'sys_pathNames' ] [ $ key ] ; } } return null ; }
Returns the value stored in the path collector for the given path .
56,436
public function emitStructure ( $ destination ) { $ this -> treeGenerator -> addPaths ( $ this -> getPaths ( ) ) ; return $ this -> treeGenerator -> generate ( $ destination ) ; }
Creates a directory structure in the provided destination directory .
56,437
public static function copy ( $ from , $ to , $ collectorData = [ ] ) { $ manager = app ( get_called_class ( ) ) ; if ( ! is_array ( $ from ) ) { $ from = array ( $ from ) ; } foreach ( $ collectorData as $ key => $ value ) { if ( $ value == null ) { $ manager -> addPathToCollector ( $ key ) ; } else { $ manager -> addRawToCollector ( $ key , $ value ) ; } } $ manager -> addPaths ( $ from ) ; $ manager -> emitStructure ( $ to ) ; return $ manager ; }
A helper method to quickly emit the directory structure from either a single file or an array of files to a single output directory .
56,438
public static function path ( $ array , $ path , $ default = null , $ delimiter = null ) { if ( ! static :: is ( $ array ) ) { return $ default ; } if ( static :: is ( $ path ) ) { $ keys = $ path ; } else { if ( static :: exists ( $ path , $ array ) ) { return $ array [ $ path ] ; } if ( $ delimiter === null ) { $ delimiter = static :: $ delimiter ; } $ path = ltrim ( $ path , "{$delimiter} " ) ; $ path = rtrim ( $ path , "{$delimiter} *" ) ; $ keys = explode ( $ delimiter , $ path ) ; } do { $ key = array_shift ( $ keys ) ; if ( ctype_digit ( $ key ) ) { $ key = ( int ) $ key ; } if ( isset ( $ array [ $ key ] ) ) { if ( $ keys ) { if ( static :: is ( $ array [ $ key ] ) ) { $ array = $ array [ $ key ] ; } else { break ; } } else { return $ array [ $ key ] ; } } elseif ( $ key === '*' ) { $ values = array ( ) ; foreach ( $ array as $ arr ) { if ( $ value = static :: path ( $ arr , implode ( '.' , $ keys ) ) ) { $ values [ ] = $ value ; } } if ( $ values ) { return $ values ; } else { break ; } } else { break ; } } while ( $ keys ) ; return $ default ; }
Gets a value from an array using a dot separated path .
56,439
public static function extract ( $ array , array $ paths , $ default = null ) { $ found = [ ] ; foreach ( $ paths as $ path ) { static :: setPath ( $ found , $ path , static :: path ( $ array , $ path , $ default ) ) ; } return $ found ; }
Retrieves multiple paths from an array . If the path does not exist in the array the default value will be added instead .
56,440
public static function callback ( $ str ) { $ command = $ params = null ; if ( preg_match ( '/^([^\(]*+)\((.*)\)$/' , $ str , $ match ) ) { $ command = $ match [ 1 ] ; if ( $ match [ 2 ] !== '' ) { $ params = preg_split ( '/(?<!\\\\),/' , $ match [ 2 ] ) ; $ params = repl ( '\,' , ',' , $ params ) ; } } else { $ command = $ str ; } if ( strpos ( $ command , '::' ) !== false ) { $ command = explode ( '::' , $ command , 2 ) ; } return array ( $ command , $ params ) ; }
Creates a callable function and parameter list from a string representation . Note that this function does not validate the callback string .
56,441
public static function splitOnValue ( $ array , $ value ) { if ( static :: is ( $ array ) ) { $ paramPos = array_search ( $ value , $ array ) ; if ( $ paramPos ) { $ arrays [ ] = array_slice ( $ array , 0 , $ paramPos ) ; $ arrays [ ] = array_slice ( $ array , $ paramPos + 1 ) ; } else { $ arrays = null ; } if ( static :: is ( $ arrays ) ) { return $ arrays ; } } return null ; }
finds the selected value then splits the array on that key and returns the two arrays if the value was not found then it returns false
56,442
public static function where ( $ array , \ Closure $ callback ) { $ filtered = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( call_user_func ( $ callback , $ key , $ value ) ) { $ filtered [ $ key ] = $ value ; } } return $ filtered ; }
Filter the array using the given Closure .
56,443
final public function importHTML ( $ text_html ) { $ content = $ this -> importer -> import ( $ text_html ) ; if ( ! ! is_null ( $ content ) ) { $ this -> logger -> logError ( 'E001' , array ( $ text_html ) ) ; } else if ( ! $ content ) { $ this -> logger -> logWarn ( 'W001' , array ( $ text_html ) ) ; } else { $ this -> html_content = $ content ; } return ! ! $ this -> domImport ( ) ; }
Metodo que importa y convierte el contenido html en un objeto DOM .
56,444
final public function e ( $ css_selector ) { $ xpath = $ this -> toXPath ( $ css_selector ) ; if ( ! ! $ xpath ) { return new \ PHPTools \ PHPHtmlDom \ Core \ PHPHtmlDomList ( $ this -> xpath -> query ( $ xpath ) ) ; } }
Metodo que permite buscar elementos hijos a partir de un selector css .
56,445
private function domImport ( ) { $ dom_import = @ $ this -> dom -> loadHTML ( $ this -> html_content ) ; if ( ! ! $ dom_import ) { $ this -> xpath = new \ DOMXPath ( $ this -> dom ) ; } else { $ this -> logger -> logError ( 'E002' , array ( $ this -> html_content ) ) ; } return $ dom_import ; }
Permite importar el contenido dom del texto html .
56,446
private function toXPath ( $ css_selector ) { $ xpath = Null ; try { $ xpath = $ this -> selector -> toXPath ( $ css_selector ) ; } catch ( \ Exception $ e ) { $ this -> logger -> logError ( 'E003' , array ( $ css_selector ) ) ; $ this -> logger -> logError ( 'E000' , array ( $ e -> getMessage ( ) ) ) ; } return $ xpath ; }
Metodo que convierte un selector css en un xpath
56,447
public function get ( $ url , array $ headers = array ( ) ) { curl_setopt ( $ this -> handle , CURLOPT_HTTPGET , true ) ; return $ this -> execute ( $ url , $ headers ) ; }
Executes a GET request .
56,448
public function post ( $ url , $ data , array $ headers = array ( ) ) { curl_setopt ( $ this -> handle , CURLOPT_POST , true ) ; curl_setopt ( $ this -> handle , CURLOPT_POSTFIELDS , $ data ) ; return $ this -> execute ( $ url , $ headers ) ; }
Executes a POST request .
56,449
public function put ( $ url , $ data , array $ headers = array ( ) ) { curl_setopt ( $ this -> handle , CURLOPT_CUSTOMREQUEST , 'PUT' ) ; $ fields = is_array ( $ data ) ? http_build_query ( $ data ) : $ data ; curl_setopt ( $ this -> handle , CURLOPT_POSTFIELDS , $ fields ) ; $ headers = array_replace ( $ headers , [ 'Content-Length' => strlen ( $ fields ) ] ) ; return $ this -> execute ( $ url , $ headers ) ; }
Executes a PUT request .
56,450
public function putFile ( $ url , $ file , array $ headers = array ( ) ) { $ file = $ this -> openFile ( $ file ) ; $ stat = fstat ( $ file ) ; curl_setopt ( $ this -> handle , CURLOPT_PUT , true ) ; curl_setopt ( $ this -> handle , CURLOPT_INFILE , $ file ) ; curl_setopt ( $ this -> handle , CURLOPT_INFILESIZE , $ stat [ 'size' ] ) ; return $ this -> execute ( $ url , $ headers ) ; }
Executes a PUT request using a file .
56,451
public function request ( $ method , $ url , $ data = null , array $ headers = array ( ) ) { curl_setopt ( $ this -> handle , CURLOPT_CUSTOMREQUEST , strtoupper ( $ method ) ) ; if ( ! empty ( $ data ) ) { curl_setopt ( $ this -> handle , CURLOPT_POSTFIELDS , $ data ) ; } return $ this -> execute ( $ url , $ headers ) ; }
Executes a custom request .
56,452
public function setEncoding ( $ encoding ) { if ( ! in_array ( $ encoding , [ self :: ENCODING_IDENTITY , self :: ENCODING_DEFLATE , self :: ENCODING_GZIP , self :: ENCODING_ALL ] ) ) { throw new \ InvalidArgumentException ( 'The encoding must be one of: HttpClient::ENCODING_IDENTITY, HttpClient::ENCODING_DEFLATE, HttpClient::ENCODING_GZIP, HttpClient::ENCODING_ALL.' ) ; } $ this -> encoding = $ encoding ; }
Sets the encoding .
56,453
public function acceptCookies ( $ jarfile = null ) { $ jarfile = $ jarfile ? ( string ) $ jarfile : sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . 'cookies.txt' ; if ( ! is_file ( $ jarfile ) && ! touch ( $ jarfile ) ) { throw new \ LogicException ( sprintf ( 'Cookie file "%s" could not be opened. Make sure that the directory is writable.' , $ jarfile ) ) ; } curl_setopt ( $ this -> handle , CURLOPT_COOKIEFILE , $ jarfile ) ; curl_setopt ( $ this -> handle , CURLOPT_COOKIEJAR , $ jarfile ) ; }
Enables the use of cookies .
56,454
public function useProxy ( $ proxy , $ type = self :: PROXY_HTTP , $ auth = self :: AUTH_BASIC ) { $ proxy = ( string ) $ proxy ; if ( ! in_array ( $ type , [ self :: PROXY_HTTP , self :: PROXY_SOCKS5 ] ) ) { throw new \ InvalidArgumentException ( 'The $type parameter must be one of: HttpClient::PROXY_HTTP, HttpClient::PROXY_SOCKS5.' ) ; } if ( ! in_array ( $ auth , [ self :: AUTH_BASIC , self :: AUTH_NTLM ] ) ) { throw new \ InvalidArgumentException ( 'The $auth parameter must be one of: HttpClient::AUTH_BASIC, HttpClient::AUTH_NTLM.' ) ; } if ( strpos ( $ proxy , '@' ) !== false ) { list ( $ proxyCredentials , $ proxyAddress ) = explode ( '@' , $ proxy , 2 ) ; curl_setopt ( $ this -> handle , CURLOPT_PROXY , $ proxyAddress ) ; curl_setopt ( $ this -> handle , CURLOPT_PROXYUSERPWD , $ proxyCredentials ) ; } else { curl_setopt ( $ this -> handle , CURLOPT_PROXY , $ proxy ) ; } }
Enables the use of a proxy .
56,455
protected function execute ( $ url , array $ headers = array ( ) ) { curl_setopt ( $ this -> handle , CURLOPT_URL , $ url ) ; curl_setopt ( $ this -> handle , CURLOPT_USERAGENT , $ this -> useragent ) ; curl_setopt ( $ this -> handle , CURLOPT_TIMEOUT , $ this -> timeout ) ; curl_setopt ( $ this -> handle , CURLOPT_ENCODING , $ this -> encoding ) ; $ curlheaders = array ( ) ; $ headers = array_merge ( $ this -> headers , $ headers ) ; foreach ( $ headers as $ headerName => $ headerValue ) { $ curlheaders [ ] = "$headerName: $headerValue" ; } curl_setopt ( $ this -> handle , CURLOPT_HTTPHEADER , $ curlheaders ) ; $ response = curl_exec ( $ this -> handle ) ; if ( $ response !== false ) { $ info = curl_getinfo ( $ this -> handle ) ; if ( $ info && $ info [ 'http_code' ] >= 200 && $ info [ 'http_code' ] < 300 ) { $ headers = $ this -> buffer ( ) ; $ info [ 'success' ] = true ; $ info [ 'headers' ] = $ this -> parseHeaders ( $ headers ) ; $ info [ 'data' ] = $ response ; } else { $ info [ 'success' ] = false ; } } else { $ info = array ( ) ; $ info [ 'success' ] = false ; $ info [ 'error' ] = curl_errno ( $ this -> handle ) ; $ info [ 'error_text' ] = curl_error ( $ this -> handle ) ; } return ( object ) $ info ; }
Really executes a request to the given URL .
56,456
protected function parseHeaders ( $ rawHeaders ) { $ headers = array ( ) ; $ lines = explode ( "\r\n" , preg_replace ( '/\x0D\x0A[\x09\x20]+/' , ' ' , $ rawHeaders ) ) ; foreach ( $ lines as $ header ) { if ( preg_match ( '/([^:]+): (.+)/m' , $ header , $ match ) ) { if ( ! isset ( $ headers [ $ match [ 1 ] ] ) ) { $ headers [ $ match [ 1 ] ] = trim ( $ match [ 2 ] ) ; } elseif ( is_array ( $ headers [ $ match [ 1 ] ] ) ) { $ headers [ $ match [ 1 ] ] [ ] = trim ( $ match [ 2 ] ) ; } else { $ headers [ $ match [ 1 ] ] = array ( $ headers [ $ match [ 1 ] ] , trim ( $ match [ 2 ] ) ) ; } } } return $ headers ; }
Parses the given HTTP headers .
56,457
private function openFile ( $ file ) { if ( is_resource ( $ file ) ) { if ( get_resource_type ( $ file ) !== 'stream' ) { throw new \ InvalidArgumentException ( 'The given resource is not a file handle.' ) ; } } else { $ filename = ( string ) $ file ; if ( ! is_file ( $ filename ) || ! is_readable ( $ filename ) ) { throw new \ LogicException ( sprintf ( 'File "%s" could not be opened.' , $ filename ) ) ; } $ file = fopen ( $ filename , 'r' ) ; } return $ file ; }
Opens a file handle .
56,458
private function buffer ( $ curl = null , $ line = null ) { static $ buffer ; if ( $ curl ) { $ buffer .= $ line ; return strlen ( $ line ) ; } else { $ return = $ buffer ; $ buffer = '' ; return $ return ; } }
Buffers the line read by curl . When no handle is given returns and clears the content of the buffer .
56,459
public function registerAutoloader ( ) { $ this -> app -> afterResolving ( DocumentManagerRegistry :: class , function ( ManagerRegistryInterface $ registry ) { foreach ( $ registry -> getManagers ( ) as $ manager ) { Autoloader :: register ( $ manager -> getConfiguration ( ) -> getProxyDir ( ) , $ manager -> getConfiguration ( ) -> getProxyNamespace ( ) ) ; } } ) ; }
Register proxy and hydrator autoloader
56,460
public function setopt ( string $ name , mixed $ value ) : bool { return curl_setopt ( $ this -> ch , $ name , $ value ) ; }
Set an option for the curl transfer
56,461
private static function removeCapsLock ( $ password ) { return $ password === Strings :: upper ( $ password ) ? Strings :: lower ( $ password ) : $ password ; }
Fixes caps lock accidentally turned on .
56,462
public function reset ( ) { $ this -> inQuotes = false ; $ this -> wasQuoted = false ; $ this -> content = '' ; $ this -> isNull = false ; $ this -> hasContent = false ; }
Reset the state
56,463
private function getRandomId ( $ entityClass , $ annotation ) { if ( 'int' === $ annotation -> type || 'integer' === $ annotation -> type ) { return mt_rand ( pow ( 10 , $ annotation -> length - 1 ) , pow ( 10 , $ annotation -> length ) - 1 ) ; } return substr ( hash ( 'sha256' , sprintf ( '%s - %s - %s' , microtime ( ) , $ entityClass , uniqid ( ) ) ) , 0 , $ annotation -> length ) ; }
Get Random Id
56,464
public function processQueues ( ) { foreach ( $ this -> _amqpConfigHelper -> getQueueConfigurationScopes ( ) as $ store ) { $ this -> _store = $ store ; $ this -> _consumeStoreQueues ( $ store ) ; } return $ this ; }
For each store with a unique AMQP configuration consume messages from each configured queue .
56,465
protected function _consumeStoreQueues ( Mage_Core_Model_Store $ store ) { foreach ( $ this -> _helper -> getConfigModel ( $ store ) -> queueNames as $ queueName ) { $ this -> _consumeQueue ( $ queueName , $ store ) ; } return $ this ; }
Consume messages from all queues configured for the given store .
56,466
protected function _consumeQueue ( $ queue , Mage_Core_Model_Store $ store ) { $ this -> _api = $ this -> _helper -> getSdkAmqp ( $ queue , $ store ) ; $ this -> _api -> openConnection ( ) ; $ this -> _api -> getChannel ( ) -> basic_consume ( $ this -> _helper -> _processQueueName ( $ queue , $ this -> _coreHelper -> getConfigModel ( $ store ) ) , '' , false , false , false , false , array ( $ this , 'process' ) ) ; $ timeout = $ this -> _helper -> getConfigModel ( $ store ) -> queueTimeout ? $ this -> _helper -> getConfigModel ( $ store ) -> queueTimeout : 5 ; while ( count ( $ this -> _api -> getChannel ( ) -> callbacks ) ) { try { $ this -> _api -> getChannel ( ) -> wait ( null , false , $ timeout ) ; } catch ( \ PhpAmqpLib \ Exception \ AMQPTimeoutException $ e ) { $ this -> _api -> getChannel ( ) -> close ( ) ; $ this -> _api -> closeConnection ( ) ; break ; } } return $ this ; }
Fetch messages from the queue within the store scope .
56,467
protected function _dispatchPayload ( IOrderEvent $ payload , Mage_Core_Model_Store $ store ) { $ eventName = $ this -> _eventPrefix . '_' . $ this -> _coreHelper -> underscoreWords ( $ payload -> getEventType ( ) ) ; $ logData = [ 'event_name' => $ eventName , 'payload' => $ payload -> serialize ( ) ] ; $ logMessage = 'Dispatching event "{event_name}" for payload.' ; $ this -> _logger -> info ( $ logMessage , $ this -> _context -> getMetaData ( __CLASS__ , $ logData ) ) ; Mage :: dispatchEvent ( $ eventName , array ( 'payload' => $ payload , 'store' => $ store ) ) ; return $ this ; }
Dispacth an event in Magento with the payload and store scope it was received in .
56,468
public static function getFirewallNames ( Container $ container ) { $ names = [ ] ; foreach ( $ container -> getServiceIds ( ) as $ serviceId ) { if ( 'security.firewall.map.context.' === substr ( $ serviceId , 0 , 30 ) ) { $ names [ ] = substr ( $ serviceId , 30 ) ; } } return $ names ; }
Get Firewall Names
56,469
public static function getFirewallWithAccessListenerNames ( Container $ container ) { $ names = [ ] ; foreach ( self :: getFirewallNames ( $ container ) as $ firewallName ) { $ firewall = $ container -> get ( sprintf ( 'security.firewall.map.context.%s' , $ firewallName ) ) ; if ( 0 === count ( $ firewall -> getContext ( ) ) ) { continue ; } $ firewallContext = $ firewall -> getContext ( ) ; if ( false === isset ( $ firewallContext [ 0 ] ) || 0 === count ( $ firewallContext [ 0 ] ) ) { continue ; } foreach ( $ firewallContext [ 0 ] as $ listener ) { if ( $ listener instanceof AccessListener ) { $ names [ ] = $ firewallName ; } } } return $ names ; }
Get Firewall With Access Listener Names
56,470
public static function getRandomPassword ( $ length = null , $ countCharsNum = null , $ countCharsSpecial = null ) { $ chars = [ 'alpha' => 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ' , 'special' => '!$%&=?*-:;.,+~@_' , ] ; if ( null === $ length ) { $ length = mt_rand ( 9 , 13 ) ; } if ( null === $ countCharsNum ) { $ countCharsNum = mt_rand ( 2 , 3 ) ; } if ( null === $ countCharsSpecial ) { $ countCharsSpecial = mt_rand ( 1 , 2 ) ; } $ countCharsAlpha = $ length - $ countCharsNum - $ countCharsSpecial ; if ( 0 >= $ countCharsAlpha ) { throw new \ LogicException ( sprintf ( '%d chars are not enough to include %d numbers and %d special chars' , $ lengthAlpha , $ countCharsNum , $ countCharsSpecial ) ) ; } $ result = [ ] ; for ( $ index = 0 ; $ index < $ countCharsAlpha ; $ index ++ ) { $ result [ ] = substr ( $ chars [ 'alpha' ] , mt_rand ( 0 , 45 ) , 1 ) ; } for ( $ index = 0 ; $ index < $ countCharsNum ; $ index ++ ) { $ result [ ] = mt_rand ( 1 , 9 ) ; } for ( $ index = 0 ; $ index < $ countCharsSpecial ; $ index ++ ) { $ result [ ] = substr ( $ chars [ 'special' ] , mt_rand ( 0 , 15 ) , 1 ) ; } shuffle ( $ result ) ; return join ( '' , $ result ) ; }
Get Random Password
56,471
protected function createClient ( ) { $ credentials = $ this -> getCredentials ( ) ; $ url = $ this -> getServiceURL ( ) ; $ transport = ! empty ( $ url [ 'transport' ] ) ? $ url [ 'transport' ] : self :: SECURE_TRANSPORT_DEFAULT ; $ this -> serviceClient = new SocketClient ( $ url [ 'host' ] , $ url [ 'port' ] ) ; $ this -> serviceClient -> setTransport ( $ transport ) -> setContextOptions ( array ( 'local_cert' => $ credentials -> getCertificate ( ) , 'passphrase' => $ credentials -> getCertificatePassPhrase ( ) , ) ) -> addConnectionFlag ( STREAM_CLIENT_PERSISTENT ) -> setBlockingMode ( false ) ; return $ this ; }
Initializing socket client
56,472
public function sendRequest ( ) { $ notification = $ this -> getNotificationOrThrowException ( ) ; try { $ connection = $ this -> getClientConnection ( ) ; $ connection -> write ( $ notification -> getPayload ( ) ) ; $ errorResponseData = $ connection -> read ( Response :: ERROR_RESPONSE_LENGTH ) ; } catch ( \ Exception $ e ) { throw new ClientException ( $ e -> getMessage ( ) ) ; } return new Response ( $ errorResponseData ? : '' , $ notification -> getRecipients ( ) ) ; }
If you send a notification that is accepted by APNs nothing is returned . If you send a notification that is malformed or otherwise unintelligible APNs returns an error - response packet
56,473
public static function create ( $ table , $ callback ) { $ table = new Table ( $ table ) ; $ table -> create ( ) ; call_user_func ( $ callback , $ table ) ; return static :: execute ( $ table ) ; }
Create a new database table schema .
56,474
public static function rename ( $ table , $ new_name ) { $ table = new Table ( $ table ) ; $ table -> rename ( $ new_name ) ; return static :: execute ( $ table ) ; }
Rename a database table in the schema .
56,475
public static function drop ( $ table , $ connection = null ) { $ table = new Table ( $ table ) ; $ table -> on ( $ connection ) ; $ table -> drop ( ) ; return static :: execute ( $ table ) ; }
Drop a database table from the schema .
56,476
public static function execute ( $ table ) { static :: implications ( $ table ) ; foreach ( $ table -> commands as $ command ) { $ grammar = static :: grammar ( $ connection ) ; if ( method_exists ( $ grammar , $ method = $ command -> type ) ) { $ statements = $ grammar -> $ method ( $ table , $ command ) ; foreach ( ( array ) $ statements as $ statement ) { $ connection -> query ( $ statement ) ; } } } }
Execute the given schema operation against the database .
56,477
protected static function implications ( $ table ) { if ( count ( $ table -> columns ) > 0 && ! $ table -> creating ( ) ) { $ command = new Fluent ( array ( 'type' => 'add' ) ) ; array_unshift ( $ table -> commands , $ command ) ; } foreach ( $ table -> columns as $ column ) { foreach ( array ( 'primary' , 'unique' , 'fulltext' , 'index' ) as $ key ) { if ( isset ( $ column -> $ key ) ) { if ( $ column -> $ key === true ) { $ table -> $ key ( $ column -> name ) ; } else { $ table -> $ key ( $ column -> name , $ column -> $ key ) ; } } } } }
Add any implicit commands to the schema table operation .
56,478
public static function grammar ( $ driver ) { $ driver = $ connection -> driver ( ) ; switch ( $ driver ) { case 'mysql' : return new Schema \ Grammars \ MySQL ( $ connection ) ; } throw new \ Exception ( "Schema operations not supported for [$driver]." ) ; }
Create the appropriate schema grammar for the driver .
56,479
public function take ( $ idx ) { self :: mustBeInteger ( $ idx , 'Index' ) ; if ( $ idx instanceof N ) { $ idx = $ idx -> int ; } if ( ! $ this -> exist ( $ idx ) ) { throw new \ OutOfRangeException ( 'Given ' . $ idx . ' index does not exist!' ) ; } return $ this -> value [ $ idx ] ; }
Gets item having given index . Shorthand for take method .
56,480
public function exist ( $ idx ) { self :: mustBeInteger ( $ idx ) ; if ( $ idx instanceof N ) { $ idx = $ idx -> int ; } return array_key_exists ( $ idx , $ this -> value ) ; }
Tests whether given index exists .
56,481
public function delete ( $ idx ) { self :: mustBeInteger ( $ idx ) ; if ( $ idx instanceof N ) { $ idx = $ idx -> int ; } if ( ! $ this -> exist ( $ idx ) ) { throw new \ OutOfRangeException ( 'Given ' . $ idx . ' index does not exist!' ) ; } unset ( $ this -> value [ $ idx ] ) ; $ this -> count -- ; return $ this ; }
Deletes element at given position .
56,482
public function replace ( $ idx , $ thing ) { self :: mustBeInteger ( $ idx , 'Index' ) ; if ( $ idx instanceof N ) { $ idx = $ idx -> int ; } if ( ! $ this -> exist ( $ idx ) ) { throw new \ OutOfRangeException ( 'Given ' . $ idx . ' index does not exist!' ) ; } $ this -> value [ $ idx ] = $ thing ; return $ this ; }
Replaces element at given position .
56,483
public function implode ( $ sep = '' ) { self :: mustBeString ( $ sep , 'Separator' ) ; $ sep = "$sep" ; $ arr = $ this -> value ; foreach ( $ this -> value as $ idx => $ item ) { if ( is_scalar ( $ item ) || is_array ( $ item ) || $ item instanceof A || $ item instanceof H || ( is_object ( $ item ) && method_exists ( $ item , '__toString' ) ) ) { if ( is_array ( $ item ) ) { $ item = new A ( $ item ) ; } if ( $ item instanceof A ) { $ arr [ $ idx ] = $ item -> implode ( $ sep ) ; } elseif ( $ item instanceof H ) { $ arr [ $ idx ] = $ item -> to_a -> implode ( $ sep ) ; } else { continue ; } } else { throw new \ RuntimeException ( 'Cannot convert this item to string' ) ; } } return new S ( implode ( $ sep , $ arr ) ) ; }
Joins all elements into the collection together as a string object .
56,484
protected function _array ( ) { $ arr = array_values ( $ this -> value ) ; $ cnt = count ( $ arr ) ; for ( $ i = 0 ; $ i < $ cnt ; $ i ++ ) { $ v = $ arr [ $ i ] ; if ( $ v instanceof A || $ v instanceof H ) { $ arr [ $ i ] = $ v -> array ; } } return $ arr ; }
Converts current collection as a simple array recursively .
56,485
public function pad ( $ size , $ value = null ) { self :: mustBeInteger ( $ size , 'Size' ) ; if ( $ size instanceof N ) { $ size = $ size -> int ; } return new self ( array_pad ( $ this -> value , $ size , $ value ) ) ; }
Fill the collection with given element on given size .
56,486
public function map ( $ func ) { self :: mustBeCallable ( $ func ) ; return new self ( array_map ( $ func , $ this -> value ) ) ; }
Applys given function arg on every item of the collection .
56,487
public function random ( $ n = 1 ) { self :: mustBeInteger ( $ n , 'Number of random items' ) ; if ( $ n instanceof N ) { $ n = $ n -> int ; } if ( ! is_numeric ( $ n ) || $ n < 1 ) { throw new \ InvalidArgumentException ( 'Random items amount must be an integer greater ' . 'than or equal one.' ) ; } if ( $ n > $ this -> count ( ) ) { throw new \ RuntimeException ( 'Cannot take more random elements than amount ' . 'contained into the collection.' ) ; } $ mix = array_rand ( $ this -> value , $ n ) ; if ( is_integer ( $ mix ) ) { return $ this -> value [ $ mix ] ; } $ out = new self ( ) ; foreach ( $ mix as $ idx ) { $ out -> add ( $ this -> value [ $ idx ] ) ; } return $ out ; }
Gets random items from the collection .
56,488
public function diff ( $ arr ) { self :: mustBeArrayOrHash ( $ arr ) ; return new self ( array_values ( array_diff ( $ this -> value , self :: toSimpleArray ( $ arr ) ) ) ) ; }
Returns elements not in common into current collection and given one .
56,489
public function inter ( $ arr ) { self :: mustBeArrayOrHash ( $ arr ) ; return new self ( array_values ( array_intersect ( $ this -> value , self :: toSimpleArray ( $ arr ) ) ) ) ; }
Gets commons elements into currrent collection and given collection .
56,490
public function chunk ( $ size ) { self :: mustBeInteger ( $ size , 'Size' ) ; if ( $ size instanceof N ) { $ size = $ size -> int ; } if ( $ size < 1 ) { throw new \ InvalidArgumentException ( 'Chunk cannot have null size, please use number equal or ' . 'greater than one.' ) ; } $ arr = array_chunk ( $ this -> value , $ size ) ; $ cnt = count ( $ arr ) ; for ( $ i = 0 ; $ i < $ cnt ; $ i ++ ) { $ v = $ arr [ $ i ] ; if ( is_array ( $ v ) ) { $ arr [ $ i ] = new self ( $ v ) ; } } return new self ( $ arr ) ; }
Divides current collection into subcollection having given size .
56,491
public function search ( $ foo ) { if ( in_array ( $ foo , $ this -> value ) ) { return new N ( array_search ( $ foo , $ this -> value , true ) ) ; } else { return null ; } }
Search index of the given element .
56,492
public function hasRange ( $ arr ) { self :: mustBeArrayOrHash ( $ arr ) ; $ arr = self :: toSimpleArray ( $ arr ) ; if ( empty ( $ arr ) ) { throw new \ RuntimeException ( 'Cannot used empty range to detect it into collection!' ) ; } if ( count ( $ arr ) > count ( $ this -> value ) ) { return false ; } $ arr_idx = array ( ) ; foreach ( $ this -> value as $ k => $ v ) { if ( $ v === $ arr [ 0 ] ) { $ arr_idx [ ] = $ k ; } } if ( count ( $ arr_idx ) == 0 ) { return false ; } else { foreach ( $ arr_idx as $ idx ) { $ j = 1 ; $ cnt = ( count ( $ arr ) + $ idx ) ; for ( $ i = $ idx + 1 ; $ i < $ cnt ; $ i ++ ) { if ( ! array_key_exists ( $ i , $ this -> value ) ) { return false ; } if ( $ this -> value [ $ i ] !== $ arr [ $ j ] ) { return false ; } $ j ++ ; } return true ; } } return false ; }
Checks whether current collection has given range inside .
56,493
protected function _flatten ( ) { $ arr = array ( ) ; foreach ( $ this -> value as $ idx => $ item ) { if ( is_array ( $ item ) ) { $ item = new A ( $ item ) ; } elseif ( $ item instanceof H ) { $ item = $ item -> to_a ; } if ( $ item instanceof A ) { $ arr_prov = $ item -> flatten -> array ; foreach ( $ arr_prov as $ v ) { $ arr [ ] = $ v ; } } else { $ arr [ ] = $ item ; } } return new self ( $ arr ) ; }
Flatten the current collection .
56,494
public function zip ( ) { $ args = func_get_args ( ) ; $ int_max = 0 ; array_unshift ( $ args , $ this -> value ) ; foreach ( $ args as $ item ) { self :: mustBeArrayOrHash ( $ item ) ; $ item = self :: toSimpleArray ( $ item ) ; $ int_count = count ( $ item ) ; if ( $ int_count > $ int_max ) { $ int_max = $ int_count ; } } $ arr = array ( ) ; for ( $ i = 0 ; $ i < $ int_max ; $ i ++ ) { $ arr_prov = array ( ) ; foreach ( $ args as $ item ) { $ item = self :: toSimpleArray ( $ item ) ; if ( array_key_exists ( $ i , $ item ) ) { $ arr_prov [ ] = $ item [ $ i ] ; } else { $ arr_prov [ ] = null ; } } $ arr [ ] = new A ( $ arr_prov ) ; } return new A ( $ arr ) ; }
Combines provided collections with current one .
56,495
public static function css ( $ href , array $ attrs = [ ] ) { $ attrs = array_merge ( [ 'type' => 'text/css' , 'rel' => 'stylesheet' , 'href' => $ href , ] , $ attrs ) ; return static :: tag ( 'link' , null , $ attrs ) ; }
css link tag
56,496
public function filterBySmartyFilter ( $ smartyFilter , $ comparison = null ) { if ( $ smartyFilter instanceof \ SmartyFilter \ Model \ SmartyFilter ) { return $ this -> addUsingAlias ( SmartyFilterI18nTableMap :: ID , $ smartyFilter -> getId ( ) , $ comparison ) ; } elseif ( $ smartyFilter instanceof ObjectCollection ) { if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } return $ this -> addUsingAlias ( SmartyFilterI18nTableMap :: ID , $ smartyFilter -> toKeyValue ( 'PrimaryKey' , 'Id' ) , $ comparison ) ; } else { throw new PropelException ( 'filterBySmartyFilter() only accepts arguments of type \SmartyFilter\Model\SmartyFilter or Collection' ) ; } }
Filter the query by a related \ SmartyFilter \ Model \ SmartyFilter object
56,497
public function useSmartyFilterQuery ( $ relationAlias = null , $ joinType = 'LEFT JOIN' ) { return $ this -> joinSmartyFilter ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SmartyFilter' , '\SmartyFilter\Model\SmartyFilterQuery' ) ; }
Use the SmartyFilter relation SmartyFilter object
56,498
public function parse_position ( $ string ) { if ( empty ( $ string ) ) return array ( ) ; $ time_array = array ( 'range' => '*' , 'interval' => false ) ; if ( $ string == '*' ) { return $ time_array ; } else if ( preg_match ( '/^(\d{4})$/' , $ string ) ) { $ time_array [ 'range' ] = $ string ; return $ time_array ; } else { $ time_array [ 'range' ] = array ( ) ; switch ( true ) { case ( strpos ( $ string , ',' ) !== false ) : $ multi_pos = explode ( ',' , $ string ) ; $ interval = false ; foreach ( $ multi_pos as $ pos ) { switch ( true ) { case ( ( $ pos_pos = strpos ( $ pos , '/' ) ) !== false ) : $ interval = explode ( '/' , $ pos ) ; $ pos = substr ( $ pos , 0 , - ( strlen ( $ pos ) - $ pos_pos ) ) ; default : $ time_array [ 'range' ] [ ] = array ( 'range' => $ pos , 'interval' => $ interval [ 1 ] ) ; $ interval = false ; break ; } } break ; case ( strpos ( $ string , '-' ) !== false ) : if ( ( $ pos_pos = strpos ( $ string , '/' ) ) !== false ) { $ interval = explode ( '/' , $ string ) ; $ time_array [ 'interval' ] = $ interval [ 1 ] ; $ string = substr ( $ string , 0 , - $ pos_pos ) ; } $ time_array [ 'range' ] = $ string ; break ; case ( strpos ( $ string , '/' ) !== false ) : $ multi_pos = explode ( '/' , $ string ) ; $ time_array [ 'range' ] = $ multi_pos [ 0 ] ; $ time_array [ 'interval' ] = $ multi_pos [ 1 ] ; break ; } } return $ time_array ; }
returns an array with 2 positions - > range which can be an array or a specific time positions
56,499
public function load ( $ buffer ) { $ this -> fin = ord ( $ buffer [ 0 ] ) >> 7 ; $ this -> opcode = ord ( $ buffer [ 0 ] ) & ( pow ( 2 , 4 ) - 1 ) ; $ this -> mask = ord ( $ buffer [ 1 ] ) >> 7 ; if ( $ this -> isCtlFrame ( ) ) return ; $ this -> payload_len = ord ( $ buffer [ 1 ] ) & 127 ; $ ext_bytes = 0 ; if ( $ this -> payload_len < 126 ) { $ this -> payload_ext_len = 0 ; } elseif ( $ this -> payload_len === 126 ) { $ this -> payload_ext_len = unpack ( 'n' , substr ( $ buffer , 2 , 2 ) ) ; $ ext_bytes = 2 ; } else if ( $ this -> payload_len === 127 ) { $ this -> payload_ext_len = unpack ( 'J' , substr ( $ buffer , 2 , 8 ) ) ; $ ext_bytes = 8 ; } if ( $ this -> mask ) { $ this -> mask_key = substr ( $ buffer , $ ext_bytes + 2 , 4 ) ; $ data = substr ( $ buffer , $ ext_bytes + 6 ) ; for ( $ index = 0 ; $ index < strlen ( $ data ) ; $ index ++ ) { $ this -> body .= $ data [ $ index ] ^ $ this -> mask_key [ $ index % 4 ] ; } } else { $ this -> mask_key = '' ; $ this -> body = substr ( $ buffer , $ ext_bytes + 2 ) ; } }
load request from input buffer string