idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
33,300
public function setCode ( $ value ) { $ this -> _checkCode ( $ value ) ; $ this -> _values [ 'code' ] = ( string ) $ value ; $ this -> setModified ( ) ; }
Sets the new code of the supplier item .
33,301
public function increase ( $ code , $ amount ) { $ context = $ this -> _getContext ( ) ; $ search = $ this -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'coupon.code.siteid' , $ context -> getLocale ( ) -> getSitePath ( ) ) ) ; $ types = array ( 'coupon.code.siteid' => $ this -> _searchConfig [ 'coupon.code.siteid' ] [ 'internaltype' ] ) ; $ translations = array ( 'coupon.code.siteid' => 'siteid' ) ; $ conditions = $ search -> getConditionString ( $ types , $ translations ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ path = 'mshop/coupon/manager/code/default/item/counter' ; $ stmt = $ conn -> create ( str_replace ( ':cond' , $ conditions , $ context -> getConfig ( ) -> get ( $ path , $ path ) ) ) ; $ stmt -> bind ( 1 , $ amount , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , date ( 'Y-m-d H:i:s' ) ) ; $ stmt -> bind ( 3 , $ context -> getEditor ( ) ) ; $ stmt -> bind ( 4 , $ code ) ; $ stmt -> execute ( ) -> finish ( ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } $ dbm -> release ( $ conn , $ dbname ) ; }
Increases the counter of the coupon code .
33,302
public function overrideErrorResponses ( ErrorResponseDictionary $ overridingDictionary ) { foreach ( $ overridingDictionary -> errorResponses as $ key => $ errorResponse ) { $ this -> errorResponses [ $ key ] = $ errorResponse ; } }
Creates or overrides error responses with an initialization array in mass
33,303
public function copyFrom ( MShop_Order_Item_Base_Address_Interface $ item ) { $ this -> setCompany ( $ item -> getCompany ( ) ) ; $ this -> setVatID ( $ item -> getVatID ( ) ) ; $ this -> setSalutation ( $ item -> getSalutation ( ) ) ; $ this -> setTitle ( $ item -> getTitle ( ) ) ; $ this -> setFirstname ( $ item -> getFirstname ( ) ) ; $ this -> setLastname ( $ item -> getLastname ( ) ) ; $ this -> setAddress1 ( $ item -> getAddress1 ( ) ) ; $ this -> setAddress2 ( $ item -> getAddress2 ( ) ) ; $ this -> setAddress3 ( $ item -> getAddress3 ( ) ) ; $ this -> setPostal ( $ item -> getPostal ( ) ) ; $ this -> setCity ( $ item -> getCity ( ) ) ; $ this -> setState ( $ item -> getState ( ) ) ; $ this -> setCountryId ( $ item -> getCountryId ( ) ) ; $ this -> setLanguageId ( $ item -> getLanguageId ( ) ) ; $ this -> setTelephone ( $ item -> getTelephone ( ) ) ; $ this -> setTelefax ( $ item -> getTelefax ( ) ) ; $ this -> setEmail ( $ item -> getEmail ( ) ) ; $ this -> setWebsite ( $ item -> getWebsite ( ) ) ; $ this -> setFlag ( $ item -> getFlag ( ) ) ; }
Copies the values of the order address item into the address item .
33,304
public static function autoload ( $ className ) { $ fileName = strtr ( ltrim ( $ className , '\\' ) , '\\_' , DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR ) . '.php' ; foreach ( self :: $ _includePaths as $ path ) { $ file = $ path . DIRECTORY_SEPARATOR . $ fileName ; if ( file_exists ( $ file ) === true && ( include_once $ file ) !== false ) { return true ; } } foreach ( explode ( PATH_SEPARATOR , get_include_path ( ) ) as $ path ) { $ file = $ path . DIRECTORY_SEPARATOR . $ fileName ; if ( file_exists ( $ file ) === true && ( include_once $ file ) !== false ) { return true ; } } return false ; }
Loads the class files for a given class name .
33,305
public function getI18nPaths ( ) { $ paths = array ( ) ; foreach ( $ this -> _manifests as $ basePath => $ manifest ) { if ( isset ( $ manifest [ 'i18n' ] ) ) { foreach ( $ manifest [ 'i18n' ] as $ domain => $ location ) { $ paths [ $ domain ] [ ] = $ basePath . DIRECTORY_SEPARATOR . $ location ; } } } return $ paths ; }
Returns the list of paths for each domain where the translation files are located .
33,306
public function getIncludePaths ( ) { $ includes = array ( ) ; foreach ( $ this -> _manifests as $ path => $ manifest ) { if ( isset ( $ manifest [ 'include' ] ) ) { foreach ( $ manifest [ 'include' ] as $ paths ) { $ includes [ ] = $ path . DIRECTORY_SEPARATOR . $ paths ; } } } return $ includes ; }
Returns the include paths containing the required class files .
33,307
public function getConfigPaths ( $ dbtype ) { $ confpaths = array ( ) ; foreach ( $ this -> _manifests as $ path => $ manifest ) { if ( isset ( $ manifest [ 'config' ] [ $ dbtype ] ) ) { foreach ( $ manifest [ 'config' ] [ $ dbtype ] as $ paths ) { $ confpaths [ ] = $ path . DIRECTORY_SEPARATOR . $ paths ; } } } return $ confpaths ; }
Returns the paths containing the required configuration files .
33,308
public function getCustomPaths ( $ section ) { $ paths = array ( ) ; foreach ( $ this -> _manifests as $ path => $ manifest ) { if ( isset ( $ manifest [ 'custom' ] [ $ section ] ) ) { $ paths [ $ path ] = $ manifest [ 'custom' ] [ $ section ] ; } } return $ paths ; }
Returns the paths stored in the manifest file for the given custom section .
33,309
public function getSetupPaths ( $ site ) { $ setupPaths = array ( ) ; foreach ( $ this -> _manifests as $ path => $ manifest ) { if ( isset ( $ manifest [ 'setup' ] ) ) { foreach ( $ manifest [ 'setup' ] as $ relpath ) { $ setupPaths [ ] = $ path . DIRECTORY_SEPARATOR . $ relpath ; $ sitePath = $ path . DIRECTORY_SEPARATOR . $ relpath . DIRECTORY_SEPARATOR . $ site ; if ( is_dir ( realpath ( $ sitePath ) ) ) { $ setupPaths [ ] = $ sitePath ; } } } } return $ setupPaths ; }
Returns the list of paths where setup tasks are stored .
33,310
protected function _getManifests ( array $ directories ) { $ manifests = array ( ) ; foreach ( $ directories as $ directory ) { if ( ( $ manifest = $ this -> _getManifestFile ( $ directory ) ) !== false ) { $ manifests [ $ directory ] = $ manifest ; continue ; } $ dir = new DirectoryIterator ( $ directory ) ; foreach ( $ dir as $ dirinfo ) { if ( $ dirinfo -> isDot ( ) === false ) { if ( ( $ manifest = $ this -> _getManifestFile ( $ dirinfo -> getPathName ( ) ) ) !== false ) { $ manifests [ $ dirinfo -> getPathName ( ) ] = $ manifest ; } } } } return $ manifests ; }
Returns the configurations of the manifest files in the given directories .
33,311
protected function _registerAutoloader ( ) { if ( self :: $ _autoloader === false ) { spl_autoload_register ( array ( $ this , 'autoload' ) , true , false ) ; self :: $ _autoloader = true ; } }
Registers the Arcavias autoloader .
33,312
private function _addManifests ( array $ deps , array $ stack = array ( ) ) { foreach ( $ deps as $ extName => $ name ) { if ( in_array ( $ extName , $ this -> _extensionsDone ) ) { continue ; } if ( in_array ( $ extName , $ stack ) ) { $ msg = sprintf ( 'Circular dependency for "%1$s" detected' , $ extName ) ; throw new Exception ( $ msg ) ; } $ stack [ ] = $ extName ; if ( isset ( $ this -> _dependencies [ $ extName ] ) ) { $ this -> _addManifests ( ( array ) $ this -> _dependencies [ $ extName ] , $ stack ) ; } if ( isset ( $ this -> _extensions [ $ extName ] ) ) { $ this -> _manifests [ $ this -> _extensions [ $ extName ] [ 'location' ] ] = $ this -> _extensions [ $ extName ] ; } $ this -> _extensionsDone [ ] = $ extName ; } }
Re - order the given dependencies of each manifest configuration .
33,313
protected function _checkManifestIsValid ( $ location , array $ manifest ) { if ( isset ( $ this -> _extensions [ $ manifest [ 'name' ] ] ) ) { $ location2 = $ this -> _extensions [ $ manifest [ 'name' ] ] [ 'location' ] ; $ msg = 'Extension "%1$s" exists twice in "%2$s" and in "%3$s"' ; throw new Exception ( sprintf ( $ msg , $ manifest [ 'name' ] , $ location , $ location2 ) ) ; } if ( ! isset ( $ manifest [ 'depends' ] ) || ! is_array ( $ manifest [ 'depends' ] ) ) { throw new Exception ( sprintf ( 'Incorrect dependency configuration in manifest "%1$s"' , $ location ) ) ; } }
Check that manifest has valid name and depends
33,314
protected function _checkLogLevel ( $ level ) { switch ( $ level ) { case MW_Logger_Abstract :: EMERG : case MW_Logger_Abstract :: ALERT : case MW_Logger_Abstract :: CRIT : case MW_Logger_Abstract :: ERR : case MW_Logger_Abstract :: WARN : case MW_Logger_Abstract :: NOTICE : case MW_Logger_Abstract :: INFO : case MW_Logger_Abstract :: DEBUG : break ; default : throw new MW_Logger_Exception ( sprintf ( 'Invalid log level constant "%1$d"' , $ level ) ) ; } }
Checks if the given log constant is valid
33,315
protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'product.tag.id' : $ item -> setId ( $ value ) ; break ; case 'product.tag.label' : $ item -> setLabel ( $ value ) ; break ; case 'product.tag.typeid' : $ item -> setTypeId ( $ value ) ; break ; case 'product.tag.languageid' : if ( $ value != '' ) { $ item -> setLanguageId ( $ value ) ; } break ; } } return $ item ; }
Creates a new product tag item and sets the properties from the given array .
33,316
public function inspect ( ) { if ( ! DebugConsole :: $ settings ) throw new \ RuntimeException ( "Web console not initialized" ) ; foreach ( func_get_args ( ) as $ arg ) $ this -> inspectValue ( $ arg ) ; return $ this ; }
Displays detailed information about each specified value .
33,317
function inspectValue ( $ val , $ alt = null ) { return $ this -> write ( $ this -> getRenderedInspection ( $ val , $ alt ) ) -> write ( ' ' ) ; }
Displays detailed information about the specified value .
33,318
public function log ( $ level , $ message , array $ context = [ ] ) { $ levelName = isset ( self :: $ LEVELS [ $ level ] ) ? self :: $ LEVELS [ $ level ] : $ level ; $ message = Debug :: interpolate ( $ message , $ context ) ; $ this -> write ( "<#log><#i><span class=__alert>$levelName</span> $message</#i></#log>" ) ; }
PSR - 3 - compliant logging method .
33,319
public function withFilter ( callable $ fn ) { $ args = array_slice ( func_get_args ( ) , 1 ) ; $ this -> filter = $ fn ; call_user_func_array ( [ $ this , 'inspect' ] , $ args ) ; $ this -> filter = null ; return $ this ; }
Logs detailed information about the specified values or variables to the PHP console .
33,320
protected function format ( $ msg ) { if ( is_string ( $ msg ) ) { do { $ msg = preg_replace_callback ( '~<\#(\w+) # capture LOG MARKUP TAG (ex: <#tag -> tag)\s* (?: \| ([^>]+) )? # capture optional tag arguments (ex: <#tag|a|b|c> -> a|b|c)>( # capture the tag\'s content (?: # begin loop (?= <\#\1 [ \s\|> ] ) # either the same tag is opened again (<#tag> <#tag| or <#tag(space)) (?R) # and we must recurse | # or .*? # capture everything (?= </\#\1> | <\#\1 [ \s\|> ] ) # until a closing/opening tag with the same name occurs )* # repeat loop) # end capture</\#\1> # consume closing tag~sx' , function ( $ m ) { list ( $ all , $ tag , $ args , $ str ) = $ m ; $ args = $ args ? explode ( '|' , $ args ) : [ ] ; switch ( $ tag ) { case 'i' : return "<div class='__log-item " . get ( $ args , 0 ) . "'>$str</div>" ; case 'row' : return "<div class='__log-item __rowHeader " . get ( $ args , 0 ) . "'>$str</div>" ; case 'section' : return "<div class='__log-section'>" . ( $ args ? "<div class='__log-title'>$args[0]</div>" : '' ) . "$str</div>" ; case 'log' : return "<div class='__log-stripe'>$str</div>" ; case 'data' : return "<div class='__log-data'>$str</div>" ; case 'header' : return "<div class='__header'>$str</div>" ; case 'footer' : return "<div class='__footer'>$str</div>" ; case 'alert' : return "<div class='__alert'>$str</div>" ; case 'type' : $ type = Debug :: shortenType ( $ str ) ; return "<span class='__type'>$type</span>" ; case 'indent' : return "<div class='indent'>$str</div>" ; default : ob_clean ( ) ; throw new \ RuntimeException ( "Invalid log tag <#$tag>" ) ; } } , $ msg , - 1 , $ count ) ; } while ( $ count ) ; } return $ msg ; }
Renders log markup to HTML .
33,321
public function uploadAsset ( $ filePath ) { $ params = array ( 'file' => '@' . $ filePath ) ; $ params = $ this -> validator -> validate ( $ params ) ; $ this -> validator -> validateAssetFile ( $ params [ 'file' ] ) ; try { return $ this -> client -> sendRequest ( 'assets' , $ params , 'POST' ) ; } catch ( \ Exception $ ex ) { throw $ ex ; } }
Uploads new asset to HTMLPDFAPI server
33,322
public function getAsset ( $ id ) { $ params = array ( 'id' => $ id ) ; $ params = $ this -> validator -> validate ( $ params ) ; try { return $ this -> client -> sendRequest ( 'assets/{id}' , $ params , 'GET' ) ; } catch ( \ Exception $ ex ) { throw $ ex ; } }
Downloads asset from server by id
33,323
public function getAssetID ( $ name ) { $ list = $ this -> getAssetList ( ) ; $ list_json = json_decode ( $ list , true ) ; foreach ( $ list_json as $ asset ) { if ( $ asset [ 'name' ] == $ name ) { return $ asset [ 'id' ] ; } } throw new \ Exception ( 'No asset found by name' ) ; }
Gets the asset ID by the name
33,324
public function getConfigFE ( MShop_Order_Item_Base_Interface $ basket ) { $ list = array ( ) ; $ feconfig = $ this -> _feConfig ; try { $ address = $ basket -> getAddress ( ) ; if ( ( $ fn = $ address -> getFirstname ( ) ) !== '' && ( $ ln = $ address -> getLastname ( ) ) !== '' ) { $ feconfig [ 'directdebit.accountowner' ] [ 'default' ] = $ fn . ' ' . $ ln ; } } catch ( MShop_Order_Exception $ e ) { ; } foreach ( $ feconfig as $ key => $ config ) { $ list [ $ key ] = new MW_Common_Criteria_Attribute_Default ( $ config ) ; } return $ list ; }
Returns the configuration attribute definitions of the provider to generate a list of available fields and rules for the value of each field in the frontend .
33,325
public function setConfigFE ( MShop_Order_Item_Base_Service_Interface $ orderServiceItem , array $ attributes ) { parent :: setConfigFE ( $ orderServiceItem , $ attributes ) ; $ attributeItems = $ orderServiceItem -> getAttributes ( ) ; $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base/service/attribute' ) ; if ( ( $ attrItem = $ orderServiceItem -> getAttributeItem ( 'directdebit.accountno' ) ) !== null ) { $ ordBaseAttrItem = $ manager -> createItem ( ) ; $ ordBaseAttrItem -> setType ( $ attrItem -> getType ( ) . '/hidden' ) ; $ ordBaseAttrItem -> setCode ( $ attrItem -> getCode ( ) . '/hidden' ) ; $ ordBaseAttrItem -> setValue ( $ attrItem -> getValue ( ) ) ; $ attributeItems [ ] = $ ordBaseAttrItem ; $ value = $ attrItem -> getValue ( ) ; $ attrItem -> setValue ( str_repeat ( 'X' , strlen ( $ value ) - 3 ) . substr ( $ value , - 3 ) ) ; } $ orderServiceItem -> setAttributes ( $ attributeItems ) ; }
Sets the payment attributes in the given service .
33,326
public function getPropertyOptions ( GetPropertyOptionsEvent $ event ) { if ( ( 'file_imageSize' !== $ event -> getPropertyName ( ) ) || ( 'tl_metamodel_rendersetting' !== $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) ) ) { return ; } if ( ! $ sizes = $ this -> getThemeImageSizes ( ) ) { return ; } $ options = $ event -> getOptions ( ) ; $ options [ 'image_sizes' ] = \ array_replace ( $ sizes , ( array ) $ options [ 'image_sizes' ] ) ; $ event -> setOptions ( $ options ) ; }
Get property options for file image size in the render settings .
33,327
private function getThemeImageSizes ( ) { $ dataProvider = new DefaultDataProvider ( ) ; $ dataProvider -> setBaseConfig ( [ 'source' => 'tl_image_size' ] ) ; $ config = $ dataProvider -> getEmptyConfig ( ) ; $ config -> setFields ( [ 'id' , 'name' , 'width' , 'height' ] ) ; $ config -> setSorting ( [ 'pid' , 'name' ] ) ; $ collection = $ dataProvider -> fetchAll ( $ config ) ; if ( ! $ collection -> count ( ) ) { return [ ] ; } $ sizes = [ ] ; foreach ( $ collection as $ model ) { $ sizes [ $ model -> getProperty ( 'id' ) ] = sprintf ( '%s (%sx%s)' , $ model -> getProperty ( 'name' ) , $ model -> getProperty ( 'width' ) , $ model -> getProperty ( 'height' ) ) ; } return $ sizes ; }
Get the image sizes from the theme .
33,328
protected function instanciate ( $ key , $ parameters = null ) { if ( $ key instanceof \ Closure ) { return call_user_func_array ( $ key , $ parameters ) ; } $ reflection = new \ ReflectionClass ( $ key ) ; return $ reflection -> newInstanceArgs ( $ parameters ) ; }
Instantiate an instance of the given type .
33,329
protected function _getValueFromArray ( $ config , $ parts ) { if ( ( $ key = array_shift ( $ parts ) ) !== null && isset ( $ config [ $ key ] ) ) { if ( count ( $ parts ) > 0 ) { return $ this -> _getValueFromArray ( $ config [ $ key ] , $ parts ) ; } return $ config [ $ key ] ; } return null ; }
Returns the requested configuration value from the given array
33,330
protected function _getOption ( $ name , $ default = null ) { return ( isset ( $ this -> _options [ $ name ] ) ? $ this -> _options [ $ name ] : $ default ) ; }
Returns the configured value for the given name or the default value if nothing is configured .
33,331
public function getCode ( DependencyInterface $ dependency ) : Code { if ( $ dependency instanceof Dependency ) { return $ this -> getDependencyCode ( $ dependency ) ; } elseif ( $ dependency instanceof Instance ) { return $ this -> getInstanceCode ( $ dependency ) ; } elseif ( $ dependency instanceof DependencyProvider ) { return $ this -> getProviderCode ( $ dependency ) ; } throw new \ DomainException ( \ get_class ( $ dependency ) ) ; }
Return compiled dependency code
33,332
private function getDependencyCode ( Dependency $ dependency ) : Code { $ prop = $ this -> privateProperty ; $ node = $ this -> getFactoryNode ( $ dependency ) ; ( $ this -> aopCode ) ( $ dependency , $ node ) ; $ isSingleton = $ prop ( $ dependency , 'isSingleton' ) ; $ node [ ] = $ this -> getIsSingletonCode ( $ isSingleton ) ; $ node [ ] = new Node \ Stmt \ Return_ ( new Node \ Expr \ Variable ( 'instance' ) ) ; $ node = $ this -> factory -> namespace ( 'Ray\Di\Compiler' ) -> addStmts ( $ node ) -> getNode ( ) ; $ qualifer = $ this -> qualifier ; $ this -> qualifier = null ; return new Code ( $ node , $ isSingleton , $ qualifer ) ; }
Compile generic object dependency
33,333
private function getProviderCode ( DependencyProvider $ provider ) : Code { $ prop = $ this -> privateProperty ; $ dependency = $ prop ( $ provider , 'dependency' ) ; $ node = $ this -> getFactoryNode ( $ dependency ) ; $ provider -> setContext ( $ this ) ; if ( $ this -> context ) { $ node [ ] = $ this -> getSetContextCode ( $ this -> context ) ; } $ isSingleton = $ prop ( $ provider , 'isSingleton' ) ; $ node [ ] = $ this -> getIsSingletonCode ( $ isSingleton ) ; $ node [ ] = new Stmt \ Return_ ( new MethodCall ( new Expr \ Variable ( 'instance' ) , 'get' ) ) ; $ node = $ this -> factory -> namespace ( 'Ray\Di\Compiler' ) -> addStmts ( $ node ) -> getNode ( ) ; $ qualifer = $ this -> qualifier ; $ this -> qualifier = null ; return new Code ( $ node , $ isSingleton , $ qualifer ) ; }
Compile dependency provider
33,334
private function getFactoryNode ( DependencyInterface $ dependency ) : array { $ prop = $ this -> privateProperty ; $ newInstance = $ prop ( $ dependency , 'newInstance' ) ; $ class = $ prop ( $ newInstance , 'class' ) ; $ setterMethods = ( array ) $ prop ( $ prop ( $ newInstance , 'setterMethods' ) , 'setterMethods' ) ; $ arguments = ( array ) $ prop ( $ prop ( $ newInstance , 'arguments' ) , 'arguments' ) ; $ postConstruct = ( string ) $ prop ( $ dependency , 'postConstruct' ) ; return $ this -> factoryCompiler -> getFactoryCode ( $ class , $ arguments , $ setterMethods , $ postConstruct ) ; }
Return generic factory code
33,335
public function addOption ( string $ content , string $ value ) { $ this -> options [ ] = new Option ( $ content , $ value ) ; return $ this ; }
Adds an option to this OptionGroup .
33,336
public function addOptions ( array $ options ) : OptionGroup { foreach ( $ options as $ value => $ content ) { $ this -> addOption ( $ content , $ value ) ; } return $ this ; }
Adds a batch of options to this OptionGroup .
33,337
public function getFBInfo ( $ access_token ) { if ( ! empty ( $ this -> mockData ) ) { return $ this -> mockData ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , 'https://graph.facebook.com/me?access_token=' . $ access_token ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , FALSE ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , TRUE ) ; $ response = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return json_decode ( $ response ) ; }
Pulls the Me content from Facebook
33,338
public function update ( MW_Observer_Publisher_Interface $ order , $ action , $ value = null ) { $ this -> _getContext ( ) -> getLogger ( ) -> log ( __METHOD__ . ': event=' . $ action , MW_Logger_Abstract :: DEBUG ) ; $ class = 'MShop_Order_Item_Base_Interface' ; if ( ! ( $ order instanceof $ class ) ) { throw new MShop_Plugin_Provider_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ class ) ) ; } $ this -> _checkWithoutCurrency ( $ order , $ value ) ; $ this -> _checkWithCurrency ( $ order , $ value ) ; return true ; }
Receives a notification from a publisher object .
33,339
protected function _checkWithoutCurrency ( MShop_Order_Item_Base_Interface $ order , MShop_Order_Item_Base_Product_Interface $ value ) { $ config = $ this -> _getItem ( ) -> getConfig ( ) ; if ( isset ( $ config [ 'single-number-max' ] ) && ! is_array ( $ config [ 'single-number-max' ] ) && $ value -> getQuantity ( ) > ( int ) $ config [ 'single-number-max' ] ) { $ msg = sprintf ( 'The maximum product quantity is %1$d' , ( int ) $ config [ 'single-number-max' ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } if ( isset ( $ config [ 'total-number-max' ] ) && ! is_array ( $ config [ 'total-number-max' ] ) ) { $ total = $ value -> getQuantity ( ) ; foreach ( $ order -> getProducts ( ) as $ product ) { $ total += $ product -> getQuantity ( ) ; } if ( $ total > ( int ) $ config [ 'total-number-max' ] ) { $ msg = sprintf ( 'The maximum quantity of all products is %1$d' , ( int ) $ config [ 'total-number-max' ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } } }
Checks for the product limits when the configuration doesn t contain limits per currency .
33,340
protected function _checkWithCurrency ( MShop_Order_Item_Base_Interface $ order , MShop_Order_Item_Base_Product_Interface $ value ) { $ config = $ this -> _getItem ( ) -> getConfig ( ) ; $ currencyId = $ value -> getPrice ( ) -> getCurrencyId ( ) ; if ( isset ( $ config [ 'single-value-max' ] [ $ currencyId ] ) && $ value -> getPrice ( ) -> getValue ( ) * $ value -> getQuantity ( ) > ( float ) $ config [ 'single-value-max' ] [ $ currencyId ] ) { $ msg = sprintf ( 'The maximum product value is %1$s' , $ config [ 'single-value-max' ] [ $ currencyId ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } if ( isset ( $ config [ 'total-value-max' ] [ $ currencyId ] ) ) { $ price = clone $ value -> getPrice ( ) ; $ price -> setValue ( $ price -> getValue ( ) * $ value -> getQuantity ( ) ) ; foreach ( $ order -> getProducts ( ) as $ product ) { $ price -> addItem ( $ product -> getPrice ( ) , $ product -> getQuantity ( ) ) ; } if ( ( float ) $ price -> getValue ( ) > ( float ) $ config [ 'total-value-max' ] [ $ currencyId ] ) { $ msg = sprintf ( 'The maximum value of all products is %1$s' , $ config [ 'total-value-max' ] [ $ currencyId ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } } }
Checks for the product limits when the configuration contains limits per currency .
33,341
public function getFileLoader ( ) : LoaderInterface { if ( ! isset ( $ this -> fileLoader ) ) { $ this -> fileLoader = new DelegateLoader ( ) ; } return $ this -> fileLoader ; }
Get the file loader
33,342
protected function assertDir ( string $ dir , array $ options ) { if ( is_dir ( $ dir ) ) { return true ; } if ( ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "Config directory '$dir' doesn't exist" ) ; } return false ; }
Assert the directory exists
33,343
protected function loadFile ( string $ file , array $ options ) : ? Config { if ( is_dir ( $ file ) ) { return ( bool ) ( $ options [ 'recursive' ] ?? false ) ? $ this -> load ( $ file , $ options ) : null ; } return $ this -> getFileLoader ( ) -> load ( $ file , $ options ) ; }
Load a file or subdirectory
33,344
public function load ( $ dir , array $ options = [ ] ) { $ config = new Config ( ) ; if ( ! $ this -> assertDir ( $ dir , $ options ) ) { return $ config ; } $ dir = rtrim ( $ dir , DIRECTORY_SEPARATOR ) ; foreach ( scandir ( $ dir ) as $ file ) { if ( $ file [ 0 ] == '.' ) { continue ; } $ key = pathinfo ( $ file , PATHINFO_FILENAME ) ; $ data = $ this -> loadFile ( $ dir . DIRECTORY_SEPARATOR . $ file , $ options ) ; if ( ! isset ( $ data ) ) { continue ; } if ( isset ( $ config -> $ key ) && $ config -> $ key instanceof Config ) { $ config -> $ key -> merge ( $ data ) ; } else { $ config -> $ key = $ data ; } } return $ config ; }
Load a config directory
33,345
protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'text.id' : $ item -> setId ( $ value ) ; break ; case 'text.domain' : $ item -> setDomain ( $ value ) ; break ; case 'text.typeid' : $ item -> setTypeId ( $ value ) ; break ; case 'text.status' : $ item -> setStatus ( $ value ) ; break ; case 'text.content' : $ item -> setContent ( trim ( preg_replace ( '/(<br>|\r|\n)+$/' , '' , $ value ) ) ) ; break ; case 'text.label' : $ item -> setLabel ( trim ( preg_replace ( '/(<br>|\r|\n)+/' , ' ' , $ value ) ) ) ; break ; case 'text.languageid' : if ( $ value != '' ) { $ item -> setLanguageId ( $ value ) ; } break ; } } if ( $ item -> getLabel ( ) == '' ) { $ item -> setLabel ( mb_strcut ( trim ( preg_replace ( '/(<br>|\r|\n)+/' , ' ' , $ item -> getContent ( ) ) ) , 0 , 255 ) ) ; } return $ item ; }
Creates a new text item and sets the properties from the given object .
33,346
private function getInstanceFile ( string $ dependencyIndex ) : string { $ file = \ sprintf ( self :: INSTANCE , $ this -> scriptDir , \ str_replace ( '\\' , '_' , $ dependencyIndex ) ) ; if ( \ file_exists ( $ file ) ) { return $ file ; } $ this -> compileOnDemand ( $ dependencyIndex ) ; return $ file ; }
Return compiled script file name
33,347
public function setLabel ( $ name ) { if ( $ name == $ this -> getLabel ( ) ) { return ; } $ this -> _values [ 'label' ] = ( string ) $ name ; $ this -> setModified ( ) ; }
Sets the label of the coupon item .
33,348
public function setConfig ( array $ config ) { if ( $ config == $ this -> getConfig ( ) ) { return ; } $ this -> _values [ 'config' ] = $ config ; $ this -> setModified ( ) ; }
Sets the new configuration for the coupon item .
33,349
public function getCache ( ) { if ( ! isset ( $ this -> _object ) ) { $ context = $ this -> _getContext ( ) ; $ config = $ context -> getConfig ( ) ; $ name = $ config -> get ( 'resource/db/adapter' ) ; $ name = $ config -> get ( 'resource/db-cache/adapter' , $ name ) ; $ name = $ config -> get ( 'classes/cache/name' , $ name ) ; $ config = array ( 'search' => $ this -> _searchConfig , 'dbname' => $ this -> _getResourceName ( ) , 'siteid' => $ context -> getLocale ( ) -> getSiteId ( ) , 'sql' => array ( 'delete' => $ config -> get ( 'madmin/cache/manager/default/delete' ) , 'deletebytag' => $ config -> get ( 'madmin/cache/manager/default/deletebytag' ) , 'getbytag' => $ config -> get ( 'madmin/cache/manager/default/getbytag' ) , 'get' => $ config -> get ( 'madmin/cache/manager/default/get' ) , 'set' => $ config -> get ( 'madmin/cache/manager/default/set' ) , 'settag' => $ config -> get ( 'madmin/cache/manager/default/settag' ) , ) , ) ; $ dbm = $ context -> getDatabaseManager ( ) ; try { $ this -> _object = MW_Cache_Factory :: createManager ( $ name , $ config , $ dbm ) ; } catch ( Exception $ e ) { $ this -> _object = MW_Cache_Factory :: createManager ( 'DB' , $ config , $ dbm ) ; } } return $ this -> _object ; }
Returns the cache object
33,350
public function saveItem ( MShop_Common_Item_Interface $ item , $ fetch = true ) { $ iface = 'MAdmin_Cache_Item_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MAdmin_Cache_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( ! $ item -> isModified ( ) ) { return ; } $ id = $ item -> getId ( ) ; $ cache = $ this -> getCache ( ) ; $ cache -> delete ( $ id ) ; $ cache -> set ( $ id , $ item -> getValue ( ) , $ item -> getTags ( ) , $ item -> getTimeExpire ( ) ) ; }
Adds a new cache to the storage .
33,351
public function getItem ( $ id , array $ ref = array ( ) ) { if ( ( $ value = $ this -> getCache ( ) -> get ( $ id ) ) === null ) { throw new MAdmin_Cache_Exception ( sprintf ( 'Item with ID "%1$s" not found' , $ id ) ) ; } return $ this -> _createItem ( array ( 'id' => $ id , 'value' => $ value ) ) ; }
Creates the cache object for the given cache id .
33,352
public function create ( array $ data = [ ] ) { $ data = array_filter ( $ data ) ; if ( ! isset ( $ data [ 'name' ] ) || ! isset ( $ data [ 'type' ] ) ) { throw new \ LogicException ( 'Missing one of the mandatory field!' ) ; } if ( ! isset ( $ data [ 'value' ] ) ) { $ data [ 'value' ] = 0 ; } $ name = $ data [ 'name' ] ; $ existingSetting = $ this -> get ( $ name ) ; if ( $ existingSetting ) { throw new \ LogicException ( sprintf ( 'Setting %s already exists.' , $ name ) ) ; } $ settingClass = $ this -> repo -> getClassName ( ) ; $ setting = new $ settingClass ( ) ; $ this -> eventDispatcher -> dispatch ( Events :: PRE_CREATE , new SettingActionEvent ( $ name , $ data , $ setting ) ) ; foreach ( $ data as $ key => $ value ) { $ setting -> { 'set' . ucfirst ( $ key ) } ( $ value ) ; } $ this -> manager -> persist ( $ setting ) ; $ this -> manager -> commit ( ) ; $ this -> eventDispatcher -> dispatch ( Events :: POST_CREATE , new SettingActionEvent ( $ name , $ data , $ setting ) ) ; return $ setting ; }
Creates setting .
33,353
public function update ( $ name , $ data = [ ] ) { $ setting = $ this -> get ( $ name ) ; if ( ! $ setting ) { throw new \ LogicException ( sprintf ( 'Setting %s not exist.' , $ name ) ) ; } $ this -> eventDispatcher -> dispatch ( Events :: PRE_UPDATE , new SettingActionEvent ( $ name , $ data , $ setting ) ) ; foreach ( $ data as $ key => $ value ) { $ setting -> { 'set' . ucfirst ( $ key ) } ( $ value ) ; } $ this -> manager -> persist ( $ setting ) ; $ this -> manager -> commit ( ) ; $ this -> cache -> delete ( $ name ) ; if ( $ setting -> getType ( ) == 'experiment' || $ setting -> getName ( ) == 'ongr_active_experiments' ) { $ this -> getActiveExperimentProfilesCookie ( ) -> setClear ( true ) ; } $ this -> eventDispatcher -> dispatch ( Events :: PRE_UPDATE , new SettingActionEvent ( $ name , $ data , $ setting ) ) ; return $ setting ; }
Overwrites setting parameters with given name .
33,354
public function getValue ( $ name , $ default = null ) { $ setting = $ this -> get ( $ name ) ; if ( $ setting ) { return $ setting -> getValue ( ) ; } return $ default ; }
Get setting value by current active profiles setting .
33,355
public function getCachedValue ( $ name , $ checkWithActiveProfiles = true ) { if ( $ this -> cache -> contains ( $ name ) ) { $ setting = $ this -> cache -> fetch ( $ name ) ; } elseif ( $ this -> has ( $ name ) ) { $ settingDocument = $ this -> get ( $ name ) ; $ setting = [ 'value' => $ settingDocument -> getValue ( ) , 'profiles' => $ settingDocument -> getProfile ( ) , ] ; $ this -> cache -> save ( $ name , $ setting ) ; } else { return null ; } if ( $ checkWithActiveProfiles ) { if ( count ( array_intersect ( $ this -> getActiveProfiles ( ) , $ setting [ 'profiles' ] ) ) ) { return $ setting [ 'value' ] ; } return null ; } return $ setting [ 'value' ] ; }
Get setting value by checking also from cache engine .
33,356
public function getAllProfiles ( ) { $ profiles = [ ] ; $ search = $ this -> repo -> createSearch ( ) ; $ filter = new BoolQuery ( ) ; $ filter -> add ( new TermQuery ( 'type' , 'experiment' ) , BoolQuery :: MUST_NOT ) ; $ topHitsAgg = new TopHitsAggregation ( 'documents' , 20 ) ; $ termAgg = new TermsAggregation ( 'profiles' , 'profile.profile' ) ; $ filterAgg = new FilterAggregation ( 'filter' , $ filter ) ; $ termAgg -> addAggregation ( $ topHitsAgg ) ; $ filterAgg -> addAggregation ( $ termAgg ) ; $ search -> addAggregation ( $ filterAgg ) ; $ result = $ this -> repo -> findDocuments ( $ search ) ; $ activeProfiles = $ this -> getValue ( $ this -> activeProfilesSettingName , [ ] ) ; foreach ( $ result -> getAggregation ( 'filter' ) -> getAggregation ( 'profiles' ) as $ agg ) { $ settings = [ ] ; $ docs = $ agg -> getAggregation ( 'documents' ) ; foreach ( $ docs [ 'hits' ] [ 'hits' ] as $ doc ) { $ settings [ ] = $ doc [ '_source' ] [ 'name' ] ; } $ name = $ agg -> getValue ( 'key' ) ; $ profiles [ ] = [ 'active' => $ activeProfiles ? in_array ( $ agg -> getValue ( 'key' ) , ( array ) $ activeProfiles ) : false , 'name' => $ name , 'settings' => implode ( ', ' , $ settings ) , ] ; } return $ profiles ; }
Get all full profile information .
33,357
public function getProfileSettings ( $ profile ) { $ search = $ this -> repo -> createSearch ( ) ; $ termQuery = new TermQuery ( 'profile' , $ profile ) ; $ search -> addQuery ( $ termQuery ) ; $ search -> setSize ( 1000 ) ; $ settings = $ this -> repo -> findArray ( $ search ) ; return $ settings ; }
Returns profiles settings array
33,358
public function getActiveProfiles ( ) { if ( $ this -> cache -> contains ( $ this -> activeProfilesSettingName ) ) { $ profiles = $ this -> cache -> fetch ( $ this -> activeProfilesSettingName ) ; } else { $ profiles = [ ] ; $ allProfiles = $ this -> getAllProfiles ( ) ; foreach ( $ allProfiles as $ profile ) { if ( ! $ profile [ 'active' ] ) { continue ; } $ profiles [ ] = $ profile [ 'name' ] ; } $ this -> cache -> save ( $ this -> activeProfilesSettingName , $ profiles ) ; } $ profiles = array_merge ( $ profiles , $ this -> activeProfilesList ) ; return $ profiles ; }
Returns cached active profiles names list .
33,359
public function getActiveExperiments ( ) { if ( $ this -> cache -> contains ( $ this -> activeExperimentsSettingName ) ) { return $ this -> cache -> fetch ( $ this -> activeExperimentsSettingName ) [ 'value' ] ; } if ( $ this -> has ( $ this -> activeExperimentsSettingName ) ) { $ experiments = $ this -> get ( $ this -> activeExperimentsSettingName ) -> getValue ( ) ; } else { $ this -> create ( [ 'name' => $ this -> activeExperimentsSettingName , 'value' => [ ] , 'type' => 'hidden' , ] ) ; $ experiments = [ ] ; } $ this -> cache -> save ( $ this -> activeExperimentsSettingName , [ 'value' => $ experiments ] ) ; return $ experiments ; }
Returns an array of active experiments names either from cache or from es . If none are found the setting with no active experiments is created .
33,360
public function getCachedExperiment ( $ name ) { if ( $ this -> cache -> contains ( $ name ) ) { $ experiment = $ this -> cache -> fetch ( $ name ) ; } elseif ( $ this -> has ( $ name ) ) { $ experiment = $ this -> get ( $ name ) -> getSerializableData ( ) ; } else { return null ; } if ( ! isset ( $ experiment [ 'type' ] ) || $ experiment [ 'type' ] !== 'experiment' ) { throw new LogicException ( sprintf ( 'The setting `%s` was found but it is not an experiment' , $ name ) ) ; } $ this -> cache -> save ( $ name , $ experiment ) ; return $ experiment ; }
Get full experiment by caching .
33,361
public function createItem ( ) { try { $ siteid = $ this -> _getContext ( ) -> getLocale ( ) -> getSiteId ( ) ; } catch ( Exception $ e ) { $ siteid = null ; } $ values = array ( 'siteid' => $ siteid ) ; return $ this -> _createItem ( $ values ) ; }
Create new log item object .
33,362
public function saveItem ( MShop_Common_Item_Interface $ item , $ fetch = true ) { $ iface = 'MAdmin_Log_Item_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MAdmin_Log_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( ! $ item -> isModified ( ) ) { return ; } $ context = $ this -> _getContext ( ) ; try { $ siteid = $ context -> getLocale ( ) -> getSiteId ( ) ; } catch ( Exception $ e ) { $ siteid = null ; } $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; if ( $ id === null ) { $ path = 'madmin/log/manager/default/insert' ; } else { $ path = 'madmin/log/manager/default/update' ; } $ stmt = $ this -> _getCachedStatement ( $ conn , $ path ) ; $ stmt -> bind ( 1 , $ siteid , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ item -> getFacility ( ) ) ; $ stmt -> bind ( 3 , date ( 'Y-m-d H:i:s' ) ) ; $ stmt -> bind ( 4 , $ item -> getPriority ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 5 , $ item -> getMessage ( ) ) ; $ stmt -> bind ( 6 , $ item -> getRequest ( ) ) ; if ( $ item -> getId ( ) !== null ) { $ stmt -> bind ( 7 , $ item -> getId ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ item -> setId ( $ id ) ; } $ stmt -> execute ( ) -> finish ( ) ; if ( $ id === null && $ fetch === true ) { $ path = 'madmin/log/manager/default/newid' ; $ item -> setId ( $ this -> _newId ( $ conn , $ context -> getConfig ( ) -> get ( $ path , $ path ) ) ) ; } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } }
Adds a new log to the storage .
33,363
public function setContent ( $ text ) { if ( $ text == $ this -> getContent ( ) ) { return ; } @ ini_set ( 'mbstring.substitute_character' , 'none' ) ; $ this -> _values [ 'content' ] = @ mb_convert_encoding ( ( string ) $ text , 'UTF-8' , 'UTF-8' ) ; $ this -> setModified ( ) ; }
Sets the content of the text item .
33,364
public function getSearchAttributes ( $ withsub = true ) { $ path = 'classes/catalog/manager/index/attribute/submanagers' ; $ list = $ this -> _getSearchAttributes ( $ this -> _searchConfig , $ path , array ( ) , $ withsub ) ; $ list += MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product' ) -> getSearchAttributes ( $ withsub ) ; return $ list ; }
Returns a list of objects describing the available criterias for searching .
33,365
protected function _getSubManagers ( ) { $ list = array ( ) ; $ path = 'classes/catalog/manager/index/catalog/submanagers' ; foreach ( $ this -> _getContext ( ) -> getConfig ( ) -> get ( $ path , array ( ) ) as $ domain ) { $ list [ $ domain ] = $ this -> getSubManager ( $ domain ) ; } return $ list ; }
Returns the list of sub - managers available for the catalog index catalog manager .
33,366
protected function _process ( $ stmts ) { $ this -> _msg ( 'Renameing shipping to costs in catalog index price table' , 0 ) ; if ( $ this -> _schema -> tableExists ( 'mshop_catalog_index_price' ) === true && $ this -> _schema -> columnExists ( 'mshop_catalog_index_price' , 'shipping' ) === true ) { $ this -> _execute ( $ stmts ) ; $ this -> _status ( 'done' ) ; } else { $ this -> _status ( 'OK' ) ; } }
Add column to table if it doesn t exist .
33,367
public function block ( MShop_Order_Item_Interface $ orderItem ) { $ status = 1 ; $ orderId = $ orderItem -> getId ( ) ; $ this -> _updateStatus ( MShop_Order_Item_Status_Abstract :: STOCK_UPDATE , $ orderId , $ orderItem , $ status , - 1 ) ; $ this -> _updateStatus ( MShop_Order_Item_Status_Abstract :: COUPON_UPDATE , $ orderId , $ orderItem , $ status , - 1 ) ; }
Blocks the resources listed in the order .
33,368
public function update ( MShop_Order_Item_Interface $ orderItem ) { switch ( $ orderItem -> getPaymentStatus ( ) ) { case MShop_Order_Item_Abstract :: PAY_DELETED : case MShop_Order_Item_Abstract :: PAY_CANCELED : case MShop_Order_Item_Abstract :: PAY_REFUSED : case MShop_Order_Item_Abstract :: PAY_REFUND : $ this -> unblock ( $ orderItem ) ; break ; case MShop_Order_Item_Abstract :: PAY_PENDING : case MShop_Order_Item_Abstract :: PAY_AUTHORIZED : case MShop_Order_Item_Abstract :: PAY_RECEIVED : $ this -> block ( $ orderItem ) ; break ; } }
Blocks or frees the resources listed in the order if necessary .
33,369
protected function makeBot ( $ name ) { $ config = $ this -> getBotConfig ( $ name ) ; $ token = array_get ( $ config , 'token' ) ; $ commands = array_get ( $ config , 'commands' , [ ] ) ; $ callbacks = array_get ( $ config , 'callbacks' , [ ] ) ; $ telegram = new Api ( $ token , $ this -> getConfig ( 'async_requests' , false ) , $ this -> getConfig ( 'http_client_handler' , null ) ) ; if ( $ this -> getConfig ( 'resolve_command_dependencies' , false ) && isset ( $ this -> container ) ) { $ telegram -> setContainer ( $ this -> container ) ; } $ commands = $ this -> parseBotCommands ( $ commands ) ; $ callbacks = $ this -> parseCallbacks ( $ callbacks ) ; $ telegram -> addCommands ( $ commands ) ; $ telegram -> getCallbackBus ( ) -> addCallbackCommands ( $ callbacks ) ; return $ telegram ; }
Make the bot instance .
33,370
protected function _addAttributes ( MShop_Common_Item_Interface $ item , MShop_Order_Item_Base_Product_Interface $ product , array $ properties ) { $ attributeList = $ product -> getAttributes ( ) ; $ itemProperties = $ item -> toArray ( ) ; foreach ( $ properties as $ current ) { if ( array_key_exists ( $ current , $ itemProperties ) && ( $ new = $ this -> _createAttribute ( $ product , $ current , $ itemProperties [ $ current ] ) ) !== null ) { $ attributeList [ ] = $ new ; } } return $ attributeList ; }
Adds attribute items to an array .
33,371
protected function _createAttribute ( MShop_Order_Item_Base_Product_Interface $ product , $ code , $ value , $ name = null ) { if ( $ product -> getAttribute ( $ code ) !== null ) { return null ; } $ new = $ this -> _orderAttrManager -> createItem ( ) ; $ new -> setCode ( $ code ) ; $ new -> setType ( $ this -> _type ) ; $ new -> setName ( $ name ) ; $ new -> setValue ( $ value ) ; return $ new ; }
Creates an attribute with given values for code type name and value
33,372
public function findNode ( string $ name ) : ? Node { foreach ( $ this -> nodes as $ node ) { if ( $ node instanceof self && ! empty ( $ node -> name ) ) { if ( $ node -> name === $ name ) { return $ node ; } if ( $ found = $ node -> findNode ( $ name ) ) { return $ found ; } } } return null ; }
Recursively find a children node by it s name .
33,373
protected function parseTokens ( array $ tokens ) { $ activeToken = [ ] ; $ activeLevel = 0 ; $ activeContent = [ ] ; foreach ( $ tokens as $ token ) { $ tokenType = $ token [ HtmlTokenizer :: TOKEN_TYPE ] ; if ( empty ( $ activeToken ) ) { switch ( $ tokenType ) { case HtmlTokenizer :: TAG_VOID : case HtmlTokenizer :: TAG_SHORT : $ this -> mountToken ( $ token ) ; break ; case HtmlTokenizer :: TAG_OPEN : $ activeToken = $ token ; break ; case HtmlTokenizer :: TAG_CLOSE : if ( $ this -> compiler -> getSyntax ( ) -> isStrict ( ) ) { throw new StrictSyntaxException ( "Unpaired close tag '{$token[HtmlTokenizer::TOKEN_NAME]}'." , $ token ) ; } break ; case HtmlTokenizer :: PLAIN_TEXT : $ this -> mountContent ( [ $ token ] ) ; break ; } continue ; } if ( $ tokenType != HtmlTokenizer :: PLAIN_TEXT && $ token [ HtmlTokenizer :: TOKEN_NAME ] == $ activeToken [ HtmlTokenizer :: TOKEN_NAME ] ) { if ( $ tokenType == HtmlTokenizer :: TAG_OPEN ) { $ activeContent [ ] = $ token ; $ activeLevel ++ ; } elseif ( $ tokenType == HtmlTokenizer :: TAG_CLOSE ) { if ( $ activeLevel === 0 ) { $ this -> mountToken ( $ activeToken , $ activeContent , $ token ) ; $ activeToken = $ activeContent = [ ] ; } else { $ activeContent [ ] = $ token ; $ activeLevel -- ; } } else { $ activeContent [ ] = $ token ; } continue ; } $ activeContent [ ] = $ token ; } $ this -> mountContent ( $ activeContent ) ; }
Parse set of tokens provided by html Tokenizer and create blocks and other control constructions . Basically it will try to created html tree .
33,374
private function mountContent ( $ content ) { if ( $ this -> extended || empty ( $ content ) ) { return ; } if ( is_array ( $ content ) ) { $ plainContent = '' ; foreach ( $ content as $ token ) { $ plainContent .= $ token [ HtmlTokenizer :: TOKEN_CONTENT ] ; } $ content = $ plainContent ; } $ matches = $ this -> compiler -> getSyntax ( ) -> parseBlock ( $ content ) ; if ( ! empty ( $ matches ) ) { $ chunks = explode ( $ matches [ 0 ] , $ content ) ; $ this -> mountContent ( array_shift ( $ chunks ) ) ; $ this -> mountBlock ( $ matches [ 'name' ] , isset ( $ matches [ 'default' ] ) ? $ matches [ 'default' ] : '' ) ; $ this -> mountContent ( join ( $ matches [ 0 ] , $ chunks ) ) ; return ; } if ( is_string ( end ( $ this -> nodes ) ) ) { $ this -> nodes [ key ( $ this -> nodes ) ] .= $ content ; return ; } $ this -> nodes [ ] = $ content ; }
Register string node content .
33,375
protected function applyBehaviour ( BehaviourInterface $ behaviour , array $ content = [ ] ) { if ( $ behaviour instanceof ExtendParent ) { $ this -> nodes = $ behaviour -> getNode ( ) -> nodes ; $ this -> extended = true ; foreach ( $ behaviour -> getAttributes ( ) as $ block => $ blockContent ) { $ this -> mountBlock ( $ block , $ blockContent ) ; } return ; } if ( $ behaviour instanceof CreateNode ) { $ this -> mountBlock ( $ behaviour -> getName ( ) , $ content ) ; return ; } if ( $ behaviour instanceof ReplaceNode ) { $ this -> nodes [ ] = $ behaviour -> createNode ( ) ; } }
Once supervisor defined custom token behaviour we can process it s content accordingly .
33,376
private function replaceNode ( Node $ node ) { if ( ! empty ( $ inner = $ node -> findNode ( $ this -> name ) ) ) { $ inner -> nodes = $ this -> nodes ; } $ this -> nodes = $ node -> nodes ; }
Replace node content with content provided by external node external node can still use content of parent block by defining block named identical to it s parent .
33,377
public function start ( $ identifier = null , $ force = false ) { if ( $ this -> currentImport instanceof Import ) { throw new Exception ( 'Unable to start a new import, please stop the current import first' , 1426638560 ) ; } if ( $ identifier !== null ) { $ existingImport = $ this -> importRepository -> findOneByExternalImportIdentifier ( $ identifier ) ; if ( ! $ force && $ existingImport instanceof Import ) { throw new ImportAlreadyExecutedException ( sprintf ( 'An import referring to the external identifier "%s" has already been executed on %s.' , $ identifier , $ existingImport -> getStartTime ( ) -> format ( 'd.m.Y h:m:s' ) ) , 1464028408403 ) ; } } $ this -> currentImport = new Import ( ) ; $ this -> currentImport -> setExternalImportIdentifier ( $ identifier ) ; if ( $ force && isset ( $ existingImport ) ) { $ this -> addEventMessage ( sprintf ( 'ImportService:start' , 'Forcing re-import of data set with external identifier "%s".' , $ identifier ) , LOG_NOTICE ) ; } $ this -> importRepository -> add ( $ this -> currentImport ) ; $ this -> persistenceManager -> persistAll ( ) ; }
Start a new Import
33,378
public function stop ( ) { if ( ! $ this -> currentImport instanceof Import ) { throw new Exception ( 'Unable to stop the current import, please start an import first' , 1426638563 ) ; } $ this -> currentImport -> end ( ) ; $ this -> importRepository -> update ( $ this -> currentImport ) ; $ this -> lastImport = clone $ this -> currentImport ; unset ( $ this -> currentImport ) ; }
Stop and store the current Import
33,379
public function getHTMLFragments ( $ grid ) { $ dataClass = $ grid -> getList ( ) -> dataClass ( ) ; $ obj = singleton ( $ dataClass ) ; if ( ! $ obj -> canCreate ( ) ) { return "" ; } $ text_field = TextField :: create ( "gridfieldaddbydbfield" ) -> setAttribute ( "placeholder" , _t ( "GridFieldAddLineItem.TypeToAdd" , "Type to add by {Filters} or {Title}" , "Inform the user what to add based on" , [ "Filters" => implode ( ", " , $ this -> getFilterFields ( ) ) , "Title" => $ this -> getCreateField ( ) ] ) ) -> addExtraClass ( "relation-search no-change-track" ) -> setAttribute ( 'data-search-url' , Controller :: join_links ( $ grid -> Link ( 'search' ) ) ) ; $ find_action = GridField_FormAction :: create ( $ grid , 'gridfield_relationfind' , _t ( 'GridField.Find' , "Find" ) , 'find' , 'find' ) ; $ find_action -> setAttribute ( 'data-icon' , 'relationfind' ) ; $ add_action = GridField_FormAction :: create ( $ grid , 'gridfield_lineitemadd' , _t ( "GridFieldAddLineItem.Add" , "Add" ) , 'add' , 'add' ) ; $ add_action -> addExtraClass ( 'btn btn-primary font-icon-plus-circled' ) ; $ add_action -> addExtraClass ( 'action_gridfield_relationadd' ) ; $ fields = ArrayList :: create ( ) ; $ fields -> push ( $ text_field ) ; $ fields -> push ( $ find_action ) ; $ fields -> push ( $ add_action ) ; $ forTemplate = ArrayData :: create ( [ ] ) ; $ forTemplate -> Fields = $ fields ; return [ $ this -> targetFragment => $ forTemplate -> renderWith ( AddLineItem :: class ) ] ; }
Renders the TextField and add button to the GridField .
33,380
public function callback ( $ opcode , $ subject , $ offset , $ length ) { if ( $ opcode === 'd' ) { return ; } if ( $ opcode === 'c' ) { return htmlentities ( substr ( $ subject , $ offset , $ length ) ) ; } return '<ins>' . htmlentities ( substr ( $ subject , $ offset , $ length ) ) . '</ins>' ; }
Render an insertion diff .
33,381
public function createSearch ( $ default = false ) { $ search = parent :: createSearch ( $ default ) ; if ( $ default === true ) { $ expr = array ( $ search -> getConditions ( ) , $ search -> compare ( '!=' , 'order.statuspayment' , MShop_Order_Item_Abstract :: PAY_UNFINISHED ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; } return $ search ; }
Creates a search object .
33,382
protected function _addStatus ( MShop_Order_Item_Interface $ item ) { $ statusManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/status' ) ; $ statusItem = $ statusManager -> createItem ( ) ; $ statusItem -> setParentId ( $ item -> getId ( ) ) ; if ( $ item -> getPaymentStatus ( ) != $ item -> oldPaymentStatus ) { $ statusItem -> setId ( null ) ; $ statusItem -> setType ( MShop_Order_Item_Status_Abstract :: STATUS_PAYMENT ) ; $ statusItem -> setValue ( $ item -> getPaymentStatus ( ) ) ; $ statusManager -> saveItem ( $ statusItem , false ) ; } if ( $ item -> getDeliveryStatus ( ) != $ item -> oldDeliveryStatus ) { $ statusItem -> setId ( null ) ; $ statusItem -> setType ( MShop_Order_Item_Status_Abstract :: STATUS_DELIVERY ) ; $ statusItem -> setValue ( $ item -> getDeliveryStatus ( ) ) ; $ statusManager -> saveItem ( $ statusItem , false ) ; } }
Adds the new payment and delivery values to the order status log .
33,383
protected function getUnauthorizedResponse ( ) { $ authHeaderValue = $ this -> realm === null ? static :: AUTHENTICATION_SCHEME : static :: AUTHENTICATION_SCHEME . ' realm="' . $ this -> realm . '"' ; return $ this -> integration -> createResponse ( null , Response :: HTTP_UNAUTHORIZED , [ self :: HEADER_WWW_AUTHENTICATE => $ authHeaderValue ] ) ; }
Get response for invalid authentication credentials .
33,384
public function setService ( IPReflectionClass $ class ) { $ this -> services [ $ class -> classname ] = $ class ; $ this -> services [ $ class -> classname ] -> getMethods ( false , false ) ; }
Adds the class to the services for this WSDL .
33,385
private function addOperation ( $ operationName , $ serviceName ) { $ this -> addToDebug ( "Adding Operation: '$operationName : $serviceName'" ) ; $ operationTag = $ this -> addElement ( 'wsdl:operation' , $ this -> portTypeTags [ $ serviceName ] ) ; $ operationTag -> setAttribute ( 'name' , $ operationName ) ; $ bindingOperationTag = $ this -> addElement ( 'wsdl:operation' , $ this -> bindingTags [ $ serviceName ] ) ; $ bindingOperationTag -> setAttribute ( 'name' , $ operationName ) ; $ soapOperationTag = $ this -> addElement ( 'soap:operation' , $ bindingOperationTag ) ; $ soapOperationTag -> setAttribute ( 'soapAction' , $ this -> url . '&method=' . $ operationName ) ; $ soapOperationTag -> setAttribute ( 'style' , ( $ this -> binding_style == SOAP_RPC ) ? 'rpc' : 'document' ) ; $ this -> operationTags [ $ serviceName ] [ $ operationName ] = $ operationTag ; $ this -> bindingOperationTags [ $ serviceName ] [ $ operationName ] = $ bindingOperationTag ; return $ operationTag ; }
Adds a new operation to the given service .
33,386
private function addService ( $ serviceName ) { $ this -> addToDebug ( "Adding service: '$serviceName'" ) ; $ serviceTag = $ this -> addElement ( 'wsdl:service' , $ this -> definitions ) ; $ serviceTag -> setAttribute ( 'name' , $ serviceName ) ; $ portTag = $ this -> addElement ( 'wsdl:port' , $ serviceTag ) ; $ portTag -> setAttribute ( 'name' , $ serviceName . 'Port' ) ; $ portTag -> setAttribute ( 'binding' , 'tns:' . $ serviceName . 'Binding' ) ; $ addressTag = $ this -> addElement ( 'soap:address' , $ portTag ) ; $ addressTag -> setAttribute ( 'location' , $ this -> url ) ; $ this -> serviceTags [ $ serviceName ] = $ serviceTag ; return $ serviceTag ; }
adds a new service tag to the WSDL file .
33,387
private function addPortType ( $ serviceName ) { $ this -> addToDebug ( "Adding portType: '$serviceName'" ) ; $ portTypeTag = $ this -> addElement ( 'wsdl:portType' ) ; $ portTypeTag -> setAttribute ( 'name' , $ serviceName . 'PortType' ) ; $ this -> portTypeTags [ $ serviceName ] = $ portTypeTag ; return $ portTypeTag ; }
Adds a new portType to the WSDL structure .
33,388
private function addBinding ( $ serviceName ) { $ this -> addToDebug ( "Adding binding: '$serviceName'" ) ; $ bindingTag = $ this -> addElement ( 'binding' , $ this -> definitions ) ; $ bindingTag -> setAttribute ( 'name' , $ serviceName . 'Binding' ) ; $ bindingTag -> setAttribute ( 'type' , 'tns:' . $ serviceName . 'PortType' ) ; $ soapBindingTag = $ this -> addElement ( 'soap:binding' , $ bindingTag ) ; $ soapBindingTag -> setAttribute ( 'style' , ( $ this -> binding_style == SOAP_RPC ) ? 'rpc' : 'document' ) ; $ soapBindingTag -> setAttribute ( 'transport' , 'http://schemas.xmlsoap.org/soap/http' ) ; $ this -> bindingTags [ $ serviceName ] = $ bindingTag ; return $ bindingTag ; }
Adds a new binding to the WSDL structure .
33,389
private function addMessage ( $ name , $ parts ) { $ this -> addToDebug ( "Adding message: '$name'" ) ; $ msg = $ this -> addElement ( 'message' , $ this -> definitions ) ; $ msg -> setAttribute ( 'name' , $ name ) ; foreach ( ( array ) $ parts as $ partName => $ partType ) { $ this -> addToDebug ( "Adding Message part: '$partName => $partType'" ) ; $ part = $ this -> addElement ( 'part' , $ msg ) ; $ this -> xmlSchema -> addType ( $ partType , $ partName , $ part ) ; } }
Adds a message tag to the WSDL document .
33,390
public function setLocation ( string $ file , int $ line ) { $ this -> file = $ file ; $ this -> line = $ line ; }
Set exception location .
33,391
public function getFullName ( ) { $ args = $ this -> getParameters ( ) ; $ argstr = '' ; foreach ( ( array ) $ args as $ arg ) { if ( $ argstr != '' ) { $ argstr .= ', ' ; } $ argstr .= $ arg -> type . ' $' . $ arg -> name ; } return $ this -> return . ' ' . $ this -> name . '(' . $ argstr . ')' ; }
Returns the full function name including arguments .
33,392
public function getParameters ( ) { $ this -> parameters = array ( ) ; $ ar = parent :: getParameters ( ) ; foreach ( ( array ) $ ar as $ i => $ parameter ) { $ parameter -> type = '' ; try { $ ref = $ parameter -> getClass ( ) ; if ( $ ref ) { $ parameter -> type = $ ref -> getName ( ) ; } } catch ( Exception $ e ) { } if ( $ parameter -> type == '' ) { if ( $ parameter -> isArray ( ) ) { $ parameter -> type = 'array' ; } elseif ( $ parameter -> isCallable ( ) ) { $ parameter -> type = 'function' ; } elseif ( isset ( $ this -> params ) && isset ( $ this -> params [ $ i ] ) ) { $ parameter -> type = $ this -> params [ $ i ] -> type ; } else { $ parameter -> type = 'mixed' ; } } $ this -> parameters [ $ parameter -> name ] = $ parameter ; } if ( isset ( $ this -> externalParams ) ) { foreach ( $ this -> externalParams as $ param ) { $ this -> parameters [ $ param -> name ] = $ param ; } } return $ this -> parameters ; }
Returns an array with parameter objects containing type info etc .
33,393
protected function _buildItems ( array $ map , array $ domains , $ prefix ) { $ items = $ listItemMap = $ refItemMap = $ refIdMap = array ( ) ; if ( count ( $ domains ) > 0 ) { $ listItems = $ this -> _getListItems ( array_keys ( $ map ) , $ domains , $ prefix ) ; foreach ( $ listItems as $ listItem ) { $ domain = $ listItem -> getDomain ( ) ; $ parentid = $ listItem -> getParentId ( ) ; $ listItemMap [ $ parentid ] [ $ domain ] [ $ listItem -> getId ( ) ] = $ listItem ; $ refIdMap [ $ domain ] [ $ listItem -> getRefId ( ) ] [ ] = $ parentid ; } $ refItemMap = $ this -> _getRefItems ( $ refIdMap ) ; } foreach ( $ map as $ id => $ values ) { $ listItems = array ( ) ; if ( isset ( $ listItemMap [ $ id ] ) ) { $ listItems = $ listItemMap [ $ id ] ; } $ refItems = array ( ) ; if ( isset ( $ refItemMap [ $ id ] ) ) { $ refItems = $ refItemMap [ $ id ] ; } $ items [ $ id ] = $ this -> _createItem ( $ values , $ listItems , $ refItems ) ; } return $ items ; }
Creates the items with address item list items and referenced items .
33,394
protected function _getListItems ( array $ ids , array $ domains , $ prefix ) { $ manager = $ this -> getSubManager ( 'list' ) ; $ search = $ manager -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '==' , $ prefix . '.list.parentid' , $ ids ) , $ search -> compare ( '==' , $ prefix . '.list.domain' , $ domains ) , $ search -> getConditions ( ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSlice ( 0 , 0x7fffffff ) ; return $ manager -> searchItems ( $ search ) ; }
Returns the list items that belong to the given IDs .
33,395
protected function _getRefItems ( array $ refIdMap ) { $ items = array ( ) ; $ context = $ this -> _getContext ( ) ; foreach ( $ refIdMap as $ domain => $ list ) { try { $ manager = MShop_Factory :: createManager ( $ context , $ domain ) ; $ search = $ manager -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '==' , str_replace ( '/' , '.' , $ domain ) . '.id' , array_keys ( $ list ) ) , $ search -> getConditions ( ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSlice ( 0 , 0x7fffffff ) ; foreach ( $ manager -> searchItems ( $ search ) as $ id => $ item ) { foreach ( $ list [ $ id ] as $ parentId ) { $ items [ $ parentId ] [ $ domain ] [ $ id ] = $ item ; } } } catch ( MShop_Exception $ e ) { $ logger = $ context -> getLogger ( ) ; $ logger -> log ( sprintf ( 'Item referenced in domain "%1$s" not found: %2$s' , $ domain , $ e -> getMessage ( ) ) ) ; $ logger -> log ( $ e -> getTraceAsString ( ) ) ; } } return $ items ; }
Returns the referenced items for the given IDs .
33,396
public function removeListener ( MW_Observer_Listener_Interface $ l , $ action ) { if ( isset ( $ this -> _listeners [ $ action ] ) ) { foreach ( $ this -> _listeners [ $ action ] as $ key => $ listener ) { if ( $ listener === $ l ) { unset ( $ this -> _listeners [ $ action ] [ $ key ] ) ; } } } }
Removes a listener from the publisher object .
33,397
protected function _notifyListeners ( $ action , $ value = null ) { if ( isset ( $ this -> _listeners [ $ action ] ) ) { foreach ( $ this -> _listeners [ $ action ] as $ key => $ listener ) { if ( $ listener -> update ( $ this , $ action , $ value ) === false ) { return false ; } } } return true ; }
Sends updates to all listeners of the given action .
33,398
public function columns ( $ columns ) { if ( is_array ( $ columns ) || is_string ( $ columns ) || $ columns instanceof Expression ) { $ this -> columns = $ columns ; } else { throw new InvalidArgumentException ( 'Invalid columns parameter' ) ; } return $ this ; }
Set the columns
33,399
public function hint ( $ columns , $ mode = null ) { $ this -> hint = $ columns ; $ this -> hintMode = $ mode ; return $ this ; }
Hint at index to use