idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
36,100 | public function get_items ( $ request ) { $ data = array ( ) ; foreach ( get_post_types ( array ( ) , 'object' ) as $ obj ) { if ( empty ( $ obj -> show_in_rest ) || ( 'edit' === $ request [ 'context' ] && ! current_user_can ( $ obj -> cap -> edit_posts ) ) ) { continue ; } $ post_type = $ this -> prepare_item_for_resp... | Get all public post types |
36,101 | public function get_item ( $ request ) { $ obj = get_post_type_object ( $ request [ 'type' ] ) ; if ( empty ( $ obj ) ) { return new WP_Error ( 'rest_type_invalid' , __ ( 'Invalid resource.' ) , array ( 'status' => 404 ) ) ; } if ( empty ( $ obj -> show_in_rest ) ) { return new WP_Error ( 'rest_cannot_read_type' , __ (... | Get a specific post type |
36,102 | public function prepare_item_for_response ( $ post_type , $ request ) { $ data = array ( 'capabilities' => $ post_type -> cap , 'description' => $ post_type -> description , 'hierarchical' => $ post_type -> hierarchical , 'labels' => $ post_type -> labels , 'name' => $ post_type -> label , 'slug' => $ post_type -> name... | Prepare a post type object for serialization |
36,103 | public function get_item_schema ( ) { $ schema = array ( '$schema' => 'http://json-schema.org/draft-04/schema#' , 'title' => 'type' , 'type' => 'object' , 'properties' => array ( 'capabilities' => array ( 'description' => __ ( 'All capabilities used by the resource.' ) , 'type' => 'array' , 'context' => array ( 'edit' ... | Get the Post type s schema conforming to JSON Schema |
36,104 | public static function findDirtyParam ( $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ opener = $ phpcsFile -> findNext ( T_OPEN_PARENTHESIS , $ stackPtr , null , false , null , true ) ; $ closer = $ tokens [ $ opener ] [ 'parenthesis_closer' ] ; $ s = $ opener + 1 ; $ s = $ phpcsFile -> findN... | Returns a dirty param found in the parameter of a function call |
36,105 | protected function getTagName ( $ node ) { if ( isset ( $ node -> tagName ) ) { return $ node -> tagName ; } else if ( isset ( $ node -> nodeName ) ) { return $ node -> nodeName ; } else if ( isset ( $ node -> localName ) ) { return $ node -> localName ; } return null ; } | Portably retrieve the tag name of a node ; deals with older versions of libxml like 2 . 7 . 6 |
36,106 | protected function getData ( $ node ) { if ( isset ( $ node -> data ) ) { return $ node -> data ; } else if ( isset ( $ node -> nodeValue ) ) { return $ node -> nodeValue ; } else if ( isset ( $ node -> textContent ) ) { return $ node -> textContent ; } return null ; } | Portably retrieve the data of a node ; deals with older versions of libxml like 2 . 7 . 6 |
36,107 | public function transformToHTML ( $ xml ) { if ( is_string ( $ xml ) ) { $ dom = new DOMDocument ( ) ; $ dom -> load ( $ xml ) ; } else { $ dom = $ xml ; } $ out = $ this -> xsltProcessor -> transformToXML ( $ dom ) ; $ out = str_replace ( '/>' , ' />' , $ out ) ; $ out = str_replace ( ' xmlns=""' , '' , $ out ) ; if (... | Transforms an XML file into compatible XHTML based on the stylesheet |
36,108 | public function setParameters ( $ options ) { foreach ( $ options as $ name => $ value ) { $ this -> xsltProcessor -> setParameter ( '' , $ name , $ value ) ; } } | Bulk sets parameters for the XSL stylesheet |
36,109 | public function open ( $ mode ) { if ( $ this -> handle ) $ this -> close ( ) ; $ this -> handle = $ this -> fs -> fopen ( $ this -> name , $ mode ) ; return true ; } | Opens file s handle |
36,110 | public function close ( ) { if ( ! $ this -> handle ) return false ; $ status = $ this -> fs -> fclose ( $ this -> handle ) ; $ this -> handle = false ; return $ status ; } | Closes file s handle |
36,111 | public function getChar ( ) { if ( ! $ this -> handle ) $ this -> open ( 'r' ) ; return $ this -> fs -> fgetc ( $ this -> handle ) ; } | Retrieves a character from an open file |
36,112 | public function put ( $ string ) { if ( ! $ this -> handle ) $ this -> open ( 'a' ) ; return $ this -> fs -> fwrite ( $ this -> handle , $ string ) ; } | Writes to an open file |
36,113 | public function mkdirr ( $ folder ) { $ folders = preg_split ( "#[\\\\/]#" , $ folder ) ; $ base = '' ; for ( $ i = 0 , $ c = count ( $ folders ) ; $ i < $ c ; $ i ++ ) { if ( empty ( $ folders [ $ i ] ) ) { if ( ! $ i ) { $ base .= DIRECTORY_SEPARATOR ; } continue ; } $ base .= $ folders [ $ i ] ; if ( ! is_dir ( $ ba... | Recursively creates a directory |
36,114 | public function copyr ( $ source , $ dest ) { if ( is_file ( $ source ) ) { return $ this -> copy ( $ source , $ dest ) ; } if ( ! is_dir ( $ dest ) ) { $ this -> mkdir ( $ dest ) ; } $ dir = $ this -> dir ( $ source ) ; while ( false !== ( $ entry = $ dir -> read ( ) ) ) { if ( $ entry == '.' || $ entry == '..' ) { co... | Copy a file or recursively copy a folder and its contents ; modified so that copied files if PHP have includes removed |
36,115 | public function rmdirr ( $ dirname ) { if ( ! $ this -> file_exists ( $ dirname ) ) { return false ; } if ( $ this -> is_file ( $ dirname ) || $ this -> is_link ( $ dirname ) ) { return $ this -> unlink ( $ dirname ) ; } $ dir = $ this -> dir ( $ dirname ) ; while ( false !== $ entry = $ dir -> read ( ) ) { if ( $ entr... | Delete a file or a folder and its contents |
36,116 | public function globr ( $ dir , $ pattern , $ flags = NULL ) { $ files = $ this -> glob ( "$dir/$pattern" , $ flags ) ; if ( $ files === false ) $ files = array ( ) ; $ sub_dirs = $ this -> glob ( "$dir/*" , GLOB_ONLYDIR ) ; if ( $ sub_dirs === false ) $ sub_dirs = array ( ) ; foreach ( $ sub_dirs as $ sub_dir ) { $ su... | Recursively globs a directory . |
36,117 | public function getBuilder ( $ model ) { $ builder = isset ( $ this -> builder -> constraints ) ? $ this -> builder -> constraints : $ model -> newQuery ( ) ; $ builder = $ this -> handleSoftDeletes ( $ builder , $ model ) ; $ builder = $ this -> applyWheres ( $ builder ) ; $ builder = $ this -> applyOrders ( $ builder... | Return query builder either from given constraints or as new query . Add where statements to builder when given . |
36,118 | private function handleSoftDeletes ( $ builder , $ model ) { if ( ! $ this -> usesSoftDelete ( $ model ) || ! config ( 'scout.soft_delete' , true ) ) { unset ( $ this -> builder -> wheres [ '__soft_deleted' ] ) ; return $ builder ; } if ( ! in_array ( '__soft_deleted' , $ this -> builder -> wheres ) ) { return $ builde... | Determine if soft delete is active and depending on state return the appropriate builder . |
36,119 | private function applyWheres ( $ builder ) { return collect ( $ this -> builder -> wheres ) -> map ( function ( $ value , $ key ) { return [ $ key , $ value ] ; } ) -> reduce ( function ( $ builder , $ where ) { list ( $ key , $ value ) = $ where ; return $ builder -> where ( $ key , $ value ) ; } , $ builder ) ; } | Apply where statements as constraints to the query builder . |
36,120 | private function applyOrders ( $ builder ) { return collect ( $ this -> builder -> orders ) -> map ( function ( $ value , $ key ) { return [ $ value [ "column" ] , $ value [ "direction" ] ] ; } ) -> reduce ( function ( $ builder , $ orderBy ) { list ( $ column , $ direction ) = $ orderBy ; return $ builder -> orderBy (... | Apply order by statements as constraints to the query builder . |
36,121 | public static function getValidHooks ( $ dir ) { $ composerFile = "{$dir}/composer.json" ; if ( ! file_exists ( $ composerFile ) ) { return [ ] ; } $ contents = file_get_contents ( $ composerFile ) ; $ json = json_decode ( $ contents , true ) ; $ hooks = array_merge ( isset ( $ json [ 'scripts' ] ) ? $ json [ 'scripts'... | Get scripts section of the composer config file . |
36,122 | public function on ( $ connection = null ) { $ this -> schemas = new SchemaManager ( $ this -> db -> connection ( $ connection ) ) ; return $ this ; } | Select connection to work with . |
36,123 | private function formatUsedClasses ( $ baseNamespace , $ usedClasses ) { $ result = [ ] ; foreach ( $ usedClasses as $ usedClass ) { $ namespacePattern = str_replace ( '\\' , '\\\\' , "/{$baseNamespace}\\[a-zA-Z0-9_]*/" ) ; if ( ! preg_match ( $ namespacePattern , $ usedClass ) ) { $ result [ ] = "use {$usedClass};" ; ... | Returns imports section for model . |
36,124 | private function extractUsedClasses ( & $ placeholder ) { $ classNamespaceRegExp = '/([\\\\a-zA-Z0-9_]*\\\\[\\\\a-zA-Z0-9_]*)/' ; $ matches = [ ] ; $ usedInModelClasses = [ ] ; if ( preg_match_all ( $ classNamespaceRegExp , $ placeholder , $ matches ) ) { foreach ( $ matches [ 1 ] as $ match ) { $ usedClassName = $ mat... | Extract and replace fully - qualified class names from placeholder . |
36,125 | protected function wrap ( $ table ) { $ pieces = explode ( '.' , str_replace ( '`' , '' , $ table ) ) ; return implode ( '.' , array_map ( function ( $ piece ) { return "`$piece`" ; } , $ pieces ) ) ; } | Wrap within backticks . |
36,126 | public function field ( $ name , $ value , $ options = [ ] ) { $ value = Dumper :: export ( $ value ) ; $ before = Arr :: get ( $ options , 'before' , '' ) ; $ visibility = Arr :: get ( $ options , 'visibility' , 'protected' ) ; $ after = Arr :: get ( $ options , 'after' , "\n" ) ; return "$before\t$visibility \$$name ... | Field template . |
36,127 | public function boot ( ) { if ( ! $ this -> hasMapping ( ) ) { throw new RuntimeException ( "There is no Schema Mapper registered for [{$this->type()}] connection." ) ; } $ schemas = forward_static_call ( [ $ this -> getMapper ( ) , 'schemas' ] , $ this -> connection ) ; foreach ( $ schemas as $ schema ) { $ this -> ma... | Load all schemas from this connection . |
36,128 | protected function fill ( ) { $ this -> primaryKeys = $ this -> blueprint -> primaryKey ( ) ; foreach ( $ this -> blueprint -> columns ( ) as $ column ) { $ this -> parseColumn ( $ column ) ; } if ( ! $ this -> loadRelations ) { return ; } foreach ( $ this -> blueprint -> relations ( ) as $ relation ) { $ model = $ thi... | Parses the model information . |
36,129 | protected function registerModelFactory ( ) { $ this -> app -> singleton ( ModelFactory :: class , function ( $ app ) { return new ModelFactory ( $ app -> make ( 'db' ) , $ app -> make ( Filesystem :: class ) , new Classify ( ) , new Config ( $ app -> make ( 'config' ) -> get ( 'models' ) ) ) ; } ) ; } | Register Model Factory . |
36,130 | protected function createFilesystem ( AdapterInterface $ adapter , array $ config ) { $ cache = Arr :: pull ( $ config , 'cache' ) ; $ config = Arr :: only ( $ config , [ 'visibility' , 'disable_asserts' , 'url' ] ) ; if ( $ cache ) { $ adapter = new CachedAdapter ( $ adapter , $ this -> createCacheStore ( $ cache ) ) ... | Create a Filesystem instance with the given adapter . |
36,131 | private function createClient ( $ config ) { $ keyFile = array_get ( $ config , 'key_file' ) ; if ( is_string ( $ keyFile ) ) { return new StorageClient ( [ 'projectId' => $ config [ 'project_id' ] , 'keyFilePath' => $ keyFile , ] ) ; } if ( ! is_array ( $ keyFile ) ) { $ keyFile = [ ] ; } return new StorageClient ( [ ... | Create a new StorageClient |
36,132 | protected function prepareRowOptions ( $ index , $ item ) { if ( is_callable ( $ this -> rowOptions ) ) { $ options = call_user_func ( $ this -> rowOptions , $ item , $ index , $ this -> context ) ; } else { $ options = $ this -> rowOptions ; } Html :: addCssClass ( $ options , 'multiple-input-list__item' ) ; return $ ... | Prepares the row options . |
36,133 | private function renderCloneColumn ( ) { $ options = [ 'class' => 'list-cell__button' ] ; $ layoutConfig = array_merge ( [ 'buttonCloneClass' => $ this -> isBootstrapTheme ( ) ? 'col-sm-offset-0 col-sm-1' : '' , ] , $ this -> layoutConfig ) ; Html :: addCssClass ( $ options , $ layoutConfig [ 'buttonCloneClass' ] ) ; r... | Renders the clone column . |
36,134 | private function renderRemoveButton ( ) { $ options = [ 'class' => 'multiple-input-list__btn js-input-remove' , ] ; Html :: addCssClass ( $ options , $ this -> removeButtonOptions [ 'class' ] ) ; return Html :: tag ( 'div' , $ this -> removeButtonOptions [ 'label' ] , $ options ) ; } | Renders remove button . |
36,135 | private function renderCloneButton ( ) { $ options = [ 'class' => 'multiple-input-list__btn js-input-clone' , ] ; Html :: addCssClass ( $ options , $ this -> cloneButtonOptions [ 'class' ] ) ; return Html :: tag ( 'div' , $ this -> cloneButtonOptions [ 'label' ] , $ options ) ; } | Renders clone button . |
36,136 | protected function getExtraButtons ( $ index , $ item ) { if ( ! $ this -> extraButtons ) { return '' ; } if ( is_callable ( $ this -> extraButtons ) ) { $ content = call_user_func ( $ this -> extraButtons , $ item , $ index , $ this -> context ) ; } else { $ content = $ this -> extraButtons ; } if ( ! is_string ( $ co... | Render extra content in action column . |
36,137 | protected function prepareJsAttributes ( ) { $ attributes = [ ] ; foreach ( $ this -> columns as $ column ) { $ model = $ column -> getModel ( ) ; $ inputID = str_replace ( [ '-0' , '-0-' ] , '' , $ column -> getElementId ( 0 ) ) ; if ( $ this -> form instanceof ActiveForm && $ model instanceof Model ) { $ field = $ th... | Prepares attributes options for client side . |
36,138 | protected function prepareValue ( $ contextParams = [ ] ) { $ data = $ this -> getModel ( ) ; if ( $ this -> value instanceof \ Closure ) { $ value = call_user_func ( $ this -> value , $ data , $ contextParams ) ; } else { $ value = null ; if ( $ data instanceof ActiveRecordInterface ) { $ relation = $ data -> getRelat... | Prepares the value of column . |
36,139 | public function renderInput ( $ name , $ options , $ contextParams = [ ] ) { if ( $ this -> options instanceof \ Closure ) { $ optionsExt = call_user_func ( $ this -> options , $ this -> getModel ( ) ) ; } else { $ optionsExt = $ this -> options ; } $ options = ArrayHelper :: merge ( $ options , $ optionsExt ) ; $ meth... | Renders the input . |
36,140 | protected function renderDropDownList ( $ name , $ value , $ options ) { if ( $ this -> renderer -> isBootstrapTheme ( ) ) { Html :: addCssClass ( $ options , 'form-control' ) ; } $ options [ 'tabindex' ] = self :: TABINDEX ; return Html :: dropDownList ( $ name , $ value , $ this -> prepareItems ( $ this -> items ) , ... | Renders drop down list . |
36,141 | protected function renderListBox ( $ name , $ value , $ options ) { if ( $ this -> renderer -> isBootstrapTheme ( ) ) { Html :: addCssClass ( $ options , 'form-control' ) ; } $ options [ 'tabindex' ] = self :: TABINDEX ; return Html :: listBox ( $ name , $ value , $ this -> prepareItems ( $ this -> items ) , $ options ... | Renders list box . |
36,142 | protected function renderRadio ( $ name , $ value , $ options ) { $ options [ 'tabindex' ] = self :: TABINDEX ; if ( ! isset ( $ options [ 'label' ] ) ) { $ options [ 'label' ] = '' ; } if ( ! array_key_exists ( 'uncheck' , $ options ) ) { $ options [ 'uncheck' ] = 0 ; } $ input = Html :: radio ( $ name , $ value , $ o... | Renders radio button . |
36,143 | protected function renderRadioList ( $ name , $ value , $ options ) { $ options [ 'tabindex' ] = self :: TABINDEX ; if ( ! array_key_exists ( 'unselect' , $ options ) ) { $ options [ 'unselect' ] = '' ; } $ options [ 'item' ] = function ( $ index , $ label , $ name , $ checked , $ value ) use ( $ options ) { $ content ... | Renders radio button list . |
36,144 | protected function renderCheckbox ( $ name , $ value , $ options ) { $ options [ 'tabindex' ] = self :: TABINDEX ; if ( ! isset ( $ options [ 'label' ] ) ) { $ options [ 'label' ] = '' ; } if ( ! array_key_exists ( 'uncheck' , $ options ) ) { $ options [ 'uncheck' ] = 0 ; } $ input = Html :: checkbox ( $ name , $ value... | Renders checkbox . |
36,145 | protected function renderCheckboxList ( $ name , $ value , $ options ) { $ options [ 'tabindex' ] = self :: TABINDEX ; if ( ! array_key_exists ( 'unselect' , $ options ) ) { $ options [ 'unselect' ] = '' ; } $ options [ 'item' ] = function ( $ index , $ label , $ name , $ checked , $ value ) use ( $ options ) { $ conte... | Renders checkbox list . |
36,146 | protected function renderStatic ( $ name , $ value , $ options ) { $ options [ 'tabindex' ] = self :: TABINDEX ; if ( $ this -> renderer -> isBootstrapTheme ( ) ) { Html :: addCssClass ( $ options , 'form-control-static' ) ; } return Html :: tag ( 'p' , $ value , $ options ) ; } | Renders a text . |
36,147 | protected function renderDragColumn ( $ name , $ value , $ options ) { $ class = '' ; if ( array_key_exists ( 'class' , $ options ) ) { $ class = ArrayHelper :: remove ( $ options , 'class' ) ; } $ dragClass = implode ( ' ' , [ $ class , 'drag-handle' ] ) ; return Html :: tag ( 'span' , null , [ 'class' => $ dragClass ... | Renders a drag&drop column . |
36,148 | protected function renderDefault ( $ name , $ value , $ options ) { $ type = $ this -> type ; if ( method_exists ( 'yii\helpers\Html' , $ type ) ) { $ options [ 'tabindex' ] = self :: TABINDEX ; if ( $ this -> renderer -> isBootstrapTheme ( ) ) { Html :: addCssClass ( $ options , 'form-control' ) ; } $ input = Html :: ... | Renders an input . |
36,149 | protected function renderWidget ( $ type , $ name , $ value , $ options ) { unset ( $ options [ 'tabindex' ] ) ; $ model = $ this -> getModel ( ) ; if ( $ model instanceof Model ) { $ widgetOptions = [ 'model' => $ model , 'attribute' => $ this -> name , 'value' => $ value , 'options' => [ 'id' => $ this -> normalize (... | Renders a widget . |
36,150 | public function renderError ( $ error ) { $ options = $ this -> errorOptions ; $ tag = isset ( $ options [ 'tag' ] ) ? $ options [ 'tag' ] : 'div' ; $ encode = ! isset ( $ options [ 'encode' ] ) || $ options [ 'encode' ] !== false ; unset ( $ options [ 'tag' ] , $ options [ 'encode' ] ) ; return Html :: tag ( $ tag , $... | Renders an error . |
36,151 | public function validatePhones ( $ attribute ) { $ items = $ this -> $ attribute ; if ( ! is_array ( $ items ) ) { $ items = [ ] ; } $ multiple = true ; if ( ! is_array ( $ items ) ) { $ multiple = false ; $ items = ( array ) $ items ; } foreach ( $ items as $ index => $ item ) { $ validator = new NumberValidator ( ) ;... | Phone number validation |
36,152 | public function validateEmails ( $ attribute ) { $ items = $ this -> $ attribute ; if ( ! is_array ( $ items ) ) { $ items = [ ] ; } foreach ( $ items as $ index => $ item ) { $ validator = new EmailValidator ( ) ; $ error = null ; $ validator -> validate ( $ item , $ error ) ; if ( ! empty ( $ error ) ) { $ key = $ at... | Email validation . |
36,153 | protected function initData ( ) { if ( $ this -> data !== null ) { return ; } if ( $ this -> value !== null ) { $ this -> data = $ this -> value ; return ; } if ( $ this -> model instanceof Model ) { $ data = ( $ this -> model -> hasProperty ( $ this -> attribute ) || isset ( $ this -> model -> { $ this -> attribute } ... | Initializes data . |
36,154 | protected function renderBody ( ) { $ rows = [ ] ; if ( $ this -> data ) { $ j = 0 ; foreach ( $ this -> data as $ index => $ item ) { if ( $ j ++ <= $ this -> max ) { $ rows [ ] = $ this -> renderRowContent ( $ index , $ item ) ; } else { break ; } } for ( $ i = $ j ; $ i < $ this -> min ; $ i ++ ) { $ rows [ ] = $ th... | Renders the body . |
36,155 | protected function getInputNamePrefix ( ) { $ model = $ this -> context -> model ; if ( $ model instanceof Model ) { if ( empty ( $ this -> renderer -> columns ) || ( $ this -> isRendererHasOneColumn ( ) && $ this -> hasModelAttribute ( $ this -> name ) ) ) { return $ model -> formName ( ) ; } return Html :: getInputNa... | Return prefix for name of input . |
36,156 | private function hasHeader ( ) { if ( $ this -> min === 0 || $ this -> isAddButtonPositionHeader ( ) ) { return true ; } foreach ( $ this -> columns as $ column ) { if ( $ column -> title ) { return true ; } } return false ; } | Check that at least one column has a header . |
36,157 | public function cancel ( ) { $ url = $ this -> getEntityUrl ( ) . $ this -> id . '/cancel' ; return $ this -> request ( Requests :: POST , $ url ) ; } | Cancels issued invoice |
36,158 | public function edit ( $ attributes = array ( ) ) { $ url = $ this -> getEntityUrl ( ) . $ this -> id ; return $ this -> request ( Requests :: PATCH , $ url , $ attributes ) ; } | Patches given invoice with new attributes |
36,159 | public function issue ( ) { $ url = $ this -> getEntityUrl ( ) . $ this -> id . '/issue' ; return $ this -> request ( Requests :: POST , $ url ) ; } | Issues drafted invoice |
36,160 | public function delete ( ) { $ url = $ this -> getEntityUrl ( ) . $ this -> id ; $ r = new Request ( ) ; return $ r -> request ( Requests :: DELETE , $ url ) ; } | Deletes drafted invoice |
36,161 | protected function request ( $ method , $ relativeUrl , $ data = null ) { $ request = new Request ( ) ; $ response = $ request -> request ( $ method , $ relativeUrl , $ data ) ; if ( ( isset ( $ response [ 'entity' ] ) ) and ( $ response [ 'entity' ] == $ this -> getEntity ( ) ) ) { $ this -> fill ( $ response ) ; retu... | Makes a HTTP request using Request class and assuming the API returns formatted entity or collection result wraps the returned JSON as entity and returns . |
36,162 | protected static function buildEntity ( $ data ) { $ entities = static :: getDefinedEntitiesArray ( ) ; if ( isset ( $ data [ 'entity' ] ) ) { if ( in_array ( $ data [ 'entity' ] , $ entities ) ) { $ class = static :: getEntityClass ( $ data [ 'entity' ] ) ; $ entity = new $ class ; } else { $ entity = new static ; } }... | Given the JSON response of an API call wraps it to corresponding entity class or a collection and returns the same . |
36,163 | public function request ( $ method , $ url , $ data = array ( ) ) { $ url = Api :: getFullUrl ( $ url ) ; $ hooks = new Requests_Hooks ( ) ; $ hooks -> register ( 'curl.before_send' , array ( $ this , 'setCurlSslOpts' ) ) ; $ options = array ( 'auth' => array ( Api :: getKey ( ) , Api :: getSecret ( ) ) , 'hook' => $ h... | Fires a request to the API |
36,164 | protected function checkErrors ( $ response ) { $ body = $ response -> body ; $ httpStatusCode = $ response -> status_code ; try { $ body = json_decode ( $ response -> body , true ) ; } catch ( Exception $ e ) { $ this -> throwServerError ( $ body , $ httpStatusCode ) ; } if ( ( $ httpStatusCode < 200 ) or ( $ httpStat... | Process the statusCode of the response and throw exception if necessary |
36,165 | protected function verifyErrorFormat ( $ body , $ httpStatusCode ) { if ( is_array ( $ body ) === false ) { $ this -> throwServerError ( $ body , $ httpStatusCode ) ; } if ( ( isset ( $ body [ 'error' ] ) === false ) or ( isset ( $ body [ 'error' ] [ 'code' ] ) === false ) ) { $ this -> throwServerError ( $ body , $ ht... | Verifies error is in proper format . If not then throws ServerErrorException |
36,166 | public function reverse ( $ attributes = array ( ) ) { $ relativeUrl = $ this -> getEntityUrl ( ) . $ this -> id . '/reversals' ; return $ this -> request ( 'POST' , $ relativeUrl , $ attributes ) ; } | Create a reversal for a transfer |
36,167 | public function reversals ( $ attributes = array ( ) ) { $ relativeUrl = $ this -> getEntityUrl ( ) . $ this -> id . '/reversals' ; return $ this -> request ( 'GET' , $ relativeUrl , $ attributes ) ; } | Fetches all reversals |
36,168 | public function setVersion ( string $ version ) { if ( ! preg_match ( self :: VERSION_PATTERN , $ version ) ) { throw new Exception ( 'Version string must be of YYYY-MM or unstable' ) ; } $ this -> version = $ version ; return $ this ; } | Sets the version of Shopify API to use . |
36,169 | public function enableRateLimiting ( int $ cycle = null , int $ buffer = null ) { $ this -> rateLimitingEnabled = true ; if ( ! is_null ( $ cycle ) ) { $ this -> rateLimitCycle = $ cycle ; } if ( ! is_null ( $ cycle ) ) { $ this -> rateLimitCycleBuffer = $ buffer ; } return $ this ; } | Set the rate limiting state to enabled . |
36,170 | public function setSession ( string $ shop , string $ accessToken ) { $ this -> setShop ( $ shop ) ; $ this -> setAccessToken ( $ accessToken ) ; return $ this ; } | Simple quick method to set shop and access token in one shot . |
36,171 | public function withSession ( string $ shop , string $ accessToken , Closure $ closure ) { $ clonedApi = clone $ this ; $ clonedApi -> setSession ( $ shop , $ accessToken ) ; return $ closure -> call ( $ clonedApi ) ; } | Accepts a closure to do isolated API calls for a shop . |
36,172 | public function getApiCalls ( string $ type = 'rest' , string $ key = null ) { if ( $ key ) { $ keys = array_keys ( $ this -> apiCallLimits [ $ type ] ) ; if ( ! in_array ( $ key , $ keys ) ) { throw new Exception ( 'Invalid API call limit key. Valid keys are: ' . implode ( ', ' , $ keys ) ) ; } return $ this -> apiCal... | Returns the current API call limits . |
36,173 | public function authRequest ( Request $ request ) { $ uri = $ request -> getUri ( ) ; if ( $ this -> isAuthableRequest ( ( string ) $ uri ) ) { if ( $ this -> isRestRequest ( ( string ) $ uri ) ) { if ( $ this -> private && ( $ this -> apiKey === null || $ this -> apiPassword === null ) ) { throw new Exception ( 'API k... | Ensures we have the proper request for private and public calls . Also modifies issues with redirects . |
36,174 | protected function jsonDecode ( $ json ) { if ( ! ( defined ( 'JSON_C_VERSION' ) && PHP_INT_SIZE > 4 ) ) { $ obj = json_decode ( $ json , false , 512 , JSON_BIGINT_AS_STRING ) ; } else { $ maxIntLength = strlen ( ( string ) PHP_INT_MAX ) - 1 ; $ jsonWithoutBigints = preg_replace ( '/:\s*(-?\d{' . $ maxIntLength . ',})/... | Decodes the JSON body . |
36,175 | protected function versionPath ( string $ uri ) { if ( $ this -> version === null || preg_match ( self :: VERSION_PATTERN , $ uri ) ) { return $ uri ; } if ( $ this -> isGraphRequest ( $ uri ) ) { return str_replace ( '/admin/api' , "/admin/api/{$this->version}" , $ uri ) ; } return preg_replace ( '/\/admin(\/api)?\//'... | Versions the API call with the set version . |
36,176 | public function getFullAddress ( ) : string { $ address = \ sprintf ( '%s@%s' , $ this -> mailbox , $ this -> hostname ) ; if ( null !== $ this -> name ) { $ address = \ sprintf ( '"%s" <%s>' , \ addcslashes ( $ this -> name , '"' ) , $ address ) ; } return $ address ; } | Returns address with person name . |
36,177 | public static function decode ( string $ text , string $ fromCharset ) : string { static $ utf8Aliases = [ 'unicode-1-1-utf-8' => true , 'utf8' => true , 'utf-8' => true , 'UTF8' => true , 'UTF-8' => true , ] ; if ( isset ( $ utf8Aliases [ $ fromCharset ] ) ) { return $ text ; } $ originalFromCharset = $ fromCharset ; ... | Decode text to UTF - 8 . |
36,178 | final public function toString ( ) : string { return \ sprintf ( '%s "%s"' , $ this -> getKeyword ( ) , $ this -> date -> format ( $ this -> dateFormat ) ) ; } | Converts the condition to a string that can be sent to the IMAP server . |
36,179 | private function parseHeader ( string $ key , $ value ) { switch ( $ key ) { case 'msgno' : return ( int ) $ value ; case 'from' : case 'to' : case 'cc' : case 'bcc' : case 'reply_to' : case 'sender' : case 'return_path' : foreach ( $ value as $ address ) { if ( isset ( $ address -> mailbox ) ) { $ address -> host = $ ... | Parse header . |
36,180 | public function current ( ) : MessageInterface { $ current = parent :: current ( ) ; if ( ! \ is_int ( $ current ) ) { throw new Exception \ OutOfBoundsException ( \ sprintf ( 'The current value "%s" isn\'t an integer and doesn\'t represent a message;' . ' try to cycle this "%s" with a native php function like foreach ... | Get current message . |
36,181 | final protected function decode ( string $ value ) : string { $ parts = \ imap_mime_header_decode ( $ value ) ; if ( ! \ is_array ( $ parts ) ) { return $ value ; } $ decoded = '' ; foreach ( $ parts as $ part ) { $ text = $ part -> text ; if ( 'default' !== $ part -> charset ) { $ text = Transcoder :: decode ( $ text ... | Decode value . |
36,182 | protected function getContentPartNumber ( ) : string { $ partNumber = $ this -> getPartNumber ( ) ; if ( 0 === \ count ( $ this -> getParts ( ) ) ) { $ partNumber .= '.1' ; } return $ partNumber ; } | Get content part number . |
36,183 | public function authenticate ( string $ username , string $ password ) : ConnectionInterface { $ errorMessage = null ; $ errorNumber = 0 ; \ set_error_handler ( static function ( $ nr , $ message ) use ( & $ errorMessage , & $ errorNumber ) { $ errorMessage = $ message ; $ errorNumber = $ nr ; } ) ; $ resource = \ imap... | Authenticate connection . |
36,184 | private function getServerString ( ) : string { return \ sprintf ( '{%s%s%s}' , $ this -> hostname , '' !== $ this -> port ? ':' . $ this -> port : '' , $ this -> flags ) ; } | Glues hostname port and flags and returns result . |
36,185 | public function getStatus ( int $ flags = null ) : \ stdClass { $ return = \ imap_status ( $ this -> resource -> getStream ( ) , $ this -> getFullEncodedName ( ) , $ flags ?? \ SA_ALL ) ; if ( false === $ return ) { throw new ImapStatusException ( 'imap_status failed' ) ; } return $ return ; } | Get Mailbox status . |
36,186 | public function setFlag ( string $ flag , $ numbers ) : bool { return \ imap_setflag_full ( $ this -> resource -> getStream ( ) , $ this -> prepareMessageIds ( $ numbers ) , $ flag , \ ST_UID ) ; } | Bulk Set Flag for Messages . |
36,187 | public function clearFlag ( string $ flag , $ numbers ) : bool { return \ imap_clearflag_full ( $ this -> resource -> getStream ( ) , $ this -> prepareMessageIds ( $ numbers ) , $ flag , \ ST_UID ) ; } | Bulk Clear Flag for Messages . |
36,188 | public function getMessages ( ConditionInterface $ search = null , int $ sortCriteria = null , bool $ descending = false , string $ charset = null ) : MessageIteratorInterface { if ( null === $ search ) { $ search = new All ( ) ; } $ query = $ search -> toString ( ) ; \ imap_errors ( ) ; if ( null !== $ sortCriteria ) ... | Get message ids . |
36,189 | public function getMessageSequence ( string $ sequence ) : MessageIteratorInterface { \ imap_errors ( ) ; $ overview = \ imap_fetch_overview ( $ this -> resource -> getStream ( ) , $ sequence , \ FT_UID ) ; if ( \ is_array ( $ overview ) && [ ] !== $ overview ) { $ messageNumbers = \ array_column ( $ overview , 'uid' )... | Get message iterator for a sequence . |
36,190 | public function addMessage ( string $ message , string $ options = null , DateTimeInterface $ internalDate = null ) : bool { $ arguments = [ $ this -> resource -> getStream ( ) , $ this -> getFullEncodedName ( ) , $ message , ] ; if ( null !== $ options ) { $ arguments [ ] = $ options ; if ( null !== $ internalDate ) {... | Add a message to the mailbox . |
36,191 | public function getThread ( ) : array { \ set_error_handler ( static function ( ) { } ) ; $ tree = \ imap_thread ( $ this -> resource -> getStream ( ) ) ; \ restore_error_handler ( ) ; return false !== $ tree ? $ tree : [ ] ; } | Returns a tree of threaded message for the current Mailbox . |
36,192 | public function move ( $ numbers , MailboxInterface $ mailbox ) : void { if ( ! \ imap_mail_move ( $ this -> resource -> getStream ( ) , $ this -> prepareMessageIds ( $ numbers ) , $ mailbox -> getEncodedName ( ) , \ CP_UID ) ) { throw new MessageMoveException ( \ sprintf ( 'Messages cannot be moved to "%s"' , $ mailbo... | Bulk move messages . |
36,193 | public function copy ( $ numbers , MailboxInterface $ mailbox ) : void { if ( ! \ imap_mail_copy ( $ this -> resource -> getStream ( ) , $ this -> prepareMessageIds ( $ numbers ) , $ mailbox -> getEncodedName ( ) , \ CP_UID ) ) { throw new MessageCopyException ( \ sprintf ( 'Messages cannot be copied to "%s"' , $ mailb... | Bulk copy messages . |
36,194 | private function prepareMessageIds ( $ messageIds ) : string { if ( $ messageIds instanceof MessageIterator ) { $ messageIds = $ messageIds -> getArrayCopy ( ) ; } if ( \ is_array ( $ messageIds ) ) { $ messageIds = \ implode ( ',' , $ messageIds ) ; } return $ messageIds ; } | Prepare message ids for the use with bulk functions . |
36,195 | final public function getBodyHtml ( ) : ? string { $ iterator = new \ RecursiveIteratorIterator ( $ this , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iterator as $ part ) { if ( self :: SUBTYPE_HTML === $ part -> getSubtype ( ) ) { return $ part -> getDecodedContent ( ) ; } } if ( self :: SUBTYPE_HTML ==... | Get body HTML . |
36,196 | final public function getBodyText ( ) : ? string { $ iterator = new \ RecursiveIteratorIterator ( $ this , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iterator as $ part ) { if ( self :: SUBTYPE_PLAIN === $ part -> getSubtype ( ) ) { return $ part -> getDecodedContent ( ) ; } } if ( self :: SUBTYPE_PLAIN ... | Get body text . |
36,197 | protected function lazyLoadStructure ( ) : void { if ( true === $ this -> structureLoaded ) { return ; } $ this -> structureLoaded = true ; $ messageNumber = $ this -> getNumber ( ) ; $ errorMessage = null ; $ errorNumber = 0 ; \ set_error_handler ( static function ( $ nr , $ message ) use ( & $ errorMessage , & $ erro... | Lazy load structure . |
36,198 | protected function assertMessageExists ( int $ messageNumber ) : void { if ( true === $ this -> messageNumberVerified ) { return ; } $ this -> messageNumberVerified = true ; $ msgno = \ imap_msgno ( $ this -> resource -> getStream ( ) , $ messageNumber ) ; if ( \ is_numeric ( $ msgno ) && $ msgno > 0 ) { $ this -> imap... | Ensure message exists . |
36,199 | public function getRawMessage ( ) : string { if ( null === $ this -> rawMessage ) { $ this -> rawMessage = $ this -> doGetContent ( '' ) ; } return $ this -> rawMessage ; } | Get the raw message including all headers parts etc . unencoded and unparsed . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.