idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
2,600
|
public function isDelimiter ( ) { for ( $ i = count ( $ this -> tokens ) - 1 ; $ i >= 0 ; $ i -- ) { $ t = $ this -> tokens [ $ i ] ; if ( $ t [ 0 ] === null || $ t [ 0 ] === 'COMMENT' ) { continue ; } elseif ( $ t [ 0 ] === 'OPENER' || $ t [ 0 ] === 'OPERATOR' ) { return true ; } elseif ( $ t [ 0 ] === 'IDENT' ) { switch ( $ t [ 1 ] ) { case 'lt' : case 'gt' : case 'le' : case 'ge' : case 'eq' : case 'ne' : case 'cmp' : case 'and' : case 'or' : case 'xor' : case 'if' : case 'elsif' : case 'while' : case 'unless' : case 'split' : case 'print' : return true ; } } return false ; } return true ; }
|
by looking behind in the token stream .
|
2,601
|
public function heredocRealOverride ( $ matches ) { $ this -> record ( $ matches [ 0 ] , null ) ; $ this -> posShift ( strlen ( $ matches [ 0 ] ) ) ; $ this -> removePattern ( 'HEREDOC_NL' ) ; assert ( $ this -> heredoc !== null ) ; $ delim = preg_quote ( $ this -> heredoc ) ; $ substr = $ this -> scanUntil ( '/^' . $ delim . '\\b/m' ) ; if ( $ substr !== null ) { $ this -> record ( $ substr , 'HEREDOC' ) ; $ delim_ = $ this -> scan ( '/' . $ delim . '/' ) ; assert ( $ delim !== null ) ; $ this -> record ( $ delim_ , 'DELIMITER' ) ; } else { $ this -> record ( $ this -> rest ( ) , 'HEREDOC' ) ; $ this -> terminate ( ) ; } }
|
this override handles the actual heredoc text
|
2,602
|
public function podCutOverride ( $ matches ) { $ line = $ this -> scan ( '/^=.*/m' ) ; assert ( $ line !== null ) ; $ term = '/^=cut$|\\z/m' ; $ substr = $ this -> scanUntil ( $ term ) ; assert ( $ substr !== null ) ; $ end = $ this -> scan ( $ term ) ; assert ( $ end !== null ) ; $ this -> record ( $ line . $ substr . $ end , 'DOCCOMMENT' ) ; }
|
we do it the old fashioned way
|
2,603
|
protected function generateI18n ( $ name , $ locale , $ parameters , $ referenceType = self :: ABSOLUTE_PATH ) { try { return $ this -> generator -> generate ( $ this -> routeNameInflector -> inflect ( $ name , $ locale ) , $ parameters , $ referenceType ) ; } catch ( RouteNotFoundException $ e ) { throw new RouteNotFoundException ( sprintf ( 'I18nRoute "%s" (%s) does not exist.' , $ name , $ locale ) ) ; } }
|
Generates a I18N URL from the given parameter
|
2,604
|
protected function getLocale ( $ parameters ) { if ( isset ( $ parameters [ 'locale' ] ) ) { return $ parameters [ 'locale' ] ; } if ( $ this -> getContext ( ) -> hasParameter ( '_locale' ) ) { return $ this -> getContext ( ) -> getParameter ( '_locale' ) ; } return $ this -> defaultLocale ; }
|
Determine the locale to be used with this request
|
2,605
|
public function parseJson ( $ json ) { $ this -> id = $ json [ 'id' ] ; $ this -> name = $ json [ 'name' ] ; $ this -> links = $ json [ 'links' ] ; if ( isset ( $ json [ 'xmpp_jid' ] ) ) { $ this -> xmppJid = $ json [ 'xmpp_jid' ] ; $ this -> created = new \ DateTime ( $ json [ 'created' ] ) ; $ this -> archived = $ json [ 'is_archived' ] ; $ this -> privacy = $ json [ 'privacy' ] ; $ this -> guestAccessible = $ json [ 'is_guest_accessible' ] ; $ this -> topic = $ json [ 'topic' ] ; $ this -> participants = array ( ) ; foreach ( $ json [ 'participants' ] as $ participant ) { $ this -> participants [ ] = new User ( $ participant ) ; } $ this -> owner = new User ( $ json [ 'owner' ] ) ; $ this -> guestAccessUrl = $ json [ 'guest_access_url' ] ; } }
|
Parses response given by the API and maps the fields to Room object
|
2,606
|
public function toJson ( ) { $ json = array ( ) ; $ json [ 'name' ] = $ this -> getName ( ) ; $ json [ 'privacy' ] = $ this -> getPrivacy ( ) ; if ( $ this -> getId ( ) ) { $ json [ 'is_archived' ] = $ this -> isArchived ( ) ; $ json [ 'is_guest_accessible' ] = $ this -> isGuestAccessible ( ) ; $ json [ 'topic' ] = $ this -> getTopic ( ) ; $ json [ 'owner' ] = array ( 'id' => $ this -> getOwner ( ) -> getId ( ) ) ; } else { $ json [ 'guest_access' ] = $ this -> isGuestAccessible ( ) ; if ( $ this -> getOwner ( ) ) { $ json [ 'owner_user_id' ] = $ this -> getOwner ( ) -> getId ( ) ; } } return $ json ; }
|
Serializes Room object
|
2,607
|
public function run ( ) { try { $ vulnerabilities = $ this -> checker -> check_site ( $ this -> options -> ignored_packages ) ; do_action ( 'soter_site_check_complete' , $ vulnerabilities ) ; $ this -> options -> get_store ( ) -> set ( 'last_scan_hash' , $ vulnerabilities -> hash ( ) ) ; } catch ( \ RuntimeException $ e ) { $ options = _soter_instance ( 'options_manager' ) ; $ use_html = 'html' === $ options -> email_type ; wp_mail ( $ options -> email_address , 'HTTP error while checking ' . get_bloginfo ( 'name' ) . ' for vulnerabilities' , $ use_html ? $ this -> render_html_error_email ( $ e ) : $ this -> render_text_error_email ( $ e ) , $ use_html ? [ 'Content-type: text/html' ] : [ ] ) ; } }
|
Run the site check .
|
2,608
|
public function render_html_error_email ( $ exception , CssToInlineStyles $ inliner = null ) { $ plates = _soter_instance ( 'plates' ) ; $ html = $ plates -> render ( 'emails/html/error.php' , [ 'message' => $ exception -> getMessage ( ) , ] ) ; $ css = $ plates -> render ( 'emails/style.css' ) ; $ inliner = $ inliner ? : new CssToInlineStyles ( ) ; return $ inliner -> convert ( $ html , $ css ) ; }
|
Render the contents of the HTML error notification .
|
2,609
|
protected function rebuildFiles ( Array $ files ) { DependencyInjector :: getInstance ( ) -> generateDependenciesDeclaration ( ) ; $ this -> setLayout ( 'manager/templates.tpl' ) ; $ output = array ( ) ; $ instance_inheritance = array_unique ( \ Sifo \ Domains :: getInstance ( ) -> getInstanceInheritance ( ) ) ; $ instance_inheritance_reverse = array_reverse ( $ instance_inheritance ) ; foreach ( $ instance_inheritance_reverse as $ key => $ instance ) { $ instance_config [ 'current' ] = $ instance ; if ( isset ( $ instance_inheritance [ $ key + 1 ] ) ) { $ instance_config [ 'parent' ] = $ instance_inheritance_reverse [ $ key + 1 ] ; } $ instances_configuration [ ] = $ instance_config ; unset ( $ instance_config ) ; } foreach ( $ instances_configuration as $ instance ) { $ current_instance = $ instance [ 'current' ] ; $ this -> assign ( 'instance_parent' , null ) ; if ( isset ( $ instance [ 'parent' ] ) ) { $ this -> assign ( 'instance_parent' , $ instance [ 'parent' ] ) ; } foreach ( $ files as $ file => $ folders ) { $ configs = array ( ) ; foreach ( $ folders as $ folder ) { $ configs = array_merge ( $ configs , $ this -> getAvailableFiles ( $ folder , $ current_instance ) ) ; } $ this -> assign ( 'config' , $ configs ) ; $ this -> assign ( 'file_name' , $ this -> filenames [ $ file ] ) ; $ configs_content = $ this -> grabHtml ( ) ; $ file_destination = ROOT_PATH . "/instances/" . $ current_instance . "/config/" . $ this -> filenames [ $ file ] ; if ( $ current_instance == 'common' ) { $ file_destination = ROOT_PATH . "/vendor/sifophp/sifo-common-instance/config/" . $ this -> filenames [ $ file ] ; } $ success = file_put_contents ( $ file_destination , $ configs_content ) ; if ( ! $ success ) { $ this -> failed_files [ ] = $ file_destination ; } $ output [ $ current_instance ] [ $ file ] = $ configs_content ; } } return $ output ; }
|
Writes all the configurattion files to disk .
|
2,610
|
public function setArguments ( $ name , $ required = false , $ description = 'Argument description' ) { $ required ? $ required = InputArgument :: REQUIRED : $ required = InputArgument :: OPTIONAL ; $ this -> addArgument ( $ name , $ required , $ description ) ; }
|
Add argument to a command .
|
2,611
|
public function setOption ( $ name , $ shortcut = null , $ inputRequired = false , $ description = 'option does what?' ) { $ inputRequired ? $ inputRequired = InputOption :: VALUE_REQUIRED : $ inputRequired = InputOption :: VALUE_OPTIONAL ; $ this -> addOption ( $ name , $ shortcut , $ inputRequired , $ description ) ; }
|
Add options to command .
|
2,612
|
public function offsetSet ( $ name , $ value ) { $ cookie = $ this -> _classes [ 'cookie' ] ; $ value = $ this -> _autobox ( $ name , $ value ) ; if ( ! $ value instanceof $ cookie ) { throw new RuntimeException ( "Error, only `{$cookie}` instances are allowed in this collection." ) ; } $ hash = $ name . ';' . $ value -> domain ( ) . ';' . $ value -> path ( ) ; $ this -> _hashes [ $ name ] [ ] = $ hash ; $ this -> _names [ $ hash ] = $ name ; return $ this -> _data [ $ hash ] = $ value ; }
|
Adds a cookie to the collection .
|
2,613
|
public function offsetGet ( $ name ) { $ data = [ ] ; if ( ! isset ( $ this -> _hashes [ $ name ] ) ) { throw new RuntimeException ( "Unexisting Set-Cookie `'{$name}'`." ) ; } foreach ( $ this -> _hashes [ $ name ] as $ key => $ hash ) { $ data [ ] = $ this -> _data [ $ hash ] ; } return $ data ; }
|
Gets a set - cookie .
|
2,614
|
public function offsetUnset ( $ name ) { if ( ! isset ( $ this -> _hashes [ $ name ] ) ) { return ; } foreach ( $ this -> _hashes [ $ name ] as $ hash ) { unset ( $ this -> _data [ $ hash ] ) ; unset ( $ this -> _names [ $ hash ] ) ; } unset ( $ this -> _hashes [ $ name ] ) ; }
|
Removes all set - cookies of a specific name .
|
2,615
|
protected function _autobox ( $ name , $ value ) { if ( is_object ( $ value ) ) { return $ value ; } $ cookie = $ this -> _classes [ 'cookie' ] ; if ( ! is_array ( $ value ) ) { $ value = [ 'value' => $ value ] ; } $ value [ 'name' ] = $ name ; return new $ cookie ( $ value ) ; }
|
Autoboxes a cookie value .
|
2,616
|
public function flushExpired ( ) { foreach ( $ this -> _hashes as $ name => $ hashes ) { foreach ( $ hashes as $ key => $ hash ) { $ cookie = $ this -> _data [ $ hash ] ; if ( $ cookie -> expired ( ) ) { unset ( $ this -> _data [ $ hash ] ) ; unset ( $ this -> _names [ $ hash ] ) ; unset ( $ this -> _hashes [ $ name ] [ $ key ] ) ; if ( ! $ this -> _hashes [ $ name ] ) { unset ( $ this -> _hashes [ $ name ] ) ; } } } } return $ this ; }
|
Removes expired cookies .
|
2,617
|
public function clear ( $ domain = null , $ path = null , $ name = null ) { if ( ! $ domain ) { $ this -> _data = [ ] ; return ; } elseif ( ! $ path ) { $ this -> _data = array_filter ( $ this -> _data , function ( $ cookie ) use ( $ path , $ domain ) { return ! $ cookie -> matchesDomain ( $ domain ) ; } ) ; } elseif ( ! $ name ) { $ this -> _data = array_filter ( $ this -> _data , function ( $ cookie ) use ( $ path , $ domain ) { return ! ( $ cookie -> matchesPath ( $ path ) && $ cookie -> matchesDomain ( $ domain ) ) ; } ) ; } else { $ this -> _data = array_filter ( $ this -> _data , function ( $ cookie ) use ( $ path , $ domain , $ name ) { return ! ( $ cookie -> name ( ) == $ name && $ cookie -> matchesPath ( $ path ) && $ cookie -> matchesDomain ( $ domain ) ) ; } ) ; } return $ this ; }
|
Remove some cookies from the Jar .
|
2,618
|
public function clearSessionCookies ( ) { $ this -> _data = array_filter ( $ this -> _data , function ( $ cookie ) { return ! $ cookie -> discard ( ) && $ cookie -> expires ( ) ; } ) ; return $ this ; }
|
Clear session based cookies .
|
2,619
|
public function fetchCookies ( $ request , $ response ) { foreach ( $ response -> cookies ( $ request ) as $ cookie ) { $ this -> add ( $ cookie ) ; } return $ this ; }
|
Collect the Set - Cookie header from a response .
|
2,620
|
public static function toArray ( $ cookies , $ options = [ ] ) { $ data = [ ] ; foreach ( $ cookies as $ name => $ cookie ) { $ data [ $ name ] [ ] = $ cookie -> data ( ) ; } return $ data ; }
|
Exports set - cookies .
|
2,621
|
public static function toResource ( $ obj , $ transformer ) : ResourceAbstract { if ( ! $ obj ) return new NullResource ( ) ; $ resource = null ; try { if ( is_array ( $ obj ) ) { $ resource = new Collection ( $ obj , new $ transformer ( ) , get_class ( $ obj [ 0 ] ) ) ; } else { $ resource = new Item ( $ obj , new $ transformer ( ) , get_class ( $ obj ) ) ; } } catch ( \ Error $ e ) { throw new DWDLibException ( "Specified transformer is not a class. Got transformer with the class=" . get_class ( $ transformer ) ) ; } return $ resource ; }
|
Transform the given object or array with the given transformer to a Resource .
|
2,622
|
protected function setNextNumPage ( ) { $ this -> next_num_page = 0 ; if ( $ this -> current_page_number < $ this -> num_pages ) { $ this -> next_num_page = ( $ this -> current_page_number + 1 ) ; } }
|
Set next page number .
|
2,623
|
public function setItemsPerPage ( $ items_per_page ) { if ( ! is_int ( $ items_per_page ) ) { trigger_error ( 'Pagination setItemsPerPage: Items per page must be an integer.' ) ; return false ; } if ( $ items_per_page <= 0 ) { trigger_error ( 'Pagination setItemsPerPage: Items per page must be a positive integer.' ) ; return false ; } $ this -> items_per_page = $ items_per_page ; }
|
Set number of items per page .
|
2,624
|
public function setMaxPages ( $ max_num_pages ) { if ( ! is_int ( $ max_num_pages ) ) { trigger_error ( 'Pagination setMaxPages: Maxim number of pages must be an integer.' ) ; return false ; } if ( $ max_num_pages <= 0 ) { trigger_error ( 'Pagination setMaxPages: Maxim number of pages must be a positive integer.' ) ; return false ; } $ this -> max_num_pages = $ max_num_pages ; }
|
Set maxim number of pages to show .
|
2,625
|
public function setNumTotalResults ( $ total ) { $ total = ( int ) $ total ; if ( $ total < 0 ) { trigger_error ( 'Pagination setNumTotalResults: Total must be positive.' ) ; return false ; } $ this -> items_total = $ total ; }
|
Set the total number of items .
|
2,626
|
public function setTemplateParam ( $ param , $ value ) { if ( ! isset ( $ param ) || empty ( $ param ) || ! isset ( $ value ) ) { trigger_error ( "The parameter \$param or \$value can't be empty." ) ; return false ; } $ this -> params_template [ $ param ] = $ value ; }
|
Set a parameter assigned to the pagination template .
|
2,627
|
public function setTemplate ( $ layout_template ) { $ tpl_config = $ this -> config -> getConfig ( 'templates' ) ; if ( ! isset ( $ tpl_config [ $ layout_template ] ) ) { trigger_error ( "Template file '$layout_template' not found." ) ; return false ; } $ this -> layout_template = ROOT_PATH . '/' . $ tpl_config [ $ layout_template ] ; }
|
Set the pagination template .
|
2,628
|
public function setDisplayItemsPerPage ( $ values_to_show ) { $ this -> display_items_per_page [ 'display' ] = false ; if ( ! empty ( $ values_to_show ) && is_array ( $ values_to_show ) ) { $ result = array_filter ( $ values_to_show , "is_integer" ) ; $ this -> display_items_per_page [ 'display' ] = true ; $ this -> display_items_per_page [ 'values' ] = $ result ; } }
|
Set display items per page .
|
2,629
|
public function sign ( string $ data , string $ secret ) : string { return base64_encode ( hash_hmac ( 'md5' , $ data , $ secret , true ) ) ; }
|
Sign current datas
|
2,630
|
protected function getFinalSchemas ( KernelInterface $ kernel , BundleInterface $ bundle = null ) { if ( null !== $ bundle ) { return $ this -> getSchemasFromBundle ( $ bundle ) ; } $ finalSchemas = array ( ) ; foreach ( $ kernel -> getBundles ( ) as $ bundle ) { $ finalSchemas = array_merge ( $ finalSchemas , $ this -> getSchemasFromBundle ( $ bundle ) ) ; } return $ finalSchemas ; }
|
Return a list of final schema files that will be processed .
|
2,631
|
public function logIn ( array $ user_infos ) : void { $ _SESSION [ 'phunder' ] [ 'user' ] [ 'logged_in' ] = true ; $ this -> infos = array_merge ( $ this -> infos , $ user_infos ) ; $ this -> save ( ) ; }
|
Declare the current user as logged in
|
2,632
|
public function setModule ( $ namespace ) { $ nsParts = explode ( '\\' , $ namespace ) ; $ moduleClass = $ nsParts [ 0 ] . '\Module' ; if ( ! class_exists ( $ moduleClass , true ) ) { throw new InvalidArgumentException ( sprintf ( "The Module class was not found in the '%s' namespace." , $ namespace ) ) ; } $ module = new $ moduleClass ( ) ; if ( $ module instanceof AbstractModule ) { $ this -> moduleDir = realpath ( $ module -> getDir ( ) ) ; return $ this ; } $ reflection = new ReflectionClass ( $ module ) ; $ this -> moduleDir = realpath ( dirname ( $ reflection -> getFileName ( ) ) ) ; return $ this ; }
|
Allows you to change the module . The root directory of the module is calculated as the directory that contains the file of the Module class .
|
2,633
|
public function module ( $ path = '' , $ checkIfExists = false ) { $ moduleDir = $ this -> moduleDir ; if ( $ checkIfExists ) { return realpath ( $ moduleDir . DS . $ path ) ; } if ( empty ( $ path ) ) { return $ moduleDir ; } return $ moduleDir . DS . $ this -> normalizePath ( $ path ) ; }
|
Returns the path to the root directory of the module or any child path .
|
2,634
|
public function app ( $ path = '' , $ checkIfExists = false ) { $ appDir = getcwd ( ) ; if ( $ checkIfExists ) { return realpath ( $ appDir . DS . $ path ) ; } if ( empty ( $ path ) ) { return $ appDir ; } return $ appDir . DS . $ this -> normalizePath ( $ path ) ; }
|
Returns the path to the root directory of the appliacation or any child path .
|
2,635
|
public function appAutoload ( $ path = '' , $ checkIfExists = false ) { $ appAutoloadDir = getcwd ( ) . $ this -> getRelativeAppAutoloadDir ( ) ; if ( $ checkIfExists ) { return realpath ( $ appAutoloadDir . DS . $ path ) ; } if ( empty ( $ path ) ) { return $ appAutoloadDir ; } return $ appAutoloadDir . DS . $ this -> normalizePath ( $ path ) ; }
|
Returns the path to the application autoload directory or any child path .
|
2,636
|
public function appPublic ( $ path = '' , $ checkIfExists = false ) { $ appPublicDir = getcwd ( ) . $ this -> getRelativeAppPublicDir ( ) ; if ( $ checkIfExists ) { return realpath ( $ appPublicDir . DS . $ path ) ; } if ( empty ( $ path ) ) { return $ appPublicDir ; } return $ appPublicDir . DS . $ this -> normalizePath ( $ path ) ; }
|
Returns the path to the application public directory or any child path .
|
2,637
|
public function appUploads ( $ path = '' , $ checkIfExists = false ) { $ appUploadsDir = getcwd ( ) . $ this -> getRelativeAppUploadsDir ( ) ; if ( $ checkIfExists ) { return realpath ( $ appUploadsDir . DS . $ path ) ; } if ( empty ( $ path ) ) { return $ appUploadsDir ; } return $ appUploadsDir . DS . $ this -> normalizePath ( $ path ) ; }
|
Returns the path to the upload directory or any child path .
|
2,638
|
public static function fromFilename ( $ filename ) { $ contents = file_get_contents ( $ filename ) ; $ jsonData = json_decode ( $ contents , true ) ; $ instance = new self ( $ jsonData ) ; return $ instance ; }
|
Construct from filename
|
2,639
|
public static function fromUrl ( $ url ) { $ client = new GuzzleHttp \ Client ( ) ; $ response = $ client -> get ( $ url ) ; $ jsonData = json_decode ( $ response -> getBody ( ) , true ) ; $ instance = new self ( $ jsonData ) ; return $ instance ; }
|
Construct from URL
|
2,640
|
public function register ( \ Closure $ runner , $ options = array ( ) ) { $ this -> runner = $ runner ; $ this -> options = $ options ; return $ this ; }
|
Register the runner and options for delay run
|
2,641
|
public function send ( $ msg ) { if ( $ this -> queue && is_resource ( $ this -> queue ) && msg_stat_queue ( $ this -> queue ) ) { return msg_send ( $ this -> queue , 1 , array ( 'from' => $ this -> isMaster ( ) ? $ this -> ppid : $ this -> pid , 'to' => $ this -> isMaster ( ) ? $ this -> pid : $ this -> ppid , 'body' => $ msg ) , true , false , $ error ) ; } return false ; }
|
Send msg to child process
|
2,642
|
private function getStartingRow ( $ sheet ) : int { $ row = null ; for ( $ i = 1 ; $ i <= 4 && ! $ row ; $ i ++ ) { if ( $ sheet -> getCellByColumnAndRow ( 1 , $ i ) == "Cod." ) { $ row = $ i + 1 ; } } return $ row ; }
|
Returns the spreadsheet row number for which the extractor should start extracting row data .
|
2,643
|
protected function getNodeString ( Filter $ node , Compiler $ compiler = null ) { return array_reduce ( $ node -> block -> nodes , function ( & $ result , $ line ) use ( $ compiler ) { $ val = $ compiler ? $ compiler -> interpolate ( $ line -> value ) : $ line -> value ; return $ result .= $ val . "\n" ; } ) ; }
|
Returns the node string value line by line . If the compiler is present that means we need to interpolate line contents
|
2,644
|
public function createSend ( $ sender = '' , $ messages = array ( ) , $ scheduledate = '' ) { $ message_sender = array ( ) ; $ index = 0 ; $ url = $ this -> _setEnvironment . 'wcf/Service.svc/rest/CreateSend' ; if ( is_array ( $ messages ) ) { foreach ( $ messages as $ mobile => $ message ) { $ message_sender [ $ index ] [ 'Mobile' ] = $ mobile ; $ message_sender [ $ index ] [ 'Text' ] = $ message ; $ index ++ ; } } $ json = array ( 'UserName' => $ this -> user , 'Password' => $ this -> password , 'Sender' => $ sender , 'Messages' => $ message_sender , 'ScheduleDate' => $ scheduledate , ) ; try { $ response = $ this -> client -> post ( $ url , [ 'headers' => [ 'Content-Type' => 'application/json' , 'Accept' => 'application/json' ] , 'body' => json_encode ( $ json ) ] ) ; $ result = json_decode ( $ response -> getBody ( ) -> getContents ( ) , true ) ; $ result [ 'Status' ] = $ response -> getStatusCode ( ) ; $ result = json_decode ( json_encode ( $ result ) ) ; } catch ( RequestException $ e ) { $ result = $ this -> StatusCodeHandling ( $ e ) ; } return $ result ; }
|
This operation allows you to send 1 or more messages in a single call .
|
2,645
|
public function createMessage ( $ sender = '' , $ mobile = '' , $ message = '' , $ scheduledate = '' ) { $ url = $ this -> _setEnvironment . 'wcf/Service.svc/rest/CreateMessage' ; $ json = array ( 'UserName' => $ this -> user , 'Password' => $ this -> password , 'Sender' => $ sender , 'Mobile' => $ mobile , 'Text' => $ message , 'ScheduleDate' => $ scheduledate , ) ; try { $ response = $ this -> client -> post ( $ url , [ 'headers' => [ 'Content-Type' => 'application/json' , 'Accept' => 'application/json' ] , 'body' => json_encode ( $ json ) ] ) ; $ result = json_decode ( $ response -> getBody ( ) -> getContents ( ) , true ) ; $ result [ 'Status' ] = $ response -> getStatusCode ( ) ; $ result = json_decode ( json_encode ( $ result ) ) ; } catch ( RequestException $ e ) { $ result = $ this -> StatusCodeHandling ( $ e ) ; } return $ result ; }
|
This operation allows you to send 1 message on a single call .
|
2,646
|
protected function statusCodeHandling ( $ e ) { $ response = ( object ) array ( "Status" => $ e -> getResponse ( ) -> getStatusCode ( ) , "Error" => json_decode ( $ e -> getResponse ( ) -> getBody ( true ) -> getContents ( ) ) ) ; return $ response ; }
|
Return message error
|
2,647
|
public function queue ( ) { $ log = $ this -> getLogger ( ) ; $ log -> info ( 'Queueing operation started' , array ( 'collections' => count ( $ this ) ) ) ; $ event = new CollectorEvent ( $ this ) ; $ this -> dispatchEvent ( SearchEvents :: COLLECTOR_PRE_QUEUE , $ event ) ; $ num_queued = 0 ; foreach ( $ this -> _collections as $ collection ) { $ num_queued += $ this -> queueCollection ( $ collection ) ; } $ this -> dispatchEvent ( SearchEvents :: COLLECTOR_POST_QUEUE , $ event ) ; $ log -> info ( 'Queueing operation completed' , array ( 'queued' => $ num_queued ) ) ; return $ num_queued ; }
|
Queues the items scheduled for indexing for all collections attached to the collector .
|
2,648
|
public function queueCollection ( CollectionAbstract $ collection ) { $ log = $ this -> getLogger ( ) ; $ context = array ( 'collection' => $ collection -> getId ( ) ) ; $ log -> info ( 'Begin fetching items that are scheduled for indexing' , $ context ) ; $ event = new CollectionEvent ( $ this , $ collection ) ; $ this -> dispatchEvent ( SearchEvents :: COLLECTION_PRE_QUEUE , $ event , $ context ) ; $ producer = new QueueProducer ( $ this , $ collection ) ; foreach ( $ producer as $ message ) { $ message -> publish ( ) ; $ context [ 'item' ] = $ message -> getBody ( ) ; $ log -> debug ( 'Published item scheduled for indexing to queue' , $ context ) ; } unset ( $ context [ 'item' ] ) ; $ this -> dispatchEvent ( SearchEvents :: COLLECTION_POST_QUEUE , $ event , $ context ) ; $ num_queued = count ( $ producer ) ; $ context [ 'queued' ] = $ num_queued ; $ log -> info ( 'Finished fetching and queueing items that are scheduled for indexing' , $ context ) ; return $ num_queued ; }
|
Queues the items scheduled for indexing for the collection .
|
2,649
|
public static function getConstructArguments ( $ objectClasses , $ annotationReader ) { $ constructArguments = null ; array_reverse ( $ objectClasses ) ; foreach ( $ objectClasses as $ class ) { $ annotation = $ annotationReader -> getClassAnnotation ( $ class , self :: $ constructAnnotationClass ) ; if ( $ annotation !== null ) { $ constructArguments = $ annotation -> getArguments ( ) ; break ; } } return $ constructArguments ; }
|
Get the list of needed arguments for given object s constructor .
|
2,650
|
public static function getPropertiesToInitialize ( $ properties , $ annotationReader ) { $ propertiesValues = array ( ) ; foreach ( $ properties as $ propertyName => $ property ) { $ initializeAnnotation = $ annotationReader -> getPropertyAnnotation ( $ property , self :: $ initializeAnnotationClass ) ; $ initializeObjectAnnotation = $ annotationReader -> getPropertyAnnotation ( $ property , self :: $ initializeObjectAnnotationClass ) ; if ( $ initializeAnnotation !== null && $ initializeObjectAnnotation !== null ) { throw new \ LogicException ( "Two initial values are given for property $propertyName." ) ; } if ( $ initializeAnnotation !== null ) { $ propertiesValues [ $ propertyName ] = array ( 'type' => 'initialize' , 'value' => $ initializeAnnotation -> getValue ( ) ) ; } else if ( $ initializeObjectAnnotation !== null ) { $ propertiesValues [ $ propertyName ] = array ( 'type' => 'initializeObject' , 'value' => $ initializeObjectAnnotation -> getClassName ( ) ) ; } } return $ propertiesValues ; }
|
Get the list of properties that have to be initialized automatically during the object construction plus their value .
|
2,651
|
public function addSinglePattern ( $ pattern , $ ruleName , $ childRuleName ) { return $ this -> addPattern ( $ pattern , $ ruleName , self :: SINGLE_RULE_PREFIX . $ childRuleName ) ; }
|
Add single pattern . If pattern match change to provided rule and immediately back
|
2,652
|
protected function addPattern ( $ pattern , $ ruleName , $ childRuleName = null ) { if ( ! isset ( $ this -> patterns [ $ ruleName ] ) ) { $ this -> patterns [ $ ruleName ] = new LexerPattern ( $ ruleName ) ; } $ this -> patterns [ $ ruleName ] -> addPattern ( $ pattern , $ childRuleName ) ; return $ this ; }
|
Add pattern to rule patterns
|
2,653
|
protected function reduce ( & $ text ) { if ( ! array_key_exists ( $ this -> stack -> top ( ) , $ this -> patterns ) ) { return false ; } if ( $ text !== '' && ( $ data = $ this -> patterns [ $ this -> stack -> top ( ) ] -> split ( $ text ) ) !== false ) { list ( $ unmatched , $ matched , $ text , $ childRuleName ) = $ data ; return [ $ unmatched , $ matched , $ childRuleName ] ; } return true ; }
|
Reduce input text length by patterns match
|
2,654
|
public static function getAccessProperties ( $ properties , $ annotationReader ) { $ objectAccessProperties = array ( ) ; foreach ( $ properties as $ propertyName => $ property ) { if ( empty ( $ objectAccessProperties [ $ propertyName ] ) ) { $ objectAccessProperties [ $ propertyName ] = array ( ) ; } $ propertyAccessAnnotation = $ annotationReader -> getPropertyAnnotation ( $ property , self :: $ accessAnnotationClass ) ; $ accessProperties = array ( ) ; if ( $ propertyAccessAnnotation !== null ) { $ accessProperties = $ propertyAccessAnnotation -> getAccessProperties ( ) ; } $ collectionAnnotation = null ; foreach ( self :: $ collectionAnnotationClasses as $ annotationBehavior => $ annotationClass ) { $ collectionAnnotation = $ annotationReader -> getPropertyAnnotation ( $ property , $ annotationClass ) ; if ( $ collectionAnnotation !== null ) { break ; } } $ collectionMethods = array ( ) ; if ( $ collectionAnnotation !== null ) { $ collectionMethods = $ collectionAnnotation -> getMethods ( ) ; } $ objectAccessProperties [ $ propertyName ] = array_merge ( $ accessProperties , $ collectionMethods ) ; } return $ objectAccessProperties ; }
|
Get a list of properties and the access that are given to them for given object .
|
2,655
|
public static function get ( ) { $ widgets = [ ] ; foreach ( Packages :: all ( ) as $ package ) { $ dir = __DIR__ . '/../../' . $ package . '/src' ; $ files = is_dir ( $ dir ) ? scandir ( $ dir ) : [ ] ; foreach ( $ files as $ file ) { if ( $ file == 'Widgets.json' ) { $ file_r = file_get_contents ( $ dir . '/' . $ file ) ; foreach ( json_decode ( $ file_r , true ) as $ w ) { $ w [ 'package' ] = $ package ; array_push ( $ widgets , $ w ) ; } break ; } } } $ widgets = static :: orderByPreference ( $ widgets ) ; return $ widgets ; }
|
Returns all the widgets .
|
2,656
|
public static function orderByPreference ( $ widgets ) { $ preference = collect ( [ 'laralum' , 'dashboard' , 'users' , 'roles' , 'permissions' ] ) ; $ ordered_widgets = [ ] ; $ final_ordered_widgets = [ ] ; $ widgets = collect ( $ widgets ) -> groupBy ( 'package' ) -> toArray ( ) ; foreach ( Packages :: all ( ) as $ package ) { if ( ! in_array ( $ package , $ preference -> toArray ( ) ) ) { $ preference -> push ( $ package ) ; } } $ ordered_widgets = $ preference -> map ( function ( $ p ) use ( $ widgets ) { return array_key_exists ( $ p , $ widgets ) ? $ widgets [ $ p ] : null ; } ) -> filter ( ) ; foreach ( $ ordered_widgets as $ widget ) { foreach ( $ widget as $ w ) { array_push ( $ final_ordered_widgets , $ w ) ; } } return $ final_ordered_widgets ; }
|
Order the widgets by preference .
|
2,657
|
private function getQualityFactor ( ) { $ qFactor = 0.0 ; if ( 2 === count ( explode ( '/' , $ this -> variant ) ) ) { $ qFactor = $ this -> qFactor ; } return $ qFactor ; }
|
Get the variants s quality factor defaulting to 0 on absent variant .
|
2,658
|
public function setLabelAttributes ( array $ attribs ) { foreach ( $ attribs as $ a => $ v ) { $ this -> setLabelAttribute ( $ a , $ v ) ; } return $ this ; }
|
Set the attributes of the label of the form element object
|
2,659
|
public function setHintAttributes ( array $ attribs ) { foreach ( $ attribs as $ a => $ v ) { $ this -> setHintAttribute ( $ a , $ v ) ; } return $ this ; }
|
Set the attributes of the hint of the form element object
|
2,660
|
public function addValidator ( $ validator ) { if ( ! ( $ validator instanceof \ Pop \ Validator \ AbstractValidator ) && ! is_callable ( $ validator ) ) { throw new Exception ( 'Error: The validator must be an instance of Pop\Validator\AbstractValidator or a callable object.' ) ; } $ this -> validators [ ] = $ validator ; return $ this ; }
|
Add a validator the form element
|
2,661
|
public static function fromJson ( string $ name , bool $ endsWithSession , DateTimeImmutable $ issuedAt , string $ json ) : self { $ cookie = new self ( $ name , $ endsWithSession , $ issuedAt ) ; $ cookie -> data = json_decode ( $ json , true ) ; if ( ! is_array ( $ cookie -> data ) ) { throw JsonException :: fromJsonDecodeError ( json_last_error_msg ( ) ) ; } return $ cookie ; }
|
Creates a new cookie instance from JSON encoded data .
|
2,662
|
public function toJson ( ) : string { $ json = json_encode ( $ this -> data ) ; if ( false === $ json ) { throw JsonException :: fromJsonEncodeError ( json_last_error_msg ( ) ) ; } return $ json ; }
|
Serializes the cookie data as JSON .
|
2,663
|
public function boot ( Container $ container ) { add_action ( 'admin_init' , [ $ this -> proxy ( $ container , 'options_page' ) , 'admin_init' ] ) ; add_action ( 'admin_menu' , [ $ this -> proxy ( $ container , 'options_page' ) , 'admin_menu' ] ) ; add_action ( 'admin_notices' , [ $ this -> proxy ( $ container , 'options_page' ) , 'print_notice_when_no_notifiers_active' ] ) ; add_action ( 'admin_init' , [ $ this -> proxy ( $ container , 'options_manager' ) , 'register_settings' ] ) ; add_action ( 'soter_run_check' , [ $ this -> proxy ( $ container , 'check_site_job' ) , 'run' ] ) ; add_action ( 'soter_site_check_complete' , [ $ this -> proxy ( $ container , 'notifier_manager' ) , 'notify' ] ) ; $ this -> boot_upgrader ( $ container ) ; }
|
Provider - specific boot logic .
|
2,664
|
public function register ( Container $ container ) { $ container [ 'check_site_job' ] = function ( Container $ c ) { return new Check_Site_Job ( $ c [ 'checker' ] , $ c [ 'options_manager' ] ) ; } ; $ container [ 'checker' ] = function ( Container $ c ) { $ checker = new Checker ( new Api_Client ( $ c [ 'http' ] ) , new WP_Package_Manager ( ) ) ; $ checker -> add_post_check_callback ( function ( $ vulnerabilities , $ response ) { do_action ( 'soter_package_check_complete' , $ vulnerabilities , $ response ) ; } ) ; return $ checker ; } ; $ container [ 'http' ] = function ( Container $ c ) { return new Cached_Http_Client ( new WP_Http_Client ( $ c [ 'user_agent' ] ) , new WP_Transient_Cache ( $ c [ 'prefix' ] , HOUR_IN_SECONDS ) ) ; } ; $ container [ 'notifier_manager' ] = function ( Container $ c ) { $ options = $ c [ 'options_manager' ] ; return new Notifier_Manager ( $ options , [ new Email_Notifier ( $ c [ 'plates' ] , $ options ) , new Slack_Notifier ( $ options , $ c [ 'user_agent' ] ) , ] ) ; } ; $ container [ 'options_manager' ] = function ( Container $ c ) { return new Options_Manager ( new Options_Store ( $ c [ 'prefix' ] ) ) ; } ; $ container [ 'options_page' ] = function ( Container $ c ) { return new Options_Page ( $ c [ 'options_manager' ] , $ c [ 'plates' ] ) ; } ; $ container [ 'plates' ] = function ( Container $ c ) { $ engine = new Engine ( $ c [ 'dir' ] . '/templates' ) ; $ engine -> setFileExtension ( null ) ; $ engine -> loadExtension ( new Button_Extension ( ) ) ; $ engine -> addData ( [ 'plugin_url' => $ c [ 'url' ] , 'site_name' => get_bloginfo ( 'name' ) , 'site_url' => site_url ( ) , ] , [ 'emails/html/error.php' , 'emails/html/vulnerable.php' , 'emails/partials/footer.php' , 'emails/partials/header.php' , 'emails/text/error.php' , 'emails/text/vulnerable.php' , ] ) ; return $ engine ; } ; $ container [ 'user_agent' ] = function ( Container $ c ) { return sprintf ( '%s (%s) | %s | v%s | %s' , get_bloginfo ( 'name' ) , get_home_url ( ) , $ c [ 'name' ] , $ c [ 'version' ] , $ c [ 'url' ] ) ; } ; }
|
Provider - specific registration logic .
|
2,665
|
protected function boot_upgrader ( Container $ container ) { if ( ! $ this -> doing_cron ( ) && ! is_admin ( ) ) { return ; } $ upgrader = new Upgrader ( $ container [ 'options_manager' ] ) ; add_action ( 'init' , [ $ upgrader , 'perform_upgrade' ] ) ; }
|
Boots the upgrader object on cron or admin requests .
|
2,666
|
public function push ( $ headers , $ value = '' ) { if ( is_string ( $ headers ) && func_num_args ( ) === 2 ) { $ headers = [ $ headers => $ value ] ; } return $ this -> _set ( $ headers ) ; }
|
Sets some headers .
|
2,667
|
public function prepend ( $ headers , $ value = '' ) { if ( is_string ( $ headers ) && func_num_args ( ) === 2 ) { $ headers = [ $ headers => $ value ] ; } return $ this -> _set ( $ headers , true ) ; }
|
Prepends some headers .
|
2,668
|
public function offsetExists ( $ name ) { $ name = strtolower ( $ name ) ; if ( ! array_key_exists ( $ name , $ this -> _data ) ) { return false ; } return ! empty ( $ this -> _data [ $ name ] -> value ( ) ) ; }
|
Checks whether or not an header exists .
|
2,669
|
public function offsetGet ( $ name ) { if ( ! isset ( $ this -> _data [ strtolower ( $ name ) ] ) ) { $ header = $ this -> _classes [ 'header' ] ; return $ this -> _data [ strtolower ( $ name ) ] = new $ header ( $ name , '' ) ; } return $ this -> _data [ strtolower ( $ name ) ] ; }
|
Returns the value of a specific header .
|
2,670
|
protected function _set ( $ values , $ prepend = false ) { $ header = $ this -> _classes [ 'header' ] ; $ headers = is_string ( $ values ) ? explode ( "\n" , $ values ) : $ values ; $ headers = $ headers ? $ headers : [ ] ; foreach ( $ headers as $ key => $ value ) { if ( ! is_numeric ( $ key ) ) { if ( $ value instanceof $ header ) { $ value -> name ( $ key ) ; } elseif ( is_array ( $ value ) ) { $ value = "{$key}: " . join ( ', ' , $ value ) ; } else { $ value = "{$key}: {$value}" ; } } if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; } if ( ! $ value ) { continue ; } if ( $ value instanceof $ header ) { $ parsed = $ value ; } elseif ( ! $ parsed = $ header :: parse ( $ value ) ) { throw new NetException ( "Invalid header: `'{$value}'`." ) ; } $ name = strtolower ( $ parsed -> name ( ) ) ; if ( ! $ name ) { throw new Exception ( "Error, invalid header name, can't be empty." ) ; } if ( $ name === 'set-cookie' && isset ( $ this -> _data [ $ name ] ) ) { $ previsous = $ this -> _data [ $ name ] ; $ previsous [ ] = $ parsed -> value ( ) ; $ parsed = $ previsous ; } if ( $ prepend ) { $ this -> _data = [ $ name => $ parsed ] + $ this -> _data ; } else { $ this -> _data = array_merge ( $ this -> _data , [ $ name => $ parsed ] ) ; } } return $ this ; }
|
Sets one or some plain string headers .
|
2,671
|
public function valid ( ) { if ( key ( $ this -> _data ) === null ) { return false ; } $ current = current ( $ this -> _data ) ; while ( ! $ current -> value ( ) ) { $ current = $ this -> next ( ) ; if ( key ( $ this -> _data ) === null ) { return false ; } } return true ; }
|
Returns the current item .
|
2,672
|
public static function toArray ( $ headers , $ options = [ ] ) { $ data = [ ] ; foreach ( $ headers as $ name => $ header ) { if ( strtolower ( $ name ) === 'set-cookie' ) { foreach ( $ header -> data ( ) as $ value ) { $ data [ ] = $ name . ': ' . $ value ; } } else { $ data [ ] = $ name . ': ' . $ header -> value ( ) ; } } return $ data ; }
|
Gets the headers as an array .
|
2,673
|
public function handle ( ) : array { $ this -> firstRun = true ; $ this -> output -> writeln ( '<info>' . $ this -> question -> getMessage ( ) . '</info> [<comment>SPACE=select</>, <comment>ENTER=submit</>]' ) ; $ this -> repaint ( ) ; $ sttyMode = shell_exec ( 'stty -g' ) ; shell_exec ( 'stty -icanon -echo' ) ; while ( ! feof ( $ this -> stream ) ) { $ char = fread ( $ this -> stream , 1 ) ; if ( " " === $ char ) { $ this -> tryCellSelection ( ) ; } elseif ( "\033" === $ char ) { $ this -> tryCellNavigation ( $ char ) ; } elseif ( 10 === ord ( $ char ) ) { $ this -> clear ( ) ; $ this -> output -> write ( '> ' . join ( ', ' , $ this -> question -> getSelections ( ) ) ) ; $ this -> output -> write ( $ char ) ; break ; } $ this -> repaint ( ) ; } shell_exec ( sprintf ( 'stty %s' , $ sttyMode ) ) ; $ this -> output -> writeln ( ' ' ) ; return $ this -> question -> getSelections ( ) ; }
|
Navigates through option items .
|
2,674
|
public static function get_microtime ( ) { list ( $ tps_usec , $ tps_sec ) = explode ( ' ' , microtime ( ) ) ; return ( float ) $ tps_usec + ( float ) $ tps_sec ; }
|
Return current microtime .
|
2,675
|
public static function isFrenchHoliday ( $ unixTimeStamp = null ) { $ date = strtotime ( date ( 'm/d/Y' , $ unixTimeStamp == null ? time ( ) : $ unixTimeStamp ) ) ; $ year = date ( 'Y' , $ date ) ; $ holidays = Cache :: getHandler ( 'quick' ) -> get ( 'holiday' . $ year ) ; if ( $ holidays == null ) { $ easterDate = easter_date ( $ year ) + 3 * 3600 ; $ easterDay = date ( 'j' , $ easterDate ) ; $ easterMonth = date ( 'n' , $ easterDate ) ; $ easterYear = date ( 'Y' , $ easterDate ) ; $ holidays = array ( mktime ( 0 , 0 , 0 , 1 , 1 , $ year ) , mktime ( 0 , 0 , 0 , 5 , 1 , $ year ) , mktime ( 0 , 0 , 0 , 5 , 8 , $ year ) , mktime ( 0 , 0 , 0 , 7 , 14 , $ year ) , mktime ( 0 , 0 , 0 , 8 , 15 , $ year ) , mktime ( 0 , 0 , 0 , 11 , 1 , $ year ) , mktime ( 0 , 0 , 0 , 11 , 11 , $ year ) , mktime ( 0 , 0 , 0 , 12 , 25 , $ year ) , mktime ( 0 , 0 , 0 , $ easterMonth , $ easterDay + 1 , $ easterYear ) , mktime ( 0 , 0 , 0 , $ easterMonth , $ easterDay + 39 , $ easterYear ) , mktime ( 0 , 0 , 0 , $ easterMonth , $ easterDay + 50 , $ easterYear ) , ) ; Cache :: getHandler ( 'quick' ) -> set ( 'holiday' . $ year , $ holidays ) ; } return in_array ( $ date , $ holidays ) ; }
|
Return french holiday
|
2,676
|
public function getHTMLFormatted ( $ config , $ errors = null ) { $ ret = array ( ) ; $ this -> generator = new HTMLPurifier_Generator ( $ config , $ this -> context ) ; if ( $ errors === null ) $ errors = $ this -> errors ; foreach ( $ this -> lines as $ line => $ col_array ) { if ( $ line == - 1 ) continue ; foreach ( $ col_array as $ col => $ struct ) { $ this -> _renderStruct ( $ ret , $ struct , $ line , $ col ) ; } } if ( isset ( $ this -> lines [ - 1 ] ) ) { $ this -> _renderStruct ( $ ret , $ this -> lines [ - 1 ] ) ; } if ( empty ( $ errors ) ) { return '<p>' . $ this -> locale -> getMessage ( 'ErrorCollector: No errors' ) . '</p>' ; } else { return '<ul><li>' . implode ( '</li><li>' , $ ret ) . '</li></ul>' ; } }
|
Default HTML formatting implementation for error messages
|
2,677
|
public static function load ( $ id , $ subId = null ) : CacheEntryInterface { $ storageId = $ id ; if ( $ subId ) { $ storageId .= '[' . $ subId . ']' ; } if ( ! isset ( self :: $ files [ $ storageId ] ) ) { $ filename = static :: CACHE_DIR . ( $ subId ? $ subId . '/' : null ) . urlencode ( $ id ) . '.' . static :: CACHE_EXTENSION ; self :: $ files [ $ storageId ] = new File ( $ filename ) ; } return self :: $ files [ $ storageId ] ; }
|
Gets the cache file from the filesystem
|
2,678
|
public function build ( array $ options ) { if ( isset ( $ options [ 'fields' ] ) ) { if ( ! is_array ( $ options [ 'fields' ] ) ) { $ message = 'Argument 1 passed to ' . __METHOD__ . ' must be an array.' ; throw new \ InvalidArgumentException ( $ message ) ; } foreach ( $ options [ 'fields' ] as $ id => $ field_options ) { $ this -> attachField ( new SchemaField ( $ id , $ field_options ) ) ; } } if ( isset ( $ options [ 'unique_field' ] ) ) { $ this -> setUniqueField ( $ options [ 'unique_field' ] ) ; } }
|
Builds the schema from an array of options .
|
2,679
|
public function attachField ( SchemaField $ field ) { $ id = $ field -> getId ( ) ; $ name = $ field -> getName ( ) ; $ this -> _fields [ $ id ] = $ field ; $ this -> _fieldNameMap [ $ name ] = $ id ; return $ this ; }
|
Associates a field with this schema .
|
2,680
|
public function getField ( $ id ) { if ( ! isset ( $ this -> _fields [ $ id ] ) ) { $ message = 'Field "' . $ id . '" not associated with this schema.' ; throw new \ InvalidArgumentException ( $ message ) ; } return $ this -> _fields [ $ id ] ; }
|
Returns a field by its unique identifier .
|
2,681
|
public function getFieldByName ( $ name ) { if ( ! isset ( $ this -> _fieldNameMap [ $ name ] ) ) { $ message = 'Field name "' . $ name . '" not associated to this schema.' ; throw new \ InvalidArgumentException ( $ message ) ; } return $ this -> getField ( $ this -> _fieldNameMap [ $ name ] ) ; }
|
Returns a field by its name as stored in the index .
|
2,682
|
public function removeField ( $ id ) { if ( isset ( $ this -> _fields [ $ id ] ) ) { $ name = $ this -> _fields [ $ id ] -> getName ( ) ; unset ( $ this -> _fields [ $ id ] , $ this -> _fieldNameMap [ $ name ] ) ; } return $ this ; }
|
De - references a field from the schema .
|
2,683
|
public function toArray ( ) { $ schema_options = array ( 'unique_field' => $ this -> _uniqueField , 'fields' => array ( ) , ) ; foreach ( $ this -> _fields as $ id => $ field ) { $ schema_options [ 'fields' ] [ $ id ] = $ field -> toArray ( ) ; } return $ schema_options ; }
|
Returns the array of schema options .
|
2,684
|
private function getMethodCallInfo ( $ name ) { $ extractedMethod = preg_match ( "/^(set|get|is|add|remove)([A-Z].*)/" , $ name , $ pregMatches ) ; if ( $ extractedMethod ) { $ method = $ pregMatches [ 1 ] ; $ property = lcfirst ( $ pregMatches [ 2 ] ) ; } else { $ method = 'call' ; $ property = $ name ; } $ collectionProperties = null ; if ( in_array ( $ method , array ( 'add' , 'remove' ) ) ) { $ collectionProperties = $ this -> _collectionsItemNames [ 'byItemName' ] [ $ property ] ; $ property = $ collectionProperties [ 'property' ] ; } if ( empty ( $ this -> _accessProperties [ $ property ] ) || ! in_array ( $ method , $ this -> _accessProperties [ $ property ] ) ) { throw new \ BadMethodCallException ( "Method $name does not exist." ) ; } return array ( 'method' => $ method , 'property' => $ property , 'collectionProperties' => $ collectionProperties ) ; }
|
Extract the info about the method called .
|
2,685
|
public function getPath ( string ... $ dirs ) : string { if ( empty ( $ dirs ) ) { return $ this -> path ; } return self :: canonicalize ( $ this -> path , ... $ dirs ) ; }
|
Returns the absolute path of the app .
|
2,686
|
public function getAuth ( $ oauth_token ) { try { $ this -> setToken ( $ oauth_token ) ; $ token = $ this -> getAccessToken ( ) ; $ this -> setToken ( $ token -> oauth_token , $ token -> oauth_token_secret ) ; return array ( 'oauth_token' => $ token -> oauth_token , 'oauth_token_secret' => $ token -> oauth_token_secret , 'user_id' => $ token -> user_id , 'screen_name' => $ token -> screen_name ) ; } catch ( Exception $ e ) { throw new \ Sifo \ Exception_500 ( $ e -> getMessage ( ) ) ; } }
|
Returns the authentication token and secret .
|
2,687
|
public function upload ( $ context , $ file , $ extension , FilesystemAdapter $ filesystemAdapter , $ fileName ) { $ fileName = $ this -> fileManager -> setFileSystemAdapter ( $ filesystemAdapter ) -> uploadFile ( $ file , $ extension , $ context , null , $ fileName ) ; $ this -> processSizes ( $ file , $ fileName , $ context , $ extension , $ filesystemAdapter ) ; return $ fileName ; }
|
Handles image upload
|
2,688
|
public function rebuild ( $ fileName , $ context , FilesystemAdapter $ filesystemAdapter ) { $ originalImage = $ filesystemAdapter -> get ( '/' . $ context . '/' . $ fileName ) ; $ originalImage = $ this -> openImageHandler -> loadImage ( $ originalImage ) ; $ extension = $ this -> findExtension ( $ fileName ) ; $ this -> deleteSizes ( $ fileName , $ context , $ filesystemAdapter ) ; $ this -> fileManager -> setFileSystemAdapter ( $ filesystemAdapter ) ; $ this -> processSizes ( $ originalImage , $ fileName , $ context , $ extension , $ filesystemAdapter ) ; return true ; }
|
Rebuilds image sizes
|
2,689
|
public function rename ( $ oldFileName , $ newFileName , $ context , FilesystemAdapter $ filesystemAdapter ) { if ( $ filesystemAdapter -> exists ( $ context . '/' . $ newFileName ) ) { throw new IcrRuntimeException ( "File with name {$newFileName} already exists!" ) ; } $ image = $ filesystemAdapter -> get ( $ context . '/' . $ oldFileName ) ; $ filesystemAdapter -> move ( $ context . '/' . $ oldFileName , $ context . '/' . $ newFileName ) ; foreach ( $ this -> config [ $ context ] as $ sizeName => $ value ) { $ oldPath = $ context . '/' . $ sizeName . '/' . $ oldFileName ; $ newPath = $ context . '/' . $ sizeName . '/' . $ newFileName ; $ filesystemAdapter -> move ( $ oldPath , $ newPath ) ; } return true ; }
|
Renames existing file
|
2,690
|
public function node_load ( $ nid = null , $ vid = null , $ reset = false ) { return node_load ( $ nid , $ vid , $ reset ) ; }
|
Load a node object from the database .
|
2,691
|
public function node_save ( & $ node ) { try { node_save ( $ node ) ; } catch ( \ Exception $ e ) { throw new NodeException ( sprintf ( NodeException :: FailedToSaveNodeText , $ node -> nid ) , NodeException :: FailedToSaveNode , $ e -> getCode ( ) , $ e ) ; } }
|
Save changes to a node or add a new node .
|
2,692
|
function size ( $ min = null , $ max = null ) { $ size = [ ] ; if ( $ min ) $ size [ 'min' ] = $ min ; if ( $ max ) $ size [ 'max' ] = $ max ; if ( count ( $ size ) ) $ this -> data [ 'size' ] = $ size ; return $ this ; }
|
Validates that the size of a text object or array is within a range .
|
2,693
|
function regexp ( $ pattern , $ flags = null ) { $ regexp [ 'pattern' ] = $ pattern ; if ( $ flags ) $ regexp [ 'flags' ] = $ flags ; $ this -> data [ 'regexp' ] = $ regexp ; return $ this ; }
|
Validates that the value of a field matches a Regular Expression .
|
2,694
|
function dateRange ( $ min = null , $ max = null ) { $ range = [ ] ; if ( $ min ) $ range [ 'min' ] = $ min ; if ( $ max ) $ range [ 'max' ] = $ max ; if ( count ( $ range ) ) $ this -> data [ 'dateRange' ] = $ range ; return $ this ; }
|
Validates that the value of a field is within a date range . It s defined specifying the min and max values of that range .
|
2,695
|
function assetFileSize ( $ min = null , $ max = null ) { $ range = [ ] ; if ( $ min ) $ range [ 'min' ] = $ min ; if ( $ max ) $ range [ 'max' ] = $ max ; if ( count ( $ range ) ) $ this -> data [ 'assetFileSize' ] = $ range ; return $ this ; }
|
Validates that the size of an asset is within a range . It s defined specifying the min and max values of that range . min and max are inclusive .
|
2,696
|
function assetImageDimensions ( $ height = null , $ width = null ) { $ imageDimensions = [ ] ; if ( $ height ) $ imageDimensions [ 'height' ] = $ height ; if ( $ width ) $ imageDimensions [ 'width' ] = $ width ; if ( count ( $ imageDimensions ) ) $ this -> data [ 'assetImageDimensions' ] = $ imageDimensions ; return $ this ; }
|
Validates that the dimensions of an image are within a range .
|
2,697
|
public function getGroup ( Communicator $ communicator ) : ProcessedGroup { $ groupJSON = $ communicator -> get ( 'api/groups/' . $ this -> groupID ) ; $ group = RecipientFactory :: createProcessedGroupFromJSON ( $ groupJSON ) ; return $ group ; }
|
Returns the Group this membership is referenced to .
|
2,698
|
public function getContact ( Communicator $ communicator ) : ProcessedContact { $ contactJSON = $ communicator -> get ( 'api/groups/' . $ this -> contactID ) ; $ contact = RecipientFactory :: createProcessedGroupFromJSON ( $ contactJSON ) ; return $ contact ; }
|
Returns the Contact this membership is referenced to .
|
2,699
|
public function getGroups ( Communicator $ communicator = null ) : ClassValidationArray { if ( $ communicator !== null ) { $ groupsJSON = $ communicator -> get ( 'api/contacts/' . $ this -> contactID . '/groups' ) ; $ groupStd = json_decode ( $ groupsJSON ) ; $ groups = RecipientFactory :: createProcessedGroupsFromStdClassArray ( $ groupStd ) ; $ this -> groups = $ groups ; $ this -> fetchedGroups = true ; } return $ this -> groups ; }
|
Returns an array of all the Groups the group is referenced in . If a communicator is not provided it will not fetch memberships from the API but return those that has been fetched if any .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.