idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
53,500
|
public function addMagentoCss ( $ observer ) { if ( ! Mage :: helper ( 'australia/address' ) -> isAddressValidationEnabled ( ) ) { return ; } $ layout = Mage :: getSingleton ( 'core/layout' ) ; $ head = $ layout -> getBlock ( 'head' ) ; $ skinBaseDir = Mage :: getDesign ( ) -> getSkinBaseDir ( array ( '_package' => 'base' , '_theme' => 'default' ) ) ; $ cssPath = 'prototype/windows/themes/magento.css' ; if ( file_exists ( $ skinBaseDir . DS . 'lib' . DS . $ cssPath ) ) { $ head -> addCss ( 'lib' . DS . $ cssPath ) ; } else { $ head -> addItem ( 'js_css' , $ cssPath ) ; } }
|
The magento . css file is moved into the skin directory in Magento 1 . 7 so we need to look for it in both the new and old locations for backwards compatibility .
|
53,501
|
public function validateCompletedOrderAddress ( Varien_Event_Observer $ observer ) { $ helper = Mage :: helper ( 'australia/address' ) ; if ( ! $ helper -> isValidationOrderSaveEnabled ( ) ) { return ; } try { $ order = $ observer -> getOrder ( ) ; if ( ! $ order || ! $ order -> getShippingAddress ( ) ) { return ; } $ helper -> validateOrderAddress ( $ order ) ; $ order -> save ( ) ; } catch ( Exception $ err ) { Mage :: logException ( $ err ) ; } }
|
After order placement validate the shipping address and store the result .
|
53,502
|
public function validateAdminOrderAddressSave ( Varien_Event_Observer $ observer ) { $ helper = Mage :: helper ( 'australia/address' ) ; if ( ! $ helper -> isValidationOrderSaveEnabled ( ) ) { return ; } $ session = Mage :: getSingleton ( 'adminhtml/session' ) ; $ errors = $ session -> getMessages ( ) -> getErrors ( ) ; if ( count ( $ errors ) > 0 ) { $ session -> addWarning ( 'Address validation has been skipped.' ) ; return ; } try { $ controller = $ observer -> getControllerAction ( ) ; if ( ! $ controller ) { return ; } $ addressId = $ controller -> getRequest ( ) -> getParam ( 'address_id' ) ; $ address = Mage :: getModel ( 'sales/order_address' ) -> load ( $ addressId ) ; if ( $ address -> getAddressType ( ) !== Mage_Sales_Model_Order_Address :: TYPE_SHIPPING ) { return ; } $ order = $ address -> getOrder ( ) ; if ( ! $ order ) { return ; } $ ignoreValidation = $ controller -> getRequest ( ) -> getParam ( 'override_validation' ) ; if ( $ ignoreValidation ) { $ result = array ( Fontis_Australia_Helper_Address :: ADDRESS_OVERRIDE_FLAG => true ) ; $ order -> setAddressValidated ( Fontis_Australia_Helper_Address :: ADDRESS_OVERRIDE ) ; } else { $ result = $ helper -> validateOrderAddress ( $ order ) ; } $ order -> save ( ) ; $ helper -> addValidationMessageToSession ( $ result , $ session ) ; } catch ( Exception $ err ) { Mage :: logException ( $ err ) ; } }
|
After a shipping address is edited validate it and store the result .
|
53,503
|
public function exportAction ( ) { $ orders = $ this -> getRequest ( ) -> getPost ( 'order_ids' , array ( ) ) ; try { $ filePath = Mage :: getModel ( 'australia/shipping_carrier_clickandsend_export_csv' ) -> exportOrders ( $ orders ) ; $ this -> _prepareDownloadResponse ( basename ( $ filePath ) , file_get_contents ( $ filePath ) ) ; } catch ( Exception $ e ) { Mage :: getSingleton ( 'core/session' ) -> addError ( $ e -> getMessage ( ) ) ; $ this -> _redirect ( 'adminhtml/sales_order/index' ) ; } }
|
Export Orders to CSV
|
53,504
|
public function isValidChargeCode ( $ chargeCode ) { $ isStandard = in_array ( $ chargeCode , $ this -> standardChargeCodes ) ; if ( $ isStandard || Mage :: getStoreConfigFlag ( 'doghouse_eparcelexport/charge_codes/allow_custom_charge_codes' ) ) { return true ; } return false ; }
|
Determines whether a given string is a valid eParcel charge code .
|
53,505
|
public function setClient ( DeliveryChoiceClient $ client ) { $ client -> getConfig ( ) -> setPath ( HttpClient :: CURL_OPTIONS . "/" . CURLOPT_TIMEOUT , self :: HTTP_REQUEST_TIMEOUT ) ; $ this -> client = $ client ; }
|
Set the Australia Post Delivery Choices client
|
53,506
|
public function validateAddress ( array $ street , $ state , $ suburb , $ postcode , $ country ) { $ address = array ( 'address_line_1' => strtoupper ( $ street [ 0 ] ) , 'state' => strtoupper ( $ state ) , 'suburb' => strtoupper ( $ suburb ) , 'postcode' => strtoupper ( $ postcode ) , 'country' => strtoupper ( $ country ) , ) ; if ( count ( $ street ) > 1 ) { $ address [ 'address_line_2' ] = strtoupper ( $ street [ 1 ] ) ; } $ helper = Mage :: helper ( 'australia' ) ; $ result = array ( ) ; try { $ result = $ this -> client -> validateAddress ( $ address ) ; $ result = $ result [ 'ValidateAustralianAddressResponse' ] ; $ result [ 'success' ] = true ; $ result [ 'original' ] = $ this -> _getAddressString ( trim ( $ address [ 'address_line_1' ] . ( isset ( $ address [ 'address_line_2' ] ) ? ' ' . $ address [ 'address_line_2' ] : '' ) ) , $ address [ 'suburb' ] , $ address [ 'state' ] , $ address [ 'postcode' ] ) ; if ( ! $ result [ 'ValidAustralianAddress' ] ) { return $ result ; } unset ( $ result [ 'Address' ] [ 'DeliveryPointIdentifier' ] ) ; $ resultAddress = $ result [ 'Address' ] ; $ result [ 'suggestion' ] = $ this -> _getAddressString ( $ resultAddress [ 'AddressLine' ] , $ resultAddress [ 'SuburbOrPlaceOrLocality' ] , $ resultAddress [ 'StateOrTerritory' ] , $ resultAddress [ 'PostCode' ] ) ; $ regionModel = Mage :: getModel ( 'directory/region' ) -> loadByCode ( $ resultAddress [ 'StateOrTerritory' ] , $ resultAddress [ 'Country' ] [ 'CountryCode' ] ) ; $ regionId = $ regionModel -> getId ( ) ; $ result [ 'suggestedAddress' ] = array ( 'street1' => $ resultAddress [ 'AddressLine' ] , 'city' => $ resultAddress [ 'SuburbOrPlaceOrLocality' ] , 'regionId' => $ regionId , 'postcode' => $ resultAddress [ 'PostCode' ] , ) ; $ result [ 'validAddress' ] = $ this -> _checkAddressValidity ( $ result [ 'original' ] , $ result [ 'suggestion' ] ) ; } catch ( BadResponseException $ e ) { $ helper -> logMessage ( "An error occurred while contacting the AusPost Delivery Choices API:\n" . $ e -> getMessage ( ) , Zend_Log :: ERR ) ; $ result [ 'success' ] = false ; } catch ( Exception $ e ) { Mage :: logException ( $ e ) ; $ result [ 'success' ] = false ; } return $ result ; }
|
Converts the customer provided address data into an Australia Post - supported format .
|
53,507
|
protected function getStoreName ( $ order ) { $ storeId = $ order -> getStoreId ( ) ; if ( is_null ( $ storeId ) ) { return $ this -> getOrder ( ) -> getStoreName ( ) ; } $ store = Mage :: app ( ) -> getStore ( $ storeId ) ; $ name = array ( $ store -> getWebsite ( ) -> getName ( ) , $ store -> getGroup ( ) -> getName ( ) , $ store -> getName ( ) ) ; return implode ( ', ' , $ name ) ; }
|
Returns the name of the website store and store view the order was placed in .
|
53,508
|
protected function getTotalQtyItemsOrdered ( $ order ) { $ qty = 0 ; $ orderedItems = $ order -> getItemsCollection ( ) ; foreach ( $ orderedItems as $ item ) { if ( ! $ item -> isDummy ( ) ) { $ qty += ( int ) $ item -> getQtyOrdered ( ) ; } } return $ qty ; }
|
Returns the total quantity of ordered items of the given order .
|
53,509
|
protected function getItemSku ( $ item ) { if ( $ item -> getProductType ( ) == Mage_Catalog_Model_Product_Type :: TYPE_CONFIGURABLE ) { return $ item -> getProductOptionByCode ( 'simple_sku' ) ; } return $ item -> getSku ( ) ; }
|
Returns the sku of the given item dependant on the product type .
|
53,510
|
protected function getItemOrderOptions ( $ item ) { $ result = array ( ) ; if ( $ options = $ item -> getProductOptions ( ) ) { if ( isset ( $ options [ 'options' ] ) ) { $ result = array_merge ( $ result , $ options [ 'options' ] ) ; } if ( isset ( $ options [ 'additional_options' ] ) ) { $ result = array_merge ( $ result , $ options [ 'additional_options' ] ) ; } if ( ! empty ( $ options [ 'attributes_info' ] ) ) { $ result = array_merge ( $ options [ 'attributes_info' ] , $ result ) ; } } return $ result ; }
|
Returns all the product options of the given item including additional_options and attributes_info .
|
53,511
|
protected function getItemTotal ( $ item ) { return $ item -> getRowTotal ( ) - $ item -> getDiscountAmount ( ) + $ item -> getTaxAmount ( ) + $ item -> getWeeeTaxAppliedRowAmount ( ) ; }
|
Calculates and returns the grand total of an item including tax and excluding discount .
|
53,512
|
protected function _convertAdditionalData ( ) { $ details = @ unserialize ( $ this -> getInfo ( ) -> getAdditionalData ( ) ) ; if ( is_array ( $ details ) ) { $ this -> _billerCode = isset ( $ details [ 'biller_code' ] ) ? ( string ) $ details [ 'biller_code' ] : '' ; $ this -> _ref = isset ( $ details [ 'ref' ] ) ? ( string ) $ details [ 'ref' ] : '' ; } else { $ this -> _billerCode = '' ; $ this -> _ref = '' ; } return $ this ; }
|
Gets any additional data saved by the BPAY payment module .
|
53,513
|
public function passive ( $ field = null ) { if ( ! $ field ) { $ field = $ this -> getConfig ( 'dummyField' ) ? : 'email_homepage' ; } $ dummyFields = ( array ) $ field ; $ html = [ ] ; foreach ( $ dummyFields as $ dummyField ) { $ html [ ] = '<div style="display: none">' . $ this -> Form -> control ( $ dummyField , [ 'value' => '' ] ) . '</div>' ; } return implode ( PHP_EOL , $ html ) ; }
|
Add a honey pot trap field . Requires corresponding validation to be activated .
|
53,514
|
protected function _convertAdditionalData ( ) { $ details = @ unserialize ( $ this -> getInfo ( ) -> getAdditionalData ( ) ) ; if ( is_array ( $ details ) ) { $ this -> _accountName = isset ( $ details [ 'account_name' ] ) ? ( string ) $ details [ 'account_name' ] : '' ; $ this -> _accountBSB = isset ( $ details [ 'account_bsb' ] ) ? ( string ) $ details [ 'account_bsb' ] : '' ; $ this -> _accountNumber = isset ( $ details [ 'account_number' ] ) ? ( string ) $ details [ 'account_number' ] : '' ; $ this -> _message = isset ( $ details [ 'message' ] ) ? ( string ) $ details [ 'message' ] : '' ; } else { $ this -> _accountName = '' ; $ this -> _accountBSB = '' ; $ this -> _accountNumber = '' ; $ this -> _message = '' ; } return $ this ; }
|
Converts serialised additional data into a more usable form .
|
53,515
|
public function display ( $ id = null ) { $ captcha = $ this -> Captchas -> get ( $ id ) ; $ captcha = $ this -> Preparer -> prepare ( $ captcha ) ; $ this -> set ( compact ( 'captcha' ) ) ; $ this -> viewBuilder ( ) -> setClassName ( 'Captcha.Captcha' ) ; }
|
Displays a captcha image
|
53,516
|
public function addExportToBulkAction ( $ observer ) { $ block = $ observer -> getBlock ( ) ; if ( $ block instanceof Mage_Adminhtml_Block_Sales_Order_Grid && Mage :: helper ( 'australia/clickandsend' ) -> isClickAndSendEnabled ( ) ) { $ block -> getMassactionBlock ( ) -> addItem ( 'clickandsendexport' , array ( 'label' => $ block -> __ ( 'Export to CSV (Click & Send)' ) , 'url' => $ block -> getUrl ( '*/australia_clickandsend/export' ) ) ) ; } }
|
Event observer . Triggered before an adminhtml widget template is rendered . We use this to add our action to bulk actions in the sales order grid instead of overriding the class .
|
53,517
|
public function getAllSimpleItems ( $ order ) { $ items = array ( ) ; foreach ( $ order -> getAllItems ( ) as $ item ) { if ( $ item -> getProductType ( ) == 'simple' ) { $ items [ ] = $ item ; } } return $ items ; }
|
Get all the simple items in an order .
|
53,518
|
public function getQueryText ( ) { if ( is_null ( $ this -> _queryText ) ) { if ( $ this -> _getRequest ( ) -> getParam ( 'billing' ) ) { $ tmp = $ this -> _getRequest ( ) -> getParam ( 'billing' ) ; $ this -> _queryText = $ tmp [ 'city' ] ; } elseif ( $ this -> _getRequest ( ) -> getParam ( 'shipping' ) ) { $ tmp = $ this -> _getRequest ( ) -> getParam ( 'shipping' ) ; $ this -> _queryText = $ tmp [ 'city' ] ; } else { $ this -> _queryText = $ this -> _getRequest ( ) -> getParam ( 'city' ) ; } $ this -> _queryText = trim ( $ this -> _queryText ) ; if ( Mage :: helper ( 'core/string' ) -> strlen ( $ this -> _queryText ) > self :: MAX_QUERY_LEN ) { $ this -> _queryText = Mage :: helper ( 'core/string' ) -> substr ( $ this -> _queryText , 0 , self :: MAX_QUERY_LEN ) ; } } return $ this -> _queryText ; }
|
Gets the query text for city lookups in the postcode database .
|
53,519
|
public function getValidationStatusDescription ( $ status ) { $ options = $ this -> getValidationStatusOptions ( ) ; if ( ! isset ( $ options [ $ status ] ) ) { $ status = static :: ADDRESS_UNKNOWN ; } return $ options [ $ status ] ; }
|
Returns the label for the given validation status code .
|
53,520
|
public function validate ( array $ street , $ state , $ suburb , $ postcode , $ country ) { try { $ validatorClass = Mage :: getStoreConfig ( self :: XML_PATH_ADDRESS_VALIDATION_BACKEND ) ; if ( ! $ validatorClass ) { Mage :: helper ( 'australia' ) -> logMessage ( 'Address validator class not set' ) ; return array ( ) ; } $ validator = Mage :: getModel ( $ validatorClass ) ; return $ validator -> validateAddress ( $ street , $ state , $ suburb , $ postcode , $ country ) ; } catch ( Exception $ err ) { $ message = "Error validating address\nStreet: " . print_r ( $ street , true ) . "\n" . "State: $state\nSuburb: $suburb\nPostcode: $postcode\nCountry: $country\n" . $ err -> getMessage ( ) . "\n" . $ err -> getTraceAsString ( ) ; Mage :: helper ( 'australia' ) -> logMessage ( $ message ) ; return array ( ) ; } }
|
Validates an address .
|
53,521
|
public function validateOrderAddress ( Mage_Sales_Model_Order $ order ) { $ address = $ order -> getShippingAddress ( ) ; $ countryModel = $ address -> getCountryModel ( ) ; $ result = $ this -> validate ( $ address -> getStreet ( ) , $ address -> getRegionCode ( ) , $ address -> getCity ( ) , $ address -> getPostcode ( ) , $ countryModel -> getName ( ) ) ; if ( ! $ result || ! isset ( $ result [ 'ValidAustralianAddress' ] ) ) { $ status = static :: ADDRESS_UNKNOWN ; } else if ( isset ( $ result [ 'validAddress' ] ) && $ result [ 'validAddress' ] ) { $ status = static :: ADDRESS_VALID ; } else { $ status = static :: ADDRESS_INVALID ; } $ order -> setAddressValidated ( $ status ) ; return $ result ; }
|
Validates the order s address and updates its address valid value .
|
53,522
|
public function addValidationMessageToSession ( array $ result , Mage_Core_Model_Session_Abstract $ session ) { if ( isset ( $ result [ Fontis_Australia_Helper_Address :: ADDRESS_OVERRIDE_FLAG ] ) ) { $ session -> addSuccess ( ' Address successfully overridden without validation.' ) ; } else if ( ! $ result || ! isset ( $ result [ 'ValidAustralianAddress' ] ) ) { $ session -> addWarning ( 'Unable to validate address.' ) ; } else if ( isset ( $ result [ 'validAddress' ] ) && $ result [ 'validAddress' ] ) { $ session -> addSuccess ( ' Address successfully validated.' ) ; } else if ( isset ( $ result [ 'suggestion' ] ) ) { $ session -> addWarning ( "Address is not valid; did you mean: {$result['suggestion']}" ) ; } else { $ session -> addWarning ( 'Address is not valid; no suggestions available.' ) ; } }
|
Adds a status message to the session based on a validation result .
|
53,523
|
public function addExportToBulkAction ( $ observer ) { if ( ! $ observer -> block instanceof Mage_Adminhtml_Block_Sales_Order_Grid ) { return ; } $ observer -> block -> getMassactionBlock ( ) -> addItem ( 'eparcelexport' , array ( 'label' => $ observer -> block -> __ ( 'Export to CSV (eParcel)' ) , 'url' => $ observer -> block -> getUrl ( '*/australia_eparcel/export' ) ) ) ; }
|
Event Observer . Triggered before an adminhtml widget template is rendered . We use this to add our action to bulk actions in the sales order grid instead of overridding the class .
|
53,524
|
public function createAppropriateIterator ( Response $ response ) { $ this -> checkResponseFormat ( $ response ) ; set_error_handler ( function ( ) { } ) ; $ arr = json_decode ( $ response -> getBody ( ) , true , 512 , 1 ) ; restore_error_handler ( ) ; $ objects = [ ] ; foreach ( $ arr [ 'objects' ] as $ object ) { if ( isset ( $ this -> apiEntities [ $ object [ 'type' ] ] ) ) { $ class = $ this -> apiEntities [ $ object [ 'type' ] ] ; } else { $ class = $ this -> apiEntities [ '*' ] ; } $ objects [ ] = new $ class ( $ object ) ; } return new EntityIterator ( $ objects , $ response ) ; }
|
Creates an appropriate Entity from a given Response If no valid Entity can be found for typo of API the Wildcard entity is selected
|
53,525
|
protected function checkResponseFormat ( Response $ response ) { set_error_handler ( function ( ) { } ) ; $ arr = json_decode ( $ response -> getBody ( ) , true , 512 , 1 ) ; restore_error_handler ( ) ; if ( isset ( $ arr [ 'error' ] ) ) { throw new DiffbotException ( 'Diffbot returned error ' . $ arr [ 'errorCode' ] . ': ' . $ arr [ 'error' ] ) ; } $ required = [ 'objects' => 'Objects property missing - cannot extract entity values' , 'request' => 'Request property not found in response!' ] ; foreach ( $ required as $ k => $ v ) { if ( ! isset ( $ arr [ $ k ] ) ) { throw new DiffbotException ( $ v ) ; } } }
|
Makes sure the Diffbot response has all the fields it needs to work properly
|
53,526
|
public function setContainer ( $ container ) { if ( ! is_array ( $ container ) && ! $ container instanceof \ ArrayAccess ) { throw new InvalidArgumentException ( 'array or ArrayAccess Object' , 0 ) ; } $ this -> container = $ container ; return $ this ; }
|
Set the receiving container of the parsed htaccess
|
53,527
|
public function parse ( \ SplFileObject $ file = null , $ optFlags = null , $ rewind = null ) { $ file = ( $ file !== null ) ? $ file : $ this -> file ; $ optFlags = ( $ optFlags !== null ) ? $ optFlags : $ this -> mode ; $ rewind = ( $ rewind !== null ) ? ! ! $ rewind : $ this -> rewind ; if ( ! $ file instanceof \ SplFileObject ) { throw new Exception ( ".htaccess file is not set. You must set it (with Prser::setFile) before calling parse" ) ; } if ( ! $ file -> isReadable ( ) ) { $ path = $ file -> getRealPath ( ) ; throw new Exception ( ".htaccess file '$path'' is not readable" ) ; } if ( $ rewind ) { $ file -> rewind ( ) ; } $ this -> _cpMode = $ optFlags ; $ asArray = ( AS_ARRAY & $ optFlags ) ; if ( $ asArray ) { $ htaccess = array ( ) ; } else { $ htaccess = ( $ this -> container != null ) ? $ this -> container : new HtaccessContainer ( ) ; } while ( $ file -> valid ( ) ) { $ line = $ file -> getCurrentLine ( ) ; $ parsedLine = $ this -> parseLine ( $ line , $ file ) ; if ( ! is_null ( $ parsedLine ) ) { $ htaccess [ ] = $ parsedLine ; } } return $ htaccess ; }
|
Parse a . htaccess file
|
53,528
|
protected function isBlockEnd ( $ line , $ blockName = null ) { $ line = trim ( $ line ) ; $ pattern = '/^\<\/' ; $ pattern .= ( $ blockName ) ? $ blockName : '[^\s\>]+' ; $ pattern .= '\>$/' ; return ( preg_match ( $ pattern , $ line ) > 0 ) ; }
|
Check if line is a Block end
|
53,529
|
protected function parseMultiLine ( $ line , \ SplFileObject $ file , & $ lineBreaks ) { while ( $ this -> isMultiLine ( $ line ) && $ file -> valid ( ) ) { $ lineBreaks [ ] = strlen ( $ line ) ; $ line2 = $ file -> getCurrentLine ( ) ; $ line = rtrim ( $ line , '\\' ) ; $ line = trim ( $ line . $ line2 ) ; } return $ line ; }
|
Parse a Multi Line
|
53,530
|
protected function parseCommentLine ( $ line , $ lineBreaks ) { $ comment = new Comment ( ) ; $ comment -> setText ( $ line ) -> setLineBreaks ( $ lineBreaks ) ; return $ comment ; }
|
Parse a Comment Line
|
53,531
|
protected function parseDirectiveLine ( $ line , \ SplFileObject $ file , $ lineBreaks ) { $ directive = new Directive ( ) ; $ args = $ this -> directiveRegex ( $ line ) ; $ name = array_shift ( $ args ) ; if ( $ name === null ) { $ lineNum = $ file -> key ( ) ; throw new SyntaxException ( $ lineNum , $ line , "Could not parse the name of the directive" ) ; } $ directive -> setName ( $ name ) -> setArguments ( $ args ) -> setLineBreaks ( $ lineBreaks ) ; return $ directive ; }
|
Parse a Directive Line
|
53,532
|
protected function parseBlockLine ( $ line , \ SplFileObject $ file , $ lineBreaks ) { $ block = new Block ( ) ; $ args = $ this -> blockRegex ( $ line ) ; $ name = array_shift ( $ args ) ; if ( $ name === null ) { $ lineNum = $ file -> key ( ) ; throw new SyntaxException ( $ lineNum , $ line , "Could not parse the name of the block" ) ; } $ block -> setName ( $ name ) -> setArguments ( $ args ) -> setLineBreaks ( $ lineBreaks ) ; $ newLine = $ file -> getCurrentLine ( ) ; while ( ! $ this -> isBlockEnd ( $ newLine , $ name ) ) { $ parsedLine = $ this -> parseLine ( $ newLine , $ file ) ; if ( ! is_null ( $ parsedLine ) ) { $ block -> addChild ( $ parsedLine ) ; } $ newLine = $ file -> getCurrentLine ( ) ; } return $ block ; }
|
Parse a Block Line
|
53,533
|
public function from ( $ table ) { if ( $ this -> tableReadOnly ) { throw new Exception \ InvalidArgumentException ( 'Since this object was created with a table and/or schema in the constructor, it is read only.' ) ; } if ( ! is_string ( $ table ) && ! is_array ( $ table ) && ! $ table instanceof TableIdentifier && ! $ table instanceof Select ) { throw new Exception \ InvalidArgumentException ( '$table must be a string, array, an instance of TableIdentifier, or an instance of Select' ) ; } if ( $ table instanceof TableIdentifier ) { $ table = $ table -> getTable ( ) ; } $ this -> table = $ table ; return $ this ; }
|
Create from clause
|
53,534
|
public function columns ( array $ columns , $ prefixColumnsWithTable = false ) { $ this -> columns = $ columns ; if ( $ prefixColumnsWithTable ) { throw new Exception \ InvalidArgumentException ( 'SphinxQL syntax does not support prefixing columns with table name' ) ; } return $ this ; }
|
Specify columns from which to select
|
53,535
|
protected function processSelect ( PlatformInterface $ platform , DriverInterface $ driver = null , ParameterContainer $ parameterContainer = null ) { $ expr = 1 ; $ columns = [ ] ; foreach ( $ this -> columns as $ columnIndexOrAs => $ column ) { $ colName = '' ; if ( $ column === self :: SQL_STAR ) { $ columns [ ] = [ self :: SQL_STAR ] ; continue ; } if ( $ column instanceof Expression ) { $ columnParts = $ this -> processExpression ( $ column , $ platform , $ driver , $ parameterContainer , $ this -> processInfo [ 'paramPrefix' ] . ( ( is_string ( $ columnIndexOrAs ) ) ? $ columnIndexOrAs : 'column' ) ) ; $ colName .= $ columnParts ; } else { $ colName .= $ platform -> quoteIdentifier ( $ column ) ; } $ columnAs = null ; if ( is_string ( $ columnIndexOrAs ) ) { $ columnAs = $ columnIndexOrAs ; } elseif ( stripos ( $ colName , ' as ' ) === false && ! is_string ( $ column ) ) { $ columnAs = 'Expression' . $ expr ++ ; } $ columns [ ] = isset ( $ columnAs ) ? [ $ colName , $ platform -> quoteIdentifier ( $ columnAs ) ] : [ $ colName ] ; } if ( $ this -> table ) { $ tableList = $ this -> table ; if ( is_string ( $ tableList ) && strpos ( $ tableList , ',' ) !== false ) { $ tableList = preg_split ( '#,\s+#' , $ tableList ) ; } elseif ( ! is_array ( $ tableList ) ) { $ tableList = [ $ tableList ] ; } foreach ( $ tableList as & $ table ) { if ( $ table instanceof Select ) { $ table = '(' . $ this -> processSubselect ( $ table , $ platform , $ driver , $ parameterContainer ) . ')' ; } else { $ table = $ platform -> quoteIdentifier ( $ table ) ; } } $ tableList = implode ( ', ' , $ tableList ) ; return [ $ columns , $ tableList ] ; } return [ $ columns ] ; }
|
Process the select part
|
53,536
|
public function setArguments ( array $ array = array ( ) ) { foreach ( $ array as $ arg ) { if ( ! is_scalar ( $ arg ) ) { $ type = gettype ( $ arg ) ; throw new DomainException ( "Arguments array should be an array of scalar, but found $type" ) ; } $ this -> addArgument ( $ arg ) ; } return $ this ; }
|
Set the Directive s arguments
|
53,537
|
public function addArgument ( $ arg , $ unique = false ) { if ( ! is_scalar ( $ arg ) ) { throw new InvalidArgumentException ( 'scalar' , 0 ) ; } if ( strpos ( $ arg , ' ' ) !== false && ( strpos ( $ arg , '"' ) === false ) ) { $ arg = "\"$arg\"" ; } if ( in_array ( $ arg , $ this -> arguments ) && $ unique ) { return $ this ; } $ this -> arguments [ ] = $ arg ; return $ this ; }
|
Add an argument to the Directive arguments array
|
53,538
|
public function removeArgument ( $ arg ) { if ( ( $ name = array_search ( $ arg , $ this -> arguments ) ) !== false ) { unset ( $ this -> arguments [ $ name ] ) ; } return $ this ; }
|
Remove an argument from the Directive s arguments array
|
53,539
|
public function redirect ( $ url , $ code = 302 ) { if ( $ this -> data ( ) -> virtualOwner ) { $ parts = explode ( '#' , $ url ) ; if ( isset ( $ parts [ 1 ] ) ) { $ url = $ parts [ 0 ] . '#' . $ this -> data ( ) -> virtualOwner -> ID ; } } return parent :: redirect ( $ url , $ code ) ; }
|
if this is a virtual request change the hash if set .
|
53,540
|
public function setSamplingRate ( $ samplingRate ) { if ( $ samplingRate <= 0.0 || 1.0 < $ samplingRate ) { throw new \ LogicException ( 'Sampling rate shall be within ]0, 1]' ) ; } $ this -> samplingRate = $ samplingRate ; $ this -> samplingFunction = function ( $ min , $ max ) { return rand ( $ min , $ max ) ; } ; }
|
Actually defines the sampling rate used by the service . If set to 0 . 1 the service will automatically discard 10% of the incoming metrics . It will also automatically flag these as sampled data to statsd .
|
53,541
|
public static function recursiveUnlink ( string $ folder , bool $ remove_folder = true ) : bool { try { self :: emptyFolder ( $ folder ) ; if ( $ remove_folder && rmdir ( $ folder ) === false ) { throw new Exception ( "Error deleting folder: $folder" ) ; } return true ; } catch ( Exception $ e ) { throw $ e ; } }
|
Unlink a folder recursively
|
53,542
|
public function getFieldList ( $ options = [ ] ) { $ _options = [ 'normalize' => true , ] ; $ options = Hash :: merge ( $ _options , $ options ) ; $ list = [ ] ; foreach ( $ this -> config ( ) as $ key => $ value ) { if ( ! in_array ( $ key , $ this -> _presetConfigKeys ) || is_integer ( $ key ) ) { if ( is_integer ( $ key ) ) { $ field = $ value ; } else { $ field = $ key ; } if ( $ options [ 'normalize' ] ) { $ fieldConfig = $ this -> _normalizeField ( $ field ) ; } else { $ fieldConfig = ( ( $ this -> config ( $ field ) == null ) ? [ ] : $ this -> config ( $ field ) ) ; } $ list [ $ field ] = $ fieldConfig ; } } return $ list ; }
|
Returns a list of all registered fields to upload
|
53,543
|
protected function getConfig ( $ services ) { if ( $ this -> config !== null ) { return $ this -> config ; } if ( ! $ services -> has ( 'Config' ) ) { $ this -> config = [ ] ; return $ this -> config ; } $ config = $ services -> get ( 'Config' ) ; if ( ! isset ( $ config [ 'sphinxql' ] ) || ! is_array ( $ config [ 'sphinxql' ] ) ) { $ this -> config = [ ] ; return $ this -> config ; } $ config = $ config [ 'sphinxql' ] ; if ( ! isset ( $ config [ 'adapters' ] ) || ! is_array ( $ config [ 'adapters' ] ) ) { $ this -> config = [ ] ; return $ this -> config ; } $ this -> config = $ config [ 'adapters' ] ; return $ this -> config ; }
|
Get db configuration if any
|
53,544
|
public function createServiceWithName ( ServiceLocatorInterface $ services , $ name , $ requestedName ) { $ config = $ this -> getConfig ( $ services ) ; return AdapterServiceFactory :: factory ( $ config [ $ requestedName ] ) ; }
|
Create a DB adapter
|
53,545
|
public function isPreparedStatementUsed ( ) { if ( $ this -> executeMode === self :: QUERY_MODE_AUTO ) { if ( $ this -> getAdapter ( ) -> getDriver ( ) instanceof ZendMysqliDriver ) { return false ; } return true ; } if ( $ this -> executeMode === self :: QUERY_MODE_PREPARED ) { return true ; } return false ; }
|
Are we using prepared statement?
|
53,546
|
public function setLineBreaks ( array $ lineBreaks ) { foreach ( $ lineBreaks as $ lb ) { if ( ! is_int ( $ lb ) ) { throw new DomainException ( "lineBreaks array is expected to contain only integers" ) ; } $ this -> lineBreaks [ ] = $ lb ; } return $ this ; }
|
Set the line breaks
|
53,547
|
public function quoteTrustedValue ( $ value ) { if ( is_int ( $ value ) ) { return ( string ) $ value ; } elseif ( is_float ( $ value ) ) { return $ this -> floatConversion ? $ this -> toFloatSinglePrecision ( $ value ) : ( string ) $ value ; } elseif ( is_null ( $ value ) ) { return 'NULL' ; } return parent :: quoteTrustedValue ( $ value ) ; }
|
Quotes trusted value
|
53,548
|
public function setArguments ( array $ arguments ) { foreach ( $ arguments as $ arg ) { if ( ! is_scalar ( $ arg ) ) { $ type = gettype ( $ arg ) ; throw new DomainException ( "Arguments array should be an array of scalar, but found $type" ) ; } } $ this -> arguments = $ arguments ; return $ this ; }
|
Set the block s arguments
|
53,549
|
public function addArgument ( $ arg ) { if ( ! is_scalar ( $ arg ) ) { throw new InvalidArgumentException ( 'scalar' , 0 ) ; } if ( ! in_array ( $ arg , $ this -> arguments ) ) { $ this -> arguments [ ] = $ arg ; } return $ this ; }
|
Add an argument to the Block arguments array
|
53,550
|
public function removeArgument ( $ arg ) { if ( ( $ key = array_search ( $ arg , $ this -> arguments ) ) !== false ) { unset ( $ this -> arguments [ $ key ] ) ; } return $ this ; }
|
Remove an argument from the Block arguments array
|
53,551
|
public function removeChild ( TokenInterface $ child , $ strict = true ) { $ index = array_search ( $ child , $ this -> children , ! ! $ strict ) ; if ( $ index !== false ) { unset ( $ this -> children [ $ index ] ) ; } return $ this ; }
|
Remove a child from this block
|
53,552
|
function jsonSerialize ( ) { $ array = [ 'arguments' => $ this -> arguments , 'children' => array ( ) ] ; foreach ( $ this -> children as $ child ) { if ( ! $ child instanceof WhiteLine & ! $ child instanceof Comment ) { $ array [ 'children' ] [ $ child -> getName ( ) ] = $ child -> jsonSerialize ( ) ; } } return $ array ; }
|
Return an array ready for serialization . Ignores comments and whitelines
|
53,553
|
public function toArray ( ) { $ array = [ 'name' => $ this -> getName ( ) , 'arguments' => $ this -> getArguments ( ) , 'children' => array ( ) ] ; foreach ( $ this -> children as $ child ) { $ array [ 'children' ] [ ] = $ child -> toArray ( ) ; } return $ array ; }
|
Get the array representation of the Token
|
53,554
|
public static function getInstance ( $ id ) { if ( empty ( self :: $ instances [ $ id ] ) ) { self :: $ instances [ $ id ] = new self ; } return self :: $ instances [ $ id ] ; }
|
Returns a reference to a global Registry object only creating it if it doesn t already exist .
|
53,555
|
public function loadArray ( $ array , $ flattened = false , $ separator = null ) { if ( ! $ flattened ) { $ this -> bindData ( $ this -> data , $ array ) ; return $ this ; } foreach ( $ array as $ k => $ v ) { $ this -> set ( $ k , $ v , $ separator ) ; } return $ this ; }
|
Load an associative array of values into the default namespace
|
53,556
|
public function append ( $ path , $ value ) { $ result = null ; $ nodes = array_values ( array_filter ( explode ( '.' , $ path ) , 'strlen' ) ) ; if ( $ nodes ) { $ node = $ this -> data ; for ( $ i = 0 , $ n = \ count ( $ nodes ) - 1 ; $ i <= $ n ; $ i ++ ) { if ( \ is_object ( $ node ) ) { if ( ! isset ( $ node -> { $ nodes [ $ i ] } ) && ( $ i !== $ n ) ) { $ node -> { $ nodes [ $ i ] } = new \ stdClass ; } $ node = & $ node -> { $ nodes [ $ i ] } ; } elseif ( \ is_array ( $ node ) ) { if ( ( $ i !== $ n ) && ! isset ( $ node [ $ nodes [ $ i ] ] ) ) { $ node [ $ nodes [ $ i ] ] = new \ stdClass ; } $ node = & $ node [ $ nodes [ $ i ] ] ; } } if ( ! \ is_array ( $ node ) ) { $ node = get_object_vars ( $ node ) ; } $ node [ ] = $ value ; $ result = $ value ; } return $ result ; }
|
Append value to a path in registry
|
53,557
|
public function remove ( $ path ) { if ( ! strpos ( $ path , $ this -> separator ) ) { $ result = ( isset ( $ this -> data -> $ path ) && $ this -> data -> $ path !== null && $ this -> data -> $ path !== '' ) ? $ this -> data -> $ path : null ; unset ( $ this -> data -> $ path ) ; return $ result ; } $ nodes = array_values ( array_filter ( explode ( $ this -> separator , $ path ) , 'strlen' ) ) ; if ( ! $ nodes ) { return ; } $ node = $ this -> data ; $ parent = null ; for ( $ i = 0 , $ n = \ count ( $ nodes ) - 1 ; $ i < $ n ; $ i ++ ) { if ( \ is_object ( $ node ) ) { if ( ! isset ( $ node -> { $ nodes [ $ i ] } ) && ( $ i !== $ n ) ) { continue ; } $ parent = & $ node ; $ node = $ node -> { $ nodes [ $ i ] } ; continue ; } if ( \ is_array ( $ node ) ) { if ( ( $ i !== $ n ) && ! isset ( $ node [ $ nodes [ $ i ] ] ) ) { continue ; } $ parent = & $ node ; $ node = $ node [ $ nodes [ $ i ] ] ; continue ; } } switch ( true ) { case \ is_object ( $ node ) : $ result = isset ( $ node -> { $ nodes [ $ i ] } ) ? $ node -> { $ nodes [ $ i ] } : null ; unset ( $ parent -> { $ nodes [ $ i ] } ) ; break ; case \ is_array ( $ node ) : $ result = isset ( $ node [ $ nodes [ $ i ] ] ) ? $ node [ $ nodes [ $ i ] ] : null ; unset ( $ parent [ $ nodes [ $ i ] ] ) ; break ; default : $ result = null ; break ; } return $ result ; }
|
Delete a registry value
|
53,558
|
public function flatten ( $ separator = null ) { $ array = array ( ) ; if ( empty ( $ separator ) ) { $ separator = $ this -> separator ; } $ this -> toFlatten ( $ separator , $ this -> data , $ array ) ; return $ array ; }
|
Dump to one dimension array .
|
53,559
|
public function setSkipMode ( string $ mode ) : ZipInterface { $ mode = strtoupper ( $ mode ) ; if ( ! in_array ( $ mode , $ this -> supported_skip_modes ) ) { throw new ZipException ( "Unsupported skip mode: $mode" ) ; } $ this -> skip_mode = $ mode ; return $ this ; }
|
Set files to skip
|
53,560
|
public function addZip ( Zip $ zip ) : string { $ id = UniqueId :: generate ( 32 ) ; $ this -> zip_archives [ $ id ] = $ zip ; return $ id ; }
|
Add a Zip object to manager and return its id
|
53,561
|
public function removeZip ( Zip $ zip ) : bool { $ archive_key = array_search ( $ zip , $ this -> zip_archives , true ) ; if ( $ archive_key === false ) { throw new ZipException ( "Archive not found" ) ; } unset ( $ this -> zip_archives [ $ archive_key ] ) ; return true ; }
|
Remove a Zip object from manager
|
53,562
|
public function removeZipById ( string $ id ) : bool { if ( isset ( $ this -> zip_archives [ $ id ] ) === false ) { throw new ZipException ( "Archive: $id not found" ) ; } unset ( $ this -> zip_archives [ $ id ] ) ; return true ; }
|
Remove a Zip object from manager by Zip id
|
53,563
|
public function listZips ( ) : array { return array_column ( array_map ( function ( $ key , $ archive ) { return [ "key" => $ key , "file" => $ archive -> getZipFile ( ) ] ; } , array_keys ( $ this -> zip_archives ) , $ this -> zip_archives ) , "file" , "key" ) ; }
|
Get a list of all registered Zips filenames as an array
|
53,564
|
public function getZip ( string $ id ) : Zip { if ( array_key_exists ( $ id , $ this -> zip_archives ) === false ) { throw new ZipException ( "Archive id $id not found" ) ; } return $ this -> zip_archives [ $ id ] ; }
|
Get a Zip object by Id
|
53,565
|
public function getPath ( ) : array { return array_column ( array_map ( function ( $ key , $ archive ) { return [ "key" => $ key , "path" => $ archive -> getPath ( ) ] ; } , array_keys ( $ this -> zip_archives ) , $ this -> zip_archives ) , "path" , "key" ) ; }
|
Get a list of paths used by Zips
|
53,566
|
public function setMask ( int $ mask ) : ZipManager { try { foreach ( $ this -> zip_archives as $ archive ) { $ archive -> setMask ( $ mask ) ; } return $ this ; } catch ( ZipException $ ze ) { throw $ ze ; } }
|
Set default file mask for all Zips
|
53,567
|
public function getMask ( ) : array { return array_column ( array_map ( function ( $ key , $ archive ) { return [ "key" => $ key , "mask" => $ archive -> getMask ( ) ] ; } , array_keys ( $ this -> zip_archives ) , $ this -> zip_archives ) , "mask" , "key" ) ; }
|
Get a list of masks from Zips
|
53,568
|
public function listFiles ( ) : array { try { return array_column ( array_map ( function ( $ key , $ archive ) { return [ "key" => $ key , "files" => $ archive -> listFiles ( ) ] ; } , array_keys ( $ this -> zip_archives ) , $ this -> zip_archives ) , "files" , "key" ) ; } catch ( ZipException $ ze ) { throw $ ze ; } }
|
Get a list of files in Zips
|
53,569
|
public function extract ( string $ destination , bool $ separate = true , $ files = null ) : bool { try { foreach ( $ this -> zip_archives as $ archive ) { $ local_path = substr ( $ destination , - 1 ) == '/' ? $ destination : $ destination . '/' ; $ local_file = pathinfo ( $ archive -> getZipFile ( ) ) ; $ local_destination = $ separate ? ( $ local_path . $ local_file [ 'filename' ] ) : $ destination ; $ archive -> extract ( $ local_destination , $ files ) ; } return true ; } catch ( ZipException $ ze ) { throw $ ze ; } }
|
Extract Zips to common destination
|
53,570
|
public function merge ( string $ output_zip_file , bool $ separate = true ) : bool { $ pathinfo = pathinfo ( $ output_zip_file ) ; $ temporary_folder = $ pathinfo [ 'dirname' ] . "/" . ManagerTools :: getTemporaryFolder ( ) ; try { $ this -> extract ( $ temporary_folder , $ separate ) ; $ zip = Zip :: create ( $ output_zip_file ) ; $ zip -> add ( $ temporary_folder , true ) -> close ( ) ; ManagerTools :: recursiveUnlink ( $ temporary_folder ) ; return true ; } catch ( ZipException $ ze ) { throw $ ze ; } catch ( Exception $ e ) { throw $ e ; } }
|
Merge multiple Zips into one
|
53,571
|
public function add ( $ file_name_or_array , bool $ flatten_root_folder = false ) : ZipManager { try { foreach ( $ this -> zip_archives as $ archive ) { $ archive -> add ( $ file_name_or_array , $ flatten_root_folder ) ; } return $ this ; } catch ( ZipException $ ze ) { throw $ ze ; } }
|
Add a file to all registered Zips
|
53,572
|
public function delete ( $ file_name_or_array ) : ZipManager { try { foreach ( $ this -> zip_archives as $ archive ) { $ archive -> delete ( $ file_name_or_array ) ; } return $ this ; } catch ( ZipException $ ze ) { throw $ ze ; } }
|
Delete a file from any registered Zip
|
53,573
|
public function close ( ) : bool { try { foreach ( $ this -> zip_archives as $ archive ) { $ archive -> close ( ) ; } return true ; } catch ( ZipException $ ze ) { throw $ ze ; } }
|
Close all Zips
|
53,574
|
public static function getFormat ( $ type , array $ options = array ( ) ) { $ type = strtolower ( preg_replace ( '/[^A-Z0-9_]/i' , '' , $ type ) ) ; if ( ! isset ( self :: $ formatInstances [ $ type ] ) ) { $ localNamespace = __NAMESPACE__ . '\\Format' ; $ namespace = isset ( $ options [ 'format_namespace' ] ) ? $ options [ 'format_namespace' ] : $ localNamespace ; $ class = $ namespace . '\\' . ucfirst ( $ type ) ; if ( ! class_exists ( $ class ) ) { if ( $ namespace === $ localNamespace ) { throw new \ InvalidArgumentException ( sprintf ( 'Unable to load format class for type "%s".' , $ type ) , 500 ) ; } $ class = $ localNamespace . '\\' . ucfirst ( $ type ) ; if ( ! class_exists ( $ class ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unable to load format class for type "%s".' , $ type ) , 500 ) ; } } self :: $ formatInstances [ $ type ] = new $ class ; } return self :: $ formatInstances [ $ type ] ; }
|
Returns an AbstractRegistryFormat object only creating it if it doesn t already exist .
|
53,575
|
public function search ( $ name , $ type = null , $ deepSearch = true ) { $ array = $ this -> getArrayCopy ( ) ; foreach ( $ array as $ token ) { if ( fnmatch ( $ name , $ token -> getName ( ) ) ) { if ( $ type === null ) { return $ token ; } if ( $ token -> getTokenType ( ) === $ type ) { return $ token ; } } if ( $ token instanceof Block && $ token -> hasChildren ( ) && $ deepSearch ) { if ( $ res = $ this -> deepSearch ( $ token , $ name , $ type ) ) { return $ res ; } } } return null ; }
|
Search this object for a Token with a specific name and return the first match
|
53,576
|
public function txtSerialize ( $ indentation = null , $ ignoreWhiteLines = null , $ ignoreComments = false ) { $ array = $ this -> getArrayCopy ( ) ; $ otp = '' ; $ this -> indentation = ( is_null ( $ indentation ) ) ? $ this -> indentation : $ indentation ; $ ignoreWhiteLines = ( is_null ( $ ignoreWhiteLines ) ) ? $ this -> ignoreWhiteLines : $ ignoreWhiteLines ; $ ignoreComments = ( is_null ( $ ignoreComments ) ) ? $ this -> ignoreCommentss : $ ignoreComments ; foreach ( $ array as $ num => $ token ) { $ otp .= $ this -> txtSerializeToken ( $ token , 0 , ! ! $ ignoreWhiteLines , ! ! $ ignoreComments ) ; } $ otp = rtrim ( $ otp ) ; $ otp .= PHP_EOL ; return $ otp ; }
|
Returns a representation of the htaccess ready for inclusion in a file
|
53,577
|
public function slice ( $ offset , $ length = null , $ preserveKeys = false , $ asArray = false ) { if ( ! is_int ( $ offset ) ) { throw new InvalidArgumentException ( 'integer' , 0 ) ; } if ( ! is_null ( $ length ) && ! is_int ( $ length ) ) { throw new InvalidArgumentException ( 'integer' , 1 ) ; } $ preserveKeys = ! ! $ preserveKeys ; $ array = $ this -> getArrayCopy ( ) ; $ newArray = array_slice ( $ array , $ offset , $ length , $ preserveKeys ) ; return ( ! ! $ asArray ) ? $ newArray : new self ( $ newArray ) ; }
|
Returns the sequence of elements as specified by the offset and length parameters .
|
53,578
|
public function splice ( $ offset , $ length = null , $ replacement = array ( ) ) { if ( ! is_int ( $ offset ) ) { throw new InvalidArgumentException ( 'integer' , 0 ) ; } if ( ! is_null ( $ length ) && ! is_int ( $ length ) ) { throw new InvalidArgumentException ( 'integer' , 1 ) ; } if ( ! is_array ( $ replacement ) && ! $ replacement instanceof \ ArrayAccess ) { throw new InvalidArgumentException ( 'integer' , 2 ) ; } $ array = $ this -> getArrayCopy ( ) ; $ spliced = array_splice ( $ array , $ offset , $ length , $ replacement ) ; $ this -> exchangeArray ( $ array ) ; return $ spliced ; }
|
Removes the elements designated by offset and length and replaces them with the elements of the replacement array if supplied .
|
53,579
|
public function getAnchor ( ) { $ linkedElement = $ this -> LinkedElement ( ) ; if ( $ linkedElement && $ linkedElement -> exists ( ) ) { return $ linkedElement -> getAnchor ( ) ; } return 'e' . $ this -> ID ; }
|
Get a unique anchor name .
|
53,580
|
public function forTemplate ( $ holder = true ) { if ( $ linked = $ this -> LinkedElement ( ) ) { return $ linked -> forTemplate ( $ holder ) ; } return null ; }
|
Override to render template based on LinkedElement
|
53,581
|
public function setMask ( int $ mask ) : ZipInterface { $ mask = filter_var ( $ mask , FILTER_VALIDATE_INT , [ "options" => [ "max_range" => 0777 , "default" => 0777 ] , 'flags' => FILTER_FLAG_ALLOW_OCTAL ] ) ; $ this -> mask = $ mask ; return $ this ; }
|
Set the mask of the extraction folder
|
53,582
|
public function setPassword ( string $ password ) : ZipInterface { $ this -> password = $ password ; $ this -> getArchive ( ) -> setPassword ( $ password ) ; return $ this ; }
|
Set zip password
|
53,583
|
public function setNum ( $ num = 20 ) { if ( ! is_numeric ( $ num ) && $ num !== self :: SEARCH_ALL ) { throw new \ InvalidArgumentException ( 'Argument can only be numeric or "all" to return all results.' ) ; } $ this -> otherOptions [ 'num' ] = $ num ; return $ this ; }
|
Number of results to return . Default is 20 . To return all results in the search pass num = all .
|
53,584
|
public function onBeforeDelete ( ) { if ( Versioned :: get_reading_mode ( ) == 'Stage.Stage' ) { $ firstVirtual = false ; $ allVirtual = $ this -> getVirtualElements ( ) ; if ( $ this -> getPublishedVirtualElements ( ) -> Count ( ) > 0 ) { $ firstVirtual = $ this -> getPublishedVirtualElements ( ) -> First ( ) ; $ wasPublished = true ; } elseif ( $ allVirtual -> Count ( ) > 0 ) { $ firstVirtual = $ this -> getVirtualElements ( ) -> First ( ) ; $ wasPublished = false ; } if ( $ firstVirtual ) { $ clone = $ this -> owner -> duplicate ( false ) ; $ clone -> ParentID = $ firstVirtual -> ParentID ; $ clone -> Sort = $ firstVirtual -> Sort ; $ clone -> write ( ) ; if ( $ wasPublished ) { $ clone -> doPublish ( ) ; $ firstVirtual -> doUnpublish ( ) ; } foreach ( $ allVirtual as $ virtual ) { if ( $ virtual -> ID == $ firstVirtual -> ID ) { continue ; } $ pub = false ; if ( $ virtual -> isPublished ( ) ) { $ pub = true ; } $ virtual -> LinkedElementID = $ clone -> ID ; $ virtual -> write ( ) ; if ( $ pub ) { $ virtual -> doPublish ( ) ; } } $ firstVirtual -> delete ( ) ; } } }
|
Ensure that if there are elements that are virtualised from this element that we move the original element to replace one of the virtual elements
|
53,585
|
public function getUsage ( ) { $ usage = new ArrayList ( ) ; if ( $ page = $ this -> getPage ( ) ) { $ usage -> push ( $ page ) ; if ( $ this -> virtualOwner ) { $ page -> setField ( 'ElementType' , 'Linked' ) ; } else { $ page -> setField ( 'ElementType' , 'Master' ) ; } } $ linkedElements = ElementVirtual :: get ( ) -> filter ( 'LinkedElementID' , $ this -> ID ) ; foreach ( $ linkedElements as $ element ) { $ area = $ element -> Parent ( ) ; if ( $ area instanceof ElementalArea && $ page = $ area -> getOwnerPage ( ) ) { $ page -> setField ( 'ElementType' , 'Linked' ) ; $ usage -> push ( $ page ) ; } } $ usage -> removeDuplicates ( ) ; return $ usage ; }
|
get all pages where this element is used
|
53,586
|
protected function bindParametersFromContainer ( ) { if ( $ this -> parametersBound ) { return ; } $ parameters = $ this -> parameterContainer -> getNamedArray ( ) ; foreach ( $ parameters as $ name => & $ value ) { $ type = null ; if ( $ this -> parameterContainer -> offsetHasErrata ( $ name ) ) { switch ( $ this -> parameterContainer -> offsetGetErrata ( $ name ) ) { case ParameterContainer :: TYPE_INTEGER : $ type = \ PDO :: PARAM_INT ; break ; case ParameterContainer :: TYPE_NULL : $ type = \ PDO :: PARAM_NULL ; break ; case ParameterContainer :: TYPE_DOUBLE : $ value = ( float ) $ value ; break ; case ParameterContainer :: TYPE_LOB : $ type = \ PDO :: PARAM_LOB ; break ; } } $ parameter = is_int ( $ name ) ? ( $ name + 1 ) : $ name ; $ this -> resource -> bindParam ( $ parameter , $ value , $ type ) ; } }
|
Bind parameters from container
|
53,587
|
public function release ( $ version = 'dev-master' ) { $ package = "youzanyun/open-sdk" ; list ( $ vendor , $ name ) = explode ( '/' , $ package ) ; if ( empty ( $ vendor ) || empty ( $ name ) ) { return ; } $ this -> _mkdir ( 'release' ) ; $ this -> taskExec ( "composer create-project {$package} {$name} {$version}" ) -> dir ( __DIR__ . '/release' ) -> arg ( '--prefer-dist' ) -> arg ( '--no-dev' ) -> run ( ) ; $ this -> taskExec ( 'composer remove composer/installers --update-no-dev' ) -> dir ( __DIR__ . "/release/{$name}" ) -> run ( ) ; $ this -> taskExec ( 'composer dump-autoload --optimize' ) -> dir ( __DIR__ . "/release/{$name}" ) -> run ( ) ; $ zipFile = "release/{$vendor}-{$name}.zip" ; $ this -> _remove ( $ zipFile ) ; $ this -> taskPack ( $ zipFile ) -> addDir ( $ name , "release/{$name}" ) -> run ( ) ; if ( ! empty ( $ name ) ) { $ this -> _deleteDir ( "release/{$name}" ) ; } }
|
Creates release zip
|
53,588
|
public static function get ( int $ code ) : string { if ( array_key_exists ( $ code , self :: ZIP_STATUS_CODES ) ) return self :: ZIP_STATUS_CODES [ $ code ] ; else return sprintf ( 'Unknown status %s' , $ code ) ; }
|
Get status from zip status code
|
53,589
|
public function getEstimatedDate ( ) { $ date = $ this -> getOrDefault ( 'estimatedDate' , $ this -> getDate ( ) ) ; return ( class_exists ( '\Carbon\Carbon' ) ) ? new \ Carbon \ Carbon ( $ date , 'GMT' ) : $ date ; }
|
If an article s date is ambiguous Diffbot will attempt to estimate a more specific timestamp using various factors . This will not be generated for articles older than two days or articles without an identified date .
|
53,590
|
public function from ( $ table ) { if ( $ table instanceof TableIdentifier ) { $ table = $ table -> getTable ( ) ; } $ this -> table = $ table ; return $ this ; }
|
Create from statement
|
53,591
|
public function getDownloadUrl ( $ type = "json" ) { switch ( $ type ) { case "json" : return $ this -> data [ 'downloadJson' ] ; case "debug" : return $ this -> data [ 'downloadUrls' ] ; case "csv" : return rtrim ( $ this -> data [ 'downloadJson' ] , '.json' ) . '.csv' ; default : break ; } throw new \ InvalidArgumentException ( 'Only json, debug, or csv download link available. You asked for: ' . $ type ) ; }
|
Returns the link to the dataset the job produced .
|
53,592
|
public function setText ( $ text ) { if ( ! is_string ( $ text ) ) { throw new InvalidArgumentException ( 'string' , 0 ) ; } $ text = trim ( $ text ) ; if ( strpos ( $ text , '#' ) !== 0 ) { $ text = '# ' . $ text ; } $ this -> text = $ text ; return $ this ; }
|
Set the Comment Text
|
53,593
|
public function setUrlCrawlPatterns ( array $ pattern = null ) { $ this -> otherOptions [ 'urlCrawlPattern' ] = ( $ pattern === null ) ? null : implode ( "||" , array_map ( function ( $ item ) { return urlencode ( $ item ) ; } , $ pattern ) ) ; return $ this ; }
|
Array of strings to limit pages crawled to those whose URLs contain any of the content strings .
|
53,594
|
public function setPageProcessPatterns ( array $ pattern ) { $ this -> otherOptions [ 'pageProcessPattern' ] = implode ( "||" , array_map ( function ( $ item ) { return urlencode ( $ item ) ; } , $ pattern ) ) ; return $ this ; }
|
Specify || - separated strings to limit pages processed to those whose HTML contains any of the content strings .
|
53,595
|
public function notify ( $ string ) { if ( filter_var ( $ string , FILTER_VALIDATE_EMAIL ) ) { $ this -> otherOptions [ 'notifyEmail' ] = $ string ; return $ this ; } if ( filter_var ( $ string , FILTER_VALIDATE_URL ) ) { $ this -> otherOptions [ 'notifyWebhook' ] = urlencode ( $ string ) ; return $ this ; } throw new InvalidArgumentException ( 'Only valid email or URL accepted! You provided: ' . $ string ) ; }
|
If input is email address end a message to this email address when the crawl hits the maxToCrawl or maxToProcess limit or when the crawl completes .
|
53,596
|
public function setCrawlDelay ( $ input = 0.25 ) { if ( ! is_numeric ( $ input ) ) { throw new InvalidArgumentException ( 'Input must be numeric.' ) ; } $ input = ( $ input < 0 ) ? 0.25 : $ input ; $ this -> otherOptions [ 'crawlDelay' ] = ( float ) $ input ; return $ this ; }
|
Wait this many seconds between each URL crawled from a single IP address . Specify the number of seconds as an integer or floating - point number .
|
53,597
|
public function getUrlReportUrl ( $ num = null ) { $ this -> otherOptions [ 'type' ] = 'urls' ; if ( ! empty ( $ num ) && is_numeric ( $ num ) ) { $ this -> otherOptions [ 'num' ] = $ num ; } $ url = $ this -> apiUrl . '/data' ; $ url .= '?token=' . $ this -> diffbot -> getToken ( ) ; if ( $ this -> getName ( ) ) { $ url .= '&name=' . $ this -> getName ( ) ; if ( ! empty ( $ this -> otherOptions ) ) { foreach ( $ this -> otherOptions as $ option => $ value ) { $ url .= '&' . $ option . '=' . $ value ; } } } return $ url ; }
|
Sets the request type to urls to retrieve the URL Report URL for understanding diagnostic data of URLs
|
53,598
|
public function setHttpClient ( Client $ client = null ) { if ( $ client === null ) { $ client = new Client ( HttpClientDiscovery :: find ( ) , MessageFactoryDiscovery :: find ( ) ) ; } $ this -> client = $ client ; return $ this ; }
|
Sets the client to be used for querying the API endpoints
|
53,599
|
public function setEntityFactory ( EntityFactory $ factory = null ) { if ( $ factory === null ) { $ factory = new Entity ( ) ; } $ this -> factory = $ factory ; return $ this ; }
|
Sets the Entity Factory which will create the Entities from Responses
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.