idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
32,600 | public static function castFromJson ( JsonParseException $ exception ) : self { $ details = $ exception -> getDetails ( ) ; $ message = $ exception -> getMessage ( ) ; $ line = $ details [ 'line' ] ?? - 1 ; $ snippet = null ; if ( preg_match ( "/^Parse error on line (\\d+):\n(.+)\n.+\n(.+)$/" , $ message , $ matches ) ) { $ line = ( int ) $ matches [ 1 ] ; $ snippet = $ matches [ 2 ] ; $ message = $ matches [ 3 ] ; } $ trailingComma = false ; $ pos = mb_strpos ( $ message , ' - It appears you have an extra trailing comma' ) ; if ( $ pos > 0 ) { $ message = mb_substr ( $ message , 0 , $ pos ) ; $ trailingComma = true ; } if ( mb_strpos ( $ message , 'Expected' ) === 0 && $ trailingComma ) { $ message = 'It appears you have an extra trailing comma' ; } $ message = 'JSON parsing failed: ' . $ message ; return new static ( $ message , $ line , $ snippet , JSON_ERROR_SYNTAX ) ; } | Casts JsonLint ParseException to ours . |
32,601 | private function updateRepr ( ) : void { $ this -> message = $ this -> rawMessage ; $ dot = false ; if ( mb_substr ( $ this -> message , - 1 ) === '.' ) { $ this -> message = mb_substr ( $ this -> message , 0 , - 1 ) ; $ dot = true ; } if ( $ this -> parsedLine >= 0 ) { $ this -> message .= sprintf ( ' at line %d' , $ this -> parsedLine ) ; } if ( $ this -> snippet ) { $ this -> message .= sprintf ( ' (near "%s")' , $ this -> snippet ) ; } if ( $ dot ) { $ this -> message .= '.' ; } } | Sets the exception message by joining the raw message parsed line and snippet . |
32,602 | public function getMode ( ) { if ( ! isset ( $ this -> mode ) ) { if ( isset ( $ _ENV [ 'SLIM_MODE' ] ) ) { $ this -> mode = $ _ENV [ 'SLIM_MODE' ] ; } else { $ envMode = getenv ( 'SLIM_MODE' ) ; if ( $ envMode !== false ) { $ this -> mode = $ envMode ; } else { $ this -> mode = $ this -> config ( 'mode' ) ; } } } return $ this -> mode ; } | Get application mode |
32,603 | protected function mapRoute ( $ args ) { $ pattern = array_shift ( $ args ) ; $ callable = array_pop ( $ args ) ; $ route = $ this -> router -> map ( $ pattern , $ callable ) ; if ( count ( $ args ) > 0 ) { $ route -> setMiddleware ( $ args ) ; } return $ route ; } | Add GET|POST|PUT|DELETE route |
32,604 | public function setEncryptedCookie ( $ name , $ value , $ expires = null , $ path = null , $ domain = null , $ secure = null , $ httponly = null ) { $ expires = is_null ( $ expires ) ? $ this -> config ( 'cookies.lifetime' ) : $ expires ; if ( is_string ( $ expires ) ) { $ expires = strtotime ( $ expires ) ; } $ secureValue = \ Slim \ Http \ Util :: encodeSecureCookie ( $ value , $ expires , $ this -> config ( 'cookies.secret_key' ) , $ this -> config ( 'cookies.cipher' ) , $ this -> config ( 'cookies.cipher_mode' ) ) ; $ this -> setCookie ( $ name , $ secureValue , $ expires , $ path , $ domain , $ secure , $ httponly ) ; } | Set encrypted HTTP cookie |
32,605 | public function getEncryptedCookie ( $ name , $ deleteIfInvalid = true ) { $ value = \ Slim \ Http \ Util :: decodeSecureCookie ( $ this -> request -> cookies ( $ name ) , $ this -> config ( 'cookies.secret_key' ) , $ this -> config ( 'cookies.cipher' ) , $ this -> config ( 'cookies.cipher_mode' ) ) ; if ( $ value === false && $ deleteIfInvalid ) { $ this -> deleteCookie ( $ name ) ; } return $ value ; } | Get value of encrypted HTTP cookie |
32,606 | public static function handleErrors ( $ errno , $ errstr = '' , $ errfile = '' , $ errline = '' ) { if ( error_reporting ( ) & $ errno ) { throw new \ ErrorException ( $ errstr , $ errno , 0 , $ errfile , $ errline ) ; } return true ; } | Convert errors into ErrorException objects |
32,607 | public function initializeObjectAttribute ( $ objectAttribute , $ currentVersion , $ originalContentObjectAttribute ) { $ value = $ currentVersion != false ? $ originalContentObjectAttribute -> content ( ) : $ this -> fieldType -> getEmptyValue ( ) ; $ objectAttribute -> setContent ( $ value ) ; } | Initializes content object attribute based on another attribute . |
32,608 | public function fetchObjectAttributeHTTPInput ( $ http , $ base , $ objectAttribute ) { $ objectAttributeId = $ objectAttribute -> attribute ( 'id' ) ; if ( ! $ http -> hasPostVariable ( $ base . self :: RICH_TEXT_VARIABLE . $ objectAttributeId ) ) { return false ; } $ value = trim ( $ http -> postVariable ( $ base . self :: RICH_TEXT_VARIABLE . $ objectAttributeId ) ) ; $ objectAttribute -> setContent ( new Value ( $ value ) ) ; return true ; } | Fetches the HTTP POST input and stores it in the data instance . |
32,609 | public function hasObjectAttributeContent ( $ objectAttribute ) { $ value = $ objectAttribute -> content ( ) ; if ( ! $ value instanceof Value ) { return false ; } return ! $ this -> fieldType -> isEmptyValue ( $ value ) ; } | Returns true if content object attribute has content . |
32,610 | public function storeObjectAttribute ( $ objectAttribute ) { $ value = $ this -> storage -> storeFieldData ( $ objectAttribute , $ objectAttribute -> content ( ) ) ; $ objectAttribute -> setAttribute ( self :: RICH_TEXT_FIELD , ( string ) $ value ) ; } | Stores the object attribute . |
32,611 | protected function getObjectIdsForNodeIds ( array $ nodeIds ) { $ objectIds = array ( ) ; foreach ( $ nodeIds as $ nodeId ) { $ object = eZContentObject :: fetchByNodeID ( $ nodeId ) ; if ( $ object instanceof eZContentObject ) { $ objectIds [ ] = $ object -> attribute ( 'id' ) ; } } return $ objectIds ; } | Returns all object IDs for provided node IDs . |
32,612 | protected function fixInputRelations ( eZContentObject $ object , $ versionNo ) { $ validRelationTypes = array ( 1 , 2 , 4 , 8 , 16 , 32 , 64 , 128 ) ; $ db = eZDB :: instance ( ) ; $ rows = $ db -> arrayQuery ( "SELECT * FROM ezcontentobject_link WHERE from_contentobject_id={$object->attribute('id')} AND from_contentobject_version={$versionNo}" ) ; foreach ( $ rows as $ row ) { $ relationType = ( int ) $ row [ 'relation_type' ] ; if ( ! in_array ( $ relationType , $ validRelationTypes ) ) { foreach ( $ validRelationTypes as $ validRelationType ) { if ( $ relationType & $ validRelationType ) { $ db -> query ( "INSERT INTO ezcontentobject_link ( from_contentobject_id, from_contentobject_version, to_contentobject_id, contentclassattribute_id, relation_type ) VALUES ( {$row['from_contentobject_id']}, {$row['from_contentobject_version']}, {$row['to_contentobject_id']}, {$row['contentclassattribute_id']}, {$validRelationType} ) " ) ; } } $ db -> query ( "DELETE FROM ezcontentobject_link WHERE id = {$row['id']}" ) ; } } } | Converts all composite relations to non composite ones . |
32,613 | public function toString ( $ objectAttribute ) { $ value = $ objectAttribute -> content ( ) ; $ value = $ value instanceof Value ? $ value : $ this -> fieldType -> getEmptyValue ( ) ; return ( string ) $ value ; } | Returns string representation of a content object attribute . |
32,614 | public function fromString ( $ objectAttribute , $ string ) { try { $ value = $ this -> fieldType -> acceptValue ( $ string ) ; } catch ( InvalidArgumentException $ e ) { return false ; } $ errors = $ this -> fieldType -> validate ( new FieldDefinition ( ) , $ value ) ; if ( ! empty ( $ errors ) ) { return false ; } $ objectAttribute -> setContent ( $ value ) ; return true ; } | Creates the content object attribute from string representation . |
32,615 | public function serializeContentObjectAttribute ( $ package , $ objectAttribute ) { $ node = $ this -> createContentObjectAttributeDOMNode ( $ objectAttribute ) ; $ value = $ objectAttribute -> content ( ) ; $ value = $ value instanceof Value ? $ value : $ this -> fieldType -> getEmptyValue ( ) ; $ xml = clone $ value -> xml ; $ this -> transformLinksToRemoteLinks ( $ xml ) ; $ dom = $ node -> ownerDocument ; $ valueNode = $ dom -> createElement ( 'rich-text-xml' ) ; $ valueNode -> appendChild ( $ dom -> createTextNode ( $ xml -> saveXML ( ) ) ) ; $ node -> appendChild ( $ valueNode ) ; return $ node ; } | Serializes the content object attribute . |
32,616 | public function unserializeContentObjectAttribute ( $ package , $ objectAttribute , $ attributeNode ) { $ xmlString = $ attributeNode -> getElementsByTagName ( 'rich-text-xml' ) -> item ( 0 ) -> textContent ; $ value = new DOMDocument ( ) ; $ value -> loadXML ( $ xmlString ) ; $ this -> transformRemoteLinksToLinks ( $ value ) ; try { $ value = $ this -> fieldType -> acceptValue ( $ value ) ; } catch ( InvalidArgumentException $ e ) { return ; } $ errors = $ this -> fieldType -> validate ( new FieldDefinition ( ) , $ value ) ; if ( ! empty ( $ errors ) ) { return ; } $ objectAttribute -> setContent ( $ value ) ; } | Unserializes the content object attribute from provided DOM node . |
32,617 | public function metaData ( $ objectAttribute ) { $ value = $ objectAttribute -> content ( ) ; if ( ! $ value instanceof Value ) { return '' ; } return $ this -> extractText ( $ value -> xml -> documentElement ) ; } | Returns the meta data used for storing search indices . |
32,618 | public function title ( $ objectAttribute , $ name = null ) { $ value = $ objectAttribute -> content ( ) ; if ( ! $ value instanceof Value ) { return '' ; } return $ this -> fieldType -> getName ( $ value ) ; } | Returns the title of the current type this is to form the title of the object . |
32,619 | public function unserialize ( $ input ) { $ input = unserialize ( $ input ) ; if ( ! ( $ input instanceof Input ) ) { throw new \ UnexpectedValueException ( sprintf ( '%s would not accept a `%s`.' , __METHOD__ , \ gettype ( $ this -> input ) ) ) ; } $ this -> setInput ( $ input ) ; return $ this ; } | Unserialize the controller . |
32,620 | public function getCatalogPath ( $ id , array $ domains = array ( 'text' , 'media' ) ) { return MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'catalog' ) -> getPath ( $ id , $ domains ) ; } | Returns the list of categries that are in the path to the root node including the one specified by its ID . |
32,621 | public function getCatalogTree ( $ id = null , array $ domains = array ( 'text' , 'media' ) , $ level = MW_Tree_Manager_Abstract :: LEVEL_TREE ) { return MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'catalog' ) -> getTree ( $ id , $ domains , $ level ) ; } | Returns the hierarchical catalog tree starting from the given ID . |
32,622 | public function createProductFilterDefault ( $ sort = null , $ direction = '+' , $ start = 0 , $ size = 100 , $ listtype = 'default' ) { $ sortations = array ( ) ; $ context = $ this -> _getContext ( ) ; $ search = MShop_Factory :: createManager ( $ context , 'catalog/index' ) -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '!=' , 'catalog.index.catalog.id' , null ) ) ; switch ( $ sort ) { case 'code' : $ sortations [ ] = $ search -> sort ( $ direction , 'product.code' ) ; break ; case 'name' : $ langid = $ context -> getLocale ( ) -> getLanguageId ( ) ; $ cmpfunc = $ search -> createFunction ( 'catalog.index.text.value' , array ( $ listtype , $ langid , 'name' , 'product' ) ) ; $ expr [ ] = $ search -> compare ( '>=' , $ cmpfunc , '' ) ; $ sortfunc = $ search -> createFunction ( 'sort:catalog.index.text.value' , array ( $ listtype , $ langid , 'name' ) ) ; $ sortations [ ] = $ search -> sort ( $ direction , $ sortfunc ) ; break ; case 'price' : $ currencyid = $ context -> getLocale ( ) -> getCurrencyId ( ) ; $ cmpfunc = $ search -> createFunction ( 'catalog.index.price.value' , array ( $ listtype , $ currencyid , 'default' ) ) ; $ expr [ ] = $ search -> compare ( '>=' , $ cmpfunc , '0.00' ) ; $ sortfunc = $ search -> createFunction ( 'sort:catalog.index.price.value' , array ( $ listtype , $ currencyid , 'default' ) ) ; $ sortations [ ] = $ search -> sort ( $ direction , $ sortfunc ) ; break ; } $ expr [ ] = $ search -> getConditions ( ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( $ sortations ) ; $ search -> setSlice ( $ start , $ size ) ; return $ search ; } | Returns the default product filter . |
32,623 | public function createProductFilterByCategory ( $ catid , $ sort = null , $ direction = '+' , $ start = 0 , $ size = 100 , $ listtype = 'default' ) { $ search = $ this -> createProductFilterDefault ( $ sort , $ direction , $ start , $ size , $ listtype ) ; $ expr = array ( $ search -> compare ( '==' , 'catalog.index.catalog.id' , $ catid ) ) ; if ( $ sort === 'relevance' ) { $ cmpfunc = $ search -> createFunction ( 'catalog.index.catalog.position' , array ( $ listtype , $ catid ) ) ; $ expr [ ] = $ search -> compare ( '>=' , $ cmpfunc , 0 ) ; $ sortfunc = $ search -> createFunction ( 'sort:catalog.index.catalog.position' , array ( $ listtype , $ catid ) ) ; $ search -> setSortations ( array ( $ search -> sort ( $ direction , $ sortfunc ) ) ) ; } $ expr [ ] = $ search -> getConditions ( ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; return $ search ; } | Returns a product filter for the given category ID . |
32,624 | public function createProductFilterByText ( $ input , $ sort = null , $ direction = '+' , $ start = 0 , $ size = 100 , $ listtype = 'default' ) { $ langid = $ this -> _getContext ( ) -> getLocale ( ) -> getLanguageId ( ) ; $ search = $ this -> createProductFilterDefault ( $ sort , $ direction , $ start , $ size , $ listtype ) ; $ expr = array ( $ search -> compare ( '>' , $ search -> createFunction ( 'catalog.index.text.relevance' , array ( $ listtype , $ langid , $ input ) ) , 0 ) ) ; $ expr [ ] = $ search -> getConditions ( ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; return $ search ; } | Returns product filter for the given search string . |
32,625 | public function getProductList ( MW_Common_Criteria_Interface $ filter , & $ total = null , array $ domains = array ( 'media' , 'price' , 'text' ) ) { return MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'catalog/index' ) -> searchItems ( $ filter , $ domains , $ total ) ; } | Returns a product list filtered by the given criteria object . |
32,626 | public function createTextFilter ( $ input , $ sort = null , $ direction = '+' , $ start = 0 , $ size = 25 , $ listtype = 'default' , $ type = 'name' ) { $ locale = $ this -> _getContext ( ) -> getLocale ( ) ; $ langid = $ locale -> getLanguageId ( ) ; $ search = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'catalog/index/text' ) -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '>' , $ search -> createFunction ( 'catalog.index.text.relevance' , array ( $ listtype , $ langid , $ input ) ) , 0 ) , $ search -> compare ( '>' , $ search -> createFunction ( 'catalog.index.text.value' , array ( $ listtype , $ langid , $ type , 'product' ) ) , '' ) , ) ; $ sortations = array ( ) ; switch ( $ sort ) { case 'name' : $ cmpfunc = $ search -> createFunction ( 'catalog.index.text.value' , array ( $ listtype , $ langid , 'name' , 'product' ) ) ; $ expr [ ] = $ search -> compare ( '>=' , $ cmpfunc , '' ) ; $ sortfunc = $ search -> createFunction ( 'sort:catalog.index.text.value' , array ( $ listtype , $ langid , 'name' ) ) ; $ sortations [ ] = $ search -> sort ( $ direction , $ sortfunc ) ; break ; case 'relevance' : } $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( $ sortations ) ; $ search -> setSlice ( $ start , $ size ) ; return $ search ; } | Returns text filter for the given search string . |
32,627 | static public function createManager ( MW_Config_Interface $ config , $ type = 'Default' ) { $ classname = 'MW_DB_Manager_' . $ type ; $ filename = str_replace ( '_' , '/' , $ classname ) . '.php' ; $ paths = explode ( PATH_SEPARATOR , get_include_path ( ) ) ; foreach ( $ paths as $ path ) { $ file = $ path . DIRECTORY_SEPARATOR . $ filename ; if ( file_exists ( $ file ) === true && ( include_once $ file ) !== false && class_exists ( $ classname ) ) { return new $ classname ( $ config ) ; } } throw new MW_DB_Exception ( sprintf ( 'Database manager "%1$s" not found' , $ type ) ) ; } | Creates and returns a database manager . |
32,628 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( ( array ) $ entry as $ name => $ value ) { switch ( $ name ) { case 'catalog.list.id' : $ item -> setId ( $ value ) ; break ; case 'catalog.list.domain' : $ item -> setDomain ( $ value ) ; break ; case 'catalog.list.parentid' : $ item -> setParentId ( $ value ) ; break ; case 'catalog.list.position' : $ item -> setPosition ( $ value ) ; break ; case 'catalog.list.config' : $ item -> setConfig ( ( array ) $ value ) ; break ; case 'catalog.list.status' : $ item -> setStatus ( $ value ) ; break ; case 'catalog.list.typeid' : $ item -> setTypeId ( $ value ) ; break ; case 'catalog.list.refid' : $ item -> setRefId ( $ value ) ; break ; case 'catalog.list.datestart' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'catalog.list.datestart' } = $ value ; $ item -> setDateStart ( $ value ) ; } break ; case 'catalog.list.dateend' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'catalog.list.dateend' } = $ value ; $ item -> setDateEnd ( $ value ) ; } break ; } } return $ item ; } | Creates a new catalog list item and sets the properties from the given array . |
32,629 | private function getInjectionFuncParams ( Argument $ argument ) : array { $ dependencyIndex = ( string ) $ argument ; if ( $ this -> container -> getContainer ( ) [ $ dependencyIndex ] instanceof DependencyProvider ) { return $ this -> getInjectionProviderParams ( $ argument ) ; } return [ new Node \ Arg ( new Scalar \ String_ ( ( string ) $ argument ) ) ] ; } | Return dependency index argument |
32,630 | private function getInjectionProviderParams ( Argument $ argument ) : array { $ param = $ argument -> get ( ) ; $ class = $ param -> getDeclaringClass ( ) ; if ( ! $ class instanceof \ ReflectionClass ) { throw new \ LogicException ; } $ method = $ param -> getDeclaringFunction ( ) ; $ this -> setQualifiers ( $ method , $ param ) ; return [ new Node \ Arg ( new Scalar \ String_ ( ( string ) $ argument ) ) , new Expr \ Array_ ( [ new Expr \ ArrayItem ( new Scalar \ String_ ( $ class -> name ) ) , new Expr \ ArrayItem ( new Scalar \ String_ ( $ method -> name ) ) , new Expr \ ArrayItem ( new Scalar \ String_ ( $ param -> name ) ) ] ) ] ; } | Return code for provider |
32,631 | public function saveItem ( MShop_Common_Item_Interface $ item , $ fetch = true ) { $ iface = 'MShop_Media_Item_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MShop_Media_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( ! $ item -> isModified ( ) ) { return ; } $ context = $ this -> _getContext ( ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; $ date = date ( 'Y-m-d H:i:s' ) ; if ( $ id === null ) { $ path = 'mshop/media/manager/default/item/insert' ; } else { $ path = 'mshop/media/manager/default/item/update' ; } $ stmt = $ this -> _getCachedStatement ( $ conn , $ path ) ; $ stmt -> bind ( 1 , $ context -> getLocale ( ) -> getSiteId ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ item -> getLanguageId ( ) ) ; $ stmt -> bind ( 3 , $ item -> getTypeId ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 4 , $ item -> getLabel ( ) ) ; $ stmt -> bind ( 5 , $ item -> getMimeType ( ) ) ; $ stmt -> bind ( 6 , $ item -> getUrl ( ) ) ; $ stmt -> bind ( 7 , $ item -> getStatus ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 8 , $ item -> getDomain ( ) ) ; $ stmt -> bind ( 9 , $ item -> getPreview ( ) ) ; $ stmt -> bind ( 10 , $ date ) ; $ stmt -> bind ( 11 , $ context -> getEditor ( ) ) ; if ( $ id !== null ) { $ stmt -> bind ( 12 , $ id , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ item -> setId ( $ id ) ; } else { $ stmt -> bind ( 12 , $ date ) ; } $ stmt -> execute ( ) -> finish ( ) ; if ( $ id === null && $ fetch === true ) { $ path = 'mshop/media/manager/default/item/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 item to the storage or updates an existing one . |
32,632 | public function urlTo ( $ cql , $ start = 1 , $ count = 10 , $ extraParams = array ( ) ) { $ qs = array ( 'operation' => 'searchRetrieve' , 'version' => $ this -> version , 'recordSchema' => $ this -> schema , 'maximumRecords' => $ count , 'query' => $ cql ) ; if ( $ start != 1 ) { $ qs [ 'startRecord' ] = $ start ; } foreach ( $ extraParams as $ key => $ value ) { $ qs [ $ key ] = $ value ; } return $ this -> url . '?' . http_build_query ( $ qs ) ; } | Construct the URL for a CQL query |
32,633 | public function search ( $ cql , $ start = 1 , $ count = 10 , $ extraParams = array ( ) ) { $ url = $ this -> urlTo ( $ cql , $ start , $ count , $ extraParams ) ; $ body = $ this -> request ( 'GET' , $ url ) ; return new SearchRetrieveResponse ( $ body , $ this ) ; } | Perform a searchRetrieve request |
32,634 | public function first ( $ cql , $ extraParams = array ( ) ) { $ recs = new Records ( $ cql , $ this , 1 , $ extraParams ) ; return $ recs -> numberOfRecords ( ) ? $ recs -> current ( ) : null ; } | Perform a searchRetrieve request and return first record |
32,635 | public function explain ( ) { $ url = $ this -> url . '?' . http_build_query ( array ( 'operation' => 'explain' , 'version' => $ this -> version , ) ) ; $ body = $ this -> request ( 'GET' , $ url ) ; return new ExplainResponse ( $ body , $ this ) ; } | Perform an explain request |
32,636 | public function getValue ( ) : ? string { foreach ( $ this -> getOptions ( ) as $ option ) { if ( $ option -> isSelected ( ) ) { return $ option -> getValue ( ) ; } } return null ; } | Returns the selected value or null if none is selected . |
32,637 | public function deleteItem ( $ id ) { $ actual = $ this -> _getManager ( ) -> getItem ( $ id ) ; $ siteId = $ this -> _getContext ( ) -> getLocale ( ) -> getSiteId ( ) ; if ( $ actual -> getSiteId ( ) != $ siteId ) { throw new MShop_Exception ( sprintf ( 'Item can not be deleted. Site ID of item differs from present site ID.' ) ) ; } parent :: deleteItem ( $ id ) ; } | Deletes an item object . |
32,638 | public function getFullExperimentsAction ( ) { $ experimentsArray = [ ] ; $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; $ experiments = $ manager -> getAllExperiments ( ) ; $ activeExperiments = $ manager -> getActiveExperiments ( ) ; foreach ( $ experiments as $ experiment ) { $ experiment = $ experiment -> getSerializableData ( ) ; $ experiment [ 'active' ] = in_array ( $ experiment [ 'name' ] , $ activeExperiments ) ; $ experimentsArray [ ] = $ experiment ; } return new JsonResponse ( [ 'count' => count ( $ experiments ) , 'documents' => $ experimentsArray ] ) ; } | Returns a json list of experiments |
32,639 | public function afterFind ( ) { parent :: afterFind ( ) ; $ boolArguments = [ 'is_repeating_task' , 'notify_initiator' , 'email_notification' , 'delete_after_run' , ] ; foreach ( $ boolArguments as $ argument ) { $ this -> $ argument = boolval ( $ this -> $ argument ) ; } } | Performs some afterFind stuff like casting variables to correct type |
32,640 | public function planNextRun ( ) { if ( $ this -> is_repeating_task && ! empty ( $ this -> cron_expression ) ) { $ this -> status = DeferredQueue :: STATUS_SCHEDULED ; $ cron = CronExpression :: factory ( $ this -> cron_expression ) ; $ this -> next_start = date ( 'Y-m-d H:i:s' , $ cron -> getNextRunDate ( ) -> getTimestamp ( ) ) ; return true ; } else { return false ; } } | Sets next_start field to the next future timstamp when we should run again repeating task . If task is non - repeating and cron_expression is empty - false returned |
32,641 | public function complete ( ) { $ this -> last_run_date = date ( 'Y-m-d H:i:s' , time ( ) ) ; if ( 0 != $ this -> next_task_id ) { $ this -> status = DeferredQueue :: STATUS_SUCCESS_AND_NEXT ; } else { $ this -> status = DeferredQueue :: STATUS_COMPLETE ; } if ( $ this -> planNextRun ( ) === true ) { return $ this -> save ( ) ; } else { if ( $ this -> delete_after_run ) { return $ this -> delete ( ) !== false ; } else { return $ this -> save ( ) ; } } } | Schedules next launch or deletes queue item if it is not repeatable |
32,642 | public function saveItems ( stdClass $ params ) { $ this -> _checkParams ( $ params , array ( 'site' , 'items' ) ) ; $ this -> _setLocale ( $ params -> site ) ; $ items = ( ! is_array ( $ params -> items ) ? array ( $ params -> items ) : $ params -> items ) ; foreach ( $ items as $ entry ) { $ item = $ this -> _createItem ( ( array ) $ entry ) ; $ this -> _manager -> saveItem ( $ item ) ; } return array ( 'items' => $ params -> items , 'success' => true , ) ; } | Creates a new text item or updates an existing one or a list thereof . |
32,643 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'cache.id' : $ item -> setId ( $ value ) ; break ; case 'cache.value' : $ item -> setValue ( $ value ) ; break ; case 'cache.tags' : $ item -> setTags ( ( array ) $ value ) ; break ; case 'cache.expire' : if ( $ value != '' ) { $ value = str_replace ( 'T' , ' ' , $ value ) ; $ entry -> { 'cache.expire' } = $ value ; $ item -> setTimeExpire ( $ value ) ; } break ; } } return $ item ; } | Creates a new cache item and sets the properties from the given array . |
32,644 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'order.base.address.type' : $ item -> setType ( $ value ) ; break ; case 'order.base.address.baseid' : $ item -> setBaseId ( $ value ) ; break ; case 'order.base.address.addressid' : $ item -> setAddressId ( $ value ) ; break ; case 'order.base.address.vatid' : $ item -> setVatID ( $ value ) ; break ; case 'order.base.address.company' : $ item -> setCompany ( $ value ) ; break ; case 'order.base.address.salutation' : $ item -> setSalutation ( $ value ) ; break ; case 'order.base.address.title' : $ item -> setTitle ( $ value ) ; break ; case 'order.base.address.firstname' : $ item -> setFirstname ( $ value ) ; break ; case 'order.base.address.lastname' : $ item -> setLastname ( $ value ) ; break ; case 'order.base.address.address1' : $ item -> setAddress1 ( $ value ) ; break ; case 'order.base.address.address2' : $ item -> setAddress2 ( $ value ) ; break ; case 'order.base.address.address3' : $ item -> setAddress3 ( $ value ) ; break ; case 'order.base.address.postal' : $ item -> setPostal ( $ value ) ; break ; case 'order.base.address.city' : $ item -> setCity ( $ value ) ; break ; case 'order.base.address.state' : $ item -> setState ( $ value ) ; break ; case 'order.base.address.countryid' : $ item -> setCountryId ( $ value ) ; break ; case 'order.base.address.languageid' : $ item -> setLanguageId ( $ value ) ; break ; case 'order.base.address.telephone' : $ item -> setTelephone ( $ value ) ; break ; case 'order.base.address.telefax' : $ item -> setTelefax ( $ value ) ; break ; case 'order.base.address.website' : $ item -> setWebsite ( $ value ) ; break ; case 'order.base.address.email' : $ item -> setEmail ( $ value ) ; break ; } } return $ item ; } | Creates a new order . base . address item and sets the properties from the given array . |
32,645 | public function setCouponId ( $ id ) { if ( $ id == $ this -> getCouponId ( ) ) { return ; } $ this -> _values [ 'couponid' ] = ( int ) $ id ; $ this -> setModified ( ) ; } | Sets the new unique ID of the coupon item the code belongs to . |
32,646 | public function setCount ( $ count ) { if ( $ count == $ this -> getCount ( ) ) { return ; } $ this -> _values [ 'count' ] = ( string ) $ count ; $ this -> setModified ( ) ; } | Sets the new number of tries the code is valid . |
32,647 | public function setDateEnd ( $ date ) { if ( $ date == $ this -> getDateEnd ( ) ) { return ; } $ this -> _checkDateFormat ( $ date ) ; $ this -> _values [ 'end' ] = ( $ date !== null ? ( string ) $ date : null ) ; $ this -> setModified ( ) ; } | Sets a new ending point of time in which the code is available . |
32,648 | public function query ( MShop_Order_Item_Interface $ order ) { $ orderManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order' ) ; if ( ( $ tid = $ this -> _getOrderServiceItem ( $ order -> getBaseId ( ) ) -> getAttribute ( 'TRANSACTIONID' ) ) === null ) { $ msg = sprintf ( 'PayPal Express: Payment transaction ID for order ID "%1$s" not available' , $ order -> getId ( ) ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ values = $ this -> _getAuthParameter ( ) ; $ values [ 'METHOD' ] = 'GetTransactionDetails' ; $ values [ 'TRANSACTIONID' ] = $ tid ; $ urlQuery = http_build_query ( $ values , '' , '&' ) ; $ response = $ this -> _getCommunication ( ) -> transmit ( $ this -> _apiendpoint , 'POST' , $ urlQuery ) ; $ rvals = $ this -> _checkResponse ( $ order -> getId ( ) , $ response , __METHOD__ ) ; $ this -> _setPaymentStatus ( $ order , $ rvals ) ; $ orderManager -> saveItem ( $ order ) ; } | Queries for status updates for the given order if supported . |
32,649 | public function capture ( MShop_Order_Item_Interface $ order ) { $ orderManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order' ) ; $ orderBaseManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base' ) ; $ baseid = $ order -> getBaseId ( ) ; $ baseItem = $ orderBaseManager -> getItem ( $ baseid ) ; $ serviceItem = $ this -> _getOrderServiceItem ( $ baseid ) ; if ( ( $ tid = $ serviceItem -> getAttribute ( 'TRANSACTIONID' ) ) === null ) { $ msg = sprintf ( 'PayPal Express: Payment transaction ID for order ID "%1$s" not available' , $ order -> getId ( ) ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ values = $ this -> _getAuthParameter ( ) ; $ values [ 'METHOD' ] = 'DoCapture' ; $ values [ 'COMPLETETYPE' ] = 'Complete' ; $ values [ 'AUTHORIZATIONID' ] = $ tid ; $ values [ 'INVNUM' ] = $ order -> getId ( ) ; $ values [ 'CURRENCYCODE' ] = $ baseItem -> getPrice ( ) -> getCurrencyId ( ) ; $ values [ 'AMT' ] = $ baseItem -> getPrice ( ) -> getValue ( ) + $ baseItem -> getPrice ( ) -> getCosts ( ) ; $ urlQuery = http_build_query ( $ values , '' , '&' ) ; $ response = $ this -> _getCommunication ( ) -> transmit ( $ this -> _apiendpoint , 'POST' , $ urlQuery ) ; $ rvals = $ this -> _checkResponse ( $ order -> getId ( ) , $ response , __METHOD__ ) ; $ this -> _setPaymentStatus ( $ order , $ rvals ) ; $ attributes = array ( ) ; if ( isset ( $ rvals [ 'PARENTTRANSACTIONID' ] ) ) { $ attributes [ 'PARENTTRANSACTIONID' ] = $ rvals [ 'PARENTTRANSACTIONID' ] ; } $ attributes [ 'TRANSACTIONID' ] = $ rvals [ 'TRANSACTIONID' ] ; $ this -> _saveAttributes ( $ attributes , $ serviceItem ) ; $ orderManager -> saveItem ( $ order ) ; } | Captures the money later on request for the given order if supported . |
32,650 | public function refund ( MShop_Order_Item_Interface $ order ) { $ orderManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order' ) ; $ serviceItem = $ this -> _getOrderServiceItem ( $ order -> getBaseId ( ) ) ; if ( ( $ tid = $ serviceItem -> getAttribute ( 'TRANSACTIONID' ) ) === null ) { $ msg = sprintf ( 'PayPal Express: Payment transaction ID for order ID "%1$s" not available' , $ order -> getId ( ) ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ values = $ this -> _getAuthParameter ( ) ; $ values [ 'METHOD' ] = 'RefundTransaction' ; $ values [ 'REFUNDSOURCE' ] = 'instant' ; $ values [ 'REFUNDTYPE' ] = 'Full' ; $ values [ 'TRANSACTIONID' ] = $ tid ; $ values [ 'INVOICEID' ] = $ order -> getId ( ) ; $ urlQuery = http_build_query ( $ values , '' , '&' ) ; $ response = $ this -> _getCommunication ( ) -> transmit ( $ this -> _apiendpoint , 'POST' , $ urlQuery ) ; $ rvals = $ this -> _checkResponse ( $ order -> getId ( ) , $ response , __METHOD__ ) ; $ attributes = array ( 'REFUNDTRANSACTIONID' => $ rvals [ 'REFUNDTRANSACTIONID' ] ) ; $ this -> _saveAttributes ( $ attributes , $ serviceItem ) ; $ order -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_REFUND ) ; $ orderManager -> saveItem ( $ order ) ; } | Refunds the money for the given order if supported . |
32,651 | public function cancel ( MShop_Order_Item_Interface $ order ) { $ orderManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order' ) ; if ( ( $ tid = $ this -> _getOrderServiceItem ( $ order -> getBaseId ( ) ) -> getAttribute ( 'TRANSACTIONID' ) ) === null ) { $ msg = sprintf ( 'PayPal Express: Payment transaction ID for order ID "%1$s" not available' , $ order -> getId ( ) ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ values = $ this -> _getAuthParameter ( ) ; $ values [ 'METHOD' ] = 'DoVoid' ; $ values [ 'AUTHORIZATIONID' ] = $ tid ; $ urlQuery = http_build_query ( $ values , '' , '&' ) ; $ response = $ this -> _getCommunication ( ) -> transmit ( $ this -> _apiendpoint , 'POST' , $ urlQuery ) ; $ this -> _checkResponse ( $ order -> getId ( ) , $ response , __METHOD__ ) ; $ order -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_CANCELED ) ; $ orderManager -> saveItem ( $ order ) ; } | Cancels the authorization for the given order if supported . |
32,652 | public function isImplemented ( $ what ) { switch ( $ what ) { case MShop_Service_Provider_Payment_Abstract :: FEAT_CAPTURE : case MShop_Service_Provider_Payment_Abstract :: FEAT_QUERY : case MShop_Service_Provider_Payment_Abstract :: FEAT_CANCEL : case MShop_Service_Provider_Payment_Abstract :: FEAT_REFUND : return true ; } return false ; } | Checks what features the payment provider implements . |
32,653 | protected function _doExpressCheckoutPayment ( $ additional ) { $ orderManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order' ) ; $ orderBaseManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base' ) ; $ order = $ orderManager -> getItem ( $ additional [ 'orderid' ] ) ; $ baseid = $ order -> getBaseId ( ) ; $ baseItem = $ orderBaseManager -> getItem ( $ baseid ) ; $ serviceItem = $ this -> _getOrderServiceItem ( $ baseid ) ; $ values = $ this -> _getAuthParameter ( ) ; $ values [ 'METHOD' ] = 'DoExpressCheckoutPayment' ; $ values [ 'TOKEN' ] = $ additional [ 'token' ] ; $ values [ 'PAYERID' ] = $ additional [ 'PayerID' ] ; $ values [ 'PAYMENTACTION' ] = $ this -> _getConfigValue ( array ( 'paypalexpress.PaymentAction' ) , 'Sale' ) ; $ values [ 'CURRENCYCODE' ] = $ baseItem -> getPrice ( ) -> getCurrencyId ( ) ; $ values [ 'NOTIFYURL' ] = $ this -> _getConfigValue ( array ( 'payment.url-update' , 'payment.url-success' ) ) ; $ values [ 'AMT' ] = ( $ baseItem -> getPrice ( ) -> getValue ( ) + $ baseItem -> getPrice ( ) -> getCosts ( ) ) ; $ urlQuery = http_build_query ( $ values , '' , '&' ) ; $ response = $ this -> _getCommunication ( ) -> transmit ( $ this -> _apiendpoint , 'POST' , $ urlQuery ) ; $ rvals = $ this -> _checkResponse ( $ order -> getId ( ) , $ response , __METHOD__ ) ; $ attributes = array ( 'PAYERID' => $ additional [ 'PayerID' ] ) ; if ( isset ( $ rvals [ 'TRANSACTIONID' ] ) ) { $ attributes [ 'TRANSACTIONID' ] = $ rvals [ 'TRANSACTIONID' ] ; $ this -> _saveAttributes ( array ( $ rvals [ 'TRANSACTIONID' ] => $ rvals [ 'PAYMENTSTATUS' ] ) , $ serviceItem , 'payment/paypal/txn' ) ; } $ this -> _saveAttributes ( $ attributes , $ serviceItem ) ; $ this -> _setPaymentStatus ( $ order , $ rvals ) ; $ orderManager -> saveItem ( $ order ) ; return $ order ; } | Begins paypalexpress transaction and saves transaction id . |
32,654 | protected function _checkResponse ( $ orderid , $ response , $ method ) { $ rvals = array ( ) ; parse_str ( $ response , $ rvals ) ; if ( $ rvals [ 'ACK' ] !== 'Success' ) { $ msg = 'PayPal Express: method = ' . $ method . ', order ID = ' . $ orderid . ', response = ' . print_r ( $ rvals , true ) ; $ this -> _getContext ( ) -> getLogger ( ) -> log ( $ msg , MW_Logger_Abstract :: INFO ) ; if ( $ rvals [ 'ACK' ] !== 'SuccessWithWarning' ) { $ short = ( isset ( $ rvals [ 'L_SHORTMESSAGE0' ] ) ? $ rvals [ 'L_SHORTMESSAGE0' ] : '<none>' ) ; $ msg = sprintf ( 'PayPal Express: Request for order ID "%1$s" failed with "%2$s"' , $ orderid , $ short ) ; throw new MShop_Service_Exception ( $ msg ) ; } } return $ rvals ; } | Checks the response from the payment server . |
32,655 | protected function _checkIPN ( $ baseManager , $ basket , $ additional ) { $ attrManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base/service/attribute' ) ; if ( $ this -> _getConfigValue ( array ( 'paypalexpress.AccountEmail' ) ) !== $ additional [ 'receiver_email' ] ) { $ msg = sprintf ( 'PayPal Express: Wrong receiver email "%1$s"' , $ additional [ 'receiver_email' ] ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ price = $ basket -> getPrice ( ) ; $ amount = $ price -> getValue ( ) + $ price -> getCosts ( ) ; if ( $ amount != $ additional [ 'payment_amount' ] ) { $ msg = sprintf ( 'PayPal Express: Wrong payment amount "%1$s" for order ID "%2$s"' , $ additional [ 'payment_amount' ] , $ additional [ 'invoice' ] ) ; throw new MShop_Service_Exception ( $ msg ) ; } $ search = $ attrManager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , 'order.base.service.attribute.code' , $ additional [ 'txn_id' ] ) , $ search -> compare ( '==' , 'order.base.service.attribute.value' , $ additional [ 'payment_status' ] ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ results = $ attrManager -> searchItems ( $ search ) ; if ( ( $ attr = reset ( $ results ) ) !== false ) { $ msg = sprintf ( 'PayPal Express: Duplicate transaction with ID "%1$s" and status "%2$s" ' , $ additional [ 'txn_id' ] , $ additional [ 'txn_status' ] ) ; throw new MShop_Service_Exception ( $ msg ) ; } } | Checks if IPN message from paypal is valid . |
32,656 | protected function _setPaymentStatus ( MShop_Order_Item_Interface $ invoice , array $ response ) { if ( ! isset ( $ response [ 'PAYMENTSTATUS' ] ) ) { return ; } switch ( $ response [ 'PAYMENTSTATUS' ] ) { case 'Pending' : if ( isset ( $ response [ 'PENDINGREASON' ] ) ) { if ( $ response [ 'PENDINGREASON' ] === 'authorization' ) { $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_AUTHORIZED ) ; break ; } $ str = 'PayPal Express: order ID = ' . $ invoice -> getId ( ) . ', PENDINGREASON = ' . $ response [ 'PENDINGREASON' ] ; $ this -> _getContext ( ) -> getLogger ( ) -> log ( $ str , MW_Logger_Abstract :: INFO ) ; } $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_PENDING ) ; break ; case 'In-Progress' : $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_PENDING ) ; break ; case 'Completed' : case 'Processed' : $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_RECEIVED ) ; break ; case 'Failed' : case 'Denied' : case 'Expired' : $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_REFUSED ) ; break ; case 'Refunded' : case 'Partially-Refunded' : case 'Reversed' : $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_REFUND ) ; break ; case 'Canceled-Reversal' : case 'Voided' : $ invoice -> setPaymentStatus ( MShop_Order_Item_Abstract :: PAY_CANCELED ) ; break ; default : $ str = 'PayPal Express: order ID = ' . $ invoice -> getId ( ) . ', response = ' . print_r ( $ response , true ) ; $ this -> _getContext ( ) -> getLogger ( ) -> log ( $ str , MW_Logger_Abstract :: INFO ) ; } } | Maps the PayPal status to the appropriate payment status and sets it in the order object . |
32,657 | protected function _saveAttributes ( array $ attributes , MShop_Order_Item_Base_Service_Interface $ serviceItem , $ type = 'payment/paypal' ) { $ attributeManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base/service/attribute' ) ; $ map = array ( ) ; foreach ( $ serviceItem -> getAttributes ( ) as $ attributeItem ) { $ map [ $ attributeItem -> getCode ( ) ] = $ attributeItem ; } foreach ( $ attributes as $ code => $ value ) { if ( array_key_exists ( $ code , $ map ) !== true ) { $ attributeItem = $ attributeManager -> createItem ( ) ; $ attributeItem -> setServiceId ( $ serviceItem -> getId ( ) ) ; $ attributeItem -> setCode ( $ code ) ; $ attributeItem -> setType ( $ type ) ; } else { $ attributeItem = $ map [ $ code ] ; } $ attributeItem -> setValue ( $ value ) ; $ attributeManager -> saveItem ( $ attributeItem ) ; } } | Saves a list of attributes for the order service . |
32,658 | protected function _getOrderServiceItem ( $ baseid ) { $ orderServiceManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base/service' ) ; $ search = $ orderServiceManager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , 'order.base.service.baseid' , $ baseid ) , $ search -> compare ( '==' , 'order.base.service.type' , 'payment' ) ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ results = $ orderServiceManager -> searchItems ( $ search ) ; if ( ( $ serviceItem = reset ( $ results ) ) === false ) { $ msg = sprintf ( 'Service payment provider for order base ID "%1$s" not found' , $ baseid ) ; throw new MShop_Service_Exception ( $ msg ) ; } return $ serviceItem ; } | Returns order service item for specified base ID . |
32,659 | public function setParentId ( $ parentid ) { if ( $ parentid == $ this -> getParentId ( ) ) { return ; } $ this -> _values [ 'parentid' ] = ( int ) $ parentid ; $ this -> setModified ( ) ; } | Sets the parent ID of the common list item like the unique ID of a product or a tree node . |
32,660 | public function setRefId ( $ refid ) { if ( $ refid == $ this -> getRefId ( ) ) { return ; } $ this -> _values [ 'refid' ] = ( string ) $ refid ; $ this -> setModified ( ) ; } | Sets the new reference id of the common list item like the unique id of a text item or a media item . |
32,661 | public function setPosition ( $ pos ) { if ( $ pos == $ this -> getPosition ( ) ) { return ; } $ this -> _values [ 'pos' ] = ( int ) $ pos ; $ this -> setModified ( ) ; } | Sets the new position of the list item . |
32,662 | public function updateValueAction ( Request $ request ) { $ name = $ request -> get ( 'name' ) ; $ value = $ request -> get ( 'value' ) ; $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; $ manager -> update ( $ name , [ 'value' => $ value ] ) ; return new JsonResponse ( [ 'error' => false ] ) ; } | Setting update action . |
32,663 | public function deleteAction ( Request $ request ) { try { $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; $ manager -> delete ( $ request -> get ( 'name' ) ) ; return new JsonResponse ( [ 'error' => false ] ) ; } catch ( \ Exception $ e ) { return new JsonResponse ( [ 'error' => true , 'message' => 'Error occurred please try to delete setting again.' ] ) ; } } | Setting delete action |
32,664 | public function submitAction ( Request $ request ) { try { $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; $ data = $ request -> get ( 'setting' ) ; if ( ! empty ( $ data [ 'value' ] ) && ! is_string ( $ data [ 'value' ] ) ) { $ data [ 'value' ] = json_encode ( $ data [ 'value' ] ) ; } if ( $ request -> get ( 'force' ) ) { $ name = $ request -> get ( 'name' ) ; $ manager -> update ( $ name , $ data ) ; } else { $ manager -> create ( $ data ) ; } return new JsonResponse ( [ 'error' => false ] ) ; } catch ( \ Exception $ e ) { return new JsonResponse ( [ 'error' => true , 'message' => 'Error occurred! Something is wrong with provided data. ' . 'Please try to submit form again.' ] ) ; } } | Submit action to create or edit setting if not exists . |
32,665 | protected function _checkFlags ( $ value ) { $ value = ( int ) $ value ; if ( $ value < MShop_Order_Item_Base_Product_Abstract :: FLAG_NONE || $ value > MShop_Order_Item_Base_Product_Abstract :: FLAG_IMMUTABLE ) { throw new MShop_Order_Exception ( sprintf ( 'Flags "%1$s" not within allowed range' , $ value ) ) ; } } | Checks if the given flag constant is valid . |
32,666 | public static function has ( $ data , string $ path ) : bool { Assert :: isArrayAccessible ( $ data ) ; Assert :: stringNotEmpty ( $ path ) ; $ path = explode ( '/' , $ path ) ; while ( ( $ part = array_shift ( $ path ) ) !== null ) { if ( ! ( $ data instanceof ArrayAccess ) && ! is_array ( $ data ) ) { return false ; } if ( ! ( isset ( $ data [ $ part ] ) || array_key_exists ( $ part , $ data ) ) ) { return false ; } $ data = $ data [ $ part ] ; } return true ; } | Returns whether a key exists from an array or ArrayAccess object using path syntax to check nested data . |
32,667 | public static function get ( $ data , string $ path , $ default = null ) { Assert :: isArrayAccessible ( $ data ) ; Assert :: stringNotEmpty ( $ path ) ; $ path = explode ( '/' , $ path ) ; while ( ( $ part = array_shift ( $ path ) ) !== null ) { if ( ( ! is_array ( $ data ) && ! ( $ data instanceof ArrayAccess ) ) || ! isset ( $ data [ $ part ] ) ) { return $ default ; } $ data = $ data [ $ part ] ; } return $ data ; } | Gets a value from an array or ArrayAccess object using path syntax to retrieve nested data . |
32,668 | private static function doMapRecursive ( $ iterable , callable $ callable ) : array { $ mapped = [ ] ; foreach ( $ iterable as $ key => $ value ) { $ mapped [ $ key ] = is_iterable ( $ value ) ? static :: doMapRecursive ( $ value , $ callable ) : $ callable ( $ value , $ key ) ; } return $ mapped ; } | Internal method do actual recursion after args have been validated by main method . |
32,669 | public static function get ( $ filename , array $ options = array ( ) ) { if ( class_exists ( 'finfo' ) ) { try { $ finfo = new finfo ( FILEINFO_MIME_TYPE ) ; $ mimetype = $ finfo -> file ( $ filename ) ; } catch ( Exception $ e ) { throw new MW_Media_Exception ( $ e -> getMessage ( ) ) ; } } else if ( function_exists ( 'mime_content_type' ) ) { $ mimetype = mime_content_type ( $ filename ) ; } else { $ msg = sprintf ( 'No method for retrieving the mime type available: %1$s' , 'finfo, mime_content_type' ) ; throw new MW_Media_Exception ( $ msg ) ; } $ mimeparts = explode ( '/' , $ mimetype ) ; switch ( $ mimeparts [ 0 ] ) { case 'image' : return new MW_Media_Image_Default ( $ filename , $ mimetype , $ options ) ; } return new MW_Media_Application_Default ( $ filename , $ mimetype , $ options ) ; } | Creates a new media object . |
32,670 | public function sign ( $ payload , $ key ) { if ( ! $ key instanceof Key ) { $ key = new Key ( $ key ) ; } $ privateKey = $ this -> keyParser -> parsePrivateKey ( $ key -> getContent ( ) ) ; $ hash = $ this -> hash ( $ payload ) ; $ random = RandomGeneratorFactory :: getRandomGenerator ( ) ; $ randomK = $ random -> generate ( $ this -> config -> getGenerator ( ) -> getOrder ( ) ) ; $ signer = new EccSigner ( $ this -> adapter ) ; $ signature = $ signer -> sign ( $ privateKey , $ hash , $ randomK ) ; return new LcobucciJWTSignature ( $ this -> serializer -> serialize ( $ signature , $ this -> config -> getSignatureLength ( ) ) ) ; } | Returns a signature for given data |
32,671 | private function hash ( $ payload ) { if ( class_exists ( SignHasher :: class ) ) { $ hasher = new SignHasher ( $ this -> config -> getHashingAlgorithm ( ) ) ; return $ hasher -> makeHash ( $ payload , $ this -> config -> getGenerator ( ) ) ; } $ signer = new EccSigner ( $ this -> adapter ) ; return $ signer -> hashData ( $ this -> config -> getGenerator ( ) , $ this -> config -> getHashingAlgorithm ( ) , $ payload ) ; } | Hash the payload |
32,672 | public function saveItems ( stdClass $ params ) { $ this -> _checkParams ( $ params , array ( 'site' , 'items' ) ) ; $ this -> _setLocale ( $ params -> site ) ; $ ids = array ( ) ; $ items = ( ! is_array ( $ params -> items ) ? array ( $ params -> items ) : $ params -> items ) ; foreach ( $ items as $ entry ) { $ item = $ this -> _createItem ( ( array ) $ entry ) ; $ this -> _manager -> saveItem ( $ item ) ; $ ids [ ] = $ item -> getId ( ) ; } $ this -> _clearCache ( $ ids ) ; $ search = $ this -> _manager -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'price.id' , $ ids ) ) ; $ search -> setSlice ( 0 , count ( $ ids ) ) ; $ items = $ this -> _toArray ( $ this -> _manager -> searchItems ( $ search ) ) ; return array ( 'items' => ( ! is_array ( $ params -> items ) ? reset ( $ items ) : $ items ) , 'success' => true , ) ; } | Creates a new price item or updates an existing one or a list thereof . |
32,673 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'price.id' : $ item -> setId ( $ value ) ; break ; case 'price.label' : $ item -> setLabel ( $ value ) ; break ; case 'price.domain' : $ item -> setDomain ( $ value ) ; break ; case 'price.typeid' : $ item -> setTypeId ( $ value ) ; break ; case 'price.status' : $ item -> setStatus ( $ value ) ; break ; case 'price.value' : $ item -> setValue ( $ value ) ; break ; case 'price.costs' : $ item -> setCosts ( $ value ) ; break ; case 'price.rebate' : $ item -> setRebate ( $ value ) ; break ; case 'price.taxrate' : $ item -> setTaxRate ( $ value ) ; break ; case 'price.quantity' : $ item -> setQuantity ( $ value ) ; break ; case 'price.currencyid' : $ item -> setCurrencyId ( $ value ) ; break ; } } return $ item ; } | Creates a new price item and sets the properties from the given array . |
32,674 | public static function parse_object_id ( $ object ) { if ( is_numeric ( $ object ) && $ object > 0 ) { return ( int ) $ object ; } elseif ( ! empty ( $ object -> ID ) ) { return ( int ) $ object -> ID ; } elseif ( ! empty ( $ object -> term_id ) ) { return ( int ) $ object -> term_id ; } elseif ( $ object instanceof WP_Object ) { return $ object -> get_id ( ) ; } } | Parse the object_id . |
32,675 | protected function setup_instance ( ) { switch ( $ this -> wp_type ) { case 'post' : $ wp_post = get_post ( $ this -> get_id ( ) ) ; if ( ! is_null ( $ wp_post ) && get_post_type ( $ wp_post -> ID ) === $ this -> object_type ) { $ this -> set_instance ( $ wp_post ) ; } break ; case 'term' : $ wp_term = get_term ( $ this -> get_id ( ) , $ this -> object_type ) ; if ( ! is_null ( $ wp_term ) && ! is_wp_error ( $ wp_term ) ) { $ this -> set_instance ( $ wp_term ) ; } break ; } } | Setup WP Core Object based on ID and object - type . |
32,676 | public function save ( ) { do_action ( $ this -> prefix ( 'saving' ) , $ this ) ; if ( $ this -> recently_created ) { $ this -> recently_created = false ; } $ this -> before_save ( ) ; if ( $ this -> exists ( ) ) { $ saved = $ this -> is_dirty ( ) ? $ this -> update_object ( ) : true ; } else { $ saved = $ this -> insert_object ( ) ; } if ( $ saved ) { $ this -> finish_save ( ) ; do_action ( $ this -> prefix ( 'saved' ) , $ this ) ; $ this -> sync_original ( ) ; } return $ saved ; } | Save the object to the database . |
32,677 | protected function finish_save ( ) { $ this -> clean_cache ( ) ; $ this -> perform_update_metadata ( $ this -> recently_created ? $ this -> get_dirty ( ) : $ this -> get_changes ( ) ) ; $ this -> resetup ( ) ; } | Do something when finish save . |
32,678 | protected function resetup ( ) { $ this -> setup_instance ( ) ; $ this -> metadata = $ this -> fetch_metadata ( ) ; $ this -> setup_metadata ( ) ; $ this -> setup ( ) ; } | Resetup the object . |
32,679 | protected function update_object ( ) { if ( false === apply_filters ( $ this -> prefix ( 'prev_create' ) , true ) ) { return false ; } do_action ( $ this -> prefix ( 'updating' ) , $ this ) ; $ dirty = $ this -> get_dirty ( ) ; if ( count ( $ dirty ) > 0 ) { $ updated = $ this -> perform_update ( $ dirty ) ; if ( false === $ updated ) { return false ; } do_action ( $ this -> prefix ( 'updated' ) , $ this ) ; $ this -> sync_changes ( ) ; } return true ; } | Run update object . |
32,680 | protected function insert_object ( ) { if ( false === apply_filters ( $ this -> prefix ( 'prev_create' ) , true ) ) { return false ; } do_action ( $ this -> prefix ( 'creating' ) , $ this ) ; $ insert_id = $ this -> perform_insert ( ) ; if ( is_int ( $ insert_id ) && $ insert_id > 0 ) { $ this -> id = $ insert_id ; $ this -> exists = true ; $ this -> recently_created = true ; do_action ( $ this -> prefix ( 'created' ) , $ this ) ; return true ; } return false ; } | Run insert object into database . |
32,681 | public function delete ( $ force = false ) { if ( ! $ this -> exists ( ) ) { return ; } if ( false === apply_filters ( $ this -> prefix ( 'prev_delete' ) , true ) ) { return ; } do_action ( $ this -> prefix ( 'deleting' ) , $ this ) ; $ deleted = $ this -> perform_delete ( $ force ) ; if ( $ deleted ) { $ this -> clean_cache ( ) ; $ this -> exists = false ; do_action ( $ this -> prefix ( 'deleted' ) , $ this -> get_id ( ) ) ; } return $ deleted ; } | Trash or delete a wp - object . |
32,682 | protected function perform_delete ( $ force ) { switch ( $ this -> wp_type ) { case 'term' : $ delete = wp_delete_term ( $ this -> get_id ( ) , $ this -> object_type ) ; return ( ! is_wp_error ( $ delete ) && true === $ delete ) ; case 'post' : if ( ! $ force && 'trash' !== get_post_status ( $ this -> get_id ( ) ) && EMPTY_TRASH_DAYS ) { $ delete = wp_trash_post ( $ this -> get_id ( ) ) ; } else { $ delete = wp_delete_post ( $ this -> get_id ( ) , true ) ; } return ( ! is_null ( $ delete ) && ! is_wp_error ( $ delete ) && false !== $ delete ) ; } return false ; } | Perform delete object . |
32,683 | public function process ( MShop_Order_Item_Interface $ order ) { $ logger = $ this -> _getContext ( ) -> getLogger ( ) ; $ xml = $ this -> buildXML ( $ order ) ; $ logger -> log ( __METHOD__ . ": XML request =\n" . $ xml , MW_Logger_Abstract :: INFO ) ; $ response = $ this -> _sendRequest ( $ xml ) ; $ logger -> log ( __METHOD__ . ": XML response =\n" . trim ( $ response ) , MW_Logger_Abstract :: INFO ) ; $ this -> _checkResponse ( $ response , $ order -> getId ( ) ) ; $ order -> setDeliveryStatus ( MShop_Order_Item_Abstract :: STAT_PROGRESS ) ; } | Sends the order details to the ERP system for further processing . |
32,684 | public function getConfigBE ( ) { $ list = array ( ) ; foreach ( $ this -> _beConfig 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 administration interface . |
32,685 | protected function _checkResponse ( $ response , $ invoiceid ) { $ responseXSD = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-response_v1.xsd' ; $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ dom -> preserveWhiteSpace = false ; if ( $ dom -> loadXML ( $ response ) !== true ) { throw new MShop_Service_Exception ( sprintf ( 'Loading of XML response "%1$s" from delivery provider failed' , $ response ) , parent :: ERR_XML ) ; } if ( $ dom -> schemaValidate ( $ responseXSD ) !== true ) { throw new MShop_Service_Exception ( sprintf ( 'Validation of XML response from delivery provider against schema "%1$s" failed' , $ responseXSD ) , parent :: ERR_SCHEMA ) ; } $ xpath = new DOMXPath ( $ dom ) ; $ globalStatus = $ xpath -> query ( '/response/error' ) -> item ( 0 ) -> nodeValue ; if ( $ globalStatus != 0 ) { throw new MShop_Service_Exception ( sprintf ( 'Order data sent to delivery provider was rejected with code "%1$s" according to XML response' , $ globalStatus ) ) ; } $ orderitemlist = $ xpath -> query ( '/response/orderlist/orderitem' ) ; foreach ( $ orderitemlist as $ orderitem ) { $ id = $ xpath -> query ( 'id' , $ orderitem ) -> item ( 0 ) -> nodeValue ; $ status = $ xpath -> query ( 'status' , $ orderitem ) -> item ( 0 ) -> nodeValue ; if ( $ id != $ invoiceid ) { throw new MShop_Service_Exception ( sprintf ( 'Order ID "%1$s" in XML response of delivery provider differs from stored invoice ID "%2$s" of the order' , $ id , $ invoiceid ) ) ; } if ( $ status != 0 ) { $ msg = $ xpath -> query ( 'message' , $ orderitem ) -> item ( 0 ) -> nodeValue ; throw new MShop_Service_Exception ( sprintf ( 'Order with ID "%1$s" was rejected with code "%2$s": %3$s' , $ id , $ status , $ msg ) , $ status ) ; } } } | Check response sent back from the server after the request |
32,686 | public function buildXML ( MShop_Order_Item_Interface $ invoice ) { $ orderBaseManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'order/base' ) ; $ criteria = $ orderBaseManager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.id' , $ invoice -> getBaseId ( ) ) ) ; $ result = $ orderBaseManager -> searchItems ( $ criteria ) ; if ( ( $ base = reset ( $ result ) ) === false ) { throw new MShop_Order_Exception ( sprintf ( 'Order base item with order ID "%1$s" not found' , $ invoice -> getId ( ) ) ) ; } try { $ dom = new DOMDocument ( '1.0' , 'UTF-8' ) ; $ orderlist = $ dom -> createElement ( 'orderlist' ) ; $ orderitem = $ dom -> createElement ( 'orderitem' ) ; $ this -> _buildXMLHeader ( $ invoice , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLService ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLPrice ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLProducts ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLAddresses ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ this -> _buildXMLAdditional ( $ orderBaseManager , $ base , $ dom , $ orderitem ) ; $ orderlist -> appendChild ( $ orderitem ) ; $ dom -> appendChild ( $ orderlist ) ; } catch ( DOMException $ e ) { throw new MShop_Service_Exception ( sprintf ( 'Creating XML file with order data for delivery provider failed: %1$s' , $ e -> getMessage ( ) ) , 0 , $ e ) ; } $ requestXSD = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'xsd' . DIRECTORY_SEPARATOR . 'order-request_v1.xsd' ; if ( $ dom -> schemaValidate ( $ requestXSD ) !== true ) { throw new MShop_Service_Exception ( sprintf ( 'Validation of XML response from delivery provider against schema "%1$s" failed: %2$s' , $ requestXSD , $ dom -> saveXML ( ) ) , parent :: ERR_SCHEMA ) ; } if ( ( $ xml = $ dom -> saveXML ( ) ) === false ) { throw new MShop_Service_Exception ( sprintf ( 'DOM tree of XML response from delivery provider could not be converted to XML string' ) , parent :: ERR_XML ) ; } return $ xml ; } | Builds a complete XML string including the order data |
32,687 | protected function _buildXMLHeader ( MShop_Order_Item_Interface $ invoice , MShop_Order_Item_Base_Interface $ base , DOMDocument $ dom , DOMElement $ orderitem ) { $ regex = '/^(\d+)\-(\d+)\-(\d+) (\d+)\:(\d+)\:(\d+)$/i' ; $ date = $ invoice -> getDatePayment ( ) ; if ( ( $ pdate = preg_replace ( $ regex , '$1-$2-$3T$4:$5:$6Z' , $ date ) ) === null ) { throw new MShop_Service_Exception ( sprintf ( 'Invalid characters in purchase date "%1$s"' , $ date ) ) ; } $ config = $ this -> getServiceItem ( ) -> getConfig ( ) ; if ( ! isset ( $ config [ 'default.project' ] ) ) { throw new MShop_Service_Exception ( sprintf ( 'Parameter "%1$s" for configuration not available' , "project" ) , parent :: ERR_TEMP ) ; } $ this -> _appendChildCDATA ( 'id' , $ invoice -> getId ( ) , $ dom , $ orderitem ) ; $ this -> _appendChildCDATA ( 'type' , $ invoice -> getType ( ) , $ dom , $ orderitem ) ; $ this -> _appendChildCDATA ( 'datetime' , $ pdate , $ dom , $ orderitem ) ; if ( $ invoice -> getRelatedId ( ) != null ) { $ this -> _appendChildCDATA ( 'relatedid' , $ invoice -> getRelatedId ( ) , $ dom , $ orderitem ) ; } $ this -> _appendChildCDATA ( 'customerid' , $ base -> getCustomerId ( ) , $ dom , $ orderitem ) ; $ this -> _appendChildCDATA ( 'projectcode' , $ config [ 'default.project' ] , $ dom , $ orderitem ) ; $ this -> _appendChildCDATA ( 'languagecode' , strtoupper ( $ base -> getLocale ( ) -> getLanguageId ( ) ) , $ dom , $ orderitem ) ; $ this -> _appendChildCDATA ( 'currencycode' , $ base -> getPrice ( ) -> getCurrencyId ( ) , $ dom , $ orderitem ) ; } | Adds the header elements to the XML object |
32,688 | protected function _buildXMLPrice ( MShop_Common_Manager_Interface $ orderBaseManager , MShop_Order_Item_Base_Interface $ base , DOMDocument $ dom , DOMElement $ orderitem ) { $ price = $ base -> getPrice ( ) ; $ total = $ price -> getValue ( ) + $ price -> getCosts ( ) ; $ priceitem = $ dom -> createElement ( 'priceitem' ) ; $ this -> _appendChildCDATA ( 'price' , number_format ( $ price -> getValue ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'shipping' , number_format ( $ price -> getCosts ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'discount' , number_format ( 0.00 , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'total' , number_format ( $ total , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ orderitem -> appendChild ( $ priceitem ) ; } | Adds the price item to the XML object |
32,689 | protected function _buildXMLProducts ( MShop_Common_Manager_Interface $ orderBaseManager , MShop_Order_Item_Base_Interface $ base , DOMDocument $ dom , DOMElement $ orderitem ) { $ orderProductManager = $ orderBaseManager -> getSubManager ( 'product' ) ; $ criteria = $ orderProductManager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.product.baseid' , $ base -> getId ( ) ) ) ; $ criteria -> setSortations ( array ( $ criteria -> sort ( '+' , 'order.base.product.position' ) ) ) ; $ allproducts = $ orderProductManager -> searchItems ( $ criteria ) ; $ products = $ childproducts = array ( ) ; foreach ( $ allproducts as $ product ) { if ( $ product -> getOrderProductId ( ) === null ) { $ products [ ] = $ product ; continue ; } $ childproducts [ $ product -> getOrderProductId ( ) ] [ ] = $ product ; } $ productlist = $ dom -> createElement ( 'productlist' ) ; foreach ( $ products as $ product ) { $ price = $ product -> getPrice ( ) ; $ total = $ price -> getValue ( ) + $ price -> getCosts ( ) ; $ productitem = $ dom -> createElement ( 'productitem' ) ; $ this -> _appendChildCDATA ( 'position' , $ product -> getPosition ( ) , $ dom , $ productitem ) ; $ this -> _appendChildCDATA ( 'code' , $ product -> getProductCode ( ) , $ dom , $ productitem ) ; $ this -> _appendChildCDATA ( 'name' , $ product -> getName ( ) , $ dom , $ productitem ) ; $ this -> _appendChildCDATA ( 'quantity' , $ product -> getQuantity ( ) , $ dom , $ productitem ) ; $ priceitem = $ dom -> createElement ( 'priceitem' ) ; $ this -> _appendChildCDATA ( 'price' , number_format ( $ price -> getValue ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'shipping' , number_format ( $ price -> getCosts ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'discount' , number_format ( 0.00 , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'total' , number_format ( $ total , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ productitem -> appendChild ( $ priceitem ) ; if ( $ product -> getType ( ) === 'bundle' ) { $ this -> _buildXMLChildList ( $ product , $ childproducts [ $ product -> getId ( ) ] , $ dom , $ productitem ) ; } $ productlist -> appendChild ( $ productitem ) ; } $ orderitem -> appendChild ( $ productlist ) ; } | Adds the product list to the XML object |
32,690 | protected function _buildXMLChildList ( MShop_Order_Item_Base_Product_Interface $ parent , array $ products , DOMDocument $ dom , DOMElement $ productelement ) { $ childlist = $ dom -> createElement ( 'childlist' ) ; foreach ( $ products as $ product ) { $ price = $ product -> getPrice ( ) ; $ total = $ price -> getValue ( ) + $ price -> getCosts ( ) ; $ childproductitem = $ dom -> createElement ( 'productitem' ) ; $ this -> _appendChildCDATA ( 'position' , $ product -> getPosition ( ) , $ dom , $ childproductitem ) ; $ this -> _appendChildCDATA ( 'code' , $ product -> getProductCode ( ) , $ dom , $ childproductitem ) ; $ this -> _appendChildCDATA ( 'name' , $ product -> getName ( ) , $ dom , $ childproductitem ) ; $ this -> _appendChildCDATA ( 'quantity' , $ product -> getQuantity ( ) , $ dom , $ childproductitem ) ; $ priceitem = $ dom -> createElement ( 'priceitem' ) ; $ this -> _appendChildCDATA ( 'price' , number_format ( $ price -> getValue ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'shipping' , number_format ( $ price -> getCosts ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'discount' , number_format ( $ price -> getRebate ( ) , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ this -> _appendChildCDATA ( 'total' , number_format ( $ total , 2 , '.' , '' ) , $ dom , $ priceitem ) ; $ childproductitem -> appendChild ( $ priceitem ) ; $ childlist -> appendChild ( $ childproductitem ) ; } $ productelement -> appendChild ( $ childlist ) ; } | Adds the list of child products to the bundle products in the XML object |
32,691 | protected function _buildXMLAddresses ( MShop_Common_Manager_Interface $ orderBaseManager , MShop_Order_Item_Base_Interface $ base , DOMDocument $ dom , DOMElement $ orderitem ) { $ orderAddressManager = $ orderBaseManager -> getSubManager ( 'address' ) ; $ criteria = $ orderAddressManager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.address.baseid' , $ base -> getId ( ) ) ) ; $ criteria -> setSortations ( array ( $ criteria -> sort ( '+' , 'order.base.address.type' ) ) ) ; $ addresses = $ orderAddressManager -> searchItems ( $ criteria ) ; $ addresslist = $ dom -> createElement ( 'addresslist' ) ; foreach ( $ addresses as $ address ) { $ this -> _buildXMLAddress ( $ address , $ dom , $ addresslist ) ; } $ orderitem -> appendChild ( $ addresslist ) ; } | Adds the address list to the XML object |
32,692 | protected function _buildXMLAddress ( MShop_Order_Item_Base_Address_Interface $ address , DOMDocument $ dom , DOMElement $ addresslist ) { $ addressitem = $ dom -> createElement ( 'addressitem' ) ; $ this -> _appendChildCDATA ( 'type' , $ address -> getType ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'salutation' , $ address -> getSalutation ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'title' , $ address -> getTitle ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'firstname' , $ address -> getFirstname ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'lastname' , $ address -> getLastname ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'company' , $ address -> getCompany ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'address1' , $ address -> getAddress1 ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'address2' , $ address -> getAddress2 ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'address3' , $ address -> getAddress3 ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'postalcode' , $ address -> getPostal ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'city' , $ address -> getCity ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'state' , $ address -> getState ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'countrycode' , strtoupper ( $ address -> getCountryId ( ) ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'email' , $ address -> getEmail ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'phone' , $ address -> getTelephone ( ) , $ dom , $ addressitem ) ; $ this -> _appendChildCDATA ( 'vatid' , $ address -> getVatID ( ) , $ dom , $ addressitem ) ; $ addresslist -> appendChild ( $ addressitem ) ; } | Adds a single address item to the address list of the XML object |
32,693 | protected function _buildXMLAdditional ( MShop_Common_Manager_Interface $ orderBaseManager , MShop_Order_Item_Base_Interface $ base , DOMDocument $ dom , DOMElement $ orderitem ) { $ orderCouponManager = $ orderBaseManager -> getSubManager ( 'coupon' ) ; $ criteria = $ orderCouponManager -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , 'order.base.coupon.baseid' , $ base -> getId ( ) ) ) ; $ criteria -> setSortations ( array ( $ criteria -> sort ( '+' , 'order.base.coupon.code' ) ) ) ; $ coupons = $ orderCouponManager -> searchItems ( $ criteria ) ; $ additional = $ dom -> createElement ( 'additional' ) ; $ this -> _appendChildCDATA ( 'comment' , '' , $ dom , $ additional ) ; $ couponItem = $ dom -> createElement ( 'discount' ) ; foreach ( $ coupons as $ coupon ) { $ this -> _appendChildCDATA ( 'code' , $ coupon -> getCode ( ) , $ dom , $ couponItem ) ; } $ additional -> appendChild ( $ couponItem ) ; $ orderitem -> appendChild ( $ additional ) ; } | Adds the additional section to the XML object |
32,694 | protected function _appendChildCDATA ( $ name , $ value , DOMDocument $ dom , DOMElement $ parent ) { $ child = $ dom -> createElement ( $ name ) ; $ child -> appendChild ( $ dom -> createCDATASection ( $ value ) ) ; $ parent -> appendChild ( $ child ) ; } | Add a child in CData flavour |
32,695 | public function addOptions ( array $ options ) : Select { foreach ( $ options as $ value => $ content ) { $ this -> addOption ( $ content , $ value ) ; } return $ this ; } | Adds a batch of options to this Select . |
32,696 | protected function getOptions ( ) : array { $ options = [ ] ; foreach ( $ this -> elements as $ element ) { if ( $ element instanceof Option ) { $ options [ ] = $ element ; } elseif ( $ element instanceof OptionGroup ) { $ options = array_merge ( $ options , $ element -> getOptions ( ) ) ; } } return $ options ; } | Returns all the options in this Select including the ones nested in option groups . |
32,697 | public function getCMSFields ( ) { $ this -> beforeUpdateCMSFields ( function ( $ fields ) { $ config = SiteConfig :: current_site_config ( ) ; $ fields -> removeByName ( "Customisation" ) ; $ fields -> addFieldToTab ( "Root.Main" , ReadonlyField :: create ( "Key" ) , "Title" ) ; $ fields -> addFieldToTab ( "Root.Main" , DropdownField :: create ( "TaxID" , $ this -> fieldLabel ( "TaxID" ) , $ config -> TaxRates ( ) -> map ( ) ) , "Weight" ) ; $ fields -> addFieldsToTab ( "Root.Description" , [ HTMLEditorField :: create ( "Content" ) -> addExtraClass ( "stacked" ) ] ) ; $ custom_field = $ fields -> dataFieldByName ( "Customisations" ) ; if ( $ custom_field ) { $ config = $ custom_field -> getConfig ( ) ; $ config -> removeComponentsByType ( GridFieldDeleteAction :: class ) -> removeComponentsByType ( GridFieldDataColumns :: class ) -> removeComponentsByType ( GridFieldEditButton :: class ) -> removeComponentsByType ( GridFieldAddNewButton :: class ) -> removeComponentsByType ( GridFieldAddExistingAutocompleter :: class ) -> addComponents ( new GridFieldEditableColumns ( ) , new GridFieldAddNewInlineButton ( ) , new GridFieldEditButton ( ) , new GridFieldDeleteAction ( ) ) ; $ custom_field -> setConfig ( $ config ) ; } } ) ; return parent :: getCMSFields ( ) ; } | Modify default field scaffolding in admin |
32,698 | public function getTaxRate ( ) { $ rate = ( $ this -> Tax ( ) -> exists ( ) ) ? $ this -> Tax ( ) -> Rate : 0 ; $ this -> extend ( "updateTaxRate" , $ rate ) ; return $ rate ; } | Get the rate of tax for this item |
32,699 | public function getUnitTax ( ) { $ total = ( $ this -> UnitPrice / 100 ) * $ this -> TaxRate ; $ this -> extend ( "updateUnitTax" , $ total ) ; return $ total ; } | Get the amount of tax for a single unit of this item |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.