idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
1,100 | private function registerBreadcrumbsComponent ( ) { if ( class_exists ( '\\DaveJamesMiller\\Breadcrumbs\\ServiceProvider' ) ) { $ this -> app -> register ( \ DaveJamesMiller \ Breadcrumbs \ ServiceProvider :: class ) ; $ this -> concord -> registerAlias ( 'Breadcrumbs' , \ DaveJamesMiller \ Breadcrumbs \ Facade :: class ) ; } else { $ this -> app -> register ( \ DaveJamesMiller \ Breadcrumbs \ BreadcrumbsServiceProvider :: class ) ; $ this -> concord -> registerAlias ( 'Breadcrumbs' , \ DaveJamesMiller \ Breadcrumbs \ Facades \ Breadcrumbs :: class ) ; } } | Register the breadcrumbs component also merge the config from within the box config |
1,101 | protected function getNecessaryPermission ( $ action ) { $ parsed = $ this -> parseAction ( $ action ) ; return ResourcePermissions :: permissionFor ( $ parsed [ 'resource' ] , $ parsed [ 'action' ] ) ; } | Returns permission name like edit users list users etc based on resource and action |
1,102 | public function handle ( Login $ event ) { if ( config ( 'konekt.app_shell.disable.login_counter' ) ) { return ; } $ event -> user -> last_login_at = Carbon :: now ( ) ; $ event -> user -> login_count += 1 ; $ event -> user -> save ( ) ; } | Updates user s login data |
1,103 | public function loadBreadcrumbs ( ) { if ( ! $ this -> config ( 'breadcrumbs' ) ) { return false ; } $ file = sprintf ( '%s/%s/%s' , $ this -> basePath , $ this -> convention -> routesFolder ( ) , 'breadcrumbs.php' ) ; if ( file_exists ( $ file ) ) { require $ file ; } } | Loads definitions from breadcrumbs file in case it s enabled in the config |
1,104 | public static function allPermissionsFor ( $ resource ) { $ result = [ ] ; foreach ( static :: $ permissions as $ permission ) { $ result [ ] = sprintf ( '%s %s' , $ permission , str_plural ( $ resource ) ) ; } return $ result ; } | Returns all the standard permissions for a resource |
1,105 | public function addGlobals ( $ globals ) { foreach ( $ globals as $ name => $ value ) { if ( is_array ( $ value ) && isset ( $ value [ 'class' ] ) ) { $ value = new ViewRendererStaticClassProxy ( $ value [ 'class' ] ) ; } $ this -> twig -> addGlobal ( $ name , $ value ) ; } } | Adds global objects or static classes |
1,106 | public function addExtensions ( $ extensions ) { foreach ( $ extensions as $ extName ) { $ this -> twig -> addExtension ( is_object ( $ extName ) ? $ extName : Yii :: createObject ( $ extName ) ) ; } } | Adds custom extensions |
1,107 | public function setLexerOptions ( $ options ) { $ lexer = new \ Twig_Lexer ( $ this -> twig , $ options ) ; $ this -> twig -> setLexer ( $ lexer ) ; } | Sets Twig lexer options to change templates syntax |
1,108 | private function _addCustom ( $ classType , $ elements ) { $ classFunction = 'Twig_Simple' . $ classType ; foreach ( $ elements as $ name => $ func ) { $ twigElement = null ; switch ( $ func ) { case is_callable ( $ func ) : $ twigElement = new $ classFunction ( $ name , $ func ) ; break ; case is_array ( $ func ) && is_callable ( $ func [ 0 ] ) : $ twigElement = new $ classFunction ( $ name , $ func [ 0 ] , ( ! empty ( $ func [ 1 ] ) && is_array ( $ func [ 1 ] ) ) ? $ func [ 1 ] : [ ] ) ; break ; case $ func instanceof \ Twig_SimpleFunction || $ func instanceof \ Twig_SimpleFilter : $ twigElement = $ func ; } if ( $ twigElement !== null ) { $ this -> twig -> { 'add' . $ classType } ( $ twigElement ) ; } else { throw new \ Exception ( "Incorrect options for \"$classType\" $name." ) ; } } } | Adds custom function or filter |
1,109 | public function registerAsset ( $ context , $ asset ) { return $ this -> resolveAndCall ( $ asset , 'register' , [ isset ( $ context [ 'this' ] ) ? $ context [ 'this' ] : null , ] ) ; } | Function for registering an asset |
1,110 | public function registerAssetBundle ( $ context , $ bundle , $ return = false ) { $ bundle = str_replace ( '/' , '\\' , $ bundle ) ; $ bundle = $ this -> call ( $ bundle , 'register' , [ isset ( $ context [ 'this' ] ) ? $ context [ 'this' ] : null , ] ) ; if ( $ return ) { return $ bundle ; } } | Function for additional syntax of registering asset bundles |
1,111 | public function viewHelper ( $ context , $ name = null ) { if ( $ name !== null && isset ( $ context [ 'this' ] ) ) { $ this -> call ( $ context [ 'this' ] , Inflector :: variablize ( $ name ) ) ; } } | Used for begin_page end_page begin_body end_body head |
1,112 | public function resolveAndCall ( $ className , $ method , $ arguments = null ) { return $ this -> call ( $ this -> resolveClassName ( $ className ) , $ method , $ arguments ) ; } | Resolves a method from widget and asset syntax and calls it |
1,113 | public function call ( $ className , $ method , $ arguments = null ) { $ callable = [ $ className , $ method ] ; if ( $ arguments === null ) { return call_user_func ( $ callable ) ; } else { return call_user_func_array ( $ callable , $ arguments ) ; } } | Calls a method |
1,114 | public function resolveClassName ( $ className ) { $ className = Inflector :: id2camel ( $ className , '_' ) ; if ( isset ( $ this -> aliases [ $ className ] ) ) { return $ this -> aliases [ $ className ] ; } foreach ( $ this -> namespaces as $ namespace ) { $ resolvedClassName = $ namespace . '\\' . $ className ; if ( class_exists ( $ resolvedClassName ) ) { return $ this -> aliases [ $ className ] = $ resolvedClassName ; } } return $ className ; } | Resolves class name from widget and asset syntax |
1,115 | public function addUses ( $ args ) { foreach ( ( array ) $ args as $ key => $ value ) { $ value = str_replace ( '/' , '\\' , $ value ) ; if ( is_int ( $ key ) ) { if ( class_exists ( $ value ) ) { $ this -> aliases [ StringHelper :: basename ( $ value ) ] = $ value ; } else { $ this -> namespaces [ ] = $ value ; } } else { $ this -> aliases [ $ key ] = $ value ; } } } | Adds namespaces and aliases from constructor |
1,116 | public function path ( $ path , $ args = [ ] ) { if ( is_array ( $ path ) ) { $ path = array_merge ( $ path , $ args ) ; } elseif ( $ args !== [ ] ) { $ path = array_merge ( [ $ path ] , $ args ) ; } return Url :: to ( $ path ) ; } | Generates relative URL |
1,117 | public function _dump ( $ value ) { if ( is_object ( $ value ) && get_class ( $ value ) == 'MrRio\ShellWrap' ) { echo strval ( $ value ) ; return 0 ; } return parent :: _dump ( $ value ) ; } | Override the public dump function so we can display plain text from ShellWrap instead of an object dump . |
1,118 | public function get_array ( ) { $ response_part = array ( ) ; $ response_part [ 'status' ] = $ this -> http_status ; if ( base :: $ debug ) { $ response_part [ 'code' ] = $ this -> error_message ; } if ( $ this -> friendly_message ) { $ response_part [ 'title' ] = $ this -> friendly_message ; } if ( $ this -> friendly_detail ) { $ response_part [ 'detail' ] = $ this -> friendly_detail ; } if ( $ this -> post_body_pointer || $ this -> get_parameter_name ) { $ response_part [ 'source' ] = array ( ) ; if ( $ this -> post_body_pointer ) { $ response_part [ 'source' ] [ 'pointer' ] = $ this -> post_body_pointer ; } if ( $ this -> get_parameter_name ) { $ response_part [ 'source' ] [ 'parameter' ] = $ this -> get_parameter_name ; } } if ( $ this -> about_link ) { $ response_part [ 'links' ] = array ( 'about' => $ this -> about_link , ) ; } if ( $ this -> identifier ) { $ response_part [ 'id' ] = $ this -> identifier ; } if ( $ this -> meta_data ) { $ response_part [ 'meta' ] = $ this -> meta_data ; } return $ response_part ; } | generates an array for inclusion in the whole response body of an errors collection |
1,119 | public function fill_meta ( $ meta_data ) { foreach ( $ meta_data as $ key => $ single_meta_data ) { $ this -> add_meta ( $ key , $ single_meta_data ) ; } } | fills the meta data this will end up in response . meta |
1,120 | protected static function convert_object_to_array ( $ object ) { if ( is_object ( $ object ) == false ) { throw new \ Exception ( 'can only convert objects' ) ; } if ( $ object instanceof \ alsvanzelf \ jsonapi \ resource ) { return $ object -> get_array ( ) ; } return get_object_vars ( $ object ) ; } | converting an object to an array |
1,121 | public static function fromAnything ( $ relation , array $ links = [ ] , array $ meta = [ ] ) { if ( is_array ( $ relation ) ) { $ relation = CollectionDocument :: fromResources ( ... $ relation ) ; } if ( $ relation instanceof ResourceInterface ) { $ relationshipObject = self :: fromResource ( $ relation , $ links , $ meta ) ; } elseif ( $ relation instanceof CollectionDocument ) { $ relationshipObject = self :: fromCollectionDocument ( $ relation , $ links , $ meta ) ; } elseif ( $ relation === null ) { $ relationshipObject = new RelationshipObject ( RelationshipObject :: TO_ONE ) ; } else { throw new InputException ( 'unknown format of relation "' . gettype ( $ relation ) . '"' ) ; } return $ relationshipObject ; } | create a RelationshipObject from mixed input |
1,122 | public function setResource ( ResourceInterface $ resource ) { if ( $ this -> type === RelationshipObject :: TO_MANY ) { throw new InputException ( 'can not set a resource on a to-many relationship, use ->addResource()' ) ; } $ this -> resource = $ resource ; } | set the resource on a to - one relationship |
1,123 | public function addResource ( ResourceInterface $ resource ) { if ( $ this -> type === RelationshipObject :: TO_ONE ) { throw new InputException ( 'can not add a resource to a to-one relationship, use ->setResource()' ) ; } $ this -> resources [ ] = $ resource ; } | add a resource to a to - many relationship |
1,124 | public static function mergeProfilesInContentType ( $ contentType , array $ profiles ) { if ( $ profiles === [ ] ) { return $ contentType ; } $ profileLinks = [ ] ; foreach ( $ profiles as $ profile ) { $ link = $ profile -> getAliasedLink ( ) ; $ profileLinks [ ] = ( $ link instanceof LinkObject ) ? $ link -> toArray ( ) [ 'href' ] : $ link ; } $ profileLinks = implode ( ' ' , $ profileLinks ) ; return $ contentType . ';profile="' . $ profileLinks . '", ' . $ contentType ; } | generates the value for a content type header with profiles merged in if available |
1,125 | public function fill_data ( $ values ) { if ( is_object ( $ values ) ) { $ values = parent :: convert_object_to_array ( $ values ) ; } if ( is_array ( $ values ) == false ) { throw new \ Exception ( 'use add_data() for adding scalar values' ) ; } if ( isset ( $ values [ 'id' ] ) && $ values [ 'id' ] == $ this -> primary_id ) { unset ( $ values [ 'id' ] ) ; } foreach ( $ values as $ key => $ single_value ) { $ this -> add_data ( $ key , $ single_value ) ; } } | fills the primary data this will end up in response . data . attributes |
1,126 | public function fill_relations ( $ relations , $ skip_include = false ) { foreach ( $ relations as $ key => $ relation ) { $ this -> add_relation ( $ key , $ relation , $ skip_include ) ; } } | fills the relationships to other resources this will end up in response . data . relationships |
1,127 | public function send_response ( $ content_type = null , $ encode_options = null , $ response = null , $ jsonp_callback = null ) { $ jsonapi = new errors ( $ this , $ this -> friendly_message , $ this -> about_link ) ; $ jsonapi -> send_response ( $ content_type , $ encode_options , $ response , $ jsonp_callback ) ; exit ; } | sends out the json response of an jsonapi \ errors object to the browser |
1,128 | public function setLinks ( PaginableInterface $ paginable , $ baseOrCurrentUrl , $ firstCursor , $ lastCursor ) { $ previousLinkObject = new LinkObject ( $ this -> generatePreviousLink ( $ baseOrCurrentUrl , $ firstCursor ) ) ; $ nextLinkObject = new LinkObject ( $ this -> generateNextLink ( $ baseOrCurrentUrl , $ lastCursor ) ) ; $ this -> setPaginationLinkObjects ( $ paginable , $ previousLinkObject , $ nextLinkObject ) ; } | set links to paginate the data using cursors of the paginated data |
1,129 | public function setPaginationLinkObjects ( PaginableInterface $ paginable , LinkObject $ previousLinkObject , LinkObject $ nextLinkObject ) { $ paginable -> addLinkObject ( 'prev' , $ previousLinkObject ) ; $ paginable -> addLinkObject ( 'next' , $ nextLinkObject ) ; } | pagination links are inside the links object that is a sibling of the paginated data |
1,130 | public function setItemMeta ( ResourceInterface $ resource , $ cursor ) { $ metadata = [ 'cursor' => $ cursor , ] ; if ( $ resource instanceof ResourceDocument ) { $ resource -> addMeta ( $ this -> getKeyword ( 'page' ) , $ metadata , $ level = Document :: LEVEL_RESOURCE ) ; } else { $ resource -> addMeta ( $ this -> getKeyword ( 'page' ) , $ metadata ) ; } } | pagination item metadata is the page meta at the top - level of a paginated item |
1,131 | public function getUnsupportedSortErrorObject ( $ genericTitle = null , $ specificDetails = null ) { $ errorObject = new ErrorObject ( 'Unsupported sort' ) ; $ errorObject -> appendTypeLink ( 'https://jsonapi.org/profiles/ethanresnick/cursor-pagination/unsupported-sort' ) ; $ errorObject -> blameQueryParameter ( 'sort' ) ; $ errorObject -> setHttpStatusCode ( 400 ) ; if ( $ genericTitle !== null ) { $ errorObject -> setHumanExplanation ( $ genericTitle , $ specificDetails ) ; } return $ errorObject ; } | get an ErrorObject for when the requested sorting cannot efficiently be paginated |
1,132 | public function getMaxPageSizeExceededErrorObject ( $ maxSize , $ genericTitle = null , $ specificDetails = null ) { $ errorObject = new ErrorObject ( 'Max page size exceeded' ) ; $ errorObject -> appendTypeLink ( 'https://jsonapi.org/profiles/ethanresnick/cursor-pagination/max-size-exceeded' ) ; $ errorObject -> blameQueryParameter ( $ this -> getKeyword ( 'page' ) . '[size]' ) ; $ errorObject -> setHttpStatusCode ( 400 ) ; $ errorObject -> addMeta ( $ this -> getKeyword ( 'page' ) , $ value = [ 'maxSize' => $ maxSize ] ) ; if ( $ genericTitle !== null ) { $ errorObject -> setHumanExplanation ( $ genericTitle , $ specificDetails ) ; } return $ errorObject ; } | get an ErrorObject for when the requested page size exceeds the server - defined max page size |
1,133 | private function setQueryParameter ( $ url , $ key , $ value ) { $ originalQuery = parse_url ( $ url , PHP_URL_QUERY ) ; $ decodedQuery = urldecode ( $ originalQuery ) ; $ originalIsEncoded = ( $ decodedQuery !== $ originalQuery ) ; $ originalParameters = [ ] ; parse_str ( $ decodedQuery , $ originalParameters ) ; $ newParameters = [ ] ; parse_str ( $ key . '=' . $ value , $ newParameters ) ; $ fullParameters = array_replace_recursive ( $ originalParameters , $ newParameters ) ; $ newQuery = http_build_query ( $ fullParameters ) ; if ( $ originalIsEncoded === false ) { $ newQuery = urldecode ( $ newQuery ) ; } $ newUrl = str_replace ( $ originalQuery , $ newQuery , $ url ) ; return $ newUrl ; } | add or adjust a key in the query string of a url |
1,134 | public function addLink ( $ key , $ href , array $ meta = [ ] ) { $ this -> ensureLinksObject ( ) ; $ this -> links -> add ( $ key , $ href , $ meta ) ; } | set a key containing a link |
1,135 | public function appendLink ( $ key , $ href , array $ meta = [ ] ) { $ this -> ensureLinksObject ( ) ; $ this -> links -> append ( $ key , $ href , $ meta ) ; } | append a link to a key with an array of links |
1,136 | public function addLinkObject ( $ key , LinkObject $ linkObject ) { $ this -> ensureLinksObject ( ) ; $ this -> links -> addLinkObject ( $ key , $ linkObject ) ; } | set a key containing a LinkObject |
1,137 | public function addLinksArray ( $ key , LinksArray $ linksArray ) { $ this -> ensureLinksObject ( ) ; $ this -> links -> addLinksArray ( $ key , $ linksArray ) ; } | set a key containing a LinksArray |
1,138 | public function appendLinkObject ( $ key , LinkObject $ linkObject ) { $ this -> ensureLinksObject ( ) ; $ this -> links -> appendLinkObject ( $ key , $ linkObject ) ; } | append a LinkObject to a key with a LinksArray |
1,139 | public static function fromResources ( ResourceInterface ... $ resources ) { $ collectionDocument = new self ( ) ; foreach ( $ resources as $ resource ) { $ collectionDocument -> addResource ( $ resource ) ; } return $ collectionDocument ; } | generate a CollectionDocument from one or multiple resources |
1,140 | public function addResource ( ResourceInterface $ resource , array $ options = [ ] ) { if ( $ resource -> getResource ( ) -> isEmpty ( ) ) { throw new InputException ( 'does not make sense to add empty resources to a collection' ) ; } $ options = array_merge ( self :: $ defaults , $ options ) ; $ this -> validator -> claimUsedResourceIdentifier ( $ resource ) ; $ this -> resources [ ] = $ resource ; if ( $ options [ 'includeContainedResources' ] && $ resource instanceof RecursiveResourceContainerInterface ) { $ this -> addIncludedResourceObject ( ... $ resource -> getNestedContainedResourceObjects ( ) ) ; } } | add a resource to the collection |
1,141 | public function add ( $ key , $ value , array $ options = [ ] ) { $ options = array_merge ( self :: $ defaults , $ options ) ; if ( $ this -> attributes === null ) { $ this -> attributes = new AttributesObject ( ) ; } $ this -> validator -> claimUsedFields ( [ $ key ] , Validator :: OBJECT_CONTAINER_ATTRIBUTES , $ options ) ; $ this -> attributes -> add ( $ key , $ value ) ; } | add key - value pairs to attributes |
1,142 | public function hasIdentifierPropertiesOnly ( ) { if ( $ this -> attributes !== null && $ this -> attributes -> isEmpty ( ) === false ) { return false ; } if ( $ this -> relationships !== null && $ this -> relationships -> isEmpty ( ) === false ) { return false ; } if ( $ this -> links !== null && $ this -> links -> isEmpty ( ) === false ) { return false ; } return true ; } | whether the ResourceObject is empty except for the ResourceIdentifierObject |
1,143 | public function set_redirect_location ( $ location ) { if ( self :: $ send_status_headers == false && base :: $ debug ) { trigger_error ( 'location will not be send out unless response::$send_status_headers is true' , E_USER_NOTICE ) ; } $ this -> redirect_location = $ location ; } | sets a new location the client should follow |
1,144 | public function fill_links ( $ links ) { foreach ( $ links as $ key => $ link ) { $ this -> add_link ( $ key , $ link ) ; } } | fills the set of links this will end up in response . links |
1,145 | public function set_self_link ( $ link , $ meta_data = null ) { if ( $ meta_data ) { if ( is_string ( $ link ) == false ) { throw new \ Exception ( 'link "self" should be a string if meta data is provided separate' ) ; } if ( is_object ( $ meta_data ) ) { $ meta_data = parent :: convert_object_to_array ( $ meta_data ) ; } $ link = array ( 'href' => $ link , 'meta' => $ meta_data , ) ; } $ this -> links [ 'self' ] = $ link ; } | sets the link to the request used to give this response this will end up in response . links . self .. and in response . data . links . self for single resource objects |
1,146 | public function setSelfLink ( $ href , array $ meta = [ ] , $ level = Document :: LEVEL_ROOT ) { $ this -> addLink ( 'self' , $ href , $ meta , $ level ) ; } | set the self link on the document |
1,147 | public function applyProfile ( ProfileInterface $ profile ) { $ this -> profiles [ ] = $ profile ; if ( $ this -> links === null ) { $ this -> setLinksObject ( new LinksObject ( ) ) ; } $ link = $ profile -> getAliasedLink ( ) ; if ( $ link instanceof LinkObject ) { $ this -> links -> appendLinkObject ( 'profile' , $ link ) ; } else { $ this -> links -> append ( 'profile' , $ link ) ; } } | apply a profile which adds the link and sets a correct content - type |
1,148 | public function setHumanExplanation ( $ genericTitle , $ specificDetails = null , $ specificAboutLink = null , $ genericTypeLink = null ) { $ this -> setHumanTitle ( $ genericTitle ) ; if ( $ specificDetails !== null ) { $ this -> setHumanDetails ( $ specificDetails ) ; } if ( $ specificAboutLink !== null ) { $ this -> setAboutLink ( $ specificAboutLink ) ; } if ( $ genericTypeLink !== null ) { $ this -> appendTypeLink ( $ genericTypeLink ) ; } } | explain this particular occurence of the error in a human - friendly way |
1,149 | public function addSource ( $ key , $ value ) { Validator :: checkMemberName ( $ key ) ; $ this -> source [ $ key ] = $ value ; } | add the source of the error |
1,150 | public function claimUsedFields ( array $ fieldNames , $ objectContainer , array $ options = [ ] ) { $ options = array_merge ( self :: $ defaults , $ options ) ; foreach ( $ fieldNames as $ fieldName ) { if ( isset ( $ this -> usedFields [ $ fieldName ] ) === false ) { $ this -> usedFields [ $ fieldName ] = $ objectContainer ; continue ; } if ( $ this -> usedFields [ $ fieldName ] === $ objectContainer ) { continue ; } if ( $ this -> usedFields [ $ fieldName ] === Validator :: OBJECT_CONTAINER_TYPE && $ options [ 'enforceTypeFieldNamespace' ] === false ) { continue ; } throw new DuplicateException ( 'field name "' . $ fieldName . '" already in use at "data.' . $ this -> usedFields [ $ fieldName ] . '"' ) ; } } | block if already existing in another object otherwise just overwrite |
1,151 | public function append ( $ key , $ href , array $ meta = [ ] ) { Validator :: checkMemberName ( $ key ) ; if ( isset ( $ this -> links [ $ key ] ) === false ) { $ this -> addLinksArray ( $ key , new LinksArray ( ) ) ; } elseif ( $ this -> links [ $ key ] instanceof LinksArray === false ) { throw new DuplicateException ( 'can not add to key "' . $ key . '", it is not an array of links' ) ; } $ this -> links [ $ key ] -> add ( $ href , $ meta ) ; } | appends a link to an array of links under a specific key |
1,152 | public function addIncludedResourceObject ( ResourceObject ... $ resourceObjects ) { foreach ( $ resourceObjects as $ resourceObject ) { try { $ this -> validator -> claimUsedResourceIdentifier ( $ resourceObject ) ; } catch ( DuplicateException $ e ) { continue ; } $ this -> includedResources [ ] = $ resourceObject ; } } | mainly used when an included query parameter is passed and resources are requested separate from what is standard for a response |
1,153 | public function setVersion ( ResourceInterface $ resource , $ version ) { if ( $ resource instanceof ResourceDocument ) { $ resource -> addMeta ( $ this -> getKeyword ( 'version' ) , $ version , $ level = Document :: LEVEL_RESOURCE ) ; } else { $ resource -> addMeta ( $ this -> getKeyword ( 'version' ) , $ version ) ; } } | optionally helpers for the specific profile |
1,154 | public function add ( $ key , $ value , array $ options = [ ] ) { $ this -> ensureResourceObject ( ) ; $ this -> resource -> add ( $ key , $ value , $ options ) ; } | add key - value pairs to the resource s attributes |
1,155 | public function addRelationship ( $ key , $ relation , array $ links = [ ] , array $ meta = [ ] , array $ options = [ ] ) { $ this -> ensureResourceObject ( ) ; $ options = array_merge ( self :: $ defaults , $ options ) ; $ relationshipObject = $ this -> resource -> addRelationship ( $ key , $ relation , $ links , $ meta ) ; if ( $ options [ 'includeContainedResources' ] ) { $ this -> addIncludedResourceObject ( ... $ relationshipObject -> getNestedContainedResourceObjects ( ) ) ; } } | add a relation to the resource |
1,156 | public function setSelfLink ( $ href , array $ meta = [ ] , $ level = Document :: LEVEL_RESOURCE ) { $ this -> ensureResourceObject ( ) ; if ( $ level === Document :: LEVEL_RESOURCE ) { $ this -> resource -> setSelfLink ( $ href , $ meta ) ; } else { parent :: setSelfLink ( $ href , $ meta , $ level ) ; } } | set the self link on the resource |
1,157 | public function addRelationshipObject ( $ key , RelationshipObject $ relationshipObject , array $ options = [ ] ) { $ this -> ensureResourceObject ( ) ; $ options = array_merge ( self :: $ defaults , $ options ) ; $ this -> resource -> addRelationshipObject ( $ key , $ relationshipObject ) ; if ( $ options [ 'includeContainedResources' ] ) { $ this -> addIncludedResourceObject ( ... $ relationshipObject -> getNestedContainedResourceObjects ( ) ) ; } } | add a RelationshipObject to the resource |
1,158 | public function setRelationshipsObject ( RelationshipsObject $ relationshipsObject , array $ options = [ ] ) { $ this -> ensureResourceObject ( ) ; $ options = array_merge ( self :: $ defaults , $ options ) ; $ this -> resource -> setRelationshipsObject ( $ relationshipsObject ) ; if ( $ options [ 'includeContainedResources' ] ) { $ this -> addIncludedResourceObject ( ... $ relationshipsObject -> getNestedContainedResourceObjects ( ) ) ; } } | set the RelationshipsObject to the resource |
1,159 | public function setPrimaryResource ( ResourceInterface $ resource , array $ options = [ ] ) { if ( $ resource instanceof ResourceDocument ) { throw new InputException ( 'does not make sense to set a document inside a document, use ResourceObject or ResourceIdentifierObject instead' ) ; } $ options = array_merge ( self :: $ defaults , $ options ) ; $ this -> resource = $ resource ; if ( $ options [ 'includeContainedResources' ] && $ this -> resource instanceof RecursiveResourceContainerInterface ) { $ this -> addIncludedResourceObject ( ... $ this -> resource -> getNestedContainedResourceObjects ( ) ) ; } } | overwrites the primary resource |
1,160 | function listServers ( $ count = 100 , $ offset = 0 , $ name = NULL ) { $ query = array ( ) ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; $ query [ 'name' ] = $ name ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/servers/' , $ query ) ) ; } | Get a list of all servers configured on the account . |
1,161 | function listSenderSignatures ( $ count = 100 , $ offset = 0 ) { $ query = array ( ) ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/senders/' , $ query ) ) ; } | Get a page of Sender Signatures . |
1,162 | function createSenderSignature ( $ fromEmail , $ name , $ replyToEmail = NULL , $ returnPathDomain = NULL ) { $ body = array ( ) ; $ body [ 'fromEmail' ] = $ fromEmail ; $ body [ 'name' ] = $ name ; $ body [ 'replyToEmail' ] = $ replyToEmail ; $ body [ 'returnPathDomain' ] = $ returnPathDomain ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'POST' , '/senders/' , $ body ) ) ; } | Create a new Sender Signature for a given email address . Note that you will need to verify this Sender Signature by following a link that will be emailed to the fromEmail address specified when calling this method . |
1,163 | function editSenderSignature ( $ id , $ name = NULL , $ replyToEmail = NULL , $ returnPathDomain = NULL ) { $ body = array ( ) ; $ body [ 'name' ] = $ name ; $ body [ 'replyToEmail' ] = $ replyToEmail ; $ body [ 'returnPathDomain' ] = $ returnPathDomain ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'PUT' , "/senders/$id" , $ body ) ) ; } | Alter the defaults for a Sender Signature . |
1,164 | function listDomains ( $ count = 100 , $ offset = 0 ) { $ query = array ( ) ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/domains/' , $ query ) ) ; } | Get a page of Domains . |
1,165 | function createDomain ( $ name , $ returnPathDomain = NULL ) { $ body = array ( ) ; $ body [ 'name' ] = $ name ; $ body [ 'returnPathDomain' ] = $ returnPathDomain ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'POST' , '/domains/' , $ body ) ) ; } | Create a new Domain with the given Name . |
1,166 | function editDomain ( $ id , $ returnPathDomain = NULL ) { $ body = array ( ) ; $ body [ 'returnPathDomain' ] = $ returnPathDomain ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'PUT' , "/domains/$id" , $ body ) ) ; } | Alter the properties of a Domain . |
1,167 | function sendEmailWithTemplate ( $ from , $ to , $ templateId , $ templateModel , $ inlineCss = true , $ tag = NULL , $ trackOpens = true , $ replyTo = NULL , $ cc = NULL , $ bcc = NULL , $ headers = NULL , $ attachments = NULL , $ trackLinks = NULL , $ metadata = NULL ) { $ body = array ( ) ; $ body [ 'From' ] = $ from ; $ body [ 'To' ] = $ to ; $ body [ 'Cc' ] = $ cc ; $ body [ 'Bcc' ] = $ bcc ; $ body [ 'Tag' ] = $ tag ; $ body [ 'ReplyTo' ] = $ replyTo ; $ body [ 'Headers' ] = $ this -> fixHeaders ( $ headers ) ; $ body [ 'TrackOpens' ] = $ trackOpens ; $ body [ 'Attachments' ] = $ attachments ; $ body [ 'TemplateModel' ] = $ templateModel ; $ body [ 'TemplateId' ] = $ templateId ; $ body [ 'InlineCss' ] = $ inlineCss ; $ body [ 'Metadata' ] = $ metadata ; if ( $ trackLinks !== NULL ) { $ body [ 'TrackLinks' ] = $ trackLinks ; } return new DynamicResponseModel ( $ this -> processRestRequest ( 'POST' , '/email/withTemplate' , $ body ) ) ; } | Send an email using a template . |
1,168 | private function fixHeaders ( $ headers ) { $ retval = NULL ; if ( $ headers != NULL ) { $ retval = array ( ) ; $ index = 0 ; foreach ( $ headers as $ key => $ value ) { $ retval [ $ index ] = array ( 'Name' => $ key , 'Value' => $ value ) ; $ index ++ ; } } return $ retval ; } | The Postmark API wants an Array of Key - Value pairs not a dictionary object therefore we need to wrap the elements in an array . |
1,169 | function sendEmailBatch ( $ emailBatch = array ( ) ) { $ final = array ( ) ; foreach ( $ emailBatch as $ email ) { foreach ( $ email as $ emailIdx => $ emailValue ) { if ( strtolower ( $ emailIdx ) == 'headers' ) { $ email [ $ emailIdx ] = $ this -> fixHeaders ( $ emailValue ) ; } } array_push ( $ final , $ email ) ; } return new DynamicResponseModel ( $ this -> processRestRequest ( 'POST' , '/email/batch' , $ final ) ) ; } | Send multiple emails as a batch |
1,170 | function getBounces ( $ count = 100 , $ offset = 0 , $ type = NULL , $ inactive = NULL , $ emailFilter = NULL , $ tag = NULL , $ messageID = NULL , $ fromdate = NULL , $ todate = NULL ) { $ query = array ( ) ; $ query [ 'type' ] = $ type ; $ query [ 'inactive' ] = $ inactive ; $ query [ 'emailFilter' ] = $ emailFilter ; $ query [ 'tag' ] = $ tag ; $ query [ 'messageID' ] = $ messageID ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; $ query [ 'fromdate' ] = $ fromdate ; $ query [ 'todate' ] = $ todate ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/bounces' , $ query ) ) ; } | Get a batch of bounces to be processed . |
1,171 | function getOutboundMessages ( $ count = 100 , $ offset = 0 , $ recipient = NULL , $ fromEmail = NULL , $ tag = NULL , $ subject = NULL , $ status = NULL , $ fromdate = NULL , $ todate = NULL , $ metadata = NULL ) { $ query = array ( ) ; $ query [ "recipient" ] = $ recipient ; $ query [ "fromemail" ] = $ fromEmail ; $ query [ "tag" ] = $ tag ; $ query [ "subject" ] = $ subject ; $ query [ "count" ] = $ count ; $ query [ "offset" ] = $ offset ; $ query [ "status" ] = $ status ; $ query [ "fromdate" ] = $ fromdate ; $ query [ "todate" ] = $ todate ; if ( $ metadata != NULL ) { foreach ( $ metadata as $ key => $ value ) { $ query [ "metadata_$key" ] = $ value ; } } return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/messages/outbound' , $ query ) ) ; } | Search messages that have been sent using this Server . |
1,172 | function getInboundMessages ( $ count = 100 , $ offset = 0 , $ recipient = NULL , $ fromEmail = NULL , $ tag = NULL , $ subject = NULL , $ mailboxHash = NULL , $ status = NULL , $ fromdate = NULL , $ todate = NULL ) { $ query = array ( ) ; $ query [ 'recipient' ] = $ recipient ; $ query [ 'fromemail' ] = $ fromEmail ; $ query [ 'tag' ] = $ tag ; $ query [ 'subject' ] = $ subject ; $ query [ 'mailboxhash' ] = $ mailboxHash ; $ query [ 'count' ] = $ count ; $ query [ 'status' ] = $ status ; $ query [ 'offset' ] = $ offset ; $ query [ 'fromdate' ] = $ fromdate ; $ query [ 'todate' ] = $ todate ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/messages/inbound' , $ query ) ) ; } | Get messages sent to the inbound email address associated with this Server . |
1,173 | function getOpenStatistics ( $ count = 100 , $ offset = 0 , $ recipient = NULL , $ tag = NULL , $ clientName = NULL , $ clientCompany = NULL , $ clientFamily = NULL , $ osName = NULL , $ osFamily = NULL , $ osCompany = NULL , $ platform = NULL , $ country = NULL , $ region = NULL , $ city = NULL ) { $ query = array ( ) ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; $ query [ 'recipient' ] = $ recipient ; $ query [ 'tag' ] = $ tag ; $ query [ 'client_name' ] = $ clientName ; $ query [ 'client_company' ] = $ clientCompany ; $ query [ 'client_family' ] = $ clientFamily ; $ query [ 'os_name' ] = $ osName ; $ query [ 'os_family' ] = $ osFamily ; $ query [ 'os_company' ] = $ osCompany ; $ query [ 'platform' ] = $ platform ; $ query [ 'country' ] = $ country ; $ query [ 'region' ] = $ region ; $ query [ 'city' ] = $ city ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/messages/outbound/opens' , $ query ) ) ; } | Get statistics for tracked messages optionally filtering by various open event properties . |
1,174 | function getOpenStatisticsForMessage ( $ id , $ count = 100 , $ offset = 0 ) { $ query = array ( ) ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , "/messages/outbound/opens/$id" , $ query ) ) ; } | Get information about individual opens for a sent message . |
1,175 | function getClickStatisticsForMessage ( $ id , $ count = 100 , $ offset = 0 ) { $ query = array ( ) ; $ query [ 'count' ] = $ count ; $ query [ 'offset' ] = $ offset ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , "/messages/outbound/clicks/$id" , $ query ) ) ; } | Get information about individual clicks for a sent message . |
1,176 | function getOutboundClickStatistics ( $ tag = NULL , $ fromdate = NULL , $ todate = NULL ) { $ query = array ( ) ; $ query [ 'tag' ] = $ tag ; $ query [ 'fromdate' ] = $ fromdate ; $ query [ 'todate' ] = $ todate ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/stats/outbound/clicks' , $ query ) ) ; } | Get click statistics for the messages sent using this Server optionally filtering on message tag and a to and from date . |
1,177 | function createTagTrigger ( $ matchName , $ trackOpens = true ) { $ body = array ( ) ; $ body [ "MatchName" ] = $ matchName ; $ body [ "TrackOpens" ] = $ trackOpens ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'POST' , '/triggers/tags' , $ body ) ) ; } | Create a Tag Trigger . |
1,178 | function searchTagTriggers ( $ count = 100 , $ offset = 0 , $ matchName = NULL ) { $ query = array ( ) ; $ query [ "count" ] = $ count ; $ query [ "offset" ] = $ offset ; $ query [ "match_name" ] = $ matchName ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/triggers/tags' , $ query ) ) ; } | Locate Tag Triggers matching the filter criteria . |
1,179 | function editTagTrigger ( $ id , $ matchName , $ trackOpens = true ) { $ body = array ( ) ; $ body [ "MatchName" ] = $ matchName ; $ body [ "TrackOpens" ] = $ trackOpens ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'PUT' , "/triggers/tags/$id" , $ body ) ) ; } | Edit an existing Tag Trigger |
1,180 | function listInboundRuleTriggers ( $ count = 100 , $ offset = 0 ) { $ query = array ( ) ; $ query [ "count" ] = $ count ; $ query [ "offset" ] = $ offset ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , '/triggers/inboundrules' , $ query ) ) ; } | Get a list of all existing Inbound Rule Triggers . |
1,181 | function createTemplate ( $ name , $ subject , $ htmlBody , $ textBody ) { $ template = array ( ) ; $ template [ "name" ] = $ name ; $ template [ "subject" ] = $ subject ; $ template [ "htmlBody" ] = $ htmlBody ; $ template [ "textBody" ] = $ textBody ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'POST' , "/templates" , $ template ) ) ; } | Create a template |
1,182 | function listTemplates ( $ count = 100 , $ offset = 0 ) { $ query = array ( ) ; $ query [ "count" ] = $ count ; $ query [ "offset" ] = $ offset ; return new DynamicResponseModel ( $ this -> processRestRequest ( 'GET' , "/templates" , $ query ) ) ; } | Get all templates associated with the Server . |
1,183 | public function offsetGet ( $ offset ) { $ result = parent :: offsetGet ( $ offset ) ; if ( $ result != NULL && is_array ( $ result ) ) { $ result = new DynamicResponseModel ( $ result ) ; } return $ result ; } | Infrastructure . Allows indexer to return a DynamicResponseModel . |
1,184 | protected function getClient ( ) { if ( ! $ this -> client ) { $ this -> client = new Client ( [ RequestOptions :: VERIFY => self :: $ VERIFY_SSL , RequestOptions :: TIMEOUT => $ this -> timeout , ] ) ; } return $ this -> client ; } | Return the injected GuzzleHttp \ Client or create a default instance |
1,185 | public function recordedMessages ( ) { $ allRecordedMessages = [ ] ; foreach ( $ this -> messageRecorders as $ messageRecorder ) { $ allRecordedMessages = array_merge ( $ allRecordedMessages , $ messageRecorder -> recordedMessages ( ) ) ; } return $ allRecordedMessages ; } | Get messages recorded by all known message recorders . |
1,186 | public function handle ( $ message , callable $ next ) { $ this -> queue [ ] = $ message ; if ( ! $ this -> isHandling ) { $ this -> isHandling = true ; while ( $ message = array_shift ( $ this -> queue ) ) { try { $ next ( $ message ) ; } catch ( Exception $ exception ) { $ this -> isHandling = false ; throw $ exception ; } } $ this -> isHandling = false ; } } | Completely finishes handling the current message before allowing other middlewares to start handling new messages . |
1,187 | protected function getBody ( \ Psr \ Http \ Message \ MessageInterface $ message ) { $ body = trim ( $ message -> getBody ( ) ) ; if ( $ message -> getBody ( ) -> getSize ( ) === 0 || empty ( $ body ) ) { if ( $ message instanceof \ Psr \ Http \ Message \ ResponseInterface ) { return 'No response body returned' ; } return 'No request body sent' ; } $ result = json_decode ( $ body ) ; if ( $ result !== null ) { return json_encode ( $ result , JSON_PRETTY_PRINT ) ; } return $ body ; } | Get response body |
1,188 | protected function parseArguments ( ) { $ args = $ this -> getNamedArgs ( ) ; $ this -> climate -> arguments -> add ( $ args ) ; if ( $ _SERVER [ 'argc' ] === 1 ) { $ this -> help ( ) ; return false ; } if ( $ this -> climate -> arguments -> defined ( 'help' ) ) { $ this -> help ( ) ; return ; } if ( $ this -> climate -> arguments -> defined ( 'version' ) ) { echo $ this -> version ( ) ; return ; } try { $ this -> climate -> arguments -> parse ( $ _SERVER [ 'argv' ] ) ; $ padding = count ( $ args ) ; foreach ( $ this -> climate -> arguments -> toArray ( ) as $ arg ) { if ( $ arg === null ) { -- $ padding ; } } $ argSize = count ( $ _SERVER [ 'argv' ] ) - $ padding - 1 ; for ( $ i = 0 ; $ i < $ argSize ; $ i ++ ) { $ args [ 'arg-' . $ i ] = [ ] ; } $ this -> climate -> arguments -> add ( $ args ) ; $ this -> climate -> arguments -> parse ( $ _SERVER [ 'argv' ] ) ; } catch ( \ Exception $ e ) { } return true ; } | Parse incoming arguments |
1,189 | public function help ( ) { $ arguments = new \ League \ CLImate \ Argument \ Manager ( ) ; $ arguments -> description ( 'Akamai {OPEN} Edgegrid Auth for PHP Client (v' . Client :: VERSION . ')' ) ; $ arguments -> add ( $ this -> getNamedArgs ( ) ) ; $ arguments -> usage ( $ this -> climate , $ _SERVER [ 'argv' ] ) ; } | Display CLI help |
1,190 | protected function getArgValue ( $ matches ) { $ value = $ matches [ 'value' ] ; if ( ! empty ( $ matches [ 'file' ] ) ) { if ( ! file_exists ( $ matches [ 'value' ] ) || ! is_readable ( $ matches [ 'value' ] ) ) { $ this -> climate -> error ( 'Unable to read input file: ' . $ matches [ 'value' ] ) ; return false ; } $ value = file_get_contents ( $ matches [ 'value' ] ) ; } return $ value ; } | Get argument values |
1,191 | public function requestAsync ( $ method , $ uri = null , array $ options = [ ] ) { $ options = $ this -> setRequestOptions ( $ options ) ; $ query = parse_url ( $ uri , PHP_URL_QUERY ) ; if ( ! empty ( $ query ) ) { $ uri = substr ( $ uri , 0 , ( strlen ( $ query ) + 1 ) * - 1 ) ; parse_str ( $ query , $ options [ 'query' ] ) ; } return parent :: requestAsync ( $ method , $ uri , $ options ) ; } | Make an Asynchronous request |
1,192 | public function sendAsync ( \ Psr \ Http \ Message \ RequestInterface $ request , array $ options = [ ] ) { $ options = $ this -> setRequestOptions ( $ options ) ; return parent :: sendAsync ( $ request , $ options ) ; } | Send an Asynchronous HTTP request |
1,193 | public function setHost ( $ host ) { if ( substr ( $ host , - 1 ) === '/' ) { $ host = substr ( $ host , 0 , - 1 ) ; } $ headers = $ this -> getConfig ( 'headers' ) ; $ headers [ 'Host' ] = $ host ; $ this -> setConfigOption ( 'headers' , $ headers ) ; if ( strpos ( '/' , $ host ) === false ) { $ host = 'https://' . $ host ; } $ this -> setConfigOption ( 'base_uri' , $ host ) ; return $ this ; } | Set Request Host |
1,194 | public static function createFromEdgeRcFile ( $ section = 'default' , $ path = null , array $ config = [ ] ) { $ auth = \ Akamai \ Open \ EdgeGrid \ Authentication :: createFromEdgeRcFile ( $ section , $ path ) ; if ( $ host = $ auth -> getHost ( ) ) { $ config [ 'base_uri' ] = 'https://' . $ host ; } return new static ( $ config , $ auth ) ; } | Factory method to create a client using credentials from . edgerc |
1,195 | protected function getDebugOption ( array $ config ) { if ( isset ( $ config [ 'debug' ] ) ) { return ( $ config [ 'debug' ] === true ) ? fopen ( 'php://stderr' , 'ab' ) : $ config [ 'debug' ] ; } if ( $ this -> debugOverride && $ this -> debug ) { return ( $ this -> debug === true ) ? fopen ( 'php://stderr' , 'ab' ) : $ this -> debug ; } elseif ( ! $ this -> debugOverride && static :: $ staticDebug ) { return ( static :: $ staticDebug === true ) ? fopen ( 'php://stderr' , 'ab' ) : static :: $ staticDebug ; } return false ; } | Handle debug option |
1,196 | protected function isDebug ( ) { if ( ( $ this -> debugOverride && ! $ this -> debug ) || ( ! $ this -> debugOverride && ! static :: $ staticDebug ) ) { return false ; } if ( $ this -> debugOverride && $ this -> debug ) { return $ this -> debug ; } return static :: $ staticDebug ; } | Debugging status for the current request |
1,197 | protected function isVerbose ( ) { if ( ( $ this -> verboseOverride && ! $ this -> verbose ) || ( ! $ this -> verboseOverride && ! static :: $ staticVerbose ) ) { return false ; } if ( $ this -> verboseOverride && $ this -> verbose ) { return $ this -> verbose ; } return static :: $ staticVerbose ; } | Verbose status for the current request |
1,198 | protected function setAuthentication ( array $ config , Authentication $ authentication = null ) { $ this -> authentication = $ authentication ; if ( $ authentication === null ) { $ this -> authentication = new Authentication ( ) ; } if ( isset ( $ config [ 'timestamp' ] ) ) { $ this -> authentication -> setTimestamp ( $ config [ 'timestamp' ] ) ; } if ( isset ( $ config [ 'nonce' ] ) ) { $ this -> authentication -> setNonce ( $ config [ 'nonce' ] ) ; } } | Set the Authentication instance |
1,199 | protected function setAuthenticationHandler ( array $ config , Authentication $ authentication = null ) { $ this -> setAuthentication ( $ config , $ authentication ) ; $ authenticationHandler = new AuthenticationHandler ( ) ; $ authenticationHandler -> setSigner ( $ this -> authentication ) ; if ( ! isset ( $ config [ 'handler' ] ) ) { $ config [ 'handler' ] = \ GuzzleHttp \ HandlerStack :: create ( ) ; } try { if ( ! ( $ config [ 'handler' ] instanceof \ GuzzleHttp \ HandlerStack ) ) { $ config [ 'handler' ] = \ GuzzleHttp \ HandlerStack :: create ( $ config [ 'handler' ] ) ; } $ config [ 'handler' ] -> before ( 'history' , $ authenticationHandler , 'authentication' ) ; } catch ( \ InvalidArgumentException $ e ) { $ config [ 'handler' ] -> push ( $ authenticationHandler , 'authentication' ) ; } return $ config ; } | Set the Authentication Handler |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.