idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
8,900
public function onDeleted ( $ event , $ payload ) { list ( $ model ) = $ payload ; if ( $ this -> keepsFilesOnDelete ( $ model ) ) return ; if ( ! $ this -> supportsUploads ( $ model ) || ! ( $ attributes = $ model -> getUploadAttributes ( ) ) ) return ; event ( new Events \ HandlingDeleted ( $ model ) ) ; foreach ( $ ...
A model has been deleted trash all of it s files
8,901
protected function createResponsiveSet ( $ config , $ defaultArgs , $ set ) { Requirements :: javascript ( 'heyday/silverstripe-responsive-images:javascript/picturefill/picturefill.min.js' ) ; if ( ! isset ( $ config [ 'arguments' ] ) || ! is_array ( $ config [ 'arguments' ] ) ) { throw new Exception ( "Responsive set ...
Requires the necessary JS and sends the required HTML structure to the template for a responsive image set .
8,902
public function generate ( ) { $ this -> initialise ( ) ; $ this -> populate ( ) ; $ this -> fill ( ) ; return new Puzzle ( $ this -> grid , $ this -> wordList ) ; }
Generate the puzzle .
8,903
private function initialise ( ) { for ( $ i = 0 ; $ i < $ this -> size ; $ i ++ ) { for ( $ j = 0 ; $ j < $ this -> size ; $ j ++ ) { $ this -> grid [ $ i ] [ $ j ] = null ; } $ this -> rowsAvailable [ ] = $ i ; $ this -> columnsAvailable [ ] = $ i ; } }
Initialise the grid .
8,904
private function populate ( ) { foreach ( $ this -> words as $ word ) { $ rowOrColumn = rand ( 1 , 2 ) ; if ( $ rowOrColumn == 1 ) { shuffle ( $ this -> rowsAvailable ) ; foreach ( $ this -> rowsAvailable as $ key => $ row ) { $ maxStart = ( $ this -> size - Utils :: stringLength ( $ word ) ) ; $ startOptions = Utils :...
Populate the grid with the words .
8,905
private function insertWordIntoRow ( $ word , $ row , $ col ) { $ this -> wordList -> add ( $ word , ( $ row + 1 ) , ( 1 + $ col ) ) ; $ wordArray = Utils :: stringToArray ( $ word ) ; foreach ( $ wordArray as $ letter ) { $ this -> grid [ $ row ] [ $ col ] = $ letter ; $ col ++ ; } }
Insert a word into a row .
8,906
private function tryWordInColumn ( $ word , $ col , $ row ) { $ wordArray = Utils :: stringToArray ( $ word ) ; foreach ( $ wordArray as $ letter ) { if ( $ this -> grid [ $ row ] [ $ col ] !== null && $ this -> grid [ $ row ] [ $ col ] !== $ letter ) { return false ; } $ row ++ ; } return true ; }
Try to fit a word into a column .
8,907
private function fill ( ) { foreach ( $ this -> grid as $ r => $ row ) { foreach ( $ row as $ c => $ cell ) { if ( $ cell === null ) { $ this -> grid [ $ r ] [ $ c ] = $ this -> alphabet -> randomLetter ( ) ; } } } }
Fill any empty slots .
8,908
public static function create ( array $ words , $ size = 15 , $ lang = 'en' ) { $ alphabet = ( $ lang == 'fi' ) ? new Alphabet \ Finnish : null ; $ generator = new Generator ( $ words , $ size , $ alphabet ) ; return $ generator -> generate ( ) ; }
Create a puzzle .
8,909
public function next ( ) { if ( $ this -> isEndReached ) { return null ; } if ( null === $ this -> previous ) { $ this -> previous = @ ldap_first_entry ( $ this -> connection , $ this -> resultSet ) ; } else { $ this -> previous = @ ldap_next_entry ( $ this -> connection , $ this -> previous ) ; } if ( false === $ this...
Retrieves next available entry from the search result set
8,910
public function shouldExceptionCaptureBeSkipped ( \ Throwable $ exception ) : bool { if ( in_array ( get_class ( $ exception ) , $ this -> skipCapture , true ) ) { return true ; } if ( $ this -> skipHash && in_array ( $ this -> hashService -> hash ( $ exception ) , $ this -> skipHash , true ) ) { return true ; } foreac...
Check that exception should be skip
8,911
public function shouldMessageCaptureBeSkipped ( string $ message ) : bool { if ( function_exists ( 'fnmatch' ) ) { foreach ( $ this -> skipWildcard as $ wildcard ) { if ( fnmatch ( $ wildcard , $ message ) ) { return true ; } } } if ( in_array ( $ message , $ this -> skipCapture , true ) ) { return true ; } if ( in_arr...
Check that message or command should be skip
8,912
public function handle ( Args $ args , IO $ io ) { $ criteria = array ( ) ; if ( $ args -> isOptionSet ( 'path' ) ) { $ criteria [ 'path' ] = $ args -> getOption ( 'path' ) ; $ criteria [ 'language' ] = $ args -> getOption ( 'language' ) ; } if ( $ args -> isOptionSet ( 'name' ) ) { if ( isset ( $ criteria [ 'path' ] )...
Handles the find command .
8,913
private function listMatches ( IO $ io , array $ criteria ) { if ( isset ( $ criteria [ 'path' ] ) && isset ( $ criteria [ 'bindingType' ] ) ) { $ matches = array_intersect_key ( $ this -> findByPath ( $ criteria [ 'path' ] , $ criteria [ 'language' ] ) , $ this -> findByBindingType ( $ criteria [ 'bindingType' ] ) ) ;...
Lists the matches for the given search criteria .
8,914
private function findByPath ( $ query , $ language = 'glob' ) { $ matches = array ( ) ; $ query = '/' . ltrim ( $ query , '/' ) ; foreach ( $ this -> repo -> find ( $ query , $ language ) as $ resource ) { $ matches [ $ resource -> getPath ( ) ] = StringUtil :: getShortClassName ( get_class ( $ resource ) ) ; } return ...
Finds the resources for a given path pattern .
8,915
private function findByBindingType ( $ typeName ) { $ matches = array ( ) ; $ expr = Expr :: isInstanceOf ( 'Puli\Discovery\Binding\ResourceBinding' ) ; foreach ( $ this -> discovery -> findBindings ( $ typeName , $ expr ) as $ binding ) { foreach ( $ binding -> getResources ( ) as $ resource ) { $ matches [ $ resource...
Finds the resources for a given binding type .
8,916
private function printTable ( IO $ io , array $ matches ) { $ table = new Table ( TableStyle :: borderless ( ) ) ; foreach ( $ matches as $ path => $ shortClass ) { $ table -> addRow ( array ( $ shortClass , sprintf ( '<c1>%s</c1>' , $ path ) ) ) ; } $ table -> render ( $ io ) ; }
Prints the given resources .
8,917
public function hydrateFromEntry ( EntryInterface $ entry ) { $ this -> dn = $ entry -> getDn ( ) ; $ this -> attributes = array ( ) ; foreach ( $ entry -> getAttributes ( ) as $ name => $ data ) { $ attr = new NodeAttribute ( $ name ) ; $ attr -> add ( $ data ) ; $ this -> mergeAttribute ( $ attr ) ; } $ this -> snaps...
Hydrate from a LDAP entry
8,918
public function setDn ( $ dn , $ force = false ) { if ( ( $ this -> isHydrated ) && ( ! $ force ) ) { throw new \ InvalidArgumentException ( 'Dn cannot be updated manually' ) ; } $ this -> dn = $ dn ; }
Setter for distinguished name
8,919
public function removeAttribute ( $ name ) { if ( ! $ this -> has ( $ name ) ) { return false ; } unset ( $ this -> attributes [ $ name ] ) ; $ this -> tracker -> logDeletion ( $ name ) ; return true ; }
Removes an attribute from the node store
8,920
public function get ( $ name , $ create = false ) { if ( ! $ this -> has ( $ name ) ) { if ( ! $ create ) { return null ; } $ this -> mergeAttribute ( new NodeAttribute ( $ name ) ) ; } return $ this -> attributes [ $ name ] ; }
Retrieves an attribute from its name
8,921
public function getDiffAdditions ( ) { $ data = $ this -> getValueDiffData ( 'getDiffAdditions' ) ; foreach ( $ this -> tracker -> getAdditions ( ) as $ name ) { $ data [ $ name ] = $ this -> get ( $ name ) -> getValues ( ) ; } return $ data ; }
Retrieves diff additions for the attribute
8,922
public function getDiffDeletions ( ) { $ data = $ this -> getValueDiffData ( 'getDiffDeletions' ) ; foreach ( $ this -> tracker -> getDeletions ( ) as $ name ) { $ data [ $ name ] = array ( ) ; } return $ data ; }
Retrieves diff deletions for the attribute
8,923
protected function getValueDiffData ( $ method ) { $ data = array ( ) ; foreach ( $ this -> getSafeAttributes ( ) as $ attribute ) { $ buffer = call_user_func ( array ( $ attribute , $ method ) ) ; if ( count ( $ buffer ) > 0 ) { $ data [ $ attribute -> getName ( ) ] = $ buffer ; } } return $ data ; }
Retrieve attribute value level diff information
8,924
public function getDiffReplacements ( ) { $ data = array ( ) ; foreach ( $ this -> getSafeAttributes ( ) as $ attribute ) { if ( $ attribute -> isReplaced ( ) ) { $ data [ $ attribute -> getName ( ) ] = $ attribute -> getValues ( ) ; } } foreach ( $ this -> tracker -> getReplacements ( ) as $ name ) { $ data [ $ name ]...
Retrieves diff replacements for the attribute
8,925
public function snapshot ( $ isHydrated = true ) { $ this -> tracker -> reset ( ) ; foreach ( $ this -> attributes as $ attribute ) { $ attribute -> snapshot ( ) ; } if ( $ isHydrated ) { $ this -> isHydrated = true ; } }
Snapshot resets diff tracking
8,926
public function getRawAttributes ( ) { $ data = array ( ) ; foreach ( $ this -> attributes as $ name => $ attribute ) { $ data [ $ name ] = $ attribute -> getValues ( ) ; } return $ data ; }
Retrieves attribute data in a raw format for persistence operations
8,927
public function rebaseDiff ( Node $ node ) { $ changes = array_merge ( $ node -> getDiffAdditions ( ) , $ node -> getDiffDeletions ( ) , $ node -> getDiffReplacements ( ) ) ; if ( count ( $ changes ) > 0 ) { throw new RebaseException ( sprintf ( '%s has some uncommitted changes - Cannot rebase %s on %s' , $ node -> get...
Rebase diff based on source node as an origin
8,928
public function decode ( string $ input ) { $ input = $ this -> toBuffer ( $ input ) ; $ decoded = $ this -> decodeData ( $ input ) ; return $ decoded [ 'data' ] ; }
decode Maybe use bignumber future .
8,929
protected function toBuffer ( $ input ) { if ( is_string ( $ input ) ) { if ( strpos ( $ input , '0x' ) === 0 ) { return new Buffer ( $ input , 'hex' ) ; } return new Buffer ( str_split ( $ input , 1 ) ) ; } elseif ( is_numeric ( $ input ) ) { if ( ! $ input || $ input < 0 ) { return new Buffer ( [ ] ) ; } if ( is_floa...
toBuffer Format input to buffer .
8,930
public function handle ( Args $ args , IO $ io ) { $ moduleFile = $ this -> moduleFileManager -> getModuleFile ( ) ; $ originVersion = $ moduleFile -> getVersion ( ) ; $ targetVersion = $ args -> getArgument ( 'version' ) ; if ( version_compare ( $ originVersion , $ targetVersion , '=' ) ) { $ io -> writeLine ( sprintf...
Handles the upgrade command .
8,931
public function render ( ) { $ item_output = '' ; $ item = $ this -> get_item ( ) ; $ index = $ this -> get_index ( ) ; $ trail = $ this -> get_trail ( ) ; $ trail_renderer = $ this -> get_trail_renderer ( ) ; $ item_output .= $ this -> render_link_before ( ) ; $ item_output .= $ this -> render_title ( ) ; $ item_outpu...
Render the item .
8,932
public function get_item_link ( ) { $ item = $ this -> get_item ( ) ; $ item_link = apply_filters ( 'carbon_breadcrumbs_item_link' , $ item -> get_link ( ) , $ item ) ; return $ item_link ; }
Retrieve the item link URL .
8,933
public function render_link_before ( ) { $ trail_renderer = $ this -> get_trail_renderer ( ) ; $ item_link = $ this -> get_item_link ( ) ; $ output = $ trail_renderer -> get_link_before ( ) ; if ( $ item_link && $ this -> is_link_enabled ( ) ) { $ output .= '<a href="' . $ item_link . '"' . $ this -> get_item_attribute...
Render the item link opening tag and its before wrapper .
8,934
public function render_link_after ( ) { $ trail_renderer = $ this -> get_trail_renderer ( ) ; $ item_link = $ this -> get_item_link ( ) ; $ output = '' ; if ( $ item_link && $ this -> is_link_enabled ( ) ) { $ output .= '</a>' ; } $ output .= $ trail_renderer -> get_link_after ( ) ; return $ output ; }
Render the item link closing tag and its after wrapper .
8,935
public function render_title ( ) { $ item = $ this -> get_item ( ) ; $ trail_renderer = $ this -> get_trail_renderer ( ) ; $ output = $ trail_renderer -> get_title_before ( ) ; $ output .= apply_filters ( 'carbon_breadcrumbs_item_title' , $ item -> get_title ( ) , $ item ) ; $ output .= $ trail_renderer -> get_title_af...
Render the item title along with its before & after wrappers .
8,936
public function get_item_attributes_html ( ) { $ item = $ this -> get_item ( ) ; $ item_attributes = apply_filters ( 'carbon_breadcrumbs_item_attributes' , $ item -> get_attributes ( ) , $ item ) ; $ attributes_html = '' ; foreach ( $ item_attributes as $ attr => $ attr_value ) { $ attributes_html .= ' ' . $ attr . '="...
Retrieve the attributes of the item link .
8,937
public function is_link_enabled ( ) { $ trail = $ this -> get_trail ( ) ; $ trail_renderer = $ this -> get_trail_renderer ( ) ; $ total_items = $ trail -> get_total_items ( ) ; $ index = $ this -> get_index ( ) ; return $ trail_renderer -> get_last_item_link ( ) || $ index < $ total_items ; }
Whether the link of this item is enabled .
8,938
public function get ( $ url , $ proxy = null ) { $ referer = "http://example.com/" ; $ agent = "My PHP Script" ; $ aHTTP [ 'http' ] [ 'proxy' ] = 'tcp://' . $ proxy [ 0 ] . ':' . $ proxy [ 1 ] ; $ aHTTP [ 'http' ] [ 'request_fulluri' ] = true ; $ aHTTP [ 'http' ] [ 'method' ] = 'GET' ; $ aHTTP [ 'http' ] [ 'header' ] =...
A simple curl implementation to get the content of the url via a proxy server .
8,939
public static function factory ( $ type = 'custom' , $ priority = 1000 ) { $ class = self :: verify_class_name ( __CLASS__ . '_' . $ type , 'Unexisting breadcrumb item type: "' . $ type . '".' ) ; $ item = new $ class ( $ priority ) ; $ item -> set_type ( $ type ) ; return $ item ; }
Build a new breadcrumb item of the selected type .
8,940
public static function getModuleNames ( Args $ args , ModuleList $ modules ) { if ( $ args -> isOptionSet ( 'all' ) ) { return $ modules -> getModuleNames ( ) ; } $ moduleNames = array ( ) ; if ( $ args -> isOptionSet ( 'root' ) ) { $ moduleNames [ ] = $ modules -> getRootModuleName ( ) ; } foreach ( $ args -> getOptio...
Returns the modules selected in the console arguments .
8,941
public static function getModuleNamesWithoutRoot ( Args $ args , ModuleList $ modules ) { if ( $ args -> isOptionSet ( 'all' ) ) { return $ modules -> getInstalledModuleNames ( ) ; } $ moduleNames = array ( ) ; foreach ( $ args -> getOption ( 'module' ) as $ moduleName ) { $ moduleNames [ ] = $ moduleName ; } return $ ...
Returns the non - root modules selected in the console arguments .
8,942
private function getBindingStates ( Args $ args ) { $ states = array ( BindingState :: ENABLED => 'enabled' , BindingState :: DISABLED => 'disabled' , BindingState :: TYPE_NOT_FOUND => 'type-not-found' , BindingState :: TYPE_NOT_ENABLED => 'type-not-enabled' , BindingState :: INVALID => 'invalid' , ) ; $ states = array...
Returns the binding states selected in the console arguments .
8,943
private function printBindingTable ( IO $ io , array $ descriptors , $ indentation = 0 , $ enabled = true ) { $ table = new Table ( PuliTableStyle :: borderless ( ) ) ; $ table -> setHeaderRow ( array ( 'UUID' , 'Glob' , 'Type' ) ) ; $ paramTag = $ enabled ? 'c1' : 'bad' ; $ artifactTag = $ enabled ? 'c1' : 'bad' ; $ t...
Prints a list of binding descriptors .
8,944
private function printBindingStateHeader ( IO $ io , $ bindingState ) { switch ( $ bindingState ) { case BindingState :: ENABLED : $ io -> writeLine ( 'The following bindings are currently enabled:' ) ; $ io -> writeLine ( '' ) ; return ; case BindingState :: DISABLED : $ io -> writeLine ( 'The following bindings are d...
Prints the header for a binding state .
8,945
public function resetPath ( $ path = '' ) { $ this -> blob = ( new Blob ( $ this -> package ) ) -> setPath ( $ path ) ; $ userFolder = Str :: normalizePath ( config ( 'cripfilesys.user_folder' ) ) ; if ( $ this -> blob -> path == $ userFolder ) { $ this -> makeDirectory ( ) ; } }
Reset current blob instance to the new path .
8,946
public function upload ( UploadedFile $ uploadedFile ) { if ( $ this -> blob === null ) { throw new \ Exception ( 'Blob path is not set yet.' ) ; } $ this -> makeDirectory ( ) ; $ path = $ this -> blob -> path ; $ ext = $ uploadedFile -> getClientOriginalExtension ( ) ; $ name = Slug :: make ( pathinfo ( $ uploadedFile...
Write the contents of a file on storage .
8,947
public function rename ( $ name ) { $ name = Str :: slug ( $ name ) ; if ( $ this -> isFile ( ) ) { return $ this -> renameFile ( $ name , $ this -> getMetaData ( ) -> getExtension ( ) ) ; } return $ this -> renameFolder ( $ name ) ; }
Rename blob .
8,948
public function delete ( ) { $ meta = $ this -> getMetaData ( ) ; if ( $ meta -> isImage ( ) || ! $ meta -> isFile ( ) ) { $ service = new ThumbService ( $ this -> package ) ; $ service -> delete ( $ meta -> getPath ( ) , ! $ meta -> isFile ( ) ) ; } if ( $ meta -> isFile ( ) ) { return $ this -> storage -> delete ( $ ...
Delete blob from storage .
8,949
public function folderContent ( ) { $ result = [ ] ; $ path = $ this -> ensureUserPath ( $ this -> blob -> path ) ; $ list = collect ( $ this -> storage -> getDriver ( ) -> listContents ( $ path ) ) -> pluck ( 'path' ) ; $ exclude = ( new ThumbService ( $ this -> package ) ) -> getSizes ( ) -> all ( ) ; $ isExcluded = ...
Fetch folder content of the storage directory .
8,950
public function blobExists ( ) { if ( $ this -> blob -> path . '' === '' ) { return true ; } return $ this -> storage -> exists ( $ this -> blob -> path ) ; }
Determines is current blob path is existing in storage .
8,951
public function isFile ( ) { if ( $ this -> blobExists ( ) ) { $ metadata = $ this -> storage -> getMetaData ( $ this -> blob -> path ) ; return $ metadata [ 'type' ] === 'file' ; } return false ; }
Determines is the current blob of file type .
8,952
public function fileMimeType ( ) { try { $ mimeType = $ this -> storage -> mimeType ( $ this -> blob -> path ) ; } catch ( \ Exception $ ex ) { $ ext = pathinfo ( $ this -> blob -> path , PATHINFO_EXTENSION ) ; $ mimeType = BlobMetadata :: guessMimeType ( $ ext , ! ! $ ext ) ; } return $ mimeType ; }
Get file mime type .
8,953
public function isSafe ( $ ext , $ mime ) { $ unsafeExtensions = $ this -> package -> config ( 'block.extensions' ) ; $ unsafeMimes = $ this -> package -> config ( 'block.mimetypes' ) ; $ mimeSearch = function ( $ mimeValue ) use ( $ mime ) { return preg_match ( $ mimeValue , $ mime ) ; } ; if ( in_array ( $ ext , $ un...
Determines is the file safe for upload .
8,954
public function getMetaData ( ) { if ( ! $ this -> metadata ) { $ this -> metadata = ( new BlobMetadata ( ) ) -> init ( $ this -> blob -> path ) ; } return $ this -> metadata ; }
Get blob meta data object .
8,955
public function fullDetails ( $ reset = false ) { return ( new Blob ( $ this -> package ) ) -> setPath ( $ this -> blob -> path ) -> fullDetails ( $ reset ? null : $ this -> getMetaData ( ) ) ; }
Get full details of the current blob .
8,956
private function ensureUserPath ( string $ path ) : string { $ userFolder = Str :: normalizePath ( $ this -> package -> config ( 'user_folder' ) ) ; if ( $ userFolder === '' ) { return $ path ; } if ( starts_with ( $ path , $ userFolder ) ) { return $ path ; } return $ userFolder . '/' . $ path ; }
Ensure that path contains prefix of user path ;
8,957
public static function factory ( string $ name , array $ attributes = [ ] ) : Custom { $ instance = new static ( ) ; $ instance -> name = $ name ; $ instance -> customAttributes = $ attributes ; return $ instance ; }
Creates a custom element with the given name and attributes .
8,958
private function getCipherMethod ( $ encType = CryptographyProviderInterface :: PROPERTY_ENCRYPTION ) { $ method = $ this -> settings [ 'cipher_method' ] [ $ encType ] ; $ supportedMethods = openssl_get_cipher_methods ( ) ; if ( ! in_array ( $ method , $ supportedMethods ) ) { throw new EncryptionException ( 'Method ' ...
Returns the cipher method corresponding to a determined element type
8,959
private function getSymmetricKeyLength ( $ encType = CryptographyProviderInterface :: PROPERTY_ENCRYPTION ) { $ cipherMethod = $ this -> getCipherMethod ( $ encType ) ; switch ( $ cipherMethod ) { case 'AES-128-CBC' : $ length = 16 ; break ; case 'AES-192-CBC' : $ length = 24 ; break ; case 'AES-256-CBC' : $ length = 3...
Returns the key length for the desired encryption method
8,960
private function getEncryptionOptions ( $ encType = CryptographyProviderInterface :: PROPERTY_ENCRYPTION ) { switch ( $ encType ) { case CryptographyProviderInterface :: PROPERTY_ENCRYPTION : case CryptographyProviderInterface :: PRIVATE_KEY_ENCRYPTION : return 0 ; case CryptographyProviderInterface :: FILE_ENCRYPTION ...
Returns the options for the encryption depending on the encryption type
8,961
public static function response ( $ data , $ type = self :: FORMAT_XML ) { if ( is_string ( $ data ) && strlen ( $ data ) === 0 ) { return true ; } switch ( $ type ) { case static :: FORMAT_XML : return AbstractResponse :: fromXml ( $ data ) ; case static :: FORMAT_JSON : return AbstractResponse :: fromJson ( $ data ) ...
Parse a response into a response type
8,962
public function get ( $ uri , AbstractRequest $ request = null ) { $ http = $ this -> getHttpClone ( ) ; if ( $ request ) { $ requestUri = $ this -> buildQuery ( $ uri , $ request -> getQuery ( ) ) ; } else { $ requestUri = $ uri ; } $ http -> setOption ( CURLOPT_URL , $ requestUri ) ; return $ http -> execute ( ) ; }
Execute a GET request against an API endpoint optionally with a given Request object as parameters
8,963
public function post ( $ uri , AbstractRequest $ request = null ) { $ http = $ this -> getHttpClone ( ) ; $ http -> setOption ( CURLOPT_POST , true ) ; $ http -> setOption ( CURLOPT_URL , $ uri ) ; if ( $ request ) { $ http -> setOption ( CURLOPT_POSTFIELDS , $ this -> buildPostData ( $ request -> getQuery ( ) ) ) ; } ...
Execute a POST request against an API endpoint optionally with a given Request object as parameters
8,964
public function put ( $ uri , AbstractRequest $ request = null ) { $ http = $ this -> getHttpClone ( ) ; $ http -> setOption ( CURLOPT_CUSTOMREQUEST , 'PUT' ) ; $ http -> setOption ( CURLOPT_URL , $ uri ) ; if ( $ request ) { $ http -> setOption ( CURLOPT_POSTFIELDS , $ this -> buildPostData ( $ request -> getQuery ( )...
Execute a PUT request against an API endpoint optionally with a given Request object as parameters
8,965
protected function updateCredentials ( ) { if ( $ this -> http ) { $ this -> http -> setOption ( CURLOPT_USERPWD , implode ( ":" , array ( $ this -> getUsername ( ) , $ this -> getPassword ( ) ) ) ) ; } }
Rehashes the HTTP Basic Authentication on the HTTP client
8,966
public static function isDenseArray ( $ array ) { $ arrayLength = count ( $ array ) ; if ( ! $ arrayLength ) { return true ; } $ keyTest = array_flip ( range ( 0 , $ arrayLength - 1 ) ) ; $ diff = array_diff_key ( $ keyTest , $ array ) ; return empty ( $ diff ) ; }
Determine if a given array is dense .
8,967
public function QueryContacts ( Request \ QueryContacts $ QueryContacts = null ) { $ uri = $ this -> getUri ( '/contact' , array ( ) ) ; return $ this -> get ( $ uri , $ QueryContacts ) ; }
Lists existing contacts
8,968
public function UpdateContacts ( Request \ UpdateContacts $ UpdateContacts = null ) { $ uri = $ this -> getUri ( '/contact' , array ( ) ) ; return $ this -> put ( $ uri , $ UpdateContacts ) ; }
Updates existing contacts
8,969
public function GetContactHistory ( $ ContactId , Request \ GetContactHistory $ GetContactHistory ) { $ uri = $ this -> getUri ( '/contact/%s/history' , array ( $ ContactId ) ) ; return $ this -> get ( $ uri , $ GetContactHistory ) ; }
Gets a contact s history by contact ID
8,970
public function CreateContactList ( Request \ CreateContactList $ CreateContactList = null ) { $ uri = $ this -> getUri ( '/contact/list' , array ( ) ) ; return $ this -> post ( $ uri , $ CreateContactList ) ; }
Create new contact list and add to account
8,971
public function QueryContactLists ( Request \ QueryContactLists $ QueryContactLists = null ) { $ uri = $ this -> getUri ( '/contact/list' , array ( ) ) ; return $ this -> get ( $ uri , $ QueryContactLists ) ; }
Lists existing contact lists
8,972
public function AddContactsToList ( $ ContactListId , Request \ AddContactsToList $ AddContactsToList ) { $ uri = $ this -> getUri ( '/contact/list/%s/add' , array ( $ ContactListId ) ) ; return $ this -> post ( $ uri , $ AddContactsToList ) ; }
Adds contacts to an existing list
8,973
public function RemoveContactsFromList ( $ ContactListId , Request \ RemoveContactsFromList $ RemoveContactsFromList ) { $ uri = $ this -> getUri ( '/contact/list/%s/remove' , array ( $ ContactListId ) ) ; return $ this -> post ( $ uri , $ RemoveContactsFromList ) ; }
Removes contacts from a list without deleting the contacts
8,974
protected function map ( array $ properties ) { $ map = array ( ) ; foreach ( $ properties as $ name => $ default ) { $ map [ $ name ] = ( true === empty ( $ this -> $ name ) ) ? $ default : $ this -> $ name ; } return $ map ; }
Maps the properties to array with actual values . For another properties - mapping please override this method .
8,975
protected function getDataType ( $ data ) { switch ( true ) { case $ data instanceof Undefined : return Spec :: AMF3_UNDEFINED ; break ; case $ data === null : return Spec :: AMF3_NULL ; break ; case $ data === true || $ data === false : return $ data ? Spec :: AMF3_TRUE : Spec :: AMF3_FALSE ; break ; case is_int ( $ d...
Return the AMF3 data type for given data
8,976
protected function findExpected ( PHP_CodeSniffer_File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ prevLineOp = $ phpcsFile -> findPrevious ( array ( T_WHITESPACE , T_CONSTANT_ENCAPSED_STRING ) , $ stackPtr - 1 , null , true ) ; if ( $ tokens [ $ prevLineOp ] [ 'code' ] === T_EQUAL ) { retu...
Find expected number of spaces to align operators .
8,977
private function createClassInstance ( $ className ) { if ( empty ( $ className ) ) { return new stdClass ( ) ; } try { $ refClass = new ReflectionClass ( $ className ) ; return $ refClass -> newInstance ( ) ; } catch ( Exception $ e ) { throw new DeserializationException ( "Class [$className] could not be instantiated...
Create an instance of a given class Use stdClass if no class name is provided
8,978
public function load ( $ key ) { if ( $ key !== null ) { $ this -> session = $ this -> storage -> load ( $ key ) ; } if ( is_null ( $ this -> session ) || static :: expired ( $ this -> session ) ) { $ this -> exists = false ; $ this -> session = $ this -> storage -> fresh ( ) ; } if ( ! $ this -> has ( Session :: CSRF ...
Load the session for the current request .
8,979
protected function isIn ( $ key , array $ session ) { if ( array_key_exists ( $ key , $ session ) && $ session [ $ key ] !== null ) { return $ session [ $ key ] ; } return null ; }
Checks if key is in session .
8,980
public function keep ( $ keys ) { foreach ( ( array ) $ keys as $ key ) { $ this -> flash ( $ key , $ this -> get ( $ key ) ) ; } }
Keep a session flash item from expiring at the end of the request .
8,981
public function save ( ) { $ this -> session [ 'last_activity' ] = time ( ) ; $ this -> age ( ) ; $ sessionConf = Config :: get ( 'session' ) ; $ this -> storage -> save ( $ this -> session , $ sessionConf , $ this -> exists ) ; $ this -> cookie ( $ sessionConf ) ; $ cleaning = $ sessionConf [ 'garbage_collection' ] ; ...
Store the session payload in storage . This method will be called automatically at the end of the request .
8,982
public function clean ( ) { if ( $ this -> storage instanceof \ Pimf \ Contracts \ Cleanable ) { $ this -> storage -> clean ( time ( ) - ( Config :: get ( 'session.lifetime' ) * 60 ) ) ; } }
Clean up expired sessions .
8,983
protected function cookie ( $ config ) { $ minutes = ( ! $ config [ 'expire_on_close' ] ) ? $ config [ 'lifetime' ] : 0 ; Cookie :: put ( $ config [ 'cookie' ] , $ this -> session [ 'id' ] , $ minutes , $ config [ 'path' ] , $ config [ 'domain' ] , $ config [ 'secure' ] ) ; }
Send the session ID cookie to the browser .
8,984
public function addElement ( BaseElement $ element ) : ContainerElement { $ element -> parent = $ this ; $ this -> children [ ] = $ element ; if ( $ element instanceof ContainerElement ) { return $ element ; } return $ this ; }
Adds an element instance as a child and returns either itself or the new element if its a container element .
8,985
protected function containerToDOM ( \ DomDocument $ doc , \ DomNode $ node ) : void { foreach ( $ this -> children as $ child ) { $ node -> appendChild ( $ child -> toDOM ( $ doc ) ) ; } }
Helper function that loops all children and appends them to the given \ DomNode .
8,986
public function custom ( string $ name , array $ attributes ) : Custom { return $ this -> addElement ( Custom :: factory ( $ name , $ attributes ) ) ; }
Adds a new custom element .
8,987
protected function runSteps ( $ steps = [ ] , $ pretend = false ) { $ return = true ; $ steps = empty ( $ steps ) ? array_keys ( $ this -> steps ) : $ steps ; foreach ( $ steps as $ step ) { if ( $ this -> runStep ( $ step , $ pretend ) === false ) { $ return = false ; } } return $ return ; }
Run all steps one by one .
8,988
protected function runStep ( $ step , $ pretend = false ) { try { $ step = $ this -> createStep ( $ step ) ; if ( $ this -> confirm ( $ step -> prompt ( ) , true ) ) { return $ step -> run ( $ pretend ) ; } } catch ( \ Exception $ e ) { $ this -> error ( $ e -> getMessage ( ) ) ; } return false ; }
Run installation step
8,989
protected function createStep ( $ step ) { if ( ! $ this -> stepExist ( $ step ) ) { throw new \ Exception ( "Step <comment>{$step}</comment> doesn't exist." ) ; } $ class = $ this -> steps [ $ step ] ; $ step = new $ class ( $ this ) ; if ( ! ( $ step instanceof AbstractStep ) ) { throw new \ Exception ( "Step class <...
Instantiate step class .
8,990
protected function stepExist ( $ step ) { return isset ( $ this -> steps [ $ step ] ) && class_exists ( $ this -> steps [ $ step ] ) ; }
Check if step exists .
8,991
public function lookup ( $ postcode ) { $ postcode = $ this -> mutatePostcode ( $ postcode ) ; $ coords = $ this -> getCoordinates ( $ postcode ) ; if ( empty ( $ coords ) ) { return [ ] ; } $ address_url = 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' . $ coords [ 'latitude' ] . ',' . $ coords [ 'longitu...
Retrieves the full address for a given postcode .
8,992
public static function factory ( string $ interpretAs , string $ content , string $ format = null ) { $ instance = new static ( ) ; $ instance -> interpretAs = $ interpretAs ; $ instance -> content = $ content ; $ instance -> format = $ format ; return $ instance ; }
Creates a say - as element with the given values as attributes .
8,993
public function fetch ( $ url ) { if ( $ this -> apiKey ) { $ url .= '&key=' . $ this -> apiKey ; } try { $ json = json_decode ( file_get_contents ( $ url ) ) ; } catch ( \ Exception $ e ) { throw new ServiceUnavailableException ; } $ this -> checkApiError ( $ json ) ; return $ json ; }
Calls the Google API .
8,994
public function relatedMetaInformation ( ) : KeyValueCollectionInterface { if ( ! $ this -> relatedMetaInformation instanceof KeyValueCollectionInterface ) { $ this -> relatedMetaInformation = new KeyValueCollection ( ) ; } return $ this -> relatedMetaInformation ; }
This method provides additional meta information for a resource identifier object in the context of relationship data
8,995
public static function toDOMDocument ( $ xml ) { if ( $ xml instanceof \ DOMDocument ) { return $ xml ; } if ( $ xml instanceof \ SimpleXMLElement ) { $ doc = new \ DOMDocument ( ) ; $ doc -> loadXML ( '' . $ xml -> asXML ( ) ) ; return $ doc ; } if ( is_string ( $ xml ) ) { $ doc = new \ DOMDocument ( ) ; if ( is_file...
Convert anything DOMDocument|SimpleXMLElement|string to DOMDocument .
8,996
public static function toSimpleXMLElement ( $ xml ) { if ( $ xml instanceof \ SimpleXMLElement ) { return $ xml ; } if ( $ xml instanceof \ DOMDocument ) { return simplexml_import_dom ( $ xml ) ; } if ( is_string ( $ xml ) ) { if ( is_file ( $ xml ) ) { return simplexml_load_file ( $ xml ) ; } return simplexml_load_str...
Convert anything DOMDocument|SimpleXMLElement|string to SimpleXMLElement .
8,997
public static function toArray ( \ SimpleXMLElement $ xml , $ namespace = null ) { if ( $ namespace !== null ) { $ namespaces = $ xml -> getNamespaces ( ) ; if ( false === isset ( $ namespaces [ $ namespace ] ) ) { throw new \ OutOfBoundsException ( 'namespace [' . $ namespace . '] not found' ) ; } $ xml = $ xml -> chi...
Convert SimpleXMLElement to multidimensional array .
8,998
private function _generateJ0 ( string $ IV , GHASH $ ghash ) : string { if ( 12 == strlen ( $ IV ) ) { return $ IV . "\0\0\0\1" ; } $ data = self :: _pad128 ( $ IV ) . self :: ZB_64 . self :: _uint64 ( strlen ( $ IV ) << 3 ) ; return $ ghash ( $ data ) ; }
Generate pre - counter block .
8,999
private function _gctr ( string $ ICB , string $ X , string $ K ) : string { if ( "" == $ X ) { return "" ; } $ n = ceil ( strlen ( $ X ) / 16 ) ; $ CB = $ ICB ; $ Y = "" ; for ( $ i = 0 ; $ i < $ n - 1 ; ++ $ i ) { $ xi = substr ( $ X , $ i << 4 , 16 ) ; $ Y .= $ xi ^ $ this -> _cipher -> encrypt ( $ CB , $ K ) ; $ CB...
Apply GCTR algorithm .