idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
45,900
public function addTranslationSelect ( string $ root , EntityDefinition $ definition , QueryBuilder $ query , Context $ context ) : void { $ translationDefinition = $ definition -> getTranslationDefinition ( ) ; $ fields = $ translationDefinition -> getFields ( ) ; $ chain = self :: buildTranslationChain ( $ root , $ c...
Adds the full translation select part to the provided sql query . Considers the parent - child inheritance and provided context language inheritance . The raw parameter allows to skip the parent - child inheritance .
45,901
private function addRuleCondition ( QueryBuilder $ query , EntityDefinition $ definition , Context $ context ) : void { if ( $ definition -> isBlacklistAware ( ) && $ context -> getRuleIds ( ) ) { $ wheres = [ ] ; $ accessor = $ this -> getFieldAccessor ( 'blacklistIds' , $ definition , $ definition -> getEntityName ( ...
Adds a blacklist and whitelist where condition to the provided query . This function is only for internal usage for the root entity of the query .
45,902
public function page ( string $ id , Request $ request , SalesChannelContext $ context ) : Response { if ( ! $ id ) { throw new MissingRequestParameterException ( 'Parameter id missing' ) ; } $ page = $ this -> load ( $ id , $ request , $ context ) ; return $ this -> renderStorefront ( '@Storefront/page/content/detail....
Route for stand alone cms pages
45,903
public function category ( string $ navigationId , Request $ request , SalesChannelContext $ context ) : Response { if ( ! $ navigationId ) { throw new MissingRequestParameterException ( 'Parameter navigationId missing' ) ; } $ categories = $ this -> categoryRepository -> search ( new Criteria ( [ $ navigationId ] ) , ...
Route to load a cms page which assigned to the provided navigation id . Navigation id is required to load the slot config for the navigation
45,904
public function extract ( \ ZipArchive $ archive ) : void { $ destination = $ this -> pluginDir ; if ( ! is_writable ( $ destination ) ) { throw new PluginExtractionException ( sprintf ( 'Destination directory "%s" is not writable' , $ destination ) ) ; } $ pluginName = $ this -> getPluginName ( $ archive ) ; $ this ->...
Extracts the provided zip file to the plugin directory
45,905
private function validatePluginZip ( string $ prefix , \ ZipArchive $ archive ) : void { for ( $ i = 2 ; $ i < $ archive -> numFiles ; ++ $ i ) { $ stat = $ archive -> statIndex ( $ i ) ; $ this -> assertNoDirectoryTraversal ( $ stat [ 'name' ] ) ; $ this -> assertPrefix ( $ stat [ 'name' ] , $ prefix ) ; } }
Iterates all files of the provided zip archive path and validates the plugin namespace directory traversal and multiple plugin directories .
45,906
public function buildPlaceholderItem ( string $ code , int $ currencyPrecision ) : LineItem { $ uniqueKey = self :: PLACEHOLDER_PREFIX . $ code ; $ item = new LineItem ( $ uniqueKey , $ this -> lineItemType , 1 ) ; $ item -> setLabel ( $ uniqueKey ) ; $ item -> setGood ( false ) ; $ item -> setPayload ( [ 'code' => $ c...
Builds a new placeholder promotion line item that does not have any side effects for the calculation . It will contain the code within the payload which can then be used to create a real promotion item .
45,907
public function buildDiscountLineItem ( PromotionEntity $ promotion , PromotionDiscountEntity $ discount , int $ currencyPrecision ) : LineItem { $ discountRuleCollection = $ discount -> getDiscountRules ( ) ; $ targetFilter = null ; if ( $ discountRuleCollection instanceof RuleCollection && $ discount -> isConsiderAdv...
Builds a new Line Item for the provided discount and its promotion . It will automatically reference all provided product item Ids within the payload .
45,908
public function getEntityContextCacheKey ( string $ id , EntityDefinition $ definition , Context $ context , ? Criteria $ criteria = null ) : string { $ keys = [ $ this -> getDefinitionCacheKey ( $ definition ) , $ id , $ this -> getContextHash ( $ context ) ] ; if ( $ criteria && \ count ( $ criteria -> getAssociation...
Generates a unique entity cache key . Considers a provided criteria with additional loaded associations and different context states .
45,909
public function getReadCriteriaCacheKey ( EntityDefinition $ definition , Criteria $ criteria , Context $ context ) : string { $ keys = [ $ this -> getDefinitionCacheKey ( $ definition ) , $ this -> getReadCriteriaHash ( $ criteria ) , $ this -> getContextHash ( $ context ) ] ; return md5 ( implode ( '-' , $ keys ) ) ;...
Generates a cache key for a criteria inside the read process . Considers different associations and context states .
45,910
public function getSearchCacheKey ( EntityDefinition $ definition , Criteria $ criteria , Context $ context ) : string { $ keys = [ $ this -> getDefinitionCacheKey ( $ definition ) , $ this -> getCriteriaHash ( $ criteria ) , $ this -> getContextHash ( $ context ) ] ; return md5 ( implode ( '-' , $ keys ) ) ; }
Generates a unique cache key for a search result .
45,911
public function getAggregationCacheKey ( Aggregation $ aggregation , EntityDefinition $ definition , Criteria $ criteria , Context $ context ) : string { $ keys = [ md5 ( json_encode ( $ aggregation ) ) , $ this -> getDefinitionCacheKey ( $ definition ) , $ this -> getAggregationHash ( $ criteria ) , $ this -> getConte...
Generates the unique cache key for the provided aggregation . Used as cache key for cached aggregation results .
45,912
public function getEntityTag ( string $ id , EntityDefinition $ definition ) : string { $ keys = [ $ definition -> getEntityName ( ) , $ id ] ; return implode ( '-' , $ keys ) ; }
Defines the tag for a single entity . Used for invalidation if this entity is written
45,913
public function getSearchTags ( EntityDefinition $ definition , Criteria $ criteria ) : array { $ tags = [ $ definition -> getEntityName ( ) . '.id' ] ; foreach ( $ criteria -> getSearchQueryFields ( ) as $ accessor ) { foreach ( $ this -> getFieldsOfAccessor ( $ definition , $ accessor ) as $ association ) { $ tags [ ...
Calculates all relevant cache tags for a search requests . Considers all accessed fields of the criteria .
45,914
public function getAggregationTags ( EntityDefinition $ definition , Criteria $ criteria , Aggregation $ aggregation ) : array { $ tags = [ $ definition -> getEntityName ( ) . '.id' ] ; $ fields = $ criteria -> getAggregationQueryFields ( ) ; $ fields = array_merge ( $ fields , $ aggregation -> getFields ( ) ) ; foreac...
Calculates all cache tags for the provided aggregation . Considers the criteria filters and queries .
45,915
public function getAssociatedTags ( EntityDefinition $ definition , Entity $ entity , Context $ context ) : array { $ associations = $ definition -> getFields ( ) -> filterInstance ( AssociationField :: class ) ; $ keys = [ $ this -> getEntityTag ( $ entity -> getUniqueIdentifier ( ) , $ definition ) ] ; foreach ( $ co...
Calculates all tags for a single entity . Considers the language chain context states and loaded associations
45,916
public function preValidate ( array $ writeCommands , WriteContext $ context ) : void { $ violationList = new ConstraintViolationList ( ) ; foreach ( $ writeCommands as $ command ) { if ( ! $ command instanceof InsertCommand && ! $ command instanceof UpdateCommand ) { continue ; } switch ( get_class ( $ command -> getD...
This function validates our incoming delta - values for promotions and its aggregation . It does only check for business relevant rules and logic . All primitive required constraints are done inside the definition of the entity .
45,917
private function validatePromotion ( array $ payload , ConstraintViolationList $ violationList ) { $ useCodes = $ this -> getValue ( $ payload , 'use_codes' , null ) ; $ code = $ this -> getValue ( $ payload , 'code' , null ) ; $ validFrom = $ this -> getValue ( $ payload , 'valid_from' , null ) ; $ validUntil = $ this...
Validates the provided Promotion data and adds violations to the provided list of violations if found .
45,918
private function validateDiscount ( array $ payload , ConstraintViolationList $ violationList ) { $ type = $ this -> getValue ( $ payload , 'type' , '' ) ; $ value = $ this -> getValue ( $ payload , 'value' , null ) ; if ( $ value === null ) { return ; } if ( $ value < self :: DISCOUNT_MIN_VALUE ) { $ violationList -> ...
Validates the provided PromotionDiscount data and adds violations to the provided list of violations if found .
45,919
private function buildViolation ( string $ message , $ invalidValue ) : ConstraintViolationInterface { return new ConstraintViolation ( $ message , '' , [ 'value' => $ invalidValue , ] , $ invalidValue , null , $ invalidValue ) ; }
This helper function builds an easy violation object for our validator .
45,920
public static function encodeJson ( $ value , int $ options = JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION ) : string { return \ json_encode ( $ value , $ options ) ; }
mariadbs JSON_VALID function does not allow escaped unicode .
45,921
public function validate ( RequestDataBag $ post ) : JsonResponse { $ this -> templateRenderer -> render ( $ post -> get ( 'contentHtml' , '' ) , [ ] ) ; $ this -> templateRenderer -> render ( $ post -> get ( 'contentPlain' , '' ) , [ ] ) ; return new JsonResponse ( null , Response :: HTTP_NO_CONTENT ) ; }
Validates if an email template can be rendered without sending an email
45,922
public function read ( string $ xmlFile ) : array { try { $ dom = XmlUtils :: loadFile ( $ xmlFile , $ this -> xsdFile ) ; } catch ( \ Exception $ e ) { throw new XmlParsingException ( $ xmlFile , $ e -> getMessage ( ) ) ; } return $ this -> parseFile ( $ dom ) ; }
load and validate xml file - parse to array
45,923
public function prepare ( StructCollection $ definitions , Cart $ cart , SalesChannelContext $ context , CartBehavior $ behavior ) : void { $ placeholderItemIds = [ ] ; $ promotionLineItems = $ this -> getPromotionLineItems ( $ cart ) ; foreach ( $ promotionLineItems as $ lineItem ) { if ( $ this -> isPromotionPlacehol...
This function extracts all place holder promotion items from the cart and makes sure they get converted into real promotion line items later . Only these codes along with all automatic non - code promotions will be loaded later when collecting the eligible promotions .
45,924
public function collect ( StructCollection $ fetchDefinitions , StructCollection $ data , Cart $ cart , SalesChannelContext $ context , CartBehavior $ behavior ) : void { $ promotionDefinitions = $ fetchDefinitions -> filterInstance ( CartPromotionsFetchDefinition :: class ) ; if ( $ promotionDefinitions -> count ( ) <...
This function is used to collect our promotion data for our cart . It queries the database for all placeholder promotions and their codes along with all non - code promotions that are applied automatically if conditions are met . The eligible promotions will then be passed on to the enrichment function .
45,925
public function enrich ( StructCollection $ data , Cart $ cart , SalesChannelContext $ context , CartBehavior $ behavior ) : void { $ promotionLineItems = $ this -> getPromotionLineItems ( $ cart ) ; foreach ( $ promotionLineItems as $ lineItem ) { if ( $ this -> isPromotionPlaceholder ( $ lineItem ) ) { $ cart -> getL...
This function enriches the cart with custom data that has been collected in our previous function . All collected promotions will now be converted into real Promotion Line Items . Placeholder items will be removed accordingly . If we are in live checkout mode then we also remove existing promotion line items that might...
45,926
private function getPromotionLineItems ( Cart $ cart ) : array { return array_filter ( $ cart -> getLineItems ( ) -> getElements ( ) , function ( LineItem $ lineItem ) { return $ lineItem -> getType ( ) === self :: LINE_ITEM_TYPE ; } ) ; }
Gets all promotion line items from the cart . This includes placeholders and real satisfied promotion line items .
45,927
private function isPromotionPlaceholder ( LineItem $ lineItem ) : bool { if ( $ lineItem -> getType ( ) !== self :: LINE_ITEM_TYPE ) { return false ; } return substr ( $ lineItem -> getKey ( ) , 0 , strlen ( PromotionItemBuilder :: PLACEHOLDER_PREFIX ) ) === PromotionItemBuilder :: PLACEHOLDER_PREFIX ; }
Gets if the line item is a placeholder and not yet satisfied promotion line item . This is done by verifying if the key starts with our placeholder prefix
45,928
private function isRealPromotionItem ( LineItem $ lineItem ) : bool { if ( $ lineItem -> getType ( ) !== self :: LINE_ITEM_TYPE ) { return false ; } return ! $ this -> isPromotionPlaceholder ( $ lineItem ) ; }
Gets if the line item is a real and satisfied promotion line item .
45,929
private function getCodesFromPlaceholdersIds ( Cart $ cart , array $ lineItemIDs ) : array { $ codes = [ ] ; $ promotionLineItems = $ this -> getPromotionLineItems ( $ cart ) ; foreach ( $ promotionLineItems as $ lineItem ) { if ( ! in_array ( $ lineItem -> getKey ( ) , $ lineItemIDs , true ) ) { continue ; } if ( arra...
This function extracts all code strings from the placeholder items of the provided Ids within the cart .
45,930
private function searchPromotions ( array $ codes , SalesChannelContext $ context ) : array { $ codePromotions = $ this -> promotionGateway -> getByCodes ( $ codes , $ context ) ; $ automaticPromotions = $ this -> promotionGateway -> getAutomaticPromotions ( $ context ) ; $ listPromotionsAdded = $ codePromotions -> get...
Gets a combination of all promotion objects that are valid due to automatic promotions or that have been manually added by using their codes .
45,931
private function buildDiscountLineItems ( PromotionEntity $ promotion , Cart $ cart , SalesChannelContext $ context ) : array { $ collection = $ promotion -> getDiscounts ( ) ; if ( ! $ collection instanceof PromotionDiscountCollection ) { return [ ] ; } $ lineItems = [ ] ; foreach ( $ collection -> getElements ( ) as ...
This function builds separate line items for each of the available discounts within the provided promotion . Every item will be built with a corresponding price definition based on the configuration of a discount entity . The resulting list of line items will then be returned and can be added to the cart . The function...
45,932
public function getAmount ( ) : float { $ amounts = $ this -> map ( function ( CalculatedTax $ calculatedTax ) { return $ calculatedTax -> getTax ( ) ; } ) ; return array_sum ( $ amounts ) ; }
Returns the total calculated tax for this item
45,933
private function merge ( DataValidationDefinition $ definition , DataValidationDefinition $ profileDefinition ) : void { foreach ( $ profileDefinition -> getProperties ( ) as $ key => $ constraints ) { $ parameters = [ ] ; $ parameters [ ] = $ key ; $ parameters = array_merge ( $ parameters , $ constraints ) ; call_use...
merges constraints from the second definition into the first validation definition
45,934
public function dispatch ( $ message ) : Envelope { $ messageName = $ this -> getMessageName ( $ message ) ; if ( $ this -> isIncoming ( $ message ) ) { $ this -> decrementMessageQueueSize ( $ messageName ) ; } else { $ this -> incrementMessageQueueSize ( $ messageName ) ; } return $ this -> innerBus -> dispatch ( $ me...
Dispatches the given message to the inner Bus and Logs it .
45,935
private function getCategoryTree ( string $ navigationId , SalesChannelContext $ context ) { $ category = $ this -> navigationLoader -> loadLevel ( $ navigationId , $ context ) ; $ active = $ category -> getActive ( ) ; if ( $ active -> getChildCount ( ) > 0 || $ active -> getParentId ( ) === null ) { return $ category...
returns the category tree for the passed navigation id if the category has no children the parent category will be used
45,936
private function getPathRelativeToProjectDir ( string $ absolute ) : string { $ projectDir = $ this -> kernel -> getProjectDir ( ) ; $ relative = str_replace ( $ projectDir , '' , $ absolute ) ; $ relative = ltrim ( $ relative , '/' ) ; return $ relative ; }
return a path relative to the project dir
45,937
public function load ( string $ activeId , SalesChannelContext $ context ) : ? Tree { $ active = $ this -> loadActive ( $ activeId , $ context ) ; $ criteria = new Criteria ( ) ; $ criteria -> addFilter ( new EqualsFilter ( 'visible' , true ) ) ; $ categories = $ this -> categoryRepository -> search ( $ criteria , $ co...
Returns the full category tree . The provided active id will be marked as selected
45,938
public function loadLevel ( string $ categoryId , SalesChannelContext $ context ) : ? Tree { $ active = $ this -> loadActive ( $ categoryId , $ context ) ; $ criteria = new Criteria ( ) ; $ criteria -> addFilter ( new EqualsFilter ( 'visible' , true ) ) ; $ criteria -> addFilter ( new MultiFilter ( MultiFilter :: CONNE...
Returns the category tree level for the provided category id .
45,939
private function getCustomizedCatalog ( MessageCatalogueInterface $ catalog ) : MessageCatalogueInterface { $ request = $ this -> requestStack -> getMasterRequest ( ) ; if ( ! $ request ) { return $ catalog ; } $ snippetSetId = $ request -> attributes -> get ( SalesChannelRequest :: ATTRIBUTE_DOMAIN_SNIPPET_SET_ID ) ; ...
Add language specific snippets provided by the admin
45,940
public function getLineItemsByDiscount ( PromotionDiscountEntity $ discount , Cart $ cart , SalesChannelContext $ context ) : array { $ nonPromotionLineItemsKeys = $ this -> getNonPromotionLineItemsKeys ( $ cart ) ; if ( count ( $ nonPromotionLineItemsKeys ) === 0 ) { return [ ] ; } if ( ! $ discount -> isConsiderAdvan...
returns all lineItem keys that match the rules of the promotion
45,941
private function getNonPromotionLineItems ( Cart $ cart ) : array { $ lineItems = array_filter ( $ cart -> getLineItems ( ) -> getElements ( ) , function ( LineItem $ lineItem ) { return $ lineItem -> getType ( ) !== $ this -> promotionLineItemPlaceholder ; } ) ; return $ lineItems ; }
Gets all line items that are not of the provided type These can be used to iterate through all standard items .
45,942
private function getNonPromotionLineItemsKeys ( Cart $ cart ) : array { $ lineItems = $ this -> getNonPromotionLineItems ( $ cart ) ; $ lineItemKeys = [ ] ; foreach ( $ lineItems as $ lineItem ) { $ lineItemKeys [ ] = $ lineItem -> getKey ( ) ; } return $ lineItemKeys ; }
return all LineItem Keys that are no promotions
45,943
private function doesRuleCollectionMatchsLineItem ( RuleCollection $ ruleCollection , LineItemScope $ lineItemScope ) : bool { foreach ( $ ruleCollection as $ discountRule ) { $ ruleCondition = $ discountRule -> getPayload ( ) ; if ( ! $ ruleCondition instanceof Rule ) { continue ; } if ( $ ruleCondition -> match ( $ l...
checks if a ruleCollection matches a lineItem . This function returns true if ONE rule in collection matches lineItem otherwise returns false
45,944
protected function addForwardTrigger ( Connection $ connection , string $ name , string $ table , string $ time , string $ event , string $ statements ) : void { $ this -> addTrigger ( $ connection , $ name , $ table , $ time , $ event , $ statements , '' ) ; }
FORWARD triggers are executed when an old application has to work with a newer Database and has to keep it update - safe
45,945
public function getPreconditionRule ( ) : Rule { $ requirements = new AndRule ( [ ] ) ; $ personasFound = false ; $ personaOR = new OrRule ( ) ; if ( $ this -> getPersonaRules ( ) !== null && count ( $ this -> getPersonaRules ( ) -> getElements ( ) ) > 0 ) { $ personaRuleOR = new OrRule ( ) ; foreach ( $ this -> getPer...
Builds our aggregated precondition rule condition for this promotion . If this rule matches within all its sub conditions then the whole promotion is allowed to be used .
45,946
public function buildContents ( Context $ context , array $ bodies , string $ salesChannelId ) : array { $ mailHeaderFooter = $ this -> findSalesChannel ( $ context , $ salesChannelId ) -> getMailHeaderFooter ( ) ; if ( $ mailHeaderFooter !== null ) { return [ 'text/plain' => $ mailHeaderFooter -> getHeaderPlain ( ) . ...
Attaches header and footer to given email bodies
45,947
public function addAssociationPath ( string $ path ) : self { $ parts = explode ( '.' , $ path ) ; $ criteria = $ this ; foreach ( $ parts as $ part ) { if ( ! $ criteria -> hasAssociation ( $ part ) ) { $ criteria -> addAssociation ( $ part ) ; } $ criteria = $ criteria -> getAssociation ( $ part ) ; } return $ this ;...
Allows to add a nested association
45,948
public function addExtension ( string $ name , ? Struct $ extension ) : void { $ this -> extensions [ $ name ] = $ extension ; }
Adds a new extension struct into the class storage . The passed name is used as unique identifier and has to be stored too .
45,949
protected function suffixFileName ( string $ fileName ) : string { $ pathInfo = pathinfo ( $ fileName ) ; $ dirname = $ pathInfo [ 'dirname' ] . DIRECTORY_SEPARATOR ; $ filename = $ pathInfo [ 'filename' ] ; $ extension = empty ( $ pathInfo [ 'extension' ] ) ? '' : '.' . $ pathInfo [ 'extension' ] ; $ i = 0 ; do { $ i ...
Rename a file if it already exists at its destination . Renaming is done by adding a duplicate number to the file name . E . g . existingFileName_1 . ext . After a max duplicate number renaming the file will switch over to generating a random suffix .
45,950
public function read ( $ bytes = 2082 ) { return feof ( $ this -> stream ) ? false : fread ( $ this -> stream , $ bytes ) ; }
Read the contents a few bytes at a time until completed Once read to completion it always returns false
45,951
public function save ( $ attach_dir , $ filenameStrategy = Parser :: ATTACHMENT_DUPLICATE_SUFFIX ) { $ attach_dir = rtrim ( $ attach_dir , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; if ( ! is_dir ( $ attach_dir ) ) { mkdir ( $ attach_dir ) ; } switch ( $ filenameStrategy ) { case Parser :: ATTACHMENT_RANDOM_FILENAME...
Save the attachment individually
45,952
public function setPath ( $ path ) { if ( is_writable ( $ path ) ) { $ file = fopen ( $ path , 'a+' ) ; fseek ( $ file , - 1 , SEEK_END ) ; if ( fread ( $ file , 1 ) != "\n" ) { fwrite ( $ file , PHP_EOL ) ; } fclose ( $ file ) ; } $ this -> resource = mailparse_msg_parse_file ( $ path ) ; $ this -> stream = fopen ( $ ...
Set the file path we use to get the email text
45,953
public function setStream ( $ stream ) { $ meta = @ stream_get_meta_data ( $ stream ) ; if ( ! $ meta || ! $ meta [ 'mode' ] || ! in_array ( $ meta [ 'mode' ] , self :: $ readableModes , true ) || $ meta [ 'eof' ] ) { throw new Exception ( 'setStream() expects parameter stream to be readable stream resource.' ) ; } $ t...
Set the Stream resource we use to get the email text
45,954
public function setText ( $ data ) { if ( empty ( $ data ) ) { throw new Exception ( 'You must not call MimeMailParser::setText with an empty string parameter' ) ; } if ( substr ( $ data , - 1 ) != "\n" ) { $ data = $ data . PHP_EOL ; } $ this -> resource = mailparse_msg_create ( ) ; mailparse_msg_parse ( $ this -> res...
Set the email text
45,955
protected function parse ( ) { $ structure = mailparse_msg_get_structure ( $ this -> resource ) ; $ this -> parts = [ ] ; foreach ( $ structure as $ part_id ) { $ part = mailparse_msg_get_part ( $ this -> resource , $ part_id ) ; $ part_data = mailparse_msg_get_part_data ( $ part ) ; $ mimePart = new MimePart ( $ part_...
Parse the Message into parts
45,956
public function getRawHeader ( $ name ) { $ name = strtolower ( $ name ) ; if ( isset ( $ this -> parts [ 1 ] ) ) { $ headers = $ this -> getPart ( 'headers' , $ this -> parts [ 1 ] ) ; return isset ( $ headers [ $ name ] ) ? $ headers [ $ name ] : false ; } else { throw new Exception ( 'setPath() or setText() or setSt...
Retrieve a specific Email Header without charset conversion .
45,957
public function getHeader ( $ name ) { $ rawHeader = $ this -> getRawHeader ( $ name ) ; if ( $ rawHeader === false ) { return false ; } return $ this -> decodeHeader ( $ rawHeader ) ; }
Retrieve a specific Email Header
45,958
public function getHeaders ( ) { if ( isset ( $ this -> parts [ 1 ] ) ) { $ headers = $ this -> getPart ( 'headers' , $ this -> parts [ 1 ] ) ; foreach ( $ headers as $ name => & $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as & $ v ) { $ v = $ this -> decodeSingleHeader ( $ v ) ; } } else { $ value = $ ...
Retrieve all mail headers
45,959
protected function getPartHeader ( & $ part ) { $ header = '' ; if ( $ this -> stream ) { $ header = $ this -> getPartHeaderFromFile ( $ part ) ; } elseif ( $ this -> data ) { $ header = $ this -> getPartHeaderFromText ( $ part ) ; } return $ header ; }
Retrieve the raw Header of a MIME part
45,960
protected function getPartHeaderFromFile ( & $ part ) { $ start = $ part [ 'starting-pos' ] ; $ end = $ part [ 'starting-pos-body' ] ; fseek ( $ this -> stream , $ start , SEEK_SET ) ; $ header = fread ( $ this -> stream , $ end - $ start ) ; return $ header ; }
Retrieve the Header from a MIME part from file
45,961
protected function getPartHeaderFromText ( & $ part ) { $ start = $ part [ 'starting-pos' ] ; $ end = $ part [ 'starting-pos-body' ] ; $ header = substr ( $ this -> data , $ start , $ end - $ start ) ; return $ header ; }
Retrieve the Header from a MIME part from text
45,962
protected function partIdIsChildOfPart ( $ partId , $ parentPartId ) { $ parentPartId = $ parentPartId . '.' ; return substr ( $ partId , 0 , strlen ( $ parentPartId ) ) == $ parentPartId ; }
Checks whether a given part ID is a child of another part eg . an RFC822 attachment may have one or more text parts
45,963
protected function partIdIsChildOfAnAttachment ( $ checkPartId ) { foreach ( $ this -> parts as $ partId => $ part ) { if ( $ this -> getPart ( 'content-disposition' , $ part ) == 'attachment' ) { if ( $ this -> partIdIsChildOfPart ( $ checkPartId , $ partId ) ) { return true ; } } } return false ; }
Whether the given part ID is a child of any attachment part in the message .
45,964
public function getMessageBody ( $ type = 'text' ) { $ mime_types = [ 'text' => 'text/plain' , 'html' => 'text/html' , 'htmlEmbedded' => 'text/html' , ] ; if ( in_array ( $ type , array_keys ( $ mime_types ) ) ) { $ part_type = $ type === 'htmlEmbedded' ? 'html' : $ type ; $ inline_parts = $ this -> getInlineParts ( $ ...
Returns the email message body in the specified format
45,965
protected function getEmbeddedData ( $ contentId ) { foreach ( $ this -> parts as $ part ) { if ( $ this -> getPart ( 'content-id' , $ part ) == $ contentId ) { $ embeddedData = 'data:' ; $ embeddedData .= $ this -> getPart ( 'content-type' , $ part ) ; $ embeddedData .= ';' . $ this -> getPart ( 'transfer-encoding' , ...
Returns the embedded data structure
45,966
public function getAddresses ( $ name ) { $ value = $ this -> getRawHeader ( $ name ) ; $ value = ( is_array ( $ value ) ) ? $ value [ 0 ] : $ value ; $ addresses = mailparse_rfc822_parse_addresses ( $ value ) ; foreach ( $ addresses as $ i => $ item ) { $ addresses [ $ i ] [ 'display' ] = $ this -> decodeHeader ( $ it...
Return an array with the following keys display address is_group
45,967
public function getInlineParts ( $ type = 'text' ) { $ inline_parts = [ ] ; $ mime_types = [ 'text' => 'text/plain' , 'html' => 'text/html' , ] ; if ( ! in_array ( $ type , array_keys ( $ mime_types ) ) ) { throw new Exception ( 'Invalid type specified for getInlineParts(). "type" can either be text or html.' ) ; } for...
Returns the attachments contents in order of appearance
45,968
public function saveAttachments ( $ attach_dir , $ include_inline = true , $ filenameStrategy = self :: ATTACHMENT_DUPLICATE_SUFFIX ) { $ attachments = $ this -> getAttachments ( $ include_inline ) ; $ attachments_paths = [ ] ; foreach ( $ attachments as $ attachment ) { $ attachments_paths [ ] = $ attachment -> save (...
Save attachments in a folder
45,969
protected function getAttachmentStream ( & $ part ) { $ temp_fp = tmpfile ( ) ; $ headers = $ this -> getPart ( 'headers' , $ part ) ; $ encodingType = array_key_exists ( 'content-transfer-encoding' , $ headers ) ? $ headers [ 'content-transfer-encoding' ] : '' ; if ( $ temp_fp ) { if ( $ this -> stream ) { $ start = $...
Read the attachment Body and save temporary file resource
45,970
protected function decodeContentTransfer ( $ encodedString , $ encodingType ) { if ( is_array ( $ encodingType ) ) { $ encodingType = $ encodingType [ 0 ] ; } $ encodingType = strtolower ( $ encodingType ) ; if ( $ encodingType == 'base64' ) { return base64_decode ( $ encodedString ) ; } elseif ( $ encodingType == 'quo...
Decode the string from Content - Transfer - Encoding
45,971
protected function getPartBody ( & $ part ) { $ body = '' ; if ( $ this -> stream ) { $ body = $ this -> getPartBodyFromFile ( $ part ) ; } elseif ( $ this -> data ) { $ body = $ this -> getPartBodyFromText ( $ part ) ; } return $ body ; }
Retrieve the Body of a MIME part
45,972
protected function getPartBodyFromFile ( & $ part ) { $ start = $ part [ 'starting-pos-body' ] ; $ end = $ part [ 'ending-pos-body' ] ; $ body = '' ; if ( $ end - $ start > 0 ) { fseek ( $ this -> stream , $ start , SEEK_SET ) ; $ body = fread ( $ this -> stream , $ end - $ start ) ; } return $ body ; }
Retrieve the Body from a MIME part from file
45,973
protected function getPartBodyFromText ( & $ part ) { $ start = $ part [ 'starting-pos-body' ] ; $ end = $ part [ 'ending-pos-body' ] ; return substr ( $ this -> data , $ start , $ end - $ start ) ; }
Retrieve the Body from a MIME part from text
45,974
protected function getPartComplete ( & $ part ) { $ body = '' ; if ( $ this -> stream ) { $ body = $ this -> getPartFromFile ( $ part ) ; } elseif ( $ this -> data ) { $ body = $ this -> getPartFromText ( $ part ) ; } return $ body ; }
Retrieve the content of a MIME part
45,975
protected function getPartFromText ( & $ part ) { $ start = $ part [ 'starting-pos' ] ; $ end = $ part [ 'ending-pos' ] ; return substr ( $ this -> data , $ start , $ end - $ start ) ; }
Retrieve the content from a MIME part from text
45,976
public function parse ( MimePart $ part ) { if ( ! $ this -> middleware ) { return $ part ; } $ part = call_user_func ( array ( $ this -> middleware , 'parse' ) , $ part , $ this -> next ) ; return $ part ; }
Parses the MimePart by passing it through the Middleware
45,977
public static function factory ( array $ middlewares = array ( ) ) { $ stack = new static ; foreach ( $ middlewares as $ middleware ) { $ stack = $ stack -> add ( $ middleware ) ; } return $ stack ; }
Creates a MiddlewareStack based on an array of middleware
45,978
public function persist ( $ user ) : void { $ this -> om -> persist ( $ user ) ; $ this -> om -> flush ( ) ; }
Persist the user entity .
45,979
public function canSetProperty ( $ name , $ checkVars = true ) { $ owner = $ this -> owner ; $ relation = $ owner -> getRelation ( $ name , false ) ; if ( in_array ( $ name , $ this -> _relations ) && ! is_null ( $ relation ) ) { return true ; } return parent :: canSetProperty ( $ name , $ checkVars ) ; }
Override canSetProperty method to be able to detect if a relation setter is allowed . Setter is allowed if the relation is declared in the relations parameter
45,980
protected function setSingleRelation ( $ relationName , $ value ) { $ owner = $ this -> owner ; $ relation = $ owner -> getRelation ( $ relationName ) ; if ( ! ( $ value instanceof $ relation -> modelClass ) ) { $ value = $ this -> processModelAsArray ( $ value , $ relation , $ relationName ) ; } $ this -> _newRelation...
Set the named single relation with the given value
45,981
protected function setMultipleRelation ( $ relationName , $ value ) { $ owner = $ this -> owner ; $ relation = $ owner -> getRelation ( $ relationName ) ; $ newRelations = [ ] ; if ( ! is_array ( $ value ) ) { if ( ! empty ( $ value ) ) { $ value = [ $ value ] ; } else { $ value = [ ] ; } } foreach ( $ value as $ entry...
Set the named multiple relation with the given value
45,982
private function _getRelatedFks ( $ data , $ relation , $ modelClass ) { $ fks = [ ] ; if ( is_array ( $ data ) ) { if ( $ relation -> via instanceof BaseActiveRecord ) { $ link = $ relation -> via -> link ; } elseif ( is_array ( $ relation -> via ) ) { list ( $ viaName , $ viaQuery ) = $ relation -> via ; $ link = $ v...
Get the related model foreign keys
45,983
private function _loadOrCreateRelationModel ( $ data , $ fks , $ modelClass , $ relationName ) { $ relationModel = null ; if ( ! empty ( $ fks ) ) { $ relationModel = $ modelClass :: findOne ( $ fks ) ; } if ( ! ( $ relationModel instanceof BaseActiveRecord ) && ! empty ( $ data ) ) { $ relationModel = new $ modelClass...
Load existing model or create one if no key was provided and data is not empty
45,984
protected function validateRelationModel ( $ prettyRelationName , $ relationName , BaseActiveRecord $ relationModel ) { $ model = $ this -> owner ; if ( ! is_null ( $ relationModel ) && ( $ relationModel -> isNewRecord || count ( $ relationModel -> getDirtyAttributes ( ) ) ) ) { Yii :: debug ( "Validating {$prettyRelat...
Validate a relation model and add an error message to owner model attribute if needed
45,985
private function _addError ( $ relationModel , $ owner , $ relationName , $ prettyRelationName ) { foreach ( $ relationModel -> errors as $ attribute => $ attributeErrors ) { foreach ( $ attributeErrors as $ error ) { $ owner -> addError ( $ relationName , "{$prettyRelationName}: {$error}" ) ; } } }
Attach errors to owner relational attributes
45,986
protected function _setRelationForeignKeys ( $ relationName ) { $ owner = $ this -> owner ; $ relation = $ owner -> getRelation ( $ relationName ) ; if ( $ relation -> multiple === false && ! empty ( $ owner -> { $ relationName } ) ) { Yii :: debug ( "Setting foreign keys for {$relationName}" , __METHOD__ ) ; foreach (...
Set relation foreign keys that point to owner primary key
45,987
private function _getJunctionTableColumns ( $ relationName , $ model ) { $ junctionTableColumns = [ ] ; if ( array_key_exists ( $ relationName , $ this -> _relationsExtraColumns ) ) { if ( is_callable ( $ this -> _relationsExtraColumns [ $ relationName ] ) ) { $ junctionTableColumns = $ this -> _relationsExtraColumns [...
Return array of columns to save to the junction table for a related model having a many - to - many relation .
45,988
private function _computePkDiff ( $ initialRelations , $ updatedRelations , $ forceSave = false ) { $ oldPks = ArrayHelper :: getColumn ( $ initialRelations , function ( BaseActiveRecord $ model ) { return implode ( '-' , $ model -> getPrimaryKey ( true ) ) ; } ) ; $ newPks = ArrayHelper :: getColumn ( $ updatedRelatio...
Compute the difference between two set of records using primary keys tokens If third parameter is set to true all initial related records will be marked for removal even if their properties did not change . This can be handy in a many - to - many relation_ involving a junction table .
45,989
public function beforeDelete ( ) { $ owner = $ this -> owner ; foreach ( $ this -> _relationsCascadeDelete as $ relationName => $ params ) { if ( $ params === true ) { $ relation = $ owner -> getRelation ( $ relationName ) ; if ( ! empty ( $ owner -> { $ relationName } ) ) { if ( $ relation -> multiple === true ) { $ t...
Get the list of owner model relations in order to be able to delete them after its deletion
45,990
public function afterDelete ( ) { foreach ( $ this -> _relationsToDelete as $ modelToDelete ) { try { if ( ! $ modelToDelete -> delete ( ) ) { throw new DbException ( 'Could not delete the related record: ' . $ modelToDelete :: className ( ) . '(' . VarDumper :: dumpAsString ( $ modelToDelete -> primaryKey ) . ')' ) ; ...
Delete related models marked as to be deleted
45,991
public function loadRelations ( $ data ) { $ owner = $ this -> owner ; foreach ( $ this -> _relations as $ relationName ) { $ keyName = $ this -> _getRelationKeyName ( $ relationName ) ; if ( array_key_exists ( $ keyName , $ data ) ) { $ owner -> { $ relationName } = $ data [ $ keyName ] ; } } }
Populates relations with input data
45,992
public function setRelationScenario ( $ relationName , $ scenario ) { $ owner = $ this -> owner ; $ relation = $ owner -> getRelation ( $ relationName , false ) ; if ( in_array ( $ relationName , $ this -> _relations ) && ! is_null ( $ relation ) ) { $ this -> _relationsScenario [ $ relationName ] = $ scenario ; } else...
Set the scenario for a given relation
45,993
public function getOldRelations ( ) { $ oldRelations = [ ] ; foreach ( $ this -> _relations as $ relationName ) { $ oldRelations [ $ relationName ] = $ this -> getOldRelation ( $ relationName ) ; } return $ oldRelations ; }
Return the old relations values .
45,994
public function getOldRelation ( $ relationName ) { return array_key_exists ( $ relationName , $ this -> _oldRelationValue ) ? $ this -> _oldRelationValue [ $ relationName ] : $ this -> owner -> { $ relationName } ; }
Returns the old value of the named relation .
45,995
public function getDirtyRelations ( ) { $ dirtyRelations = [ ] ; foreach ( $ this -> _relations as $ relationName ) { if ( array_key_exists ( $ relationName , $ this -> _oldRelationValue ) ) { $ dirtyRelations [ $ relationName ] = $ this -> owner -> { $ relationName } ; } } return $ dirtyRelations ; }
Returns the relations that have been modified since they are loaded .
45,996
public function markRelationDirty ( $ relationName ) { if ( in_array ( $ relationName , $ this -> _relations ) && ! array_key_exists ( $ relationName , $ this -> _oldRelationValue ) ) { $ this -> _oldRelationValue [ $ relationName ] = $ this -> owner -> { $ relationName } ; return true ; } return false ; }
Mark a relation as dirty
45,997
public function boot ( ) { if ( $ this -> booted ) { return ; } $ this -> booted = true ; foreach ( $ this -> providers as $ provider ) { if ( $ provider instanceof EventListenerProviderInterface ) { $ provider -> subscribe ( $ this , $ this [ 'dispatcher' ] ) ; } if ( $ provider instanceof BootableProviderInterface ) ...
Boots all service providers .
45,998
public function view ( $ callback , $ priority = 0 ) { $ this -> on ( KernelEvents :: VIEW , new ViewListenerWrapper ( $ this , $ callback ) , $ priority ) ; }
Registers a view handler .
45,999
public function escape ( $ text , $ flags = ENT_COMPAT , $ charset = null , $ doubleEncode = true ) { return htmlspecialchars ( $ text , $ flags , $ charset ? : $ this [ 'charset' ] , $ doubleEncode ) ; }
Escapes a text for HTML .