idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
35,700 | protected function reject ( $ message = null , $ key = null ) { $ message = $ message ? : static :: class . ' rejected the request.' ; $ key = $ key ? : static :: class ; throw new PerformerException ( $ message , $ key ) ; } | Make this guard reject the request by throwing a PerformerException |
35,701 | protected function option ( $ key , $ default = null ) { return array_key_exists ( $ key , $ this -> options ) ? $ this -> options [ $ key ] : $ default ; } | Get an option from the options array |
35,702 | protected function requireOption ( $ key ) { $ value = $ this -> option ( $ key ) ; if ( $ value === null ) { throw new Exception ( "The '{$key}' option is required." ) ; } return $ value ; } | Get an option from the options array and throw an exception if it isn t set |
35,703 | public function perform ( ) { $ url = $ this -> requireOption ( 'url' ) ; $ only = $ this -> option ( 'only' ) ; $ except = $ this -> option ( 'except' ) ; if ( is_array ( $ only ) ) { $ data = [ ] ; foreach ( $ only as $ key ) { $ data [ $ key ] = $ this -> form -> data ( $ key ) ; } } else { $ data = $ this -> form -... | Call a webhook |
35,704 | public function perform ( ) { $ params = array_merge ( $ this -> options , [ 'to' => $ this -> requireOption ( 'to' ) , 'from' => $ this -> requireOption ( 'from' ) , 'replyTo' => $ this -> option ( 'replyTo' , $ this -> form -> data ( self :: EMAIL_KEY ) ) , 'subject' => $ this -> getSubject ( ) , ] ) ; if ( empty ( $... | Send the form data via email . |
35,705 | protected function handleException ( $ e ) { if ( App :: instance ( ) -> option ( 'debug' ) === true ) { $ this -> fail ( I18n :: translate ( 'uniform-email-error' ) . ': ' . $ e -> getMessage ( ) ) ; } $ this -> fail ( I18n :: translate ( 'uniform-email-error' ) . '.' ) ; } | Handle an exception when the email should be sent . |
35,706 | protected function getSubject ( ) { $ templatableItems = array_filter ( $ this -> form -> data ( ) , function ( $ item ) { return is_scalar ( $ item ) ; } ) ; $ subject = Str :: template ( $ this -> option ( 'subject' , I18n :: translate ( 'uniform-email-subject' ) ) , $ templatableItems ) ; return str_replace ( "\n" ,... | Get the email subject and resolve possible template strings |
35,707 | protected function getBody ( ) { $ data = $ this -> form -> data ( ) ; unset ( $ data [ self :: EMAIL_KEY ] ) ; unset ( $ data [ self :: RECEIVE_COPY_KEY ] ) ; $ body = '' ; foreach ( $ data as $ key => $ value ) { if ( is_array ( $ value ) ) { $ value = implode ( ', ' , array_filter ( $ value , function ( $ i ) { retu... | Get the email body |
35,708 | protected function fail ( $ message = null , $ key = null ) { $ message = $ message ? : static :: class . ' failed.' ; $ key = $ key ? : static :: class ; throw new PerformerException ( $ message , $ key ) ; } | Make this action fail by throwing an PerformerException . |
35,709 | public function perform ( ) { $ fields = $ this -> requireOption ( 'fields' ) ; foreach ( $ fields as $ field => $ options ) { $ this -> handleFile ( $ field , $ options ) ; } } | Move uploaded files to their target directory . |
35,710 | protected function handleFile ( $ field , $ options ) { $ file = $ this -> form -> data ( $ field ) ; if ( ! is_array ( $ file ) || ! isset ( $ file [ 'error' ] ) || intval ( $ file [ 'error' ] ) !== UPLOAD_ERR_OK ) { return ; } if ( ! array_key_exists ( 'target' , $ options ) ) { $ this -> fail ( "The target directory... | Move a single uploaded file . |
35,711 | public function perform ( ) { $ file = $ this -> requireOption ( 'file' ) ; $ content = $ this -> getContent ( ) ; if ( $ this -> write ( $ file , $ content ) === false ) { $ this -> fail ( I18n :: translate ( 'uniform-log-error' ) ) ; } } | Append the form data to the log file . |
35,712 | protected function getContent ( ) { $ template = $ this -> option ( 'template' ) ; $ data = $ this -> form -> data ( ) ; if ( $ template ) { $ content = $ this -> getTemplate ( $ template , [ 'data' => $ data , 'options' => $ this -> options ] ) ; } else { $ visitor = App :: instance ( ) -> visitor ( ) ; $ content = '[... | Get the content of the log entry |
35,713 | protected function getTemplate ( $ name , array $ data ) { $ template = App :: instance ( ) -> template ( $ name ) ; if ( ! $ template -> exists ( ) ) { throw new Exception ( "The template '{$name}' does not exist." ) ; } return $ template -> render ( $ data ) ; } | Returns the a rendered template as string . |
35,714 | public function perform ( ) { $ userField = $ this -> option ( 'user-field' , 'username' ) ; $ passwordField = $ this -> option ( 'password-field' , 'password' ) ; $ user = $ this -> getUser ( $ this -> form -> data ( $ userField ) ) ; if ( ! $ user || ! $ user -> login ( $ this -> form -> data ( $ passwordField ) ) ) ... | Log in a user . |
35,715 | public function perform ( ) { $ this -> options [ 'to' ] = $ this -> getRecipient ( ) ; unset ( $ this -> data [ self :: RECIPIENT_FIELD ] ) ; unset ( $ this -> options [ 'allowed-recipients' ] ) ; return parent :: perform ( ) ; } | Set the chosen recipient email address and send the form data via email . |
35,716 | protected function getRecipient ( ) { $ recipient = $ this -> form -> data ( self :: RECIPIENT_FIELD ) ; $ allowed = $ this -> requireOption ( 'allowed-recipients' ) ; if ( ! array_key_exists ( $ recipient , $ allowed ) ) { $ this -> fail ( I18n :: translate ( 'uniform-email-error' ) . ' ' . I18n :: translate ( 'unifor... | Get the chosen recipient or fail if it is invalid |
35,717 | public function guard ( $ guard = HoneypotGuard :: class , $ options = [ ] ) { if ( $ this -> shouldValidate ) $ this -> validate ( ) ; $ this -> shouldCallGuard = false ; if ( $ this -> shouldFallThrough ) return $ this ; if ( is_string ( $ guard ) && ! class_exists ( $ guard ) ) { throw new Exception ( "{$guard} does... | Call a guard |
35,718 | protected function fail ( ) { $ this -> success = false ; if ( $ this -> shouldRedirect ) { die ( Response :: redirect ( Url :: last ( ) ) ) ; } else { $ this -> shouldFallThrough = true ; } } | Redirect back to the page of the form |
35,719 | protected function perform ( Performer $ performer ) { try { $ performer -> perform ( ) ; } catch ( PerformerException $ e ) { $ this -> addError ( $ e -> getKey ( ) , $ e -> getMessage ( ) ) ; $ this -> saveData ( ) ; $ this -> fail ( ) ; } } | Perform a performer and handle a possible exception |
35,720 | public function __doRequest ( $ request , $ location , $ action , $ version , $ one_way = false ) { if ( ! $ this -> authCookies ) $ this -> configureAuthCookies ( $ location ) ; $ headers = array ( ) ; $ headers [ ] = "Content-Type: text/xml;" ; $ headers [ ] = "SOAPAction: \"{$action}\"" ; $ curl = curl_init ( $ loca... | Override do request method |
35,721 | protected function configureAuthCookies ( $ location ) { $ location = parse_url ( $ location ) ; $ endpoint = 'https://' . $ location [ 'host' ] ; $ login = $ this -> { '_login' } ; $ password = $ this -> { '_password' } ; $ xml = $ this -> generateSecurityToken ( $ login , $ password , $ endpoint ) ; $ result = $ this... | ConfigureAuthCookies Authenticate with sharepoint online in order to get valid authentication cookies |
35,722 | protected function extractAuthCookies ( $ result ) { $ authCookies = array ( ) ; $ cookie_payload = '' ; $ header_array = explode ( "\r\n" , $ result ) ; foreach ( $ header_array as $ header ) { $ loop = explode ( ":" , $ header ) ; if ( strtolower ( $ loop [ 0 ] ) == 'set-cookie' ) { $ authCookies [ ] = $ loop [ 1 ] ;... | extractAuthCookies Extract Authentication cookies from SP response & format in to usable cookie string |
35,723 | protected function authCurl ( $ url , $ payload , $ header = false ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , $ payload ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT... | authCurl helper method used to cURL SharePoint Online authentiction webservices |
35,724 | public function getLimitedLists ( array $ keys , array $ params = array ( 'hidden' => 'False' ) , $ isSensetive = TRUE ) { $ lists = $ this -> getLists ( ) ; $ newLists = array ( ) ; foreach ( $ lists as $ entry ) { $ isFound = TRUE ; foreach ( $ params as $ key => $ value ) { if ( ( isset ( $ entry [ $ key ] ) ) && ( ... | Returns an array of all lists |
35,725 | public function getLists ( ) { $ rawXml = '' ; try { $ rawXml = $ this -> soapClient -> GetListCollection ( ) -> GetListCollectionResult -> any ; } catch ( \ SoapFault $ fault ) { $ this -> onError ( $ fault ) ; } $ nodes = $ this -> getArrayFromElementsByTagName ( $ rawXml , 'List' ) ; foreach ( $ nodes as $ counter =... | Get Lists Return an array containing all avaiable lists within a given sharepoint subsite . Use set return type if you wish for this data to be provided as an object . |
35,726 | public function read ( $ list_name , $ limit = NULL , $ query = NULL , $ view = NULL , $ sort = NULL , $ options = NULL ) { if ( $ limit < 1 || is_null ( $ limit ) ) { $ limit = $ this -> MAX_ROWS ; } $ xml_options = '' ; $ xml_query = '' ; $ fields_xml = '' ; if ( $ query instanceof Service \ QueryObjectService ) { $ ... | Read Use s raw CAML to query sharepoint data |
35,727 | public function readFromFolder ( $ listName , $ folderName = '' , $ isLibrary = false , $ limit = NULL , $ query = NULL , $ view = NULL , $ sort = NULL ) { return $ this -> read ( $ listName , $ limit , $ query , $ view , $ sort , "<Folder>" . ( $ isLibrary ? '' : 'Lists/' ) . $ listName . '/' . $ folderName . "</Folde... | ReadFromFolder Uses raw CAML to query sharepoint data from a folder |
35,728 | public function deleteMultiple ( $ list_name , array $ IDs , array $ data = array ( ) ) { $ deletes = array ( ) ; foreach ( $ IDs as $ ID ) { $ delete = array ( 'ID' => $ ID ) ; if ( ! empty ( $ data [ $ ID ] ) ) { foreach ( $ data [ $ ID ] as $ key => $ value ) { $ delete [ $ key ] = $ value ; } } $ deletes [ ] = $ de... | DeleteMultiple Delete existing multiple list items . |
35,729 | public function addAttachment ( $ list_name , $ list_item_id , $ file_name ) { $ attachment = base64_encode ( file_get_contents ( $ file_name ) ) ; $ CAML = ' <AddAttachment xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>' . $ list_name . '</listName> <listItemID>' . $ list_item_id . '</listItemI... | addAttachment Add an attachment to a SharePoint List |
35,730 | public function deleteAttachment ( $ list_name , $ list_item_id , $ url ) { $ CAML = ' <DeleteAttachment xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>' . $ list_name . '</listName> <listItemID>' . $ list_item_id . '</listItemID> <url>' . $ url . '</url> </DeleteAttachment>' ; $ xmlvar = new ... | deleteAttachment Remove an attachment from a SharePoint list item |
35,731 | public function getAttachments ( $ list_name , $ list_item_id ) { $ CAML = ' <GetAttachmentCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <listName>' . $ list_name . '</listName> <listItemID>' . $ list_item_id . '</listItemID> </GetAttachmentCollection>' ; $ xmlvar = new \ SoapVar ( $ CAML , XS... | getAttachment Return an attachment from a SharePoint list item |
35,732 | private function getArrayFromElementsByTagName ( $ rawXml , $ tag , $ namespace = NULL ) { $ dom = new \ DOMDocument ( ) ; $ dom -> loadXML ( $ rawXml , ( LIBXML_VERSION >= 20900 ) ? LIBXML_PARSEHUGE : null ) ; if ( ! is_null ( $ namespace ) ) { $ nodes = $ dom -> getElementsByTagNameNS ( $ tag , $ namespace ) ; } else... | Getter for an array of nodes from given raw XML and tag name |
35,733 | private function whereXML ( array $ q ) { $ queryString = '' ; $ counter = 0 ; foreach ( $ q as $ col => $ value ) { $ counter ++ ; $ queryString .= '<Eq><FieldRef Name="' . $ col . '" /><Value Type="Text">' . htmlspecialchars ( $ value ) . '</Value></Eq>' ; if ( $ counter >= 2 ) { $ queryString = '<And>' . $ queryStri... | Query XML Generates XML for WHERE Query |
35,734 | private function sortXML ( array $ sort ) { if ( count ( $ sort ) == 0 ) { return '' ; } $ queryString = '' ; foreach ( $ sort as $ col => $ value ) { $ queryString .= '<FieldRef Name="' . $ col . '" Ascending="' . $ this -> getSortFromValue ( $ value ) . '" />' ; } return '<OrderBy>' . $ queryString . '</OrderBy>' ; } | Sort XML Generates XML for sort |
35,735 | public function modifyList ( $ list_name , array $ items , $ method , $ folderPath = null ) { $ commands = $ this -> prepBatch ( $ items , $ method ) ; $ rootFolderAttr = '' ; if ( $ folderPath != null && $ folderPath != '/' ) { $ sitePath = substr ( $ this -> spWsdl , 0 , strpos ( $ this -> spWsdl , '_vti_bin' ) ) ; $... | modifyList Perform an action on a sharePoint list to either update or add content to it . This method will use prepBatch to generate the batch xml then call the SharePoint SOAP API with this data to apply the changes . |
35,736 | public function prepBatch ( array $ items , $ method ) { assert ( in_array ( $ method , array ( 'New' , 'Update' , 'Delete' ) ) ) ; $ batch = '' ; $ counter = 1 ; foreach ( $ items as $ data ) { $ batch .= '<Method Cmd="' . $ method . '" ID="' . $ counter . '">' ; foreach ( $ data as $ itm => $ val ) { $ batch .= '<Fie... | prepBatch Convert an array of new items or change sets in to XML commands to be run on the sharepoint SOAP API . |
35,737 | private function onError ( \ SoapFault $ fault ) { $ more = '' ; if ( isset ( $ fault -> detail -> errorstring ) ) { $ more = 'Detailed: ' . $ fault -> detail -> errorstring ; } throw new \ Exception ( 'Error (' . $ fault -> faultcode . ') ' . $ fault -> faultstring . ',more=' . $ more ) ; } | onError This is called when sharepoint throws an error and displays basic debug info . |
35,738 | public function getFieldVersions ( $ list , $ id , $ field ) { $ CAML = ' <GetVersionCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/"> <strlistID>' . $ list . '</strlistID> <strlistItemID>' . $ id . '</strlistItemID> <strFieldName>' . $ field . '</strFieldName... | getFieldVersions Get previous versions of field contents |
35,739 | public function getVersions ( $ list , $ id , $ field = null ) { return $ this -> getFieldVersions ( $ list , $ id , $ field ) ; } | getVersions Get previous versions of a field |
35,740 | public function read ( $ limit = 0 , $ query = NULL , $ view = NULL , $ sort = NULL , $ options = NULL ) { return $ this -> api -> read ( $ this -> list_name , $ limit , $ query , $ view , $ sort , $ options ) ; } | Read Read items from List |
35,741 | public function sort ( $ sort_on , $ order = 'desc' ) { $ queryString = '<FieldRef Name="' . $ sort_on . '" Ascending="' . $ this -> api -> getSortFromValue ( $ order ) . '" />' ; $ this -> sort_caml = '<OrderBy>' . $ queryString . '</OrderBy>' ; return $ this ; } | Sort Specify order data should be returned in . |
35,742 | public function all_fields ( $ exclude_hidden = true ) { $ fields = $ this -> api -> readListMeta ( $ this -> list_name , $ exclude_hidden ) ; foreach ( $ fields as $ field ) { $ this -> fields [ ] = $ field [ 'name' ] ; } return $ this ; } | all_fields Attempt to include all fields row has within result |
35,743 | public function get ( $ options = NULL ) { $ view = ( sizeof ( $ this -> fields ) === 0 ) ? $ this -> view : $ this -> fields ; return $ this -> api -> read ( $ this -> list_name , $ this -> limit , $ this , $ view , NULL , $ this -> options ) ; } | get Runs the specified query and returns a usable result . |
35,744 | private function addQueryLine ( $ rel , $ col , $ test , $ value ) { if ( ! in_array ( $ test , array ( '!=' , '>=' , '<=' , '<' , '>' , '=' , 'like' ) ) ) { throw new \ Exception ( 'Unrecognized query parameter. Please use <,>,=,>=,<=, != or like' ) ; } $ rel = strtolower ( $ rel ) ; $ test = str_replace ( array ( '!=... | addQueryLine Generate CAML for where statements |
35,745 | public function getCAML ( ) { $ xml = '' ; if ( ! empty ( $ this -> where_caml ) ) { $ xml = '<Where>' . $ this -> where_caml . '</Where>' ; } if ( ! empty ( $ this -> sort_caml ) ) { $ xml .= $ this -> sort_caml ; } return $ xml ; } | getCAML Combine and return the raw CAML data for the query operation that has been specified . |
35,746 | public function getOptionCAML ( ) { $ xml = '' ; if ( sizeof ( $ this -> fields ) > 0 ) { $ xml .= $ this -> api -> viewFieldsXML ( $ this -> fields ) ; } if ( $ this -> view !== NULL ) $ xml .= '<viewName>' . $ this -> view . '</viewName>' ; return $ xml ; } | getOptionCAML Combine and return the raw CAML data for the request options |
35,747 | public function handle ( $ request , Closure $ next ) { Paginator :: currentPageResolver ( function ( ) { return app ( 'paginateroute' ) -> currentPage ( ) ; } ) ; return $ next ( $ request ) ; } | Set the current page based on the page route parameter before the route s action is executed . |
35,748 | public function currentPage ( ) { $ currentRoute = $ this -> router -> getCurrentRoute ( ) ; if ( ! $ currentRoute ) { return 1 ; } $ query = $ currentRoute -> parameter ( 'pageQuery' ) ; return ( int ) str_replace ( $ this -> pageKeyword . '/' , '' , $ query ) ? : 1 ; } | Return the current page . |
35,749 | public function nextPageUrl ( Paginator $ paginator ) { $ nextPage = $ this -> nextPage ( $ paginator ) ; if ( $ nextPage === null ) { return ; } return $ this -> pageUrl ( $ nextPage ) ; } | Get the next page URL . |
35,750 | public function previousPageUrl ( $ full = false ) { $ previousPage = $ this -> previousPage ( ) ; if ( $ previousPage === null ) { return ; } return $ this -> pageUrl ( $ previousPage , $ full ) ; } | Get the previous page URL . |
35,751 | public function allUrls ( LengthAwarePaginator $ paginator , $ full = false ) { if ( ! $ paginator -> hasPages ( ) ) { return [ ] ; } $ urls = [ ] ; $ left = $ this -> getLeftPoint ( $ paginator ) ; $ right = $ this -> getRightPoint ( $ paginator ) ; for ( $ page = $ left ; $ page <= $ right ; $ page ++ ) { $ urls [ $ ... | Get all urls in an array . |
35,752 | public function getLeftPoint ( LengthAwarePaginator $ paginator ) { $ side = $ paginator -> onEachSide ; $ current = $ paginator -> currentPage ( ) ; $ last = $ paginator -> lastPage ( ) ; if ( ! empty ( $ side ) ) { $ x = $ current + $ side ; $ offset = $ x >= $ last ? $ x - $ last : 0 ; $ left = $ current - $ side - ... | Get the left most point in the pagination element . |
35,753 | public function getRightPoint ( LengthAwarePaginator $ paginator ) { $ side = $ paginator -> onEachSide ; $ current = $ paginator -> currentPage ( ) ; $ last = $ paginator -> lastPage ( ) ; if ( ! empty ( $ side ) ) { $ offset = $ current <= $ side ? $ side - $ current + 1 : 0 ; $ right = $ current + $ side + $ offset ... | Get the right or last point of the pagination element . |
35,754 | public function renderPageList ( LengthAwarePaginator $ paginator , $ full = false , $ class = null , $ additionalLinks = false ) { $ urls = $ this -> allUrls ( $ paginator , $ full ) ; if ( $ class ) { $ class = " class=\"$class\"" ; } $ listItems = "<ul{$class}>" ; if ( $ this -> hasPreviousPage ( ) && $ additionalLi... | Render a plain html list with previous next and all urls . The current page gets a current class on the list item . |
35,755 | public function renderRelLinks ( LengthAwarePaginator $ paginator , $ full = false ) { $ urls = $ this -> allUrls ( $ paginator , $ full ) ; $ linkItems = '' ; foreach ( $ urls as $ i => $ url ) { $ pageNum = $ i + 1 ; switch ( $ pageNum - $ this -> currentPage ( ) ) { case - 1 : $ linkItems .= "<link rel=\"prev\" href... | Render html link tags for SEO indication of previous and next page . |
35,756 | public function pageUrl ( $ page , $ full = false ) { $ currentPageUrl = $ this -> router -> getCurrentRoute ( ) -> uri ( ) ; $ url = $ this -> addPageQuery ( str_replace ( '{pageQuery?}' , '' , $ currentPageUrl ) , $ page , $ full ) ; foreach ( ( new RouteParameterBinder ( $ this -> router -> getCurrentRoute ( ) ) ) -... | Generate a page URL based on the request s current URL . |
35,757 | public function addPageQuery ( $ url , $ page , $ full = false ) { if ( $ page === 1 && ! $ full ) { return $ url ; } return trim ( $ url , '/' ) . "/{$this->pageKeyword}/{$page}" ; } | Append the page query to a URL . |
35,758 | public function setVariable ( string $ name , $ value = null ) : self { $ this -> variables [ $ name ] = $ value ; return $ this ; } | Set an arbitrary variable . |
35,759 | public function getOpeningTag ( ) : string { $ attributes = [ ] ; foreach ( $ this -> attributes as $ name => $ value ) { $ attributes [ ] = self :: getHtmlAttribute ( $ name , $ value ) ; } $ attributes = implode ( ' ' , array_filter ( $ attributes ) ) ; return sprintf ( '<%s%s>' , $ this -> nodeName , $ attributes ==... | Returns the html code of the opening tag . |
35,760 | public function getClosingTag ( ) : ? string { if ( ! in_array ( $ this -> nodeName , self :: SELF_CLOSING_TAGS ) ) { return sprintf ( '</%s>' , $ this -> nodeName ) ; } return null ; } | Returns the html code of the closing tag . |
35,761 | private static function getHtmlAttribute ( string $ name , $ value ) : string { if ( ! self :: isset ( $ value ) ) { return '' ; } if ( $ value === true ) { return $ name ; } if ( is_array ( $ value ) ) { $ value = self :: convertAttributeArrayValue ( $ name , $ value ) ; } return sprintf ( '%s="%s"' , $ name , static ... | Creates a html attribute . |
35,762 | public function getTaggedUrls ( $ tag ) { $ sql = \ Craft :: $ app -> getDb ( ) -> getIsMysql ( ) ? "SELECT uid, url FROM %s WHERE MATCH(tags) AGAINST (%s IN BOOLEAN MODE)" : "SELECT uid, url FROM %s WHERE tags @> (ARRAY[%s]::varchar[])" ; $ sql = sprintf ( $ sql , \ Craft :: $ app -> getDb ( ) -> quoteTableName ( Plug... | Get cached urls by given tag |
35,763 | protected function afterInstall ( ) { $ configSourceFile = __DIR__ . DIRECTORY_SEPARATOR . 'config.example.php' ; $ configTargetFile = \ Craft :: $ app -> getConfig ( ) -> configDir . DIRECTORY_SEPARATOR . $ this -> handle . '.php' ; if ( ! file_exists ( $ configTargetFile ) ) { copy ( $ configSourceFile , $ configTarg... | Is called after the plugin is installed . Copies example config to project s config folder |
35,764 | public function purgeUrls ( array $ urls ) { if ( strpos ( $ this -> domain , 'http' ) === false ) { throw new \ InvalidArgumentException ( "'domain' is not configured for fastly driver" ) ; } if ( strpos ( $ this -> domain , 'http' ) !== 0 ) { throw new \ InvalidArgumentException ( "'domain' must include the protocol,... | Purge cache by urls |
35,765 | protected function sendRequest ( string $ method = 'PURGE' , string $ uri , array $ headers = [ ] ) { $ client = new Client ( [ 'base_uri' => self :: API_ENDPOINT , 'headers' => array_merge ( $ headers , [ 'Content-Type' => 'application/json' , 'Fastly-Key' => $ this -> apiToken ] ) ] ) ; if ( in_array ( $ method , [ '... | Send API call |
35,766 | public function getKeyPrefix ( ) { if ( ! $ this -> keyPrefix ) { return '' ; } $ clean = Inflector :: slug ( $ this -> keyPrefix ) ; return substr ( $ clean , 0 , 8 ) ; } | Get key prefix . To prevent key collision if you use the same cache server for several Craft installations . |
35,767 | public function removeCacheControlDirective ( string $ key ) { unset ( $ this -> cacheControl [ $ key ] ) ; $ this -> owner -> getHeaders ( ) -> set ( 'Cache-Control' , $ this -> getCacheControlHeader ( ) ) ; } | Removes a Cache - Control directive . |
35,768 | public static function fromJsonError ( int $ jsonError , $ failedValue ) : self { return new static ( static :: getExceptionMessage ( $ jsonError ) , $ jsonError , null , $ failedValue ) ; } | Creates a new exception object based on the JSON error code . |
35,769 | public static function fromJson ( string $ json ) : self { if ( empty ( $ json ) ) { throw new JsonParseException ( 'An empty string is not a valid JSON value' , JSON_ERROR_SYNTAX , null , $ json ) ; } $ parsed = json_decode ( $ json , true ) ; $ lastError = json_last_error ( ) ; if ( \ JSON_ERROR_NONE !== $ lastError ... | Parses a JSON string into a Problem object . |
35,770 | protected static function xmlToArray ( \ SimpleXMLElement $ element ) : array { $ data = ( array ) $ element ; foreach ( $ data as $ key => $ value ) { if ( $ value instanceof \ SimpleXMLElement ) { $ data [ $ key ] = static :: xmlToArray ( $ value ) ; } } return $ data ; } | Converts a SimpleXMLElement to a nested array . |
35,771 | public static function fromXml ( string $ string ) : self { $ xml = new \ SimpleXMLElement ( $ string ) ; $ data = static :: xmlToArray ( $ xml ) ; return static :: decompile ( $ data ) ; } | Parses an XML string into a Problem object . |
35,772 | protected static function decompile ( array $ parsed ) : self { $ problem = new static ( ) ; if ( ! empty ( $ parsed [ 'title' ] ) ) { $ problem -> setTitle ( $ parsed [ 'title' ] ) ; } if ( ! empty ( $ parsed [ 'type' ] ) ) { $ problem -> setType ( $ parsed [ 'type' ] ) ; } if ( ! empty ( $ parsed [ 'status' ] ) ) { $... | Decompiles an array into an ApiProblem object . |
35,773 | public function asJson ( bool $ pretty = false ) : string { $ response = $ this -> compile ( ) ; $ options = 0 ; if ( $ pretty ) { $ options = \ JSON_UNESCAPED_SLASHES | \ JSON_PRETTY_PRINT ; } $ json = json_encode ( $ response , $ options ) ; if ( false === $ json ) { throw JsonEncodeException :: fromJsonError ( \ jso... | Renders this problem as JSON . |
35,774 | public function asXml ( bool $ pretty = false ) { $ doc = new \ SimpleXMLElement ( '<problem></problem>' ) ; $ this -> arrayToXml ( $ this -> compile ( ) , $ doc ) ; $ dom = dom_import_simplexml ( $ doc ) ; if ( $ pretty ) { $ dom -> ownerDocument -> preserveWhiteSpace = false ; $ dom -> ownerDocument -> formatOutput =... | Renders this problem as XML . |
35,775 | protected function compile ( ) : array { $ response = $ this -> extensions ; foreach ( [ 'title' , 'type' , 'status' , 'detail' , 'instance' ] as $ key ) { if ( ! empty ( $ this -> $ key ) ) { $ response [ $ key ] = $ this -> $ key ; } } return $ response ; } | Compiles the object down to an array format suitable for serializing . |
35,776 | public function toJsonResponse ( ApiProblem $ problem ) : ResponseInterface { $ response = $ this -> toResponse ( $ problem ) ; $ body = $ response -> getBody ( ) ; $ body -> write ( $ problem -> asJson ( $ this -> pretty ) ) ; $ body -> rewind ( ) ; return $ response -> withHeader ( 'Content-Type' , ApiProblem :: CONT... | Converts a problem to a JSON HTTP Response object provided . |
35,777 | public function toXmlResponse ( ApiProblem $ problem ) : ResponseInterface { $ response = $ this -> toResponse ( $ problem ) ; $ body = $ response -> getBody ( ) ; $ body -> write ( $ problem -> asXml ( $ this -> pretty ) ) ; $ body -> rewind ( ) ; return $ this -> toResponse ( $ problem ) -> withHeader ( 'Content-Type... | Converts a problem to an XML HTTP Response object provided . |
35,778 | protected function toResponse ( ApiProblem $ problem ) : ResponseInterface { $ status = $ problem -> getStatus ( ) ? : 500 ; $ response = $ this -> responseFactory -> createResponse ( $ status ) ; return $ response ; } | Converts a problem to a provided Response without the format - sensitive bits . |
35,779 | public function isPrestashopVersionSupported ( $ version ) { if ( version_compare ( $ version , self :: PS_COMPATIBLE_VERSION_MIN , '>=' ) === false || version_compare ( $ version , self :: PS_COMPATIBLE_VERSION_MAX , '<=' ) === false ) { $ exception = 'This library is not compatible with this version of PrestaShop. ' ... | Throws exception if prestashop version is not supported |
35,780 | protected function executeCurl ( $ url , array $ options = array ( ) ) { $ session = curl_init ( $ url ) ; if ( count ( $ options ) ) { curl_setopt_array ( $ session , $ options ) ; } $ response = curl_exec ( $ session ) ; $ error = false ; $ info = curl_getinfo ( $ session ) ; if ( $ response === false ) { $ error = c... | Executes the CURL request to PrestaShop WebService . |
35,781 | public function fillSchema ( SimpleXMLElement $ xmlSchema , $ data , $ removeUselessNodes = true , $ removeSpecificNodes = array ( ) ) { $ resource = $ xmlSchema -> children ( ) -> children ( ) ; foreach ( $ data as $ key => $ value ) { $ this -> processNode ( $ resource , $ key , $ value ) ; } if ( $ removeUselessNode... | Fill the provided schema with an associative array data also remove the useless XML nodes if the corresponding flag is true |
35,782 | private function checkForUselessNodes ( SimpleXMLElement $ resource , $ data ) { $ uselessNodes = [ ] ; foreach ( $ resource as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ data ) ) { $ uselessNodes [ ] = $ key ; } } foreach ( $ uselessNodes as $ key ) { unset ( $ resource -> $ key ) ; } } | Remove XML first level nodes that are not present int the data array |
35,783 | public function getChannel ( $ connection ) { if ( isset ( $ this -> channels [ $ connection ] ) ) { return $ this -> channels [ $ connection ] ; } if ( ! isset ( $ this -> connections [ $ connection ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown connection "%s". Available: [%s]' , $ connection , imp... | Return the AMQPChannel of the given connection . |
35,784 | private function parseUrl ( string $ url ) : array { $ parts = parse_url ( $ url ) ; if ( $ parts === false || ! isset ( $ parts [ 'host' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid connection URL given: "%s"' , $ url ) ) ; } $ params = [ 'login' => $ parts [ 'user' ] ?? '' , 'password' => $ parts... | Parse a RabbitMQ URI into its components . |
35,785 | public function set_line_style ( $ style1 , $ style2 = '' , $ preserve_defaults = false ) { if ( is_bool ( $ style2 ) ) { $ preserve_defaults = $ style2 ; $ style2 = '' ; } if ( ! $ preserve_defaults ) { $ this -> line_style1 = $ style1 ; $ this -> line_style2 = $ style2 ; } else { $ this -> line_style1 .= $ style1 ; $... | Sets the styles for the line numbers . |
35,786 | public function set_tab_width ( $ width ) { $ this -> tab_width = intval ( $ width ) ; if ( $ this -> tab_width < 1 ) { $ this -> tab_width = 8 ; } } | Sets how many spaces a tab is substituted for |
35,787 | public function get_real_tab_width ( ) { if ( ! $ this -> use_language_tab_width || ! isset ( $ this -> language_data [ 'TAB_WIDTH' ] ) ) { return $ this -> tab_width ; } else { return $ this -> language_data [ 'TAB_WIDTH' ] ; } } | Returns the tab width to use based on the current language and user preference |
35,788 | public function add_keyword ( $ key , $ word ) { if ( ! is_array ( $ this -> language_data [ 'KEYWORDS' ] [ $ key ] ) ) { $ this -> language_data [ 'KEYWORDS' ] [ $ key ] = array ( ) ; } if ( ! in_array ( $ word , $ this -> language_data [ 'KEYWORDS' ] [ $ key ] ) ) { $ this -> language_data [ 'KEYWORDS' ] [ $ key ] [ ... | Adds a keyword to a keyword group for highlighting |
35,789 | public function remove_keyword_group ( $ key ) { unset ( $ this -> language_data [ 'KEYWORDS' ] [ $ key ] ) ; unset ( $ this -> lexic_permissions [ 'KEYWORDS' ] [ $ key ] ) ; unset ( $ this -> language_data [ 'CASE_SENSITIVE' ] [ $ key ] ) ; unset ( $ this -> language_data [ 'STYLES' ] [ 'KEYWORDS' ] [ $ key ] ) ; unse... | Removes a keyword group |
35,790 | protected function set_time ( $ start_time , $ end_time ) { $ start = explode ( ' ' , $ start_time ) ; $ end = explode ( ' ' , $ end_time ) ; $ this -> time = $ end [ 0 ] + $ end [ 1 ] - $ start [ 0 ] - $ start [ 1 ] ; } | Sets the time taken to parse the code |
35,791 | protected function merge_arrays ( ) { $ arrays = func_get_args ( ) ; $ narrays = count ( $ arrays ) ; for ( $ i = 0 ; $ i < $ narrays ; $ i ++ ) { if ( ! is_array ( $ arrays [ $ i ] ) ) { trigger_error ( 'Argument #' . ( $ i + 1 ) . ' is not an array - trying to merge array with scalar! Returning false!' , E_USER_WARNI... | Merges arrays recursively overwriting values of the first array with values of later arrays |
35,792 | public function run ( ) { $ parser = $ this -> createParser ( ) ; try { $ result = $ parser -> parse ( ) ; $ file = $ result -> args [ 'infile' ] ; $ format = $ result -> options [ 'format' ] ; $ css = $ result -> options [ 'css' ] ; if ( $ format == '' ) { $ format = $ this -> detectFormat ( $ file ) ; } $ geshi = new... | Runs the script and outputs highlighted code . |
35,793 | protected function createParser ( ) { $ geshi = new GeSHi ( ) ; $ parser = new Console_CommandLine ( ) ; $ parser -> description = 'CLI interface to GeSHi, the generic syntax highlighter' ; $ parser -> version = '0.1.0' ; $ parser -> addOption ( 'css' , array ( 'long_name' => '--css' , 'description' => 'Use CSS classes... | Creates the command line parser and populates it with all allowed options and parameters . |
35,794 | public function getFilePath ( ) { if ( ! $ this -> filePath ) { $ path = sprintf ( storage_path ( 'logs/%s' ) , $ this -> file ) ; if ( ! file_exists ( $ path ) ) { throw new \ Exception ( 'log not exists!' ) ; } $ this -> filePath = $ path ; } return $ this -> filePath ; } | Get file path by giving log file name . |
35,795 | public function fetch ( $ seek = 0 , $ lines = 20 , $ buffer = 4096 ) { $ f = fopen ( $ this -> filePath , 'rb' ) ; if ( $ seek ) { fseek ( $ f , abs ( $ seek ) ) ; } else { fseek ( $ f , 0 , SEEK_END ) ; } if ( fread ( $ f , 1 ) != "\n" ) { $ lines -= 1 ; } fseek ( $ f , - 1 , SEEK_CUR ) ; if ( $ seek > 0 ) { $ output... | Fetch logs by giving offset . |
35,796 | protected function parseLog ( $ raw ) { $ logs = preg_split ( '/\[(\d{4}(?:-\d{2}){2} \d{2}(?::\d{2}){2})\] (\w+)\.(\w+):((?:(?!{"exception").)*)?/' , trim ( $ raw ) , - 1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; foreach ( $ logs as $ index => $ log ) { if ( preg_match ( '/^\d{4}/' , $ log ) ) { break ; } e... | Parse raw log text to array . |
35,797 | public static function taskFileLoad ( ) { if ( file_exists ( self :: $ data_file ) ) { $ data = file_get_contents ( self :: $ data_file ) ; $ data = unserialize ( $ data ) ; } if ( empty ( $ data ) ) { $ data = array ( ) ; } return $ data ; } | Reads file from disk and returns array of tasks |
35,798 | public static function taskGet ( $ task_id ) { $ tasks = self :: taskFileLoad ( ) ; if ( isset ( $ tasks [ $ task_id ] ) ) { return $ tasks [ $ task_id ] ; } return false ; } | Returns tasks with given id |
35,799 | public static function find ( $ task_ids ) { if ( ! is_array ( $ task_ids ) ) { $ task_ids = array ( $ task_ids ) ; } $ tasks = self :: getAll ( ) ; foreach ( $ tasks as $ key => $ task ) { if ( ! in_array ( $ task -> task_id , $ task_ids ) ) { unset ( $ tasks [ $ key ] ) ; } } return $ tasks ; } | Returns array of tasks with specified ids |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.