idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
8,500
public function saveToFile ( $ filePath ) { $ this -> adsUtilityRegistry -> addUtility ( AdsUtility :: REPORT_DOWNLOADER_FILE ) ; $ this -> reportDownloadResultDelegate -> saveToFile ( $ filePath ) ; }
Writes the contents of the report download response to the specified file .
8,501
public function fromFile ( $ path = null ) { if ( $ path === null ) { $ path = self :: DEFAULT_CONFIGURATION_FILENAME ; } return $ this -> from ( $ this -> configurationLoader -> fromFile ( $ path ) ) ; }
Reads configuration settings from the specified filepath . The filepath is optional and if omitted it will look for the default configuration filename in the home directory of the user running PHP .
8,502
public function waitForReportToFinish ( ) { $ reportJobStatus = $ this -> reportService -> getReportJobStatus ( $ this -> reportJobId ) ; while ( $ reportJobStatus === ReportJobStatus :: IN_PROGRESS ) { $ this -> logger -> info ( sprintf ( 'Report job ID %d has status %s. Sleeping for %d seconds ' . 'before polling again for report status.' , $ this -> reportJobId , $ reportJobStatus , $ this -> pollTimeSeconds ) ) ; sleep ( $ this -> pollTimeSeconds ) ; $ reportJobStatus = $ this -> reportService -> getReportJobStatus ( $ this -> reportJobId ) ; } return $ reportJobStatus === ReportJobStatus :: COMPLETED ; }
Blocks and waits for the report to finish running by polling for the report s status and sleeping in between polls .
8,503
public function downloadReport ( $ exportFormat , $ filePath = null ) { $ downloadUrl = $ this -> getDownloadUrl ( $ exportFormat ) ; $ requestOptions = [ ] ; $ requestOptions [ RequestOptions :: HEADERS ] = [ 'User-Agent' => $ this -> getFormattedUserAgent ( ) ] ; $ proxy = $ this -> reportService -> getAdsSession ( ) -> getConnectionSettings ( ) -> getProxyUrl ( ) ; if ( ! empty ( $ proxy ) ) { $ requestOptions [ RequestOptions :: PROXY ] = [ 'https' => $ proxy ] ; } if ( $ filePath !== null ) { $ requestOptions [ RequestOptions :: SINK ] = $ filePath ; $ this -> httpClient -> request ( 'GET' , $ downloadUrl , $ requestOptions ) ; } else { $ requestOptions [ RequestOptions :: STREAM ] = true ; $ response = $ this -> httpClient -> request ( 'GET' , $ downloadUrl , $ requestOptions ) ; return $ response -> getBody ( ) ; } }
Downloads the report with the specified export format .
8,504
private function getDownloadUrl ( $ exportFormat ) { $ reportJobStatus = $ this -> reportService -> getReportJobStatus ( $ this -> reportJobId ) ; if ( $ reportJobStatus === ReportJobStatus :: IN_PROGRESS ) { throw new UnexpectedValueException ( sprintf ( 'Report %d must be completed before downloading. ' . 'Report is still %s.' , $ this -> reportJobId , ReportJobStatus :: IN_PROGRESS ) ) ; } elseif ( $ reportJobStatus === ReportJobStatus :: FAILED ) { throw new UnexpectedValueException ( sprintf ( 'Cannot download report %d because it has a status of %s.' , $ this -> reportJobId , ReportJobStatus :: FAILED ) ) ; } return $ this -> reportService -> getReportDownloadURL ( $ this -> reportJobId , $ exportFormat ) ; }
Gets the download URL for the report .
8,505
public static function pass ( ) { if ( is_null ( self :: $ passedResult ) ) { self :: $ passedResult = new self ( true ) ; } return self :: $ passedResult ; }
Creates a validation pass result .
8,506
public static function getSoapHeaderValue ( $ xml , $ soapHeaderName ) { $ headerValue = '' ; if ( $ xml === null || $ xml === '' ) { return $ headerValue ; } $ xmlReader = new XMLReader ( ) ; $ xmlReader -> xml ( $ xml ) ; while ( $ xmlReader -> read ( ) ) { if ( $ xmlReader -> nodeType === XMLReader :: ELEMENT && $ xmlReader -> localName === $ soapHeaderName ) { $ xmlReader -> read ( ) ; $ headerValue = $ xmlReader -> value ; } elseif ( $ xmlReader -> nodeType === XMLReader :: END_ELEMENT && $ xmlReader -> localName === self :: $ SOAP_HEADER_NODE_NAME ) { break ; } } $ xmlReader -> close ( ) ; return $ headerValue ; }
Gets the value of the specified SOAP header from the specified SOAP request or response payload as an XML string .
8,507
public function formatDetailed ( RequestInterface $ request , ResponseInterface & $ response = null , Exception & $ error = null ) { $ needRewind = $ this -> shouldLogResponsePayload && ! is_null ( $ response ) && ! is_null ( $ response -> getBody ( ) ) ; if ( $ needRewind && ! $ response -> getBody ( ) -> isSeekable ( ) ) { $ response = $ response -> withBody ( new CachingStream ( $ response -> getBody ( ) ) ) ; if ( ! is_null ( $ error ) ) { $ error = RequestException :: create ( $ request , $ response , $ error ) ; } } $ detailedLog = $ this -> scrubAndFormatDetailedMessage ( $ request , $ response , $ error ) ; if ( $ needRewind ) { \ GuzzleHttp \ Psr7 \ rewind_body ( $ response ) ; } return $ detailedLog ; }
Formats a detailed message based on the specified HTTP request and response and errors if present . This function also replaces the original response with a new one with a seekable stream if the original one contains forward - only stream .
8,508
private function scrubAndFormatDetailedMessage ( RequestInterface $ request , ResponseInterface $ response = null , Exception $ error = null ) { $ requestHeaders = LogMessageScrubbers :: scrubHttpHeadersArray ( $ request -> getHeaders ( ) , $ this -> requestHttpHeadersToScrub ) ; $ changes = [ 'set_headers' => $ requestHeaders , 'body' => urldecode ( $ request -> getBody ( ) ) ] ; $ clonedRequest = \ GuzzleHttp \ Psr7 \ modify_request ( $ request , $ changes ) ; return $ this -> detailedMessageFormatter -> format ( $ clonedRequest , $ response , $ error ) ; }
Scrubs and formats a detailed message containing HTTP request and response and errors if exist .
8,509
public function mutate ( \ Google \ AdsApi \ AdWords \ v201809 \ mcm \ Customer $ customer ) { return $ this -> __soapCall ( 'mutate' , array ( array ( 'customer' => $ customer ) ) ) -> getRval ( ) ; }
Update the authorized customer .
8,510
public function generateHttpClient ( ) { $ config = $ this -> config ; if ( ! array_key_exists ( 'handler' , $ config ) || $ config [ 'handler' ] === null ) { $ config [ 'handler' ] = HandlerStack :: create ( ) ; } $ config [ 'handler' ] -> before ( 'http_errors' , GuzzleLogMessageHandler :: log ( $ this -> logger , $ this -> messageFormatter ) ) ; return new Client ( $ config ) ; }
Generates a Guzzle HTTP client for making HTTP calls by using configs of the user - provided client . This method adds the logging middleware required by this library to the handler stack of the generated client .
8,511
private static function createFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ feedService = $ adWordsServices -> get ( $ session , FeedService :: class ) ; $ urlAttribute = new FeedAttribute ( ) ; $ urlAttribute -> setType ( FeedAttributeType :: URL_LIST ) ; $ urlAttribute -> setName ( 'Page URL' ) ; $ labelAttribute = new FeedAttribute ( ) ; $ labelAttribute -> setType ( FeedAttributeType :: STRING_LIST ) ; $ labelAttribute -> setName ( 'Label' ) ; $ dsaPageFeed = new Feed ( ) ; $ dsaPageFeed -> setName ( 'DSA Feed #' . uniqid ( ) ) ; $ dsaPageFeed -> setAttributes ( [ $ urlAttribute , $ labelAttribute ] ) ; $ dsaPageFeed -> setOrigin ( FeedOrigin :: USER ) ; $ operation = new FeedOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ dsaPageFeed ) ; $ result = $ feedService -> mutate ( [ $ operation ] ) ; $ feedDetails = new DSAFeedDetails ( ) ; $ savedFeed = $ result -> getValue ( ) [ 0 ] ; $ feedDetails -> feedId = $ savedFeed -> getId ( ) ; $ savedAttributes = $ savedFeed -> getAttributes ( ) ; $ feedDetails -> urlAttributeId = $ savedAttributes [ 0 ] -> getId ( ) ; $ feedDetails -> labelAttributeId = $ savedAttributes [ 1 ] -> getId ( ) ; printf ( "Feed with name '%s', ID %d with urlAttributeId %d and labelAttributeId %d was created.\n" , $ savedFeed -> getName ( ) , $ feedDetails -> feedId , $ feedDetails -> urlAttributeId , $ feedDetails -> labelAttributeId ) ; return $ feedDetails ; }
Creates the feed for DSA page URLs .
8,512
private static function createFeedMapping ( AdWordsServices $ adWordsServices , AdWordsSession $ session , DSAFeedDetails $ feedDetails ) { $ feedMappingService = $ adWordsServices -> get ( $ session , FeedMappingService :: class ) ; $ urlFieldMapping = new AttributeFieldMapping ( ) ; $ urlFieldMapping -> setFeedAttributeId ( $ feedDetails -> urlAttributeId ) ; $ urlFieldMapping -> setFieldId ( self :: DSA_PAGE_URLS_FIELD_ID ) ; $ labelFieldMapping = new AttributeFieldMapping ( ) ; $ labelFieldMapping -> setFeedAttributeId ( $ feedDetails -> labelAttributeId ) ; $ labelFieldMapping -> setFieldId ( self :: DSA_LABEL_FIELD_ID ) ; $ feedMapping = new FeedMapping ( ) ; $ feedMapping -> setCriterionType ( self :: DSA_PAGE_FEED_CRITERION_TYPE ) ; $ feedMapping -> setFeedId ( $ feedDetails -> feedId ) ; $ feedMapping -> setAttributeFieldMappings ( [ $ urlFieldMapping , $ labelFieldMapping ] ) ; $ operation = new FeedMappingOperation ( ) ; $ operation -> setOperand ( $ feedMapping ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ feedMappingService -> mutate ( [ $ operation ] ) ; $ feedMapping = $ result -> getValue ( ) [ 0 ] ; printf ( "Feed mapping with ID %d and criterion type %d was saved for feed with ID %d.\n" , $ feedMapping -> getFeedMappingId ( ) , $ feedMapping -> getCriterionType ( ) , $ feedMapping -> getFeedId ( ) ) ; }
Creates the feed mapping for the DSA page feeds .
8,513
private static function createFeedItems ( AdWordsServices $ adWordsServices , AdWordsSession $ session , DSAFeedDetails $ feedDetails , $ labelName ) { $ feedItemService = $ adWordsServices -> get ( $ session , FeedItemService :: class ) ; $ rentalCars = self :: createDsaUrlAddOperation ( $ feedDetails , 'http://www.example.com/discounts/rental-cars' , $ labelName ) ; $ hotelDeals = self :: createDsaUrlAddOperation ( $ feedDetails , 'http://www.example.com/discounts/hotel-deals' , $ labelName ) ; $ flightDeals = self :: createDsaUrlAddOperation ( $ feedDetails , 'http://www.example.com/discounts/flight-deals' , $ labelName ) ; $ result = $ feedItemService -> mutate ( [ $ rentalCars , $ hotelDeals , $ flightDeals ] ) ; foreach ( $ result -> getValue ( ) as $ feedItem ) { printf ( "Feed item with feed item ID %d was added.\n" , $ feedItem -> getFeedItemId ( ) ) ; } }
Creates the page URLs in the DSA page feed .
8,514
private static function createDsaUrlAddOperation ( DSAFeedDetails $ feedDetails , $ url , $ labelName ) { $ urlAttributeValue = new FeedItemAttributeValue ( ) ; $ urlAttributeValue -> setFeedAttributeId ( $ feedDetails -> urlAttributeId ) ; $ urlAttributeValue -> setStringValues ( [ $ url ] ) ; $ labelAttributeValue = new FeedItemAttributeValue ( ) ; $ labelAttributeValue -> setFeedAttributeId ( $ feedDetails -> labelAttributeId ) ; $ labelAttributeValue -> setStringValues ( [ $ labelName ] ) ; $ feedItem = new FeedItem ( ) ; $ feedItem -> setFeedId ( $ feedDetails -> feedId ) ; $ feedItem -> setAttributeValues ( [ $ urlAttributeValue , $ labelAttributeValue ] ) ; $ operation = new FeedItemOperation ( ) ; $ operation -> setOperand ( $ feedItem ) ; $ operation -> setOperator ( Operator :: ADD ) ; return $ operation ; }
Creates a feed item operation to add the DSA URL .
8,515
private static function updateCampaignDsaSetting ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ campaignId , DSAFeedDetails $ feedDetails ) { $ campaignService = $ adWordsServices -> get ( $ session , CampaignService :: class ) ; $ selector = new Selector ( ) ; $ selector -> setFields ( [ 'Id' , 'Settings' ] ) ; $ selector -> setPredicates ( [ new Predicate ( 'CampaignId' , PredicateOperator :: IN , [ $ campaignId ] ) ] ) ; $ result = $ campaignService -> get ( $ selector ) ; if ( empty ( $ result -> getEntries ( ) ) || $ result -> getTotalNumEntries ( ) === 0 ) { throw new InvalidArgumentException ( 'No campaign found with ID: ' . $ campaignId ) ; } $ campaign = $ result -> getEntries ( ) [ 0 ] ; if ( $ campaign -> getSettings ( ) === null ) { throw new InvalidArgumentException ( 'Campaign with ID ' . $ campaignId . ' is not a DSA campaign.' ) ; } $ dsaSetting = null ; foreach ( $ campaign -> getSettings ( ) as $ setting ) { if ( $ setting instanceof DynamicSearchAdsSetting ) { $ dsaSetting = $ setting ; break ; } } if ( $ dsaSetting === null ) { throw new InvalidArgumentException ( 'Campaign with ID ' . $ campaignId . ' is not a DSA campaign.' ) ; } $ pageFeed = new PageFeed ( ) ; $ pageFeed -> setFeedIds ( [ $ feedDetails -> feedId ] ) ; $ dsaSetting -> setPageFeed ( $ pageFeed ) ; $ dsaSetting -> setUseSuppliedUrlsOnly ( true ) ; $ updatedCampaign = new Campaign ( ) ; $ updatedCampaign -> setId ( $ campaignId ) ; $ updatedCampaign -> setSettings ( $ campaign -> getSettings ( ) ) ; $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ updatedCampaign ) ; $ operation -> setOperator ( Operator :: SET ) ; $ result = $ campaignService -> mutate ( [ $ operation ] ) ; $ updatedCampaign = $ result -> getValue ( ) [ 0 ] ; printf ( "DSA page feed for campaign ID %d was updated with feed ID %d.\n" , $ updatedCampaign -> getId ( ) , $ feedDetails -> feedId ) ; }
Updates the campaign DSA setting to add DSA pagefeeds .
8,516
private static function addDsaTargeting ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId , $ dsaPageUrlLabel ) { $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; $ webpage = new Webpage ( ) ; $ parameter = new WebpageParameter ( ) ; $ parameter -> setCriterionName ( 'Test criterion' ) ; $ webpage -> setParameter ( $ parameter ) ; $ condition = new WebpageCondition ( ) ; $ condition -> setOperand ( WebpageConditionOperand :: CUSTOM_LABEL ) ; $ condition -> setArgument ( $ dsaPageUrlLabel ) ; $ parameter -> setConditions ( [ $ condition ] ) ; $ criterion = new BiddableAdGroupCriterion ( ) ; $ criterion -> setAdGroupId ( $ adGroupId ) ; $ criterion -> setCriterion ( $ webpage ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ cpcBid = new CpcBid ( ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 1500000 ) ; $ cpcBid -> setBid ( $ money ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ criterion -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ operation = new AdGroupCriterionOperation ( ) ; $ operation -> setOperand ( $ criterion ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ adGroupCriterionService -> mutate ( [ $ operation ] ) ; $ criterion = $ result -> getValue ( ) [ 0 ] ; printf ( "Web page criterion with ID %d and status '%s' was created.\n" , $ criterion -> getCriterion ( ) -> getId ( ) , $ criterion -> getUserStatus ( ) ) ; }
Sets custom targeting for the page feed URLs based on a list of labels .
8,517
private static function getAllManagedCustomerIds ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ managedCustomerService = $ adWordsServices -> get ( $ session , ManagedCustomerService :: class ) ; $ selector = new Selector ( ) ; $ selector -> setFields ( [ 'CustomerId' ] ) ; $ selector -> setPaging ( new Paging ( 0 , self :: PAGE_LIMIT ) ) ; $ selector -> setPredicates ( [ new Predicate ( 'CanManageClients' , PredicateOperator :: EQUALS , [ 'false' ] ) ] ) ; $ customerIds = [ ] ; $ totalNumEntries = 0 ; do { $ page = $ managedCustomerService -> get ( $ selector ) ; if ( $ page -> getEntries ( ) !== null ) { $ totalNumEntries = $ page -> getTotalNumEntries ( ) ; foreach ( $ page -> getEntries ( ) as $ customer ) { $ customerIds [ ] = $ customer -> getCustomerId ( ) ; } } $ selector -> getPaging ( ) -> setStartIndex ( $ selector -> getPaging ( ) -> getStartIndex ( ) + self :: PAGE_LIMIT ) ; } while ( $ selector -> getPaging ( ) -> getStartIndex ( ) < $ totalNumEntries ) ; return $ customerIds ; }
Retrieves all the customer IDs under a manager account .
8,518
public function formatDetailed ( $ requestHeaders , $ request , $ responseHeaders , $ response ) { $ requestHeaders = LogMessageScrubbers :: scrubRequestHttpHeaders ( trim ( $ requestHeaders ) , $ this -> requestHttpHeadersToScrub ) ; $ request = LogMessageScrubbers :: scrubRequestSoapHeaders ( $ request , $ this -> requestSoapHeadersToScrub ) ; $ request = LogMessageScrubbers :: scrubRequestSoapBodyTags ( $ request , $ this -> requestSoapBodyTagsToScrub ) ; $ responseHeaders = trim ( $ responseHeaders ) ; return sprintf ( "%s\n\n%s\n%s\n\n%s\n" , $ requestHeaders , $ request , $ responseHeaders , $ response ) ; }
Formats this log message as a detailed message containing full SOAP XML request and response payloads along with their HTTP headers .
8,519
private function formatSoapFaultForSummary ( $ soapFault ) { $ soapFault = str_replace ( [ "\r\n" , "\n" , "\r" ] , '' , $ soapFault ) ; if ( mb_strlen ( $ soapFault , 'UTF-8' ) > $ this -> faultMsgMaxLength ) { $ soapFault = mb_substr ( $ soapFault , 0 , $ this -> faultMsgMaxLength , 'UTF-8' ) . '...' ; } ; return $ soapFault ; }
Removes line breaks and truncates the SOAP fault if necessary .
8,520
public function createInstance ( $ className , $ args = null ) { $ reflectionClass = new ReflectionClass ( $ className ) ; $ args = func_get_args ( ) ; array_shift ( $ args ) ; return $ reflectionClass -> newInstanceArgs ( $ args ) ; }
Creates a new instance of the specified class name .
8,521
private static function createAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , Campaign $ campaign ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; $ adGroup = new AdGroup ( ) ; $ adGroup -> setCampaignId ( $ campaign -> getId ( ) ) ; $ adGroup -> setName ( 'Dynamic remarketing ad group #' . uniqid ( ) ) ; $ adGroup -> setStatus ( AdGroupStatus :: ENABLED ) ; $ adGroupOperation = new AdGroupOperation ( ) ; $ adGroupOperation -> setOperand ( $ adGroup ) ; $ adGroupOperation -> setOperator ( Operator :: ADD ) ; $ adGroupAddResult = $ adGroupService -> mutate ( [ $ adGroupOperation ] ) ; $ adGroup = $ adGroupAddResult -> getValue ( ) [ 0 ] ; return $ adGroup ; }
Creates an ad group in the specified campaign .
8,522
private static function attachUserList ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup , $ userListId ) { $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; $ userList = new CriterionUserList ( ) ; $ userList -> setUserListId ( $ userListId ) ; $ adGroupCriterion = new BiddableAdGroupCriterion ( ) ; $ adGroupCriterion -> setCriterion ( $ userList ) ; $ adGroupCriterion -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ adGroupCriterionOperation = new AdGroupCriterionOperation ( ) ; $ adGroupCriterionOperation -> setOperand ( $ adGroupCriterion ) ; $ adGroupCriterionOperation -> setOperator ( Operator :: ADD ) ; $ adGroupCriterionAddResult = $ adGroupCriterionService -> mutate ( [ $ adGroupCriterionOperation ] ) ; $ adGroupCriterion = $ adGroupCriterionAddResult -> getValue ( ) [ 0 ] ; return $ adGroupCriterion ; }
Attaches a user list to an ad group . The user list provides positive targeting and feed information to drive the dynamic content of the ad .
8,523
private static function createAd ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; $ responsiveDisplayAd = new ResponsiveDisplayAd ( ) ; $ marketingImage = self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/3b9Wfh' ) ; $ responsiveDisplayAd -> setMarketingImage ( $ marketingImage ) ; $ responsiveDisplayAd -> setShortHeadline ( 'Travel' ) ; $ responsiveDisplayAd -> setLongHeadline ( 'Travel the World.' ) ; $ responsiveDisplayAd -> setDescription ( 'Take to the air!' ) ; $ responsiveDisplayAd -> setBusinessName ( 'Interplanetary Cruises' ) ; $ responsiveDisplayAd -> setFinalUrls ( [ 'http://www.example.com' ] ) ; $ responsiveDisplayAd -> setCallToActionText ( 'Apply Now' ) ; $ dynamicDisplayAdSettings = self :: createDynamicDisplayAdSettings ( $ adWordsServices , $ session ) ; $ responsiveDisplayAd -> setDynamicDisplayAdSettings ( $ dynamicDisplayAdSettings ) ; $ squareMarketingImage = self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/mtt54n' ) ; $ responsiveDisplayAd -> setSquareMarketingImage ( $ squareMarketingImage ) ; $ logoImage = self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/mtt54n' ) ; $ responsiveDisplayAd -> setLogoImage ( $ logoImage ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ adGroupAd -> setAd ( $ responsiveDisplayAd ) ; $ adGroupAdOperation = new AdGroupAdOperation ( ) ; $ adGroupAdOperation -> setOperand ( $ adGroupAd ) ; $ adGroupAdOperation -> setOperator ( Operator :: ADD ) ; $ adGroupAdAddResult = $ adGroupAdService -> mutate ( [ $ adGroupAdOperation ] ) ; $ adGroupAd = $ adGroupAdAddResult -> getValue ( ) [ 0 ] ; return $ adGroupAd ; }
Creates an ad for serving dynamic content in a remarketing campaign .
8,524
private static function createDynamicDisplayAdSettings ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ landscapeLogoImage = self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/dEvQeF' ) ; $ dynamicSettings = new DynamicSettings ( ) ; $ dynamicSettings -> setLandscapeLogoImage ( $ landscapeLogoImage ) ; $ dynamicSettings -> setPricePrefix ( 'as low as' ) ; $ dynamicSettings -> setPromoText ( 'Free shipping!' ) ; return $ dynamicSettings ; }
Creates dynamic display ad settings .
8,525
public static function log ( LoggerInterface $ logger , GuzzleLogMessageFormatter $ messageFormatter ) { return function ( callable $ handler ) use ( $ logger , $ messageFormatter ) { return function ( $ request , array $ options ) use ( $ handler , $ logger , $ messageFormatter ) { return $ handler ( $ request , $ options ) -> then ( function ( $ response ) use ( $ request , $ logger , $ messageFormatter ) { $ logger -> info ( $ messageFormatter -> formatSummary ( $ request , $ response ) ) ; if ( ! ( $ logger instanceof Logger ) || $ logger -> isHandling ( Logger :: DEBUG ) ) { $ logger -> debug ( $ messageFormatter -> formatDetailed ( $ request , $ response ) ) ; } return $ response ; } , function ( $ reason ) use ( $ request , $ logger , $ messageFormatter ) { $ response = is_subclass_of ( $ reason , 'GuzzleHttp\Exception\RequestException' ) ? $ reason -> getResponse ( ) : null ; $ logger -> warning ( $ messageFormatter -> formatSummary ( $ request , $ response ) ) ; if ( ! ( $ logger instanceof Logger ) || $ logger -> isHandling ( Logger :: NOTICE ) ) { $ logger -> notice ( $ messageFormatter -> formatDetailed ( $ request , $ response , $ reason ) ) ; } return \ GuzzleHttp \ Promise \ rejection_for ( $ reason ) ; } ) ; } ; } ; }
Logs requests and responses for Guzzle HTTP calls to non - SOAP ads API endpoints to the specified logger .
8,526
private static function createPriceTableRow ( $ header , $ description , $ finalUrl , $ priceInMicros , $ currencyCode , $ priceUnit , $ finalMobileUrl = null ) { $ priceTableRow = new PriceTableRow ( ) ; $ priceTableRow -> setHeader ( $ header ) ; $ priceTableRow -> setDescription ( $ description ) ; $ priceTableRow -> setFinalUrls ( new UrlList ( [ $ finalUrl ] ) ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( $ priceInMicros ) ; $ moneyWithCurrency = new MoneyWithCurrency ( ) ; $ moneyWithCurrency -> setMoney ( $ money ) ; $ moneyWithCurrency -> setCurrencyCode ( $ currencyCode ) ; $ priceTableRow -> setPrice ( $ moneyWithCurrency ) ; $ priceTableRow -> setPriceUnit ( $ priceUnit ) ; if ( $ finalMobileUrl !== null ) { $ priceTableRow -> setFinalMobileUrls ( new UrlList ( [ $ finalMobileUrl ] ) ) ; } return $ priceTableRow ; }
Creates a new price table row with the specified attributes .
8,527
public function updateNetwork ( \ Google \ AdsApi \ AdManager \ v201808 \ Network $ network ) { return $ this -> __soapCall ( 'updateNetwork' , array ( array ( 'network' => $ network ) ) ) -> getRval ( ) ; }
Updates the specified network . Currently only the network display name can be updated .
8,528
public static function copyFrom ( ExpressionBuilder $ otherInstance ) { $ copyingInstance = new self ( $ otherInstance -> fieldName ) ; $ copyingInstance -> simpleOperator = $ otherInstance -> simpleOperator ; $ copyingInstance -> simpleValue = $ otherInstance -> simpleValue ; $ copyingInstance -> listOperator = $ otherInstance -> listOperator ; $ copyingInstance -> listValues = $ otherInstance -> listValues ; return $ copyingInstance ; }
Creates a new expression builder object by copying the operands and operators from another expression builder object .
8,529
private function setSimpleOperator ( $ operator , $ value ) { if ( empty ( $ operator ) ) { throw new InvalidArgumentException ( 'The operator must not be null' . ' or empty.' ) ; } if ( is_null ( $ value ) || $ value === '' ) { throw new InvalidArgumentException ( 'The value string must not be' . ' null or empty' ) ; } $ this -> simpleOperator = $ operator ; $ this -> simpleValue = $ value ; }
Sets an operator and a single value that follows the operator .
8,530
private static function formatValue ( $ value ) { if ( is_numeric ( $ value ) && ! is_string ( $ value ) ) { return $ value ; } return sprintf ( '\'%s\'' , addslashes ( $ value ) ) ; }
If the input value is not numeric escape all quotes then wrap the string in a pair of quotes .
8,531
private static function formatValues ( $ listValues ) { $ formattedValues = [ ] ; foreach ( $ listValues as $ value ) { $ formattedValues [ ] = self :: formatValue ( $ value ) ; } return $ formattedValues ; }
Formats each individual value in an array .
8,532
private function setListOperator ( $ listOperator , array $ values ) { if ( empty ( $ listOperator ) ) { throw new InvalidArgumentException ( 'The list operator must not' . ' be null or empty.' ) ; } if ( empty ( $ values ) ) { throw new InvalidArgumentException ( 'The list of values must not' . ' be null or empty.' ) ; } $ this -> listOperator = $ listOperator ; $ this -> listValues = $ values ; }
Sets the list operator and values ; Also adds quotes to string values .
8,533
public function buildExpression ( ) { if ( isset ( $ this -> simpleOperator ) ) { return sprintf ( '%s %s %s' , $ this -> fieldName , $ this -> simpleOperator , self :: formatValue ( $ this -> simpleValue ) ) ; } if ( isset ( $ this -> listOperator ) ) { return sprintf ( '%s %s [%s]' , $ this -> fieldName , $ this -> listOperator , implode ( ', ' , self :: formatValues ( $ this -> listValues ) ) ) ; } throw new BadFunctionCallException ( 'An operator must be set' . ' prior to calling this function.' ) ; }
Builds a logic expression in the WHERE clause of an AWQL string .
8,534
private static function createUserListRule ( ) { $ checkoutStringRuleItem = new StringRuleItem ( ) ; $ checkoutStringKey = new StringKey ( ) ; $ checkoutStringKey -> setName ( 'ecomm_pagetype' ) ; $ checkoutStringRuleItem -> setKey ( $ checkoutStringKey ) ; $ checkoutStringRuleItem -> setOp ( StringRuleItemStringOperator :: EQUALS ) ; $ checkoutStringRuleItem -> setValue ( 'checkout' ) ; $ checkoutRuleItem = new RuleItem ( ) ; $ checkoutRuleItem -> setStringRuleItem ( $ checkoutStringRuleItem ) ; $ cartSizeNumberRuleItem = new NumberRuleItem ( ) ; $ cartSizeNumberKey = new NumberKey ( ) ; $ cartSizeNumberKey -> setName ( 'cartsize' ) ; $ cartSizeNumberRuleItem -> setKey ( $ cartSizeNumberKey ) ; $ cartSizeNumberRuleItem -> setOp ( NumberRuleItemNumberOperator :: GREATER_THAN ) ; $ cartSizeNumberRuleItem -> setValue ( 1.0 ) ; $ cartSizeRuleItem = new RuleItem ( ) ; $ cartSizeRuleItem -> setNumberRuleItem ( $ cartSizeNumberRuleItem ) ; $ checkoutMultipleItemGroup = new RuleItemGroup ( ) ; $ checkoutMultipleItemGroup -> setItems ( [ $ checkoutRuleItem , $ cartSizeRuleItem ] ) ; $ today = new DateTime ( ) ; $ startDateDateRuleItem = new DateRuleItem ( ) ; $ startDateDateKey = new DateKey ( ) ; $ startDateDateKey -> setName ( 'checkoutdate' ) ; $ startDateDateRuleItem -> setKey ( $ startDateDateKey ) ; $ startDateDateRuleItem -> setOp ( DateRuleItemDateOperator :: AFTER ) ; $ startDateDateRuleItem -> setValue ( $ today -> format ( 'Ymd' ) ) ; $ startDateRuleItem = new RuleItem ( ) ; $ startDateRuleItem -> setDateRuleItem ( $ startDateDateRuleItem ) ; $ threeMonthsLater = new DateTime ( '+3 month' ) ; $ endDateDateRuleItem = new DateRuleItem ( ) ; $ endDateDateKey = new DateKey ( ) ; $ endDateDateKey -> setName ( 'checkoutdate' ) ; $ endDateDateRuleItem -> setKey ( $ endDateDateKey ) ; $ endDateDateRuleItem -> setOp ( DateRuleItemDateOperator :: BEFORE ) ; $ endDateDateRuleItem -> setValue ( $ threeMonthsLater -> format ( 'Ymd' ) ) ; $ endDateRuleItem = new RuleItem ( ) ; $ endDateRuleItem -> setDateRuleItem ( $ endDateDateRuleItem ) ; $ checkedOutDateRangeItemGroup = new RuleItemGroup ( ) ; $ checkedOutDateRangeItemGroup -> setItems ( [ $ startDateRuleItem , $ endDateRuleItem ] ) ; $ rule = new Rule ( ) ; $ rule -> setGroups ( [ $ checkoutMultipleItemGroup , $ checkedOutDateRangeItemGroup ] ) ; $ rule -> setRuleType ( UserListRuleTypeEnumsEnum :: DNF ) ; return $ rule ; }
Create a user list rule composed of two rule item groups .
8,535
private static function createCombinedUserListRules ( ) { $ site1StringRuleItem = new StringRuleItem ( ) ; $ site1StringKey = new StringKey ( ) ; $ site1StringKey -> setName ( 'url__' ) ; $ site1StringRuleItem -> setKey ( $ site1StringKey ) ; $ site1StringRuleItem -> setOp ( StringRuleItemStringOperator :: EQUALS ) ; $ site1StringRuleItem -> setValue ( 'example.com/example1' ) ; $ site1RuleItem = new RuleItem ( ) ; $ site1RuleItem -> setStringRuleItem ( $ site1StringRuleItem ) ; $ site2StringRuleItem = new StringRuleItem ( ) ; $ site2StringKey = new StringKey ( ) ; $ site2StringKey -> setName ( 'url__' ) ; $ site2StringRuleItem -> setKey ( $ site2StringKey ) ; $ site2StringRuleItem -> setOp ( StringRuleItemStringOperator :: EQUALS ) ; $ site2StringRuleItem -> setValue ( 'example.com/example2' ) ; $ site2RuleItem = new RuleItem ( ) ; $ site2RuleItem -> setStringRuleItem ( $ site2StringRuleItem ) ; $ site1ItemGroup = new RuleItemGroup ( ) ; $ site1ItemGroup -> setItems ( [ $ site1RuleItem ] ) ; $ site2ItemGroup = new RuleItemGroup ( ) ; $ site2ItemGroup -> setItems ( [ $ site2RuleItem ] ) ; $ userVisitedSite1Rule = new Rule ( ) ; $ userVisitedSite1Rule -> setGroups ( [ $ site1ItemGroup ] ) ; $ userVisitedSite2Rule = new Rule ( ) ; $ userVisitedSite2Rule -> setGroups ( [ $ site2ItemGroup ] ) ; return [ $ userVisitedSite1Rule , $ userVisitedSite2Rule ] ; }
Create rules to be used as left and right operands of a combined user list .
8,536
public static function asBiddableAdGroupCriterion ( $ adGroupId , ProductPartition $ productPartition , $ bidAmount = null ) { $ criterion = new BiddableAdGroupCriterion ( ) ; if ( $ bidAmount !== null && $ bidAmount > 0 ) { $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ cpcBid = new CpcBid ( ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( $ bidAmount ) ; $ cpcBid -> setBid ( $ money ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ criterion -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; } $ criterion -> setAdGroupId ( $ adGroupId ) ; $ criterion -> setCriterion ( $ productPartition ) ; return $ criterion ; }
Returns the biddable ad group criterion with by specifying the product partition and bid amount .
8,537
public static function asNegativeAdGroupCriterion ( $ adGroupId , ProductPartition $ productPartition ) { $ criterion = new NegativeAdGroupCriterion ( ) ; $ criterion -> setAdGroupId ( $ adGroupId ) ; $ criterion -> setCriterion ( $ productPartition ) ; return $ criterion ; }
Returns the negative ad group criterion with by specifying the product partition .
8,538
private static function createAdGroupCriterionOperation ( AdGroupCriterion $ criterion , $ operator ) { $ operation = new AdGroupCriterionOperation ( ) ; $ operation -> setOperand ( $ criterion ) ; $ operation -> setOperator ( $ operator ) ; return $ operation ; }
Creates an ad group criterion operation for the given ad group criterion .
8,539
public static function showAdGroupTree ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; $ children = [ ] ; $ rootNode = null ; $ totalNumEntries = 0 ; $ offset = 0 ; do { $ query = sprintf ( 'SELECT AdGroupId, Id, ParentCriterionId, CaseValue, PartitionType' . ' WHERE AdGroupId = %s AND CriteriaType = PRODUCT_PARTITION' . ' AND Status IN [ENABLED, PAUSED]' , $ adGroupId ) ; $ page = $ adGroupCriterionService -> query ( $ query ) ; if ( $ page -> getEntries ( ) !== null ) { $ totalNumEntries = $ page -> getTotalNumEntries ( ) ; foreach ( $ page -> getEntries ( ) as $ adGroupCriterion ) { $ criterionId = $ adGroupCriterion -> getCriterion ( ) -> getId ( ) ; if ( ! array_key_exists ( $ criterionId , $ children ) ) { $ children [ $ criterionId ] = [ ] ; } if ( $ adGroupCriterion -> getCriterion ( ) -> getParentCriterionId ( ) !== null ) { $ parentCriterionId = $ adGroupCriterion -> getCriterion ( ) -> getParentCriterionId ( ) ; $ children [ $ parentCriterionId ] [ ] = $ adGroupCriterion -> getCriterion ( ) ; } else { $ rootNode = $ adGroupCriterion -> getCriterion ( ) ; } } } $ offset += self :: PAGE_LIMIT ; } while ( $ offset < $ totalNumEntries ) ; if ( $ rootNode === null ) { return 'Empty tree' ; } return self :: traverseTree ( $ rootNode , $ children , 0 ) ; }
Returns the string representation of ad group criteria of the specified ad group ID by showing them hierarchically .
8,540
private static function traverseTree ( Criterion $ node , array $ children , $ level ) { $ type = 'n/a' ; $ value = 'n/a' ; if ( $ node -> getCaseValue ( ) !== null ) { $ type = ( new ReflectionClass ( $ node -> getCaseValue ( ) ) ) -> getShortName ( ) ; if ( $ node -> getCaseValue ( ) instanceof ProductCanonicalCondition ) { $ value = $ node -> getCaseValue ( ) -> getCondition ( ) ; } elseif ( $ node -> getCaseValue ( ) instanceof ProductBiddingCategory ) { $ value = sprintf ( '%s (%s)' , $ node -> getCaseValue ( ) -> getType ( ) , $ node -> getCaseValue ( ) -> getValue ( ) ) ; } else { $ value = $ node -> getCaseValue ( ) -> getValue ( ) ; } } $ result = sprintf ( "%sID: %d, type: %s, value: %s\n" , str_repeat ( " " , $ level ) , $ node -> getId ( ) , $ type , $ value ) ; foreach ( $ children [ $ node -> getId ( ) ] as $ childNode ) { $ result .= self :: traverseTree ( $ childNode , $ children , $ level + 1 ) ; } return $ result ; }
Recursively traverses this tree and returns its string representation .
8,541
public function getOrFetchAccessToken ( FetchAuthTokenInterface $ fetchAuthTokenInterface , callable $ httpHandler = null ) { if ( $ this -> shouldFetchAccessToken ( $ fetchAuthTokenInterface ) ) { return $ fetchAuthTokenInterface -> fetchAuthToken ( $ httpHandler ) [ 'access_token' ] ; } return $ fetchAuthTokenInterface -> getLastReceivedToken ( ) [ 'access_token' ] ; }
Gets the existing access token or fetches a new one if an existing one is about to expire within the refresh window or fetches a new one if there is no existing access token .
8,542
private static function getPredefinedCustomTargetingKeyIds ( ServiceFactory $ serviceFactory , AdManagerSession $ session ) { $ customTargetingKeyIds = [ ] ; $ customTargetingService = $ serviceFactory -> createCustomTargetingService ( $ session ) ; $ pageSize = StatementBuilder :: SUGGESTED_PAGE_LIMIT ; $ statementBuilder = ( new StatementBuilder ( ) ) -> where ( 'type = :type' ) -> orderBy ( 'id ASC' ) -> limit ( $ pageSize ) -> withBindVariableValue ( 'type' , CustomTargetingKeyType :: PREDEFINED ) ; $ totalResultSetSize = 0 ; do { $ page = $ customTargetingService -> getCustomTargetingKeysByStatement ( $ statementBuilder -> toStatement ( ) ) ; if ( $ page -> getResults ( ) !== null ) { $ totalResultSetSize = $ page -> getTotalResultSetSize ( ) ; $ i = $ page -> getStartIndex ( ) ; foreach ( $ page -> getResults ( ) as $ customTargetingKey ) { printf ( "%d) Custom targeting key with ID %d, name '%s', and" . " display name '%s' was found.%s" , $ i ++ , $ customTargetingKey -> getId ( ) , $ customTargetingKey -> getName ( ) , $ customTargetingKey -> getDisplayName ( ) , PHP_EOL ) ; $ customTargetingKeyIds [ ] = $ customTargetingKey -> getId ( ) ; } } $ statementBuilder -> increaseOffsetBy ( $ pageSize ) ; } while ( $ statementBuilder -> getOffset ( ) < $ totalResultSetSize ) ; printf ( "Number of keys found: %d%s%s" , $ totalResultSetSize , PHP_EOL , PHP_EOL ) ; return $ customTargetingKeyIds ; }
Gets predefined custom targeting key IDs .
8,543
private static function createAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , Campaign $ campaign ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; $ adGroup = new AdGroup ( ) ; $ adGroup -> setCampaignId ( $ campaign -> getId ( ) ) ; $ adGroup -> setName ( 'Ad Group #' . uniqid ( ) ) ; $ adGroup -> setAdGroupType ( AdGroupType :: SHOPPING_SHOWCASE_ADS ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ bidAmount = new Money ( ) ; $ bidAmount -> setMicroAmount ( 100000 ) ; $ cpcBid = new CpcBid ( ) ; $ cpcBid -> setBid ( $ bidAmount ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ adGroup -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ adGroupOperation = new AdGroupOperation ( ) ; $ adGroupOperation -> setOperand ( $ adGroup ) ; $ adGroupOperation -> setOperator ( Operator :: ADD ) ; $ adGroupAddResult = $ adGroupService -> mutate ( [ $ adGroupOperation ] ) ; $ adGroup = $ adGroupAddResult -> getValue ( ) [ 0 ] ; return $ adGroup ; }
Creates an ad group in the Shopping campaign .
8,544
private static function createShowcaseAd ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; $ showcaseAd = new ShowcaseAd ( ) ; $ showcaseAd -> setName ( 'Showcase ad #' . uniqid ( ) ) ; $ showcaseAd -> setFinalUrls ( [ 'http://example.com/showcase' ] ) ; $ showcaseAd -> setDisplayUrl ( 'example.com' ) ; $ expandedImage = new Image ( ) ; $ expandedImage -> setMediaId ( self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/IfVlpF' ) ) ; $ showcaseAd -> setExpandedImage ( $ expandedImage ) ; $ collapsedImage = new Image ( ) ; $ collapsedImage -> setMediaId ( self :: uploadImage ( $ adWordsServices , $ session , 'https://goo.gl/NqTxAE' ) ) ; $ showcaseAd -> setCollapsedImage ( $ collapsedImage ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ adGroupAd -> setAd ( $ showcaseAd ) ; $ adGroupAdOperation = new AdGroupAdOperation ( ) ; $ adGroupAdOperation -> setOperand ( $ adGroupAd ) ; $ adGroupAdOperation -> setOperator ( Operator :: ADD ) ; $ adGroupAdAddResult = $ adGroupAdService -> mutate ( [ $ adGroupAdOperation ] ) ; $ adGroupAd = $ adGroupAdAddResult -> getValue ( ) [ 0 ] ; return $ adGroupAd ; }
Creates a Showcase ad .
8,545
private static function createProductPartitions ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ operations = [ ] ; $ root = ProductPartitions :: createSubdivision ( ) ; $ criterion = ProductPartitions :: asBiddableAdGroupCriterion ( $ adGroupId , $ root ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ newCondition = new ProductCanonicalCondition ( ) ; $ newCondition -> setCondition ( ProductCanonicalConditionCondition :: NEW_VALUE ) ; $ newConditionUnit = ProductPartitions :: createUnit ( $ root , $ newCondition ) ; $ criterion = ProductPartitions :: asBiddableAdGroupCriterion ( $ adGroupId , $ newConditionUnit ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ usedCondition = new ProductCanonicalCondition ( ) ; $ usedCondition -> setCondition ( ProductCanonicalConditionCondition :: USED ) ; $ usedConditionUnit = ProductPartitions :: createUnit ( $ root , $ usedCondition ) ; $ criterion = ProductPartitions :: asBiddableAdGroupCriterion ( $ adGroupId , $ usedConditionUnit ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ excludedUnit = ProductPartitions :: createUnit ( $ root , new ProductCanonicalCondition ( ) ) ; $ criterion = ProductPartitions :: asNegativeAdGroupCriterion ( $ adGroupId , $ excludedUnit ) ; $ operation = ProductPartitions :: createAddOperation ( $ criterion ) ; $ operations [ ] = $ operation ; $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; $ adGroupCriterionService -> mutate ( $ operations ) ; }
Creates the product partition tree for the ad group .
8,546
private static function uploadImage ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ url ) { $ mediaService = $ adWordsServices -> get ( $ session , MediaService :: class ) ; $ image = new Image ( ) ; $ image -> setData ( file_get_contents ( $ url ) ) ; $ image -> setType ( MediaMediaType :: IMAGE ) ; $ result = $ mediaService -> upload ( [ $ image ] ) ; return $ result [ 0 ] -> getMediaId ( ) ; }
Uploads an image .
8,547
public function formatApplicationNameForSoapHeader ( $ applicationName , $ productNameForSoapHeader , $ includeUtilityUsage ) { $ adsUtilities = $ this -> adsUtilityRegistry -> popAllUtilities ( ) ; return sprintf ( '%s (%sApi-PHP, %s/%s, PHP/%s%s)' , $ applicationName , $ productNameForSoapHeader , $ this -> libraryMetadataProvider -> getLibName ( ) , $ this -> libraryMetadataProvider -> getLibVersion ( ) , PHP_VERSION , $ this -> formatUtilUsages ( $ adsUtilities , $ includeUtilityUsage ) ) ; }
Formats an application name in a format standard to the ads libraries to include in the SOAP header .
8,548
public function formatApplicationNameForGuzzleHeader ( $ applicationName , $ productName , $ includeUtilityUsage , $ isReportingGzipEnabled = null ) { $ adsUtilities = $ this -> adsUtilityRegistry -> popAllUtilities ( ) ; return sprintf ( '%s (%sApi-PHP, %s/%s, PHP/%s, %s%s%s)' , $ applicationName , $ productName , $ this -> libraryMetadataProvider -> getLibName ( ) , $ this -> libraryMetadataProvider -> getLibVersion ( ) , PHP_VERSION , $ this -> formatGuzzleInfo ( ) , $ this -> formatUtilUsages ( $ adsUtilities , $ includeUtilityUsage ) , $ isReportingGzipEnabled === true ? ', gzip' : '' ) ; }
Formats an application name in a format standard to the ads libraries to include in the Guzzle HTTP header .
8,549
private function initiateResumableUpload ( $ uploadUrl ) { $ requestOptions = [ ] ; $ requestOptions [ RequestOptions :: HEADERS ] = [ 'Content-Type' => 'application/xml' , 'Content-Length' => 0 , 'x-goog-resumable' => 'start' ] ; if ( ! empty ( $ this -> connectionSettings -> getProxyUrl ( ) ) ) { $ requestOptions [ RequestOptions :: PROXY ] = [ 'https' => $ this -> connectionSettings -> getProxyUrl ( ) ] ; } $ response = $ this -> httpClient -> request ( 'POST' , $ uploadUrl , $ requestOptions ) ; return $ response -> getHeader ( 'Location' ) [ 0 ] ; }
Initiates the resumable upload by sending a request to Google Cloud Storage .
8,550
public function generateSoapClient ( AdsSession $ session , AdsHeaderHandler $ headerHandler , AdsServiceDescriptor $ serviceDescriptor ) { $ options = [ 'trace' => true , 'encoding' => 'utf-8' , 'connection_timeout' => $ this -> soapCallTimeout , 'features' => SOAP_SINGLE_ELEMENT_ARRAYS ] ; $ soapSettings = $ session -> getSoapSettings ( ) ; $ options = $ this -> populateOptions ( $ session , $ options , $ soapSettings ) ; $ soapClient = $ this -> reflection -> createInstance ( $ serviceDescriptor -> getServiceClass ( ) , $ options ) ; $ soapClient -> setStreamContext ( $ options [ 'stream_context' ] ) ; $ soapClient -> setSoapLogMessageFormatter ( $ this -> soapLogMessageFormatter ) ; $ soapClient -> setAdsSession ( $ session ) ; $ soapClient -> setHeaderHandler ( $ headerHandler ) ; $ soapClient -> setServiceDescriptor ( $ serviceDescriptor ) ; $ soapClient -> setSoapCallTimeout ( $ this -> soapCallTimeout ) ; $ soapClient -> __setLocation ( str_replace ( sprintf ( '%s://%s' , parse_url ( $ soapClient -> getWsdlUri ( ) , PHP_URL_SCHEME ) , parse_url ( $ soapClient -> getWsdlUri ( ) , PHP_URL_HOST ) ) , rtrim ( $ session -> getEndpoint ( ) , '/' ) , $ soapClient -> getWsdlUri ( ) ) ) ; return $ soapClient ; }
Generates a SOAP client that interfaces with the specified service using configuration data from the specified ads session .
8,551
private function getLocalWsdlPath ( $ wsdl ) { $ resourcesWsdlsPath = sprintf ( self :: $ RESOURCES_WSDLS_PATH_FORMAT , __DIR__ , DIRECTORY_SEPARATOR ) ; $ wsdlFilePath = str_replace ( '/' , DIRECTORY_SEPARATOR , parse_url ( $ wsdl , PHP_URL_PATH ) ) ; return $ resourcesWsdlsPath . $ wsdlFilePath . self :: $ WSDL_FILE_EXTENSION ; }
Gets the path to stored WSDLs from the provided live WSDL URI .
8,552
public static function writeCsvToStream ( array $ csvData , $ handle ) { if ( is_null ( $ handle ) ) { throw new InvalidArgumentException ( 'File handle is null.' ) ; } foreach ( $ csvData as $ line ) { fputcsv ( $ handle , $ line ) ; } }
Writes the CSV data to a stream handle .
8,553
private static function printMeanEstimate ( StatsEstimate $ minEstimate , StatsEstimate $ maxEstimate ) { $ meanAverageCpc = self :: calculateMeanMicroAmount ( $ minEstimate -> getAverageCpc ( ) , $ maxEstimate -> getAverageCpc ( ) ) ; $ meanAveragePosition = self :: calculateMean ( $ minEstimate -> getAveragePosition ( ) , $ maxEstimate -> getAveragePosition ( ) ) ; $ meanClicks = self :: calculateMean ( $ minEstimate -> getClicksPerDay ( ) , $ maxEstimate -> getClicksPerDay ( ) ) ; $ meanTotalCost = self :: calculateMeanMicroAmount ( $ minEstimate -> getTotalCost ( ) , $ maxEstimate -> getTotalCost ( ) ) ; printf ( " Estimated average CPC: %s\n" , self :: formatMean ( $ meanAverageCpc ) ) ; printf ( " Estimated ad position: %s\n" , self :: formatMean ( $ meanAveragePosition ) ) ; printf ( " Estimated daily clicks: %s\n" , self :: formatMean ( $ meanClicks ) ) ; printf ( " Estimated daily cost: %s\n\n" , self :: formatMean ( $ meanTotalCost ) ) ; }
Prints estimated average CPC ad position daily clicks and daily costs between the provided lower bound and upper bound of estimated stats .
8,554
private static function calculateMean ( $ min , $ max ) { if ( $ min === null || $ max === null ) { return null ; } return ( $ min + $ max ) / 2 ; }
Returns the mean of the two numbers if neither is null else returns null .
8,555
private static function calculateMeanMicroAmount ( $ min , $ max ) { if ( $ min === null || $ max === null ) { return null ; } if ( $ min -> getMicroAmount ( ) === null || $ max -> getMicroAmount ( ) === null ) { return null ; } return ( $ min -> getMicroAmount ( ) + $ max -> getMicroAmount ( ) ) / 2 ; }
Returns the mean of the two object s microAmounts if neither is null else returns null .
8,556
public function uploadBatchJobOperations ( array $ operations , $ uploadUrl ) { $ this -> adsUtilityRegistry -> addUtility ( AdsUtility :: BATCH_JOBS ) ; return $ this -> batchJobsDelegate -> uploadBatchJobOperations ( $ operations , $ uploadUrl ) ; }
Uploads all batch job operations to the specified upload URL .
8,557
public function uploadIncrementalBatchJobOperations ( array $ operations , BatchJobUploadStatus $ batchJobUploadStatus ) { $ this -> adsUtilityRegistry -> addUtility ( AdsUtility :: BATCH_JOBS ) ; return $ this -> batchJobsDelegate -> uploadIncrementalBatchJobOperations ( $ operations , $ batchJobUploadStatus ) ; }
Uploads batch job operations incrementally to the specified upload URL .
8,558
public function downloadBatchJobResults ( $ downloadUrl ) { $ this -> adsUtilityRegistry -> addUtility ( AdsUtility :: BATCH_JOBS ) ; return $ this -> batchJobsDelegate -> downloadBatchJobResults ( $ downloadUrl ) ; }
Downloads the results of batch processing from the download URL .
8,559
public static function createValue ( $ value ) { if ( $ value instanceof Value ) { return $ value ; } elseif ( is_bool ( $ value ) ) { return new BooleanValue ( $ value ) ; } elseif ( is_float ( $ value ) || is_int ( $ value ) ) { return new NumberValue ( strval ( $ value ) ) ; } elseif ( is_string ( $ value ) ) { return new TextValue ( $ value ) ; } elseif ( $ value instanceof AdManagerDateTime ) { return new DateTimeValue ( $ value ) ; } elseif ( $ value instanceof Date ) { return new DateValue ( $ value ) ; } elseif ( is_array ( $ value ) ) { $ values = [ ] ; foreach ( $ value as $ valueEntry ) { $ values [ ] = self :: createValue ( $ valueEntry ) ; } $ setValue = new SetValue ( ) ; $ setValue -> setValues ( $ values ) ; return $ setValue ; } elseif ( $ value instanceof Targeting ) { return new TargetingValue ( $ value ) ; } else { throw new InvalidArgumentException ( sprintf ( 'Unsupported value type [%s]' , is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ) ) ; } }
Creates a PQL Value from the specified value .
8,560
public static function toString ( Value $ value ) { if ( $ value instanceof BooleanValue ) { return $ value -> getValue ( ) ? 'true' : 'false' ; } elseif ( $ value instanceof NumberValue || $ value instanceof TextValue ) { return strval ( $ value -> getValue ( ) ) ; } elseif ( $ value instanceof DateTimeValue ) { return $ value -> getValue ( ) !== null ? AdManagerDateTimes :: toDateTimeString ( $ value -> getValue ( ) ) : '' ; } elseif ( $ value instanceof DateValue ) { return AdManagerDates :: toDateString ( $ value -> getValue ( ) ) ; } elseif ( $ value instanceof SetValue ) { $ pqlValues = $ value -> getValues ( ) ; if ( $ pqlValues !== null ) { $ valuesAsStrings = [ ] ; foreach ( $ pqlValues as $ pqlValue ) { $ valuesAsStrings [ ] = self :: toString ( $ pqlValue ) ; } return implode ( ',' , $ valuesAsStrings ) ; } else { return '' ; } } else { throw new InvalidArgumentException ( sprintf ( 'Unsupported value type [%s]' , get_class ( $ value ) ) ) ; } }
Creates a string from the Value .
8,561
public static function getColumnLabels ( ResultSet $ resultSet ) { $ columnLabels = [ ] ; foreach ( $ resultSet -> getColumnTypes ( ) as $ columnType ) { $ columnLabels [ ] = $ columnType -> getLabelName ( ) ; } return $ columnLabels ; }
Gets the column labels for the result set .
8,562
public static function combineResultSets ( ResultSet $ first , ResultSet $ second ) { $ firstColumns = self :: getColumnLabels ( $ first ) ; $ secondColumns = self :: getColumnLabels ( $ second ) ; if ( $ firstColumns !== $ secondColumns ) { throw new InvalidArgumentException ( sprintf ( 'First result set columns [%s] do not match second result ' . 'set columns [%s]' , implode ( ', ' , $ firstColumns ) , implode ( ', ' , $ secondColumns ) ) ) ; } $ combinedRows = $ first -> getRows ( ) ; if ( ! empty ( $ second -> getRows ( ) ) ) { $ combinedRows = array_merge ( $ combinedRows , $ second -> getRows ( ) ) ; } return new ResultSet ( $ first -> getColumnTypes ( ) , $ combinedRows ) ; }
Combines the first and second result sets if and only if the columns of both result sets match .
8,563
public static function copyFrom ( ServiceQueryBuilderDelegate $ otherInstance , ServiceQueryBuilder $ queryBuilder ) { $ copyingInstance = new self ( ) ; $ copyingInstance -> startIndex = $ otherInstance -> startIndex ; $ copyingInstance -> pageSize = $ otherInstance -> pageSize ; $ copyingInstance -> orderByFields = $ otherInstance -> orderByFields ; $ copyingInstance -> selectFields = $ otherInstance -> selectFields ; if ( isset ( $ otherInstance -> whereBuilders ) ) { $ copyingInstance -> whereBuilders = [ ] ; foreach ( $ otherInstance -> whereBuilders as $ whereBuilder ) { $ copyingInstance -> whereBuilders [ ] = ServiceQueryWhereBuilder :: copyFrom ( $ whereBuilder , $ queryBuilder ) ; } } return $ copyingInstance ; }
Creates a new query builder delegate object by copying field names WHERE conditions and pagination data from another query builder delegate object .
8,564
public function select ( array $ fields ) { if ( empty ( $ fields ) ) { throw new InvalidArgumentException ( 'The field array must not be' . ' empty.' ) ; } foreach ( $ fields as $ field ) { $ validationResult = QueryValidator :: validateFieldName ( $ field ) ; if ( $ validationResult -> isFailed ( ) ) { throw new InvalidArgumentException ( 'The field array for' . ' building the SELECT clause contains invalid field name.' . ' Validation fail reason: ' . $ validationResult -> getFailReason ( ) ) ; } } $ distinctFields = array_flip ( $ fields ) ; $ this -> selectFields = array_keys ( $ distinctFields ) ; }
Sets the fields for the SELECT clause . Repeated field names will be included exactly once .
8,565
private function appendOrderByClause ( $ awqlString ) { if ( empty ( $ this -> orderByFields ) ) { return $ awqlString ; } return sprintf ( '%s ORDER BY %s' , $ awqlString , implode ( ', ' , $ this -> orderByFields ) ) ; }
Appends the ORDER BY clause to a partial AWQL string .
8,566
public function downloadReport ( ReportDefinition $ reportDefinition , ReportSettings $ reportSettingsOverride = null ) { return $ this -> makeReportRequest ( $ this -> requestOptionsFactory -> createRequestOptionsWithReportDefinition ( $ reportDefinition , $ reportSettingsOverride ) ) ; }
Downloads a report using report definition .
8,567
public function downloadReportWithAwql ( $ reportQuery , $ reportFormat , ReportSettings $ reportSettingsOverride = null ) { if ( ! is_string ( $ reportQuery ) ) { throw new InvalidArgumentException ( 'The report query must be a' . ' string.' ) ; } return $ this -> makeReportRequest ( $ this -> requestOptionsFactory -> createRequestOptionsWithAwqlQuery ( $ reportQuery , $ reportFormat , $ reportSettingsOverride ) ) ; }
Downloads a report using AWQL .
8,568
public function downloadReportWithReportQuery ( ReportQuery $ reportQuery , $ reportFormat , ReportSettings $ reportSettingsOverride = null ) { $ awqlString = sprintf ( '%s' , $ reportQuery ) ; return $ this -> downloadReportWithAwql ( $ awqlString , $ reportFormat , $ reportSettingsOverride ) ; }
Downloads a report using a report query object .
8,569
private function makeReportRequest ( array $ requestOptions ) { $ requestOptions [ RequestOptions :: STREAM ] = true ; $ proxy = $ this -> session -> getConnectionSettings ( ) -> getProxyUrl ( ) ; if ( ! empty ( $ proxy ) ) { $ requestOptions [ RequestOptions :: PROXY ] = [ 'https' => $ proxy ] ; } if ( $ this -> session -> getConnectionSettings ( ) -> isReportingGzipEnabled ( ) === true ) { $ requestOptions [ RequestOptions :: DECODE_CONTENT ] = 'gzip' ; } try { $ response = $ this -> httpClient -> request ( 'POST' , rtrim ( $ this -> session -> getEndpoint ( ) , '/' ) . self :: $ REPORT_DOWNLOAD_URL_PATH , $ requestOptions ) ; } catch ( ClientException $ e ) { $ decodedResponse = $ this -> apiErrorSerializer -> decode ( $ e -> getResponse ( ) -> getBody ( ) -> getContents ( ) , 'xml' ) ; $ apiErrorList = AdWordsNormalizer :: isOneOrMany ( $ decodedResponse [ 'ApiError' ] ) ? [ $ decodedResponse [ 'ApiError' ] ] : $ decodedResponse [ 'ApiError' ] ; $ reportDownloadErrors = $ this -> apiErrorSerializer -> denormalize ( $ apiErrorList , 'Google\AdsApi\AdWords\Reporting\v201809\ReportDownloadError[]' ) ; $ reportDownloadException = new ApiException ( sprintf ( 'Details: [%s]' , implode ( ', ' , $ reportDownloadErrors ) ) ) ; $ reportDownloadException -> setErrors ( $ reportDownloadErrors ) ; throw $ reportDownloadException ; } catch ( ServerException $ e ) { throw new ApiException ( 'Temporary problem with the server. Please retry the request' . ' after a few moments' ) ; } return new ReportDownloadResult ( $ response ) ; }
Make an HTTP request to download a report with the specified request options .
8,570
private static function getFeeds ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ feedService = $ adWordsServices -> get ( $ session , FeedService :: class ) ; $ totalNumEntries = 0 ; $ offset = 0 ; $ query = 'SELECT Id, Name, Attributes WHERE Origin="USER" AND ' . 'FeedStatus="ENABLED"' ; $ feeds = [ ] ; do { $ pageQuery = sprintf ( '%s LIMIT %d,%d' , $ query , $ offset , self :: PAGE_LIMIT ) ; $ page = $ feedService -> query ( $ pageQuery ) ; if ( $ page -> getEntries ( ) !== null ) { $ totalNumEntries = $ page -> getTotalNumEntries ( ) ; foreach ( $ page -> getEntries ( ) as $ feed ) { $ feeds [ ] = $ feed ; } } $ offset += self :: PAGE_LIMIT ; } while ( $ offset < $ totalNumEntries ) ; return $ feeds ; }
Gets all enabled feeds .
8,571
private static function getFeedItems ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedId ) { $ feedItemService = $ adWordsServices -> get ( $ session , FeedItemService :: class ) ; $ totalNumEntries = 0 ; $ offset = 0 ; $ query = sprintf ( 'SELECT FeedItemId, AttributeValues WHERE Status = ' . '"ENABLED" AND FeedId = %d' , $ feedId ) ; $ feedItems = [ ] ; do { $ pageQuery = sprintf ( '%s LIMIT %d,%d' , $ query , $ offset , self :: PAGE_LIMIT ) ; $ page = $ feedItemService -> query ( $ pageQuery ) ; if ( $ page -> getEntries ( ) !== null ) { $ totalNumEntries = $ page -> getTotalNumEntries ( ) ; foreach ( $ page -> getEntries ( ) as $ feedItem ) { $ feedItems [ ] = $ feedItem ; } } $ offset += self :: PAGE_LIMIT ; } while ( $ offset < $ totalNumEntries ) ; return $ feedItems ; }
Gets all enabled feed items of the specified feed .
8,572
private static function getCampaignFeeds ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedId , $ placeholderId ) { $ campaignFeedService = $ adWordsServices -> get ( $ session , CampaignFeedService :: class ) ; $ page = $ campaignFeedService -> query ( sprintf ( 'SELECT CampaignId, MatchingFunction, PlaceholderTypes WHERE ' . 'Status="ENABLED" AND FeedId = %d AND PlaceholderTypes ' . 'CONTAINS_ANY[%d]' , $ feedId , $ placeholderId ) ) ; return $ page -> getEntries ( ) ; }
Gets all enabled campaign feeds for the specified feed and placeholder type .
8,573
private static function getAttributeFieldMappings ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedId , $ placeholderTypeId ) { $ feedMappingService = $ adWordsServices -> get ( $ session , FeedMappingService :: class ) ; $ page = $ feedMappingService -> query ( sprintf ( 'SELECT FeedMappingId, AttributeFieldMappings WHERE FeedId="%d" ' . 'AND PlaceholderType="%d" AND Status="ENABLED"' , $ feedId , $ placeholderTypeId ) ) ; $ attributeMappings = [ ] ; if ( $ page -> getEntries ( ) !== null ) { foreach ( $ page -> getEntries ( ) as $ feedMapping ) { foreach ( $ feedMapping -> getAttributeFieldMappings ( ) as $ attributeMapping ) { if ( array_key_exists ( $ attributeMapping -> getFeedAttributeId ( ) , $ attributeMappings ) === false ) { $ attributeMappings [ $ attributeMapping -> getFeedAttributeId ( ) ] = [ ] ; } $ attributeMappings [ $ attributeMapping -> getFeedAttributeId ( ) ] [ ] = $ attributeMapping -> getFieldId ( ) ; } } } return $ attributeMappings ; }
Gets attribute field mappings from the specified feed and placeholder type .
8,574
private static function getSitelinksFromFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedId ) { printf ( "Processing feed ID %d...\n" , $ feedId ) ; $ sitelinks = [ ] ; $ feedItems = self :: getFeedItems ( $ adWordsServices , $ session , $ feedId ) ; if ( $ feedItems !== null ) { $ attributeFieldMappings = self :: getAttributeFieldMappings ( $ adWordsServices , $ session , $ feedId , self :: PLACEHOLDER_TYPE_SITELINKS ) ; foreach ( $ feedItems as $ feedItem ) { $ sitelinkFromFeed = new SitelinkFromFeed ( $ feedItem -> getFeedId ( ) , $ feedItem -> getFeedItemId ( ) ) ; foreach ( $ feedItem -> getAttributeValues ( ) as $ attributeValue ) { if ( array_key_exists ( $ attributeValue -> getFeedAttributeId ( ) , $ attributeFieldMappings ) === false ) { continue ; } foreach ( $ attributeFieldMappings [ $ attributeValue -> getFeedAttributeId ( ) ] as $ fieldId ) { switch ( $ fieldId ) { case self :: PLACEHOLDER_FIELD_TEXT : $ sitelinkFromFeed -> setText ( $ attributeValue -> getStringValue ( ) ) ; break ; case self :: PLACEHOLDER_FIELD_URL : $ sitelinkFromFeed -> setUrl ( $ attributeValue -> getStringValue ( ) ) ; break ; case self :: PLACEHOLDER_FIELD_FINAL_URLS : $ sitelinkFromFeed -> setFinalUrls ( $ attributeValue -> getStringValues ( ) ) ; break ; case self :: PLACEHOLDER_FIELD_FINAL_MOBILE_URLS : $ sitelinkFromFeed -> setFinalMobileUrls ( $ attributeValue -> getStringValues ( ) ) ; break ; case self :: PLACEHOLDER_FIELD_TRACKING_URL_TEMPLATE : $ sitelinkFromFeed -> setTrackingUrlTemplate ( $ attributeValue -> getStringValue ( ) ) ; break ; case self :: PLACEHOLDER_FIELD_LINE2 : $ sitelinkFromFeed -> setLine2 ( $ attributeValue -> getStringValue ( ) ) ; break ; case self :: PLACEHOLDER_FIELD_LINE3 : $ sitelinkFromFeed -> setLine3 ( $ attributeValue -> getStringValue ( ) ) ; break ; } } } $ sitelinks [ $ feedItem -> getFeedItemId ( ) ] = $ sitelinkFromFeed ; } } return $ sitelinks ; }
Gets sitelinks from the specified feed .
8,575
private static function getPlatformRestrictionsForCampaignFeed ( $ campaignFeed ) { $ platformRestrictions = ExtensionSettingPlatform :: NONE ; if ( $ campaignFeed -> getMatchingFunction ( ) -> getOperator ( ) === FunctionOperator :: AND_VALUE ) { foreach ( $ campaignFeed -> getMatchingFunction ( ) -> getLhsOperand ( ) as $ argument ) { if ( $ argument instanceof FunctionOperand ) { if ( $ argument -> getValue ( ) -> getOperator ( ) === FunctionOperator :: EQUALS && $ argument -> getValue ( ) -> getLhsOperand ( ) [ 0 ] instanceof RequestContextOperand ) { $ requestContextOperand = $ argument -> getValue ( ) -> getLhsOperand ( ) [ 0 ] ; if ( $ requestContextOperand -> getContextType ( ) === RequestContextOperandContextType :: DEVICE_PLATFORM ) { $ platformRestrictions = strtoupper ( $ argument -> getValue ( ) -> getRhsOperand ( ) [ 0 ] -> getStringValue ( ) ) ; } } } } } return $ platformRestrictions ; }
Gets plaftform restrictions for the specified campaign feed .
8,576
private static function getFeedItemIdsForCampaignFeed ( $ campaignFeed ) { $ feedItemIds = [ ] ; if ( $ campaignFeed -> getMatchingFunction ( ) -> getOperator ( ) === FunctionOperator :: IN ) { $ feedItemIds = array_merge ( $ feedItemIds , self :: getFeedItemIdsFromArgument ( $ campaignFeed -> getMatchingFunction ( ) ) ) ; } elseif ( $ campaignFeed -> getMatchingFunction ( ) -> getOperator ( ) === FunctionOperator :: AND_VALUE ) { foreach ( $ campaignFeed -> getMatchingFunction ( ) -> getLhsOperand ( ) as $ argument ) { if ( $ argument instanceof FunctionOperand ) { if ( $ argument -> getValue ( ) -> getOperator ( ) === FunctionOperator :: IN ) { $ feedItemIds = array_merge ( $ feedItemIds , self :: getFeedItemIdsFromArgument ( $ argument -> getValue ( ) ) ) ; } } } } return $ feedItemIds ; }
Gets feed item IDs from the specified campaign feed .
8,577
private static function getFeedItemIdsFromArgument ( $ function ) { $ feedItemIds = [ ] ; if ( count ( $ function -> getLhsOperand ( ) ) === 1 && $ function -> getLhsOperand ( ) [ 0 ] instanceof RequestContextOperand && $ function -> getLhsOperand ( ) [ 0 ] -> getContextType ( ) === RequestContextOperandContextType :: FEED_ITEM_ID && $ function -> getOperator ( ) === FunctionOperator :: IN ) { foreach ( $ function -> getRhsOperand ( ) as $ argument ) { $ feedItemIds [ ] = $ argument -> getLongValue ( ) ; } } return $ feedItemIds ; }
Gets feed item IDs from the specified function argument .
8,578
private static function createExtensionSetting ( AdWordsServices $ adWordsServices , AdWordsSession $ session , array $ sitelinksFromFeed , $ campaignId , array $ feedItemIds , $ platformRestrictions ) { $ campaignExtensionSettingService = $ adWordsServices -> get ( $ session , CampaignExtensionSettingService :: class ) ; $ extensionSetting = new CampaignExtensionSetting ( ) ; $ extensionSetting -> setCampaignId ( $ campaignId ) ; $ extensionSetting -> setExtensionType ( FeedType :: SITELINK ) ; $ extensionSetting -> setExtensionSetting ( new ExtensionSetting ( ) ) ; $ extensionFeedItems = [ ] ; foreach ( $ feedItemIds as $ feedItemId ) { $ sitelink = $ sitelinksFromFeed [ $ feedItemId ] ; $ newFeedItem = new SitelinkFeedItem ( ) ; $ newFeedItem -> setSitelinkText ( $ sitelink -> getText ( ) ) ; $ newFeedItem -> setSitelinkUrl ( $ sitelink -> getUrl ( ) ) ; $ newFeedItem -> setSitelinkLine2 ( $ sitelink -> getLine2 ( ) ) ; $ newFeedItem -> setSitelinkLine3 ( $ sitelink -> getLine3 ( ) ) ; $ newFeedItem -> setSitelinkFinalUrls ( $ sitelink -> getFinalUrls ( ) ) ; $ newFeedItem -> setSitelinkFinalMobileUrls ( $ sitelink -> getFinalMobileUrls ( ) ) ; $ newFeedItem -> setSitelinkTrackingUrlTemplate ( $ sitelink -> getTrackingUrlTemplate ( ) ) ; $ extensionFeedItems [ ] = $ newFeedItem ; } $ extensionSetting -> getExtensionSetting ( ) -> setExtensions ( $ extensionFeedItems ) ; $ extensionSetting -> getExtensionSetting ( ) -> setPlatformRestrictions ( $ platformRestrictions ) ; $ operation = new CampaignExtensionSettingOperation ( ) ; $ operation -> setOperand ( $ extensionSetting ) ; $ operation -> setOperator ( Operator :: ADD ) ; printf ( "Adding %d sitelinks for campaign ID %d...\n" , count ( $ feedItemIds ) , $ campaignId ) ; return $ campaignExtensionSettingService -> mutate ( [ $ operation ] ) ; }
Creates a new extension setting for the specified feed items .
8,579
private static function deleteCampaignFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ campaignFeed ) { $ campaignFeedService = $ adWordsServices -> get ( $ session , CampaignFeedService :: class ) ; printf ( "Deleting association of feed ID %d and campaign ID %d...\n" , $ campaignFeed -> getFeedId ( ) , $ campaignFeed -> getCampaignId ( ) ) ; $ operation = new CampaignFeedOperation ( ) ; $ operation -> setOperand ( $ campaignFeed ) ; $ operation -> setOperator ( Operator :: REMOVE ) ; return $ campaignFeedService -> mutate ( [ $ operation ] ) ; }
Deletes associations of the specified feed IDs and campaign IDs .
8,580
private static function deleteOldFeedItems ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedItemIds , $ feedId ) { if ( count ( $ feedItemIds ) === 0 ) { return ; } $ feedItemService = $ adWordsServices -> get ( $ session , FeedItemService :: class ) ; $ operations = [ ] ; foreach ( $ feedItemIds as $ feedItemId ) { $ feedItem = new FeedItem ( ) ; $ feedItem -> setFeedId ( $ feedId ) ; $ feedItem -> setFeedItemId ( $ feedItemId ) ; $ operation = new FeedItemOperation ( ) ; $ operation -> setOperand ( $ feedItem ) ; $ operation -> setOperator ( Operator :: REMOVE ) ; $ operations [ ] = $ operation ; } printf ( "Deleting %d old feed items from feed ID %d...\n" , count ( $ feedItemIds ) , $ feedId ) ; return $ feedItemService -> mutate ( $ operations ) ; }
Deletes old feed items that became unused anymore after migration .
8,581
private static function createCustomizerFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedName ) { $ adCustomizerFeedService = $ adWordsServices -> get ( $ session , AdCustomizerFeedService :: class ) ; $ nameAttribute = new AdCustomizerFeedAttribute ( ) ; $ nameAttribute -> setName ( 'Name' ) ; $ nameAttribute -> setType ( AdCustomizerFeedAttributeType :: STRING ) ; $ priceAttribute = new AdCustomizerFeedAttribute ( ) ; $ priceAttribute -> setName ( 'Price' ) ; $ priceAttribute -> setType ( AdCustomizerFeedAttributeType :: STRING ) ; $ dateAttribute = new AdCustomizerFeedAttribute ( ) ; $ dateAttribute -> setName ( 'Date' ) ; $ dateAttribute -> setType ( AdCustomizerFeedAttributeType :: DATE_TIME ) ; $ customizerFeed = new AdCustomizerFeed ( ) ; $ customizerFeed -> setFeedName ( $ feedName ) ; $ customizerFeed -> setFeedAttributes ( [ $ nameAttribute , $ priceAttribute , $ dateAttribute ] ) ; $ feedOperation = new AdCustomizerFeedOperation ( ) ; $ feedOperation -> setOperand ( $ customizerFeed ) ; $ feedOperation -> setOperator ( Operator :: ADD ) ; $ operations = [ $ feedOperation ] ; $ result = $ adCustomizerFeedService -> mutate ( $ operations ) ; $ addedFeed = $ result -> getValue ( ) [ 0 ] ; printf ( "Created ad customizer feed with ID %d, name '%s' and attributes:\n" , $ addedFeed -> getFeedId ( ) , $ addedFeed -> getFeedName ( ) ) ; if ( empty ( $ addedFeed ) ) { print " No attributes\n" ; } else { foreach ( $ addedFeed -> getFeedAttributes ( ) as $ feedAttribute ) { printf ( " ID: %d, name: '%s', type: %s\n" , $ feedAttribute -> getId ( ) , $ feedAttribute -> getName ( ) , $ feedAttribute -> getType ( ) ) ; } } return $ addedFeed ; }
Creates a new feed for AdCustomizerFeed .
8,582
private static function createCustomizerFeedItems ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdCustomizerFeed $ adCustomizerFeed , array $ adGroupIds ) { $ feedItemService = $ adWordsServices -> get ( $ session , FeedItemService :: class ) ; $ operations = [ ] ; $ marsDate = mktime ( 0 , 0 , 0 , date ( 'm' ) , 1 , date ( 'Y' ) ) ; $ venusDate = mktime ( 0 , 0 , 0 , date ( 'm' ) , 15 , date ( 'Y' ) ) ; $ operations [ ] = self :: createFeedItemAddOperation ( 'Mars' , '$1234.56' , date ( 'Ymd His' , $ marsDate ) , $ adCustomizerFeed ) ; $ operations [ ] = self :: createFeedItemAddOperation ( 'Venus' , '$1450.00' , date ( 'Ymd His' , $ venusDate ) , $ adCustomizerFeed ) ; $ result = $ feedItemService -> mutate ( $ operations ) ; foreach ( $ result -> getValue ( ) as $ feedItem ) { printf ( 'FeedItem with ID %d was added.%s' , $ feedItem -> getFeedItemId ( ) , PHP_EOL ) ; } for ( $ i = 0 ; $ i < count ( $ result -> getValue ( ) ) ; $ i ++ ) { self :: restrictFeedItemToAdGroup ( $ adWordsServices , $ session , $ result -> getValue ( ) [ $ i ] , $ adGroupIds [ $ i ] ) ; } }
Creates feed items with the values to use in ad customizations for each ad group .
8,583
private static function createFeedItemAddOperation ( $ name , $ price , $ date , AdCustomizerFeed $ adCustomizerFeed ) { $ nameAttributeValue = new FeedItemAttributeValue ( ) ; $ nameAttributeValue -> setFeedAttributeId ( $ adCustomizerFeed -> getFeedAttributes ( ) [ 0 ] -> getId ( ) ) ; $ nameAttributeValue -> setStringValue ( $ name ) ; $ priceAttributeValue = new FeedItemAttributeValue ( ) ; $ priceAttributeValue -> setFeedAttributeId ( $ adCustomizerFeed -> getFeedAttributes ( ) [ 1 ] -> getId ( ) ) ; $ priceAttributeValue -> setStringValue ( $ price ) ; $ dateAttributeValue = new FeedItemAttributeValue ( ) ; $ dateAttributeValue -> setFeedAttributeId ( $ adCustomizerFeed -> getFeedAttributes ( ) [ 2 ] -> getId ( ) ) ; $ dateAttributeValue -> setStringValue ( $ date ) ; $ item = new FeedItem ( ) ; $ item -> setFeedId ( $ adCustomizerFeed -> getFeedId ( ) ) ; $ item -> setAttributeValues ( [ $ nameAttributeValue , $ priceAttributeValue , $ dateAttributeValue ] ) ; $ operation = new FeedItemOperation ( ) ; $ operation -> setOperand ( $ item ) ; $ operation -> setOperator ( 'ADD' ) ; return $ operation ; }
Creates a feed item operation that will create a feed item with the specified values and ad group target when sent to FeedItemService . mutate .
8,584
private static function restrictFeedItemToAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , FeedItem $ feedItem , $ adGroupId ) { $ feedItemTargetService = $ adWordsServices -> get ( $ session , FeedItemTargetService :: class ) ; $ adGroupTarget = new FeedItemAdGroupTarget ( ) ; $ adGroupTarget -> setFeedId ( $ feedItem -> getFeedId ( ) ) ; $ adGroupTarget -> setFeedItemId ( $ feedItem -> getFeedItemId ( ) ) ; $ adGroupTarget -> setAdGroupId ( $ adGroupId ) ; $ operation = new FeedItemTargetOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ adGroupTarget ) ; $ result = $ feedItemTargetService -> mutate ( [ $ operation ] ) ; $ addedAdGroupTarget = $ result -> getValue ( ) [ 0 ] ; sprintf ( 'Feed item target for feed ID %s and feed item ID %s ' . 'was created to restrict serving to ad group ID %s.%s' , $ addedAdGroupTarget -> getFeedId ( ) , $ addedAdGroupTarget -> getFeedItemId ( ) , $ addedAdGroupTarget -> getAdGroupId ( ) , PHP_EOL ) ; }
Restricts the feed item to an ad group .
8,585
private static function createAdsWithCustomizations ( AdWordsServices $ adWordsServices , AdWordsSession $ session , array $ adGroupIds , $ feedName ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; $ operations = [ ] ; $ expandedTextAd = new ExpandedTextAd ( ) ; $ expandedTextAd -> setHeadlinePart1 ( sprintf ( 'Luxury Cruise to {=%s.Name}' , $ feedName ) ) ; $ expandedTextAd -> setHeadlinePart2 ( sprintf ( 'Only {=%s.Price}' , $ feedName ) ) ; $ expandedTextAd -> setDescription ( sprintf ( 'Offer ends in {=countdown(%s.Date)}!' , $ feedName ) ) ; $ expandedTextAd -> setFinalUrls ( [ 'http://www.example.com' ] ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroupIds [ 0 ] ) ; $ adGroupAd -> setAd ( $ expandedTextAd ) ; $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperand ( $ adGroupAd ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; $ expandedTextAd2 = new ExpandedTextAd ( ) ; $ expandedTextAd2 -> setHeadlinePart1 ( sprintf ( 'Luxury Cruise to {=%s.Name}' , $ feedName ) ) ; $ expandedTextAd2 -> setHeadlinePart2 ( sprintf ( 'Only {=%s.Price}' , $ feedName ) ) ; $ expandedTextAd2 -> setDescription ( sprintf ( 'Offer ends in {=countdown(%s.Date)}!' , $ feedName ) ) ; $ expandedTextAd2 -> setFinalUrls ( [ 'http://www.example.com' ] ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroupIds [ 1 ] ) ; $ adGroupAd -> setAd ( $ expandedTextAd2 ) ; $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperand ( $ adGroupAd ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; $ result = $ adGroupAdService -> mutate ( $ operations ) ; foreach ( $ result -> getValue ( ) as $ adGroupAd ) { printf ( "Expanded text ad with ID %d and status '%s' was added.\n" , $ adGroupAd -> getAd ( ) -> getId ( ) , $ adGroupAd -> getStatus ( ) ) ; } }
Creates expanded text ads that use ad customizations for the specified ad group IDs .
8,586
public function getConfiguration ( $ name , $ section = null ) { $ configValue = null ; if ( $ section === null ) { if ( array_key_exists ( $ name , $ this -> config ) ) { $ configValue = $ this -> config [ $ name ] ; } } else { if ( array_key_exists ( $ section , $ this -> config ) ) { $ sectionSettings = $ this -> config [ $ section ] ; if ( array_key_exists ( $ name , $ sectionSettings ) ) { $ configValue = $ sectionSettings [ $ name ] ; } } } return $ configValue ; }
Gets the value for the specified setting name .
8,587
private function createSoapHeaderObject ( AdsServiceDescriptor $ serviceDescriptor ) { $ reflectionClass = new ReflectionClass ( $ serviceDescriptor -> getServiceClass ( ) ) ; return $ this -> reflection -> createInstance ( sprintf ( '%s\\%s' , $ reflectionClass -> getNamespaceName ( ) , self :: SOAP_HEADER_CLASS_NAME ) ) ; }
Creates a new instance of the SOAP header object used by the Ad Manager API .
8,588
public function getPreviewUrl ( $ lineItemId , $ creativeId , $ siteUrl ) { return $ this -> __soapCall ( 'getPreviewUrl' , array ( array ( 'lineItemId' => $ lineItemId , 'creativeId' => $ creativeId , 'siteUrl' => $ siteUrl ) ) ) -> getRval ( ) ; }
Returns an insite preview URL that references the specified site URL with the specified creative from the association served to it . For Creative Set previewing you may specify the master creative Id .
8,589
public function getPreviewUrlsForNativeStyles ( $ lineItemId , $ creativeId , $ siteUrl ) { return $ this -> __soapCall ( 'getPreviewUrlsForNativeStyles' , array ( array ( 'lineItemId' => $ lineItemId , 'creativeId' => $ creativeId , 'siteUrl' => $ siteUrl ) ) ) -> getRval ( ) ; }
Returns a list of URLs that reference the specified site URL with the specified creative from the association served to it . For Creative Set previewing you may specify the master creative Id . Each URL corresponds to one available native style for previewing the specified creative .
8,590
private static function printAccountHierarchy ( $ account , $ customerIdsToAccounts , $ customerIdsToChildLinks , $ depth = null ) { if ( $ depth === null ) { print "(Customer ID, Account Name)\n" ; self :: printAccountHierarchy ( $ account , $ customerIdsToAccounts , $ customerIdsToChildLinks , 0 ) ; return ; } print str_repeat ( '-' , $ depth * 2 ) ; $ customerId = $ account -> getCustomerId ( ) ; printf ( "%s, %s\n" , $ customerId , $ account -> getName ( ) ) ; if ( array_key_exists ( $ customerId , $ customerIdsToChildLinks ) ) { foreach ( $ customerIdsToChildLinks [ strval ( $ customerId ) ] as $ childLink ) { $ childAccount = $ customerIdsToAccounts [ strval ( $ childLink -> getClientCustomerId ( ) ) ] ; self :: printAccountHierarchy ( $ childAccount , $ customerIdsToAccounts , $ customerIdsToChildLinks , $ depth + 1 ) ; } } }
Prints the specified account s hierarchy using recursion .
8,591
public function getCampaignsAction ( Request $ request , FetchAuthTokenInterface $ oAuth2Credential , AdWordsServices $ adWordsServices , AdWordsSessionBuilder $ adWordsSessionBuilder ) { if ( $ request -> method ( ) === 'POST' ) { $ selectedFields = array_values ( [ 'id' => 'Id' ] + $ request -> except ( [ '_token' , 'clientCustomerId' , 'entriesPerPage' ] ) ) ; $ clientCustomerId = $ request -> input ( 'clientCustomerId' ) ; $ entriesPerPage = $ request -> input ( 'entriesPerPage' ) ; $ session = $ adWordsSessionBuilder -> fromFile ( config ( 'app.adsapi_php_path' ) ) -> withOAuth2Credential ( $ oAuth2Credential ) -> withClientCustomerId ( $ clientCustomerId ) -> build ( ) ; $ request -> session ( ) -> put ( 'selectedFields' , $ selectedFields ) ; $ request -> session ( ) -> put ( 'entriesPerPage' , $ entriesPerPage ) ; $ request -> session ( ) -> put ( 'session' , $ session ) ; } else { $ selectedFields = $ request -> session ( ) -> get ( 'selectedFields' ) ; $ entriesPerPage = $ request -> session ( ) -> get ( 'entriesPerPage' ) ; $ session = $ request -> session ( ) -> get ( 'session' ) ; } $ pageNo = $ request -> input ( 'page' ) ? : 1 ; $ collection = self :: fetchCampaigns ( $ request , $ adWordsServices -> get ( $ session , CampaignService :: class ) , $ selectedFields , $ entriesPerPage , $ pageNo ) ; $ campaigns = new LengthAwarePaginator ( $ collection , $ request -> session ( ) -> get ( 'totalNumEntries' ) , $ entriesPerPage , $ pageNo , [ 'path' => url ( 'get-campaigns' ) ] ) ; return view ( 'campaigns' , compact ( 'campaigns' , 'selectedFields' ) ) ; }
Controls a POST and GET request that is submitted from the Get All Campaigns form .
8,592
private function fetchCampaigns ( Request $ request , CampaignService $ campaignService , array $ selectedFields , $ entriesPerPage , $ pageNo ) { $ query = ( new ServiceQueryBuilder ( ) ) -> select ( $ selectedFields ) -> orderByAsc ( 'Name' ) -> limit ( ( $ pageNo - 1 ) * $ entriesPerPage , intval ( $ entriesPerPage ) ) -> build ( ) ; $ totalNumEntries = 0 ; $ results = [ ] ; $ page = $ campaignService -> query ( "$query" ) ; if ( ! empty ( $ page -> getEntries ( ) ) ) { $ totalNumEntries = $ page -> getTotalNumEntries ( ) ; $ results = $ page -> getEntries ( ) ; } $ request -> session ( ) -> put ( 'totalNumEntries' , $ totalNumEntries ) ; return collect ( $ results ) ; }
Fetch campaigns using the provided campaign service selected fields the number of entries per page and the specified page number .
8,593
public function downloadReportAction ( Request $ request , FetchAuthTokenInterface $ oAuth2Credential , AdWordsServices $ adWordsServices , AdWordsSessionBuilder $ adWordsSessionBuilder ) { if ( $ request -> method ( ) === 'POST' ) { $ clientCustomerId = $ request -> input ( 'clientCustomerId' ) ; $ reportType = $ request -> input ( 'reportType' ) ; $ reportRange = $ request -> input ( 'reportRange' ) ; $ entriesPerPage = $ request -> input ( 'entriesPerPage' ) ; $ selectedFields = array_values ( $ request -> except ( [ '_token' , 'clientCustomerId' , 'reportType' , 'entriesPerPage' , 'reportRange' ] ) ) ; $ selectedFields = array_merge ( self :: $ REPORT_TYPE_TO_DEFAULT_SELECTED_FIELDS [ $ reportType ] , $ selectedFields ) ; $ request -> session ( ) -> put ( 'clientCustomerId' , $ clientCustomerId ) ; $ request -> session ( ) -> put ( 'reportType' , $ reportType ) ; $ request -> session ( ) -> put ( 'reportRange' , $ reportRange ) ; $ request -> session ( ) -> put ( 'selectedFields' , $ selectedFields ) ; $ request -> session ( ) -> put ( 'entriesPerPage' , $ entriesPerPage ) ; $ session = $ adWordsSessionBuilder -> fromFile ( config ( 'app.adsapi_php_path' ) ) -> withOAuth2Credential ( $ oAuth2Credential ) -> withClientCustomerId ( $ clientCustomerId ) -> build ( ) ; $ collection = self :: downloadReport ( $ reportType , $ reportRange , new ReportDownloader ( $ session ) , $ selectedFields ) ; $ request -> session ( ) -> put ( 'collection' , $ collection ) ; } else { $ selectedFields = $ request -> session ( ) -> get ( 'selectedFields' ) ; $ entriesPerPage = $ request -> session ( ) -> get ( 'entriesPerPage' ) ; $ collection = $ request -> session ( ) -> get ( 'collection' ) ; } $ pageNo = $ request -> input ( 'page' ) ? : 1 ; $ reportResults = new LengthAwarePaginator ( $ collection -> forPage ( $ pageNo , $ entriesPerPage ) , $ collection -> count ( ) , $ entriesPerPage , $ pageNo , [ 'path' => url ( 'download-report' ) ] ) ; return view ( 'report-results' , compact ( 'reportResults' , 'selectedFields' ) ) ; }
Controls a POST and GET request that is submitted from the Download Report form .
8,594
private function downloadReport ( $ reportType , $ reportRange , ReportDownloader $ reportDownloader , array $ selectedFields ) { $ query = ( new ReportQueryBuilder ( ) ) -> select ( $ selectedFields ) -> from ( $ reportType ) -> duringDateRange ( $ reportRange ) -> build ( ) ; $ reportSettingsOverride = ( new ReportSettingsBuilder ( ) ) -> includeZeroImpressions ( false ) -> build ( ) ; $ reportDownloadResult = $ reportDownloader -> downloadReportWithAwql ( "$query" , DownloadFormat :: XML , $ reportSettingsOverride ) ; $ json = json_encode ( simplexml_load_string ( $ reportDownloadResult -> getAsString ( ) ) ) ; $ resultTable = json_decode ( $ json , true ) [ 'table' ] ; if ( array_key_exists ( 'row' , $ resultTable ) ) { $ row = $ resultTable [ 'row' ] ; $ row = count ( $ row ) > 1 ? $ row : [ $ row ] ; return collect ( $ row ) ; } return collect ( [ ] ) ; }
Download a report of the specified report type and date range selected fields and the number of entries per page .
8,595
private function padContent ( $ content ) { $ numBytes = mb_strlen ( $ content , '8bit' ) ; $ remainder = $ numBytes % self :: $ REQUIRED_CONTENT_BYTES_INCREMENT ; if ( $ remainder > 0 ) { $ targetLength = $ numBytes + ( self :: $ REQUIRED_CONTENT_BYTES_INCREMENT - $ remainder ) ; $ content = str_pad ( $ content , $ targetLength , ' ' ) ; } return $ content ; }
Pads the request content to conform to the requirements of Google Cloud Storage .
8,596
public function createLogger ( $ channel , $ stream = null , $ level = null ) { $ stream = $ stream === null ? fopen ( 'php://stderr' , 'w' ) : $ stream ; $ level = $ level === null ? Logger :: INFO : $ level ; $ handler = new StreamHandler ( $ stream , $ level ) ; $ handler -> getFormatter ( ) -> ignoreEmptyContextAndExtra ( ) ; $ handler -> getFormatter ( ) -> allowInlineLineBreaks ( ) ; return new Logger ( $ channel , [ $ handler ] ) ; }
Creates a Monolog logger with a stream handler configured for this library .
8,597
public function withBindVariableValue ( $ key , $ value ) { $ this -> valueMap [ $ key ] = Pql :: createValue ( $ value ) ; return $ this ; }
Adds a bind variable value to the statement .
8,598
public function toStatement ( ) { $ statement = new Statement ( ) ; $ statement -> setQuery ( $ this -> buildQuery ( ) ) ; $ statement -> setValues ( MapEntries :: fromAssociativeArray ( $ this -> getBindVariableMap ( ) , 'Google\AdsApi\AdManager\v201805\String_ValueMapEntry' ) ) ; return $ statement ; }
Gets the statement representing the state of this statement builder .
8,599
private static function removeKeyword ( $ clause , $ keyword ) { $ keyword .= ' ' ; if ( stristr ( substr ( $ clause , 0 , strlen ( $ keyword ) ) , $ keyword ) !== false ) { return substr ( $ clause , strlen ( $ keyword ) ) ; } return $ clause ; }
Removes the specified keyword from the clause if present . Will remove keyword + .