idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
225,800
protected function setBasketHash ( ) { $ oContainer = $ this -> _getContainer ( ) ; $ sBasketHash = $ oContainer -> getConfig ( ) -> getRequestParameter ( 'amazonBasketHash' ) ; if ( $ sBasketHash ) { $ oContainer -> getSession ( ) -> setVariable ( 'sAmazonBasketHash' , $ sBasketHash ) ; } }
Sets the basket hash .
225,801
public function render ( ) { $ sTemplate = parent :: render ( ) ; $ oPayment = $ this -> getPayment ( ) ; $ oConfig = $ this -> _getContainer ( ) -> getConfig ( ) ; if ( $ oPayment !== false ) { $ sPaymentId = ( string ) $ this -> getPayment ( ) -> getId ( ) ; $ sAmazonOrderReferenceId = ( string ) $ this -> _getContai...
The main render function with additional payment checks .
225,802
public function logIPNResponse ( $ sLevel , $ sMessage , $ oIpnMessage = null ) { if ( ( bool ) $ this -> getConfig ( ) -> getConfigParam ( 'blAmazonLogging' ) !== true ) { return ; } $ aContext = ( $ oIpnMessage !== null ) ? array ( 'ipnMessage' => $ oIpnMessage ) : array ( ) ; $ this -> _getLogger ( ) -> log ( $ sLev...
Method logs IPN response to text file
225,803
protected function _getMessage ( $ sBody ) { try { $ aHeaders = array ( ) ; foreach ( $ _SERVER as $ sKey => $ sValue ) { if ( substr ( $ sKey , 0 , 5 ) !== 'HTTP_' ) { continue ; } $ sHeader = str_replace ( ' ' , '-' , str_replace ( '_' , ' ' , strtolower ( substr ( $ sKey , 5 ) ) ) ) ; $ aHeaders [ $ sHeader ] = $ sV...
Parses SNS message and saves as simplified IPN message into array
225,804
protected function _orderReferenceUpdate ( $ oData ) { $ sId = $ oData -> OrderReference -> AmazonOrderReferenceId ; $ oOrder = $ this -> _loadOrderById ( 'BESTITAMAZONORDERREFERENCEID' , $ sId ) ; if ( $ oOrder !== false && isset ( $ oData -> OrderReference -> OrderReferenceStatus -> State ) ) { $ this -> getClient ( ...
Handles response for NotificationType = OrderReferenceNotification
225,805
protected function _paymentAuthorize ( $ oData ) { $ sId = $ oData -> AuthorizationDetails -> AmazonAuthorizationId ; $ oOrder = $ this -> _loadOrderById ( 'BESTITAMAZONAUTHORIZATIONID' , $ sId ) ; if ( $ oOrder !== false && isset ( $ oData -> AuthorizationDetails -> AuthorizationStatus -> State ) ) { $ this -> getClie...
Handles response for NotificationType = PaymentAuthorize
225,806
protected function _paymentCapture ( $ oData ) { $ sId = $ oData -> CaptureDetails -> AmazonCaptureId ; $ oOrder = $ this -> _loadOrderById ( 'BESTITAMAZONCAPTUREID' , $ sId ) ; if ( $ oOrder !== false && isset ( $ oData -> CaptureDetails -> CaptureStatus -> State ) ) { $ this -> getClient ( ) -> setCaptureState ( $ oO...
Handles response for NotificationType = PaymentCapture
225,807
protected function _paymentRefund ( $ oData ) { $ sAmazonRefundId = $ oData -> RefundDetails -> AmazonRefundId ; $ sSql = "SELECT COUNT(*) FROM bestitamazonrefunds WHERE BESTITAMAZONREFUNDID = {$this->getDatabase()->quote($sAmazonRefundId)} LIMIT 1" ; $ iMatches = ( int ) $ this -> get...
Handles response for NotificationType = PaymentRefund
225,808
public function processIPNAction ( $ sBody ) { $ oMessage = $ this -> _getMessage ( $ sBody ) ; if ( isset ( $ oMessage -> NotificationData ) ) { $ oData = $ oMessage -> NotificationData ; switch ( $ oMessage -> NotificationType ) { case 'OrderReferenceNotification' : return $ this -> _orderReferenceUpdate ( $ oData ) ...
Process actions by NotificationType
225,809
public function initializeNode ( $ weightClasses ) { if ( ! $ this -> isInitialized ( ) ) { $ contentScore = 0 ; switch ( $ this -> nodeName ) { case 'div' : $ contentScore += 5 ; break ; case 'pre' : case 'td' : case 'blockquote' : $ contentScore += 3 ; break ; case 'address' : case 'ol' : case 'ul' : case 'dl' : case...
Initializer . Calculates the current score of the node and returns a full Readability object .
225,810
public function getNodeAncestors ( $ maxLevel = 3 ) { $ ancestors = [ ] ; $ level = 0 ; $ node = $ this -> parentNode ; while ( $ node && ! ( $ node instanceof DOMDocument ) ) { $ ancestors [ ] = $ node ; $ level ++ ; if ( $ level === $ maxLevel ) { break ; } $ node = $ node -> parentNode ; } return $ ancestors ; }
Get the ancestors of the current node .
225,811
public function getLinkDensity ( ) { $ linkLength = 0 ; $ textLength = mb_strlen ( $ this -> getTextContent ( true ) ) ; if ( ! $ textLength ) { return 0 ; } $ links = $ this -> getAllLinks ( ) ; if ( $ links ) { foreach ( $ links as $ link ) { $ linkLength += mb_strlen ( $ link -> getTextContent ( true ) ) ; } } retur...
Get the density of links as a percentage of the content This is the amount of text that is inside a link divided by the total text in the node .
225,812
public function getTextContent ( $ normalize = false ) { $ nodeValue = $ this -> nodeValue ; if ( $ normalize ) { $ nodeValue = trim ( preg_replace ( '/\s{2,}/' , ' ' , $ nodeValue ) ) ; } return $ nodeValue ; }
Returns the full text of the node .
225,813
public function getChildren ( $ filterEmptyDOMText = false ) { $ ret = iterator_to_array ( $ this -> childNodes ) ; if ( $ filterEmptyDOMText ) { $ ret = array_values ( array_filter ( $ ret , function ( $ node ) { return $ node -> nodeName !== '#text' || mb_strlen ( trim ( $ node -> nodeValue ) ) ; } ) ) ; } return $ r...
Returns the children of the current node .
225,814
public function getRowAndColumnCount ( ) { $ rows = $ columns = 0 ; $ trs = $ this -> getElementsByTagName ( 'tr' ) ; foreach ( $ trs as $ tr ) { $ rowspan = $ tr -> getAttribute ( 'rowspan' ) ; $ rows += ( $ rowspan || 1 ) ; $ columnsInThisRow = 0 ; $ cells = $ tr -> getElementsByTagName ( 'td' ) ; foreach ( $ cells a...
Return an array indicating how many rows and columns this table has .
225,815
public function createNode ( $ originalNode , $ tagName ) { $ text = $ originalNode -> getTextContent ( ) ; $ newNode = $ originalNode -> ownerDocument -> createElement ( $ tagName , $ text ) ; return $ newNode ; }
Creates a new node based on the text content of the original node .
225,816
public function hasAncestorTag ( $ tagName , $ maxDepth = 3 , callable $ filterFn = null ) { $ depth = 0 ; $ node = $ this ; while ( $ node -> parentNode ) { if ( $ maxDepth > 0 && $ depth > $ maxDepth ) { return false ; } if ( $ node -> parentNode -> nodeName === $ tagName && ( ! $ filterFn || $ filterFn ( $ node -> p...
Check if a given node has one of its ancestor tag name matching the provided one .
225,817
public function hasSingleTagInsideElement ( $ tag ) { if ( count ( $ children = $ this -> getChildren ( true ) ) !== 1 || $ children [ 0 ] -> nodeName !== $ tag ) { return false ; } return array_reduce ( $ children , function ( $ carry , $ child ) { if ( ! $ carry === false ) { return false ; } return ! ( $ child -> no...
Check if this node has only whitespace and a single element with given tag or if it contains no element with given tag or more than 1 element .
225,818
public function hasSingleChildBlockElement ( ) { $ result = false ; if ( $ this -> hasChildNodes ( ) ) { foreach ( $ this -> getChildren ( ) as $ child ) { if ( in_array ( $ child -> nodeName , $ this -> divToPElements ) ) { $ result = true ; } else { $ result = ( $ result || $ child -> hasSingleChildBlockElement ( ) )...
Check if the current element has a single child block element . Block elements are the ones defined in the divToPElements array .
225,819
public function shiftingAwareGetElementsByTagName ( $ tag ) { $ nodes = $ this -> getElementsByTagName ( $ tag ) ; $ count = $ nodes -> length ; for ( $ i = 0 ; $ i < $ count ; $ i = max ( ++ $ i , 0 ) ) { yield $ nodes -> item ( $ i ) ; $ nodes = $ this -> getElementsByTagName ( $ tag ) ; $ i -= $ count - $ nodes -> l...
This is a hack that overcomes the issue of node shifting when scanning and removing nodes .
225,820
private function getMetadata ( ) { $ this -> logger -> debug ( '[Metadata] Retrieving metadata...' ) ; $ values = [ ] ; $ propertyPattern = '/\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|image)\s*/i' ; $ namePattern = '/^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creat...
Tries to guess relevant info from metadata of the html . Sets the results in the Readability properties .
225,821
public function getImages ( ) { $ result = [ ] ; if ( $ this -> getImage ( ) ) { $ result [ ] = $ this -> getImage ( ) ; } if ( null == $ this -> getDOMDocument ( ) ) { return $ result ; } foreach ( $ this -> getDOMDocument ( ) -> getElementsByTagName ( 'img' ) as $ img ) { if ( $ src = $ img -> getAttribute ( 'src' ) ...
Returns all the images of the parsed article .
225,822
public function getMainImage ( ) { $ imgUrl = false ; if ( $ this -> getImage ( ) !== null ) { $ imgUrl = $ this -> getImage ( ) ; } if ( ! $ imgUrl ) { foreach ( $ this -> dom -> getElementsByTagName ( 'link' ) as $ link ) { if ( $ link -> hasAttribute ( 'rel' ) && ( $ link -> getAttribute ( 'rel' ) === 'img_src' || $...
Tries to get the main article image . Will only update the metadata if the getMetadata function couldn t find a correct image .
225,823
private function toAbsoluteURI ( $ uri ) { list ( $ pathBase , $ scheme , $ prePath ) = $ this -> getPathInfo ( $ this -> configuration -> getOriginalURL ( ) ) ; if ( preg_match ( '/^[a-zA-Z][a-zA-Z0-9\+\-\.]*:/' , $ uri ) ) { return $ uri ; } if ( substr ( $ uri , 0 , 2 ) === '//' ) { return $ scheme . '://' . substr ...
Convert URI to an absolute URI .
225,824
public function getPathInfo ( $ url ) { if ( $ this -> dom -> baseURI !== null ) { if ( substr ( $ this -> dom -> baseURI , 0 , 1 ) === '/' ) { $ pathBase = parse_url ( $ url , PHP_URL_SCHEME ) . '://' . parse_url ( $ url , PHP_URL_HOST ) . $ this -> dom -> baseURI ; } else { $ pathBase = parse_url ( $ url , PHP_URL_SC...
Returns full path info of an URL .
225,825
private function checkByline ( $ node , $ matchString ) { if ( ! $ this -> configuration -> getArticleByLine ( ) ) { return false ; } if ( $ this -> getAuthor ( ) ) { return false ; } $ rel = $ node -> getAttribute ( 'rel' ) ; if ( $ rel === 'author' || preg_match ( NodeUtility :: $ regexps [ 'byline' ] , $ matchString...
Checks if the node is a byline .
225,826
private function isValidByline ( $ text ) { if ( gettype ( $ text ) == 'string' ) { $ byline = trim ( $ text ) ; return ( mb_strlen ( $ byline ) > 0 ) && ( mb_strlen ( $ byline ) < 100 ) ; } return false ; }
Checks the validity of a byLine . Based on string length .
225,827
private function removeScripts ( DOMDocument $ dom ) { foreach ( [ 'script' , 'noscript' ] as $ tag ) { $ nodes = $ dom -> getElementsByTagName ( $ tag ) ; foreach ( iterator_to_array ( $ nodes ) as $ node ) { NodeUtility :: removeNode ( $ node ) ; } } }
Removes all the scripts of the html .
225,828
private function prepDocument ( DOMDocument $ dom ) { $ this -> logger -> info ( '[PrepDocument] Preparing document for parsing...' ) ; foreach ( $ dom -> shiftingAwareGetElementsByTagName ( 'br' ) as $ br ) { $ next = $ br -> nextSibling ; $ replaced = false ; while ( ( $ next = NodeUtility :: nextElement ( $ next ) )...
Prepares the document for parsing .
225,829
public function _cleanStyles ( $ node ) { if ( property_exists ( $ node , 'tagName' ) && $ node -> tagName === 'svg' ) { return ; } if ( method_exists ( $ node , 'removeAttribute' ) ) { $ presentational_attributes = [ 'align' , 'background' , 'bgcolor' , 'border' , 'cellpadding' , 'cellspacing' , 'frame' , 'hspace' , '...
Remove the style attribute on every e and under .
225,830
public function _cleanClasses ( $ node ) { if ( $ node -> getAttribute ( 'class' ) !== '' ) { $ node -> removeAttribute ( 'class' ) ; } for ( $ node = $ node -> firstChild ; $ node !== null ; $ node = $ node -> nextSibling ) { $ this -> _cleanClasses ( $ node ) ; } }
Removes the class = attribute from every element in the given subtree .
225,831
public function toArray ( ) { $ out = [ ] ; foreach ( $ this as $ key => $ value ) { $ getter = sprintf ( 'get%s' , $ key ) ; if ( ! is_object ( $ value ) && method_exists ( $ this , $ getter ) ) { $ out [ $ key ] = call_user_func ( [ $ this , $ getter ] ) ; } } return $ out ; }
Returns an array - representation of configuration .
225,832
public static function nextElement ( $ node ) { $ next = $ node ; while ( $ next && $ next -> nodeType !== XML_ELEMENT_NODE && $ next -> isWhitespace ( ) ) { $ next = $ next -> nextSibling ; } return $ next ; }
Imported from the Element class on league \ html - to - markdown .
225,833
public static function setNodeTag ( $ node , $ value , $ importAttributes = true ) { $ new = new DOMDocument ( '1.0' , 'utf-8' ) ; $ new -> appendChild ( $ new -> createElement ( $ value ) ) ; $ children = $ node -> childNodes ; for ( $ i = 0 ; $ i < $ children -> length ; $ i ++ ) { $ import = $ new -> importNode ( $ ...
Changes the node tag name . Since tagName on DOMElement is a read only value this must be done creating a new element with the new tag name and importing it to the main DOMDocument .
225,834
private function generatePatterns ( ) { foreach ( $ this -> builders as $ uri => $ builder ) { $ pattern = '/' . ltrim ( $ uri , '/' ) ; if ( preg_match_all ( '/{[\w]+}/i' , $ uri , $ matches ) ) { foreach ( array_unique ( $ matches [ 0 ] ) as $ match ) { $ pattern = str_replace ( $ match , '[\w\d\@_~\-\.]+' , $ patter...
Generate regex patterns for URI templates .
225,835
public function create ( $ uri , $ content ) { $ uri = '/' . trim ( $ uri , '/' ) ; foreach ( $ this -> patterns as $ pattern => $ key ) { if ( preg_match ( $ pattern , $ uri ) ) { return call_user_func ( $ this -> builders [ $ key ] , ( array ) $ content ) ; } } throw new RuntimeException ( sprintf ( 'Cannot create re...
Create resource object by URI template and resource data .
225,836
public static function config ( $ configName , $ config = null ) { $ _this = Purifier :: getInstance ( ) ; if ( empty ( $ config ) ) { if ( ! isset ( $ _this -> _configs [ $ configName ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Purifier configuration `%s` does not exist!' , $ configName ) ) ; } return $ ...
Gets and sets purifier configuration sets .
225,837
public static function getPurifierInstance ( $ configName = 'default' ) { $ _this = Purifier :: getInstance ( ) ; if ( ! isset ( $ _this -> _instances [ $ configName ] ) ) { if ( ! isset ( $ _this -> _configs [ $ configName ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Configuration and instance `%s` does n...
Gets an instance of the purifier lib only when needed lazy loading it
225,838
public static function clean ( $ markup , $ configName = 'default' ) { $ _this = Purifier :: getInstance ( ) ; if ( ! isset ( $ _this -> _configs [ $ configName ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid HtmlPurifier configuration "%s"!' , $ configName ) ) ; } return $ _this -> getPurifierInstanc...
Cleans Markup using a given config
225,839
protected function execute ( array $ options = [ ] ) { $ session = $ this -> createSession ( ) ; $ result = [ ] ; try { if ( $ session -> open ( ) === false ) { throw new RuntimeException ( 'Cannot initialize a cURL session' ) ; } $ session -> setOptions ( $ options + $ this -> options ) ; $ result = $ session -> execu...
Execute cURL session .
225,840
protected function _getTable ( ) { $ table = TableRegistry :: get ( $ this -> args [ 0 ] ) ; $ connection = $ table -> connection ( ) ; $ tables = $ connection -> schemaCollection ( ) -> listTables ( ) ; if ( ! in_array ( $ table -> table ( ) , $ tables ) ) { $ this -> abort ( __d ( 'Burzum/HtmlPurifier' , 'Table `{0}`...
Gets the table from the shell args .
225,841
protected function _loadBehavior ( Table $ table , $ fields ) { if ( ! in_array ( 'HtmlPurifier' , $ table -> behaviors ( ) -> loaded ( ) ) ) { $ table -> addBehavior ( 'Burzum/HtmlPurifier.HtmlPurifier' , [ 'fields' => $ fields , 'purifierConfig' => $ this -> param ( 'config' ) ] ) ; } }
Loads the purifier behavior for the given table if not already attached .
225,842
public function purify ( ) { $ table = $ this -> _getTable ( ) ; $ fields = $ this -> _getFields ( $ table ) ; $ this -> _loadBehavior ( $ table , $ fields ) ; $ query = $ table -> find ( ) ; if ( $ table -> hasFinder ( 'purifier' ) ) { $ query -> find ( 'purifier' ) ; } $ total = $ query -> all ( ) -> count ( ) ; $ th...
Purifies data base content .
225,843
protected function _process ( Table $ table , $ chunkCount , $ chunkSize , $ fields ) { $ query = $ table -> find ( ) ; if ( $ table -> hasFinder ( 'purifier' ) ) { $ query -> find ( 'purifier' ) ; } $ fields [ ] = $ table -> primaryKey ( ) ; $ results = $ query -> select ( $ fields ) -> offset ( $ chunkCount ) -> limi...
Processes the records .
225,844
protected function allowedTypes ( ) { return [ self :: TYPE_DEFAULT_MESSAGE , self :: TYPE_REGISTRATION_MESSAGE , self :: TYPE_RESET_PASSWORD_MESSAGE , self :: TYPE_LOGIN_MESSAGE , self :: TYPE_NOTIFICATION_MESSAGE , ] ; }
Allowed message types
225,845
public function send ( $ numbers , $ message , $ type = self :: TYPE_DEFAULT_MESSAGE ) { if ( ! in_array ( $ type , $ this -> allowedTypes ( ) ) ) { throw new NotSupportedException ( "Message type \"$type\" doesn't support." ) ; } if ( empty ( $ numbers ) || ( is_array ( $ numbers ) && count ( $ numbers ) === 0 ) || em...
Send sms message
225,846
public function getStatus ( $ id , $ phone , $ all = 2 ) { if ( empty ( $ id ) || empty ( $ phone ) ) { throw new \ InvalidArgumentException ( 'For getting sms status, please, set id and phone' ) ; } $ data = $ this -> _client -> getMessageStatus ( $ id , $ phone , $ all ) ; if ( $ this -> _logger instanceof LoggerInte...
Get sms status by id and phone
225,847
public function createRequest ( $ method , $ uri , $ payload , array $ headers = [ ] ) { return new GuzzleRequest ( $ method , $ uri , $ headers , $ payload ) ; }
Factory method to create a new Request object .
225,848
public function createUri ( $ uri , array $ params = [ ] ) { if ( $ uri instanceof GuzzleUri ) { if ( ! empty ( $ params ) ) { $ uri = $ uri -> withQuery ( http_build_query ( $ params ) ) ; } return $ uri ; } if ( preg_match_all ( '/{[\w]+}/i' , $ uri , $ matches ) ) { foreach ( array_unique ( $ matches [ 0 ] ) as $ ma...
Factory method to create a new Uri object .
225,849
public static function generateSignature ( $ apiUser , $ apiKey ) { $ serverTimezone = date_default_timezone_get ( ) ; date_default_timezone_set ( 'UTC' ) ; $ nonce = self :: generateNonce ( self :: NONCE_LENGTH ) ; $ time = time ( ) ; $ signature = hash_hmac ( 'sha1' , $ apiUser . $ nonce . $ time , $ apiKey ) ; $ dat...
This method returns an array with the header name and header values for the nonce timestamp and signature .
225,850
public static function ini ( $ profile = null , $ filename = null ) { $ filename = $ filename ? : ( self :: getHomeDir ( ) . self :: INI_DEFAULT_FILE ) ; $ profile = $ profile ? : self :: INI_PROFILE ; return function ( ) use ( $ profile , $ filename ) { if ( ! is_readable ( $ filename ) ) { throw new RuntimeException ...
APIKEY provider that read APIKEY in an ini file stored in the current user s home directory .
225,851
private static function getHomeDir ( ) { if ( $ homeDir = getenv ( 'HOME' ) ) { return $ homeDir ; } if ( ( $ homeDrive = getenv ( 'HOMEDRIVE' ) ) && ( $ homePath = getenv ( 'HOMEPATH' ) ) ) { return $ homeDrive . $ homePath ; } throw new BadMethodCallException ( 'Cannot establish the home directory' ) ; }
Gets the environment s HOME directory if available .
225,852
public function init ( ) { $ git_repo = exec ( 'basename `git rev-parse --show-toplevel`' ) ; $ readme_contents = file_get_contents ( 'README.md' ) ; $ start_string = '### Initial build (new repo)' ; $ end_string = '### Initial build (existing repo)' ; $ from = $ this -> findAllTextBetween ( $ start_string , $ end_stri...
Initialize the project for the first time .
225,853
function setUpBehat ( ) { if ( ! $ this -> taskExec ( 'which chromedriver' ) -> run ( ) -> wasSuccessful ( ) ) { $ os = exec ( 'uname' ) ; if ( $ os == 'Darwin' ) { $ this -> taskExec ( 'brew install chromedriver' ) -> run ( ) ; } else { $ version = exec ( 'curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE...
Ensure that the filesystem has everything Behat needs . At present that s only chromedriver AKA Headless Chrome .
225,854
function pantheonInstall ( ) { $ admin_name = $ this -> projectProperties [ 'admin_name' ] ; $ install_cmd = 'site-install ' . $ this -> projectProperties [ 'install_profile' ] . ' --account-name=' . $ admin_name . ' -y' ; $ terminus_site_env = $ this -> getPantheonSiteEnv ( ) ; $ install_cmd = "terminus remote:drush $...
Install site on Pantheon .
225,855
protected function replaceArraySetting ( $ file , $ key , $ value ) { $ this -> taskReplaceInFile ( $ file ) -> regex ( "/'$key' => '[^'\\\\]*(?:\\\\.[^'\\\\]*)*',/s" ) -> to ( "'$key' => '" . $ value . "'," ) -> run ( ) ; }
Use regex to replace a key = > value pair in a file like a settings file .
225,856
private function findAllTextBetween ( $ beginning , $ end , $ string ) { $ beginningPos = strpos ( $ string , $ beginning ) ; $ endPos = strpos ( $ string , $ end ) ; if ( $ beginningPos === false || $ endPos === false ) { return '' ; } $ textToDelete = substr ( $ string , $ beginningPos , ( $ endPos + strlen ( $ end )...
Finds the text between two strings within a third string .
225,857
public function postDeploy ( ) { $ terminus_site_env = $ this -> getPantheonSiteEnv ( ) ; $ pantheon_prefix = getenv ( 'TERMINUS_SITE' ) ; if ( $ terminus_site_env == $ pantheon_prefix . '.develop' || $ terminus_site_env == $ pantheon_prefix . '.dev' ) { $ drush_commands = [ 'drush_partial_config_import' => "terminus r...
Clean up state of Pantheon dev & develop environments after deploying .
225,858
public function pullConfig ( ) { $ project_properties = $ this -> getProjectProperties ( ) ; $ terminus_site_env = $ this -> getPantheonSiteEnv ( $ this -> databaseSourceOfTruth ( ) ) ; $ grab_database = $ this -> confirm ( "To pull the latest config, you should create a new backup on Pantheon. Create backup now?" ) ; ...
Pull the config from the live site down to your local .
225,859
public function prepareLocal ( ) { $ do_composer_install = TRUE ; $ project_properties = $ this -> getProjectProperties ( ) ; $ grab_database = $ this -> confirm ( "Load a database backup?" ) ; if ( $ grab_database == 'y' ) { $ do_composer_install = $ this -> getDatabaseOfTruth ( ) ; } if ( $ do_composer_install ) { $ ...
Prepare your local machine for development .
225,860
public function postInstall ( ) { $ this -> say ( "The post:install command should be customized per project. Copy the postInstall() method from the `/vendor/robo-drupal/src/Tasks.php` folder into your RoboFile.php file and alter it to suit your needs." ) ; return TRUE ; $ terminus_site_env = $ this -> getPantheonSiteE...
Prepare a freshly - installed site with some dummy data for site editors .
225,861
private function getDatabaseOfTruth ( ) { $ project_properties = $ this -> getProjectProperties ( ) ; $ default_database = $ this -> databaseSourceOfTruth ( ) ; if ( file_exists ( 'vendor/database.sql.gz' ) ) { $ default_database = 'local' ; } $ this -> say ( 'This command will drop all tables in your local database an...
Helper function to pull the database of truth to your local machine .
225,862
private function downloadPantheonBackup ( $ env ) { $ project_properties = $ this -> getProjectProperties ( ) ; $ terminus_site_env = $ this -> getPantheonSiteEnv ( $ env ) ; $ terminus_url_request = $ this -> taskExec ( 'terminus backup:get ' . $ terminus_site_env . ' --element="db"' ) -> dir ( $ project_properties [ ...
Grabs a backup from Pantheon .
225,863
public function importLocal ( ) { $ project_properties = $ this -> getProjectProperties ( ) ; $ drush_commands = [ 'drush_import_database' => 'zcat < ../vendor/database.sql.gz | drush @self sqlc # Importing local copy of db.' ] ; $ database_import = $ this -> taskExec ( implode ( ' && ' , $ drush_commands ) ) -> dir ( ...
Imports a local database .
225,864
public function migrateCleanup ( $ opts = [ 'migrations' => '' ] ) { if ( $ opts [ 'migrations' ] && ( $ this -> migrationSourceFolder ( ) || $ this -> usesMigrationPlugins ) ) { $ migrations = explode ( ',' , $ opts [ 'migrations' ] ) ; $ project_properties = $ this -> getProjectProperties ( ) ; foreach ( $ migrations...
Cleanup migrations .
225,865
public static function update ( $ force = false ) { if ( ! defined ( 'SEMALT_UNIT_TESTING' ) && ! self :: isWritable ( ) ) { return ; } if ( ! $ force && ! self :: isOutdated ( ) ) { return ; } self :: doUpdate ( ) ; }
Try to update the blocked domains list .
225,866
public static function getRootDomain ( $ url ) { $ host = $ domain = self :: getHostname ( $ url ) ; $ root = false ; if ( ( $ dotsCount = substr_count ( $ host , '.' ) ) > 0 ) { $ last = $ domain ; while ( $ dotsCount > - 1 ) { if ( self :: isHostInSuffixList ( $ domain ) ) { $ root = $ last ; break ; } $ last = trim ...
Extracts lower - case ASCII root domain from URL if it is available and valid returns false otherwise .
225,867
private static function parseUrl ( $ url , $ component ) { if ( ! isset ( self :: $ cache [ $ url ] [ 'url' ] ) ) { $ scheme = parse_url ( $ url , PHP_URL_SCHEME ) ; $ url = str_replace ( $ scheme . '://' , '' , $ url ) ; $ url = str_replace ( $ scheme . ':' , '' , $ url ) ; $ host = parse_url ( 'http://' . $ url , PHP...
Checks an URL for validity and punycode encode the returned component .
225,868
public function keysgroup ( array $ keysgroup ) : self { $ this -> transaction -> asset [ 'multisignature' ] [ 'keysgroup' ] = $ keysgroup ; $ this -> transaction -> fee = ( count ( $ keysgroup ) + 1 ) * $ this -> transaction -> fee ; return $ this ; }
Set the keysgroup of signatures .
225,869
public function serialize ( ) : void { $ delegateBytes = bin2hex ( $ this -> transaction [ 'asset' ] [ 'delegate' ] [ 'username' ] ) ; $ this -> buffer -> writeUInt8 ( strlen ( $ delegateBytes ) / 2 ) ; $ this -> buffer -> writeHexBytes ( $ delegateBytes ) ; }
Handle the serialization of vote data .
225,870
public function deserialize ( ) : object { $ this -> buffer -> position ( $ this -> assetOffset / 2 ) ; $ voteLength = $ this -> buffer -> readUInt8 ( ) & 0xff ; $ this -> transaction -> asset = [ 'votes' => [ ] ] ; $ vote = null ; for ( $ i = 0 ; $ i < $ voteLength ; $ i ++ ) { $ this -> buffer -> position ( $ this ->...
Handle the deserialization of second signature registration data .
225,871
public function deserialize ( ) : object { $ this -> buffer -> position ( $ this -> assetOffset / 2 ) ; $ this -> transaction -> asset = [ 'payments' => [ ] ] ; $ count = $ this -> buffer -> readUInt16 ( ) & 0xff ; $ offset = $ this -> assetOffset / 2 + 1 ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ this -> transacti...
Handle the deserialization of multi payment data .
225,872
public function deserialize ( ) : Transaction { $ transaction = new Transaction ( ) ; $ transaction -> version = $ this -> buffer -> readUInt8 ( ) ; $ transaction -> network = $ this -> buffer -> readUInt8 ( ) ; $ transaction -> type = $ this -> buffer -> readUInt8 ( ) ; $ transaction -> timestamp = $ this -> buffer ->...
Perform AIP11 compliant deserialization .
225,873
public function handleType ( int $ assetOffset , Transaction $ transaction ) : Transaction { $ deserializer = $ this -> deserializers [ $ transaction -> type ] ; return ( new $ deserializer ( $ this -> buffer , $ assetOffset , $ transaction ) ) -> deserialize ( ) ; }
Handle the deserialization of transaction data .
225,874
public function handleVersionOne ( Transaction $ transaction ) : Transaction { if ( isset ( $ transaction -> secondSignature ) ) { $ transaction -> signSignature = $ transaction -> secondSignature ; } if ( Types :: VOTE === $ transaction -> type ) { $ transaction -> recipientId = Address :: fromPublicKey ( $ transactio...
Handle the deserialization of transaction data with a version of 1 . 0 .
225,875
public function handleVersionTwo ( Transaction $ transaction ) : Transaction { $ transaction -> id = Hash :: sha256 ( $ transaction -> serialize ( ) ) -> getHex ( ) ; return $ transaction ; }
Handle the deserialization of transaction data with a version of 2 . 0 .
225,876
public function serialize ( ) : void { $ dag = $ this -> transaction [ 'asset' ] [ 'ipfs' ] [ 'dag' ] ; $ this -> buffer -> writeUInt8 ( strlen ( $ dag ) / 2 ) ; $ this -> buffer -> writeHexBytes ( $ dag ) ; }
Handle the serialization of ipfs data .
225,877
public function deserialize ( ) : object { $ this -> buffer -> position ( $ this -> assetOffset / 2 ) ; $ this -> transaction -> amount = $ this -> buffer -> readUInt64 ( ) ; $ this -> transaction -> expiration = $ this -> buffer -> readUInt32 ( ) ; $ this -> transaction -> recipientId = Base58 :: encodeCheck ( new Buf...
Handle the deserialization of transfer data .
225,878
public static function fromPassphrase ( string $ passphrase , AbstractNetwork $ network = null ) : string { return static :: fromPrivateKey ( PrivateKey :: fromPassphrase ( $ passphrase ) , $ network ) ; }
Derive the address from the given passphrase .
225,879
public static function fromPublicKey ( string $ publicKey , $ network = null ) : string { $ network = $ network ?? NetworkConfiguration :: get ( ) ; $ ripemd160 = Hash :: ripemd160 ( PublicKey :: fromHex ( $ publicKey ) -> getBuffer ( ) ) ; $ seed = Writer :: bit8 ( Helpers :: version ( $ network ) ) . $ ripemd160 -> g...
Derive the address from the given public key .
225,880
public static function fromPrivateKey ( EccPrivateKey $ privateKey , AbstractNetwork $ network = null ) : string { $ digest = Hash :: ripemd160 ( $ privateKey -> getPublicKey ( ) -> getBuffer ( ) ) ; return ( new PayToPubKeyHashAddress ( $ digest ) ) -> getAddress ( $ network ) ; }
Derive the address from the given private key .
225,881
public static function validate ( string $ address , $ network = null ) : bool { try { $ addressCreator = new AddressCreator ( ) ; $ addressCreator -> fromString ( $ address , $ network ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Validate the given address .
225,882
public function deserialize ( ) : object { $ this -> buffer -> position ( $ this -> assetOffset / 2 ) ; $ usernameLength = $ this -> buffer -> readUInt8 ( ) ; $ this -> transaction -> asset = [ 'delegate' => [ 'username' => $ this -> buffer -> position ( $ this -> assetOffset + 2 ) -> readHexBytes ( $ usernameLength * ...
Handle the deserialization of vote data .
225,883
public function serialize ( ) : void { $ voteBytes = [ ] ; foreach ( $ this -> transaction [ 'asset' ] [ 'votes' ] as $ vote ) { $ voteBytes [ ] = '+' === substr ( $ vote , 0 , 1 ) ? '01' . substr ( $ vote , 1 ) : '00' . substr ( $ vote , 1 ) ; } $ this -> buffer -> writeUInt8 ( count ( $ this -> transaction [ 'asset' ...
Handle the serialization of second signature registration data .
225,884
public static function fromPassphrase ( string $ passphrase , AbstractNetwork $ network = null ) : string { return PrivateKey :: fromPassphrase ( $ passphrase ) -> toWif ( $ network ) ; }
Derive the WIF from the given passphrase .
225,885
public function serialize ( ) : void { $ this -> buffer -> writeUInt64 ( $ this -> transaction [ 'amount' ] ) ; $ this -> buffer -> writeUInt32 ( $ this -> transaction [ 'expiration' ] ?? 0 ) ; $ this -> buffer -> writeHex ( Base58 :: decodeCheck ( $ this -> transaction [ 'recipientId' ] ) -> getHex ( ) ) ; }
Handle the serialization of transfer data .
225,886
public function serialize ( ) : void { $ this -> buffer -> writeUInt16 ( count ( $ this -> transaction [ 'asset' ] [ 'payments' ] ) ) ; foreach ( $ this -> transaction [ 'asset' ] [ 'payments' ] as $ payment ) { $ this -> buffer -> writeUInt64 ( $ payment [ 'amount' ] ) ; $ this -> buffer -> writeHex ( Base58 :: decode...
Handle the serialization of multi payment data .
225,887
protected function parseSignatures ( int $ startOffset ) : object { return $ this -> transaction -> parseSignatures ( $ this -> buffer -> toHex ( ) , $ startOffset ) ; }
Parse the signatures of the given transaction .
225,888
public function add ( string $ recipientId , int $ amount ) : self { $ this -> transaction -> asset [ 'payments' ] [ ] = compact ( 'recipientId' , 'amount' ) ; return $ this ; }
Add a new payment to the collection .
225,889
public function serialize ( ) : void { $ keysgroup = [ ] ; if ( ! isset ( $ this -> transaction [ 'version' ] ) || 1 === $ this -> transaction [ 'version' ] ) { foreach ( $ this -> transaction [ 'asset' ] [ 'multisignature' ] [ 'keysgroup' ] as $ key ) { $ keysgroup [ ] = '+' === substr ( $ key , 0 , 1 ) ? substr ( $ k...
Handle the serialization of multi signature registration data .
225,890
public function signature ( string $ secondPassphrase ) : self { $ this -> transaction -> asset = [ 'signature' => [ 'publicKey' => PublicKey :: fromPassphrase ( $ secondPassphrase ) -> getHex ( ) , ] , ] ; return $ this ; }
Set the signature asset to register the second passphrase .
225,891
public function deserialize ( ) : object { $ this -> buffer -> position ( $ this -> assetOffset ) ; $ this -> transaction -> asset = [ 'signature' => [ 'publicKey' => $ this -> buffer -> readHexRaw ( 66 ) , ] , ] ; return $ this -> parseSignatures ( $ this -> assetOffset + 66 ) ; }
Handle the deserialization of delegate registration data .
225,892
public function deserialize ( ) : object { $ this -> buffer -> position ( $ this -> assetOffset / 2 ) ; $ this -> transaction -> asset = [ 'multisignature' => [ 'min' => $ this -> buffer -> readUInt8 ( ) & 0xff , 'lifetime' => $ this -> buffer -> skip ( 1 ) -> readUInt8 ( ) & 0xff , ] , ] ; $ count = $ this -> buffer -...
Handle the deserialization of multi signature registration data .
225,893
public function verify ( ) : bool { $ factory = new PublicKeyFactory ; $ publicKey = $ factory -> fromHex ( $ this -> senderPublicKey ) ; return $ publicKey -> verify ( Hash :: sha256 ( $ this -> toBytes ( ) ) , SignatureFactory :: fromHex ( $ this -> signature ) ) ; }
Verify the transaction .
225,894
public function secondVerify ( string $ secondPublicKey ) : bool { $ factory = new PublicKeyFactory ; $ secondPublicKey = $ factory -> fromHex ( $ secondPublicKey ) ; return $ secondPublicKey -> verify ( Hash :: sha256 ( $ this -> toBytes ( false ) ) , SignatureFactory :: fromHex ( $ this -> signSignature ) ) ; }
Verify the transaction with a second public key .
225,895
public function parseSignatures ( string $ serialized , int $ startOffset ) : self { $ this -> signature = substr ( $ serialized , $ startOffset ) ; $ multiSignatureOffset = 0 ; if ( 0 === strlen ( $ this -> signature ) ) { unset ( $ this -> signature ) ; } else { $ signatureLength = intval ( substr ( $ this -> signatu...
Parse the signature second signature and multi signatures .
225,896
public function toBytes ( bool $ skipSignature = true , bool $ skipSecondSignature = true ) : Buffer { $ buffer = new Writer ( ) ; $ buffer -> writeUInt8 ( $ this -> type ) ; $ buffer -> writeUInt32 ( $ this -> timestamp ) ; $ buffer -> writeHex ( $ this -> senderPublicKey ) ; $ skipRecipientId = $ this -> type === Typ...
Convert the transaction to its byte representation .
225,897
public function toArray ( ) : array { return array_filter ( [ 'amount' => $ this -> amount , 'asset' => $ this -> asset ?? null , 'fee' => $ this -> fee , 'id' => $ this -> id , 'network' => $ this -> network ?? Network :: get ( ) -> version ( ) , 'recipientId' => $ this -> recipientId ?? null , 'secondSignature' => $ ...
Convert the transaction to its array representation .
225,898
public function serialize ( ) : Buffer { $ buffer = new Writer ( ) ; $ buffer -> writeUInt8 ( 0xff ) ; $ buffer -> writeUInt8 ( $ this -> transaction [ 'version' ] ?? 0x01 ) ; $ buffer -> writeUInt8 ( $ this -> transaction [ 'network' ] ?? Network :: version ( ) ) ; $ buffer -> writeUInt8 ( $ this -> transaction [ 'typ...
Perform AIP11 compliant serialization .
225,899
public static function fromPassphrase ( string $ passphrase ) : EcPrivateKey { $ passphrase = Hash :: sha256 ( new Buffer ( $ passphrase ) ) ; return ( new PrivateKeyFactory ( ) ) -> fromHexCompressed ( $ passphrase -> getHex ( ) ) ; }
Derive the private key for the given passphrase .