idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
55,500 | public function duplicateToCreditInvoice ( ) { $ response = $ this -> connection ( ) -> patch ( $ this -> getEndpoint ( ) . '/' . $ this -> id . '/duplicate_creditinvoice' , json_encode ( [ ] ) ) ; return $ this -> makeFromResponse ( $ response ) ; } | Create a credit invoice based on the current invoice . |
55,501 | public function addAttachment ( $ filename , $ contents ) { $ this -> connection ( ) -> upload ( $ this -> endpoint . '/' . $ this -> id . '/attachments' , [ 'multipart' => [ [ 'name' => 'file' , 'contents' => $ contents , 'filename' => $ filename , ] , ] , ] ) ; return $ this ; } | Add Attachment to this invoice . |
55,502 | public function pauseWorkflow ( ) { try { $ this -> connection ( ) -> post ( $ this -> endpoint . '/' . $ this -> id . '/pause' , json_encode ( [ ] ) ) ; } catch ( ApiException $ exception ) { if ( strpos ( $ exception -> getMessage ( ) , 'The sales_invoice is already paused' ) !== false ) { return true ; } throw $ exc... | Pauses the sales invoice . The automatic workflow steps will not be executed while the sales invoice is paused . |
55,503 | private function parseExceptionForErrorMessages ( Exception $ exception ) { if ( ! $ exception instanceof BadResponseException ) { return new ApiException ( $ exception -> getMessage ( ) , 0 , $ exception ) ; } $ response = $ exception -> getResponse ( ) ; if ( null === $ response ) { return new ApiException ( 'Respons... | Parse the response in the Exception to return the Exact error messages . |
55,504 | public function selfFromResponse ( array $ response ) { $ this -> fill ( $ response ) ; foreach ( $ this -> getSingleNestedEntities ( ) as $ key => $ value ) { if ( isset ( $ response [ $ key ] ) ) { $ entityName = $ value ; $ this -> $ key = new $ entityName ( $ this -> connection , $ response [ $ key ] ) ; } } foreac... | Recreate this object with the response from the API . |
55,505 | public function parse ( $ line ) { if ( ! preg_match ( $ this -> pcreFormat , $ line , $ matches ) ) { throw new FormatException ( $ line ) ; } $ entry = $ this -> createEntry ( ) ; foreach ( array_filter ( array_keys ( $ matches ) , 'is_string' ) as $ key ) { if ( 'time' === $ key && true !== $ stamp = strtotime ( $ m... | Parses one single log line . |
55,506 | public function registerManager ( ) { $ this -> app -> singleton ( 'omnipay' , function ( $ app ) { $ factory = new GatewayFactory ; $ manager = new LaravelOmnipayManager ( $ app , $ factory ) ; return $ manager ; } ) ; } | Register the Omnipay manager |
55,507 | public function gateway ( $ name = null ) { $ name = $ name ? : $ this -> getGateway ( ) ; if ( ! isset ( $ this -> gateways [ $ name ] ) ) { $ this -> gateways [ $ name ] = $ this -> resolve ( $ name ) ; } return $ this -> gateways [ $ name ] ; } | Get an instance of the specified gateway |
55,508 | public function isActive ( $ routes ) { $ routes = is_array ( $ routes ) ? $ routes : func_get_args ( ) ; list ( $ routes , $ ignoredRoutes ) = $ this -> parseIgnoredRoutes ( $ routes ) ; if ( $ this -> isPath ( $ routes ) || $ this -> isFullPath ( $ routes ) || $ this -> isRoute ( $ routes ) ) { if ( count ( $ ignored... | Determine if any of the provided routes are active . |
55,509 | public function isPath ( $ routes ) { $ routes = is_array ( $ routes ) ? $ routes : func_get_args ( ) ; return call_user_func_array ( [ $ this -> request , 'is' ] , $ routes ) ; } | Determine if the current path is one of the provided paths . |
55,510 | public function isFullPath ( $ routes ) { $ routes = is_array ( $ routes ) ? $ routes : func_get_args ( ) ; return call_user_func_array ( [ $ this -> request , 'fullUrlIs' ] , $ routes ) ; } | Determine if the current full path is one of the provided paths . |
55,511 | public function isRoute ( $ routes ) { $ routes = is_array ( $ routes ) ? $ routes : func_get_args ( ) ; return call_user_func_array ( [ $ this -> router , 'is' ] , $ routes ) ; } | Determin if the current route is one of the provided routes . |
55,512 | public function route ( $ routes , $ class = null ) { $ routes = ( array ) $ routes ; if ( $ this -> isRoute ( $ routes ) ) { return $ this -> getActiveClass ( $ class ) ; } } | Get the active class if the active route is provided . |
55,513 | private function parseIgnoredRoutes ( $ routes ) { $ ignoredRoutes = [ ] ; $ routes = is_array ( $ routes ) ? $ routes : func_get_args ( ) ; foreach ( $ routes as $ index => $ route ) { if ( Str :: startsWith ( $ route , 'not:' ) ) { $ ignoredRoute = substr ( $ route , 4 ) ; unset ( $ routes [ $ index ] ) ; $ ignoredRo... | Separate ignored routes from the provided routes . |
55,514 | public function controller ( $ separator = null , $ includeNamespace = true , $ trimNamespace = 'App\Http\Controllers\\' ) { if ( $ action = $ this -> router -> currentRouteAction ( ) ) { $ separator = is_null ( $ separator ) ? ' ' : $ separator ; $ controller = head ( Str :: parseCallback ( $ action , null ) ) ; if ( ... | Get the controller name separated as necessary and with or without namespaces . |
55,515 | public function action ( $ removeHttpMethod = true ) { if ( $ action = $ this -> router -> currentRouteAction ( ) ) { $ action = last ( Str :: parseCallback ( $ action , null ) ) ; if ( $ removeHttpMethod ) { $ action = str_replace ( [ 'get' , 'post' , 'patch' , 'put' , 'delete' ] , '' , $ action ) ; } return Str :: sn... | Get the current controller action name . |
55,516 | private function getSnippet ( string $ content , int $ line , $ text ) : array { $ content = str_replace ( array ( "\r\n" , "\r" ) , "\n" , $ content ) ; $ lines = explode ( "\n" , $ content ) ; $ lineContent = array_slice ( $ lines , $ line - 1 , 1 ) ; $ lineContent = reset ( $ lineContent ) ; $ start = strpos ( $ lin... | Get the snippet and information about it |
55,517 | public function sendEmail ( Exception $ exception ) { try { $ e = FlattenException :: create ( $ exception ) ; $ handler = new SymfonyExceptionHandler ( ) ; $ html = $ handler -> getHtml ( $ e ) ; Mail :: send ( new ExceptionOccured ( $ html ) ) ; } catch ( Exception $ exception ) { Log :: error ( $ exception ) ; } } | Sends an email upon exception . |
55,518 | protected function fetch ( ) { return Collection :: make ( file ( $ this -> source , FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ) ) -> map ( function ( $ line ) { preg_match_all ( self :: PATTERN_CAPTURE , $ line , $ matches ) ; return $ matches [ 1 ] ; } ) -> filter ( ) ; } | Fetch the salts from the generator and return the parsed response . |
55,519 | protected function get_flag ( $ key , $ default = null ) { return \ WP_CLI \ Utils \ get_flag_value ( $ this -> args -> original ( ) , $ key , $ default ) ; } | Get flag value for command line option . |
55,520 | protected function resolve_file_path ( $ file = null ) { if ( is_null ( $ file ) ) { $ file = $ this -> args -> file ; } if ( file_exists ( $ file ) ) { return $ file ; } $ dirname = dirname ( $ file ) ; $ filename = basename ( $ file ) ; $ relpath = $ dirname ? "/$dirname" : '' ; $ path = getcwd ( ) . "$relpath/$filen... | Get the absolute path to the file . |
55,521 | protected function prompt ( $ question , $ default ) { try { return \ cli \ prompt ( $ question , $ default ) ; } catch ( \ Exception $ e ) { WP_CLI :: error ( $ e -> getMessage ( ) ) ; die ; } } | Prompt the user for input at the command line or use a default . |
55,522 | public static function at ( $ path ) { $ file = new static ( $ path ) ; if ( ! $ file -> exists ( ) ) { throw new NonExistentFileException ( "File does not exist at $path" ) ; } if ( ! $ file -> isReadable ( ) ) { throw new FilePermissionsException ( "File not readable at $path" ) ; } return $ file ; } | Get a new instance and ensure the file is readable . |
55,523 | public static function create ( $ path ) { $ file = new static ( $ path ) ; if ( ! is_dir ( dirname ( $ path ) ) ) { mkdir ( dirname ( $ path ) , 0755 , true ) ; } if ( ! $ file -> exists ( ) ) { touch ( $ path ) ; } return $ file ; } | Create a new instance including the file and parent directories . |
55,524 | public function set ( $ key , $ value , $ quote = '' ) { $ this -> lines -> updateOrAdd ( new KeyValue ( $ key , $ value , $ quote ) ) ; return $ this ; } | Set a variable definition . |
55,525 | public function remove ( $ key ) { $ linesBefore = $ this -> lineCount ( ) ; $ this -> lines -> removeDefinition ( $ key ) ; return $ linesBefore - $ this -> lineCount ( ) ; } | Remove a variable definition . |
55,526 | public function run_check ( ) { $ r = $ this -> run ( ) ; if ( $ r -> return_code || ! empty ( $ r -> STDERR ) ) { throw new \ RuntimeException ( $ r ) ; } return $ r ; } | Run the command but throw an Exception on error . |
55,527 | public function value_raw ( ) { if ( ! strlen ( $ this -> text ) ) { return $ this -> text ; } $ pieces = explode ( '=' , $ this -> text , 2 ) ; $ pieces = array_map ( 'trim' , $ pieces ) ; return end ( $ pieces ) ; } | Get the raw uncleaned value . |
55,528 | public function isPair ( ) { if ( 0 === strpos ( trim ( $ this -> text ) , '#' ) ) { return false ; } $ pieces = explode ( '=' , $ this -> text , 2 ) ; $ pieces = array_map ( 'trim' , $ pieces ) ; return 2 === count ( $ pieces ) ; } | Whether or not the text is a key = value pair . |
55,529 | public static function wraps_value ( $ char , $ value ) { return substr ( ( string ) $ value , 0 , 1 ) == $ char && substr ( ( string ) $ value , - 1 , 1 ) == $ char ; } | Check if the given character wraps the value . |
55,530 | public static function clean_quotes ( $ string ) { if ( static :: wrapping_quote_for ( $ string ) ) { $ string = substr ( $ string , 1 ) ; $ string = substr ( $ string , 0 , - 1 ) ; } return $ string ; } | Trim surrounding quotes from a string |
55,531 | private static function cache_wp_files ( ) { self :: $ cache_dir = sys_get_temp_dir ( ) . '/wp-cli-test core-download-cache' ; if ( is_readable ( self :: $ cache_dir . '/wp-config-sample.php' ) ) return ; $ cmd = Utils \ esc_cmd ( 'wp core download --force --path=%s' , self :: $ cache_dir ) ; Process :: create ( $ cmd ... | Ideally we d cache at the HTTP layer for more reliable tests |
55,532 | public function generate ( $ _ , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; $ updated = $ this -> update_salts ( $ this -> get_flag ( 'force' ) ? : $ this -> salts_are_placeholders ( ) ) ; if ( ! $ this -> env -> save ( ) ) { WP_CLI :: error ( 'Failed to update salts.' ) ; } $ skipped = $ updated -> p... | Fetch some fresh salts and add them to the environment file if they do not already exist . |
55,533 | public function regenerate ( $ _ , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; $ this -> update_salts ( true ) ; if ( ! $ this -> env -> save ( ) ) { WP_CLI :: error ( 'Failed to update salts.' ) ; } WP_CLI :: success ( 'Salts regenerated.' ) ; } | Regenerate salts for the environment file . |
55,534 | protected function salts_are_placeholders ( ) { return $ this -> env -> dictionary ( ) -> only ( $ this -> salts -> pluck ( 0 ) -> all ( ) ) -> values ( ) -> unique ( ) -> count ( ) === 1 ; } | Perform a simple check to see if all defined salts are using a placeholder . |
55,535 | protected function update_salts ( $ force = false ) { return $ this -> salts -> map ( function ( $ salt ) use ( $ force ) { list ( $ key , $ value ) = $ salt ; if ( ! $ force && $ this -> env -> hasKey ( $ key ) ) { WP_CLI :: line ( "The '$key' already exists, skipping." ) ; $ salt [ 'skipped' ] = true ; return $ salt ... | Update salts in the environment file . |
55,536 | protected function init_args ( $ args ) { parent :: init_args ( $ args ) ; $ this -> env = $ this -> get_env_for_write_or_fail ( ) ; $ api = new Salts ( ) ; try { $ this -> salts = $ api -> collect ( ) ; } catch ( Exception $ e ) { WP_CLI :: error ( $ e -> getMessage ( ) ) ; } } | Initialize properties for the command . |
55,537 | public function updateOrAdd ( LineInterface $ line ) { $ key = $ line -> key ( ) ; $ index = $ this -> search ( function ( LineInterface $ line ) use ( $ key ) { return $ line -> key ( ) == $ key ; } ) ; if ( $ index > - 1 ) { $ this -> put ( $ index , $ line ) ; } else { $ this -> add ( $ line ) ; } } | Update the line by key or add it if there is no existing line for the same key . |
55,538 | public function hasDefinition ( $ varName ) { return $ this -> contains ( function ( $ index , LineInterface $ line ) use ( $ varName ) { return $ line -> key ( ) == $ varName ; } ) ; } | Check if the collection has a definition for the given variable name . |
55,539 | public function removeDefinition ( $ varName ) { $ this -> items = $ this -> reject ( function ( LineInterface $ line ) use ( $ varName ) { return $ line -> key ( ) == $ varName ; } ) -> all ( ) ; return $ this ; } | Remove the definition by the variable name . |
55,540 | public function toDictionary ( ) { return $ this -> pairs ( ) -> reduce ( function ( Collection $ pairs , LineInterface $ line ) { $ pairs [ $ line -> key ( ) ] = $ line -> value ( ) ; return $ pairs ; } , new Collection ) ; } | Get the lines as key = > value . |
55,541 | public function whereKeysLike ( $ patterns ) { if ( ! $ patterns instanceof Collection ) { $ patterns = new Collection ( ( array ) $ patterns ) ; } if ( $ patterns -> filter ( ) -> isEmpty ( ) ) { return new static ( $ this -> all ( ) ) ; } return $ this -> pairs ( ) -> filter ( function ( LineInterface $ line ) use ( ... | Get a subset of lines where the key matches at least one of the given glob - style patterns . |
55,542 | public function init ( $ _ , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; $ path = $ this -> resolve_file_path ( ) ; if ( file_exists ( $ path ) && ! $ this -> get_flag ( 'force' ) ) { WP_CLI :: error ( "Environment file already exists at: $path" ) ; return ; } $ env = File :: create ( $ path ) ; if ( !... | Initialize the environment file . |
55,543 | public function set ( $ _ , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; list ( $ key , $ value ) = $ _ ; $ env = $ this -> get_env_for_write_or_fail ( ) ; $ env -> set ( $ key , $ value , $ this -> quote ( ) ) ; $ env -> save ( ) ; WP_CLI :: success ( "'$key' set." ) ; } | Set a value in the environment file for a given key . Updates an existing value or creates a new entry . |
55,544 | public function get ( $ _ , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; list ( $ key ) = $ _ ; $ env = $ this -> get_env_for_read_or_fail ( ) ; if ( is_null ( $ value = $ env -> get ( $ key ) ) ) { WP_CLI :: error ( "Key '$key' not found." ) ; } WP_CLI :: line ( $ value ) ; } | Get the value for a given key from the environment file |
55,545 | public function delete ( $ _ , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; $ env = $ this -> get_env_for_write_or_fail ( ) ; foreach ( $ _ as $ key ) { if ( $ result = $ env -> remove ( $ key ) ) { WP_CLI :: success ( "Removed '$key'" ) ; } else { WP_CLI :: warning ( "No line found for key: '$key'" ) ;... | Delete a definition from the environment file |
55,546 | public function _list ( $ patterns , $ assoc_args ) { $ this -> init_args ( func_get_args ( ) ) ; $ env = $ this -> get_env_for_read_or_fail ( ) ; $ items = $ env -> dictionaryWithKeysMatching ( $ patterns ) -> map ( function ( $ value , $ key ) { return ( object ) compact ( 'key' , 'value' ) ; } ) ; $ args = $ this ->... | List the defined variables from the environment file |
55,547 | protected function fields ( ) { return is_string ( $ this -> args -> fields ) ? explode ( ',' , $ this -> args -> fields ) : $ this -> args -> fields ; } | Get the fields to display as passed in the arguments . |
55,548 | protected function prompt_all ( File $ env ) { $ env -> dictionary ( ) -> each ( function ( $ value , $ key ) use ( $ env ) { $ env -> set ( $ key , $ this -> prompt ( $ key , $ value ) ) ; } ) ; $ env -> save ( ) ; } | Iterate over each line and prompt for a new value |
55,549 | public function offsetGet ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> data ) ) { throw new \ RuntimeException ( sprintf ( 'Identifier "%s" does not exist in the context.' , $ key ) ) ; } return $ this -> data [ $ key ] ; } | Get a data . |
55,550 | public function accept ( Visitor \ Visit $ visitor , & $ handle = null , $ eldnah = null ) { return $ visitor -> visit ( $ this , $ handle , $ eldnah ) ; } | Accept a visitor . |
55,551 | public static function ensureTraversable ( $ items ) : \ Traversable { if ( $ items instanceof \ Traversable ) { return $ items ; } if ( is_array ( $ items ) ) { return self :: fromArray ( $ items ) ; } throw new \ InvalidArgumentException ( 'Un-handled argument of type: ' . get_class ( $ items ) ) ; } | Ensures that the given items are \ Traversable . |
55,552 | public function filter ( $ target , string $ rule , array $ parameters = [ ] , array $ executionContext = [ ] ) { $ targetCompiler = $ this -> findTargetCompiler ( $ target , CompilationTarget :: MODE_FILTER ) ; $ compilationContext = $ targetCompiler -> createCompilationContext ( $ target ) ; $ executor = $ this -> co... | Filters a target using the given rule and parameters . The target compiler to use is determined at runtime using the registered ones . |
55,553 | public function filterSpec ( $ target , Specification $ spec , array $ executionContext = [ ] ) { return $ this -> filter ( $ target , $ spec -> getRule ( ) , $ spec -> getParameters ( ) , $ executionContext ) ; } | Filters a target using the given specification . The targetCompiler to use is determined at runtime using the registered ones . |
55,554 | public function applyFilterSpec ( $ target , Specification $ spec , array $ executionContext = [ ] ) { return $ this -> applyFilter ( $ target , $ spec -> getRule ( ) , $ spec -> getParameters ( ) , $ executionContext ) ; } | Apply the filters on a target using the given specification . The targetCompiler to use is determined at runtime using the registered ones . |
55,555 | public function satisfies ( $ target , string $ rule , array $ parameters = [ ] , array $ executionContext = [ ] ) : bool { $ targetCompiler = $ this -> findTargetCompiler ( $ target , CompilationTarget :: MODE_SATISFIES ) ; $ compilationContext = $ targetCompiler -> createCompilationContext ( $ target ) ; $ executor =... | Tells if a target satisfies the given rule and parameters . The target compiler to use is determined at runtime using the registered ones . |
55,556 | public function satisfiesSpec ( $ target , Specification $ spec , array $ executionContext = [ ] ) : bool { return $ this -> satisfies ( $ target , $ spec -> getRule ( ) , $ spec -> getParameters ( ) , $ executionContext ) ; } | Tells if a target satisfies the given specification . The target compiler to use is determined at runtime using the registered ones . |
55,557 | private function findTargetCompiler ( $ target , $ mode ) : CompilationTarget { foreach ( $ this -> compilationTargets as $ targetCompiler ) { if ( $ targetCompiler -> supports ( $ target , $ mode ) ) { return $ targetCompiler ; } } throw new TargetUnsupportedException ( 'The given target is not supported.' ) ; } | Finds a target compiler supporting the given target . |
55,558 | public function defineOperator ( string $ operator , callable $ transformer ) : void { unset ( $ this -> inlineOperators [ $ operator ] ) ; $ this -> operators [ $ operator ] = $ transformer ; } | Define an operator . |
55,559 | protected function getOperator ( string $ operator ) : callable { if ( ! $ this -> hasOperator ( $ operator ) ) { throw new OperatorNotFoundException ( $ operator , sprintf ( 'Operator "%s" does not exist.' , $ operator ) ) ; } return $ this -> operators [ $ operator ] ; } | Get an operator . |
55,560 | public function getInlineOperator ( string $ operator ) : callable { if ( ! $ this -> hasInlineOperator ( $ operator ) ) { throw new OperatorNotFoundException ( $ operator , sprintf ( 'Inline operator "%s" does not exist.' , $ operator ) ) ; } return $ this -> inlineOperators [ $ operator ] ; } | Gets an inline - able operator . |
55,561 | public function defineInlineOperator ( string $ operator , callable $ transformer ) { unset ( $ this -> operators [ $ operator ] ) ; $ this -> inlineOperators [ $ operator ] = $ transformer ; } | Set an inline - able operator . |
55,562 | private function searchOverridenParameters ( array $ parametersList ) : array { $ parametersUsageCount = [ ] ; foreach ( $ parametersList as $ list ) { foreach ( $ list as $ parameter => $ _value ) { if ( ! isset ( $ parametersUsageCount [ $ parameter ] ) ) { $ parametersUsageCount [ $ parameter ] = 0 ; } $ parametersU... | Search the parameters that were overridden during the parameters - merge phase . |
55,563 | public function parse ( $ rule ) { if ( $ this -> parser === null ) { $ this -> parser = Compiler \ Llk :: load ( new File \ Read ( __DIR__ . '/../Grammar.pp' ) ) ; } $ this -> nextParameterIndex = 0 ; return $ this -> visit ( $ this -> parser -> parse ( $ rule ) ) ; } | Parses the rule into an equivalent AST . |
55,564 | public static function set_debug ( $ toggle , $ output = "stdout" ) { if ( $ toggle ) { self :: $ debug = $ output ; } else { self :: $ debug = false ; } } | Set debug config |
55,565 | public function offsetSet ( $ offset , $ field ) { if ( ! is_a ( $ field , 'PodioAppField' ) ) { throw new PodioDataIntegrityError ( "Objects in PodioAppFieldCollection must be of class PodioAppField" ) ; } parent :: offsetSet ( $ offset , $ field ) ; } | Array access . Add field to collection . |
55,566 | public function save ( $ options = array ( ) ) { $ json_attributes = $ this -> as_json_without_readonly_fields ( ) ; if ( $ this -> id ) { return self :: update ( $ this -> id , $ json_attributes , $ options ) ; } else { if ( $ this -> app && $ this -> app -> id ) { $ new = self :: create ( $ this -> app -> id , $ json... | Create or updates an item |
55,567 | public function as_json_without_readonly_fields ( ) { $ readonly_fields = $ this -> fields -> readonly_fields ( ) -> external_ids ( ) ; $ json_attributes = $ this -> as_json ( false ) ; foreach ( $ this -> fields -> readonly_fields ( ) -> external_ids ( ) as $ external_id ) { if ( isset ( $ json_attributes [ 'fields' ]... | Return json representation without readonly fields . Used for saving items . |
55,568 | public function property ( $ name , $ type , $ options = array ( ) ) { if ( ! $ this -> has_property ( $ name ) ) { $ this -> __properties [ $ name ] = array ( 'type' => $ type , 'options' => $ options ) ; } } | Define a property on this object |
55,569 | public function save ( ) { if ( $ this -> id ) { return self :: update ( $ this -> id , $ this ) ; } else { $ new = self :: create ( $ this ) ; $ this -> task_id = $ new -> task_id ; return $ this ; } } | Creates or updates a task |
55,570 | public function offsetSet ( $ offset , $ value ) { if ( ! is_a ( $ value , 'PodioObject' ) ) { throw new PodioDataIntegrityError ( "Objects in PodioCollection must be of class PodioObject" ) ; } $ relationship = $ this -> relationship ( ) ; if ( $ relationship ) { $ value -> add_relationship ( $ relationship [ 'instanc... | Array access . Set item by offset automatically adding relationship . |
55,571 | public function offsetGet ( $ offset ) { return isset ( $ this -> __items [ $ offset ] ) ? $ this -> __items [ $ offset ] : null ; } | Array access . Get . |
55,572 | public function add_relationship ( $ instance , $ property = 'fields' ) { $ this -> __belongs_to = array ( 'property' => $ property , 'instance' => $ instance ) ; foreach ( $ this as $ item ) { if ( $ item -> has_property ( $ property ) ) { $ item -> add_relationship ( $ instance , $ property ) ; } } } | Add a new relationship to a parent object . Will also add relationship to all individual objects in the collection . |
55,573 | public function get ( $ id_or_external_id ) { $ key = is_int ( $ id_or_external_id ) ? 'id' : 'external_id' ; foreach ( $ this as $ item ) { if ( $ item -> { $ key } === $ id_or_external_id ) { return $ item ; } } return null ; } | Get object in the collection by id or external_id . |
55,574 | public function remove ( $ id_or_external_id ) { if ( count ( $ this ) === 0 ) { return true ; } $ this -> _set_items ( array_filter ( $ this -> _get_items ( ) , function ( $ item ) use ( $ id_or_external_id ) { return ! ( $ item -> id == $ id_or_external_id || $ item -> external_id == $ id_or_external_id ) ; } ) ) ; } | Remove object from collection by id or external_id . |
55,575 | public function offsetSet ( $ offset , $ field ) { if ( is_string ( $ offset ) ) { $ field -> external_id = $ offset ; $ offset = null ; } if ( ! $ field -> id && ! $ field -> external_id ) { throw new PodioDataIntegrityError ( 'Field must have id or external_id set.' ) ; } $ this -> remove ( $ field -> id ? $ field ->... | Array access . Set fiels using external id or offset . |
55,576 | public function offsetExists ( $ offset ) { if ( is_string ( $ offset ) ) { return $ this -> get ( $ offset ) ? true : false ; } return parent :: offsetExists ( $ offset ) ; } | Array access . Check for existence using external_id or offset . |
55,577 | public function offsetUnset ( $ offset ) { if ( is_string ( $ offset ) ) { $ this -> remove ( $ offset ) ; } else { parent :: offsetUnset ( $ offset ) ; } } | Array access . Unset field using external ) id or offset . |
55,578 | public function offsetGet ( $ offset ) { if ( is_string ( $ offset ) ) { return $ this -> get ( $ offset ) ; } return parent :: offsetGet ( $ offset ) ; } | Array access . Get field using external_id or offset . |
55,579 | public function readonly_fields ( ) { $ fields = new PodioFieldCollection ( array ( ) ) ; foreach ( $ this -> _get_items ( ) as $ field ) { if ( $ field -> type === 'calculation' ) { $ fields [ ] = $ field ; } } return $ fields ; } | Returns all readonly fields |
55,580 | public function save ( $ options = array ( ) ) { $ relationship = $ this -> relationship ( ) ; if ( ! $ relationship ) { throw new PodioMissingRelationshipError ( '{"error_description":"Field is missing relationship to item"}' , null , null ) ; } if ( ! $ this -> id && ! $ this -> external_id ) { throw new PodioDataInt... | Saves the value of the field |
55,581 | public function as_json ( $ encoded = true ) { $ result = $ this -> api_friendly_values ( ) ; return $ encoded ? json_encode ( $ result ) : $ result ; } | Overwrites normal as_json to use api_friendly_values |
55,582 | public function same_day ( ) { if ( ! $ this -> values || ( $ this -> start && ! $ this -> end ) ) { return true ; } if ( $ this -> start -> format ( 'Y-m-d' ) == $ this -> end -> format ( 'Y-m-d' ) ) { return true ; } return false ; } | True if start and end are on the same day . |
55,583 | public function sendToContact ( $ id , $ contactId , $ parameters = array ( ) ) { return $ this -> makeRequest ( $ this -> endpoint . '/' . $ id . '/contact/' . $ contactId . '/send' , $ parameters , 'POST' ) ; } | Send email to a specific contact |
55,584 | public function setBaseUrl ( $ url ) { if ( substr ( $ url , - 1 ) != '/' ) { $ url .= '/' ; } if ( substr ( $ url , - 4 , 4 ) != 'api/' ) { $ url .= 'api/' ; } $ this -> baseUrl = $ url ; return $ this ; } | Set the base URL for API endpoints |
55,585 | public function getList ( $ search = '' , $ start = 0 , $ limit = 0 , $ orderBy = '' , $ orderByDir = 'ASC' , $ publishedOnly = false , $ minimal = false ) { $ parameters = array ( 'search' => $ search , 'start' => $ start , 'limit' => $ limit , 'orderBy' => $ orderBy , 'orderByDir' => $ orderByDir , 'publishedOnly' =>... | Get a list of items |
55,586 | public function createBatch ( array $ parameters ) { $ supported = $ this -> isSupported ( 'createBatch' ) ; return ( true === $ supported ) ? $ this -> makeRequest ( $ this -> endpoint . '/batch/new' , $ parameters , 'POST' ) : $ supported ; } | Create a batch of new items |
55,587 | public function edit ( $ id , array $ parameters , $ createIfNotExists = false ) { $ method = $ createIfNotExists ? 'PUT' : 'PATCH' ; $ supported = $ this -> isSupported ( 'edit' ) ; return ( true === $ supported ) ? $ this -> makeRequest ( $ this -> endpoint . '/' . $ id . '/edit' , $ parameters , $ method ) : $ suppo... | Edit an item with option to create if it doesn t exist |
55,588 | public function editBatch ( array $ parameters , $ createIfNotExists = false ) { $ method = $ createIfNotExists ? 'PUT' : 'PATCH' ; $ supported = $ this -> isSupported ( 'editBatch' ) ; return ( true === $ supported ) ? $ this -> makeRequest ( $ this -> endpoint . '/batch/edit' , $ parameters , $ method ) : $ supported... | Edit a batch of items |
55,589 | public function deleteBatch ( array $ ids ) { $ supported = $ this -> isSupported ( 'deleteBatch' ) ; return ( true === $ supported ) ? $ this -> makeRequest ( $ this -> endpoint . '/batch/delete' , array ( 'ids' => $ ids ) , 'DELETE' ) : $ supported ; } | Delete a batch of items |
55,590 | protected function isSupported ( $ action ) { if ( empty ( $ this -> endpointsSupported ) || in_array ( $ action , $ this -> endpointsSupported ) ) { return true ; } return $ this -> actionNotSupported ( $ action ) ; } | Verify that a default endpoint is supported by the API |
55,591 | public function newAuth ( $ parameters = array ( ) , $ authMethod = 'OAuth' ) { $ class = 'Mautic\\Auth\\' . $ authMethod ; $ authObject = new $ class ( ) ; $ reflection = new \ ReflectionMethod ( $ class , 'setup' ) ; $ pass = array ( ) ; foreach ( $ reflection -> getParameters ( ) as $ param ) { if ( isset ( $ parame... | Get an API Auth object |
55,592 | protected function createCurlFile ( $ filename , $ mimetype = '' , $ postname = '' ) { if ( ! function_exists ( 'curl_file_create' ) ) { return "@$filename;filename=" . ( $ postname ? : basename ( $ filename ) ) . ( $ mimetype ? ";type=$mimetype" : '' ) ; } return curl_file_create ( $ filename , $ mimetype , $ postname... | Build the CURL file based on PHP version |
55,593 | protected function parseHeaders ( $ headersStr ) { $ headersArr = array ( ) ; $ headersHlpr = explode ( "\r\n" , $ headersStr ) ; foreach ( $ headersHlpr as $ header ) { $ pos = strpos ( $ header , ':' ) ; if ( $ pos === false ) { $ headersArr [ ] = trim ( $ header ) ; } else { $ headersArr [ trim ( substr ( $ header ,... | Build the HTTP response array out of the headers string |
55,594 | protected function separateUrlParams ( $ url , $ params ) { $ a = parse_url ( $ url ) ; if ( ! empty ( $ a [ 'query' ] ) ) { parse_str ( $ a [ 'query' ] , $ qparts ) ; $ cleanParams = array ( ) ; foreach ( $ qparts as $ k => $ v ) { $ cleanParams [ $ k ] = $ v ? $ v : '' ; } $ params = array_merge ( $ params , $ cleanP... | Separates parameters from base URL |
55,595 | public function getAccessTokenData ( ) { if ( $ this -> isOauth1 ( ) ) { return array ( 'access_token' => $ this -> _access_token , 'access_token_secret' => $ this -> _access_token_secret , 'expires' => $ this -> _expires , ) ; } return array ( 'access_token' => $ this -> _access_token , 'expires' => $ this -> _expires... | Returns access token data |
55,596 | public function setScope ( $ scope ) { if ( ! is_array ( $ scope ) ) { $ this -> _scope = explode ( ',' , $ scope ) ; } else { $ this -> _scope = $ scope ; } return $ this ; } | Set OAuth2 scope |
55,597 | public function validateAccessToken ( $ redirect = true ) { $ this -> _do_not_redirect = ! $ redirect ; $ this -> log ( 'validateAccessToken()' ) ; if ( ! empty ( $ this -> _expires ) && $ this -> _expires < time ( ) ) { $ this -> log ( 'access token expired so reauthorize' ) ; if ( strlen ( $ this -> _refresh_token ) ... | Validate existing access token |
55,598 | protected function requestToken ( $ responseType = 'flat' ) { $ this -> log ( 'requestToken()' ) ; $ settings = array ( 'responseType' => $ responseType , 'includeCallback' => true , 'includeVerifier' => false ) ; $ params = $ this -> makeRequest ( $ this -> _request_token_url , array ( ) , 'POST' , $ settings ) ; if (... | Request token for OAuth1 |
55,599 | private function buildAuthorizationHeader ( $ oauth ) { $ r = 'Authorization: OAuth ' ; $ values = $ this -> normalizeParameters ( $ oauth ) ; $ r .= str_replace ( '&' , ', ' , $ values ) ; return $ r ; } | Build header for OAuth 1 authorization |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.