idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
13,800 | public function getCurrentUserPrincipals ( ) { $ currentUser = $ this -> getCurrentUserPrincipal ( ) ; if ( is_null ( $ currentUser ) ) { return [ ] ; } return array_merge ( [ $ currentUser ] , $ this -> getPrincipalMembership ( $ currentUser ) ) ; } | Returns a list of principals that s associated to the current user either directly or through group membership . |
13,801 | public function getPrincipalMembership ( $ mainPrincipal ) { if ( isset ( $ this -> principalMembershipCache [ $ mainPrincipal ] ) ) { return $ this -> principalMembershipCache [ $ mainPrincipal ] ; } $ check = [ $ mainPrincipal ] ; $ principals = [ ] ; while ( count ( $ check ) ) { $ principal = array_shift ( $ check ) ; $ node = $ this -> server -> tree -> getNodeForPath ( $ principal ) ; if ( $ node instanceof IPrincipal ) { foreach ( $ node -> getGroupMembership ( ) as $ groupMember ) { if ( ! in_array ( $ groupMember , $ principals ) ) { $ check [ ] = $ groupMember ; $ principals [ ] = $ groupMember ; } } } } $ this -> principalMembershipCache [ $ mainPrincipal ] = $ principals ; return $ principals ; } | Returns all the principal groups the specified principal is a member of . |
13,802 | public function principalMatchesPrincipal ( $ checkPrincipal , $ currentPrincipal = null ) { if ( is_null ( $ currentPrincipal ) ) { $ currentPrincipal = $ this -> getCurrentUserPrincipal ( ) ; } if ( $ currentPrincipal === $ checkPrincipal ) { return true ; } if ( is_null ( $ currentPrincipal ) ) { return false ; } return in_array ( $ checkPrincipal , $ this -> getPrincipalMembership ( $ currentPrincipal ) ) ; } | Find out of a principal equals another principal . |
13,803 | public function getSupportedPrivilegeSet ( $ node ) { if ( is_string ( $ node ) ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ node ) ; } $ supportedPrivileges = null ; if ( $ node instanceof IACL ) { $ supportedPrivileges = $ node -> getSupportedPrivilegeSet ( ) ; } if ( is_null ( $ supportedPrivileges ) ) { $ supportedPrivileges = [ '{DAV:}read' => [ 'abstract' => false , 'aggregates' => [ '{DAV:}read-acl' => [ 'abstract' => false , 'aggregates' => [ ] , ] , '{DAV:}read-current-user-privilege-set' => [ 'abstract' => false , 'aggregates' => [ ] , ] , ] , ] , '{DAV:}write' => [ 'abstract' => false , 'aggregates' => [ '{DAV:}write-properties' => [ 'abstract' => false , 'aggregates' => [ ] , ] , '{DAV:}write-content' => [ 'abstract' => false , 'aggregates' => [ ] , ] , '{DAV:}unlock' => [ 'abstract' => false , 'aggregates' => [ ] , ] , ] , ] , ] ; if ( $ node instanceof DAV \ ICollection ) { $ supportedPrivileges [ '{DAV:}write' ] [ 'aggregates' ] [ '{DAV:}bind' ] = [ 'abstract' => false , 'aggregates' => [ ] , ] ; $ supportedPrivileges [ '{DAV:}write' ] [ 'aggregates' ] [ '{DAV:}unbind' ] = [ 'abstract' => false , 'aggregates' => [ ] , ] ; } if ( $ node instanceof IACL ) { $ supportedPrivileges [ '{DAV:}write' ] [ 'aggregates' ] [ '{DAV:}write-acl' ] = [ 'abstract' => false , 'aggregates' => [ ] , ] ; } } $ this -> server -> emit ( 'getSupportedPrivilegeSet' , [ $ node , & $ supportedPrivileges ] ) ; return $ supportedPrivileges ; } | Returns a tree of supported privileges for a resource . |
13,804 | final public function getFlatPrivilegeSet ( $ node ) { $ privs = [ 'abstract' => false , 'aggregates' => $ this -> getSupportedPrivilegeSet ( $ node ) , ] ; $ fpsTraverse = null ; $ fpsTraverse = function ( $ privName , $ privInfo , $ concrete , & $ flat ) use ( & $ fpsTraverse ) { $ myPriv = [ 'privilege' => $ privName , 'abstract' => isset ( $ privInfo [ 'abstract' ] ) && $ privInfo [ 'abstract' ] , 'aggregates' => [ ] , 'concrete' => isset ( $ privInfo [ 'abstract' ] ) && $ privInfo [ 'abstract' ] ? $ concrete : $ privName , ] ; if ( isset ( $ privInfo [ 'aggregates' ] ) ) { foreach ( $ privInfo [ 'aggregates' ] as $ subPrivName => $ subPrivInfo ) { $ myPriv [ 'aggregates' ] [ ] = $ subPrivName ; } } $ flat [ $ privName ] = $ myPriv ; if ( isset ( $ privInfo [ 'aggregates' ] ) ) { foreach ( $ privInfo [ 'aggregates' ] as $ subPrivName => $ subPrivInfo ) { $ fpsTraverse ( $ subPrivName , $ subPrivInfo , $ myPriv [ 'concrete' ] , $ flat ) ; } } } ; $ flat = [ ] ; $ fpsTraverse ( '{DAV:}all' , $ privs , null , $ flat ) ; return $ flat ; } | Returns the supported privilege set as a flat list . |
13,805 | public function getAcl ( $ node ) { if ( is_string ( $ node ) ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ node ) ; } if ( ! $ node instanceof IACL ) { return $ this -> getDefaultAcl ( ) ; } $ acl = $ node -> getACL ( ) ; foreach ( $ this -> adminPrincipals as $ adminPrincipal ) { $ acl [ ] = [ 'principal' => $ adminPrincipal , 'privilege' => '{DAV:}all' , 'protected' => true , ] ; } return $ acl ; } | Returns the full ACL list . |
13,806 | public function getCurrentUserPrivilegeSet ( $ node ) { if ( is_string ( $ node ) ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ node ) ; } $ acl = $ this -> getACL ( $ node ) ; $ collected = [ ] ; $ isAuthenticated = null !== $ this -> getCurrentUserPrincipal ( ) ; foreach ( $ acl as $ ace ) { $ principal = $ ace [ 'principal' ] ; switch ( $ principal ) { case '{DAV:}owner' : $ owner = $ node -> getOwner ( ) ; if ( $ owner && $ this -> principalMatchesPrincipal ( $ owner ) ) { $ collected [ ] = $ ace ; } break ; case '{DAV:}all' : $ collected [ ] = $ ace ; break ; case '{DAV:}authenticated' : if ( $ isAuthenticated ) { $ collected [ ] = $ ace ; } break ; case '{DAV:}unauthenticated' : if ( ! $ isAuthenticated ) { $ collected [ ] = $ ace ; } break ; default : if ( $ this -> principalMatchesPrincipal ( $ ace [ 'principal' ] ) ) { $ collected [ ] = $ ace ; } break ; } } $ flat = $ this -> getFlatPrivilegeSet ( $ node ) ; $ collected2 = [ ] ; while ( count ( $ collected ) ) { $ current = array_pop ( $ collected ) ; $ collected2 [ ] = $ current [ 'privilege' ] ; if ( ! isset ( $ flat [ $ current [ 'privilege' ] ] ) ) { $ this -> server -> getLogger ( ) -> debug ( 'A node has the "' . $ current [ 'privilege' ] . '" in its ACL list, but this privilege was not reported in the supportedPrivilegeSet list. This will be ignored.' ) ; continue ; } foreach ( $ flat [ $ current [ 'privilege' ] ] [ 'aggregates' ] as $ subPriv ) { $ collected2 [ ] = $ subPriv ; $ collected [ ] = $ flat [ $ subPriv ] ; } } return array_values ( array_unique ( $ collected2 ) ) ; } | Returns a list of privileges the current user has on a particular node . |
13,807 | public function getPrincipalByUri ( $ uri ) { $ result = null ; $ collections = $ this -> principalCollectionSet ; foreach ( $ collections as $ collection ) { try { $ principalCollection = $ this -> server -> tree -> getNodeForPath ( $ collection ) ; } catch ( NotFound $ e ) { continue ; } if ( ! $ principalCollection instanceof IPrincipalCollection ) { continue ; } $ result = $ principalCollection -> findByUri ( $ uri ) ; if ( $ result ) { return $ result ; } } } | Returns a principal based on its uri . |
13,808 | public function principalSearch ( array $ searchProperties , array $ requestedProperties , $ collectionUri = null , $ test = 'allof' ) { if ( ! is_null ( $ collectionUri ) ) { $ uris = [ $ collectionUri ] ; } else { $ uris = $ this -> principalCollectionSet ; } $ lookupResults = [ ] ; foreach ( $ uris as $ uri ) { $ principalCollection = $ this -> server -> tree -> getNodeForPath ( $ uri ) ; if ( ! $ principalCollection instanceof IPrincipalCollection ) { continue ; } $ results = $ principalCollection -> searchPrincipals ( $ searchProperties , $ test ) ; foreach ( $ results as $ result ) { $ lookupResults [ ] = rtrim ( $ uri , '/' ) . '/' . $ result ; } } $ matches = [ ] ; foreach ( $ lookupResults as $ lookupResult ) { list ( $ matches [ ] ) = $ this -> server -> getPropertiesForPath ( $ lookupResult , $ requestedProperties , 0 ) ; } return $ matches ; } | Principal property search . |
13,809 | public function beforeMethod ( RequestInterface $ request , ResponseInterface $ response ) { $ method = $ request -> getMethod ( ) ; $ path = $ request -> getPath ( ) ; $ exists = $ this -> server -> tree -> nodeExists ( $ path ) ; if ( ! $ exists ) { return ; } switch ( $ method ) { case 'GET' : case 'HEAD' : case 'OPTIONS' : $ this -> checkPrivileges ( $ path , '{DAV:}read' ) ; break ; case 'PUT' : case 'LOCK' : $ this -> checkPrivileges ( $ path , '{DAV:}write-content' ) ; break ; case 'UNLOCK' : break ; case 'PROPPATCH' : $ this -> checkPrivileges ( $ path , '{DAV:}write-properties' ) ; break ; case 'ACL' : $ this -> checkPrivileges ( $ path , '{DAV:}write-acl' ) ; break ; case 'COPY' : case 'MOVE' : $ this -> checkPrivileges ( $ path , '{DAV:}read' , self :: R_RECURSIVE ) ; break ; } } | Triggered before any method is handled . |
13,810 | public function beforeBind ( $ uri ) { list ( $ parentUri ) = Uri \ split ( $ uri ) ; $ this -> checkPrivileges ( $ parentUri , '{DAV:}bind' ) ; } | Triggered before a new node is created . |
13,811 | public function beforeUnbind ( $ uri ) { list ( $ parentUri ) = Uri \ split ( $ uri ) ; $ this -> checkPrivileges ( $ parentUri , '{DAV:}unbind' , self :: R_RECURSIVEPARENTS ) ; } | Triggered before a node is deleted . |
13,812 | public function propPatch ( $ path , DAV \ PropPatch $ propPatch ) { $ propPatch -> handle ( '{DAV:}group-member-set' , function ( $ value ) use ( $ path ) { if ( is_null ( $ value ) ) { $ memberSet = [ ] ; } elseif ( $ value instanceof Href ) { $ memberSet = array_map ( [ $ this -> server , 'calculateUri' ] , $ value -> getHrefs ( ) ) ; } else { throw new DAV \ Exception ( 'The group-member-set property MUST be an instance of Sabre\DAV\Property\HrefList or null' ) ; } $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; if ( ! ( $ node instanceof IPrincipal ) ) { return false ; } $ node -> setGroupMemberSet ( $ memberSet ) ; $ this -> principalMembershipCache = [ ] ; return true ; } ) ; } | This method intercepts PROPPATCH methods and make sure the group - member - set is updated correctly . |
13,813 | public function report ( $ reportName , $ report , $ path ) { switch ( $ reportName ) { case '{DAV:}principal-property-search' : $ this -> server -> transactionType = 'report-principal-property-search' ; $ this -> principalPropertySearchReport ( $ path , $ report ) ; return false ; case '{DAV:}principal-search-property-set' : $ this -> server -> transactionType = 'report-principal-search-property-set' ; $ this -> principalSearchPropertySetReport ( $ path , $ report ) ; return false ; case '{DAV:}expand-property' : $ this -> server -> transactionType = 'report-expand-property' ; $ this -> expandPropertyReport ( $ path , $ report ) ; return false ; case '{DAV:}principal-match' : $ this -> server -> transactionType = 'report-principal-match' ; $ this -> principalMatchReport ( $ path , $ report ) ; return false ; case '{DAV:}acl-principal-prop-set' : $ this -> server -> transactionType = 'acl-principal-prop-set' ; $ this -> aclPrincipalPropSetReport ( $ path , $ report ) ; return false ; } } | This method handles HTTP REPORT requests . |
13,814 | protected function principalMatchReport ( $ path , Xml \ Request \ PrincipalMatchReport $ report ) { $ depth = $ this -> server -> getHTTPDepth ( 0 ) ; if ( 0 !== $ depth ) { throw new BadRequest ( 'The principal-match report is only defined on Depth: 0' ) ; } $ currentPrincipals = $ this -> getCurrentUserPrincipals ( ) ; $ result = [ ] ; if ( Xml \ Request \ PrincipalMatchReport :: SELF === $ report -> type ) { foreach ( $ currentPrincipals as $ currentPrincipal ) { if ( $ currentPrincipal === $ path || 0 === strpos ( $ currentPrincipal , $ path . '/' ) ) { $ result [ ] = $ currentPrincipal ; } } } else { $ candidates = $ this -> server -> getPropertiesForPath ( $ path , [ $ report -> principalProperty ] , 1 ) ; foreach ( $ candidates as $ candidate ) { if ( ! isset ( $ candidate [ 200 ] [ $ report -> principalProperty ] ) ) { continue ; } $ hrefs = $ candidate [ 200 ] [ $ report -> principalProperty ] ; if ( ! $ hrefs instanceof Href ) { continue ; } foreach ( $ hrefs -> getHrefs ( ) as $ href ) { if ( in_array ( trim ( $ href , '/' ) , $ currentPrincipals ) ) { $ result [ ] = $ candidate [ 'href' ] ; continue 2 ; } } } } $ responses = [ ] ; foreach ( $ result as $ item ) { $ properties = [ ] ; if ( $ report -> properties ) { $ foo = $ this -> server -> getPropertiesForPath ( $ item , $ report -> properties ) ; $ foo = $ foo [ 0 ] ; $ item = $ foo [ 'href' ] ; unset ( $ foo [ 'href' ] ) ; $ properties = $ foo ; } $ responses [ ] = new DAV \ Xml \ Element \ Response ( $ item , $ properties , '200' ) ; } $ this -> server -> httpResponse -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ this -> server -> httpResponse -> setStatus ( 207 ) ; $ this -> server -> httpResponse -> setBody ( $ this -> server -> xml -> write ( '{DAV:}multistatus' , $ responses , $ this -> server -> getBaseUri ( ) ) ) ; } | The principal - match report is defined in RFC3744 section 9 . 3 . |
13,815 | protected function expandPropertyReport ( $ path , $ report ) { $ depth = $ this -> server -> getHTTPDepth ( 0 ) ; $ result = $ this -> expandProperties ( $ path , $ report -> properties , $ depth ) ; $ xml = $ this -> server -> xml -> write ( '{DAV:}multistatus' , new DAV \ Xml \ Response \ MultiStatus ( $ result ) , $ this -> server -> getBaseUri ( ) ) ; $ this -> server -> httpResponse -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ this -> server -> httpResponse -> setStatus ( 207 ) ; $ this -> server -> httpResponse -> setBody ( $ xml ) ; } | The expand - property report is defined in RFC3253 section 3 . 8 . |
13,816 | protected function expandProperties ( $ path , array $ requestedProperties , $ depth ) { $ foundProperties = $ this -> server -> getPropertiesForPath ( $ path , array_keys ( $ requestedProperties ) , $ depth ) ; $ result = [ ] ; foreach ( $ foundProperties as $ node ) { foreach ( $ requestedProperties as $ propertyName => $ childRequestedProperties ) { if ( ! is_array ( $ childRequestedProperties ) || 0 === count ( $ childRequestedProperties ) ) { continue ; } if ( ! array_key_exists ( $ propertyName , $ node [ 200 ] ) ) { continue ; } if ( ! $ node [ 200 ] [ $ propertyName ] instanceof DAV \ Xml \ Property \ Href ) { continue ; } $ childHrefs = $ node [ 200 ] [ $ propertyName ] -> getHrefs ( ) ; $ childProps = [ ] ; foreach ( $ childHrefs as $ href ) { $ childProps [ ] = [ 'name' => '{DAV:}response' , 'value' => $ this -> expandProperties ( $ href , $ childRequestedProperties , 0 ) [ 0 ] , ] ; } $ node [ 200 ] [ $ propertyName ] = $ childProps ; } $ result [ ] = new DAV \ Xml \ Element \ Response ( $ node [ 'href' ] , $ node ) ; } return $ result ; } | This method expands all the properties and returns a list with property values . |
13,817 | protected function aclPrincipalPropSetReport ( $ path , Xml \ Request \ AclPrincipalPropSetReport $ report ) { if ( 0 !== $ this -> server -> getHTTPDepth ( 0 ) ) { throw new BadRequest ( 'The {DAV:}acl-principal-prop-set REPORT only supports Depth 0' ) ; } $ acl = $ this -> server -> getProperties ( $ path , '{DAV:}acl' ) ; if ( ! $ acl || ! isset ( $ acl [ '{DAV:}acl' ] ) ) { throw new Forbidden ( 'Could not fetch ACL rules for this path' ) ; } $ principals = [ ] ; foreach ( $ acl [ '{DAV:}acl' ] -> getPrivileges ( ) as $ ace ) { if ( '{' === $ ace [ 'principal' ] [ 0 ] ) { continue ; } $ principals [ ] = $ ace [ 'principal' ] ; } $ properties = $ this -> server -> getPropertiesForMultiplePaths ( $ principals , $ report -> properties ) ; $ this -> server -> httpResponse -> setStatus ( 207 ) ; $ this -> server -> httpResponse -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ this -> server -> httpResponse -> setBody ( $ this -> server -> generateMultiStatus ( $ properties ) ) ; } | aclPrincipalPropSet REPORT . |
13,818 | public function getHTTPHeaders ( \ Sabre \ DAV \ Server $ server ) { $ methods = $ server -> getAllowedMethods ( $ server -> getRequestUri ( ) ) ; return [ 'Allow' => strtoupper ( implode ( ', ' , $ methods ) ) , ] ; } | This method allows the exception to return any extra HTTP response headers . |
13,819 | public function propFind ( PropFind $ propFind , INode $ node ) { $ path = $ propFind -> getPath ( ) ; $ pathFilter = $ this -> pathFilter ; if ( $ pathFilter && ! $ pathFilter ( $ path ) ) { return ; } $ this -> backend -> propFind ( $ propFind -> getPath ( ) , $ propFind ) ; } | Called during PROPFIND operations . |
13,820 | public function propPatch ( $ path , PropPatch $ propPatch ) { $ pathFilter = $ this -> pathFilter ; if ( $ pathFilter && ! $ pathFilter ( $ path ) ) { return ; } $ this -> backend -> propPatch ( $ path , $ propPatch ) ; } | Called during PROPPATCH operations . |
13,821 | public function afterUnbind ( $ path ) { $ pathFilter = $ this -> pathFilter ; if ( $ pathFilter && ! $ pathFilter ( $ path ) ) { return ; } $ this -> backend -> delete ( $ path ) ; } | Called after a node is deleted . |
13,822 | public function afterMove ( $ source , $ destination ) { $ pathFilter = $ this -> pathFilter ; if ( $ pathFilter && ! $ pathFilter ( $ source ) ) { return ; } if ( $ pathFilter && ! $ pathFilter ( $ destination ) ) { return ; } $ this -> backend -> move ( $ source , $ destination ) ; } | Called after a node is moved . |
13,823 | public function getProperties ( $ requestedProperties ) { $ response = [ ] ; foreach ( $ this -> calendarInfo as $ propName => $ propValue ) { if ( ! is_null ( $ propValue ) && '{' === $ propName [ 0 ] ) { $ response [ $ propName ] = $ this -> calendarInfo [ $ propName ] ; } } return $ response ; } | Returns the list of properties . |
13,824 | public function getChild ( $ name ) { $ obj = $ this -> caldavBackend -> getCalendarObject ( $ this -> calendarInfo [ 'id' ] , $ name ) ; if ( ! $ obj ) { throw new DAV \ Exception \ NotFound ( 'Calendar object not found' ) ; } $ obj [ 'acl' ] = $ this -> getChildACL ( ) ; return new CalendarObject ( $ this -> caldavBackend , $ this -> calendarInfo , $ obj ) ; } | Returns a calendar object . |
13,825 | public function getChildren ( ) { $ objs = $ this -> caldavBackend -> getCalendarObjects ( $ this -> calendarInfo [ 'id' ] ) ; $ children = [ ] ; foreach ( $ objs as $ obj ) { $ obj [ 'acl' ] = $ this -> getChildACL ( ) ; $ children [ ] = new CalendarObject ( $ this -> caldavBackend , $ this -> calendarInfo , $ obj ) ; } return $ children ; } | Returns the full list of calendar objects . |
13,826 | public function childExists ( $ name ) { $ obj = $ this -> caldavBackend -> getCalendarObject ( $ this -> calendarInfo [ 'id' ] , $ name ) ; if ( ! $ obj ) { return false ; } else { return true ; } } | Checks if a child - node exists . |
13,827 | protected function imapOpen ( $ username , $ password ) { $ success = false ; try { $ imap = imap_open ( $ this -> mailbox , $ username , $ password , OP_HALFOPEN | OP_READONLY , 1 ) ; if ( $ imap ) { $ success = true ; } } catch ( \ ErrorException $ e ) { error_log ( $ e -> getMessage ( ) ) ; } $ errors = imap_errors ( ) ; if ( $ errors ) { foreach ( $ errors as $ error ) { error_log ( $ error ) ; } } if ( isset ( $ imap ) && $ imap ) { imap_close ( $ imap ) ; } return $ success ; } | Connects to an IMAP server and tries to authenticate . |
13,828 | public static function getUUID ( ) { return sprintf ( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0x0fff ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) ) ; } | Returns a pseudo - random v4 UUID . |
13,829 | public function initialize ( DAV \ Server $ server ) { $ this -> server = $ server ; $ this -> server -> on ( 'method:GET' , [ $ this , 'httpGet' ] , 90 ) ; $ server -> on ( 'browserButtonActions' , function ( $ path , $ node , & $ actions ) { if ( $ node instanceof IAddressBook ) { $ actions .= '<a href="' . htmlspecialchars ( $ path , ENT_QUOTES , 'UTF-8' ) . '?export"><span class="oi" data-glyph="book"></span></a>' ; } } ) ; } | Initializes the plugin and registers event handlers . |
13,830 | public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ queryParams = $ request -> getQueryParameters ( ) ; if ( ! array_key_exists ( 'export' , $ queryParams ) ) { return ; } $ path = $ request -> getPath ( ) ; $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; if ( ! ( $ node instanceof IAddressBook ) ) { return ; } $ this -> server -> transactionType = 'get-addressbook-export' ; if ( $ aclPlugin = $ this -> server -> getPlugin ( 'acl' ) ) { $ aclPlugin -> checkPrivileges ( $ path , '{DAV:}read' ) ; } $ nodes = $ this -> server -> getPropertiesForPath ( $ path , [ '{' . Plugin :: NS_CARDDAV . '}address-data' , ] , 1 ) ; $ format = 'text/directory' ; $ output = null ; $ filenameExtension = null ; switch ( $ format ) { case 'text/directory' : $ output = $ this -> generateVCF ( $ nodes ) ; $ filenameExtension = '.vcf' ; break ; } $ filename = preg_replace ( '/[^a-zA-Z0-9-_ ]/um' , '' , $ node -> getName ( ) ) ; $ filename .= '-' . date ( 'Y-m-d' ) . $ filenameExtension ; $ response -> setHeader ( 'Content-Disposition' , 'attachment; filename="' . $ filename . '"' ) ; $ response -> setHeader ( 'Content-Type' , $ format ) ; $ response -> setStatus ( 200 ) ; $ response -> setBody ( $ output ) ; return false ; } | Intercepts GET requests on addressbook urls ending with ?export . |
13,831 | public function generateVCF ( array $ nodes ) { $ output = '' ; foreach ( $ nodes as $ node ) { if ( ! isset ( $ node [ 200 ] [ '{' . Plugin :: NS_CARDDAV . '}address-data' ] ) ) { continue ; } $ nodeData = $ node [ 200 ] [ '{' . Plugin :: NS_CARDDAV . '}address-data' ] ; $ vcard = VObject \ Reader :: read ( $ nodeData ) ; $ output .= $ vcard -> serialize ( ) ; $ vcard -> destroy ( ) ; } return $ output ; } | Merges all vcard objects and builds one big vcf export . |
13,832 | public function propFind ( PropFind $ propFind , INode $ node ) { $ props = [ '{http://calendarserver.org/ns/}subscribed-strip-alarms' , '{http://calendarserver.org/ns/}subscribed-strip-attachments' , '{http://calendarserver.org/ns/}subscribed-strip-todos' , ] ; foreach ( $ props as $ prop ) { if ( 200 === $ propFind -> getStatus ( $ prop ) ) { $ propFind -> set ( $ prop , '' , 200 ) ; } } } | Triggered after properties have been fetched . |
13,833 | public function httpPost ( RequestInterface $ request , ResponseInterface $ response ) { $ contentType = $ request -> getHeader ( 'Content-Type' ) ; if ( ! $ contentType || 0 !== strpos ( $ contentType , 'text/calendar' ) ) { return ; } $ path = $ request -> getPath ( ) ; try { $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; } catch ( NotFound $ e ) { return ; } if ( ! $ node instanceof IOutbox ) { return ; } $ this -> server -> transactionType = 'post-caldav-outbox' ; $ this -> outboxRequest ( $ node , $ request , $ response ) ; return false ; } | This method handles POST request for the outbox . |
13,834 | public function calendarObjectChange ( RequestInterface $ request , ResponseInterface $ response , VCalendar $ vCal , $ calendarPath , & $ modified , $ isNew ) { if ( ! $ this -> scheduleReply ( $ this -> server -> httpRequest ) ) { return ; } $ calendarNode = $ this -> server -> tree -> getNodeForPath ( $ calendarPath ) ; $ addresses = $ this -> getAddressesForPrincipal ( $ calendarNode -> getOwner ( ) ) ; if ( ! $ isNew ) { $ node = $ this -> server -> tree -> getNodeForPath ( $ request -> getPath ( ) ) ; $ oldObj = Reader :: read ( $ node -> get ( ) ) ; } else { $ oldObj = null ; } $ this -> processICalendarChange ( $ oldObj , $ vCal , $ addresses , [ ] , $ modified ) ; if ( $ oldObj ) { $ oldObj -> destroy ( ) ; } } | This method is triggered whenever there was a calendar object gets created or updated . |
13,835 | public function deliver ( ITip \ Message $ iTipMessage ) { $ this -> server -> emit ( 'schedule' , [ $ iTipMessage ] ) ; if ( ! $ iTipMessage -> scheduleStatus ) { $ iTipMessage -> scheduleStatus = '5.2;There was no system capable of delivering the scheduling message' ; } list ( $ baseCode ) = explode ( '.' , $ iTipMessage -> scheduleStatus ) ; if ( ! $ iTipMessage -> significantChange && in_array ( $ baseCode , [ '3' , '5' ] ) ) { $ iTipMessage -> scheduleStatus = null ; } } | This method is responsible for delivering the ITip message . |
13,836 | public function beforeUnbind ( $ path ) { if ( 'MOVE' === $ this -> server -> httpRequest -> getMethod ( ) ) { return ; } $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; if ( ! $ node instanceof ICalendarObject || $ node instanceof ISchedulingObject ) { return ; } if ( ! $ this -> scheduleReply ( $ this -> server -> httpRequest ) ) { return ; } $ addresses = $ this -> getAddressesForPrincipal ( $ node -> getOwner ( ) ) ; $ broker = new ITip \ Broker ( ) ; $ messages = $ broker -> parseEvent ( null , $ addresses , $ node -> get ( ) ) ; foreach ( $ messages as $ message ) { $ this -> deliver ( $ message ) ; } } | This method is triggered before a file gets deleted . |
13,837 | public function getSupportedPrivilegeSet ( INode $ node , array & $ supportedPrivilegeSet ) { $ ns = '{' . self :: NS_CALDAV . '}' ; if ( $ node instanceof IOutbox ) { $ supportedPrivilegeSet [ $ ns . 'schedule-send' ] = [ 'abstract' => false , 'aggregates' => [ $ ns . 'schedule-send-invite' => [ 'abstract' => false , 'aggregates' => [ ] , ] , $ ns . 'schedule-send-reply' => [ 'abstract' => false , 'aggregates' => [ ] , ] , $ ns . 'schedule-send-freebusy' => [ 'abstract' => false , 'aggregates' => [ ] , ] , $ ns . 'schedule-post-vevent' => [ 'abstract' => false , 'aggregates' => [ ] , ] , ] , ] ; } if ( $ node instanceof IInbox ) { $ supportedPrivilegeSet [ $ ns . 'schedule-deliver' ] = [ 'abstract' => false , 'aggregates' => [ $ ns . 'schedule-deliver-invite' => [ 'abstract' => false , 'aggregates' => [ ] , ] , $ ns . 'schedule-deliver-reply' => [ 'abstract' => false , 'aggregates' => [ ] , ] , $ ns . 'schedule-query-freebusy' => [ 'abstract' => false , 'aggregates' => [ ] , ] , ] , ] ; } } | This method is triggered whenever a subsystem requests the privileges that are supported on a particular node . |
13,838 | protected function processICalendarChange ( $ oldObject = null , VCalendar $ newObject , array $ addresses , array $ ignore = [ ] , & $ modified = false ) { $ broker = new ITip \ Broker ( ) ; $ messages = $ broker -> parseEvent ( $ newObject , $ addresses , $ oldObject ) ; if ( $ messages ) { $ modified = true ; } foreach ( $ messages as $ message ) { if ( in_array ( $ message -> recipient , $ ignore ) ) { continue ; } $ this -> deliver ( $ message ) ; if ( isset ( $ newObject -> VEVENT -> ORGANIZER ) && ( $ newObject -> VEVENT -> ORGANIZER -> getNormalizedValue ( ) === $ message -> recipient ) ) { if ( $ message -> scheduleStatus ) { $ newObject -> VEVENT -> ORGANIZER [ 'SCHEDULE-STATUS' ] = $ message -> getScheduleStatus ( ) ; } unset ( $ newObject -> VEVENT -> ORGANIZER [ 'SCHEDULE-FORCE-SEND' ] ) ; } else { if ( isset ( $ newObject -> VEVENT -> ATTENDEE ) ) { foreach ( $ newObject -> VEVENT -> ATTENDEE as $ attendee ) { if ( $ attendee -> getNormalizedValue ( ) === $ message -> recipient ) { if ( $ message -> scheduleStatus ) { $ attendee [ 'SCHEDULE-STATUS' ] = $ message -> getScheduleStatus ( ) ; } unset ( $ attendee [ 'SCHEDULE-FORCE-SEND' ] ) ; break ; } } } } } } | This method looks at an old iCalendar object a new iCalendar object and starts sending scheduling messages based on the changes . |
13,839 | protected function getAddressesForPrincipal ( $ principal ) { $ CUAS = '{' . self :: NS_CALDAV . '}calendar-user-address-set' ; $ properties = $ this -> server -> getProperties ( $ principal , [ $ CUAS ] ) ; if ( ! isset ( $ properties [ $ CUAS ] ) ) { return [ ] ; } $ addresses = $ properties [ $ CUAS ] -> getHrefs ( ) ; return $ addresses ; } | Returns a list of addresses that are associated with a principal . |
13,840 | public function outboxRequest ( IOutbox $ outboxNode , RequestInterface $ request , ResponseInterface $ response ) { $ outboxPath = $ request -> getPath ( ) ; try { $ vObject = VObject \ Reader :: read ( $ request -> getBody ( ) ) ; } catch ( VObject \ ParseException $ e ) { throw new BadRequest ( 'The request body must be a valid iCalendar object. Parse error: ' . $ e -> getMessage ( ) ) ; } $ componentType = null ; foreach ( $ vObject -> getComponents ( ) as $ component ) { if ( 'VTIMEZONE' !== $ component -> name ) { $ componentType = $ component -> name ; break ; } } if ( is_null ( $ componentType ) ) { throw new BadRequest ( 'We expected at least one VTODO, VJOURNAL, VFREEBUSY or VEVENT component' ) ; } $ method = strtoupper ( ( string ) $ vObject -> METHOD ) ; if ( ! $ method ) { throw new BadRequest ( 'A METHOD property must be specified in iTIP messages' ) ; } $ acl = $ this -> server -> getPlugin ( 'acl' ) ; if ( 'VFREEBUSY' === $ componentType && 'REQUEST' === $ method ) { $ acl && $ acl -> checkPrivileges ( $ outboxPath , '{' . self :: NS_CALDAV . '}schedule-send-freebusy' ) ; $ this -> handleFreeBusyRequest ( $ outboxNode , $ vObject , $ request , $ response ) ; $ vObject -> destroy ( ) ; unset ( $ vObject ) ; } else { throw new NotImplemented ( 'We only support VFREEBUSY (REQUEST) on this endpoint' ) ; } } | This method handles POST requests to the schedule - outbox . |
13,841 | public function getStatus ( $ propertyName ) { return isset ( $ this -> result [ $ propertyName ] ) ? $ this -> result [ $ propertyName ] [ 0 ] : null ; } | Returns the current status code for a property name . |
13,842 | public function getResultForMultiStatus ( ) { $ r = [ 200 => [ ] , 404 => [ ] , ] ; foreach ( $ this -> result as $ propertyName => $ info ) { if ( ! isset ( $ r [ $ info [ 0 ] ] ) ) { $ r [ $ info [ 0 ] ] = [ $ propertyName => $ info [ 1 ] ] ; } else { $ r [ $ info [ 0 ] ] [ $ propertyName ] = $ info [ 1 ] ; } } if ( self :: ALLPROPS === $ this -> requestType ) { unset ( $ r [ 404 ] ) ; } return $ r ; } | Returns a result array that s often used in multistatus responses . |
13,843 | public function httpPatch ( RequestInterface $ request , ResponseInterface $ response ) { $ path = $ request -> getPath ( ) ; $ node = $ this -> server -> tree -> getNodeForPath ( $ path ) ; if ( ! $ node instanceof IPatchSupport ) { throw new DAV \ Exception \ MethodNotAllowed ( 'The target resource does not support the PATCH method.' ) ; } $ range = $ this -> getHTTPUpdateRange ( $ request ) ; if ( ! $ range ) { throw new DAV \ Exception \ BadRequest ( 'No valid "X-Update-Range" found in the headers' ) ; } $ contentType = strtolower ( ( string ) $ request -> getHeader ( 'Content-Type' ) ) ; if ( 'application/x-sabredav-partialupdate' != $ contentType ) { throw new DAV \ Exception \ UnsupportedMediaType ( 'Unknown Content-Type header "' . $ contentType . '"' ) ; } $ len = $ this -> server -> httpRequest -> getHeader ( 'Content-Length' ) ; if ( ! $ len ) { throw new DAV \ Exception \ LengthRequired ( 'A Content-Length header is required' ) ; } switch ( $ range [ 0 ] ) { case self :: RANGE_START : if ( ! $ range [ 2 ] ) { $ range [ 2 ] = $ range [ 1 ] + $ len - 1 ; } else { if ( $ range [ 2 ] < $ range [ 1 ] ) { throw new DAV \ Exception \ RequestedRangeNotSatisfiable ( 'The end offset (' . $ range [ 2 ] . ') is lower than the start offset (' . $ range [ 1 ] . ')' ) ; } if ( $ range [ 2 ] - $ range [ 1 ] + 1 != $ len ) { throw new DAV \ Exception \ RequestedRangeNotSatisfiable ( 'Actual data length (' . $ len . ') is not consistent with begin (' . $ range [ 1 ] . ') and end (' . $ range [ 2 ] . ') offsets' ) ; } } break ; } if ( ! $ this -> server -> emit ( 'beforeWriteContent' , [ $ path , $ node , null ] ) ) { return ; } $ body = $ this -> server -> httpRequest -> getBody ( ) ; $ etag = $ node -> patch ( $ body , $ range [ 0 ] , isset ( $ range [ 1 ] ) ? $ range [ 1 ] : null ) ; $ this -> server -> emit ( 'afterWriteContent' , [ $ path , $ node ] ) ; $ response -> setHeader ( 'Content-Length' , '0' ) ; if ( $ etag ) { $ response -> setHeader ( 'ETag' , $ etag ) ; } $ response -> setStatus ( 204 ) ; return false ; } | Patch an uri . |
13,844 | public function getHTTPUpdateRange ( RequestInterface $ request ) { $ range = $ request -> getHeader ( 'X-Update-Range' ) ; if ( is_null ( $ range ) ) { return null ; } if ( ! preg_match ( '/^(append)|(?:bytes=([0-9]+)-([0-9]*))|(?:bytes=(-[0-9]+))$/i' , $ range , $ matches ) ) { return null ; } if ( 'append' === $ matches [ 1 ] ) { return [ self :: RANGE_APPEND ] ; } elseif ( strlen ( $ matches [ 2 ] ) > 0 ) { return [ self :: RANGE_START , ( int ) $ matches [ 2 ] , ( int ) $ matches [ 3 ] ? : null ] ; } else { return [ self :: RANGE_END , ( int ) $ matches [ 4 ] ] ; } } | Returns the HTTP custom range update header . |
13,845 | public function render ( ? Formatter $ formatter = null ) : string { if ( $ formatter === null ) { $ formatter = new PassthroughFormatter ( ) ; } $ tags = [ ] ; foreach ( $ this -> tags as $ tag ) { $ tags [ ] = '{' . $ formatter -> format ( $ tag ) . '}' ; } return vsprintf ( $ this -> bodyTemplate , $ tags ) ; } | Renders this description as a string where the provided formatter will format the tags in the expected string format . |
13,846 | public static function create ( string $ body , DescriptionFactory $ descriptionFactory = null , Context $ context = null ) : MyTag { Assert :: notNull ( $ descriptionFactory ) ; return new static ( $ descriptionFactory -> create ( $ body , $ context ) ) ; } | A static Factory that creates a new instance of the current Tag . |
13,847 | public function getTagsByName ( string $ name ) : array { $ result = [ ] ; foreach ( $ this -> getTags ( ) as $ tag ) { if ( $ tag -> getName ( ) !== $ name ) { continue ; } $ result [ ] = $ tag ; } return $ result ; } | Returns an array of tags matching the given name . If no tags are found an empty array is returned . |
13,848 | public function hasTag ( string $ name ) : bool { foreach ( $ this -> getTags ( ) as $ tag ) { if ( $ tag -> getName ( ) === $ name ) { return true ; } } return false ; } | Checks if a tag of a certain type is present in this DocBlock . |
13,849 | public function removeTag ( Tag $ tagToRemove ) : void { foreach ( $ this -> tags as $ key => $ tag ) { if ( $ tag === $ tagToRemove ) { unset ( $ this -> tags [ $ key ] ) ; break ; } } } | Remove a tag from this DocBlock . |
13,850 | public static function create ( string $ body , string $ name = '' , ? DescriptionFactory $ descriptionFactory = null , ? TypeContext $ context = null ) : self { Assert :: stringNotEmpty ( $ name ) ; Assert :: notNull ( $ descriptionFactory ) ; $ description = $ descriptionFactory && $ body !== "" ? $ descriptionFactory -> create ( $ body , $ context ) : null ; return new static ( $ name , $ description ) ; } | Creates a new tag that represents any unknown tag type . |
13,851 | private function validateTagName ( string $ name ) : void { if ( ! preg_match ( '/^' . StandardTagFactory :: REGEX_TAGNAME . '$/u' , $ name ) ) { throw new \ InvalidArgumentException ( 'The tag name "' . $ name . '" is not wellformed. Tags may only consist of letters, underscores, ' . 'hyphens and backslashes.' ) ; } } | Validates if the tag name matches the expected format otherwise throws an exception . |
13,852 | private function lex ( string $ contents ) : array { $ contents = $ this -> removeSuperfluousStartingWhitespace ( $ contents ) ; if ( strpos ( $ contents , '{@' ) === false ) { return [ $ contents ] ; } return preg_split ( '/\{ # "{@}" is not a valid inline tag. This ensures that we do not treat it as one, but treat it literally. (?!@\}) # We want to capture the whole tag line, but without the inline tag delimiters. (\@ # Match everything up to the next delimiter. [^{}]* # Nested inline tag content should not be captured, or it will appear in the result separately. (?: # Match nested inline tags. (?: # Because we did not catch the tag delimiters earlier, we must be explicit with them here. # Notice that this also matches "{}", as a way to later introduce it as an escape sequence. \{(?1)?\} | # Make sure we match hanging "{". \{ ) # Match content after the nested inline tag. [^{}]* )* # If there are more inline tags, match them as well. We use "*" since there may not be any # nested inline tags. ) \}/Sux' , $ contents , 0 , PREG_SPLIT_DELIM_CAPTURE ) ; } | Strips the contents from superfluous whitespace and splits the description into a series of tokens . |
13,853 | private function parse ( $ tokens , ? TypeContext $ context = null ) : array { $ count = count ( $ tokens ) ; $ tagCount = 0 ; $ tags = [ ] ; for ( $ i = 1 ; $ i < $ count ; $ i += 2 ) { $ tags [ ] = $ this -> tagFactory -> create ( $ tokens [ $ i ] , $ context ) ; $ tokens [ $ i ] = '%' . ++ $ tagCount . '$s' ; } for ( $ i = 0 ; $ i < $ count ; $ i += 2 ) { $ tokens [ $ i ] = str_replace ( [ '{@}' , '{}' , '%' ] , [ '@' , '}' , '%%' ] , $ tokens [ $ i ] ) ; } return [ implode ( '' , $ tokens ) , $ tags ] ; } | Parses the stream of tokens in to a new set of tokens containing Tags . |
13,854 | private function removeSuperfluousStartingWhitespace ( string $ contents ) : string { $ lines = explode ( "\n" , $ contents ) ; if ( count ( $ lines ) <= 1 ) { return $ contents ; } $ startingSpaceCount = 9999999 ; for ( $ i = 1 ; $ i < count ( $ lines ) ; ++ $ i ) { if ( strlen ( trim ( $ lines [ $ i ] ) ) === 0 ) { continue ; } $ startingSpaceCount = min ( $ startingSpaceCount , strlen ( $ lines [ $ i ] ) - strlen ( ltrim ( $ lines [ $ i ] ) ) ) ; } if ( $ startingSpaceCount > 0 ) { for ( $ i = 1 ; $ i < count ( $ lines ) ; ++ $ i ) { $ lines [ $ i ] = substr ( $ lines [ $ i ] , $ startingSpaceCount ) ; } } return implode ( "\n" , $ lines ) ; } | Removes the superfluous from a multi - line description . |
13,855 | public static function createInstance ( array $ additionalTags = [ ] ) : self { $ fqsenResolver = new FqsenResolver ( ) ; $ tagFactory = new StandardTagFactory ( $ fqsenResolver ) ; $ descriptionFactory = new DescriptionFactory ( $ tagFactory ) ; $ tagFactory -> addService ( $ descriptionFactory ) ; $ tagFactory -> addService ( new TypeResolver ( $ fqsenResolver ) ) ; $ docBlockFactory = new self ( $ descriptionFactory , $ tagFactory ) ; foreach ( $ additionalTags as $ tagName => $ tagHandler ) { $ docBlockFactory -> registerTagHandler ( $ tagName , $ tagHandler ) ; } return $ docBlockFactory ; } | Factory method for easy instantiation . |
13,856 | private function splitDocBlock ( string $ comment ) : array { if ( strpos ( $ comment , '@' ) === 0 ) { return [ '' , '' , '' , $ comment ] ; } $ comment = preg_replace ( '/\h*$/Sum' , '' , $ comment ) ; preg_match ( '/ \A # 1. Extract the template marker (?:(\#\@\+|\#\@\-)\n?)? # 2. Extract the summary (?: (?! @\pL ) # The summary may not start with an @ ( [^\n.]+ (?: (?! \. \n | \n{2} ) # End summary upon a dot followed by newline or two newlines [\n.]* (?! [ \t]* @\pL ) # End summary when an @ is found as first character on a new line [^\n.]+ # Include anything else )* \.? )? ) # 3. Extract the description (?: \s* # Some form of whitespace _must_ precede a description because a summary must be there (?! @\pL ) # The description may not start with an @ ( [^\n]+ (?: \n+ (?! [ \t]* @\pL ) # End description when an @ is found as first character on a new line [^\n]+ # Include anything else )* ) )? # 4. Extract the tags (anything that follows) (\s+ [\s\S]*)? # everything that follows /ux' , $ comment , $ matches ) ; array_shift ( $ matches ) ; while ( count ( $ matches ) < 4 ) { $ matches [ ] = '' ; } return $ matches ; } | Splits the DocBlock into a template marker summary description and block of tags . |
13,857 | public function format ( Tag $ tag ) : string { return '@' . $ tag -> getName ( ) . str_repeat ( ' ' , $ this -> maxLen - strlen ( $ tag -> getName ( ) ) + 1 ) . ( string ) $ tag ; } | Formats the given tag to return a simple plain text version . |
13,858 | public function addOne ( $ title , $ url , array $ data = [ ] ) { return $ this -> addBreadcrumb ( BreadcrumbItem :: make ( $ title , $ url , $ data ) ) ; } | Add a breadcrumb item to collection . |
13,859 | private function order ( ) { $ count = $ this -> count ( ) ; $ this -> map ( function ( BreadcrumbItem $ crumb , $ key ) use ( $ count ) { $ crumb -> resetPosition ( ) ; if ( $ key === 0 ) $ crumb -> setFirst ( ) ; if ( $ key === ( $ count - 1 ) ) $ crumb -> setLast ( ) ; return $ crumb ; } ) ; return $ this ; } | Order all breadcrumbs items . |
13,860 | public function parse ( $ text = '' , $ options = [ ] ) { $ options = array_merge ( [ 'config' => [ ] , 'purifier' => true ] , $ options ) ; $ markdown = parent :: text ( $ text ) ; if ( config ( 'parsedownextra.purifier.enabled' ) && $ options [ 'purifier' ] ) { $ purifier = app ( HTMLPurifierLaravel :: class ) ; $ markdown = $ purifier -> purify ( $ markdown , $ options [ 'config' ] ) ; } return $ markdown ; } | Convert Markdown text to HTML and sanitize the output . |
13,861 | private function makeQuery ( $ pageNumber = 1 ) { $ params = array ( 'page_size' => $ this -> pageSize , 'page' => $ pageNumber ) ; $ params = array_merge ( $ params , $ this -> filter ) ; $ params = array_merge ( $ params , $ this -> order ) ; $ response = $ this -> api -> get ( $ this -> typeClass -> url ( ) , $ params ) ; $ this -> countCached = $ response -> meta -> total_count ; return $ response ; } | Makes a GET request to the API with parameters for page size page number filtering and order values . Returns the API response . |
13,862 | public function count ( ) { if ( $ this -> countCached === null ) { $ pageSize = $ this -> pageSize ; $ this -> pageSize = 1 ; $ this -> makeQuery ( 1 ) ; $ this -> pageSize = $ pageSize ; } return $ this -> countCached ; } | Total amount of objects matched by the current query reading this may cause a remote request . |
13,863 | public function makeFilter ( $ filterType = null , $ filterField = null , $ filterValue = null ) { if ( $ filterType === null && $ filterField === null && $ filterValue === null ) $ this -> filter = array ( ) ; else $ this -> filter = array ( 'filter_type' => $ filterType , 'filter_field' => $ filterField , 'filter_value' => $ filterValue ) ; return $ this ; } | Sets up filtering rules for the query . |
13,864 | public function getPage ( $ pageNumber ) { $ response = $ this -> makeQuery ( $ pageNumber ) ; $ className = $ this -> typeClass -> objectClass ; $ objects = array ( ) ; if ( ! isset ( $ response -> data ) || ! $ response -> data ) return array ( ) ; foreach ( $ response -> data as $ object ) { $ objects [ ] = new $ className ( $ this -> api , $ this -> typeClass , $ object ) ; } return $ objects ; } | Fetch objects for the one - based page number . |
13,865 | private function initSession ( ) { $ transport = $ this -> transportRegistry -> getTransport ( $ this -> profile -> get ( 'transport' , 'name' ) ) ; $ repository = $ transport -> getRepository ( $ this -> profile -> get ( 'transport' ) ) ; $ credentials = new SimpleCredentials ( $ this -> profile -> get ( 'phpcr' , 'username' ) , $ this -> profile -> get ( 'phpcr' , 'password' ) ) ; $ session = $ repository -> login ( $ credentials , $ this -> profile -> get ( 'phpcr' , 'workspace' ) ) ; if ( ! $ this -> session ) { $ this -> session = new PhpcrSession ( $ session ) ; } else { $ this -> session -> setPhpcrSession ( $ session ) ; } } | Initialize the PHPCR session . |
13,866 | public function changeWorkspace ( $ workspaceName ) { $ this -> init ( ) ; $ this -> session -> logout ( ) ; $ this -> profile -> set ( 'phpcr' , 'workspace' , $ workspaceName ) ; $ this -> initSession ( $ this -> profile ) ; } | Change the current workspace . |
13,867 | protected function loadFile ( $ file ) { if ( ! stream_is_local ( $ file ) ) { throw new InvalidArgumentException ( sprintf ( 'This is not a local file "%s".' , $ file ) ) ; } if ( ! file_exists ( $ file ) ) { throw new InvalidArgumentException ( sprintf ( 'The service file "%s" is not valid.' , $ file ) ) ; } return Toml :: Parse ( $ file ) ; } | Loads the Toml File |
13,868 | public static function get_palette ( $ numColors = 50 , $ type = 'hsv' ) { $ s = CalendarConfig :: subpackage_settings ( 'colors' ) ; $ arr = $ s [ 'basepalette' ] ; return $ arr ; if ( $ type == 'hsv' ) { $ s = 1 ; $ v = 1 ; $ arr = array ( ) ; for ( $ i = 0 ; $ i <= $ numColors ; $ i ++ ) { $ c = new Color ( ) ; $ h = $ i / $ numColors ; $ hex = $ c -> fromHSV ( $ h , $ s , $ v ) -> toHexString ( ) ; $ arr [ $ hex ] = $ hex ; } return $ arr ; } elseif ( $ type == 'websafe' ) { $ cs = array ( '00' , '33' , '66' , '99' , 'CC' , 'FF' ) ; $ arr = array ( ) ; for ( $ i = 0 ; $ i < 6 ; $ i ++ ) { for ( $ j = 0 ; $ j < 6 ; $ j ++ ) { for ( $ k = 0 ; $ k < 6 ; $ k ++ ) { $ c = $ cs [ $ i ] . $ cs [ $ j ] . $ cs [ $ k ] ; $ arr [ "$c" ] = "#$c" ; } } } return $ arr ; } } | Getting a color palette For now we only have a hsv palette could be extended with more options |
13,869 | protected function sendSignal ( $ signalNumber ) { if ( ! $ this -> context -> isRunning || ! $ this -> context -> processId ) { return false ; } $ result = $ this -> control -> signal ( ) -> send ( $ signalNumber , $ this -> context -> processId ) ; if ( in_array ( $ signalNumber , [ SIGTERM , SIGKILL ] ) ) { $ this -> context -> isRunning = false ; $ this -> context -> processId = null ; } return $ result ; } | Sends a signal to the current process and returns its results . |
13,870 | protected function setHandlerAlarm ( ) { $ handler = new SignalAlarm ( $ this -> control , $ this -> action , $ this -> context ) ; $ this -> control -> signal ( ) -> setHandler ( 'alarm' , $ handler ) ; $ this -> control -> signal ( ) -> alarm ( $ this -> context -> timeout ) ; } | Define the timeout handler . |
13,871 | protected function silentRunActionTrigger ( $ event ) { try { $ this -> action -> trigger ( $ event , $ this -> control , $ this -> context ) ; } catch ( Exception $ exception ) { } } | Runs action trigger by the given event ignoring all exception . |
13,872 | protected function run ( ) { $ this -> silentRunActionTrigger ( Action :: EVENT_START ) ; try { $ event = $ this -> action -> execute ( $ this -> control , $ this -> context ) ? : Action :: EVENT_SUCCESS ; $ this -> context -> exitCode = 0 ; } catch ( ErrorException $ errorException ) { $ event = Action :: EVENT_ERROR ; $ this -> context -> exception = $ errorException ; $ this -> context -> exitCode = 2 ; } catch ( Exception $ exception ) { $ event = Action :: EVENT_FAILURE ; $ this -> context -> exception = $ exception ; $ this -> context -> exitCode = 1 ; } $ this -> context -> finishTime = time ( ) ; $ this -> silentRunActionTrigger ( $ event ) ; $ this -> silentRunActionTrigger ( Action :: EVENT_FINISH ) ; } | Execute the action triggers the events and then exit the program . |
13,873 | private function doParse ( $ sql2 ) { $ this -> implicitSelectorName = null ; $ this -> sql2 = $ sql2 ; $ source = null ; $ constraint = null ; $ updates = [ ] ; $ applies = [ ] ; while ( $ this -> scanner -> lookupNextToken ( ) !== '' ) { switch ( strtoupper ( $ this -> scanner -> lookupNextToken ( ) ) ) { case 'UPDATE' : $ this -> scanner -> expectToken ( 'UPDATE' ) ; $ source = $ this -> parseSource ( ) ; break ; case 'SET' : $ this -> scanner -> expectToken ( 'SET' ) ; $ updates = $ this -> parseUpdates ( ) ; break ; case 'APPLY' : $ this -> scanner -> expectToken ( 'APPLY' ) ; $ applies = $ this -> parseApply ( ) ; break ; case 'WHERE' : $ this -> scanner -> expectToken ( 'WHERE' ) ; $ constraint = $ this -> parseConstraint ( ) ; break ; default : throw new InvalidQueryException ( 'Expected end of query, got "' . $ this -> scanner -> lookupNextToken ( ) . '" in ' . $ this -> sql2 ) ; } } if ( ! $ source instanceof SourceInterface ) { throw new InvalidQueryException ( 'Invalid query, source could not be determined: ' . $ sql2 ) ; } $ query = $ this -> factory -> createQuery ( $ source , $ constraint ) ; $ res = new \ ArrayObject ( [ $ query , $ updates , $ constraint , $ applies ] ) ; return $ res ; } | Parse an SQL2 UPDATE statement and construct a query builder for selecting the rows and build a field = > value mapping for the update . |
13,874 | public function handleAlias ( CommandPreRunEvent $ event ) { $ input = $ event -> getInput ( ) ; $ commandName = $ input -> getFirstArgument ( ) ; $ aliasConfig = $ this -> configManager -> getConfig ( 'alias' ) ; if ( ! isset ( $ aliasConfig [ $ commandName ] ) ) { return ; } $ command = $ aliasConfig [ $ commandName ] ; $ command = $ command .= substr ( $ input -> getRawCommand ( ) , strlen ( $ commandName ) ) ; $ newInput = new StringInput ( $ command ) ; $ event -> setInput ( $ newInput ) ; return $ command ; } | Check for an alias and replace the input with a new string command if the alias exists . |
13,875 | public function getStateLabel ( ) { $ list = self :: getStateList ( ) ; return isset ( $ list [ $ this -> getState ( ) ] ) ? $ list [ $ this -> getState ( ) ] : null ; } | Returns comment state label . |
13,876 | public function tag ( $ tag , $ content , array $ attributes = [ ] ) { return $ this -> htmlBuilder -> tag ( $ tag , $ content , $ attributes ) ; } | Generate an html tag . |
13,877 | protected function normalize ( $ value ) { if ( $ value instanceof Exception ) { $ value = [ 'class' => get_class ( $ value ) , 'message' => $ value -> getMessage ( ) , 'code' => $ value -> getCode ( ) , 'file' => $ value -> getFile ( ) , 'line' => $ value -> getLine ( ) , ] ; } return $ value ; } | Normalizes the given value . |
13,878 | private function configureFormatter ( OutputFormatter $ formatter ) { $ style = new OutputFormatterStyle ( 'yellow' , null , [ 'bold' ] ) ; $ formatter -> setStyle ( 'pathbold' , $ style ) ; $ style = new OutputFormatterStyle ( 'green' ) ; $ formatter -> setStyle ( 'localname' , $ style ) ; $ style = new OutputFormatterStyle ( null , null , [ 'bold' ] ) ; $ formatter -> setStyle ( 'node' , $ style ) ; $ style = new OutputFormatterStyle ( 'blue' , null , [ 'bold' ] ) ; $ formatter -> setStyle ( 'templatenode' , $ style ) ; $ style = new OutputFormatterStyle ( 'blue' , null , [ ] ) ; $ formatter -> setStyle ( 'templateproperty' , $ style ) ; $ style = new OutputFormatterStyle ( null , null , [ ] ) ; $ formatter -> setStyle ( 'property' , $ style ) ; $ style = new OutputFormatterStyle ( 'magenta' , null , [ 'bold' ] ) ; $ formatter -> setStyle ( 'node-type' , $ style ) ; $ style = new OutputFormatterStyle ( 'magenta' , null , [ ] ) ; $ formatter -> setStyle ( 'property-type' , $ style ) ; $ style = new OutputFormatterStyle ( null , null , [ ] ) ; $ formatter -> setStyle ( 'property-value' , $ style ) ; $ style = new OutputFormatterStyle ( null , 'red' , [ ] ) ; $ formatter -> setStyle ( 'exception' , $ style ) ; } | Configure the output formatter . |
13,879 | public function add ( Command $ command ) { if ( $ command instanceof ContainerAwareInterface ) { $ command -> setContainer ( $ this -> container ) ; } if ( $ command instanceof BasePhpcrCommand ) { if ( $ this -> showUnsupported || $ command -> isSupported ( ) ) { parent :: add ( $ command ) ; } } else { parent :: add ( $ command ) ; } } | Wrap the add method and do not register commands which are unsupported by the current transport . |
13,880 | protected function prepareSettings ( $ mass , $ makeResources , $ makeMountPoint , $ extensionKey , $ author , $ title , $ description , $ useVhs , $ useFluidcontentCore , $ pages , $ content , $ backend , $ controllers ) { return [ $ mass , ( boolean ) $ makeResources , ( boolean ) $ makeMountPoint , false === is_null ( $ extensionKey ) ? $ extensionKey : self :: DEFAULT_EXTENSION_KEY , $ this -> getAuthor ( $ author ) , false === empty ( $ title ) ? $ title : self :: DEFAULT_EXTENSION_TITLE , false === empty ( $ description ) ? $ description : self :: DEFAULT_EXTENSION_DESCRIPTION , ( boolean ) $ useVhs , ( boolean ) $ useFluidcontentCore , ( boolean ) $ pages , ( boolean ) $ content , ( boolean ) $ backend , ( boolean ) $ controllers ] ; } | Prepare values to avoid problems |
13,881 | private function gatherInformation ( ) { $ objectManager = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: makeInstance ( ObjectManager :: class ) ; $ service = $ objectManager -> get ( 'TYPO3\\CMS\\Extensionmanager\\Utility\\ListUtility' ) ; $ extensionInformation = $ service -> getAvailableExtensions ( ) ; foreach ( $ extensionInformation as $ extensionKey => $ info ) { if ( true === array_key_exists ( $ extensionKey , $ GLOBALS [ 'TYPO3_LOADED_EXT' ] ) ) { $ extensionInformation [ $ extensionKey ] [ 'installed' ] = 1 ; } else { $ extensionInformation [ $ extensionKey ] [ 'installed' ] = 0 ; } } return $ extensionInformation ; } | Gathers Extension Information |
13,882 | public static function fromHexString ( $ color ) { $ color = rtrim ( $ color , '#' ) ; preg_match_all ( '([0-9a-f][0-9a-f])' , $ color , $ rgb ) ; $ c = new self ( ) ; list ( $ c -> r , $ c -> g , $ c -> b ) = array_map ( 'hexdec' , $ rgb [ 0 ] ) ; return $ c ; } | Construct a Color from hex string |
13,883 | public static function fromRGBString ( $ color ) { $ color = rtrim ( $ color , "rgb (\t)" ) ; $ rgb = preg_split ( '\s+,\s+' , $ color ) ; $ c = new self ( ) ; list ( $ c -> r , $ c -> g , $ c -> b ) = array_map ( 'intval' , $ rgb ) ; return $ c ; } | Construct Color object from an rgb string |
13,884 | public function toHexString ( ) { return '#' . $ this -> decToHex ( $ this -> r ) . $ this -> decToHex ( $ this -> g ) . $ this -> decToHex ( $ this -> b ) ; } | Convert color object to hex string |
13,885 | public static function fromHSL ( $ h , $ s , $ l ) { $ h -= floor ( $ h ) ; $ c = new self ( ) ; if ( $ s == 0 ) { $ c -> r = $ c -> g = $ c -> b = $ l * 255 ; return $ c ; } $ chroma = floatval ( 1 - abs ( 2 * $ l - 1 ) ) * $ s ; $ h_ = $ h * 6 ; $ k = intval ( $ h_ ) ; $ h_mod2 = $ k % 2 + $ h_ - floor ( $ h_ ) ; $ x = $ chroma * abs ( 1 - abs ( $ h_mod2 - 1 ) ) ; $ r = $ g = $ b = 0.0 ; switch ( $ k ) { case 0 : case 6 : $ r = $ chroma ; $ g = $ x ; break ; case 1 : $ r = $ x ; $ g = $ chroma ; break ; case 2 : $ g = $ chroma ; $ b = $ x ; break ; case 3 : $ g = $ x ; $ b = $ chroma ; break ; case 4 : $ r = $ x ; $ b = $ chroma ; break ; case 5 : $ r = $ chroma ; $ b = $ x ; break ; } $ m = $ l - 0.5 * $ chroma ; $ c -> r = ( ( $ r + $ m ) * 255 ) ; $ c -> g = ( ( $ g + $ m ) * 255 ) ; $ c -> b = ( ( $ b + $ m ) * 255 ) ; return $ c ; } | Construct a Color object from H S L values |
13,886 | public static function fromHSV ( $ h , $ s , $ v ) { $ h -= floor ( $ h ) ; $ c = new self ( ) ; if ( $ s == 0 ) { $ c -> r = $ c -> g = $ c -> b = $ v * 255 ; return $ c ; } $ chroma = $ v * $ s ; $ h_ = $ h * 6 ; $ k = intval ( $ h_ ) ; $ h_mod2 = $ k % 2 + $ h_ - floor ( $ h_ ) ; $ x = $ chroma * abs ( 1 - abs ( $ h_mod2 - 1 ) ) ; $ r = $ g = $ b = 0.0 ; switch ( $ k ) { case 0 : case 6 : $ r = $ chroma ; $ g = $ x ; break ; case 1 : $ r = $ x ; $ g = $ chroma ; break ; case 2 : $ g = $ chroma ; $ b = $ x ; break ; case 3 : $ g = $ x ; $ b = $ chroma ; break ; case 4 : $ r = $ x ; $ b = $ chroma ; break ; case 5 : $ r = $ chroma ; $ b = $ x ; break ; } $ m = $ v - $ chroma ; $ c -> r = ( ( $ r + $ m ) * 255 ) ; $ c -> g = ( ( $ g + $ m ) * 255 ) ; $ c -> b = ( ( $ b + $ m ) * 255 ) ; return $ c ; } | Construct a Color object from HSV values |
13,887 | public function darken ( $ fraction = 0.1 ) { $ hsl = $ this -> toHSL ( ) ; $ l = $ hsl [ 2 ] ; $ dl = - $ l * $ fraction ; return $ this -> changeHSL ( 0 , 0 , $ dl ) ; } | Darken the current color by a fraction |
13,888 | public function lighten ( $ fraction = 0.1 ) { $ hsl = $ this -> toHSL ( ) ; $ l = $ hsl [ 2 ] ; $ dl = ( 1 - $ l ) * $ fraction ; return $ this -> changeHSL ( 0 , 0 , $ dl ) ; } | Lighten the current color by a fraction |
13,889 | public function changeHSL ( $ dh = 0 , $ ds = 0 , $ dl = 0 ) { list ( $ h , $ s , $ l ) = $ this -> toHSL ( ) ; $ h += $ dh ; $ s += $ ds ; $ l += $ dl ; $ c = self :: fromHSL ( $ h , $ s , $ l ) ; $ this -> r = $ c -> r ; $ this -> g = $ c -> g ; $ this -> b = $ c -> b ; return $ this ; } | Change HSL values by given deltas |
13,890 | public function toHSL ( ) { $ r = $ this -> r / 255.0 ; $ g = $ this -> g / 255.0 ; $ b = $ this -> b / 255.0 ; $ max = max ( $ r , $ g , $ b ) ; $ min = min ( $ r , $ g , $ b ) ; $ dmax = $ max - $ min ; $ l = ( $ min + $ max ) / 2 ; if ( $ dmax == 0 ) { $ h = 0 ; $ s = 0 ; } else { $ s = ( $ l < 0.5 ) ? $ dmax / ( $ l * 2 ) : $ dmax / ( ( 1 - $ l ) * 2 ) ; $ dr = ( ( ( $ max - $ r ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; $ dg = ( ( ( $ max - $ g ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; $ db = ( ( ( $ max - $ b ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; if ( $ r == $ max ) { $ h = ( 0.0 / 3 ) + $ db - $ dg ; } elseif ( $ g == $ max ) { $ h = ( 1.0 / 3 ) + $ dr - $ db ; } elseif ( $ b == $ max ) { $ h = ( 2.0 / 3 ) + $ dg - $ dr ; } if ( $ h < 0 ) { $ h += 1 ; } if ( $ h > 1 ) { $ h -= 1 ; } } return array ( $ h , $ s , $ l ) ; } | Convert the current color to HSL values |
13,891 | public function toHSV ( ) { $ r = $ this -> r / 255.0 ; $ g = $ this -> g / 255.0 ; $ b = $ this -> b / 255.0 ; $ max = max ( $ r , $ g , $ b ) ; $ min = min ( $ r , $ g , $ b ) ; $ dmax = $ max - $ min ; $ v = $ max ; if ( $ dmax == 0 ) { $ h = 0 ; $ s = 0 ; } else { $ s = $ dmax / $ max ; $ dr = ( ( ( $ max - $ r ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; $ dg = ( ( ( $ max - $ g ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; $ db = ( ( ( $ max - $ b ) / 6 ) + ( $ dmax / 2 ) ) / $ dmax ; if ( $ r == $ max ) { $ h = ( 0.0 / 3 ) + $ db - $ dg ; } elseif ( $ g == $ max ) { $ h = ( 1.0 / 3 ) + $ dr - $ db ; } elseif ( $ b == $ max ) { $ h = ( 2.0 / 3 ) + $ dg - $ dr ; } if ( $ h < 0 ) { $ h += 1 ; } if ( $ h > 1 ) { $ h -= 1 ; } } return array ( $ h , $ s , $ v ) ; } | Convert the current color to HSV values |
13,892 | public function getAbsTargetPath ( $ srcPath , $ targetPath ) { $ targetPath = $ this -> getAbsPath ( $ targetPath ) ; try { $ this -> getNode ( $ targetPath ) ; } catch ( PathNotFoundException $ e ) { return $ targetPath ; } $ basename = basename ( $ this -> getAbsPath ( $ srcPath ) ) ; return $ this -> getAbsPath ( sprintf ( '%s/%s' , $ targetPath , $ basename ) ) ; } | Infer the absolute target path for a given source path . |
13,893 | public function getNodeByPathOrIdentifier ( $ pathOrId ) { if ( true === UUIDHelper :: isUUID ( $ pathOrId ) ) { return $ this -> getNodeByIdentifier ( $ pathOrId ) ; } $ pathOrId = $ this -> getAbsPath ( $ pathOrId ) ; return $ this -> getNode ( $ pathOrId ) ; } | If the given parameter looks like a UUID retrieve by Identifier otherwise by path . |
13,894 | private function normalizeTokens ( array $ tokens ) { $ nTokens = array ( ) ; for ( $ i = 0 , $ c = count ( $ tokens ) ; $ i < $ c ; $ i ++ ) { $ token = $ tokens [ $ i ] ; if ( is_string ( $ token ) ) { $ nTokens [ ] = new LiteralToken ( $ token , end ( $ nTokens ) -> getEndLine ( ) ) ; continue ; } switch ( $ token [ 0 ] ) { case T_WHITESPACE : $ lines = explode ( "\n" , $ token [ 1 ] ) ; for ( $ j = 0 , $ k = count ( $ lines ) ; $ j < $ k ; $ j ++ ) { $ line = $ lines [ $ j ] . ( $ j + 1 === $ k ? '' : "\n" ) ; if ( $ j + 1 === $ k && '' === $ line ) { break ; } $ nTokens [ ] = new PhpToken ( array ( T_WHITESPACE , $ line , $ token [ 2 ] + $ j ) ) ; } break ; default : if ( preg_match ( '/^(.*?)(\s+)$/' , $ token [ 1 ] , $ match ) ) { $ nTokens [ ] = new PhpToken ( array ( $ token [ 0 ] , $ match [ 1 ] , $ token [ 2 ] ) ) ; if ( isset ( $ tokens [ $ i + 1 ] ) && ! is_string ( $ tokens [ $ i + 1 ] ) && T_WHITESPACE === $ tokens [ $ i + 1 ] [ 0 ] ) { $ tokens [ $ i + 1 ] [ 1 ] = $ match [ 2 ] . $ tokens [ $ i + 1 ] [ 1 ] ; $ tokens [ $ i + 1 ] [ 2 ] = $ token [ 2 ] ; } else { $ nTokens [ ] = new PhpToken ( array ( T_WHITESPACE , $ match [ 2 ] , $ token [ 2 ] ) ) ; } } else { $ nTokens [ ] = new PhpToken ( $ token ) ; } } } return $ nTokens ; } | Normalizes the original PHP token stream into a format which is more usable for analysis . |
13,895 | public function insertBefore ( AbstractToken $ token , $ type , $ value = null ) { $ this -> insertAllTokensBefore ( $ token , array ( array ( $ type , $ value , $ token -> getLine ( ) ) ) ) ; } | Inserts a new token before the passed token . |
13,896 | private function httpRequest ( $ url , $ request , $ data = array ( ) , $ sendHeaders = array ( ) , $ timeout = 10 ) { $ streamParams = array ( 'http' => array ( 'method' => $ request , 'ignore_errors' => true , 'timeout' => $ timeout , 'header' => "User-Agent: " . $ this -> userAgent . "\r\n" ) ) ; foreach ( $ sendHeaders as $ header => $ value ) { $ streamParams [ 'http' ] [ 'header' ] .= $ header . ': ' . $ value . "\r\n" ; } foreach ( $ this -> extraHeaders as $ header => $ value ) { $ streamParams [ 'http' ] [ 'header' ] .= $ header . ': ' . $ value . "\r\n" ; } if ( is_array ( $ data ) ) { if ( in_array ( $ request , array ( 'POST' , 'PUT' ) ) ) $ streamParams [ 'http' ] [ 'content' ] = http_build_query ( $ data ) ; elseif ( $ data && count ( $ data ) ) $ url .= '?' . http_build_query ( $ data ) ; } elseif ( $ data !== null ) { if ( in_array ( $ request , array ( 'POST' , 'PUT' ) ) ) $ streamParams [ 'http' ] [ 'content' ] = $ data ; } $ streamParams [ 'cURL' ] = $ streamParams [ 'http' ] ; $ context = stream_context_create ( $ streamParams ) ; $ fp = @ fopen ( $ url , 'rb' , false , $ context ) ; if ( ! $ fp ) $ content = false ; else $ content = stream_get_contents ( $ fp ) ; $ status = null ; $ statusCode = null ; $ headers = array ( ) ; if ( $ content !== false ) { $ metadata = stream_get_meta_data ( $ fp ) ; if ( isset ( $ metadata [ 'wrapper_data' ] [ 'headers' ] ) ) $ headerMetadata = $ metadata [ 'wrapper_data' ] [ 'headers' ] ; else $ headerMetadata = $ metadata [ 'wrapper_data' ] ; foreach ( $ headerMetadata as $ row ) { if ( preg_match ( '/^HTTP\/1\.[01] (\d{3})\s*(.*)/' , $ row , $ m ) ) { $ statusCode = $ m [ 1 ] ; $ status = $ m [ 2 ] ; } elseif ( preg_match ( '/^([^:]+):\s*(.*)$/' , $ row , $ m ) ) { $ headers [ mb_strtolower ( $ m [ 1 ] ) ] = $ m [ 2 ] ; } } } return ( object ) array ( 'ok' => $ statusCode == 200 , 'statusCode' => $ statusCode , 'status' => $ status , 'content' => $ content , 'headers' => $ headers ) ; } | Opens a socket and makes a request to the url of choice . Returns an object with statusCode status content and the received headers . |
13,897 | public function get ( $ objectUrl , $ data = null , $ expectContentType = null ) { $ url = $ this -> apiBase . '/' . $ objectUrl ; return $ this -> checkApiResponse ( $ this -> httpRequest ( $ url , 'GET' , $ data , $ this -> authHeader ( ) ) , $ expectContentType ) ; } | Makes a GET request to an API object . Used for receiving an existing object or a list of resources . |
13,898 | public function put ( $ objectUrl , $ data ) { $ url = $ this -> apiBase . '/' . $ objectUrl ; return $ this -> checkApiResponse ( $ this -> httpRequest ( $ url , 'PUT' , json_encode ( $ data ) , array_merge ( $ this -> authHeader ( ) , array ( 'Content-type' => 'application/json' ) ) ) ) ; } | Makes a PUT request to an API object . Used for updating a single existing object . |
13,899 | public function delete ( $ objectUrl ) { $ url = $ this -> apiBase . '/' . $ objectUrl ; return $ this -> checkApiResponse ( $ this -> httpRequest ( $ url , 'DELETE' , null , $ this -> authHeader ( ) ) ) ; } | Makes a DELETE request to an API object . Used to delete a single existing object . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.