idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
32,700
public function getUnitTotal ( ) { $ total = $ this -> UnitPrice + $ this -> UnitTax ; $ this -> extend ( "updateUnitTotal" , $ total ) ; return $ total ; }
Get the total price and tax for a single unit
32,701
public function getSubTotal ( ) { $ total = $ this -> UnitPrice * $ this -> Quantity ; $ this -> extend ( "updateSubTotal" , $ total ) ; return $ total ; }
Get the value of this item minus any tax
32,702
public function getTaxTotal ( ) { $ total = $ this -> UnitTax * $ this -> Quantity ; $ this -> extend ( "updateTaxTotal" , $ total ) ; return $ total ; }
Get the total amount of tax for a single unit of this item
32,703
public function Image ( ) { $ product = $ this -> FindStockItem ( ) ; if ( $ product && method_exists ( $ product , "SortedImages" ) ) { return $ product -> SortedImages ( ) -> first ( ) ; } elseif ( $ product && method_exists ( $ product , "Images" ) ) { return $ product -> Images ( ) -> first ( ) ; } elseif ( $ product && method_exists ( $ product , "Image" ) && $ product -> Image ( ) -> exists ( ) ) { return $ product -> Image ( ) ; } }
Get an image object associated with this line item . By default this is retrieved from the base product .
32,704
public function getCustomisationList ( ) { $ return = [ ] ; $ items = $ this -> Customisations ( ) ; if ( $ items && $ items -> exists ( ) ) { foreach ( $ items as $ item ) { $ return [ ] = $ item -> Title . ': ' . $ item -> Value ; } } $ this -> extend ( "updateCustomisationList" , $ return ) ; return implode ( ", " , $ return ) ; }
Provide a string of customisations seperated by a comma but not including a price
32,705
public function getCustomisationAndPriceList ( ) { $ return = [ ] ; $ items = $ this -> Customisations ( ) ; if ( $ items && $ items -> exists ( ) ) { foreach ( $ items as $ item ) { $ return [ ] = $ item -> Title . ': ' . $ item -> Value . ' (' . $ item -> dbObject ( "Price" ) -> Nice ( ) . ')' ; } } $ this -> extend ( "updateCustomisationAndPriceList" , $ return ) ; return implode ( ", " , $ return ) ; }
Provide a string of customisations seperated by a comma and including a price
32,706
public function CustomisationHTML ( ) { $ return = HTMLText :: create ( ) ; $ items = $ this -> Customisations ( ) ; $ html = "" ; if ( $ items && $ items -> exists ( ) ) { foreach ( $ items as $ item ) { $ html .= $ item -> Title . ': ' . $ item -> Value . ";<br/>" ; } } $ return -> setValue ( $ html ) ; $ this -> extend ( "updateCustomisationHTML" , $ return ) ; return $ return ; }
Get list of customisations rendering into a basic HTML string
32,707
public function Match ( $ relation_name = null , $ relation_col = "StockID" , $ match_col = "StockID" ) { if ( ! $ relation_name && ! $ this -> ProductClass ) { $ relation_name = "Product" ; } elseif ( ! $ relation_name && $ this -> ProductClass ) { $ relation_name = $ this -> ProductClass ; } return $ relation_name :: get ( ) -> filter ( $ relation_col , $ this -> $ match_col ) -> first ( ) ; }
Match this item to another object in the Database by the provided details .
32,708
public function checkStockLevel ( $ qty ) { $ stock_param = $ this -> config ( ) -> get ( "stock_param" ) ; $ item = $ this -> Match ( ) ; $ stock = ( $ item -> $ stock_param ) ? $ item -> $ stock_param : 0 ; $ return = $ stock - $ qty ; $ this -> extend ( "updateCheckStockLevel" , $ return ) ; return $ return ; }
Check stock levels for this item will return the actual number of remaining stock after removing the current quantity
32,709
public function canCreate ( $ member = null , $ context = [ ] ) { $ extended = $ this -> extend ( 'canCreate' , $ member ) ; if ( $ extended && $ extended !== null ) { return $ extended ; } return true ; }
Anyone can create an order item
32,710
public function duplicate ( $ doWrite = true , $ manyMany = "many_many" ) { $ clone = parent :: duplicate ( $ doWrite ) ; if ( $ doWrite ) { foreach ( $ this -> Customisations ( ) as $ customisation ) { $ new_item = $ customisation -> duplicate ( false ) ; $ new_item -> ParentID = $ clone -> ID ; $ new_item -> write ( ) ; } } return $ clone ; }
Overwrite default duplicate function
32,711
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ key = base64_encode ( json_encode ( $ this -> Customisations ( ) -> map ( "Title" , "Value" ) -> toArray ( ) ) ) ; $ this -> Key = $ this -> StockID . ':' . $ key ; }
Pre - write tasks
32,712
public function onAfterWrite ( ) { parent :: onAfterWrite ( ) ; if ( $ this -> Customisation ) { $ data = unserialize ( $ this -> Customisation ) ; if ( $ data instanceof ArrayList ) { foreach ( $ data as $ data_item ) { $ data_item -> ParentID = $ this -> ID ; $ data_item -> write ( ) ; } $ this -> Customisation = null ; $ this -> write ( ) ; } } }
Perform post - DB write functions
32,713
public function main ( ) { $ result = array ( ) ; if ( ! isset ( $ this -> _file ) && count ( $ this -> _filesets ) == 0 ) { throw new BuildException ( "Missing either a nested fileset or attribute 'file' set" ) ; } if ( ! isset ( $ this -> _optfile ) || ( $ string = file_get_contents ( $ this -> _optfile ) ) === false ) { throw new BuildException ( sprintf ( 'Unable to open optfile "%1$s"' , $ this -> _optfile ) ) ; } if ( ( $ options = unserialize ( $ string ) ) === false ) { throw new BuildException ( sprintf ( 'Unable to unserialize content of file "%1$s"' , $ this -> _optfile ) ) ; } if ( $ this -> _file instanceof PhingFile ) { $ this -> _extract ( $ this -> _file -> getPath ( ) , $ options ) ; } else { $ project = $ this -> getProject ( ) ; foreach ( $ this -> _filesets as $ fs ) { $ files = $ fs -> getDirectoryScanner ( $ project ) -> getIncludedFiles ( ) ; $ dir = $ fs -> getDir ( $ this -> project ) -> getPath ( ) ; foreach ( $ files as $ file ) { $ this -> _extract ( $ dir . DIRECTORY_SEPARATOR . $ file , $ options ) ; } } } $ len = strlen ( $ this -> _keyprefix ) ; foreach ( $ options as $ key => $ values ) { if ( strncmp ( $ key , $ this -> _keyprefix , $ len ) !== 0 ) { unset ( $ options [ $ key ] ) ; } else if ( strpos ( $ key , 'unknown' ) !== false ) { unset ( $ options [ $ key ] ) ; } else if ( ! isset ( $ values [ 'short' ] ) && $ key [ 0 ] !== "\n" ) { $ this -> log ( 'No doc: ' . $ key ) ; } } ksort ( $ options ) ; $ this -> log ( 'Number of config options for ' . $ this -> _keyprefix . ': ' . count ( $ options ) ) ; $ this -> _createWikiPages ( $ options ) ; }
Generates Mediawiki pages for the configuration documentation .
32,714
protected function _createWikiPagesList ( array $ options , array $ sections ) { $ data = '' ; $ date = date ( 'c' ) ; $ keyprefix = $ this -> _keyprefix ; $ wikiprefix = $ this -> _wikiprefix ; foreach ( $ sections as $ name => $ list ) { $ data .= "<page>\n<title>$wikiprefix/$keyprefix/$name</title>\n<ns>0</ns><revision><timestamp>$date</timestamp><contributor></contributor>\n<comment>Generated by MShopConfigDocTask</comment><text xml:space=\"preserve\">__TOC__\n\n\n&lt;div class=\"config\"&gt;" ; if ( isset ( $ list [ 'global' ] ) ) { foreach ( ( array ) $ list [ 'global' ] as $ key ) { $ desc = $ options [ $ key ] [ 'short' ] ; $ data .= "\n; [[$wikiprefix/$key|$key]] : $desc\n" ; } unset ( $ list [ 'global' ] ) ; } foreach ( $ list as $ subname => $ keys ) { if ( is_array ( $ keys ) ) { $ data .= "\n== $subname ==\n" ; foreach ( $ keys as $ key ) { $ desc = $ options [ $ key ] [ 'short' ] ; $ data .= "\n; [[$wikiprefix/$key|$key]] : $desc\n" ; } } else { $ desc = $ options [ $ keys ] [ 'short' ] ; $ data .= "\n; [[$wikiprefix/$keys|$keys]] : $desc\n" ; } } $ data .= "&lt;/div&gt;</text><model>wikitext</model><format>text/x-wiki</format></revision>\n</page>\n" ; } return $ data ; }
Creates the list page for all wiki pages .
32,715
public function getClasses ( ) { $ ar = get_declared_classes ( ) ; foreach ( $ ar as $ class ) { $ c = new reflectionClass ( $ class ) ; if ( $ c -> isUserDefined ( ) ) { $ this -> classes [ $ class ] = new IPReflectionClass ( $ class ) ; } } ksort ( $ this -> classes ) ; return $ this -> classes ; }
Haalt alle geladen classes op die custom zijn .
32,716
public function getDocumentation ( $ template = null ) { if ( $ template === null ) { $ template = __DIR__ . '/../../doc/templates/docclass.xsl' ; } if ( ! is_file ( $ template ) ) { throw new WSException ( "Could not find the template file: '$template'" ) ; } $ xtpl = new IPXSLTemplate ( $ template ) ; $ documentation = array ( ) ; $ documentation [ 'menu' ] = array ( ) ; $ documentation [ 'menu' ] = $ this -> getClasses ( ) ; if ( $ this -> class ) { if ( $ this -> class -> isUserDefined ( ) ) { $ this -> class -> properties = $ this -> class -> getProperties ( false , false ) ; $ this -> class -> methods = $ this -> class -> getMethods ( false , false ) ; foreach ( ( array ) $ this -> class -> methods as $ method ) { $ method -> params = $ method -> getParameters ( ) ; } } else { $ documentation [ 'fault' ] = 'Native class' ; } $ documentation [ 'class' ] = $ this -> class ; } echo $ xtpl -> execute ( $ documentation ) ; }
Generates the documentation page with all classes methods etc .
32,717
public function create ( $ sql , $ type = MW_DB_Connection_Abstract :: TYPE_SIMPLE ) { try { switch ( $ type ) { case MW_DB_Connection_Abstract :: TYPE_SIMPLE : return new MW_DB_Statement_PDO_Simple ( $ this -> _connection , $ sql ) ; case MW_DB_Connection_Abstract :: TYPE_PREP : return new MW_DB_Statement_PDO_Prepared ( $ this -> _connection -> prepare ( $ sql ) ) ; default : throw new MW_DB_Exception ( sprintf ( 'Invalid value "%1$d" for statement type' , $ type ) ) ; } } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } }
Creates a PDO database statement .
32,718
public function rollback ( ) { try { if ( -- $ this -> _txnumber === 0 ) { if ( $ this -> _connection -> rollBack ( ) === false ) { throw new MW_DB_Exception ( 'Failed to roll back transaction' ) ; } } } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } }
Discards the changes done inside of the transaction .
32,719
protected function mapData ( array $ data , array $ options ) { if ( ! isset ( $ options [ 'settings_field' ] ) ) { $ field = $ options [ 'key_field' ] ?? 'key' ; expect_type ( $ field , 'string' , \ BadMethodCallException :: class ) ; unset ( $ data [ $ field ] ) ; } else { $ field = $ options [ 'settings_field' ] ; if ( ! isset ( $ data [ $ field ] ) && ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "DynamoDB item '{$options['key_value']}' doesn't have a '$field' field" ) ; } $ data = $ data [ $ field ] ?? [ ] ; } return $ data ; }
Get the map with settings from the data .
32,720
protected function loadDataFromItem ( DynamoDbClient $ dynamodb , array $ options ) { $ field = $ options [ 'key_field' ] ?? 'key' ; expect_type ( $ field , 'string' , \ BadMethodCallException :: class ) ; $ key = $ options [ 'key_value' ] ; expect_type ( $ key , 'string' , \ BadMethodCallException :: class ) ; try { $ result = $ dynamodb -> getItem ( [ 'TableName' => $ options [ "table" ] , 'Key' => [ $ field => [ 'S' => $ key ] ] ] ) ; if ( ! isset ( $ result [ 'Item' ] ) && ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "Failed to load '{$options['key_value']}' configuration from DynamoDB: " . "No item found with $field '$key'" ) ; } $ item = isset ( $ result [ 'Item' ] ) ? $ result [ 'Item' ] : null ; } catch ( DynamoDbException $ e ) { if ( ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "Failed to load '{$options['key_value']}' configuration from DynamoDB" , 0 , $ e ) ; } } if ( ! isset ( $ item ) ) { return [ ] ; } $ marshaler = new Marshaler ( ) ; $ data = $ marshaler -> unmarshalItem ( $ item ) ; return $ this -> mapData ( $ data , $ options ) ; }
Query Dynamo DB table loading all settings from a single item .
32,721
public function load ( $ dynamodb , array $ options = [ ] ) { expect_type ( $ dynamodb , DynamoDbClient :: class ) ; $ this -> assertOptions ( $ options ) ; $ data = $ this -> loadDataFromItem ( $ dynamodb , $ options ) ; if ( ! is_array ( $ data ) ) { throw new LoadException ( "DynamoDB '{$options['key_value']}' configuration isn't a key/value map" ) ; } return new Config ( $ data ) ; }
Load config from DynamoDB
32,722
protected static function _createSignature ( array $ params ) { $ list = array ( ) ; foreach ( $ params as $ param ) { switch ( gettype ( $ param ) ) { case 'boolean' : case 'integer' : case 'double' : $ list [ ] = $ param ; break ; case 'array' : $ list [ ] = '[' . self :: _createSignature ( $ param ) . ']' ; break ; default : $ list [ ] = '"' . $ param . '"' ; } } return implode ( ',' , $ list ) ; }
Creates a parameter signature for compare expressions .
32,723
protected function _isFunction ( & $ name , array & $ params ) { $ len = strlen ( $ name ) ; if ( $ len === 0 || $ name [ $ len - 1 ] !== ')' ) { return false ; } if ( ( $ pos = strpos ( $ name , '(' ) ) === false ) { throw new MW_Common_Exception ( 'Missing opening bracket for function syntax' ) ; } if ( ( $ paramstr = substr ( $ name , $ pos , $ len - $ pos ) ) === false ) { throw new MW_Common_Exception ( 'Unable to extract function parameter' ) ; } if ( ( $ namestr = substr ( $ name , 0 , $ pos ) ) === false ) { throw new MW_Common_Exception ( 'Unable to extract function name' ) ; } $ matches = array ( ) ; $ pattern = '/(\[[^\]]*\]|"[^"]*"|[0-9]+\.[0-9]+|[0-9]+),?/' ; if ( preg_match_all ( $ pattern , $ paramstr , $ matches ) === false ) { throw new MW_Common_Exception ( 'Unable to extract function parameters' ) ; } if ( isset ( $ matches [ 1 ] ) ) { $ params = $ this -> _extractParams ( $ matches [ 1 ] ) ; } $ name = $ namestr . '()' ; return true ; }
Checks if the given string is an expression function and returns the parameters . The parameters will be cut off the function name and will be added to the given parameter array
32,724
protected function _translateName ( & $ name , array $ translations = array ( ) ) { $ params = array ( ) ; if ( $ this -> _isFunction ( $ name , $ params ) === true ) { $ transname = $ name ; if ( isset ( $ translations [ $ name ] ) ) { $ transname = $ translations [ $ name ] ; } $ find = array ( ) ; $ count = count ( $ params ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ find [ $ i ] = '$' . ( $ i + 1 ) ; } return str_replace ( $ find , $ params , $ transname ) ; } if ( isset ( $ translations [ $ name ] ) ) { return $ translations [ $ name ] ; } else { return $ name ; } }
Translates an expression string and replaces the parameter if it s an expression function .
32,725
protected function _translateValue ( $ name , $ value ) { if ( isset ( $ this -> _plugins [ $ name ] ) ) { return $ this -> _plugins [ $ name ] -> translate ( $ value ) ; } return $ value ; }
Translates a value to another one by a plugin if available .
32,726
private function _extractParams ( array $ strings ) { $ params = array ( ) ; foreach ( $ strings as $ string ) { if ( isset ( $ string [ 0 ] ) && $ string [ 0 ] == '[' ) { $ items = array ( ) ; $ pattern = '/("[^"]*"|[0-9]+\.[0-9]+|[0-9]+),?/' ; if ( preg_match_all ( $ pattern , $ string , $ items ) === false ) { throw new MW_Common_Exception ( 'Unable to extract function parameters' ) ; } if ( isset ( $ items [ 1 ] ) ) { $ list = array ( ) ; foreach ( $ items [ 1 ] as $ item ) { $ list [ ] = $ this -> _escape ( '==' , $ this -> _getParamType ( $ item ) , $ item ) ; } $ params [ ] = implode ( ',' , $ list ) ; } } else { $ params [ ] = $ this -> _escape ( '==' , $ this -> _getParamType ( $ string ) , $ string ) ; } } return $ params ; }
Extracts the function parameters from the parameter strings .
32,727
public static function create ( array $ options = [ ] , $ offset = null , $ limit = null ) { $ dataProvider = new static ( $ options , new Vault ( $ options [ '__presetName' ] ) ) ; $ dataProvider -> setOffset ( $ offset ) ; $ dataProvider -> setLimit ( $ limit ) ; return $ dataProvider ; }
Factory method which returns an instance of the concrete implementation and passes the given options offset and limit to it .
32,728
public static function method ( $ since = null , $ suggest = '' , $ subject = 0 ) : void { if ( $ subject === null || is_int ( $ subject ) ) { [ $ subject , $ function , $ constructor ] = static :: getCaller ( $ subject ? : 0 ) ; } else { Assert :: stringNotEmpty ( $ subject , 'Expected a non-empty string. Got: %s' ) ; $ function = $ subject ; $ constructor = false ; } if ( $ suggest && preg_match ( '/\s/' , $ suggest ) === 0 ) { if ( ! class_exists ( $ suggest ) ) { $ suggest .= '()' ; } elseif ( ! $ constructor && method_exists ( $ suggest , $ function ) ) { $ suggest .= '::' . $ function . '()' ; } $ suggest = "Use ${suggest} instead." ; } if ( ! $ constructor ) { $ subject .= '()' ; } static :: warn ( $ subject , $ since , $ suggest ) ; }
Shortcut for triggering a deprecation warning for a method .
32,729
protected static function getCaller ( $ index , $ offset = 1 ) : array { Assert :: greaterThanEq ( $ index , 0 ) ; $ index += $ offset + 1 ; $ stack = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS , $ index + 1 ) ; if ( ! isset ( $ stack [ $ index ] ) ) { throw new \ OutOfBoundsException ( sprintf ( '%s is greater than the current call stack' , $ index - $ offset - 1 ) ) ; } $ frame = $ stack [ $ index ] ; if ( ! isset ( $ frame [ 'class' ] ) ) { if ( ! function_exists ( $ frame [ 'function' ] ) ) { $ frame = $ stack [ $ index - $ offset ] ; throw new \ InvalidArgumentException ( sprintf ( '%s::%s() must be called from within a function/method.' , $ frame [ 'class' ] , $ frame [ 'function' ] ) ) ; } return [ $ frame [ 'function' ] , $ frame [ 'function' ] , false , false , ] ; } $ class = $ frame [ 'class' ] ; $ function = $ frame [ 'function' ] ; $ constructor = $ function === '__construct' ; if ( $ function === '__call' || $ function === '__callStatic' ) { $ frame = debug_backtrace ( 0 , $ index + 1 ) [ $ index ] ; $ function = $ frame [ 'args' ] [ 0 ] ; } return [ $ class . ( ! $ constructor ? '::' . $ function : '' ) , $ function , $ constructor , ] ; }
Get info about caller at index .
32,730
public static function cls ( $ class , $ since = null , $ suggest = null ) : void { if ( $ suggest && preg_match ( '/\s/' , $ suggest ) === 0 ) { $ suggest = ltrim ( $ suggest , '\\' ) ; $ suggest = "Use ${suggest} instead." ; } $ class = ltrim ( $ class , '\\' ) ; static :: warn ( $ class , $ since , $ suggest ) ; }
Shortcut for triggering a deprecation warning for a class .
32,731
public static function warn ( $ subject , $ since = null , $ suggest = '' ) : void { $ message = $ subject . ' is deprecated' ; if ( $ since !== null ) { $ since = ( string ) $ since ; $ message .= sprintf ( ' since %.1f and will be removed in %s.0' , $ since , $ since [ 0 ] + 1 ) ; } $ message .= '.' ; if ( $ suggest ) { $ message .= ' ' . $ suggest ; } static :: raw ( $ message ) ; }
Shortcut for triggering a deprecation warning for a subject .
32,732
public function run ( ) { if ( isset ( \ Yii :: $ app -> cmsMarketplace ) && \ Yii :: $ app -> cmsMarketplace ) { \ Yii :: $ app -> cmsMarketplace -> info ; } if ( $ this -> _isRunning === false && $ this -> _checkAccess ( ) ) { $ this -> _isRunning = true ; static :: $ _runningBakcend = $ this ; $ event = new Event ( ) ; $ this -> trigger ( self :: EVENT_BEFORE_RUN , $ event ) ; $ this -> _run ( ) ; $ event = new Event ( ) ; $ this -> trigger ( self :: EVENT_RUN , $ event ) ; } return $ this ; }
Run backend app
32,733
protected function verifyRequired ( $ route ) { $ request = Yii :: $ app -> getRequest ( ) ; Yii :: $ app -> session -> set ( $ this -> buildKey ( '_url' ) , [ $ route , $ request -> getUrl ( ) ] ) ; $ id = $ this -> owner -> uniqueId . '/' . $ this -> verificationRoute ; return Yii :: $ app -> getResponse ( ) -> redirect ( [ $ id ] ) ; }
Redirect to verify controller
32,734
public function isValid ( $ code , $ route ) { return call_user_func ( $ this -> validationCallback , $ code , $ this -> validateForAll ? '' : $ route ) ; }
Check entered code for action
32,735
public function setResultMode ( $ mode ) { if ( ! is_int ( $ mode ) || $ mode < 0 || $ mode > 3 ) { throw new InvalidArgumentException ( "Invalid result mode" ) ; } $ this -> resultMode = $ mode ; return $ this ; }
Set result mode
32,736
public static function encodeSecureCookie ( $ value , $ expires , $ secret , $ algorithm , $ mode ) { $ key = hash_hmac ( 'sha1' , $ expires , $ secret ) ; $ iv = self :: get_iv ( $ expires , $ secret ) ; $ secureString = base64_encode ( self :: encrypt ( $ value , $ key , $ iv , array ( 'algorithm' => $ algorithm , 'mode' => $ mode ) ) ) ; $ verificationString = hash_hmac ( 'sha1' , $ expires . $ value , $ key ) ; return implode ( '|' , array ( $ expires , $ secureString , $ verificationString ) ) ; }
Encode secure cookie value
32,737
private function convert ( $ mixValues ) { $ data = ToolboxFile :: convertValuesToDatabase ( $ mixValues ) ; return $ this -> get ( 'file_multiple' ) ? \ serialize ( $ data ) : ( $ data [ 0 ] ?? null ) ; }
Take the native data and serialize it for the database .
32,738
protected function handle ( Handler $ handler , Notification $ notification ) { try { $ handler -> handle ( $ notification ) ; $ this -> write ( "RESULT 2\nOK" ) ; } catch ( EventHandlingFailed $ e ) { $ this -> write ( "RESULT 4\nFAIL" ) ; } catch ( StopListener $ e ) { $ this -> listen = false ; } }
Handles the notification
32,739
protected function getNotification ( ) { if ( $ header = $ this -> read ( ) ) { $ header = $ this -> parseData ( $ header ) ; $ payload = $ this -> read ( $ header [ 'len' ] ) ; $ payload = explode ( "\n" , $ payload , 2 ) ; isset ( $ payload [ 1 ] ) or $ payload [ 1 ] = null ; list ( $ payload , $ body ) = $ payload ; $ payload = $ this -> parseData ( $ payload ) ; return new Notification ( $ header , $ payload , $ body ) ; } }
Returns notification from input stream if available
32,740
protected function parseData ( $ rawData ) { $ outputData = [ ] ; foreach ( explode ( ' ' , $ rawData ) as $ data ) { $ data = explode ( ':' , $ data ) ; $ outputData [ $ data [ 0 ] ] = $ data [ 1 ] ; } return $ outputData ; }
Parses colon devided data
32,741
public function appendData ( $ data ) { if ( ! is_array ( $ data ) ) { throw new \ InvalidArgumentException ( 'Cannot append view data. Expected array argument.' ) ; } $ this -> data = array_merge ( $ this -> data , $ data ) ; }
Append new data to existing template data
32,742
public function handle ( ) { if ( substr ( $ _SERVER [ 'QUERY_STRING' ] , - 4 ) == 'wsdl' ) { $ this -> showWSDL ( ) ; return ; } if ( $ this -> isSoapRequest ( ) ) { $ this -> handleRequest ( ) ; } else { $ this -> createDocumentation ( ) ; } }
Handles everything . Makes sure the webservice is handled documentations is generated or the wsdl is generated according to the page request .
32,743
public function showWSDL ( ) { if ( ! in_array ( $ this -> name , $ this -> classNameArr ) ) { throw new Exception ( 'No valid webservice class.' ) ; } header ( 'Content-type: text/xml' ) ; if ( $ this -> useWSDLCache && file_exists ( $ this -> wsdlfile ) ) { readfile ( $ this -> wsdlfile ) ; } else { ini_set ( 'soap.wsdl_cache_enabled' , 0 ) ; echo $ this -> createWSDL ( ) ; } }
Checks if the current WSDL is up - to - date regenerates if necessary and outputs the WSDL .
32,744
private function handleRequest ( ) { if ( ! in_array ( $ this -> name , $ this -> classNameArr ) ) { throw new Exception ( 'No valid webservice class.' ) ; } if ( ! file_exists ( $ this -> wsdlfile ) ) { $ this -> createWSDL ( ) ; } $ options = array ( 'soap_version' => SOAP_1_1 , 'actor' => $ this -> actor , 'classmap' => $ this -> structureMap , ) ; header ( 'Content-type: text/xml' ) ; $ this -> server = new SoapServer ( $ this -> wsdlfile , $ options ) ; $ this -> server -> setClass ( $ this -> name ) ; $ this -> server -> setPersistence ( $ this -> persistence ) ; use_soap_error_handler ( true ) ; $ this -> server -> handle ( ) ; }
Lets the native PHP5 soap implementation handle the request after registrating the class .
32,745
public function createDocumentation ( $ template = '' ) { if ( $ template == '' ) { $ template = $ this -> docTemplate ; } if ( $ template == '' ) { throw new WSException ( 'No template file to generate documentation' ) ; } if ( ! is_file ( $ template ) ) { throw new WSException ( "Could not find the template file: '$template'" ) ; } $ this -> class = new IPReflectionClass ( $ this -> name ) ; $ xtpl = new IPXSLTemplate ( $ template ) ; $ documentation = array ( ) ; $ documentation [ 'menu' ] = array ( ) ; sort ( $ this -> classNameArr ) ; foreach ( $ this -> classNameArr as $ className ) { $ documentation [ 'menu' ] [ ] = new IPReflectionClass ( $ className ) ; } if ( $ this -> class ) { $ this -> class -> properties = $ this -> class -> getProperties ( false , false ) ; $ this -> class -> methods = $ this -> class -> getMethods ( false , false ) ; foreach ( ( array ) $ this -> class -> methods as $ method ) { $ method -> params = $ method -> getParameters ( ) ; } $ documentation [ 'class' ] = $ this -> class ; } echo $ xtpl -> execute ( $ documentation ) ; }
Generates the documentations for the webservice usage .
32,746
public function transform ( MShop_Catalog_Item_Interface $ item , array $ path , array $ params = array ( ) ) { if ( $ item -> getStatus ( ) <= 0 ) { return '' ; } $ id = $ item -> getId ( ) ; $ enc = $ this -> _encoder ; $ config = $ item -> getConfig ( ) ; $ class = ( $ item -> hasChildren ( ) ? ' withchild' : ' nochild' ) ; $ class .= ( isset ( $ path [ $ item -> getId ( ) ] ) ? ' active' : '' ) ; $ class .= ( isset ( $ config [ 'css-class' ] ) ? ' ' . $ config [ 'css-class' ] : '' ) ; $ params [ 'a-name' ] = str_replace ( ' ' , '-' , $ item -> getName ( ) ) ; $ params [ 'f-catalog-id' ] = $ id ; $ url = $ enc -> attr ( $ this -> url ( $ this -> _target , $ this -> _controller , $ this -> _action , $ params , array ( ) , $ this -> _config ) ) ; $ output = '<li class="cat-item catid-' . $ enc -> attr ( $ id . $ class ) . '" data-id="' . $ id . '" ><!-- . $ url . '"><span class="cat-name">' . $ enc -> html ( $ item -> getName ( ) , $ enc :: TRUST ) . '</span></a>' ; $ children = $ item -> getChildren ( ) ; if ( ! empty ( $ children ) ) { $ output .= '<ul class="level-' . $ enc -> attr ( $ item -> getNode ( ) -> level + 1 ) . '">' ; foreach ( $ children as $ child ) { $ output .= $ this -> transform ( $ child , $ path , $ params ) ; } $ output .= '</ul>' ; } $ output .= '</li>' ; return $ output ; }
Returns the HTML for the navigation tree .
32,747
protected function interpolateParams ( ) { if ( count ( $ this -> params ) <= 0 ) { return ; } if ( $ this -> quoteCallback ) { $ cb = $ this -> quoteCallback ; } else if ( $ this -> database ) { $ cb = array ( $ this -> database , 'quote' ) ; } else { throw new LogicException ( 'Interpolation not available without ' . 'setting a quote callback or database adapter' ) ; } if ( substr_count ( $ this -> query , '?' ) != count ( $ this -> params ) ) { throw new LogicException ( 'Parameter count mismatch: ' . $ this -> query ) ; } $ parts = explode ( '?' , $ this -> query ) ; $ query = $ parts [ 0 ] ; for ( $ i = 0 , $ l = count ( $ this -> params ) ; $ i < $ l ; $ i ++ ) { $ query .= call_user_func ( $ cb , $ this -> params [ $ i ] ) . $ parts [ $ i + 1 ] ; } $ this -> query = $ query ; }
Interpolate parameters into query
32,748
protected function pushTable ( ) { if ( empty ( $ this -> table ) ) { throw new LogicException ( 'No table specified' ) ; } $ this -> parts [ ] = $ this -> quoteIdentifierIfNotExpression ( $ this -> table ) ; }
Push table onto parts
32,749
protected function pushValues ( ) { if ( empty ( $ this -> values ) ) { throw new LogicException ( 'No values specified' ) ; } foreach ( $ this -> values as $ key => $ value ) { if ( ! is_int ( $ key ) ) { $ this -> parts [ ] = $ this -> quoteIdentifierIfNotExpression ( $ key ) ; $ this -> parts [ ] = '=' ; } if ( $ value instanceof Expression ) { $ this -> parts [ ] = ( string ) $ value ; } else if ( ! is_int ( $ key ) ) { $ this -> parts [ ] = '?' ; $ this -> params [ ] = $ value ; } $ this -> parts [ ] = ',' ; } array_pop ( $ this -> parts ) ; }
Push values onto parts
32,750
public function query ( ) { if ( ! empty ( $ this -> preExecuteCallbacks ) ) { foreach ( $ this -> preExecuteCallbacks as $ callable ) { call_user_func ( $ callable , $ this ) ; } } if ( $ this -> database ) { $ result = $ this -> database -> query ( $ this ) ; } else if ( $ this -> queryCallback ) { $ query = $ this -> toString ( ) ; $ params = $ this -> params ( ) ; if ( $ this -> interpolation ) { $ result = call_user_func ( $ this -> queryCallback , $ query ) ; } else { $ result = call_user_func ( $ this -> queryCallback , $ query , $ params ) ; } } else { throw new LogicException ( 'query() called when no callback or database adapter set' ) ; } if ( ! empty ( $ this -> postExecuteCallbacks ) ) { foreach ( $ this -> postExecuteCallbacks as $ callable ) { call_user_func ( $ callable , $ result , $ this ) ; } } return $ result ; }
Proxy to query callback
32,751
public function table ( $ table ) { if ( $ table instanceof Expression ) { $ this -> table = $ table ; } else { $ this -> table = ( string ) $ table ; } return $ this ; }
Set the table
32,752
protected function newSelfs ( array $ input ) { $ strObjects = [ ] ; foreach ( $ input as $ key => $ value ) { if ( is_string ( $ value ) ) { $ strObjects [ $ key ] = $ this -> newSelf ( $ value ) ; } elseif ( is_array ( $ value ) ) { $ strObjects [ $ key ] = $ this -> newSelfs ( $ value ) ; } else { $ strObjects [ $ key ] = $ value ; } } return $ strObjects ; }
Helper method used internally .
32,753
public function getIterator ( ) { $ chars = array ( ) ; for ( $ i = 0 , $ l = $ this -> getLength ( ) ; $ i < $ l ; $ i ++ ) { $ chars [ ] = $ this [ $ i ] ; } return new \ ArrayIterator ( $ chars ) ; }
IteratorAggregate interface method .
32,754
public function offsetExists ( $ index ) { $ index = ( int ) $ index ; if ( $ index >= 0 ) return ( $ this -> getLength ( ) > $ index ) ; return ( $ this -> getLength ( ) >= abs ( $ index ) ) ; }
Checks to see if the character index exists .
32,755
public static function create ( $ formattedString , $ offset = null ) { if ( strpos ( $ formattedString , '/' ) ) { $ dual = new VF_Wheel_BoltPattern_Dual ( $ formattedString ) ; return $ dual -> getPatterns ( ) ; } else { return new VF_Wheel_BoltPattern_Single ( $ formattedString , $ offset ) ; } }
SINGLE FORMAT Lug Count x Bolt Distance ex . 5 x 135 5 lug nuts 135mm distance
32,756
public function serialize ( Signature $ signature , $ length ) { $ r = str_pad ( $ this -> adapter -> decHex ( ( string ) $ signature -> getR ( ) ) , $ length , '0' , STR_PAD_LEFT ) ; $ s = str_pad ( $ this -> adapter -> decHex ( ( string ) $ signature -> getS ( ) ) , $ length , '0' , STR_PAD_LEFT ) ; return pack ( 'H*' , $ r . $ s ) ; }
Serialize a Signature to a binary string
32,757
public function unserialize ( $ binary , $ length ) { list ( $ r , $ s ) = str_split ( unpack ( 'H*' , $ binary ) [ 1 ] , $ length ) ; return new Signature ( gmp_init ( $ this -> adapter -> hexDec ( $ r ) , 10 ) , gmp_init ( $ this -> adapter -> hexDec ( $ s ) , 10 ) ) ; }
Serialize a binary string to a Signature
32,758
public function getLoader ( ) : LoaderInterface { if ( ! isset ( $ this -> i__loader ) ) { $ this -> i__loader = new DelegateLoader ( ) ; } return $ this -> i__loader ; }
Get the loader
32,759
protected static function mergeObjects ( stdClass & $ target , stdClass ... $ sources ) : void { foreach ( $ sources as $ source ) { foreach ( $ source as $ key => $ value ) { if ( str_starts_with ( $ key , 'i__' ) ) { continue ; } if ( isset ( $ target -> $ key ) && is_object ( $ value ) && is_object ( $ target -> $ key ) ) { static :: mergeObjects ( $ target -> $ key , $ value ) ; } else { $ target -> $ key = $ value ; } } } }
Recursive merge of 2 or more objects
32,760
public function get ( $ key ) { expect_type ( $ key , 'string' ) ; $ value = DotKey :: on ( $ this ) -> get ( $ key ) ; if ( ! isset ( $ value ) ) { throw new NotFoundException ( "Config setting '$key' not found" ) ; } return $ value ; }
Finds an entry of the container by its identifier and returns it . Supports dot key notation .
32,761
public function saveAsScript ( string $ filename ) : void { $ config = clone $ this ; unset ( $ config -> i__loader ) ; $ export = str_replace ( 'stdClass::__set_state' , '(object)' , var_export ( $ config , true ) ) ; $ script = "<?php\nreturn $export;" ; $ success = file_put_contents ( $ filename , $ script , str_contains ( $ filename , ':' ) ? 0 : LOCK_EX ) ; if ( $ success && function_exists ( 'opcache_compile_file' ) ) { opcache_compile_file ( $ filename ) ; } }
Save configuration as PHP script . This will speed up loading the configuration .
32,762
public static function loadFromScript ( string $ filename ) : ? Config { if ( ( function_exists ( 'opcache_is_script_cached' ) && opcache_is_script_cached ( $ filename ) ) || file_exists ( $ filename ) ) { return include $ filename ? : null ; } return null ; }
Load configuration from PHP script .
32,763
protected function _checkType ( $ value ) { switch ( $ value ) { case MShop_Order_Item_Base_Address_Abstract :: TYPE_DELIVERY : case MShop_Order_Item_Base_Address_Abstract :: TYPE_PAYMENT : return ; default : throw new MShop_Order_Exception ( sprintf ( 'Service of type "%1$s" not available' , $ value ) ) ; } }
Checks if the given address type is valid
32,764
public static function bootSluggable ( ) { static :: saving ( function ( Model $ model ) { if ( empty ( $ model -> getSlug ( ) ) ) { $ model -> setSlug ( Str :: slug ( $ model -> getSluggableString ( ) ) ) ; } } ) ; }
Boot the sluggable trait for a model .
32,765
public function getConfig ( ) { return $ this -> _node -> __isset ( 'config' ) && is_array ( $ this -> _node -> config ) ? $ this -> _node -> __get ( 'config' ) : array ( ) ; }
Returns the config property of the catalog .
32,766
public function toArray ( ) { return array ( 'catalog.id' => $ this -> _node -> getId ( ) , 'catalog.code' => $ this -> _node -> getCode ( ) , 'catalog.label' => $ this -> _node -> getLabel ( ) , 'catalog.status' => $ this -> _node -> getStatus ( ) , 'catalog.config' => $ this -> getConfig ( ) , 'catalog.siteid' => $ this -> _node -> __get ( 'siteid' ) , 'catalog.ctime' => $ this -> _node -> __get ( 'ctime' ) , 'catalog.mtime' => $ this -> _node -> __get ( 'mtime' ) , 'catalog.editor' => $ this -> _node -> __get ( 'editor' ) , 'catalog.hasChildren' => $ this -> hasChildren ( ) ) ; }
Returns the public values of the node as array .
32,767
public function transform ( $ name = null , $ default = null ) { if ( $ name === null ) { return $ this -> _params ; } $ parts = explode ( '/' , trim ( $ name , '/' ) ) ; $ param = $ this -> _params ; foreach ( $ parts as $ part ) { if ( isset ( $ param [ $ part ] ) ) { $ param = $ param [ $ part ] ; } else { return $ default ; } } return $ param ; }
Returns the parameter value .
32,768
protected function _process ( array $ stmts ) { $ table = "madmin_job" ; $ this -> _msg ( sprintf ( 'Converting "%1$s" to InnoDB".' , $ table ) , 0 ) ; $ stmt = $ this -> _conn -> create ( $ stmts [ 'check' ] ) ; $ stmt -> bind ( 1 , $ this -> _schema -> getDBName ( ) ) ; $ stmt -> bind ( 2 , $ table ) ; $ result = $ stmt -> execute ( ) ; $ dbname = $ result -> fetch ( ) ; $ result -> finish ( ) ; if ( $ this -> _schema -> tableExists ( $ table ) === true && $ dbname [ 'ENGINE' ] === 'MyISAM' ) { $ this -> _execute ( $ stmts [ 'convert' ] ) ; $ this -> _status ( 'converted' ) ; } else { $ this -> _status ( 'OK' ) ; } }
Converts MyISAM table to InnoDB .
32,769
function get ( $ name ) { if ( $ this -> _container -> locateName ( $ name ) === false ) { $ msg = 'No content object "%1$s" available in "%2$s"' ; throw new MW_Container_Exception ( sprintf ( $ msg , $ name , $ this -> _container -> filename ) ) ; } return new $ this -> _classname ( 'zip://' . $ this -> _resourcepath . '#' . $ name , $ name ) ; }
Returns the element specified by its name .
32,770
public function created ( $ instance ) { $ after = $ this -> recordableAttributes ( get_class ( $ instance ) , $ instance -> getAttributes ( ) ) ; $ instance -> recordActivity ( 'created' , null , $ after ) ; }
Record activity for the created event .
32,771
public function updated ( $ instance ) { $ before = $ this -> recordableAttributes ( get_class ( $ instance ) , $ instance -> getOriginal ( ) ) ; $ after = $ this -> recordableAttributes ( get_class ( $ instance ) , $ instance -> getAttributes ( ) ) ; $ instance -> recordActivity ( 'updated' , $ before , $ after ) ; }
Record activity for the updated event .
32,772
public function deleted ( $ instance ) { $ before = $ this -> recordableAttributes ( get_class ( $ instance ) , $ instance -> getAttributes ( ) ) ; $ instance -> recordActivity ( 'deleted' , $ before , null ) ; }
Record activity for the deleted event .
32,773
protected function recordableAttributes ( $ model , $ attributes ) { $ except = array_flip ( $ this -> config ( 'ignore' , $ model ) ) ; return array_diff_key ( $ attributes , $ except ) ; }
Filter model s recordable attributes .
32,774
public function registerEventListeners ( $ model ) { $ activities = $ this -> config ( 'activities' , $ model ) ; foreach ( $ activities as $ activity ) { call_user_func ( "$model::$activity" , function ( $ instance ) use ( $ activity ) { $ this -> { $ activity } ( $ instance ) ; } ) ; } }
Register model event listeners .
32,775
public function call ( ) { $ callable = $ this -> getRouteCallable ( ) ; if ( empty ( $ callable ) || ! $ this -> doesHaveAccessToMethod ( $ callable [ 1 ] ) ) { $ this -> getApp ( ) -> returnError ( DefaultAppErrors :: $ NOT_AUTHORIZED ) ; } if ( ! empty ( $ this -> next ) ) { $ this -> next -> call ( ) ; } }
Blocks access to REST functions that this class specifies using the doesHaveAccessToMethod .
32,776
public function documentMethod ( \ ReflectionClass $ rClass , \ ReflectionMethod $ rMethod , array & $ methodDoc ) { parent :: documentMethod ( $ rClass , $ rMethod , $ methodDoc ) ; if ( ! $ this -> doesHaveAccessToMethod ( $ rMethod -> name ) ) { $ methodDoc = NULL ; return ; } if ( ! empty ( $ this -> next ) ) { $ this -> next -> documentMethod ( $ rClass , $ rMethod , $ methodDoc ) ; } }
Removes the documentation for methods that the api does not have access to
32,777
public function isFormData ( ) { $ method = isset ( $ this -> env [ 'slim.method_override.original_method' ] ) ? $ this -> env [ 'slim.method_override.original_method' ] : $ this -> getMethod ( ) ; return ( $ method === self :: METHOD_POST && is_null ( $ this -> getContentType ( ) ) ) || in_array ( $ this -> getMediaType ( ) , self :: $ formDataMediaTypes ) ; }
Does the Request body contain parseable form data?
32,778
public function registerChain ( ) { $ parentTask = null ; $ firstTask = true ; $ firstTaskId = null ; foreach ( $ this -> chainedQueue as $ task ) { $ task -> model -> output_file = $ this -> output_file ; $ task -> model -> delete_after_run = false ; if ( $ task -> registerTask ( ) ) { if ( true === $ firstTask ) { $ firstTaskId = $ task -> model -> id ; $ firstTask = false ; } if ( null !== $ parentTask ) { $ parentTask -> model -> next_task_id = $ task -> model -> id ; $ parentTask -> model -> save ( 'next_task_id' ) ; } $ parentTask = $ task ; } } return $ firstTaskId ; }
Registers newly created chain
32,779
public function set ( $ name , $ value , $ default ) { $ this -> _config [ $ name ] [ 'value' ] = $ value ; $ this -> _config [ $ name ] [ 'default' ] = $ default ; }
Stores the configuration key the actual and the default value
32,780
public function transform ( $ domain , $ singular , $ plural = '' , $ number = 1 ) { if ( $ plural !== '' ) { return $ this -> _translator -> dn ( $ domain , $ singular , $ plural , $ number ) ; } return $ this -> _translator -> dt ( $ domain , $ singular ) ; }
Returns the translated string or the original one if no translation is available .
32,781
public static function runImmediateTask ( $ taskId ) { $ command = new ProcessBuilder ( ) ; $ command -> setWorkingDirectory ( Yii :: getAlias ( '@app' ) ) ; $ command -> setPrefix ( self :: getPhpBinary ( ) ) ; if ( strncasecmp ( PHP_OS , 'WIN' , 3 ) === 0 ) { $ command -> add ( 'yii' ) ; } else { $ command -> add ( './yii' ) ; } $ command -> add ( 'deferred/index' ) -> add ( "$taskId" ) ; $ process = $ command -> getProcess ( ) ; $ process -> setWorkingDirectory ( Yii :: getAlias ( '@app' ) ) ; $ process -> disableOutput ( ) ; if ( strncasecmp ( PHP_OS , 'WIN' , 3 ) === 0 ) { $ process -> setCommandLine ( 'start /b "deferred" ' . $ process -> getCommandLine ( ) ) ; } else { $ process -> setCommandLine ( $ process -> getCommandLine ( ) . ' &' ) ; } if ( isset ( Yii :: $ app -> params [ 'deferred.env' ] ) ) { $ process -> setEnv ( ArrayHelper :: merge ( Yii :: $ app -> params [ 'deferred.env' ] , $ process -> getEnv ( ) ) ) ; } $ process -> mustRun ( ) ; }
Performs immediate task start - fire and forget . Used in web requests to start task in background .
32,782
public static function getPhpBinary ( ) { $ binary = null ; if ( defined ( 'HHVM_VERSION' ) === true ) { if ( ( $ binary = getenv ( 'PHP_BINARY' ) ) === false ) { $ binary = PHP_BINARY ; } $ binary = $ binary . ' --php' ; } if ( $ binary === null ) { $ possibleBinaryLocations = [ PHP_BINDIR . DIRECTORY_SEPARATOR . 'php' , PHP_BINDIR . DIRECTORY_SEPARATOR . 'php-cli.exe' , PHP_BINDIR . DIRECTORY_SEPARATOR . 'php.exe' , getenv ( 'PHP_BINARY' ) , getenv ( 'PHP_BIN' ) , getenv ( 'PHPBIN' ) , ] ; foreach ( $ possibleBinaryLocations as $ bin ) { if ( is_readable ( $ bin ) ) { $ binary = $ bin ; break ; } } } if ( $ binary === null ) { $ binary = 'php' ; } return $ binary ; }
Helper method to find PHP binary path
32,783
protected function _getListTypeItem ( $ code ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'customer/list/type' ) ; $ search = $ manager -> createSearch ( true ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'customer.list.type.code' , $ code ) ) ; $ result = $ manager -> searchItems ( $ search ) ; if ( ( $ item = reset ( $ result ) ) === false ) { throw new Controller_Jobs_Exception ( sprintf ( 'List type for domain "%1$s" and code "%2$s" not found' , 'customer' , $ code ) ) ; } return $ item ; }
Returns the customer list type item for the given type code .
32,784
public function close ( ) { if ( fflush ( $ this -> _fh ) === false ) { throw new MW_Container_Exception ( sprintf ( 'Unable to flush file "%1$s"' , $ this -> getResource ( ) ) ) ; } if ( fclose ( $ this -> _fh ) === false ) { throw new MW_Container_Exception ( sprintf ( 'Unable to close file "%1$s"' , $ this -> getResource ( ) ) ) ; } }
Closes the CSV file so it s written to disk .
32,785
public function add ( $ data ) { $ enclosure = $ this -> _enclosure ; foreach ( ( array ) $ data as $ key => $ entry ) { $ entry = str_replace ( $ this -> _lineend , $ this -> _endsubst , $ entry ) ; $ data [ $ key ] = $ enclosure . str_replace ( $ enclosure , $ this -> _escape . $ enclosure , $ entry ) . $ enclosure ; } if ( fwrite ( $ this -> _fh , implode ( $ this -> _separator , $ data ) . $ this -> _lineend ) === false ) { throw new MW_Container_Exception ( sprintf ( 'Unable to add content to file "%1$s"' , $ this -> getName ( ) ) ) ; } }
Adds row to the content object .
32,786
function rewind ( ) { $ filename = $ this -> getResource ( ) ; if ( fclose ( $ this -> _fh ) === false ) { throw new MW_Container_Exception ( sprintf ( 'Unable to close file handle for %1$s' , $ filename ) ) ; } if ( ( $ this -> _fh = fopen ( $ filename , 'r' ) ) === false ) { throw new MW_Container_Exception ( sprintf ( 'Unable to open file %1$s' , $ filename ) ) ; } $ this -> _position = 0 ; $ this -> _data = $ this -> _getData ( ) ; }
Rewinds the file pointer to the beginning .
32,787
protected function _getData ( ) { do { $ data = fgetcsv ( $ this -> _fh , 0 , $ this -> _separator , $ this -> _enclosure , $ this -> _escape ) ; if ( $ data === false || $ data === null ) { return null ; } } while ( $ data === array ( null ) ) ; return $ data ; }
Reads the next line from the file .
32,788
public function populate ( array $ data ) : Form { $ this -> resetErrors ( ) ; foreach ( $ this -> components as $ name => $ component ) { $ value = isset ( $ data [ $ name ] ) ? $ data [ $ name ] : null ; $ component -> populate ( $ value ) ; } return $ this ; }
Populates the form with an associative array of data .
32,789
public function isValid ( ) : bool { $ this -> validate ( ) ; if ( $ this -> hasErrors ( ) ) { return false ; } foreach ( $ this -> components as $ component ) { if ( $ component -> hasErrors ( ) ) { return false ; } } return true ; }
Returns whether the form is valid .
32,790
public function getAllErrors ( ) : array { $ errors = $ this -> getErrors ( ) ; foreach ( $ this -> components as $ component ) { $ errors = array_merge ( $ errors , $ component -> getErrors ( ) ) ; } return $ errors ; }
Returns all form - level errors and component - level errors .
32,791
protected function _process ( array $ stmts ) { $ this -> _msg ( 'Migrating catalog suggest tables' , 0 ) ; $ this -> _status ( '' ) ; $ this -> _msg ( sprintf ( 'Checking table "%1$s": ' , 'mshop_catalog_suggest' ) , 1 ) ; if ( $ this -> _schema -> tableExists ( 'mshop_catalog_suggest' ) === true ) { $ result = $ this -> _conn -> create ( $ stmts [ 'gettypeid' ] ) -> execute ( ) ; if ( ( $ row = $ result -> fetch ( MW_DB_Result_Abstract :: FETCH_NUM ) ) === false ) { throw new MW_Setup_Exception ( 'Product list type "suggestion" is missing' ) ; } $ result -> finish ( ) ; $ result = $ this -> _conn -> create ( str_replace ( ':typeid' , $ row [ 0 ] , $ stmts [ 'migrate' ] ) ) -> execute ( ) ; $ count = $ result -> affectedRows ( ) ; $ result -> finish ( ) ; $ this -> _executeList ( $ stmts [ 'drop' ] ) ; $ this -> _status ( sprintf ( 'migrated (%1$d)' , $ count ) ) ; } else { $ this -> _status ( 'OK' ) ; } }
Renames catalog_tree table if it exists .
32,792
public function recordActivity ( $ event , $ before , $ after ) { if ( $ before == $ after || Chronos :: paused ( ) ) { return ; } $ this -> activities ( ) -> create ( [ 'event' => $ event , 'before' => $ before , 'after' => $ after , ] ) ; }
Records the activity .
32,793
public function truncate ( $ length , $ substring = '' ) { if ( $ length >= $ this -> getLength ( ) ) return $ this ; $ substringLength = UTF8 :: strlen ( $ substring , $ this -> encoding ) ; $ length -= $ substringLength ; $ truncated = UTF8 :: substr ( $ this -> scalarString , 0 , $ length , $ this -> encoding ) ; return $ this -> newSelf ( $ truncated . $ substring ) ; }
Truncates the string to a given length .
32,794
public function safeTruncate ( $ length , $ substring = '' ) { if ( $ length >= $ this -> getLength ( ) ) return $ this ; $ substringLength = UTF8 :: strlen ( $ substring , $ this -> encoding ) ; $ length -= $ substringLength ; $ truncated = UTF8 :: substr ( $ this -> scalarString , 0 , $ length , $ this -> encoding ) ; if ( UTF8 :: strpos ( $ this -> scalarString , ' ' , $ length - 1 , $ this -> encoding ) != $ length ) { $ lastPos = UTF8 :: strrpos ( $ truncated , ' ' , 0 , $ this -> encoding ) ; if ( ! is_integer ( $ lastPos ) ) $ lastPos = 0 ; $ truncated = UTF8 :: substr ( $ truncated , 0 , $ lastPos , $ this -> encoding ) ; } return $ this -> newSelf ( $ truncated . $ substring ) ; }
Truncates the string to a given length while ensuring that it does not split words .
32,795
public function next ( ) { if ( is_null ( $ this -> client ) ) { throw new \ Exception ( 'No client reference passed to response' ) ; } if ( is_null ( $ this -> query ) ) { throw new \ Exception ( 'No query available' ) ; } if ( is_null ( $ this -> nextRecordPosition ) ) { return null ; } return $ this -> client -> search ( $ this -> query , $ this -> nextRecordPosition , count ( $ this -> records ) ) ; }
Request next batch of records in the result set or return null if we re at the end of the set
32,796
public function canUseWriter ( $ query ) { $ allowed = ! $ this -> isSelect ( $ query ) || $ this -> writerForced ( ) ; return $ this -> hasWriter ( ) && $ allowed ; }
Returns true if a query should use the writer mysqli object .
32,797
protected function isSelect ( $ query ) { if ( $ query instanceof Query ) { return $ query instanceof Select ; } else { return ( boolean ) preg_match ( '/^(SELECT|SHOW)/i' , trim ( $ query ) ) ; } }
Tests for queries that do not modify .
32,798
protected function _getAttributes ( array $ ids ) { if ( empty ( $ ids ) ) { return array ( ) ; } $ attrManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'attribute' ) ; $ search = $ attrManager -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '==' , 'attribute.id' , $ ids ) , $ search -> getConditions ( ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; return $ attrManager -> searchItems ( $ search , array ( 'price' ) ) ; }
Returns the attribute items for the given IDs .
32,799
protected function _getProducts ( array $ prodCodes ) { if ( empty ( $ prodCodes ) ) { return array ( ) ; } $ productManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product' ) ; $ search = $ productManager -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '==' , 'product.code' , $ prodCodes ) , $ search -> getConditions ( ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ products = $ productManager -> searchItems ( $ search , array ( 'price' ) ) ; $ prodMap = array ( ) ; foreach ( $ products as $ item ) { $ prodMap [ $ item -> getCode ( ) ] = $ item ; } return $ prodMap ; }
Returns the product items for the given product codes .