idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
32,800 | private function _getPrice ( MShop_Order_Item_Base_Product_Interface $ orderProduct , array $ refPrices , array $ attributes , $ pos ) { $ context = $ this -> _getContext ( ) ; if ( empty ( $ refPrices ) ) { $ productManager = MShop_Factory :: createManager ( $ context , 'product' ) ; $ product = $ productManager -> getItem ( $ orderProduct -> getProductId ( ) , array ( 'price' ) ) ; $ refPrices = $ product -> getRefItems ( 'price' , 'default' , 'default' ) ; } if ( empty ( $ refPrices ) ) { $ pid = $ orderProduct -> getProductId ( ) ; $ pcode = $ orderProduct -> getProductCode ( ) ; $ codes = array ( 'product' => array ( $ pos => 'product.price' ) ) ; $ msg = sprintf ( 'No price for product ID "%1$s" or product code "%2$s" available' , $ pid , $ pcode ) ; throw new MShop_Plugin_Provider_Exception ( $ msg , - 1 , null , $ codes ) ; } $ priceManager = MShop_Factory :: createManager ( $ context , 'price' ) ; $ price = $ priceManager -> getLowestPrice ( $ refPrices , $ orderProduct -> getQuantity ( ) ) ; foreach ( $ orderProduct -> getAttributes ( ) as $ orderAttribute ) { $ attrPrices = array ( ) ; $ attrId = $ orderAttribute -> getAttributeId ( ) ; if ( isset ( $ attributes [ $ attrId ] ) ) { $ attrPrices = $ attributes [ $ attrId ] -> getRefItems ( 'price' , 'default' , 'default' ) ; } if ( ! empty ( $ attrPrices ) ) { $ price -> addItem ( $ priceManager -> getLowestPrice ( $ attrPrices , $ orderProduct -> getQuantity ( ) ) ) ; } } return $ price ; } | Returns the actual price for the given order product . |
32,801 | public function setBaseId ( $ value ) { if ( $ value == $ this -> getBaseId ( ) ) { return ; } $ this -> _values [ 'baseid' ] = ( $ value !== null ? ( int ) $ value : null ) ; $ this -> setModified ( ) ; } | Sets the order service base ID of the order service item . |
32,802 | public function setServiceId ( $ servid ) { if ( $ servid == $ this -> getServiceId ( ) ) { return ; } $ this -> _values [ 'servid' ] = ( string ) $ servid ; $ this -> setModified ( ) ; } | Sets a new ID of the service item used for the order . |
32,803 | public function setName ( $ name ) { if ( $ name == $ this -> getName ( ) ) { return ; } $ this -> _values [ 'name' ] = ( string ) $ name ; $ this -> setModified ( ) ; } | Sets a new name for the service item . |
32,804 | public function setMediaUrl ( $ value ) { if ( $ value == $ this -> getMediaUrl ( ) ) { return ; } $ this -> _values [ 'mediaurl' ] = ( string ) $ value ; $ this -> setModified ( ) ; } | Sets the media url of the service item . |
32,805 | public function setPrice ( MShop_Price_Item_Interface $ price ) { if ( $ price === $ this -> _price ) { return ; } $ this -> _price = $ price ; $ this -> setModified ( ) ; } | Sets a new price object for the service item . |
32,806 | public function getAttribute ( $ code ) { $ map = $ this -> _getAttributeMap ( ) ; if ( isset ( $ map [ $ code ] ) ) { return $ map [ $ code ] -> getValue ( ) ; } return null ; } | Returns the value of the attribute item for the service with the given code . |
32,807 | public function getAttributeItem ( $ code ) { $ map = $ this -> _getAttributeMap ( ) ; if ( isset ( $ map [ $ code ] ) ) { return $ map [ $ code ] ; } return null ; } | Returns the attribute item for the service with the given code . |
32,808 | public function getAttributes ( $ type = null ) { if ( $ type === null ) { return $ this -> _attributes ; } $ list = array ( ) ; foreach ( $ this -> _attributes as $ attrItem ) { if ( $ attrItem -> getType ( ) === $ type ) { $ list [ ] = $ attrItem ; } } return $ list ; } | Returns the list of attribute items for the service . |
32,809 | public function copyFrom ( MShop_Service_Item_Interface $ service ) { $ this -> setCode ( $ service -> getCode ( ) ) ; $ this -> setName ( $ service -> getName ( ) ) ; $ this -> setType ( $ service -> getType ( ) ) ; $ this -> setServiceId ( $ service -> getId ( ) ) ; $ items = $ service -> getRefItems ( 'media' , 'default' , 'default' ) ; if ( ( $ item = reset ( $ items ) ) !== false ) { $ this -> setMediaUrl ( $ item -> getUrl ( ) ) ; } $ this -> setModified ( ) ; } | Copys all data from a given service item . |
32,810 | protected function _getAttributeMap ( ) { if ( ! isset ( $ this -> _attributesMap ) ) { $ this -> _attributesMap = array ( ) ; foreach ( $ this -> _attributes as $ attribute ) { $ this -> _attributesMap [ $ attribute -> getCode ( ) ] = $ attribute ; } } return $ this -> _attributesMap ; } | Returns the attribute map for the service . |
32,811 | public function setProvider ( $ provider ) { if ( $ provider == $ this -> getProvider ( ) ) { return ; } $ this -> _values [ 'provider' ] = ( string ) $ provider ; $ this -> setModified ( ) ; } | Sets the new provider of the plugin item which is the short name of the plugin class name . |
32,812 | public function setPosition ( $ position ) { if ( $ position == $ this -> getPosition ( ) ) { return ; } $ this -> _values [ 'pos' ] = ( int ) $ position ; $ this -> setModified ( ) ; } | Sets the new position of the plugin item . |
32,813 | public function make ( $ id , ... $ args ) { $ this -> bind ( $ id , ... $ args ) ; return $ this -> resolve ( $ id ) ; } | Bind and then resolve to return an instantiated binding . |
32,814 | private function processDependencies ( & $ binding ) : void { if ( ! $ binding [ 'reflector' ] -> isInstantiable ( ) ) { throw new ContainerException ( $ binding [ 'concrete' ] . ' can not be instantiated.' ) ; } if ( ! $ binding [ 'reflector' ] -> getConstructor ( ) ) { $ binding [ 'dependencies' ] = [ ] ; return ; } $ binding [ 'dependencies' ] = $ this -> resolveParameters ( $ binding [ 'reflector' ] -> getConstructor ( ) -> getParameters ( ) ) ; } | Get all dependency information for the binding . Do not hydrate the the dependencies but store the data to the binding registry for later use . |
32,815 | private function resolveParameters ( $ parameters ) : array { $ dependencies = [ ] ; foreach ( $ parameters as $ key => $ parameter ) { $ dependency = $ parameter -> getClass ( ) ; if ( is_null ( $ dependency ) ) { if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ dependencies [ $ key ] [ 'type' ] = 'default' ; $ dependencies [ $ key ] [ 'value' ] = $ parameter -> getDefaultValue ( ) ; } else { throw new ContainerException ( 'Non class dependency (' . $ parameter -> name . ') requires default value.' ) ; } } else { $ dependencies [ $ key ] [ 'type' ] = 'class' ; $ dependencies [ $ key ] [ 'value' ] = $ dependency -> name ; } } return $ dependencies ; } | Process the constructor parameter list that was obtained from the ReflectionClass and return the resolved dependencies . |
32,816 | private function prepareBindingClosure ( $ id , $ blueprint , $ dependencies = null ) : Closure { if ( $ this -> bindings [ $ id ] [ 'singleton' ] ) { return $ this -> prepareSingletonBindingClosure ( $ id , $ blueprint , $ dependencies ) ; } return $ this -> preparePrototypeBindingClosure ( $ id , $ blueprint , $ dependencies ) ; } | Make a binding closure method to store in the cache . |
32,817 | private function preparePrototypeBindingClosure ( $ id , $ blueprint , $ dependencies ) : Closure { if ( $ blueprint instanceof ReflectionClass ) { return $ this -> cache [ $ id ] = function ( ) use ( $ blueprint , $ dependencies ) { foreach ( $ dependencies as $ key => $ dependency ) { if ( $ dependency instanceof Closure ) { $ dependencies [ $ key ] = $ dependency ( ) ; } } return $ blueprint -> newInstanceArgs ( $ dependencies ) ; } ; } if ( $ blueprint instanceof Closure ) { return $ this -> cache [ $ id ] = $ blueprint ; } return $ this -> cache [ $ id ] = function ( ) use ( $ blueprint ) { return new $ blueprint ; } ; } | Make a prototype binding closure method to store in the cache . |
32,818 | private function prepareSingletonBindingClosure ( $ id , $ blueprint , $ dependencies ) : Closure { $ binding = $ this -> bindings [ $ id ] ; $ instance = $ blueprint ; if ( $ blueprint instanceof ReflectionClass ) { foreach ( $ dependencies as $ key => $ dependency ) { if ( $ dependency instanceof Closure ) { $ dependencies [ $ key ] = $ dependency ( ) ; } } $ instance = $ blueprint -> newInstanceArgs ( $ dependencies ) ; } if ( $ blueprint instanceof Closure ) { $ instance = $ blueprint ( ) ; } if ( is_string ( $ blueprint ) ) { $ instance = new $ blueprint ; } unset ( $ binding [ 'dependencies' ] , $ binding [ 'reflector' ] ) ; return $ this -> cache [ $ id ] = function ( ) use ( $ instance ) { return $ instance ; } ; } | Make a singleton binding closure method to store in the cache . |
32,819 | public function alias ( $ alias , $ binding ) { if ( $ this -> resolve ( $ binding ) ) { $ this -> bindings [ $ alias ] = $ this -> bindings [ $ binding ] ; $ this -> cache [ $ alias ] = $ this -> cache [ $ binding ] ; $ this -> aliases [ $ alias ] = $ binding ; } } | Create an alias to an existing cached binding . |
32,820 | private function destroyBinding ( $ id ) { unset ( $ this -> cache [ $ id ] , $ this -> bindings [ $ id ] , $ this -> aliases [ $ id ] ) ; } | Remove all traces of the specified binding . |
32,821 | protected function getVendor ( OperationInterface $ operation ) { if ( $ operation -> getMiraklId ( ) ) { return $ this -> vendorManager -> findByMiraklId ( $ operation -> getMiraklId ( ) ) ; } return $ this -> operator ; } | Return the right vendor for an operation |
32,822 | public function hasSufficientFunds ( $ amount , $ vendor , $ transfer = false ) { $ balance = round ( $ this -> hipay -> getBalance ( $ vendor ) , static :: SCALE ) ; if ( $ balance < round ( $ amount , static :: SCALE ) ) { if ( $ transfer ) { throw new WrongWalletBalance ( 'technical' , 'transfer' , $ amount , $ balance ) ; } throw new WrongWalletBalance ( $ vendor -> getHipayId ( ) , 'withdraw' , $ amount , $ balance ) ; } } | Check if technical account has sufficient funds . |
32,823 | protected function vendorEnabled ( $ vendor ) { if ( $ vendor === null ) { return false ; } if ( $ vendor -> getEnabled ( ) === null ) { return $ this -> mirakl -> vendorIsEnabled ( $ vendor -> getMiraklId ( ) ) ; } else { return ( bool ) $ vendor -> getEnabled ( ) ; } } | Check if vendor account is enable for HiPay |
32,824 | public function getConditionString ( array $ types , array $ translations = array ( ) , array $ plugins = array ( ) ) { $ types [ '1' ] = 'int' ; if ( ( $ string = $ this -> _conditions -> toString ( $ types , $ translations , $ plugins ) ) !== '' ) { return $ string ; } return '1==1' ; } | Returns the expression string used for generating the expression . |
32,825 | public function getSortationString ( array $ types , array $ translations = array ( ) ) { if ( empty ( $ this -> _sortations ) ) { reset ( $ types ) ; if ( ( $ name = key ( $ types ) ) === false ) { throw new MW_Common_Exception ( 'No sortation types available' ) ; } return $ this -> sort ( '+' , $ name ) -> toString ( $ types , $ translations ) ; } $ sortation = array ( ) ; foreach ( $ this -> _sortations as $ sortitem ) { if ( ( $ string = $ sortitem -> toString ( $ types , $ translations ) ) !== '' ) { $ sortation [ ] = $ string ; } } return implode ( ' ' , $ sortation ) ; } | Returns the string for sorting the result . |
32,826 | public static function matchRouteCollection ( RouteCollectionInterface $ routeCollection , ServerRequestInterface $ request , $ pathOffset , array $ parentParams ) { $ methodFailureResult = null ; $ schemeFailureResult = null ; foreach ( $ routeCollection as $ name => $ route ) { if ( null === ( $ matchResult = $ route -> match ( $ request , $ pathOffset ) ) ) { continue ; } if ( $ matchResult -> isSuccess ( ) ) { return MatchResult :: fromChildMatch ( $ matchResult , $ parentParams , $ name ) ; } if ( $ matchResult -> isMethodFailure ( ) ) { if ( null === $ methodFailureResult ) { $ methodFailureResult = $ matchResult ; } else { $ methodFailureResult = MatchResult :: mergeMethodFailures ( $ methodFailureResult , $ matchResult ) ; } continue ; } if ( $ matchResult -> isSchemeFailure ( ) ) { $ schemeFailureResult = $ schemeFailureResult ? : $ matchResult ; continue ; } return $ matchResult ; } if ( null !== $ schemeFailureResult ) { return $ schemeFailureResult ; } if ( null !== $ methodFailureResult ) { return $ methodFailureResult ; } return null ; } | Matches a request against a route collection . |
32,827 | public function delete ( ViewSource $ source , string $ className ) { try { $ this -> files -> delete ( $ this -> getKey ( $ source , $ className ) ) ; } catch ( \ Throwable $ e ) { } } | Delete cached files . |
32,828 | public function toArray ( ) : array { $ result = [ ] ; foreach ( static :: getInstanceProperties ( ) as $ key ) { $ result [ $ key ] = $ this -> $ key ; } return $ result ; } | Returns array representation of DTO properties . |
32,829 | public function __isset ( string $ name ) : bool { return in_array ( $ name , static :: getInstanceProperties ( ) ) && $ this -> $ name !== null ; } | Returns whether given property is set in DTO . |
32,830 | public function validateAssetFile ( $ file ) { $ filePath = substr ( $ file , 1 ) ; if ( ! is_file ( $ filePath ) ) throw new FileNotFoundException ( "File " . $ filePath . " was not found" ) ; $ path_parts = pathinfo ( $ filePath ) ; if ( ! in_array ( $ path_parts [ 'extension' ] , array ( "js" , "css" , "png" , "jpg" , "jpeg" , "gif" , "ttf" , "otf" , "woff" ) ) ) throw new WrongFileExtensionException ( "Wrong file format\n Supported formats: js, css, png, jpg, jpeg, gif, ttf, otf, woff" ) ; } | Checks if asset exists at provided path and is of supported format |
32,831 | private function boolParams ( $ params ) { if ( isset ( $ params [ 'lowquality' ] ) && $ params [ 'lowquality' ] === false ) $ params [ 'lowquality' ] = ( int ) $ params [ 'lowquality' ] ; if ( isset ( $ params [ 'images' ] ) && $ params [ 'images' ] === false ) $ params [ 'images' ] = ( int ) $ params [ 'images' ] ; if ( isset ( $ params [ 'outline' ] ) && $ params [ 'outline' ] === false ) $ params [ 'outline' ] = ( int ) $ params [ 'outline' ] ; if ( isset ( $ params [ 'javascript' ] ) && $ params [ 'javascript' ] === false ) $ params [ 'javascript' ] = ( int ) $ params [ 'javascript' ] ; if ( isset ( $ params [ 'internal_links' ] ) && $ params [ 'internal_links' ] === false ) $ params [ 'internal_links' ] = ( int ) $ params [ 'internal_links' ] ; if ( isset ( $ params [ 'external_links' ] ) && $ params [ 'external_links' ] === false ) $ params [ 'external_links' ] = ( int ) $ params [ 'external_links' ] ; if ( isset ( $ params [ 'use_print_media' ] ) && $ params [ 'use_print_media' ] === false ) $ params [ 'use_print_media' ] = ( int ) $ params [ 'use_print_media' ] ; if ( isset ( $ params [ 'background' ] ) && $ params [ 'background' ] === false ) $ params [ 'background' ] = ( int ) $ params [ 'background' ] ; return $ params ; } | Casts bool parameters to integer if set to false |
32,832 | public function html ( $ value , $ trust = self :: TAINT ) { if ( $ trust === self :: TRUST ) { return $ value ; } return htmlspecialchars ( $ value , ENT_QUOTES , 'UTF-8' ) ; } | Escapes strings for HTML . |
32,833 | protected function _checkDeliveryStatus ( $ value ) { $ temp = ( int ) $ value ; if ( $ temp < MShop_Order_Item_Abstract :: STAT_UNFINISHED || $ temp > MShop_Order_Item_Abstract :: STAT_RETURNED ) { throw new MShop_Order_Exception ( sprintf ( 'Order delivery status "%1$s" not within allowed range' , $ value ) ) ; } } | Checks if the given delivery status is a valid constant . |
32,834 | protected function _checkPaymentStatus ( $ value ) { $ temp = ( int ) $ value ; if ( $ temp < MShop_Order_Item_Abstract :: PAY_UNFINISHED || $ temp > MShop_Order_Item_Abstract :: PAY_RECEIVED ) { throw new MShop_Order_Exception ( sprintf ( 'Order payment status "%1$s" not within allowed range' , $ value ) ) ; } } | Checks the given payment status is a valid constant . |
32,835 | protected function _checkType ( $ value ) { switch ( $ value ) { case MShop_Order_Item_Abstract :: TYPE_REPEAT : case MShop_Order_Item_Abstract :: TYPE_WEB : case MShop_Order_Item_Abstract :: TYPE_PHONE : break ; default : throw new MShop_Order_Exception ( sprintf ( 'Order type "%1$s" not within allowed range' , $ value ) ) ; } } | Checks the given order type is a valid constant . |
32,836 | public function createNode ( ) : Node { $ node = $ this -> compiler -> createNode ( $ this -> path , $ this -> token ) ; $ node -> mountBlock ( self :: CONTEXT_BLOCK , [ ] , [ $ this -> createPlaceholder ( self :: CONTEXT_BLOCK , $ contextID ) ] , true ) ; foreach ( $ this -> token [ HtmlTokenizer :: TOKEN_ATTRIBUTES ] as $ attribute => $ value ) { $ node -> mountBlock ( $ attribute , [ ] , [ $ value ] , true ) ; } $ content = $ node -> compile ( $ dynamic ) ; foreach ( $ this -> compiler -> getExports ( ) as $ exporter ) { $ content = $ exporter -> mountBlocks ( $ content , $ dynamic ) ; } $ compiler = clone $ this -> compiler ; $ rebuilt = new Node ( $ compiler , $ compiler -> generateID ( ) , $ content ) ; if ( ! empty ( $ contextBlock = $ rebuilt -> findNode ( $ contextID ) ) ) { $ contextBlock -> mountNode ( $ this -> contextNode ( ) ) ; } return $ rebuilt ; } | Create node to be injected into template at place of tag caused import . |
32,837 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'order.base.coupon.id' : $ item -> setId ( $ value ) ; break ; case 'order.base.coupon.code' : $ item -> setCode ( $ value ) ; break ; case 'order.base.coupon.baseid' : $ item -> setBaseId ( $ value ) ; break ; case 'order.base.coupon.productid' : $ item -> setProductId ( $ value ) ; break ; } } return $ item ; } | Creates a new order base coupon item and sets the properties from the given array . |
32,838 | protected function _process ( array $ stmts ) { $ this -> _msg ( 'Changing PRIMARY KEYS for locale' , 0 ) ; $ this -> _status ( '' ) ; $ search = ' SELECT COUNT(INDEX_NAME) "counter" FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = \'%1$s\' AND INDEX_NAME = \'PRIMARY\' AND COLUMN_NAME IN(\'id\', \'siteid\') ' ; foreach ( $ stmts as $ table => $ stmt ) { $ this -> _msg ( sprintf ( 'Checking table "%1$s" for PRIMARY": ' , $ table ) , 1 ) ; $ counter = $ this -> _getValue ( sprintf ( $ search , $ table ) , 'counter' ) ; if ( $ counter == 2 ) { $ this -> _execute ( $ stmt ) ; $ this -> _status ( 'changed' ) ; } else { $ this -> _status ( 'OK' ) ; } } } | Change critical PRIMARY KEY - constellation in locale tables . |
32,839 | public function dn ( $ domain , $ singular , $ plural , $ number ) { $ index = $ this -> _getPluralIndex ( $ number , $ this -> getLocale ( ) ) ; try { foreach ( $ this -> _getTranslations ( $ domain ) as $ content ) { if ( isset ( $ content [ $ singular ] [ $ index ] ) && is_array ( $ content [ $ singular ] ) ) { return $ content [ $ singular ] [ $ index ] ; } } } catch ( Exception $ e ) { ; } if ( $ index > 0 ) { return ( string ) $ plural ; } return ( string ) $ singular ; } | Returns the translated plural by given domain . |
32,840 | private function _getTranslations ( $ domain ) { if ( ! isset ( $ this -> _translations [ $ domain ] ) ) { if ( ! isset ( $ this -> _translationSources [ $ domain ] ) ) { $ msg = sprintf ( 'No translation directory for domain "%1$s" available' , $ domain ) ; throw new MW_Translation_Exception ( $ msg ) ; } $ locations = array_reverse ( $ this -> _getTranslationFileLocations ( $ this -> _translationSources [ $ domain ] , $ this -> getLocale ( ) ) ) ; foreach ( $ locations as $ location ) { if ( ( $ content = file_get_contents ( $ location ) ) === false ) { throw new MW_Translation_Exception ( 'No translation file "%1$s" available' , $ location ) ; } if ( ( $ content = unserialize ( $ content ) ) === false ) { throw new MW_Translation_Exception ( 'Invalid content in translation file "%1$s"' , $ location ) ; } $ this -> _translations [ $ domain ] [ ] = $ content ; } } return $ this -> _translations [ $ domain ] ; } | Gets adds and loads necessary translation data if it was not set befor . |
32,841 | public function setId ( $ id ) { if ( $ id === $ this -> getId ( ) ) { return ; } $ this -> _values [ 'id' ] = ( string ) $ id ; $ this -> setModified ( ) ; } | Sets the unique ID of the item . |
32,842 | public function setTimeExpire ( $ timestamp ) { if ( $ timestamp !== null ) { $ timestamp = ( string ) $ timestamp ; $ this -> _checkDateFormat ( $ timestamp ) ; } $ this -> _values [ 'expire' ] = $ timestamp ; $ this -> setModified ( ) ; } | Sets the new expiration time of the item . |
32,843 | public function register ( MW_Observer_Publisher_Interface $ p ) { $ p -> addListener ( $ this , 'setAddress.after' ) ; $ p -> addListener ( $ this , 'deleteAddress.after' ) ; $ p -> addListener ( $ this , 'addProduct.after' ) ; $ p -> addListener ( $ this , 'deleteProduct.after' ) ; $ p -> addListener ( $ this , 'addCoupon.after' ) ; $ p -> addListener ( $ this , 'deleteCoupon.after' ) ; } | Subscribes itself to a publisher |
32,844 | static public function createManager ( $ name , array $ config , $ resource ) { if ( ctype_alnum ( $ name ) === false ) { $ classname = is_string ( $ name ) ? 'MW_Tree_Manager_' . $ name : '<not a string>' ; throw new MW_Tree_Exception ( sprintf ( 'Invalid characters in class name "%1$s"' , $ classname ) ) ; } $ iface = 'MW_Tree_Manager_Interface' ; $ classname = 'MW_Tree_Manager_' . $ name ; if ( class_exists ( $ classname ) === false ) { throw new MW_Tree_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ manager = new $ classname ( $ config , $ resource ) ; if ( ! ( $ manager instanceof $ iface ) ) { throw new MW_Tree_Exception ( sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ iface ) ) ; } return $ manager ; } | Creates and returns a tree manager . |
32,845 | public function getMatchedRoutes ( $ httpMethod , $ resourceUri , $ reload = false ) { if ( $ reload || is_null ( $ this -> matchedRoutes ) ) { $ this -> matchedRoutes = array ( ) ; foreach ( $ this -> routes as $ route ) { if ( ! $ route -> supportsHttpMethod ( $ httpMethod ) ) { continue ; } if ( $ route -> matches ( $ resourceUri ) ) { $ this -> matchedRoutes [ ] = $ route ; } } } return $ this -> matchedRoutes ; } | Return route objects that match the given HTTP method and URI |
32,846 | public function map ( $ pattern , $ callable ) { $ route = new \ Slim \ Route ( $ pattern , $ callable ) ; $ this -> routes [ ] = $ route ; return $ route ; } | Map a route object to a callback function |
32,847 | protected function _createSchema ( MW_DB_Connection_Interface $ conn , $ adapter , $ dbname ) { if ( empty ( $ adapter ) || ctype_alnum ( $ adapter ) === false ) { throw new MW_Setup_Exception ( sprintf ( 'Invalid database adapter "%1$s"' , $ adapter ) ) ; } $ classname = 'MW_Setup_DBSchema_' . ucwords ( strtolower ( $ adapter ) ) ; if ( class_exists ( $ classname ) === false ) { throw new MW_Setup_Exception ( sprintf ( 'Database schema class "%1$s" not found' , $ classname ) ) ; } return new $ classname ( $ conn , $ dbname ) ; } | Creates a new database schema object . |
32,848 | protected function _createTasks ( array $ paths , MW_Setup_DBSchema_Interface $ schema , MW_DB_Connection_Interface $ conn , $ additional ) { $ tasks = array ( ) ; foreach ( $ paths as $ path ) { foreach ( new DirectoryIterator ( $ path ) as $ item ) { if ( $ item -> isDir ( ) === true || substr ( $ item -> getFilename ( ) , - 4 ) != '.php' ) { continue ; } $ this -> _includeFile ( $ item -> getPathName ( ) ) ; $ taskname = substr ( $ item -> getFilename ( ) , 0 , - 4 ) ; $ classname = 'MW_Setup_Task_' . $ taskname ; if ( class_exists ( $ classname ) === false ) { throw new MW_Setup_Exception ( sprintf ( 'Class "%1$s" not found' , $ classname ) ) ; } $ interface = 'MW_Setup_Task_Interface' ; $ task = new $ classname ( $ schema , $ conn , $ additional ) ; if ( ( $ task instanceof $ interface ) === false ) { throw new MW_Setup_Exception ( sprintf ( 'Class "%1$s" doesn\'t implement "%2$s"' , $ classname , 'MW_Setup_Task_Interface' ) ) ; } $ tasks [ $ taskname ] = $ task ; } } return $ tasks ; } | Creates the tasks from the given directories . |
32,849 | public function header ( $ name , $ value = null ) { if ( ! is_null ( $ value ) ) { $ this [ $ name ] = $ value ; } return $ this [ $ name ] ; } | Get and set header |
32,850 | protected function addComplexType ( $ type , $ name = false , $ parent = false ) { if ( ! $ parent ) { if ( isset ( $ this -> types [ $ name ] ) ) { return $ this -> types [ $ name ] ; } $ complexTypeTag = $ this -> addElement ( 'xsd:complexType' , $ this -> parentElement ) ; if ( $ name ) { $ complexTypeTag -> setAttribute ( 'name' , $ name ) ; $ this -> types [ $ name ] = $ complexTypeTag ; } } else { $ complexTypeTag = $ this -> addElement ( 'xsd:complexType' , $ parent ) ; } $ tag = $ this -> addElement ( 'xsd:all' , $ complexTypeTag ) ; if ( strtolower ( substr ( $ type , 0 , 6 ) ) == 'object' ) { $ content = substr ( $ type , 7 , - 1 ) ; $ properties = explode ( ',' , $ content ) ; foreach ( $ properties as $ property ) { if ( strpos ( $ property , '=>' ) !== false ) { list ( $ keyType , $ valueType ) = explode ( '=>' , $ property ) ; $ el = $ this -> addTypeElement ( $ valueType , $ keyType , $ tag ) ; } else { throw new WSDLException ( 'Error creating WSDL: expected "=>". When using the object() as type, use it as object(paramname=>paramtype,paramname2=>paramtype2)' , 100 ) ; } } } else { if ( ! class_exists ( $ name ) ) { throw new WSDLException ( "Error creating WSDL: no class found with the name '$name' / $type : $parent, so how should we know the structure for this datatype?" , 101 ) ; } $ v = new IPReflectionClass ( $ name ) ; $ properties = $ v -> getProperties ( false , false , false ) ; foreach ( ( array ) $ properties as $ property ) { if ( ! $ property -> isPrivate ) { $ el = $ this -> addTypeElement ( $ property -> type , $ property -> name , $ tag , $ property -> optional ) ; } } } return $ complexTypeTag ; } | Ads a complexType tag with xmlschema content to the types tag . |
32,851 | protected function addArray ( $ name , $ xsdType ) { if ( isset ( $ this -> types [ $ name ] ) ) { return $ this -> types [ $ name ] ; } $ complexTypeTag = $ this -> addElement ( 'xsd:complexType' , $ this -> parentElement ) ; $ complexTypeTag -> setAttribute ( 'name' , $ name ) ; $ this -> types [ $ name ] = $ complexTypeTag ; $ cc = $ this -> addElement ( 'xsd:complexContent' , $ complexTypeTag ) ; $ rs = $ this -> addElement ( 'xsd:restriction' , $ cc ) ; $ rs -> setAttribute ( 'base' , 'SOAP-ENC:Array' ) ; $ el = $ this -> addElement ( 'xsd:attribute' , $ rs ) ; $ el -> setAttribute ( 'ref' , 'SOAP-ENC:arrayType' ) ; $ el -> setAttribute ( 'wsdl:arrayType' , $ xsdType . '[]' ) ; } | Creates an xmlSchema element for the given array . |
32,852 | public static function checkSchemaType ( $ type ) { if ( isset ( self :: $ _schemaTypes [ $ type ] ) ) { return self :: $ _schemaTypes [ $ type ] ; } else { return false ; } } | Checks if the given type is a valid XML Schema type or can be casted to a schema type . |
32,853 | protected function _include ( $ file ) { if ( ! isset ( $ this -> _includeCache [ $ file ] ) ) { $ this -> _includeCache [ $ file ] = include $ file ; } return $ this -> _includeCache [ $ file ] ; } | Includes config files using a simple caching . |
32,854 | public function isAvailable ( MShop_Order_Item_Base_Interface $ base ) { if ( ( $ prodcode = $ this -> _getConfigValue ( 'required.productcode' ) ) !== null ) { foreach ( $ base -> getProducts ( ) as $ product ) { if ( $ product -> getProductCode ( ) == $ prodcode ) { return parent :: isAvailable ( $ base ) ; } } return false ; } return true ; } | Checks for requirements . |
32,855 | public function mapRelatives ( ) { $ relations = collect ( $ this -> relations ( ) ) ; if ( $ relations -> isEmpty ( ) ) { return false ; } return $ this -> items = collect ( $ this -> all ( ) ) -> map ( function ( $ value , $ key ) use ( $ relations ) { if ( $ relations -> has ( $ key ) ) { $ className = $ relations -> get ( $ key ) ; return new $ className ( $ value ) ; } return $ value ; } ) -> all ( ) ; } | Map property relatives to appropriate objects . |
32,856 | protected function loadFile ( string $ file , array $ options ) { $ json = file_get_contents ( $ file ) ; return json_decode ( $ json , false , 512 , JSON_BIGINT_AS_STRING ) ; } | Load and parse json file |
32,857 | protected function loadField ( $ modelFieldInfo , & $ parameter , $ result ) { if ( $ modelFieldInfo -> isMABIModel ) { if ( empty ( $ result ) ) { $ parameter = NULL ; } else { $ model = call_user_func ( $ modelFieldInfo -> type . '::init' , $ this -> app ) ; $ model -> load ( $ result ) ; $ parameter = $ model ; } } else { switch ( $ modelFieldInfo -> type ) { case 'string' : $ parameter = $ result ; break ; case 'int' : $ parameter = intval ( $ result ) ; break ; case 'bool' : $ parameter = $ result == TRUE ; break ; case 'float' : $ parameter = floatval ( $ result ) ; break ; case 'DateTime' : case '\DateTime' : if ( empty ( $ result ) ) { $ parameter = NULL ; } else { $ parameter = new \ DateTime ( '@' . $ result ) ; } break ; case '' : case 'array' : $ parameter = $ result ; } } ; } | Sets a parameter based on its type |
32,858 | protected function load ( $ resultArray , $ sanitizeArray = FALSE ) { if ( ! is_array ( $ resultArray ) ) { $ resultArray = json_decode ( $ resultArray , TRUE ) ; if ( ! is_array ( $ resultArray ) ) { throw new InvalidJSONException ( "Invalid JSON used to load a model" ) ; } } if ( ! empty ( $ resultArray [ $ this -> idColumn ] ) ) { if ( ! $ sanitizeArray ) { $ dataConnection = $ this -> app -> getDataConnection ( $ this -> connection ) ; $ this -> { $ this -> idProperty } = $ dataConnection -> convertFromNativeId ( $ resultArray [ $ this -> idColumn ] ) ; } unset ( $ resultArray [ $ this -> idColumn ] ) ; unset ( $ resultArray [ $ this -> idProperty ] ) ; } foreach ( $ this -> modelFieldsInfo as $ modelFieldInfo ) { if ( ! array_key_exists ( $ modelFieldInfo -> name , $ resultArray ) ) { continue ; } if ( $ sanitizeArray && ( $ modelFieldInfo -> isInternal || $ modelFieldInfo -> isSystem ) ) { unset ( $ resultArray [ $ modelFieldInfo -> name ] ) ; continue ; } if ( ! $ modelFieldInfo -> hasType ) { $ this -> { $ modelFieldInfo -> name } = $ resultArray [ $ modelFieldInfo -> name ] ; } else { if ( $ modelFieldInfo -> isArrayType ) { $ outArr = array ( ) ; if ( ! empty ( $ resultArray [ $ modelFieldInfo -> name ] ) ) { foreach ( $ resultArray [ $ modelFieldInfo -> name ] as $ listResult ) { $ this -> loadField ( $ modelFieldInfo , $ parameter , $ listResult ) ; $ outArr [ ] = $ parameter ; } } $ this -> { $ modelFieldInfo -> name } = $ outArr ; } else { $ this -> loadField ( $ modelFieldInfo , $ this -> { $ modelFieldInfo -> name } , $ resultArray [ $ modelFieldInfo -> name ] ) ; } } unset ( $ resultArray [ $ modelFieldInfo -> name ] ) ; } $ this -> _remainingReadResults = $ resultArray ; } | Loads the data for the model from a PHP array or a json string into the current model object using reflection and MABI annotations . |
32,859 | protected function _checkParts ( $ value ) { $ value = ( int ) $ value ; if ( $ value < MShop_Order_Item_Base_Abstract :: PARTS_NONE || $ value > MShop_Order_Item_Base_Abstract :: PARTS_ALL ) { throw new MShop_Order_Exception ( sprintf ( 'Flags "%1$s" not within allowed range' , $ value ) ) ; } } | Checks the constants for the different parts of the basket . |
32,860 | function levelsToSelect ( $ levelIds , $ mode ) { $ levelsToSelect = array ( ) ; foreach ( $ this -> schema -> getLevels ( ) as $ level ) { if ( self :: INCLUDE_PARTIALS == $ mode && ! $ levelIds [ $ level ] ) { continue ; } if ( self :: INCLUDE_PARTIALS == $ mode && ! $ levelIds [ $ level ] ) { continue ; } array_push ( $ levelsToSelect , $ level ) ; } return $ levelsToSelect ; } | Figures out which levels need to be selected based on the level IDs being searched & what mode |
32,861 | public static function createManager ( MShop_Context_Item_Interface $ context , $ name = null ) { if ( $ name === null ) { $ name = $ context -> getConfig ( ) -> get ( 'classes/catalog/manager/name' , 'Default' ) ; } if ( ctype_alnum ( $ name ) === false ) { $ classname = is_string ( $ name ) ? 'MShop_Catalog_Manager_' . $ name : '<not a string>' ; throw new MShop_Catalog_Exception ( sprintf ( 'Invalid characters in class name "%1$s"' , $ classname ) ) ; } $ iface = 'MShop_Catalog_Manager_Interface' ; $ classname = 'MShop_Catalog_Manager_' . $ name ; $ manager = self :: _createManager ( $ context , $ classname , $ iface ) ; return self :: _addManagerDecorators ( $ context , $ manager , 'catalog' ) ; } | Creates a catalog DAO object . |
32,862 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'coupon.id' : $ item -> setId ( $ value ) ; break ; case 'coupon.label' : $ item -> setLabel ( $ value ) ; break ; case 'coupon.status' : $ item -> setStatus ( $ value ) ; break ; case 'coupon.provider' : $ item -> setProvider ( $ value ) ; break ; case 'coupon.config' : $ item -> setConfig ( ( array ) $ value ) ; break ; case 'coupon.datestart' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'coupon.datestart' } = $ value ; $ item -> setDateStart ( $ value ) ; } break ; case 'coupon.dateend' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'coupon.dateend' } = $ value ; $ item -> setDateEnd ( $ value ) ; } break ; } } return $ item ; } | Creates a new coupon item and sets the properties from the given array . |
32,863 | public function getDatePrettyPrint ( ) { $ date = str_replace ( '?' , '' , $ this -> date ) ; $ date = explode ( '.' , $ date ) ; $ date = array_filter ( $ date ) ; if ( count ( $ date ) == 2 || count ( $ date ) == 3 ) { $ month = date ( 'F' , mktime ( 0 , 0 , 0 , $ date [ 1 ] , 1 ) ) ; $ date = "$month, $date[0]" ; } elseif ( count ( $ date ) == 1 ) { $ date = $ date [ 0 ] ; } else { $ date = null ; } return $ date ; } | Get the date formatted smartly . |
32,864 | public function getEventSitePrettyPrint ( ) { $ eventSite = null ; if ( $ this -> event && $ this -> site ) { if ( strpos ( $ this -> event , $ this -> site ) !== false ) { $ eventSite = $ this -> event ; } else { $ eventSite = "$this->event, in $this->site" ; } } elseif ( $ this -> event ) { $ eventSite = $ this -> event ; } elseif ( $ this -> site ) { $ eventSite = $ this -> site ; } return $ eventSite ; } | Get the event and site concatenated smartly . |
32,865 | public function is ( $ pattern ) { if ( $ this -> toString ( ) === $ pattern ) return true ; $ quotedPattern = preg_quote ( $ pattern , $ this -> regexDelimiter ) ; $ replaceWildCards = str_replace ( '\*' , '.*' , $ quotedPattern ) ; return $ this -> regexMatch ( '^' . $ replaceWildCards . '\z' ) ; } | Poor mans WildCard regular expression . |
32,866 | public function isSerialized ( ) { if ( $ this -> getLength ( ) === 0 ) return false ; return ( $ this -> scalarString === 'b:0;' || @ unserialize ( $ this -> scalarString ) !== false ) ; } | Returns true if the string is serialized false otherwise . |
32,867 | public function isBase64 ( ) { if ( $ this -> getLength ( ) === 0 ) return false ; $ possiblyEncoded = $ this -> scalarString ; $ decoded = base64_decode ( $ possiblyEncoded , true ) ; if ( $ decoded === false ) return false ; return ( base64_encode ( $ decoded ) === $ this -> scalarString ) ; } | Returns true if the string is base64 encoded false otherwise . |
32,868 | public function get ( $ key , $ default = null ) { $ list = $ this -> getList ( array ( $ key ) ) ; if ( ( $ value = reset ( $ list ) ) !== false ) { return $ value ; } return $ default ; } | Returns the cached value for the given key . |
32,869 | public function setCommunication ( MW_Communication_Interface $ communication ) { parent :: setCommunication ( $ communication ) ; $ this -> _object -> setCommunication ( $ communication ) ; } | Sets the communication object for a service provider . |
32,870 | private function noScalar ( $ value ) : Expr { if ( \ is_array ( $ value ) ) { return $ this -> arrayValue ( $ value ) ; } elseif ( \ is_object ( $ value ) ) { return $ this -> normalizeObject ( $ value ) ; } throw new InvalidInstance ; } | Return array or object node |
32,871 | private function arrayValue ( $ value ) : Expr \ Array_ { $ items = [ ] ; $ lastKey = - 1 ; foreach ( $ value as $ itemKey => $ itemValue ) { if ( null !== $ lastKey && ++ $ lastKey === $ itemKey ) { $ items [ ] = new Expr \ ArrayItem ( $ this -> __invoke ( $ itemValue ) ) ; } else { $ lastKey = null ; $ items [ ] = new Expr \ ArrayItem ( $ this -> __invoke ( $ itemValue ) , $ this -> __invoke ( $ itemKey ) ) ; } } return new Expr \ Array_ ( $ items ) ; } | Return array value node |
32,872 | protected function calculateExpectedIndent ( array $ tokens , $ stackPtr ) { $ conditionStack = array ( ) ; if ( empty ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) === true ) { return 1 ; } $ tokenConditions = $ tokens [ $ stackPtr ] [ 'conditions' ] ; foreach ( $ tokenConditions as $ id => $ condition ) { if ( in_array ( $ condition , $ this -> nonIndentingScopes ) === false ) { $ conditionStack [ $ id ] = $ condition ; } } return ( ( count ( $ conditionStack ) * $ this -> indent ) + 1 ) ; } | Calculates the expected indent of a token . |
32,873 | protected function _checkLimits ( MShop_Price_Item_Interface $ sum , $ count ) { $ currencyId = $ sum -> getCurrencyId ( ) ; $ config = $ this -> _getItem ( ) -> getConfig ( ) ; if ( ( isset ( $ config [ 'min-value' ] [ $ currencyId ] ) ) && ( $ sum -> getValue ( ) + $ sum -> getRebate ( ) < $ config [ 'min-value' ] [ $ currencyId ] ) ) { $ msg = sprintf ( 'The minimum basket value of %1$s isn\'t reached' , $ config [ 'min-value' ] [ $ currencyId ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } if ( ( isset ( $ config [ 'max-value' ] [ $ currencyId ] ) ) && ( $ sum -> getValue ( ) + $ sum -> getRebate ( ) > $ config [ 'max-value' ] [ $ currencyId ] ) ) { $ msg = sprintf ( 'The maximum basket value of %1$s is exceeded' , $ config [ 'max-value' ] [ $ currencyId ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } if ( ( isset ( $ config [ 'min-products' ] ) ) && ( $ count < $ config [ 'min-products' ] ) ) { $ msg = sprintf ( 'The minimum product quantity of %1$d isn\'t reached' , $ config [ 'min-products' ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } if ( ( isset ( $ config [ 'max-products' ] ) ) && ( $ count > $ config [ 'max-products' ] ) ) { $ msg = sprintf ( 'The maximum product quantity of %1$d is exceeded' , $ config [ 'max-products' ] ) ; throw new MShop_Plugin_Provider_Exception ( $ msg ) ; } } | Checks for the configured basket limits . |
32,874 | protected function _process ( array $ stmts ) { $ this -> _msg ( 'Fixing order email status values' , 0 ) ; if ( $ this -> _schema -> tableExists ( 'mshop_order_status' ) === true ) { $ this -> _execute ( $ stmts [ 'update' ] ) ; $ mapping = array ( 0 => 'email-deleted' , 1 => 'email-pending' , 2 => 'email-progress' , 3 => 'email-dispatched' , 4 => 'email-delivered' , 5 => 'email-lost' , 6 => 'email-refused' , 7 => 'email-returned' , ) ; $ cntRows = 0 ; foreach ( $ mapping as $ value => $ type ) { $ stmt = $ this -> _conn -> create ( $ stmts [ 'change' ] ) ; $ stmt -> bind ( 1 , $ value , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ type ) ; $ result = $ stmt -> execute ( ) ; $ cntRows += $ result -> affectedRows ( ) ; $ result -> finish ( ) ; } if ( $ cntRows > 0 ) { $ this -> _status ( sprintf ( 'migrated (%1$d)' , $ cntRows ) ) ; } else { $ this -> _status ( 'OK' ) ; } } else { $ this -> _status ( 'OK' ) ; } } | Migrates the emailflag status values in order table to the order status table . |
32,875 | protected function absolutePath ( string $ file , string $ base ) : string { return $ file [ 0 ] !== DIRECTORY_SEPARATOR && ! str_contains ( $ file , ':' ) ? $ base . DIRECTORY_SEPARATOR . $ file : $ file ; } | Turn a relative filename to an absolute path |
32,876 | protected function assertFile ( string $ file , array $ options ) : bool { if ( is_file ( $ file ) && is_readable ( $ file ) ) { return true ; } if ( ! ( bool ) ( $ options [ 'optional' ] ?? false ) ) { throw new LoadException ( "Config file '$file' doesn't exist or is not readable" ) ; } return false ; } | Assert the file exists |
32,877 | protected function assertData ( $ data , string $ file ) : void { if ( $ data === false || $ data === null ) { throw new LoadException ( "Failed to load settings from '$file'" ) ; } if ( ! $ data instanceof stdClass && ! is_associative_array ( $ data ) ) { throw new LoadException ( "Failed to load settings from '$file': data should be key/value pairs" ) ; } } | Assert that data has been property loaded |
32,878 | public function load ( $ file , array $ options = [ ] ) : Config { expect_type ( $ file , 'string' ) ; $ options += $ this -> options ; $ path = $ this -> absolutePath ( $ file , $ options [ 'base_path' ] ?? getcwd ( ) ) ; if ( ! $ this -> assertFile ( $ path , $ options ) ) { return new Config ( ) ; } $ data = $ this -> loadFile ( $ path , $ options ) ; $ this -> assertData ( $ data , $ file ) ; return new Config ( $ data ) ; } | Load a config file or directory |
32,879 | protected function _process ( $ stmts ) { $ this -> _msg ( 'Adding unique constraints to catalog index tables' , 0 ) ; $ this -> _status ( '' ) ; foreach ( $ stmts as $ table => $ list ) { foreach ( $ list as $ index => $ sqls ) { $ this -> _msg ( sprintf ( 'Checking index "%1$s"' , $ index ) , 1 ) ; if ( $ this -> _schema -> tableExists ( $ table ) === true && $ this -> _schema -> constraintExists ( $ table , $ index ) === false ) { $ this -> _executeList ( $ sqls ) ; $ this -> _status ( 'added' ) ; } else { $ this -> _status ( 'OK' ) ; } } } } | Adds unique constraints to catalog index tables . |
32,880 | public function populate ( $ value ) : void { $ isArray = $ this -> isArray ( ) ; if ( $ value === null ) { $ value = $ isArray ? [ ] : '' ; } else { $ isCorrectType = $ isArray ? is_array ( $ value ) : is_string ( $ value ) ; if ( ! $ isCorrectType ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid value received for "%s": expected %s, got %s' , $ this -> getName ( ) , $ isArray ? 'array' : 'string' , gettype ( $ value ) ) ) ; } } $ this -> resetErrors ( ) ; $ empty = ( $ value === '' || $ value === [ ] ) ; if ( $ empty && $ this -> required ) { $ this -> addTranslatableError ( 'form.required' , 'This field is required.' ) ; } if ( ! $ empty && ! $ isArray ) { $ value = $ this -> filter ( $ value ) ; $ this -> validate ( $ value ) ; } $ this -> doPopulate ( $ value ) ; } | Populates the component with the given value . |
32,881 | public function addValidator ( Validator $ validator ) : Component { $ hash = spl_object_hash ( $ validator ) ; $ this -> validators [ $ hash ] = $ validator ; return $ this ; } | Adds a validator . |
32,882 | protected function hasValidator ( Validator $ validator ) : bool { $ hash = spl_object_hash ( $ validator ) ; return isset ( $ this -> validators [ $ hash ] ) ; } | Checks whether a validator is present . |
32,883 | protected function removeValidator ( Validator $ validator ) : Component { $ hash = spl_object_hash ( $ validator ) ; unset ( $ this -> validators [ $ hash ] ) ; return $ this ; } | Removes a validator . |
32,884 | protected function removeValidators ( string $ className ) : Component { foreach ( $ this -> validators as $ key => $ validator ) { if ( $ validator instanceof $ className ) { unset ( $ this -> validators [ $ key ] ) ; } } return $ this ; } | Removes all validators of the given class name . |
32,885 | function _mapInExtensions ( & $ root , $ path , $ asn1 ) { $ extensions = & $ this -> _subArray ( $ root , $ path ) ; if ( is_array ( $ extensions ) ) { for ( $ i = 0 ; $ i < count ( $ extensions ) ; $ i ++ ) { $ id = $ extensions [ $ i ] [ 'extnId' ] ; $ value = & $ extensions [ $ i ] [ 'extnValue' ] ; $ value = base64_decode ( $ value ) ; $ decoded = $ asn1 -> decodeBER ( $ value ) ; $ map = $ this -> _getMapping ( $ id ) ; if ( ! is_bool ( $ map ) ) { $ mapped = $ asn1 -> asn1map ( $ decoded [ 0 ] , $ map ) ; $ value = $ mapped === false ? $ decoded [ 0 ] : $ mapped ; if ( $ id == 'id-ce-certificatePolicies' ) { for ( $ j = 0 ; $ j < count ( $ value ) ; $ j ++ ) { if ( ! isset ( $ value [ $ j ] [ 'policyQualifiers' ] ) ) { continue ; } for ( $ k = 0 ; $ k < count ( $ value [ $ j ] [ 'policyQualifiers' ] ) ; $ k ++ ) { $ subid = $ value [ $ j ] [ 'policyQualifiers' ] [ $ k ] [ 'policyQualifierId' ] ; $ map = $ this -> _getMapping ( $ subid ) ; $ subvalue = & $ value [ $ j ] [ 'policyQualifiers' ] [ $ k ] [ 'qualifier' ] ; if ( $ map !== false ) { $ decoded = $ asn1 -> decodeBER ( $ subvalue ) ; $ mapped = $ asn1 -> asn1map ( $ decoded [ 0 ] , $ map ) ; $ subvalue = $ mapped === false ? $ decoded [ 0 ] : $ mapped ; } } } } } elseif ( $ map ) { $ value = base64_encode ( $ value ) ; } } } } | Map extension values from octet string to extension - specific internal format . |
32,886 | function loadCA ( $ cert ) { $ olddn = $ this -> dn ; $ oldcert = $ this -> currentCert ; $ oldsigsubj = $ this -> signatureSubject ; $ cert = $ this -> loadX509 ( $ cert ) ; if ( ! $ cert ) { $ this -> dn = $ olddn ; $ this -> currentCert = $ oldcert ; $ this -> signatureSubject = $ oldsigsubj ; return false ; } $ this -> CAs [ ] = $ cert ; $ this -> dn = $ olddn ; $ this -> currentCert = $ oldcert ; $ this -> signatureSubject = $ oldsigsubj ; return true ; } | Load an X . 509 certificate as a certificate authority |
32,887 | function signCSR ( $ signatureAlgorithm = 'sha1WithRSAEncryption' ) { if ( ! is_object ( $ this -> privateKey ) || empty ( $ this -> dn ) ) { return false ; } $ origPublicKey = $ this -> publicKey ; $ class = get_class ( $ this -> privateKey ) ; $ this -> publicKey = new $ class ( ) ; $ this -> publicKey -> loadKey ( $ this -> privateKey -> getPublicKey ( ) ) ; $ this -> publicKey -> setPublicKey ( ) ; if ( ! ( $ publicKey = $ this -> _formatSubjectPublicKey ( ) ) ) { return false ; } $ this -> publicKey = $ origPublicKey ; $ currentCert = isset ( $ this -> currentCert ) ? $ this -> currentCert : NULL ; $ signatureSubject = isset ( $ this -> signatureSubject ) ? $ this -> signatureSubject : NULL ; if ( isset ( $ this -> currentCert ) && is_array ( $ this -> currentCert ) && isset ( $ this -> currentCert [ 'certificationRequestInfo' ] ) ) { $ this -> currentCert [ 'signatureAlgorithm' ] [ 'algorithm' ] = $ signatureAlgorithm ; if ( ! empty ( $ this -> dn ) ) { $ this -> currentCert [ 'certificationRequestInfo' ] [ 'subject' ] = $ this -> dn ; } $ this -> currentCert [ 'certificationRequestInfo' ] [ 'subjectPKInfo' ] = $ publicKey ; } else { $ this -> currentCert = array ( 'certificationRequestInfo' => array ( 'version' => 'v1' , 'subject' => $ this -> dn , 'subjectPKInfo' => $ publicKey ) , 'signatureAlgorithm' => array ( 'algorithm' => $ signatureAlgorithm ) , 'signature' => false ) ; } $ certificationRequestInfo = $ this -> currentCert [ 'certificationRequestInfo' ] ; $ this -> loadCSR ( $ this -> saveCSR ( $ this -> currentCert ) ) ; $ result = $ this -> _sign ( $ this -> privateKey , $ signatureAlgorithm ) ; $ result [ 'certificationRequestInfo' ] = $ certificationRequestInfo ; $ this -> currentCert = $ currentCert ; $ this -> signatureSubject = $ signatureSubject ; return $ result ; } | Sign a CSR |
32,888 | function _getExtension ( $ id , $ cert = NULL , $ path = NULL ) { $ extensions = $ this -> _extensions ( $ cert , $ path ) ; if ( ! is_array ( $ extensions ) ) { return false ; } foreach ( $ extensions as $ key => $ value ) { if ( $ value [ 'extnId' ] == $ id ) { return $ value [ 'extnValue' ] ; } } return false ; } | Get an Extension |
32,889 | function _setExtension ( $ id , $ value , $ critical = false , $ replace = true , $ path = NULL ) { $ extensions = & $ this -> _extensions ( $ this -> currentCert , $ path , true ) ; if ( ! is_array ( $ extensions ) ) { return false ; } $ newext = array ( 'extnId' => $ id , 'critical' => $ critical , 'extnValue' => $ value ) ; foreach ( $ extensions as $ key => $ value ) { if ( $ value [ 'extnId' ] == $ id ) { if ( ! $ replace ) { return false ; } $ extensions [ $ key ] = $ newext ; return true ; } } $ extensions [ ] = $ newext ; return true ; } | Set an Extension |
32,890 | function getRevokedCertificateExtension ( $ serial , $ id , $ crl = NULL ) { if ( ! isset ( $ crl ) ) { $ crl = $ this -> currentCert ; } if ( is_array ( $ rclist = $ this -> _subArray ( $ crl , 'tbsCertList/revokedCertificates' ) ) ) { if ( ( $ i = $ this -> _revokedCertificate ( $ rclist , $ serial ) ) !== false ) { return $ this -> _getExtension ( $ id , $ crl , "tbsCertList/revokedCertificates/$i/crlEntryExtensions" ) ; } } return false ; } | Get a Revoked Certificate Extension |
32,891 | public function increase ( $ productCode , $ warehouseCode , $ amount ) { $ context = $ this -> _getContext ( ) ; $ productManager = MShop_Factory :: createManager ( $ context , 'product' ) ; $ search = $ productManager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'product.code' , $ productCode ) ) ; $ productIds = array_keys ( $ productManager -> searchItems ( $ search ) ) ; $ warehouseManager = $ this -> getSubManager ( 'warehouse' ) ; $ search = $ warehouseManager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'product.stock.warehouse.code' , $ warehouseCode ) ) ; $ warehouseIds = array_keys ( $ warehouseManager -> searchItems ( $ search ) ) ; if ( empty ( $ warehouseIds ) ) { throw new MShop_Product_Exception ( sprintf ( 'No warehouse for code "%1$s" found' , $ warehouseCode ) ) ; } $ search = $ this -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , 'product.stock.siteid' , $ context -> getLocale ( ) -> getSitePath ( ) ) , $ search -> compare ( '==' , 'product.stock.productid' , $ productIds ) , $ search -> compare ( '==' , 'product.stock.warehouseid' , $ warehouseIds ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ types = array ( 'product.stock.siteid' => $ this -> _searchConfig [ 'product.stock.siteid' ] [ 'internaltype' ] , 'product.stock.productid' => $ this -> _searchConfig [ 'product.stock.productid' ] [ 'internaltype' ] , 'product.stock.warehouseid' => $ this -> _searchConfig [ 'product.stock.warehouseid' ] [ 'internaltype' ] , ) ; $ translations = array ( 'product.stock.siteid' => '"siteid"' , 'product.stock.productid' => '"prodid"' , 'product.stock.warehouseid' => '"warehouseid"' , ) ; $ conditions = $ search -> getConditionString ( $ types , $ translations ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ path = 'mshop/product/manager/stock/default/item/stocklevel' ; $ 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 -> execute ( ) -> finish ( ) ; $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } } | Increases the stock level of the product for the warehouse . |
32,892 | protected function _addLocaleSiteData ( MShop_Common_Manager_Interface $ localeManager , array $ data , $ manager = 'Default' , $ parentId = null ) { $ this -> _msg ( 'Adding data for MShop locale sites' , 1 ) ; $ localeSiteManager = $ localeManager -> getSubManager ( 'site' , $ manager ) ; $ siteItem = $ localeSiteManager -> createItem ( ) ; $ siteIds = array ( ) ; foreach ( $ data as $ key => $ dataset ) { try { $ siteItem -> setId ( null ) ; $ siteItem -> setCode ( $ dataset [ 'code' ] ) ; $ siteItem -> setLabel ( $ dataset [ 'label' ] ) ; $ siteItem -> setConfig ( $ dataset [ 'config' ] ) ; $ siteItem -> setStatus ( $ dataset [ 'status' ] ) ; $ localeSiteManager -> insertItem ( $ siteItem , $ parentId ) ; $ siteIds [ $ key ] = $ siteItem -> getId ( ) ; } catch ( Exception $ e ) { $ search = $ localeSiteManager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'locale.site.code' , $ dataset [ 'code' ] ) ) ; $ result = $ localeSiteManager -> searchItems ( $ search ) ; if ( ( $ item = reset ( $ result ) ) === false ) { throw new Exception ( sprintf ( 'No site for code "%1$s" available' , $ dataset [ 'code' ] ) ) ; } $ siteIds [ $ key ] = $ item -> getId ( ) ; } } $ this -> _status ( 'done' ) ; return $ siteIds ; } | Adds locale site data . |
32,893 | protected function _addLocaleCurrencyData ( MShop_Common_Manager_Interface $ localeManager , array $ data ) { $ this -> _msg ( 'Adding data for MShop locale currencies' , 1 ) ; $ currencyItemManager = $ localeManager -> getSubManager ( 'currency' , 'Default' ) ; $ num = $ total = 0 ; foreach ( $ data as $ key => $ dataset ) { $ total ++ ; $ currencyItem = $ currencyItemManager -> createItem ( ) ; $ currencyItem -> setCode ( $ dataset [ 'id' ] ) ; $ currencyItem -> setLabel ( $ dataset [ 'label' ] ) ; $ currencyItem -> setStatus ( $ dataset [ 'status' ] ) ; try { $ currencyItemManager -> saveItem ( $ currencyItem ) ; $ num ++ ; } catch ( Exception $ e ) { ; } } $ this -> _status ( $ num > 0 ? $ num . '/' . $ total : 'OK' ) ; } | Adds locale currency data . |
32,894 | protected function _addLocaleLanguageData ( MShop_Common_Manager_Interface $ localeManager , array $ data ) { $ this -> _msg ( 'Adding data for MShop locale languages' , 1 ) ; $ languageItemManager = $ localeManager -> getSubManager ( 'language' , 'Default' ) ; $ num = $ total = 0 ; foreach ( $ data as $ dataset ) { $ total ++ ; $ languageItem = $ languageItemManager -> createItem ( ) ; $ languageItem -> setCode ( $ dataset [ 'id' ] ) ; $ languageItem -> setLabel ( $ dataset [ 'label' ] ) ; $ languageItem -> setStatus ( $ dataset [ 'status' ] ) ; try { $ languageItemManager -> saveItem ( $ languageItem ) ; $ num ++ ; } catch ( Exception $ e ) { ; } } $ this -> _status ( $ num > 0 ? $ num . '/' . $ total : 'OK' ) ; } | Adds locale language data . |
32,895 | public function returnError ( $ errorKeyOrDefinition , $ replacementArray = array ( ) ) { if ( is_string ( $ errorKeyOrDefinition ) ) { $ errorKey = $ errorKeyOrDefinition ; } else { $ errorKeys = array_keys ( $ errorKeyOrDefinition ) ; $ errorKey = $ errorKeys [ 0 ] ; } $ errorResponse = $ this -> errorResponseDictionary -> getErrorResponse ( $ errorKey ) ; if ( empty ( $ errorResponse ) ) { $ errorResponse = ErrorResponse :: FromArray ( $ errorKeyOrDefinition [ $ errorKey ] ) ; } $ appCode = $ errorResponse -> getCode ( ) ; echo json_encode ( array ( 'error' => empty ( $ appCode ) ? array ( 'message' => $ errorResponse -> getFormattedMessage ( $ replacementArray ) ) : array ( 'code' => $ appCode , 'message' => $ errorResponse -> getFormattedMessage ( $ replacementArray ) ) ) ) ; $ this -> getResponse ( ) -> status ( $ errorResponse -> getHttpcode ( ) ) ; throw new Stop ( $ errorResponse -> getFormattedMessage ( $ replacementArray ) ) ; } | Returns a JSON array displaying the error to the client and stops execution |
32,896 | static function display ( $ exception , ResponseInterface $ response = null ) { if ( strpos ( get ( $ _SERVER , 'HTTP_ACCEPT' ) , 'text/html' ) !== false ) { ob_start ( ) ; ErrorConsoleRenderer :: renderStyles ( ) ; $ stackTrace = self :: getStackTrace ( $ exception -> getPrevious ( ) ? : $ exception ) ; ErrorConsoleRenderer :: renderPopup ( $ exception , self :: $ appName , $ stackTrace ) ; $ popup = ob_get_clean ( ) ; if ( $ response ) { $ response -> getBody ( ) -> write ( $ popup ) ; return $ response -> withStatus ( 500 ) ; } echo $ popup ; } else { if ( $ response ) { $ response -> getBody ( ) -> write ( $ exception -> getMessage ( ) ) ; if ( self :: $ devEnv ) $ response -> getBody ( ) -> write ( "\n\nStack trace:\n" . $ exception -> getTraceAsString ( ) ) ; return $ response -> withoutHeader ( 'Content-Type' ) -> withHeader ( 'Content-Type' , 'text-plain' ) -> withStatus ( 500 ) ; } header ( "Content-Type: text/plain" ) ; http_response_code ( 500 ) ; echo $ exception -> getMessage ( ) ; if ( self :: $ devEnv ) echo "\n\nStack trace:\n" . $ exception -> getTraceAsString ( ) ; } return null ; } | Outputs the error popup or a plain message depending on the response content type . |
32,897 | public static function processMessage ( $ msg ) { $ msg = preg_replace_callback ( '#<path>([^<]*)</path>#' , function ( $ m ) { return ErrorConsole :: errorLink ( $ m [ 1 ] , 1 , 1 , self :: shortFileName ( $ m [ 1 ] ) ) ; } , $ msg ) ; return $ msg ; } | For use by renderers . |
32,898 | public function toConditions ( array $ array ) { if ( count ( $ array ) === 0 ) { return $ this -> compare ( '==' , '1' , '1' ) ; } if ( ( list ( $ op , $ value ) = each ( $ array ) ) === false ) { throw new MW_Common_Exception ( sprintf ( 'Invalid condition array "%1$s"' , json_encode ( $ array ) ) ) ; } $ operators = $ this -> getOperators ( ) ; if ( in_array ( $ op , $ operators [ 'combine' ] ) ) { return $ this -> _createCombineExpression ( $ op , ( array ) $ value ) ; } else if ( in_array ( $ op , $ operators [ 'compare' ] ) ) { return $ this -> _createCompareExpression ( $ op , ( array ) $ value ) ; } throw new MW_Common_Exception ( sprintf ( 'Invalid operator "%1$s"' , $ op ) ) ; } | Creates condition expressions from a multi - dimensional associative array . |
32,899 | public function toSortations ( array $ array ) { $ results = array ( ) ; foreach ( $ array as $ name => $ op ) { $ results [ ] = $ this -> sort ( $ op , $ name ) ; } return $ results ; } | Creates sortation expressions from an associative array . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.