idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
8,600
|
public function select ( $ columns ) { $ columns = self :: removeKeyword ( $ columns , self :: SELECT ) ; $ this -> select = $ columns ; return $ this ; }
|
Sets the statement SELECT clause in the form of a b ... .
|
8,601
|
public function from ( $ table ) { $ table = self :: removeKeyword ( $ table , self :: FROM ) ; $ this -> from = $ table ; return $ this ; }
|
Sets the statement FROM clause in the form of table .
|
8,602
|
public function increaseOffsetBy ( $ amount ) { if ( $ this -> offset === null ) { $ this -> offset = 0 ; } $ this -> offset += $ amount ; return $ this ; }
|
Increases the offset by the specified amount .
|
8,603
|
private function buildQuery ( ) { $ this -> validateQuery ( ) ; $ statement = "" ; if ( $ this -> select !== null ) { $ statement .= sprintf ( "%s %s " , self :: SELECT , $ this -> select ) ; } if ( $ this -> from !== null ) { $ statement .= sprintf ( "%s %s " , self :: FROM , $ this -> from ) ; } if ( $ this -> where !== null ) { $ statement .= sprintf ( "%s %s " , self :: WHERE , $ this -> where ) ; } if ( $ this -> orderBy !== null ) { $ statement .= sprintf ( "%s %s " , self :: ORDER_BY , $ this -> orderBy ) ; } if ( $ this -> limit !== null ) { $ statement .= sprintf ( "%s %s " , self :: LIMIT , $ this -> limit ) ; } if ( $ this -> offset !== null ) { $ statement .= sprintf ( "%s %s " , self :: OFFSET , $ this -> offset ) ; } return trim ( $ statement ) ; }
|
Builds the query from the clauses .
|
8,604
|
private static function validate ( $ awqlString , $ startIndex , $ pageSize ) { $ validationResult = QueryValidator :: validateServiceQuery ( $ awqlString , false ) ; if ( $ validationResult -> isFailed ( ) ) { throw new InvalidArgumentException ( 'The service query string is invalid. Validation fail reason: ' . $ validationResult -> getFailReason ( ) ) ; } if ( is_null ( $ startIndex ) !== is_null ( $ pageSize ) ) { throw new InvalidArgumentException ( 'Start index and page size' . ' must be both null, or both not null.' ) ; } if ( ! is_null ( $ startIndex ) ) { if ( ! is_int ( $ startIndex ) ) { throw new InvalidArgumentException ( 'The start index must be' . ' an integer.' ) ; } if ( $ startIndex < 0 ) { throw new OutOfBoundsException ( 'The start index must be 0 or' . ' a positive number.' ) ; } } if ( ! is_null ( $ pageSize ) ) { if ( ! is_int ( $ pageSize ) ) { throw new InvalidArgumentException ( 'The page size must be' . ' an integer.' ) ; } if ( $ pageSize < 1 ) { throw new OutOfBoundsException ( 'The page size must be a' . ' positive number.' ) ; } } }
|
Validates the arguments for constructing a service query object .
|
8,605
|
private static function countLandscapePoints ( Page $ page ) { $ entries = $ page -> getEntries ( ) ; if ( is_null ( $ entries ) ) { return 0 ; } $ totalLandscapePointsInPage = 0 ; foreach ( $ entries as $ entry ) { $ totalLandscapePointsInPage += count ( $ entry -> getLandscapePoints ( ) ) ; } return $ totalLandscapePointsInPage ; }
|
Counts the number of landscape points in a AdGroupBidLandscapePage or AdGroupBidLandscapePage page .
|
8,606
|
public function nextPage ( Page $ previousPage = null ) { if ( is_null ( $ previousPage ) ) { $ this -> startIndex = $ this -> startIndex + $ this -> pageSize ; return $ this ; } if ( ! ( $ previousPage instanceof AdGroupBidLandscapePage ) && ! ( $ previousPage instanceof CriterionBidLandscapePage ) ) { throw new InvalidArgumentException ( 'The page object must be an' . ' instance of either `AdGroupBidLandscapePage` or' . ' `CriterionBidLandscapePage` type' ) ; } $ this -> startIndex = $ this -> startIndex + self :: countLandscapePoints ( $ previousPage ) ; return $ this ; }
|
Increases the start index by the current page size .
|
8,607
|
public function hasNext ( Page $ previousPage ) { if ( $ previousPage instanceof AdGroupBidLandscapePage || $ previousPage instanceof CriterionBidLandscapePage ) { return $ this -> pageSize <= self :: countLandscapePoints ( $ previousPage ) ; } if ( is_null ( $ this -> totalNumEntries ) ) { $ this -> totalNumEntries = $ previousPage -> getTotalNumEntries ( ) ; } return $ this -> startIndex + $ this -> pageSize < $ this -> totalNumEntries ; }
|
Checks if there are still entries to be fetched on the next page .
|
8,608
|
public static function runExample ( ServiceFactory $ serviceFactory , AdManagerSession $ session ) { $ networkService = $ serviceFactory -> createNetworkService ( $ session ) ; $ networks = $ networkService -> getAllNetworks ( ) ; if ( empty ( $ networks ) ) { printf ( 'No accessible networks found.' . PHP_EOL ) ; return ; } foreach ( $ networks as $ i => $ network ) { printf ( "%d) Network with code %d and display name '%s' was found.%s" , $ i , $ network -> getNetworkCode ( ) , $ network -> getDisplayName ( ) , PHP_EOL ) ; } printf ( "Number of results found: %d%s" , count ( $ networks ) , PHP_EOL ) ; }
|
Gets all networks .
|
8,609
|
public function getHome ( ) { $ home = null ; if ( ! empty ( getenv ( 'HOME' ) ) ) { $ home = getenv ( 'HOME' ) ; } elseif ( ! empty ( $ _SERVER [ 'HOME' ] ) ) { $ home = $ _SERVER [ 'HOME' ] ; } elseif ( ! empty ( getenv ( 'HOMEDRIVE' ) ) && ! empty ( getenv ( 'HOMEPATH' ) ) ) { $ home = getenv ( 'HOMEDRIVE' ) . getenv ( 'HOMEPATH' ) ; } elseif ( ! empty ( $ _SERVER [ 'HOMEDRIVE' ] ) && ! empty ( $ _SERVER [ 'HOMEPATH' ] ) ) { $ home = $ _SERVER [ 'HOMEDRIVE' ] . $ _SERVER [ 'HOMEPATH' ] ; } if ( $ home === null ) { throw new UnexpectedValueException ( 'Could not locate home directory.' ) ; } return rtrim ( $ home , '\\/' ) ; }
|
Attempts to find the home directory of the user running the PHP script .
|
8,610
|
public static function copyFrom ( ReportQueryBuilderDelegate $ otherInstance , ReportQueryBuilder $ queryBuilder ) { $ copyingInstance = new self ( ) ; $ copyingInstance -> selectFields = $ otherInstance -> selectFields ; $ copyingInstance -> fromReportType = $ otherInstance -> fromReportType ; $ copyingInstance -> duringDateRangeType = $ otherInstance -> duringDateRangeType ; $ copyingInstance -> duringStartDate = $ otherInstance -> duringStartDate ; $ copyingInstance -> duringEndDate = $ otherInstance -> duringEndDate ; if ( isset ( $ otherInstance -> whereBuilders ) ) { $ copyingInstance -> whereBuilders = [ ] ; foreach ( $ otherInstance -> whereBuilders as $ whereBuilder ) { $ copyingInstance -> whereBuilders [ ] = ReportQueryWhereBuilder :: copyFrom ( $ whereBuilder , $ queryBuilder ) ; } } return $ copyingInstance ; }
|
Creates a new query builder delegate object by copying field names WHERE FROM and DURING clauses from another query builder delegate object .
|
8,611
|
public function during ( $ startDate , $ endDate ) { $ validationResult = QueryValidator :: validateCustomDateRange ( $ startDate , $ endDate ) ; if ( $ validationResult -> isFailed ( ) ) { throw new InvalidArgumentException ( 'The start or end date is' . ' invalid. Validation fail reasons: ' . $ validationResult -> getFailReason ( ) ) ; } $ this -> duringStartDate = $ startDate ; $ this -> duringEndDate = $ endDate ; }
|
Sets a custom date range by specifying the start and end dates .
|
8,612
|
public static function fromDateTime ( DateTime $ dateTime ) { $ date = new Date ( ) ; $ date -> setYear ( intval ( $ dateTime -> format ( 'Y' ) ) ) ; $ date -> setMonth ( intval ( $ dateTime -> format ( 'm' ) ) ) ; $ date -> setDay ( intval ( $ dateTime -> format ( 'd' ) ) ) ; $ result = new AdManagerDateTime ( ) ; $ result -> setDate ( $ date ) ; $ result -> setHour ( intval ( $ dateTime -> format ( 'H' ) ) ) ; $ result -> setMinute ( intval ( $ dateTime -> format ( 'i' ) ) ) ; $ result -> setSecond ( intval ( $ dateTime -> format ( 's' ) ) ) ; $ result -> setTimeZoneID ( $ dateTime -> format ( 'e' ) ) ; return $ result ; }
|
Creates a Ad Manager date time from a PHP date time .
|
8,613
|
public static function toDateTime ( AdManagerDateTime $ adManagerDateTime ) { $ dateTimeString = sprintf ( '%sT%02d:%02d:%02d' , AdManagerDates :: toDateString ( $ adManagerDateTime -> getDate ( ) ) , $ adManagerDateTime -> getHour ( ) , $ adManagerDateTime -> getMinute ( ) , $ adManagerDateTime -> getSecond ( ) ) ; return new DateTime ( $ dateTimeString , new DateTimeZone ( $ adManagerDateTime -> getTimeZoneID ( ) ) ) ; }
|
Converts a Ad Manager date time to a PHP date time .
|
8,614
|
public static function toDateTimeString ( AdManagerDateTime $ adManagerDateTime , $ timeZoneId = null ) { $ dateTime = self :: toDateTime ( $ adManagerDateTime ) ; if ( $ timeZoneId !== null ) { $ dateTime -> setTimezone ( new DateTimeZone ( $ timeZoneId ) ) ; } return $ dateTime -> format ( DateTime :: ATOM ) ; }
|
Returns an ISO 8601 string representation of the specified Ad Manager date time .
|
8,615
|
public static function validateFieldName ( $ fieldName ) { if ( ! is_string ( $ fieldName ) ) { return ValidationResult :: fail ( 'The field name must be a' . ' string.' ) ; } if ( empty ( trim ( $ fieldName ) ) ) { return ValidationResult :: fail ( 'The field name must not be' . ' null, empty, white spaces or zero.' ) ; } return ValidationResult :: pass ( ) ; }
|
Validates a field name for using in the SELECT WHERE or ORDER BY clauses of an AWQL string .
|
8,616
|
public static function validateCustomDateRange ( $ startDateString , $ endDateString ) { $ startDate = DateTime :: createFromFormat ( 'Ymd' , $ startDateString ) ; $ warningsFound = ! empty ( DateTime :: getLastErrors ( ) [ 'warnings' ] ) ; if ( false === $ startDate || $ warningsFound ) { return ValidationResult :: fail ( 'The start date must be a valid' . ' date and follow YYYYMMDD format.' ) ; } $ endDate = DateTime :: createFromFormat ( 'Ymd' , $ endDateString ) ; $ warningsFound = ! empty ( DateTime :: getLastErrors ( ) [ 'warnings' ] ) ; if ( false === $ endDate || $ warningsFound ) { return ValidationResult :: fail ( 'The end date must be a valid date' . ' and follow YYYYMMDD format.' ) ; } if ( $ endDate < $ startDate ) { return ValidationResult :: fail ( 'The end date must not be prior to' . ' the start date.' ) ; } return ValidationResult :: pass ( ) ; }
|
Validates the start and end dates of a custom date range in the DURING clause of an AWQL string .
|
8,617
|
private static function containKeywords ( $ awqlString , $ clauseKeywords , $ containAll ) { $ patterns = array_map ( function ( $ keyword ) { return "/\w+$keyword\w+/i" ; } , $ clauseKeywords ) ; array_unshift ( $ patterns , self :: PATTERN_LITERAL_STRING ) ; $ awqlStringWithoutLiteralStrings = preg_replace ( $ patterns , self :: REDACTED_LITERAL_STRING , $ awqlString ) ; $ count = 0 ; foreach ( $ clauseKeywords as $ clause ) { if ( false !== stripos ( $ awqlStringWithoutLiteralStrings , $ clause ) ) { if ( ! $ containAll ) { return true ; } $ count ++ ; } } return $ count === count ( $ clauseKeywords ) ; }
|
Checks if an AWQL string contains certain clauses by searching for the clause opening keywords .
|
8,618
|
private static function validateQuery ( $ awqlString , $ requiredKeywords , $ forbiddenKeywords ) { if ( empty ( $ awqlString ) ) { return ValidationResult :: fail ( 'The AWQL string must not be' . ' null or empty' ) ; } if ( ! self :: containAllKeywords ( $ awqlString , $ requiredKeywords ) ) { return ValidationResult :: fail ( sprintf ( 'The AWQL string must contain %s clause(s).' , implode ( ', ' , $ requiredKeywords ) ) ) ; } if ( self :: containAnyKeywords ( $ awqlString , $ forbiddenKeywords ) ) { return ValidationResult :: fail ( sprintf ( 'The AWQL string must not contain %s clauses.' , implode ( ', ' , $ forbiddenKeywords ) ) ) ; } return ValidationResult :: pass ( ) ; }
|
Checks if the AWQL string contains the required clause opening keywords but not the forbidden ones .
|
8,619
|
public static function validateServiceQuery ( $ awqlString , $ allowPagination = true ) { $ forbiddenKeywords = [ 'FROM' , 'DURING' ] ; if ( ! $ allowPagination ) { $ forbiddenKeywords [ ] = 'LIMIT' ; } return self :: validateQuery ( $ awqlString , [ 'SELECT' ] , $ forbiddenKeywords ) ; }
|
Validates a service query AWQL string .
|
8,620
|
private static function createSitelinksFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ feedService = $ adWordsServices -> get ( $ session , FeedService :: class ) ; $ sitelinksData = [ ] ; $ textAttribute = new FeedAttribute ( ) ; $ textAttribute -> setType ( FeedAttributeType :: STRING ) ; $ textAttribute -> setName ( 'Link Text' ) ; $ finalUrlAttribute = new FeedAttribute ( ) ; $ finalUrlAttribute -> setType ( FeedAttributeType :: URL_LIST ) ; $ finalUrlAttribute -> setName ( 'Link URL' ) ; $ line2Attribute = new FeedAttribute ( ) ; $ line2Attribute -> setType ( FeedAttributeType :: STRING ) ; $ line2Attribute -> setName ( 'Line 2' ) ; $ line3Attribute = new FeedAttribute ( ) ; $ line3Attribute -> setType ( FeedAttributeType :: STRING ) ; $ line3Attribute -> setName ( 'Line 3' ) ; $ sitelinksFeed = new Feed ( ) ; $ sitelinksFeed -> setName ( 'Feed For Sitelinks #' . uniqid ( ) ) ; $ sitelinksFeed -> setAttributes ( [ $ textAttribute , $ finalUrlAttribute , $ line2Attribute , $ line3Attribute ] ) ; $ sitelinksFeed -> setOrigin ( FeedOrigin :: USER ) ; $ operation = new FeedOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ sitelinksFeed ) ; $ result = $ feedService -> mutate ( [ $ operation ] ) ; $ savedFeed = $ result -> getValue ( ) [ 0 ] ; $ sitelinksData [ 'sitelinksFeedId' ] = $ savedFeed -> getId ( ) ; $ savedAttributes = $ savedFeed -> getAttributes ( ) ; $ sitelinksData [ 'linkTextFeedAttributeId' ] = $ savedAttributes [ 0 ] -> getId ( ) ; $ sitelinksData [ 'linkFinalUrlFeedAttributeId' ] = $ savedAttributes [ 1 ] -> getId ( ) ; $ sitelinksData [ 'line2FeedAttribute' ] = $ savedAttributes [ 2 ] -> getId ( ) ; $ sitelinksData [ 'line3FeedAttribute' ] = $ savedAttributes [ 3 ] -> getId ( ) ; printf ( "Feed with name '%s', ID %d with linkTextAttributeId %d, " . "linkFinalUrlAttributeId %d, line2AttributeId %d and " . "line3AttributeId %d was created.%s" , $ savedFeed -> getName ( ) , $ savedFeed -> getId ( ) , $ savedAttributes [ 0 ] -> getId ( ) , $ savedAttributes [ 1 ] -> getId ( ) , $ savedAttributes [ 2 ] -> getId ( ) , $ savedAttributes [ 3 ] -> getId ( ) , PHP_EOL ) ; return $ sitelinksData ; }
|
Creates the feed that holds the sitelinks data .
|
8,621
|
private static function createSitelinksFeedItems ( AdWordsServices $ adWordsServices , AdWordsSession $ session , array $ sitelinksData ) { $ feedItemService = $ adWordsServices -> get ( $ session , FeedItemService :: class ) ; $ home = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Home' , 'http://www.example.com' , 'Home line 2' , 'Home line 3' ) ; $ stores = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Stores' , 'http://www.example.com/stores' , 'Stores line 2' , 'Stores line 3' ) ; $ onSale = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'On Sale' , 'http://www.example.com/sale' , 'On Sale line 2' , 'On Sale line 3' ) ; $ support = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Support' , 'http://www.example.com/support' , 'Support line 2' , 'Support line 3' ) ; $ products = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Products' , 'http://www.example.com/products' , 'Products line 2' , 'Products line 3' ) ; $ aboutUs = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'About Us' , 'http://www.example.com/about' , 'About Us line 2' , 'About Us line 3' , true ) ; $ result = $ feedItemService -> mutate ( [ $ home , $ stores , $ onSale , $ support , $ products , $ aboutUs ] ) ; $ sitelinksData [ 'sitelinkFeedItemIds' ] = [ ] ; foreach ( $ result -> getValue ( ) as $ feedItem ) { printf ( 'Feed item with feed item ID %d was added.%s' , $ feedItem -> getFeedItemId ( ) , PHP_EOL ) ; $ sitelinksData [ 'sitelinkFeedItemIds' ] [ ] = $ feedItem -> getFeedItemId ( ) ; } self :: restrictFeedItemToGeoTarget ( $ adWordsServices , $ session , $ result -> getValue ( ) [ 5 ] , 21137 ) ; return $ sitelinksData ; }
|
Creates sitelinks feed items and add it to the feed .
|
8,622
|
private static function createSitelinksFeedMapping ( AdWordsServices $ adWordsServices , AdWordsSession $ session , array $ sitelinksData ) { $ feedMappingService = $ adWordsServices -> get ( $ session , FeedMappingService :: class ) ; $ linkTextFieldMapping = new AttributeFieldMapping ( ) ; $ linkTextFieldMapping -> setFeedAttributeId ( $ sitelinksData [ 'linkTextFeedAttributeId' ] ) ; $ linkTextFieldMapping -> setFieldId ( self :: PLACEHOLDER_FIELD_SITELINK_LINK_TEXT ) ; $ linkFinalUrlFieldMapping = new AttributeFieldMapping ( ) ; $ linkFinalUrlFieldMapping -> setFeedAttributeId ( $ sitelinksData [ 'linkFinalUrlFeedAttributeId' ] ) ; $ linkFinalUrlFieldMapping -> setFieldId ( self :: PLACEHOLDER_FIELD_SITELINK_FINAL_URL ) ; $ line2FieldMapping = new AttributeFieldMapping ( ) ; $ line2FieldMapping -> setFeedAttributeId ( $ sitelinksData [ 'line2FeedAttribute' ] ) ; $ line2FieldMapping -> setFieldId ( self :: PLACEHOLDER_FIELD_LINE_2_TEXT ) ; $ line3FieldMapping = new AttributeFieldMapping ( ) ; $ line3FieldMapping -> setFeedAttributeId ( $ sitelinksData [ 'line3FeedAttribute' ] ) ; $ line3FieldMapping -> setFieldId ( self :: PLACEHOLDER_FIELD_LINE_3_TEXT ) ; $ feedMapping = new FeedMapping ( ) ; $ feedMapping -> setPlaceholderType ( self :: PLACEHOLDER_SITELINKS ) ; $ feedMapping -> setFeedId ( $ sitelinksData [ 'sitelinksFeedId' ] ) ; $ feedMapping -> setAttributeFieldMappings ( [ $ linkTextFieldMapping , $ linkFinalUrlFieldMapping , $ line2FieldMapping , $ line3FieldMapping ] ) ; $ operation = new FeedMappingOperation ( ) ; $ operation -> setOperand ( $ feedMapping ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ feedMappingService -> mutate ( [ $ operation ] ) ; foreach ( $ result -> getValue ( ) as $ feedMapping ) { printf ( 'Feed mapping with ID %d and placeholder type %d was ' . 'saved for feed with ID %d.%s' , $ feedMapping -> getFeedMappingId ( ) , $ feedMapping -> getPlaceholderType ( ) , $ feedMapping -> getFeedId ( ) , PHP_EOL ) ; } }
|
Maps the feed attributes to the sitelink placeholders .
|
8,623
|
private static function createSitelinksCampaignFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session , array $ sitelinksData , $ campaignId ) { $ campaignFeedService = $ adWordsServices -> get ( $ session , CampaignFeedService :: class ) ; $ matchingFunctionString = sprintf ( 'AND( IN(FEED_ITEM_ID, {%s}), EQUALS(CONTEXT.DEVICE, "Mobile") )' , implode ( ',' , $ sitelinksData [ 'sitelinkFeedItemIds' ] ) ) ; $ campaignFeed = new CampaignFeed ( ) ; $ campaignFeed -> setFeedId ( $ sitelinksData [ 'sitelinksFeedId' ] ) ; $ campaignFeed -> setCampaignId ( $ campaignId ) ; $ matchingFunction = new MatchingFunction ( ) ; $ matchingFunction -> setFunctionString ( $ matchingFunctionString ) ; $ campaignFeed -> setMatchingFunction ( $ matchingFunction ) ; $ campaignFeed -> setPlaceholderTypes ( [ self :: PLACEHOLDER_SITELINKS ] ) ; $ operation = new CampaignFeedOperation ( ) ; $ operation -> setOperand ( $ campaignFeed ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ campaignFeedService -> mutate ( [ $ operation ] ) ; foreach ( $ result -> getValue ( ) as $ savedCampaignFeed ) { printf ( 'Campaign with ID %d was associated with feed with ID %d.%s' , $ savedCampaignFeed -> getCampaignId ( ) , $ savedCampaignFeed -> getFeedId ( ) , PHP_EOL ) ; } }
|
Creates the campaign feed associated to the populated feed data for the specified campaign ID .
|
8,624
|
private static function restrictFeedItemToAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ feedId , $ feedItemId , $ adGroupId ) { $ feedItemTargetService = $ adWordsServices -> get ( $ session , FeedItemTargetService :: class ) ; $ feedItemAdGroupTarget = new FeedItemAdGroupTarget ( ) ; $ feedItemAdGroupTarget -> setFeedId ( $ feedId ) ; $ feedItemAdGroupTarget -> setFeedItemId ( $ feedItemId ) ; $ feedItemAdGroupTarget -> setAdGroupId ( $ adGroupId ) ; $ operation = new FeedItemTargetOperation ( ) ; $ operation -> setOperand ( $ feedItemAdGroupTarget ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ feedItemTargetService -> mutate ( [ $ operation ] ) ; $ feedItemAdGroupTarget = $ result -> getValue ( ) [ 0 ] ; printf ( 'Feed item target for feed ID %d and feed item ID %d was ' . 'created to restrict serving to ad group ID %d.%s' , $ feedItemAdGroupTarget -> getFeedId ( ) , $ feedItemAdGroupTarget -> getFeedItemId ( ) , $ feedItemAdGroupTarget -> getAdGroupId ( ) , PHP_EOL ) ; }
|
Creates feed item ad group target for a specified feed ID feed item ID and ad group ID .
|
8,625
|
private static function restrictFeedItemToGeoTarget ( AdWordsServices $ adWordsServices , AdWordsSession $ session , FeedItem $ feedItem , $ locationId ) { $ feedItemTargetService = $ adWordsServices -> get ( $ session , FeedItemTargetService :: class ) ; $ feedItemCriterionTarget = new FeedItemCriterionTarget ( ) ; $ feedItemCriterionTarget -> setFeedId ( $ feedItem -> getFeedId ( ) ) ; $ feedItemCriterionTarget -> setFeedItemId ( $ feedItem -> getFeedItemId ( ) ) ; $ location = new Location ( ) ; $ location -> setId ( $ locationId ) ; $ feedItemCriterionTarget -> setCriterion ( $ location ) ; $ operation = new FeedItemTargetOperation ( ) ; $ operation -> setOperand ( $ feedItemCriterionTarget ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ feedItemTargetService -> mutate ( [ $ operation ] ) ; $ feedItemCriterionTarget = $ result -> getValue ( ) [ 0 ] ; printf ( 'Feed item target for feed ID %d and feed item ID %d was ' . 'created to restrict serving to location ID %d.%s' , $ feedItemCriterionTarget -> getFeedId ( ) , $ feedItemCriterionTarget -> getFeedItemId ( ) , $ feedItemCriterionTarget -> getCriterion ( ) -> getId ( ) , PHP_EOL ) ; }
|
Restricts the first feed item to only serve with ads for the specified location ID .
|
8,626
|
private static function newSitelinkFeedItemAddOperation ( array $ sitelinksData , $ text , $ finalUrl , $ line2 , $ line3 , $ restrictToLop = null ) { $ linkTextAttributeValue = new FeedItemAttributeValue ( ) ; $ linkTextAttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'linkTextFeedAttributeId' ] ) ; $ linkTextAttributeValue -> setStringValue ( $ text ) ; $ linkFinalUrlAttributeValue = new FeedItemAttributeValue ( ) ; $ linkFinalUrlAttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'linkFinalUrlFeedAttributeId' ] ) ; $ linkFinalUrlAttributeValue -> setStringValues ( [ $ finalUrl ] ) ; $ line2AttributeValue = new FeedItemAttributeValue ( ) ; $ line2AttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'line2FeedAttribute' ] ) ; $ line2AttributeValue -> setStringValue ( $ line2 ) ; $ line3AttributeValue = new FeedItemAttributeValue ( ) ; $ line3AttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'line3FeedAttribute' ] ) ; $ line3AttributeValue -> setStringValue ( $ line3 ) ; $ item = new FeedItem ( ) ; $ item -> setFeedId ( $ sitelinksData [ 'sitelinksFeedId' ] ) ; $ item -> setAttributeValues ( [ $ linkTextAttributeValue , $ linkFinalUrlAttributeValue , $ line2AttributeValue , $ line3AttributeValue ] ) ; if ( $ restrictToLop === true ) { $ item -> setGeoTargetingRestriction ( new FeedItemGeoRestriction ( GeoRestriction :: LOCATION_OF_PRESENCE ) ) ; } $ operation = new FeedItemOperation ( ) ; $ operation -> setOperand ( $ item ) ; $ operation -> setOperator ( Operator :: ADD ) ; return $ operation ; }
|
Creates a site link feed item and wraps it in an ADD operation .
|
8,627
|
public static function toDateString ( Date $ adManagerDate ) { return sprintf ( '%d-%02d-%02d' , $ adManagerDate -> getYear ( ) , $ adManagerDate -> getMonth ( ) , $ adManagerDate -> getDay ( ) ) ; }
|
Returns string representation of the specified Ad Manager date in yyyy - MM - dd format .
|
8,628
|
public static function replaceReferences ( $ request ) { $ requestDom = new DOMDocument ( ) ; try { set_error_handler ( [ self :: class , 'handleLoadXmlWarnings' ] ) ; $ requestDom -> loadXML ( $ request ) ; } catch ( DOMException $ e ) { return $ request ; } finally { restore_error_handler ( ) ; } $ xpath = new DOMXPath ( $ requestDom ) ; $ references = $ xpath -> query ( '//*[@href]' ) ; $ referencedElementsCache = [ ] ; foreach ( $ references as $ reference ) { $ id = substr ( $ reference -> getAttribute ( 'href' ) , 1 ) ; if ( ! array_key_exists ( $ id , $ referencedElementsCache ) ) { $ referencedElements = $ xpath -> query ( sprintf ( "//*[@id='%s']" , $ id ) ) ; if ( $ referencedElements -> length > 0 ) { $ referencedElementsCache [ $ id ] = $ referencedElements -> item ( 0 ) ; } else { continue ; } } foreach ( $ referencedElementsCache [ $ id ] -> childNodes as $ childNode ) { $ reference -> appendChild ( $ childNode -> cloneNode ( true ) ) ; } $ reference -> removeAttribute ( 'href' ) ; } foreach ( array_keys ( $ referencedElementsCache ) as $ id ) { $ referencedElements = $ xpath -> query ( sprintf ( "//*[@id='%s']" , $ id ) ) ; foreach ( $ referencedElements as $ referencedElement ) { $ referencedElement -> removeAttribute ( 'id' ) ; } } return $ requestDom -> saveXML ( ) ; }
|
Iterates through all nodes with an href attribute in the specified request SOAP XML string and replaces them with the node they are referencing .
|
8,629
|
public static function appendWhereClause ( $ whereBuilders , $ awql ) { if ( empty ( $ whereBuilders ) ) { return $ awql ; } $ conditions = [ ] ; foreach ( $ whereBuilders as $ whereBuilder ) { $ conditions [ ] = $ whereBuilder -> buildWhere ( ) ; } return sprintf ( '%s WHERE %s' , $ awql , implode ( ' AND ' , $ conditions ) ) ; }
|
Builds and appends a WHERE clause to a partial AWQL string . If there is no expressions specified the input AWQL string will be returned without modifications .
|
8,630
|
private static function createSmartCampaign ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ budgetId , $ merchantId ) { $ campaignService = $ adWordsServices -> get ( $ session , CampaignService :: class ) ; $ campaign = new Campaign ( ) ; $ campaign -> setName ( 'Smart Shopping campaign #' . uniqid ( ) ) ; $ campaign -> setAdvertisingChannelType ( AdvertisingChannelType :: SHOPPING ) ; $ campaign -> setAdvertisingChannelSubType ( AdvertisingChannelSubType :: SHOPPING_GOAL_OPTIMIZED_ADS ) ; $ campaign -> setStatus ( CampaignStatus :: PAUSED ) ; $ budget = new Budget ( ) ; $ budget -> setBudgetId ( $ budgetId ) ; $ campaign -> setBudget ( $ budget ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ biddingStrategyConfiguration -> setBiddingStrategyType ( BiddingStrategyType :: MAXIMIZE_CONVERSION_VALUE ) ; $ campaign -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ shoppingSetting = new ShoppingSetting ( ) ; $ shoppingSetting -> setSalesCountry ( 'US' ) ; $ shoppingSetting -> setMerchantId ( $ merchantId ) ; $ campaign -> setSettings ( [ $ shoppingSetting ] ) ; $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ campaign ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ addedCampaign = $ campaignService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] ; printf ( "Smart Shopping campaign with name '%s' and ID %d was added.%s" , $ addedCampaign -> getName ( ) , $ addedCampaign -> getId ( ) , PHP_EOL ) ; return $ addedCampaign -> getId ( ) ; }
|
Creates a Smart Shopping campaign .
|
8,631
|
private static function createSmartShoppingAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ campaignId ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; $ adGroup = new AdGroup ( ) ; $ adGroup -> setCampaignId ( $ campaignId ) ; $ adGroup -> setName ( 'Smart Shopping ad group #' . uniqid ( ) ) ; $ adGroup -> setAdGroupType ( AdGroupType :: SHOPPING_GOAL_OPTIMIZED_ADS ) ; $ adGroupOperation = new AdGroupOperation ( ) ; $ adGroupOperation -> setOperand ( $ adGroup ) ; $ adGroupOperation -> setOperator ( Operator :: ADD ) ; $ addedAdGroup = $ adGroupService -> mutate ( [ $ adGroupOperation ] ) -> getValue ( ) [ 0 ] ; printf ( "Smart Shopping ad group with name '%s' and ID %d was added.%s" , $ addedAdGroup -> getName ( ) , $ addedAdGroup -> getId ( ) , PHP_EOL ) ; return $ addedAdGroup -> getId ( ) ; }
|
Creates a Smart Shopping ad group by setting the ad group type to SHOPPING_GOAL_OPTIMIZED_ADS .
|
8,632
|
private static function createSmartShoppingAd ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; $ smartShoppingAd = new GoalOptimizedShoppingAd ( ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroupId ) ; $ adGroupAd -> setAd ( $ smartShoppingAd ) ; $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperand ( $ adGroupAd ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ addedAdGroupAd = $ adGroupAdService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] ; printf ( "Smart Shopping ad with ID %d was added.%s" , $ addedAdGroupAd -> getAd ( ) -> getId ( ) , PHP_EOL ) ; }
|
Creates a Smart Shopping ad .
|
8,633
|
private static function createDefaultPartition ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ adGroupId ) { $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; $ productPartition = new ProductPartition ( ) ; $ productPartition -> setPartitionType ( ProductPartitionType :: UNIT ) ; $ criterion = new BiddableAdGroupCriterion ( ) ; $ criterion -> setAdGroupId ( $ adGroupId ) ; $ criterion -> setCriterion ( $ productPartition ) ; $ operation = new AdGroupCriterionOperation ( ) ; $ operation -> setOperand ( $ criterion ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ addedAdGroupCriterion = $ adGroupCriterionService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] ; printf ( "Ad group criterion with ID %d in ad group with ID %d" . " was added.%s" , $ addedAdGroupCriterion -> getCriterion ( ) -> getId ( ) , $ addedAdGroupCriterion -> getAdGroupId ( ) , PHP_EOL ) ; }
|
Creates a default product partition as an ad group criterion .
|
8,634
|
public function createRequestOptionsWithReportDefinition ( ReportDefinition $ reportDefinition , ReportSettings $ reportSettingsOverride = null ) { $ params = [ ] ; $ context = [ 'xml_root_node_name' => 'reportDefinition' ] ; $ params [ '__rdxml' ] = $ this -> reportDefinitionSerializer -> serialize ( $ reportDefinition , 'xml' , $ context ) ; return array_merge ( $ this -> options , [ RequestOptions :: HEADERS => $ this -> createHeaders ( $ reportSettingsOverride ) , RequestOptions :: FORM_PARAMS => $ params , ] ) ; }
|
Creates request options for downloading a report using an XML - based report definition .
|
8,635
|
public function createRequestOptionsWithAwqlQuery ( $ reportDefinition , $ reportFormat , ReportSettings $ reportSettingsOverride = null ) { $ params = [ '__rdquery' => $ reportDefinition , '__fmt' => $ reportFormat ] ; return array_merge ( $ this -> options , [ RequestOptions :: HEADERS => $ this -> createHeaders ( $ reportSettingsOverride ) , RequestOptions :: FORM_PARAMS => $ params , ] ) ; }
|
Creates request options for downloading a report using an AWQL - based report definition .
|
8,636
|
private static function buildAdGroupAdOperations ( array $ adGroupOperations ) { $ operations = [ ] ; foreach ( $ adGroupOperations as $ adGroupOperation ) { $ adGroupId = $ adGroupOperation -> getOperand ( ) -> getId ( ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroupId ) ; $ expandedTextAd = new ExpandedTextAd ( ) ; $ expandedTextAd -> setHeadlinePart1 ( 'Luxury Cruise to Mars' ) ; $ expandedTextAd -> setHeadlinePart2 ( 'Visit the Red Planet in style.' ) ; $ expandedTextAd -> setDescription ( 'Low-gravity fun for everyone!' ) ; $ expandedTextAd -> setFinalUrls ( [ 'http://www.example.com/1' ] ) ; $ adGroupAd -> setAd ( $ expandedTextAd ) ; $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ adGroupAd ) ; $ operations [ ] = $ operation ; } return $ operations ; }
|
Builds objects of AdGroupAdOperation for creating an ad group ad for ad groups in the specified ad group operations .
|
8,637
|
private static function buildAdGroupOperations ( $ namePrefix , array $ campaignOperations ) { $ operations = [ ] ; foreach ( $ campaignOperations as $ campaignOperation ) { for ( $ i = 0 ; $ i < self :: NUMBER_OF_ADGROUPS_TO_ADD ; $ i ++ ) { $ adGroup = new AdGroup ( ) ; $ adGroup -> setCampaignId ( $ campaignOperation -> getOperand ( ) -> getId ( ) ) ; $ adGroup -> setId ( -- self :: $ temporaryId ) ; $ adGroup -> setName ( sprintf ( 'Batch Ad Group %s.%s' , $ namePrefix , strval ( $ adGroup -> getId ( ) ) ) ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 10000000 ) ; $ bid = new CpcBid ( ) ; $ bid -> setBid ( $ money ) ; $ biddingStrategyConfiguration -> setBids ( [ $ bid ] ) ; $ adGroup -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ operation = new AdGroupOperation ( ) ; $ operation -> setOperand ( $ adGroup ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; } } return $ operations ; }
|
Builds objects of AdGroupOperation for creating ad groups for campaigns in the specified campaign operations .
|
8,638
|
private static function buildCampaignOperations ( $ namePrefix , BudgetOperation $ budgetOperation ) { $ budgetId = $ budgetOperation -> getOperand ( ) -> getBudgetId ( ) ; $ operations = [ ] ; for ( $ i = 0 ; $ i < self :: NUMBER_OF_CAMPAIGNS_TO_ADD ; $ i ++ ) { $ campaign = new Campaign ( ) ; $ campaign -> setId ( -- self :: $ temporaryId ) ; $ campaign -> setName ( sprintf ( 'Batch Campaign %s.%s' , $ namePrefix , strval ( $ campaign -> getId ( ) ) ) ) ; $ campaign -> setStatus ( CampaignStatus :: PAUSED ) ; $ campaign -> setAdvertisingChannelType ( AdvertisingChannelType :: SEARCH ) ; $ budget = new Budget ( ) ; $ budget -> setBudgetId ( $ budgetId ) ; $ campaign -> setBudget ( $ budget ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ biddingStrategyConfiguration -> setBiddingStrategyType ( BiddingStrategyType :: MANUAL_CPC ) ; $ cpcBiddingScheme = new ManualCpcBiddingScheme ( ) ; $ biddingStrategyConfiguration -> setBiddingScheme ( $ cpcBiddingScheme ) ; $ campaign -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ campaign ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; } return $ operations ; }
|
Builds objects of CampaignOperation for creating a campaign using the ID of budget in the specified budget operation .
|
8,639
|
private static function buildBudgetOperation ( $ namePrefix ) { $ budget = new Budget ( ) ; $ budget -> setBudgetId ( -- self :: $ temporaryId ) ; $ budget -> setName ( 'Interplanetary Cruise #' . $ namePrefix ) ; $ budgetAmount = new Money ( ) ; $ budgetAmount -> setMicroAmount ( 50000000 ) ; $ budget -> setAmount ( $ budgetAmount ) ; $ budget -> setDeliveryMethod ( BudgetBudgetDeliveryMethod :: STANDARD ) ; $ budgetOperation = new BudgetOperation ( ) ; $ budgetOperation -> setOperand ( $ budget ) ; $ budgetOperation -> setOperator ( Operator :: ADD ) ; return $ budgetOperation ; }
|
Builds BudgetOperation for creating a budget .
|
8,640
|
private static function createOfflineData ( \ DateTime $ transactionTime , $ transactionMicroAmount , $ transactionCurrency , $ conversionName , array $ userIdentifierList ) { $ storeSalesTransaction = new StoreSalesTransaction ( ) ; $ storeSalesTransaction -> setTransactionTime ( $ transactionTime -> format ( 'Ymd His' ) ) ; $ storeSalesTransaction -> setConversionName ( $ conversionName ) ; $ storeSalesTransaction -> setUserIdentifiers ( $ userIdentifierList ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( $ transactionMicroAmount ) ; $ moneyWithCurrency = new MoneyWithCurrency ( ) ; $ moneyWithCurrency -> setMoney ( $ money ) ; $ moneyWithCurrency -> setCurrencyCode ( $ transactionCurrency ) ; $ storeSalesTransaction -> setTransactionAmount ( $ moneyWithCurrency ) ; $ offlineData = new OfflineData ( ) ; $ offlineData -> setStoreSalesTransaction ( $ storeSalesTransaction ) ; return $ offlineData ; }
|
Creates the offline data from the specified transaction time transaction micro amount transaction currency conversion name and user identifier list .
|
8,641
|
private static function createUserIdentifier ( $ type , $ value ) { if ( 0 === strpos ( $ type , 'HASHED_' ) ) { $ value = hash ( 'sha256' , strtolower ( trim ( $ value ) ) ) ; } $ userIdentifier = new UserIdentifier ( ) ; $ userIdentifier -> setUserIdentifierType ( $ type ) ; $ userIdentifier -> setValue ( $ value ) ; return $ userIdentifier ; }
|
Creates a user identifier from the specified type and value .
|
8,642
|
private static function createBiddingStrategy ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ biddingStrategyService = $ adWordsServices -> get ( $ session , BiddingStrategyService :: class ) ; $ biddingStrategy = new SharedBiddingStrategy ( ) ; $ biddingStrategy -> setName ( "Maximize Clicks " . uniqid ( ) ) ; $ biddingScheme = new TargetSpendBiddingScheme ( ) ; $ bidCeiling = new Money ( ) ; $ bidCeiling -> setMicroAmount ( 2000000 ) ; $ biddingScheme -> setBidCeiling ( $ bidCeiling ) ; $ spendTarget = new Money ( ) ; $ spendTarget -> setMicroAmount ( 20000000 ) ; $ biddingScheme -> setSpendTarget ( $ spendTarget ) ; $ biddingStrategy -> setBiddingScheme ( $ biddingScheme ) ; $ operation = new BiddingStrategyOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ biddingStrategy ) ; $ result = $ biddingStrategyService -> mutate ( [ $ operation ] ) ; $ newBiddingStrategy = $ result -> getValue ( ) [ 0 ] ; printf ( "Portfolio bidding strategy with name '%s' and ID %d of type %s was created.\n" , $ newBiddingStrategy -> getName ( ) , $ newBiddingStrategy -> getId ( ) , $ newBiddingStrategy -> getType ( ) ) ; return $ newBiddingStrategy ; }
|
Creates a shared bidding strategy .
|
8,643
|
private static function createCampaignWithBiddingStrategy ( AdWordsServices $ adWordsServices , AdWordsSession $ session , $ biddingStrategyId , $ sharedBudgetId ) { $ campaignService = $ adWordsServices -> get ( $ session , CampaignService :: class ) ; $ campaign = new Campaign ( ) ; $ campaign -> setName ( 'Interplanetary Cruise #' . uniqid ( ) ) ; $ campaign -> setBudget ( new Budget ( ) ) ; $ campaign -> getBudget ( ) -> setBudgetId ( $ sharedBudgetId ) ; $ campaign -> setAdvertisingChannelType ( AdvertisingChannelType :: SEARCH ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ biddingStrategyConfiguration -> setBiddingStrategyId ( $ biddingStrategyId ) ; $ campaign -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ networkSetting = new NetworkSetting ( ) ; $ networkSetting -> setTargetGoogleSearch ( true ) ; $ networkSetting -> setTargetSearchNetwork ( true ) ; $ networkSetting -> setTargetContentNetwork ( true ) ; $ campaign -> setNetworkSetting ( $ networkSetting ) ; $ campaign -> setStatus ( CampaignStatus :: PAUSED ) ; $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ campaign ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ campaignService -> mutate ( [ $ operation ] ) ; $ newCampaign = $ result -> getValue ( ) [ 0 ] ; printf ( "Campaign with name '%s', ID %d and bidding scheme ID %d was created.\n" , $ newCampaign -> getName ( ) , $ newCampaign -> getId ( ) , $ newCampaign -> getBiddingStrategyConfiguration ( ) -> getBiddingStrategyId ( ) ) ; }
|
Create a campaign with a portfolio bidding strategy .
|
8,644
|
private function createSoapHeaderObject ( AdsServiceDescriptor $ serviceDescriptor ) { $ reflectionClass = new ReflectionClass ( $ serviceDescriptor -> getServiceClass ( ) ) ; $ namespaceParts = explode ( '\\' , trim ( $ reflectionClass -> getNamespaceName ( ) , '\\' ) ) ; array_pop ( $ namespaceParts ) ; $ soapHeaderClassName = sprintf ( '%s\\%s' , implode ( '\\' , $ namespaceParts ) , self :: DEFAULT_SOAP_HEADER_CLASS_NAME ) ; return $ this -> reflection -> createInstance ( $ soapHeaderClassName ) ; }
|
Creates a new instance of the SOAP header object used by the AdWords API .
|
8,645
|
private static function createBudget ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ budgetService = $ adWordsServices -> get ( $ session , BudgetService :: class ) ; $ sharedBudget = new Budget ( ) ; $ sharedBudget -> setName ( 'Interplanetary Cruise #' . uniqid ( ) ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 50000000 ) ; $ sharedBudget -> setAmount ( $ money ) ; $ sharedBudget -> setDeliveryMethod ( BudgetBudgetDeliveryMethod :: STANDARD ) ; $ operation = new BudgetOperation ( ) ; $ operation -> setOperand ( $ sharedBudget ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ budgetService -> mutate ( [ $ operation ] ) ; $ sharedBudget = $ result -> getValue ( ) [ 0 ] ; return $ sharedBudget ; }
|
Creates the budget .
|
8,646
|
private static function createCampaign ( AdWordsServices $ adWordsServices , AdWordsSession $ session , Budget $ budget ) { $ campaignService = $ adWordsServices -> get ( $ session , CampaignService :: class ) ; $ campaign = new Campaign ( ) ; $ campaign -> setName ( 'Interplanetary Cruise #' . uniqid ( ) ) ; $ campaign -> setAdvertisingChannelType ( AdvertisingChannelType :: SEARCH ) ; $ campaign -> setStatus ( CampaignStatus :: PAUSED ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ biddingStrategyConfiguration -> setBiddingStrategyType ( BiddingStrategyType :: MANUAL_CPC ) ; $ campaign -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ campaignBudget = new Budget ( ) ; $ campaignBudget -> setBudgetId ( $ budget -> getBudgetId ( ) ) ; $ campaign -> setBudget ( $ campaignBudget ) ; $ dynamicSearchAdsSetting = new DynamicSearchAdsSetting ( ) ; $ dynamicSearchAdsSetting -> setDomainName ( 'example.com' ) ; $ dynamicSearchAdsSetting -> setLanguageCode ( 'en' ) ; $ campaign -> setSettings ( [ $ dynamicSearchAdsSetting ] ) ; $ campaign -> setStartDate ( date ( 'Ymd' , strtotime ( '+1 day' ) ) ) ; $ campaign -> setEndDate ( date ( 'Ymd' , strtotime ( '+1 year' ) ) ) ; $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ campaign ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ campaignService -> mutate ( [ $ operation ] ) ; $ campaign = $ result -> getValue ( ) [ 0 ] ; printf ( "Campaign with name '%s' and ID %d was added.\n" , $ campaign -> getName ( ) , $ campaign -> getId ( ) ) ; return $ campaign ; }
|
Creates the campaign .
|
8,647
|
private static function createAdGroup ( AdWordsServices $ adWordsServices , AdWordsSession $ session , Campaign $ campaign ) { $ adGroupService = $ adWordsServices -> get ( $ session , AdGroupService :: class ) ; $ adGroup = new AdGroup ( ) ; $ adGroup -> setAdGroupType ( AdGroupType :: SEARCH_DYNAMIC_ADS ) ; $ adGroup -> setName ( 'Interplanetary Cruise #' . uniqid ( ) ) ; $ adGroup -> setCampaignId ( $ campaign -> getId ( ) ) ; $ adGroup -> setStatus ( AdGroupStatus :: PAUSED ) ; $ adGroup -> setTrackingUrlTemplate ( 'http://tracker.example.com/traveltracker/{escapedlpurl}' ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ cpcBid = new CpcBid ( ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 3000000 ) ; $ cpcBid -> setBid ( $ money ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ adGroup -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ operation = new AdGroupOperation ( ) ; $ operation -> setOperand ( $ adGroup ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ adGroupService -> mutate ( [ $ operation ] ) ; $ adGroup = $ result -> getValue ( ) [ 0 ] ; printf ( "Ad group with name '%s' and ID %d was added.\n" , $ adGroup -> getName ( ) , $ adGroup -> getId ( ) ) ; return $ adGroup ; }
|
Creates the ad group .
|
8,648
|
private static function createExpandedDSA ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup ) { $ adGroupAdService = $ adWordsServices -> get ( $ session , AdGroupAdService :: class ) ; $ expandedDSA = new ExpandedDynamicSearchAd ( ) ; $ expandedDSA -> setDescription ( 'Buy your tickets now!' ) ; $ expandedDSA -> setDescription2 ( 'Discount ends soon' ) ; $ adGroupAd = new AdGroupAd ( ) ; $ adGroupAd -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ adGroupAd -> setAd ( $ expandedDSA ) ; $ adGroupAd -> setStatus ( AdGroupAdStatus :: PAUSED ) ; $ operation = new AdGroupAdOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ adGroupAd ) ; $ result = $ adGroupAdService -> mutate ( [ $ operation ] ) ; $ newAdGroupAd = $ result -> getValue ( ) [ 0 ] ; $ expandedDSA = $ newAdGroupAd -> getAd ( ) ; printf ( "Expanded Dynamic Search Ad with ID %d, description '%s', and" . " description 2 '%s' was added.%s" , $ expandedDSA -> getId ( ) , $ expandedDSA -> getDescription ( ) , $ expandedDSA -> getDescription2 ( ) , PHP_EOL ) ; }
|
Creates the expanded Dynamic Search Ad .
|
8,649
|
private static function addWebPageCriteria ( AdWordsServices $ adWordsServices , AdWordsSession $ session , AdGroup $ adGroup ) { $ adGroupCriterionService = $ adWordsServices -> get ( $ session , AdGroupCriterionService :: class ) ; $ param = new WebpageParameter ( ) ; $ param -> setCriterionName ( 'Special offers' ) ; $ urlCondition = new WebpageCondition ( ) ; $ urlCondition -> setOperand ( WebpageConditionOperand :: URL ) ; $ urlCondition -> setArgument ( '/specialoffers' ) ; $ titleCondition = new WebpageCondition ( ) ; $ titleCondition -> setOperand ( WebpageConditionOperand :: PAGE_TITLE ) ; $ titleCondition -> setArgument ( 'Special Offer' ) ; $ param -> setConditions ( [ $ urlCondition , $ titleCondition ] ) ; $ webpage = new Webpage ( ) ; $ webpage -> setParameter ( $ param ) ; $ biddableAdGroupCriterion = new BiddableAdGroupCriterion ( ) ; $ biddableAdGroupCriterion -> setAdGroupId ( $ adGroup -> getId ( ) ) ; $ biddableAdGroupCriterion -> setCriterion ( $ webpage ) ; $ biddableAdGroupCriterion -> setUserStatus ( UserStatus :: PAUSED ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ cpcBid = new CpcBid ( ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 10000000 ) ; $ cpcBid -> setBid ( $ money ) ; $ biddingStrategyConfiguration -> setBids ( [ $ cpcBid ] ) ; $ biddableAdGroupCriterion -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ operation = new AdGroupCriterionOperation ( ) ; $ operation -> setOperand ( $ biddableAdGroupCriterion ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ result = $ adGroupCriterionService -> mutate ( [ $ operation ] ) ; $ adGroupCriterion = $ result -> getValue ( ) [ 0 ] ; printf ( "Web page criterion with ID %d was added to ad group ID %d.\n" , $ adGroupCriterion -> getCriterion ( ) -> getId ( ) , $ adGroupCriterion -> getAdGroupId ( ) ) ; }
|
Adds a web page criteria to target Dynamic Search Ads .
|
8,650
|
public static function createWithField ( $ field , ServiceQueryBuilder $ queryBuilder ) { $ validationResult = QueryValidator :: validateFieldName ( $ field ) ; if ( $ validationResult -> isFailed ( ) ) { throw new InvalidArgumentException ( 'The field name for building the WHERE clause is invalid.' . ' Validation fail reason: ' . $ validationResult -> getFailReason ( ) ) ; } return new self ( $ queryBuilder , new ExpressionBuilder ( $ field ) ) ; }
|
Creates a where builder object to start a logic expression with a field name .
|
8,651
|
public static function scrubRequestHttpHeaders ( $ httpHeaders , array $ headersToScrub ) { foreach ( $ headersToScrub as $ header ) { $ regex = sprintf ( self :: $ HTTP_REQUEST_HEADER_REGEX , $ header ) ; $ httpHeaders = preg_replace ( $ regex , '\1' . self :: $ REDACTED , $ httpHeaders , 1 ) ; } return $ httpHeaders ; }
|
Scrubs the specified header values replacing all occurrences in the specified request HTTP headers with a redacted token .
|
8,652
|
public static function scrubRequestSoapHeaders ( $ soapXml , array $ headersToScrub ) { foreach ( $ headersToScrub as $ header ) { $ regex = sprintf ( self :: $ SOAP_REQUEST_HEADER_TAG_REGEX , $ header ) ; $ soapXml = preg_replace ( $ regex , '\1' . self :: $ REDACTED . '\2' , $ soapXml , 1 ) ; } return $ soapXml ; }
|
Scrubs the specified header values replacing their occurrences in the specified request SOAP XML with a redacted token .
|
8,653
|
public static function scrubRequestSoapBodyTags ( $ soapXml , array $ tagsToScrub ) { foreach ( $ tagsToScrub as $ tag ) { $ regex = sprintf ( self :: $ SOAP_REQUEST_BODY_TAG_REGEX , $ tag ) ; $ soapXml = preg_replace ( $ regex , '\1' . self :: $ REDACTED . '\2' , $ soapXml , 1 ) ; } return $ soapXml ; }
|
Scrubs the values of specified tags replacing their occurrences in the specified request SOAP XML with a redacted token .
|
8,654
|
public static function scrubHttpHeadersArray ( array $ httpHeaders , array $ headersToScrub ) { foreach ( $ headersToScrub as $ header ) { $ httpHeaders [ $ header ] = self :: $ REDACTED ; } return $ httpHeaders ; }
|
Scrubs an array of HTTP headers by replacing their values with a redacted token .
|
8,655
|
public function get ( \ Google \ AdsApi \ AdWords \ v201809 \ ch \ CustomerSyncSelector $ selector ) { return $ this -> __soapCall ( 'get' , array ( array ( 'selector' => $ selector ) ) ) -> getRval ( ) ; }
|
Returns information about changed entities inside a customer s account .
|
8,656
|
public function getPendingInvitations ( \ Google \ AdsApi \ AdWords \ v201809 \ mcm \ PendingInvitationSelector $ selector ) { return $ this -> __soapCall ( 'getPendingInvitations' , array ( array ( 'selector' => $ selector ) ) ) -> getRval ( ) ; }
|
Returns the pending invitations for the customer IDs in the selector .
|
8,657
|
private static function uploadImageAsset ( AssetService $ assetService , $ url ) { $ imageAsset = new ImageAsset ( ) ; $ imageAsset -> setImageData ( file_get_contents ( $ url ) ) ; $ operation = new AssetOperation ( ) ; $ operation -> setOperand ( $ imageAsset ) ; $ operation -> setOperator ( Operator :: ADD ) ; return $ assetService -> mutate ( [ $ operation ] ) -> getValue ( ) [ 0 ] -> getAssetId ( ) ; }
|
Upload an image asset using AssetService and provided URL .
|
8,658
|
private static function createBudget ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ budgetService = $ adWordsServices -> get ( $ session , BudgetService :: class ) ; $ budget = new Budget ( ) ; $ budget -> setName ( 'Interplanetary Cruise Budget #' . uniqid ( ) ) ; $ money = new Money ( ) ; $ money -> setMicroAmount ( 50000000 ) ; $ budget -> setAmount ( $ money ) ; $ budget -> setDeliveryMethod ( BudgetBudgetDeliveryMethod :: STANDARD ) ; $ budget -> setIsExplicitlyShared ( false ) ; $ operations = [ ] ; $ operation = new BudgetOperation ( ) ; $ operation -> setOperand ( $ budget ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; $ result = $ budgetService -> mutate ( $ operations ) ; $ budget = $ result -> getValue ( ) [ 0 ] ; printf ( "Budget with name '%s' and ID %d was created.\n" , $ budget -> getName ( ) , $ budget -> getBudgetId ( ) ) ; return $ budget -> getBudgetId ( ) ; }
|
Creates the budget for the campaign .
|
8,659
|
private static function setCampaignTargetingCriteria ( $ campaignId , AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ campaignCriterionService = $ adWordsServices -> get ( $ session , CampaignCriterionService :: class ) ; $ campaignCriteria = [ ] ; $ california = new Location ( ) ; $ california -> setId ( 21137 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ california ) ; $ mexico = new Location ( ) ; $ mexico -> setId ( 2484 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ mexico ) ; $ english = new Language ( ) ; $ english -> setId ( 1000 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ english ) ; $ spanish = new Language ( ) ; $ spanish -> setId ( 1003 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ spanish ) ; $ operations = [ ] ; foreach ( $ campaignCriteria as $ campaignCriterion ) { $ operation = new CampaignCriterionOperation ( ) ; $ operation -> setOperand ( $ campaignCriterion ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; } $ result = $ campaignCriterionService -> mutate ( $ operations ) ; foreach ( $ result -> getValue ( ) as $ campaignCriterion ) { printf ( "Campaign criterion of type '%s' and ID %d was added.\n" , $ campaignCriterion -> getCriterion ( ) -> getType ( ) , $ campaignCriterion -> getCriterion ( ) -> getId ( ) ) ; } }
|
Sets the campaign s targeting criteria .
|
8,660
|
public static function createFromCurrencies ( Currency $ baseCurrency , Currency $ counterCurrency ) { $ message = sprintf ( 'Cannot resolve a currency pair for currencies: %s/%s' , $ baseCurrency -> getCode ( ) , $ counterCurrency -> getCode ( ) ) ; return new self ( $ message ) ; }
|
Creates an exception from Currency objects .
|
8,661
|
public function equals ( CurrencyPair $ other ) { return $ this -> baseCurrency -> equals ( $ other -> baseCurrency ) && $ this -> counterCurrency -> equals ( $ other -> counterCurrency ) && $ this -> conversionRatio === $ other -> conversionRatio ; }
|
Checks if an other CurrencyPair has the same parameters as this .
|
8,662
|
public function equals ( Money $ other ) { return $ this -> isSameCurrency ( $ other ) && $ this -> amount === $ other -> amount ; }
|
Checks whether the value represented by this object equals to the other .
|
8,663
|
public function compare ( Money $ other ) { $ this -> assertSameCurrency ( $ other ) ; return $ this -> getCalculator ( ) -> compare ( $ this -> amount , $ other -> amount ) ; }
|
Returns an integer less than equal to or greater than zero if the value of this object is considered to be respectively less than equal to or greater than the other .
|
8,664
|
public function add ( Money ... $ addends ) { $ amount = $ this -> amount ; $ calculator = $ this -> getCalculator ( ) ; foreach ( $ addends as $ addend ) { $ this -> assertSameCurrency ( $ addend ) ; $ amount = $ calculator -> add ( $ amount , $ addend -> amount ) ; } return new self ( $ amount , $ this -> currency ) ; }
|
Returns a new Money object that represents the sum of this and an other Money object .
|
8,665
|
public function subtract ( Money ... $ subtrahends ) { $ amount = $ this -> amount ; $ calculator = $ this -> getCalculator ( ) ; foreach ( $ subtrahends as $ subtrahend ) { $ this -> assertSameCurrency ( $ subtrahend ) ; $ amount = $ calculator -> subtract ( $ amount , $ subtrahend -> amount ) ; } return new self ( $ amount , $ this -> currency ) ; }
|
Returns a new Money object that represents the difference of this and an other Money object .
|
8,666
|
private function assertOperand ( $ operand ) { if ( ! is_numeric ( $ operand ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Operand should be a numeric value, "%s" given.' , is_object ( $ operand ) ? get_class ( $ operand ) : gettype ( $ operand ) ) ) ; } }
|
Asserts that the operand is integer or float .
|
8,667
|
private function assertRoundingMode ( $ roundingMode ) { if ( ! in_array ( $ roundingMode , [ self :: ROUND_HALF_DOWN , self :: ROUND_HALF_EVEN , self :: ROUND_HALF_ODD , self :: ROUND_HALF_UP , self :: ROUND_UP , self :: ROUND_DOWN , self :: ROUND_HALF_POSITIVE_INFINITY , self :: ROUND_HALF_NEGATIVE_INFINITY , ] , true ) ) { throw new \ InvalidArgumentException ( 'Rounding mode should be Money::ROUND_HALF_DOWN | ' . 'Money::ROUND_HALF_EVEN | Money::ROUND_HALF_ODD | ' . 'Money::ROUND_HALF_UP | Money::ROUND_UP | Money::ROUND_DOWN' . 'Money::ROUND_HALF_POSITIVE_INFINITY | Money::ROUND_HALF_NEGATIVE_INFINITY' ) ; } }
|
Asserts that rounding mode is a valid integer value .
|
8,668
|
public function multiply ( $ multiplier , $ roundingMode = self :: ROUND_HALF_UP ) { $ this -> assertOperand ( $ multiplier ) ; $ this -> assertRoundingMode ( $ roundingMode ) ; $ product = $ this -> round ( $ this -> getCalculator ( ) -> multiply ( $ this -> amount , $ multiplier ) , $ roundingMode ) ; return $ this -> newInstance ( $ product ) ; }
|
Returns a new Money object that represents the multiplied value by the given factor .
|
8,669
|
public function divide ( $ divisor , $ roundingMode = self :: ROUND_HALF_UP ) { $ this -> assertOperand ( $ divisor ) ; $ this -> assertRoundingMode ( $ roundingMode ) ; $ divisor = ( string ) Number :: fromNumber ( $ divisor ) ; if ( $ this -> getCalculator ( ) -> compare ( $ divisor , '0' ) === 0 ) { throw new \ InvalidArgumentException ( 'Division by zero' ) ; } $ quotient = $ this -> round ( $ this -> getCalculator ( ) -> divide ( $ this -> amount , $ divisor ) , $ roundingMode ) ; return $ this -> newInstance ( $ quotient ) ; }
|
Returns a new Money object that represents the divided value by the given factor .
|
8,670
|
public function mod ( Money $ divisor ) { $ this -> assertSameCurrency ( $ divisor ) ; return new self ( $ this -> getCalculator ( ) -> mod ( $ this -> amount , $ divisor -> amount ) , $ this -> currency ) ; }
|
Returns a new Money object that represents the remainder after dividing the value by the given factor .
|
8,671
|
public function allocate ( array $ ratios ) { if ( count ( $ ratios ) === 0 ) { throw new \ InvalidArgumentException ( 'Cannot allocate to none, ratios cannot be an empty array' ) ; } $ remainder = $ this -> amount ; $ results = [ ] ; $ total = array_sum ( $ ratios ) ; if ( $ total <= 0 ) { throw new \ InvalidArgumentException ( 'Cannot allocate to none, sum of ratios must be greater than zero' ) ; } foreach ( $ ratios as $ key => $ ratio ) { if ( $ ratio < 0 ) { throw new \ InvalidArgumentException ( 'Cannot allocate to none, ratio must be zero or positive' ) ; } $ share = $ this -> getCalculator ( ) -> share ( $ this -> amount , $ ratio , $ total ) ; $ results [ $ key ] = $ this -> newInstance ( $ share ) ; $ remainder = $ this -> getCalculator ( ) -> subtract ( $ remainder , $ share ) ; } if ( $ this -> getCalculator ( ) -> compare ( $ remainder , '0' ) === 0 ) { return $ results ; } $ fractions = array_map ( function ( $ ratio ) use ( $ total ) { $ share = ( $ ratio / $ total ) * $ this -> amount ; return $ share - floor ( $ share ) ; } , $ ratios ) ; while ( $ this -> getCalculator ( ) -> compare ( $ remainder , '0' ) > 0 ) { $ index = ! empty ( $ fractions ) ? array_keys ( $ fractions , max ( $ fractions ) ) [ 0 ] : 0 ; $ results [ $ index ] -> amount = $ this -> getCalculator ( ) -> add ( $ results [ $ index ] -> amount , '1' ) ; $ remainder = $ this -> getCalculator ( ) -> subtract ( $ remainder , '1' ) ; unset ( $ fractions [ $ index ] ) ; } return $ results ; }
|
Allocate the money according to a list of ratios .
|
8,672
|
public function allocateTo ( $ n ) { if ( ! is_int ( $ n ) ) { throw new \ InvalidArgumentException ( 'Number of targets must be an integer' ) ; } if ( $ n <= 0 ) { throw new \ InvalidArgumentException ( 'Cannot allocate to none, target must be greater than zero' ) ; } return $ this -> allocate ( array_fill ( 0 , $ n , 1 ) ) ; }
|
Allocate the money among N targets .
|
8,673
|
public function numericCodeFor ( Currency $ currency ) { if ( ! $ this -> contains ( $ currency ) ) { throw new UnknownCurrencyException ( 'Cannot find ISO currency ' . $ currency -> getCode ( ) ) ; } return $ this -> getCurrencies ( ) [ $ currency -> getCode ( ) ] [ 'numericCode' ] ; }
|
Returns the numeric code for a currency .
|
8,674
|
private function getCurrencies ( ) { if ( null === self :: $ currencies ) { self :: $ currencies = $ this -> loadCurrencies ( ) ; } return self :: $ currencies ; }
|
Returns a map of known currencies indexed by code .
|
8,675
|
public function overview ( ) { $ migrations = $ this -> getMigrations ( ) ; $ dbMigrations = $ this -> getExecutedMigrations ( ) ; return view ( 'vendor.installer.update.overview' , [ 'numberOfUpdatesPending' => count ( $ migrations ) - count ( $ dbMigrations ) ] ) ; }
|
Display the updater overview page .
|
8,676
|
public function database ( ) { $ databaseManager = new DatabaseManager ; $ response = $ databaseManager -> migrateAndSeed ( ) ; return redirect ( ) -> route ( 'LaravelUpdater::final' ) -> with ( [ 'message' => $ response ] ) ; }
|
Migrate and seed the database .
|
8,677
|
public function create ( ) { $ installedLogFile = storage_path ( 'installed' ) ; $ dateStamp = date ( "Y/m/d h:i:sa" ) ; if ( ! file_exists ( $ installedLogFile ) ) { $ message = trans ( 'installer_messages.installed.success_log_message' ) . $ dateStamp . "\n" ; file_put_contents ( $ installedLogFile , $ message ) ; } else { $ message = trans ( 'installer_messages.updater.log.success_message' ) . $ dateStamp ; file_put_contents ( $ installedLogFile , $ message . PHP_EOL , FILE_APPEND | LOCK_EX ) ; } return $ message ; }
|
Create installed file .
|
8,678
|
public function requirements ( ) { $ phpSupportInfo = $ this -> requirements -> checkPHPversion ( config ( 'installer.core.minPhpVersion' ) ) ; $ requirements = $ this -> requirements -> check ( config ( 'installer.requirements' ) ) ; return view ( 'vendor.installer.requirements' , compact ( 'requirements' , 'phpSupportInfo' ) ) ; }
|
Display the requirements page .
|
8,679
|
public function runFinal ( ) { $ outputLog = new BufferedOutput ; $ this -> generateKey ( $ outputLog ) ; $ this -> publishVendorAssets ( $ outputLog ) ; return $ outputLog -> fetch ( ) ; }
|
Run final commands .
|
8,680
|
private static function publishVendorAssets ( BufferedOutput $ outputLog ) { try { if ( config ( 'installer.final.publish' ) ) { Artisan :: call ( 'vendor:publish' , [ '--all' => true ] , $ outputLog ) ; } } catch ( Exception $ e ) { return static :: response ( $ e -> getMessage ( ) , $ outputLog ) ; } return $ outputLog ; }
|
Publish vendor assets .
|
8,681
|
public function alreadyUpdated ( ) { $ migrations = $ this -> getMigrations ( ) ; $ dbMigrations = $ this -> getExecutedMigrations ( ) ; if ( count ( $ migrations ) == count ( $ dbMigrations ) ) { return true ; } return false ; }
|
If application is already updated .
|
8,682
|
public function check ( array $ folders ) { foreach ( $ folders as $ folder => $ permission ) { if ( ! ( $ this -> getPermission ( $ folder ) >= $ permission ) ) { $ this -> addFileAndSetErrors ( $ folder , $ permission , false ) ; } else { $ this -> addFile ( $ folder , $ permission , true ) ; } } return $ this -> results ; }
|
Check for the folders permissions .
|
8,683
|
private function addFile ( $ folder , $ permission , $ isSet ) { array_push ( $ this -> results [ 'permissions' ] , [ 'folder' => $ folder , 'permission' => $ permission , 'isSet' => $ isSet ] ) ; }
|
Add the file to the list of results .
|
8,684
|
private function addFileAndSetErrors ( $ folder , $ permission , $ isSet ) { $ this -> addFile ( $ folder , $ permission , $ isSet ) ; $ this -> results [ 'errors' ] = true ; }
|
Add the file and set the errors .
|
8,685
|
public function check ( array $ requirements ) { $ results = [ ] ; foreach ( $ requirements as $ type => $ requirement ) { switch ( $ type ) { case 'php' : foreach ( $ requirements [ $ type ] as $ requirement ) { $ results [ 'requirements' ] [ $ type ] [ $ requirement ] = true ; if ( ! extension_loaded ( $ requirement ) ) { $ results [ 'requirements' ] [ $ type ] [ $ requirement ] = false ; $ results [ 'errors' ] = true ; } } break ; case 'apache' : foreach ( $ requirements [ $ type ] as $ requirement ) { if ( function_exists ( 'apache_get_modules' ) ) { $ results [ 'requirements' ] [ $ type ] [ $ requirement ] = true ; if ( ! in_array ( $ requirement , apache_get_modules ( ) ) ) { $ results [ 'requirements' ] [ $ type ] [ $ requirement ] = false ; $ results [ 'errors' ] = true ; } } } break ; } } return $ results ; }
|
Check for the server requirements .
|
8,686
|
public function checkPHPversion ( string $ minPhpVersion = null ) { $ minVersionPhp = $ minPhpVersion ; $ currentPhpVersion = $ this -> getPhpVersionInfo ( ) ; $ supported = false ; if ( $ minPhpVersion == null ) { $ minVersionPhp = $ this -> getMinPhpVersion ( ) ; } if ( version_compare ( $ currentPhpVersion [ 'version' ] , $ minVersionPhp ) >= 0 ) { $ supported = true ; } $ phpStatus = [ 'full' => $ currentPhpVersion [ 'full' ] , 'current' => $ currentPhpVersion [ 'version' ] , 'minimum' => $ minVersionPhp , 'supported' => $ supported ] ; return $ phpStatus ; }
|
Check PHP version requirement .
|
8,687
|
private static function getPhpVersionInfo ( ) { $ currentVersionFull = PHP_VERSION ; preg_match ( "#^\d+(\.\d+)*#" , $ currentVersionFull , $ filtered ) ; $ currentVersion = $ filtered [ 0 ] ; return [ 'full' => $ currentVersionFull , 'version' => $ currentVersion ] ; }
|
Get current Php version information
|
8,688
|
protected function publishFiles ( ) { $ this -> publishes ( [ __DIR__ . '/../Config/installer.php' => base_path ( 'config/installer.php' ) , ] , 'laravelinstaller' ) ; $ this -> publishes ( [ __DIR__ . '/../assets' => public_path ( 'installer' ) , ] , 'laravelinstaller' ) ; $ this -> publishes ( [ __DIR__ . '/../Views' => base_path ( 'resources/views/vendor/installer' ) , ] , 'laravelinstaller' ) ; $ this -> publishes ( [ __DIR__ . '/../Lang' => base_path ( 'resources/lang' ) , ] , 'laravelinstaller' ) ; }
|
Publish config file for the installer .
|
8,689
|
public function getEnvContent ( ) { if ( ! file_exists ( $ this -> envPath ) ) { if ( file_exists ( $ this -> envExamplePath ) ) { copy ( $ this -> envExamplePath , $ this -> envPath ) ; } else { touch ( $ this -> envPath ) ; } } return file_get_contents ( $ this -> envPath ) ; }
|
Get the content of the . env file .
|
8,690
|
public function saveFileClassic ( Request $ input ) { $ message = trans ( 'installer_messages.environment.success' ) ; try { file_put_contents ( $ this -> envPath , $ input -> get ( 'envConfig' ) ) ; } catch ( Exception $ e ) { $ message = trans ( 'installer_messages.environment.errors' ) ; } return $ message ; }
|
Save the edited content to the . env file .
|
8,691
|
public function insert ( self $ branch ) { if ( ! \ in_array ( $ branch , $ this -> branches ) ) { $ this -> branches [ ] = $ branch ; } }
|
Inserts a node in the branch graph .
|
8,692
|
public function show ( $ padding = 0 ) { echo str_repeat ( ' ' , $ padding ) , $ this -> branch -> getUniqueId ( ) , ':' , $ this -> increase ; if ( \ count ( $ this -> branches ) ) { echo ':' , PHP_EOL ; foreach ( $ this -> branches as $ node ) { $ node -> show ( $ padding + 1 ) ; } } else { echo PHP_EOL ; } }
|
Generates an ASCII visualization of the branch .
|
8,693
|
public function setExpectReturn ( $ expecting , Variable $ expectingVariable = null ) { $ this -> expecting = $ expecting ; $ this -> expectingVariable = $ expectingVariable ; }
|
Sets if the variable must be resolved into a direct variable symbol create a temporary value or ignore the return value .
|
8,694
|
public function compile ( $ expression , CompilationContext $ compilationContext ) { if ( $ this -> expecting ) { if ( $ this -> expectingVariable ) { $ symbolVariable = $ this -> expectingVariable ; if ( 'variable' != $ symbolVariable -> getType ( ) ) { throw new CompilerException ( 'Cannot use variable type: ' . $ symbolVariable -> getType ( ) . ' to store a reference' , $ expression ) ; } } else { $ symbolVariable = $ compilationContext -> symbolTable -> getTempVariableForWrite ( 'variable' , $ compilationContext , $ expression ) ; } } else { $ symbolVariable = $ compilationContext -> symbolTable -> getTempVariableForWrite ( 'variable' , $ compilationContext , $ expression ) ; } $ leftExpr = new Expression ( $ expression [ 'left' ] ) ; $ leftExpr -> setReadOnly ( $ this -> readOnly ) ; $ left = $ leftExpr -> compile ( $ compilationContext ) ; switch ( $ left -> getType ( ) ) { case 'variable' : case 'string' : case 'object' : case 'array' : case 'callable' : break ; default : throw new CompilerException ( 'Cannot obtain a reference from type: ' . $ left -> getType ( ) , $ expression ) ; } $ leftVariable = $ compilationContext -> symbolTable -> getVariableForRead ( $ left -> getCode ( ) , $ compilationContext , $ expression ) ; switch ( $ leftVariable -> getType ( ) ) { case 'variable' : case 'string' : case 'object' : case 'array' : case 'callable' : break ; default : throw new CompilerException ( 'Cannot obtain reference from variable type: ' . $ leftVariable -> getType ( ) , $ expression ) ; } $ symbolVariable -> setMustInitNull ( true ) ; $ compilationContext -> symbolTable -> mustGrownStack ( true ) ; $ symbolVariable -> increaseVariantIfNull ( ) ; $ compilationContext -> codePrinter -> output ( 'ZEPHIR_MAKE_REFERENCE(' . $ symbolVariable -> getName ( ) . ', ' . $ leftVariable -> getName ( ) . ');' ) ; return new CompiledExpression ( 'reference' , $ symbolVariable -> getRealName ( ) , $ expression ) ; }
|
Compiles a reference to a value .
|
8,695
|
public function addLeaf ( Branch $ branch ) { if ( isset ( $ this -> branchMap [ $ branch -> getUniqueId ( ) ] ) ) { $ branchNode = $ this -> branchMap [ $ branch -> getUniqueId ( ) ] ; } else { $ branchNode = new BranchGraphNode ( $ branch ) ; } $ branchNode -> increase ( ) ; $ tempBranch = $ branch -> getParentBranch ( ) ; while ( $ tempBranch ) { if ( isset ( $ this -> branchMap [ $ tempBranch -> getUniqueId ( ) ] ) ) { $ parentBranchNode = $ this -> branchMap [ $ tempBranch -> getUniqueId ( ) ] ; } else { $ parentBranchNode = new BranchGraphNode ( $ tempBranch ) ; $ this -> branchMap [ $ tempBranch -> getUniqueId ( ) ] = $ parentBranchNode ; } $ parentBranchNode -> insert ( $ branchNode ) ; $ branchNode = $ parentBranchNode ; $ tempBranch = $ tempBranch -> getParentBranch ( ) ; if ( ! $ tempBranch ) { $ this -> root = $ parentBranchNode ; } } }
|
Adds a leaf to the branch tree .
|
8,696
|
public function hasVariable ( $ name , CompilationContext $ compilationContext = null ) { return false !== $ this -> getVariable ( $ name , $ compilationContext ? : $ this -> compilationContext ) ; }
|
Check if a variable is declared in the current symbol table .
|
8,697
|
public function addVariable ( $ type , $ name , CompilationContext $ compilationContext ) { $ currentBranch = $ compilationContext -> branchManager -> getCurrentBranch ( ) ; $ branchId = $ currentBranch -> getUniqueId ( ) ; if ( $ this -> globalsManager -> isSuperGlobal ( $ name ) || 'zephir_fcall_cache_entry' == $ type ) { $ branchId = 1 ; } $ varName = $ name ; if ( $ branchId > 1 && Branch :: TYPE_ROOT != $ currentBranch -> getType ( ) ) { $ varName = $ name . Variable :: BRANCH_MAGIC . $ branchId ; } $ variable = new Variable ( $ type , $ varName , $ currentBranch ) ; if ( 'variable' == $ type && $ this -> localContext && $ this -> localContext -> shouldBeLocal ( $ name ) ) { $ variable -> setLocalOnly ( true ) ; } if ( ! isset ( $ this -> branchVariables [ $ branchId ] ) ) { $ this -> branchVariables [ $ branchId ] = [ ] ; } $ this -> branchVariables [ $ branchId ] [ $ name ] = $ variable ; return $ variable ; }
|
Adds a variable to the symbol table .
|
8,698
|
public function getVariable ( $ name , $ compilationContext = null ) { $ pos = strpos ( $ name , Variable :: BRANCH_MAGIC ) ; if ( $ pos > - 1 ) { $ branchId = ( int ) ( substr ( $ name , $ pos + \ strlen ( Variable :: BRANCH_MAGIC ) ) ) ; $ name = substr ( $ name , 0 , $ pos ) ; } else { $ branch = $ this -> resolveVariableToBranch ( $ name , $ compilationContext ? : $ this -> compilationContext ) ; if ( ! $ branch ) { return false ; } $ branchId = $ branch -> getUniqueId ( ) ; } if ( ! isset ( $ this -> branchVariables [ $ branchId ] ) || ! isset ( $ this -> branchVariables [ $ branchId ] [ $ name ] ) ) { return false ; } return $ this -> branchVariables [ $ branchId ] [ $ name ] ; }
|
Returns a variable in the symbol table .
|
8,699
|
public function getVariables ( ) { $ ret = [ ] ; foreach ( $ this -> branchVariables as $ branchId => $ vars ) { foreach ( $ vars as $ var ) { $ ret [ $ var -> getName ( ) ] = $ var ; } } return $ ret ; }
|
Returns all the variables defined in the symbol table .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.