idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
56,800
public function isThere ( string $ uri ) : bool { if ( empty ( $ uri ) ) { return true ; } $ uri = parse_url ( $ uri ) ; if ( $ this -> path !== '/' && strpos ( $ uri [ 'path' ] , rtrim ( $ this -> path , '/' ) ) === false ) { return false ; } if ( $ this -> hostonly ) { return $ this -> domain === $ uri [ 'host' ] ; } else { $ rest = str_replace ( $ this -> domain , '' , $ uri [ 'host' ] , $ is_there ) ; if ( $ is_there ) { if ( substr_count ( $ rest , '.' ) > 1 ) { return false ; } else { return true ; } } else { return false ; } } }
Check if the cookie belongs to this url
56,801
public function isValid ( string $ uri = '' ) : bool { return ! empty ( $ this -> value ) && $ this -> isNotExpired ( ) && $ this -> isThere ( $ uri ) ; }
Check whether the cookie takes effect in the url
56,802
public function load ( $ uri ) { try { $ uri = $ this -> validateUri ( $ uri ) ; $ data = $ this -> loadUri ( $ uri ) ; return $ this -> parseData ( $ data ) ; } catch ( Exception $ exception ) { throw new FailedToLoadConfigException ( sprintf ( _ ( 'Could not load resource located at "%1$s". Reason: "%2$s".' ) , $ uri , $ exception -> getMessage ( ) ) , $ exception -> getCode ( ) , $ exception ) ; } }
Load the configuration from an URI .
56,803
public static function createFromUri ( $ uri ) { foreach ( static :: $ loaders as $ loader ) { if ( $ loader :: canLoad ( $ uri ) ) { return static :: getLoader ( $ loader ) ; } } throw new FailedToLoadConfigException ( sprintf ( _ ( 'Could not find a suitable loader for URI "%1$s".' ) , $ uri ) ) ; }
Create a new Loader from an URI .
56,804
public static function getLoader ( $ loaderClass ) { try { if ( ! array_key_exists ( $ loaderClass , static :: $ loaderInstances ) ) { static :: $ loaderInstances [ $ loaderClass ] = new $ loaderClass ; } return static :: $ loaderInstances [ $ loaderClass ] ; } catch ( Exception $ exception ) { throw new FailedToLoadConfigException ( sprintf ( _ ( 'Could not instantiate the requested loader class "%1$s".' ) , $ loaderClass ) ) ; } }
Get an instance of a specific loader .
56,805
private static function _fromJson ( & $ json ) { $ fields = json_decode ( $ json ) ; if ( is_null ( $ fields ) ) { throw new UnexpectedResponseException ( json_last_error_msg ( ) , $ json ) ; } return $ fields ; }
Attempts to parse the given JSON blob into an object .
56,806
private static function _dateTime ( & $ json , $ str ) { try { return new \ DateTime ( $ str ) ; } catch ( \ Exception $ ex ) { throw new UnexpectedResponseException ( $ ex -> getMessage ( ) , $ json ) ; } }
Deserializes the given string into a DateTime .
56,807
private static function _batchResponseHelper ( & $ json , \ stdClass & $ fields , Api \ MtBatchSmsResult & $ object ) { $ object -> setBatchId ( $ fields -> id ) ; $ object -> setRecipients ( $ fields -> to ) ; $ object -> setSender ( $ fields -> from ) ; $ object -> setCanceled ( $ fields -> canceled ) ; if ( isset ( $ fields -> delivery_report ) ) { $ object -> setDeliveryReport ( $ fields -> delivery_report ) ; } if ( isset ( $ fields -> send_at ) ) { $ object -> setSendAt ( Deserialize :: _dateTime ( $ json , $ fields -> send_at ) ) ; } if ( isset ( $ fields -> expire_at ) ) { $ object -> setExpireAt ( Deserialize :: _dateTime ( $ json , $ fields -> expire_at ) ) ; } if ( isset ( $ fields -> created_at ) ) { $ object -> setCreatedAt ( Deserialize :: _dateTime ( $ json , $ fields -> created_at ) ) ; } if ( isset ( $ fields -> modified_at ) ) { $ object -> setModifiedAt ( Deserialize :: _dateTime ( $ json , $ fields -> modified_at ) ) ; } if ( isset ( $ fields -> callback_url ) ) { $ object -> setCallbackUrl ( $ fields -> callback_url ) ; } }
Helper that populates the given batch result .
56,808
private static function _convertParameters ( & $ params ) { $ res = [ ] ; foreach ( $ params as $ param => $ substitutions ) { $ res [ "$param" ] = [ ] ; foreach ( $ substitutions as $ key => $ value ) { $ res [ "$param" ] [ "$key" ] = "$value" ; } } return $ res ; }
Converts an object describing parameter mappings to associative arrays .
56,809
private static function _batchResponseFromFields ( & $ json , & $ fields ) { if ( $ fields -> type == 'mt_text' ) { $ result = new Api \ MtBatchTextSmsResult ( ) ; $ result -> setBody ( $ fields -> body ) ; if ( isset ( $ fields -> parameters ) ) { $ result -> setParameters ( Deserialize :: _convertParameters ( $ fields -> parameters ) ) ; } } else if ( $ fields -> type == 'mt_binary' ) { $ result = new Api \ MtBatchBinarySmsResult ( ) ; $ result -> setUdh ( hex2bin ( $ fields -> udh ) ) ; $ result -> setBody ( base64_decode ( $ fields -> body ) ) ; } else { throw new UnexpectedResponseException ( "Received unexpected batch type " . $ fields -> type , $ json ) ; } Deserialize :: _batchResponseHelper ( $ json , $ fields , $ result ) ; return $ result ; }
Helper that creates and populates a batch result object .
56,810
public static function batchResponse ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; return Deserialize :: _batchResponseFromFields ( $ json , $ fields ) ; }
Reads a JSON blob describing a batch result .
56,811
public static function batchesPage ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; $ result = new Api \ Page ( ) ; $ result -> setPage ( $ fields -> page ) ; $ result -> setSize ( $ fields -> page_size ) ; $ result -> setTotalSize ( $ fields -> count ) ; $ result -> setContent ( array_map ( function ( $ s ) use ( $ json ) { return Deserialize :: _batchResponseFromFields ( $ json , $ s ) ; } , $ fields -> batches ) ) ; return $ result ; }
Reads a JSON blob describing a page of batches .
56,812
public static function batchDryRun ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; $ result = new Api \ MtBatchDryRunResult ( ) ; $ result -> setNumberOfRecipients ( $ fields -> number_of_recipients ) ; $ result -> setNumberOfMessages ( $ fields -> number_of_messages ) ; if ( isset ( $ fields -> per_recipient ) ) { $ result -> setPerRecipient ( array_map ( function ( $ s ) { $ pr = new Api \ DryRunPerRecipient ( ) ; $ pr -> setRecipient ( $ s -> recipient ) ; $ pr -> setNumberOfParts ( $ s -> number_of_parts ) ; $ pr -> setBody ( $ s -> body ) ; $ pr -> setEncoding ( $ s -> encoding ) ; return $ pr ; } , $ fields -> per_recipient ) ) ; } return $ result ; }
Reads a JSON formatted string describing a dry - run result .
56,813
public static function batchDeliveryReport ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; if ( ! isset ( $ fields -> type ) || $ fields -> type != 'delivery_report_sms' ) { throw new UnexpectedResponseException ( "Expected delivery report" , $ json ) ; } $ result = new Api \ BatchDeliveryReport ( ) ; $ result -> setBatchId ( $ fields -> batch_id ) ; $ result -> setTotalMessageCount ( $ fields -> total_message_count ) ; $ result -> setStatuses ( array_map ( function ( $ s ) { $ r = new Api \ BatchDeliveryReportStatus ( ) ; $ r -> setCode ( $ s -> code ) ; $ r -> setStatus ( $ s -> status ) ; $ r -> setCount ( $ s -> count ) ; if ( isset ( $ s -> recipients ) ) { $ r -> setRecipients ( $ s -> recipients ) ; } return $ r ; } , $ fields -> statuses ) ) ; return $ result ; }
Reads a JSON blob describing a batch delivery report .
56,814
public static function batchRecipientDeliveryReport ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; if ( ! isset ( $ fields -> type ) || $ fields -> type != 'recipient_delivery_report_sms' ) { throw new UnexpectedResponseException ( "Expected recipient delivery report" , $ json ) ; } $ result = new Api \ BatchRecipientDeliveryReport ( ) ; $ result -> setBatchId ( $ fields -> batch_id ) ; $ result -> setRecipient ( $ fields -> recipient ) ; $ result -> setCode ( $ fields -> code ) ; $ result -> setStatus ( $ fields -> status ) ; $ result -> setStatusAt ( Deserialize :: _dateTime ( $ json , $ fields -> at ) ) ; if ( isset ( $ fields -> status_message ) ) { $ result -> setStatusMessage ( $ fields -> status_message ) ; } if ( isset ( $ fields -> operator ) ) { $ result -> setOperator ( $ fields -> operator ) ; } if ( isset ( $ fields -> operator_status_at ) ) { $ result -> setOperatorStatusAt ( Deserialize :: _dateTime ( $ json , $ fields -> operator_status_at ) ) ; } return $ result ; }
Reads a batch recipient delivery report from the given JSON text .
56,815
private static function _autoUpdateFromFields ( & $ fields ) { $ addKeywords = [ null , null ] ; $ removeKeywords = [ null , null ] ; if ( isset ( $ fields -> add ) && isset ( $ fields -> add -> first_word ) ) { $ addKeywords [ 0 ] = $ fields -> add -> first_word ; } if ( isset ( $ fields -> add ) && isset ( $ fields -> add -> second_word ) ) { $ addKeywords [ 1 ] = $ fields -> add -> second_word ; } if ( isset ( $ fields -> remove ) && isset ( $ fields -> remove -> first_word ) ) { $ removeKeywords [ 0 ] = $ fields -> remove -> first_word ; } if ( isset ( $ fields -> remove ) && isset ( $ fields -> remove -> second_word ) ) { $ removeKeywords [ 1 ] = $ fields -> remove -> second_word ; } return new Api \ GroupAutoUpdate ( $ fields -> to , $ addKeywords , $ removeKeywords ) ; }
Helper that creates a group auto update object from the given fields .
56,816
private static function _groupResponseFromFields ( & $ json , & $ fields ) { $ result = new Api \ GroupResult ( ) ; $ result -> setChildGroups ( $ fields -> child_groups ) ; $ result -> setGroupId ( $ fields -> id ) ; $ result -> setSize ( $ fields -> size ) ; $ result -> setCreatedAt ( Deserialize :: _dateTime ( $ json , $ fields -> created_at ) ) ; $ result -> setModifiedAt ( Deserialize :: _dateTime ( $ json , $ fields -> modified_at ) ) ; if ( isset ( $ fields -> name ) ) { $ result -> setName ( $ fields -> name ) ; } if ( isset ( $ fields -> auto_update ) ) { $ result -> setAutoUpdate ( Deserialize :: _autoUpdateFromFields ( $ fields -> auto_update ) ) ; } return $ result ; }
Helper that creates a group response object from the given fields .
56,817
public static function groupResponse ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; return Deserialize :: _groupResponseFromFields ( $ json , $ fields ) ; }
Parses a group response from the given JSON text .
56,818
public static function groupsPage ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; $ result = new Api \ Page ( ) ; $ result -> setPage ( $ fields -> page ) ; $ result -> setSize ( $ fields -> page_size ) ; $ result -> setTotalSize ( $ fields -> count ) ; $ result -> setContent ( array_map ( function ( $ s ) use ( $ json ) { return Deserialize :: _groupResponseFromFields ( $ json , $ s ) ; } , $ fields -> groups ) ) ; return $ result ; }
Parses a page of groups from the given JSON text .
56,819
public static function error ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; $ result = new Api \ Error ( ) ; $ result -> setCode ( $ fields -> code ) ; $ result -> setText ( $ fields -> text ) ; return $ result ; }
Reads a JSON blob containing an error response .
56,820
private static function _moSmsFromFields ( & $ json , & $ fields ) { if ( $ fields -> type === 'mo_text' ) { $ result = new Api \ MoTextSms ( ) ; $ result -> setBody ( $ fields -> body ) ; if ( isset ( $ fields -> keyword ) ) { $ result -> setKeyword ( $ fields -> keyword ) ; } } else if ( $ fields -> type === 'mo_binary' ) { $ result = new Api \ MoBinarySms ( ) ; $ result -> setBody ( base64_decode ( $ fields -> body ) ) ; $ result -> setUdh ( hex2bin ( $ fields -> udh ) ) ; } else { throw new UnexpectedResponseException ( "Received unexpected inbound type " . $ fields -> type , $ json ) ; } $ result -> setMessageId ( $ fields -> id ) ; $ result -> setSender ( $ fields -> from ) ; $ result -> setRecipient ( $ fields -> to ) ; if ( isset ( $ fields -> operator ) ) { $ result -> setOperator ( $ fields -> operator ) ; } if ( isset ( $ fields -> sent_at ) ) { $ result -> setSentAt ( Deserialize :: _dateTime ( $ json , $ fields -> sent_at ) ) ; } if ( isset ( $ fields -> received_at ) ) { $ result -> setReceivedAt ( Deserialize :: _dateTime ( $ json , $ fields -> received_at ) ) ; } return $ result ; }
Helper that reads an MO from the given fields .
56,821
public static function moSms ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; return Deserialize :: _moSmsFromFields ( $ json , $ fields ) ; }
Reads a JSON blob containing an MO message .
56,822
public static function inboundsPage ( $ json ) { $ fields = Deserialize :: _fromJson ( $ json ) ; $ result = new Api \ Page ( ) ; $ result -> setPage ( $ fields -> page ) ; $ result -> setSize ( $ fields -> page_size ) ; $ result -> setTotalSize ( $ fields -> count ) ; $ result -> setContent ( array_map ( function ( $ s ) { return Deserialize :: _moSmsFromFields ( $ json , $ s ) ; } , $ fields -> inbounds ) ) ; return $ result ; }
Reads a JSON blob describing a page of MO messages .
56,823
public function setTranslatable ( TranslatableInterface $ translatable = null ) { if ( $ this -> translatable == $ translatable ) { return $ this ; } $ old = $ this -> translatable ; $ this -> translatable = $ translatable ; if ( $ old !== null ) { $ old -> removeTranslation ( $ this ) ; } if ( $ translatable !== null ) { $ translatable -> addTranslation ( $ this ) ; } return $ this ; }
Set the translatable object
56,824
public function scopeOnlyUnkeptOlderThanHours ( Builder $ builder , $ hours ) { return $ builder -> withoutGlobalScope ( KeptFlagScope :: class ) -> where ( 'is_kept' , 0 ) -> where ( static :: getCreatedAtColumn ( ) , '<=' , Date :: now ( ) -> subHours ( $ hours ) -> toDateTimeString ( ) ) ; }
Get unkept models that are older than the given number of hours .
56,825
protected function resolveOptions ( $ config ) { if ( ! $ this -> schema ) { return $ config ; } try { $ resolver = new OptionsResolver ( ) ; if ( $ this -> configureOptions ( $ resolver ) ) { $ config = $ resolver -> resolve ( $ config ) ; } } catch ( Exception $ exception ) { throw new FailedToResolveConfigException ( sprintf ( _ ( 'Error while resolving config options: %1$s' ) , $ exception -> getMessage ( ) ) ) ; } return $ config ; }
Process the passed - in defaults and merge them with the new values while checking that all required options are set .
56,826
protected function configureOptions ( OptionsResolver $ resolver ) { $ defined = $ this -> schema -> getDefinedOptions ( ) ; $ defaults = $ this -> schema -> getDefaultOptions ( ) ; $ required = $ this -> schema -> getRequiredOptions ( ) ; if ( ! $ defined && ! $ defaults && ! $ required ) { return false ; } try { if ( $ defined ) { $ resolver -> setDefined ( $ defined ) ; } if ( $ defaults ) { $ resolver -> setDefaults ( $ defaults ) ; } if ( $ required ) { $ resolver -> setRequired ( $ required ) ; } } catch ( Exception $ exception ) { throw new FailedToResolveConfigException ( sprintf ( _ ( 'Error while processing config options: %1$s' ) , $ exception -> getMessage ( ) ) ) ; } return true ; }
Configure the possible and required options for the Config .
56,827
protected function processConfig ( ConfigInterface $ config ) { if ( func_num_args ( ) > 1 ) { try { $ keys = func_get_args ( ) ; array_shift ( $ keys ) ; $ config = $ config -> getSubConfig ( $ keys ) ; } catch ( Exception $ exception ) { throw new FailedToProcessConfigException ( sprintf ( _ ( 'Could not process the config with the arguments "%1$s".' ) , print_r ( func_get_args ( ) , true ) ) ) ; } } $ this -> config = $ config ; }
Process the passed - in configuration file .
56,828
protected function getConfigCallable ( $ key , array $ args = [ ] ) { $ value = $ this -> config -> getKey ( $ key ) ; if ( is_callable ( $ value ) ) { $ value = $ value ( ... $ args ) ; } return $ value ; }
Get the callable Config value for a specific key .
56,829
protected function fetchDefaultConfig ( ) { $ configFile = method_exists ( $ this , 'getDefaultConfigFile' ) ? $ this -> getDefaultConfigFile ( ) : __DIR__ . '/../config/defaults.php' ; return $ this -> fetchConfig ( $ configFile ) ; }
Get a default configuration in case none was injected into the constructor .
56,830
protected function addUndoApprove ( Builder $ builder ) : void { $ builder -> macro ( 'undoApprove' , function ( Builder $ builder ) { return $ builder -> update ( [ 'is_approved' => 0 ] ) ; } ) ; }
Add the undoApprove extension to the builder .
56,831
protected function addWithNotApproved ( Builder $ builder ) : void { $ builder -> macro ( 'withNotApproved' , function ( Builder $ builder ) { return $ builder -> withoutGlobalScope ( $ this ) ; } ) ; }
Add the withNotApproved extension to the builder .
56,832
public function deleteToAPI ( $ endpoint , array $ params = [ ] , $ accessToken = null ) { return $ this -> sendRequest ( "DELETE" , $ endpoint , 'api' , $ params , $ accessToken ) ; }
Make a HTTP DELETE Request to the API endpoint type
56,833
public function deleteToContent ( $ endpoint , array $ params = [ ] , $ accessToken = null ) { return $ this -> sendRequest ( "DELETE" , $ endpoint , 'upload' , $ params , $ accessToken ) ; }
Make a HTTP DELETE Request to the Content endpoint type
56,834
public function makeBoxFile ( $ boxFile , $ maxLength = - 1 , $ offset = - 1 ) { if ( ! $ boxFile instanceof BoxFile ) { if ( is_file ( $ boxFile ) ) { $ boxFile = new BoxFile ( $ boxFile , $ maxLength , $ offset ) ; } else { throw new Exceptions \ BoxClientException ( "File '{$boxFile}' is invalid." ) ; } } $ boxFile -> setOffset ( $ offset ) ; $ boxFile -> setMaxLength ( $ maxLength ) ; return $ boxFile ; }
Make BoxFile Object
56,835
public function listRevisions ( $ path , array $ params = [ ] ) { $ params [ 'path' ] = $ path ; $ response = $ this -> postToAPI ( '/files/list_revisions' , $ params ) ; $ body = $ response -> getDecodedBody ( ) ; $ entries = isset ( $ body [ 'entries' ] ) ? $ body [ 'entries' ] : [ ] ; $ processedEntries = [ ] ; foreach ( $ entries as $ entry ) { $ processedEntries [ ] = new BoxFileMetadata ( $ entry ) ; } return new ModelCollection ( $ processedEntries ) ; }
Get Revisions of a File
56,836
public function saveCopyReference ( $ path , $ copyReference ) { if ( is_null ( $ path ) || is_null ( $ copyReference ) ) { throw new Exceptions \ BoxClientException ( "Path and Copy Reference cannot be null." ) ; } $ response = $ this -> postToAPI ( '/files/copy_reference/save' , [ 'path' => $ path , 'copy_reference' => $ copyReference ] ) ; $ body = $ response -> getDecodedBody ( ) ; if ( ! isset ( $ body [ 'metadata' ] ) || ! is_array ( $ body [ 'metadata' ] ) ) { throw new Exceptions \ BoxClientException ( "Invalid Response." ) ; } return ModelFactory :: make ( $ body [ 'metadata' ] ) ; }
Save Copy Reference
56,837
public function upload ( $ boxFile , $ attributes , array $ params = [ ] ) { $ boxFile = $ this -> makeBoxFile ( $ boxFile ) ; return $ this -> simpleUpload ( $ boxFile , $ attributes , $ params ) ; }
Upload a File to Box
56,838
public function simpleUpload ( $ boxFile , $ attributes , array $ params = [ ] ) { $ boxFile = $ this -> makeBoxFile ( $ boxFile ) ; $ params [ 'attributes' ] = $ attributes ; $ params [ 'file' ] = $ boxFile ; $ file = $ this -> postToContent ( '/files/content' , $ params ) ; $ body = $ file -> getDecodedBody ( ) ; if ( $ body [ "type" ] == "error" ) throw new Exceptions \ BoxClientException ( $ body [ "message" ] . " - ID: " . $ body [ "context_info" ] [ "conflicts" ] [ "id" ] , $ body [ "status" ] ) ; $ fileData = array ( ) ; if ( ! empty ( $ body [ "total_count" ] ) && $ body [ "total_count" ] ) $ fileData = $ body [ "entries" ] [ 0 ] ; return new BoxFileMetadata ( $ fileData ) ; }
Upload a File to BoxMain in a single request
56,839
public function handle ( GetResponseEvent $ event ) { if ( null !== $ this -> logger ) { $ this -> logger -> info ( 'Checking for guard authentication credentials.' , array ( 'firewall_key' => $ this -> providerKey , 'authenticators' => count ( $ this -> guardAuthenticators ) ) ) ; } foreach ( $ this -> guardAuthenticators as $ key => $ guardAuthenticator ) { $ uniqueGuardKey = $ this -> providerKey . '_' . $ key ; $ this -> executeGuardAuthenticator ( $ uniqueGuardKey , $ guardAuthenticator , $ event ) ; } }
Iterates over each authenticator to see if each wants to authenticate the request .
56,840
private function triggerRememberMe ( GuardAuthenticatorInterface $ guardAuthenticator , Request $ request , TokenInterface $ token , Response $ response = null ) { if ( ! $ guardAuthenticator -> supportsRememberMe ( ) ) { return ; } if ( null === $ this -> rememberMeServices ) { if ( null !== $ this -> logger ) { $ this -> logger -> info ( 'Remember me skipped: it is not configured for the firewall.' , array ( 'authenticator' => get_class ( $ guardAuthenticator ) ) ) ; } return ; } if ( ! $ response instanceof Response ) { throw new \ LogicException ( sprintf ( '%s::onAuthenticationSuccess *must* return a Response if you want to use the remember me functionality. Return a Response, or set remember_me to false under the guard configuration.' , get_class ( $ guardAuthenticator ) ) ) ; } $ this -> rememberMeServices -> loginSuccess ( $ request , $ response , $ token ) ; }
Checks to see if remember me is supported in the authenticator and on the firewall . If it is the RememberMeServicesInterface is notified .
56,841
public function getUsersList ( ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; $ members = Permission :: get_members_by_permission ( array ( 'ADMIN' , 'CODE_BANK_ACCESS' ) ) ; foreach ( $ members as $ member ) { $ response [ 'data' ] [ ] = array ( 'id' => $ member -> ID , 'username' => $ member -> Email , 'lastLogin' => $ member -> LastVisited ) ; } return $ response ; }
Gets a list of users in the database
56,842
public function createUser ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; try { if ( Member :: get ( ) -> filter ( 'Email' , Convert :: raw2sql ( $ data -> username ) ) -> count ( ) > 0 ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.EMAIL_EXISTS' , '_An account with that email already exists' ) ; return $ response ; } $ member = new Member ( ) ; $ member -> FirstName = ( ! empty ( $ data -> firstname ) ? $ data -> firstname : $ data -> username ) ; $ member -> Surname = ( ! empty ( $ data -> surname ) ? $ data -> surname : null ) ; $ member -> Email = $ data -> username ; $ member -> Password = $ data -> Password ; $ member -> UseHeartbeat = 0 ; if ( ! $ member -> validate ( ) ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.PASSWORD_NOT_VALID' , '_Password is not valid' ) ; return $ response ; } $ member -> write ( ) ; $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = "User added successfully" ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Creates a user in the database
56,843
public function getAdminLanguages ( ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; $ languages = SnippetLanguage :: get ( ) ; foreach ( $ languages as $ lang ) { $ response [ 'data' ] [ ] = array ( 'id' => $ lang -> ID , 'language' => $ lang -> Name , 'file_extension' => $ lang -> FileExtension , 'shjh_code' => $ lang -> HighlightCode , 'user_language' => $ lang -> UserLanguage , 'snippetCount' => $ lang -> Snippets ( ) -> Count ( ) , 'hidden' => $ lang -> Hidden ) ; } return $ response ; }
Gets the list of languages with snippet counts
56,844
public function createLanguage ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; try { if ( SnippetLanguage :: get ( ) -> filter ( 'Name:nocase' , Convert :: raw2sql ( $ data -> language ) ) -> Count ( ) > 0 ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.LANGUAGE_EXISTS' , '_Language already exists' ) ; return $ response ; } $ lang = new SnippetLanguage ( ) ; $ lang -> Name = $ data -> language ; $ lang -> FileExtension = $ data -> fileExtension ; $ lang -> HighlightCode = 'Plain' ; $ lang -> UserLanguage = 1 ; $ lang -> write ( ) ; $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = "Language added successfully" ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Creates a language in the database
56,845
public function deleteLanguage ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; try { $ lang = SnippetLanguage :: get ( ) -> byID ( intval ( $ data -> id ) ) ; if ( ! empty ( $ lang ) && $ lang !== false && $ lang -> ID != 0 ) { if ( $ lang -> canDelete ( ) == false ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.LANGUAGE_DELETE_ERROR' , '_Language cannot be deleted, it is either not a user language or has snippets attached to it' ) ; return $ response ; } } else { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.LANGUAGE_NOT_FOUND' , '_Language not found' ) ; return $ response ; } $ lang -> delete ( ) ; $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = "Language deleted successfully" ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Deletes a language from the database
56,846
public function editLanguage ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; try { if ( SnippetLanguage :: get ( ) -> filter ( 'Name:nocase' , Convert :: raw2sql ( $ data -> language ) ) -> Count ( ) > 0 ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.LANGUAGE_EXISTS' , '_Language already exists' ) ; return $ response ; } $ lang = SnippetLanguage :: get ( ) -> byID ( intval ( $ data -> id ) ) ; if ( empty ( $ lang ) || $ lang === false || $ lang -> ID == 0 ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.LANGUAGE_NOT_FOUND' , '_Language not found' ) ; return $ response ; } if ( $ lang -> UserLanguage == true ) { $ lang -> Name = $ data -> language ; $ lang -> FileExtension = $ data -> fileExtension ; } $ lang -> Hidden = $ data -> hidden ; $ lang -> write ( ) ; $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = "Language edited successfully" ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Edits a language
56,847
public static function MakeOfType ( array $ esHit , $ className = "" , Client $ esClient = null ) { if ( $ className && strpos ( $ className , '{type}' ) !== false ) { $ baseClassName = str_replace ( ' ' , '' , ucwords ( preg_replace ( '/[^a-zA-Z0-9]+/' , ' ' , $ esHit [ '_type' ] ) ) ) ; $ fullClassName = str_replace ( "{type}" , $ baseClassName , $ className ) ; if ( ! class_exists ( $ fullClassName ) ) { $ fullClassName = array_key_exists ( '_source' , $ esHit ) ? static :: class : ArrayObject :: class ; } } else { $ fullClassName = $ className ? : static :: class ; } return $ fullClassName :: make ( $ esHit , $ esClient ) ; }
A custom factory method that will try to detect the correct model class and instantiate and object of it .
56,848
public function update ( array $ data , array $ parameters = [ ] ) { if ( ! $ this -> canAlter ( ) ) { throw new Exception ( 'Need index, type, and key to update a document' ) ; } if ( ! $ this -> esClient ) { throw new Exception ( 'Need ElasticSearch client object for ALTER operations' ) ; } $ params = [ 'index' => $ this -> meta [ 'index' ] , 'type' => $ this -> meta [ 'type' ] , 'id' => $ this -> meta [ 'id' ] , 'body' => $ data ] + $ parameters ; return $ this -> esClient -> update ( $ params ) ; }
Updates the document
56,849
protected function buildGraphComponents ( array $ components ) { $ graphComponents = array_fill_keys ( array_column ( $ components , 'class' ) , [ 'class' => null , 'id' => null , 'type' => null , 'label' => null , 'variant' => null , 'master' => null , 'variants' => [ ] , 'dependencies' => [ ] , 'path' => [ ] , ] ) ; foreach ( $ components as $ component ) { $ graphComponents [ $ componentClass ] [ 'class' ] = $ componentClass = $ component [ 'class' ] ; $ graphComponents [ $ componentClass ] [ 'id' ] = $ component [ 'name' ] ; $ graphComponents [ $ componentClass ] [ 'type' ] = $ component [ 'type' ] ; $ graphComponents [ $ componentClass ] [ 'label' ] = $ component [ 'label' ] ? : $ component [ 'name' ] ; $ graphComponents [ $ componentClass ] [ 'variant' ] = $ component [ 'variant' ] ; $ graphComponents [ $ componentClass ] [ 'path' ] = $ component [ 'path' ] ; foreach ( ( new $ componentClass ) -> getDependencies ( ) as $ componentDependency ) { if ( isset ( $ graphComponents [ $ componentDependency ] ) ) { $ graphComponents [ $ componentClass ] [ 'dependencies' ] [ $ componentDependency ] = & $ graphComponents [ $ componentDependency ] ; } } if ( $ component [ 'variant' ] ) { list ( $ masterClass ) = explode ( '_' , $ componentClass , 2 ) ; $ masterClass .= 'Component' ; if ( isset ( $ graphComponents [ $ masterClass ] ) ) { $ graphComponents [ $ componentClass ] [ 'master' ] = & $ graphComponents [ $ masterClass ] ; $ graphComponents [ $ masterClass ] [ 'variants' ] [ $ componentClass ] = & $ graphComponents [ $ componentClass ] ; } } } return $ graphComponents ; }
Prepare the list of graph components
56,850
protected function addToComponentTree ( $ componentId , array $ componentPath , array & $ tree ) { if ( count ( $ componentPath ) ) { $ subpath = array_shift ( $ componentPath ) ; if ( empty ( $ tree [ $ subpath ] ) ) { $ tree [ $ subpath ] = [ ] ; } $ this -> addToComponentTree ( $ componentId , $ componentPath , $ tree [ $ subpath ] ) ; return ; } $ tree [ ] = $ componentId ; }
Add a component to the component tree
56,851
protected function addToComponentTreeSubset ( array & $ pointer , $ componentId ) { foreach ( $ this -> graphComponents [ $ componentId ] [ 'path' ] as $ node ) { if ( empty ( $ pointer [ $ node ] ) ) { $ pointer [ $ node ] = [ ] ; } $ pointer = & $ pointer [ $ node ] ; } $ pointer [ ] = $ componentId ; if ( $ this -> graphComponents [ $ componentId ] [ 'master' ] ) { $ dependencies = array_column ( $ this -> graphComponents [ $ componentId ] [ 'master' ] [ 'dependencies' ] , 'class' ) ; foreach ( $ this -> graphComponents [ $ componentId ] [ 'master' ] [ 'variants' ] as $ variant ) { $ dependencies = array_column ( $ variant [ 'dependencies' ] , 'class' ) ; } } else { $ dependencies = array_column ( $ this -> graphComponents [ $ componentId ] [ 'dependencies' ] , 'class' ) ; } return array_unique ( $ dependencies ) ; }
Recursively add a single component to a component tree subset
56,852
protected function addComponents ( BaseGraph $ graph , array $ components , Node $ parentNode = null ) { foreach ( $ components as $ name => $ component ) { if ( is_array ( $ component ) ) { $ this -> addNode ( $ graph , $ name , $ component , $ parentNode ) ; } else { $ this -> addComponent ( $ graph , $ component , $ parentNode ) ; } } return $ graph ; }
Add a list of components to a graph
56,853
protected function addNode ( BaseGraph $ graph , $ nodeId , array $ components , Node $ parentNode = null ) { $ absNodeId = ( ( $ parentNode instanceof Node ) ? $ parentNode -> getId ( ) : '/' ) . $ nodeId ; $ graph -> node ( $ absNodeId , [ 'label' => $ nodeId , 'shape' => 'none' , 'style' => 'none' , ] ) ; if ( $ parentNode instanceof Node ) { $ graph -> edge ( [ $ parentNode -> getId ( ) , $ absNodeId ] , [ 'arrowhead' => 'none' , 'color' => 'darkgrey' , 'penwidth' => .5 ] ) ; } return $ this -> addComponents ( $ graph , $ components , $ graph -> get ( $ absNodeId ) ) ; }
Add a node to a graph
56,854
protected function getComponentTitle ( $ componentId ) { $ component = & $ this -> graphComponents [ $ componentId ] ; $ componentTitle = implode ( '/' , array_filter ( array_merge ( $ component [ 'path' ] , [ $ component [ 'id' ] ] ) ) ) ; $ componentTitle .= ' (' . $ component [ 'class' ] . ')' ; return $ componentTitle ; }
Create and return an component title
56,855
public function serialize ( DomainEvent $ event ) : string { $ reflect = new ReflectionObject ( $ event ) ; $ props = $ reflect -> getProperties ( ReflectionProperty :: IS_PUBLIC | ReflectionProperty :: IS_PRIVATE ) ; return json_encode ( [ 'eventName' => $ this -> eventNameForClass ( get_class ( $ event ) ) , 'fields' => $ this -> serializeFields ( $ props , $ event ) , ] ) ; }
serialize a domain event into event sourcery library storage conventions
56,856
private function serializeFields ( $ props , $ event ) { array_map ( function ( ReflectionProperty $ prop ) use ( & $ fields , $ event ) { $ prop -> setAccessible ( true ) ; $ fields [ $ prop -> getName ( ) ] = $ this -> valueSerializer -> serialize ( $ prop -> getValue ( $ event ) ) ; } , $ props ) ; return $ fields ; }
Serialize the fields of a domain event into a key = > value hash
56,857
public function deserialize ( array $ serialized ) : DomainEvent { $ className = $ this -> classNameForEvent ( $ serialized [ 'eventName' ] ) ; $ reflect = new ReflectionClass ( $ className ) ; $ const = $ reflect -> getConstructor ( ) ; $ constParams = [ ] ; foreach ( $ const -> getParameters ( ) as $ param ) { $ constParams [ ] = [ $ param -> getType ( ) -> getName ( ) , $ param -> getName ( ) , ] ; } $ constParamValues = [ ] ; foreach ( $ constParams as $ constParam ) { list ( $ type , $ name ) = $ constParam ; $ fields = $ serialized [ 'fields' ] ; if ( ! isset ( $ fields [ $ name ] ) ) { throw new \ Exception ( "Cannot find serialized field {$name} for {$className}." ) ; } $ constParamValues [ ] = [ $ type , $ name , $ fields [ $ name ] , ] ; } return new $ className ( ... array_map ( [ $ this , 'deserializeField' ] , $ constParamValues ) ) ; }
deserialize a domain event from event sourcery library storage conventions
56,858
public function sort ( $ by , $ direction = "asc" , $ override = false ) { $ this -> assertInitiated ( "sort" ) ; if ( $ override ) { $ this -> query [ 'sort' ] = [ ] ; } $ this -> query [ 'sort' ] [ ] = [ $ by => $ direction ] ; return $ this ; }
Adds a sort clause to the query
56,859
public function wildcard ( $ key , $ value , $ bool = "must" , $ filter = false , array $ params = [ ] ) { if ( is_array ( $ key ) ) { return $ this -> multiWildcard ( $ key , $ value , $ bool , $ filter , $ params ) ; } if ( is_array ( $ value ) ) { return $ this -> wildcards ( $ key , $ value , $ bool , $ filter , $ params ) ; } $ this -> addBool ( $ this -> makeFilteredQuery ( [ "wildcard" => [ $ key => [ "wildcard" => $ value ] ] ] , $ filter ) , $ bool , $ filter , $ params ) ; return $ this ; }
Creates a wildcard query part .
56,860
public function regexp ( $ key , $ value , $ bool = "must" , $ filter = false , array $ params = [ ] ) { if ( is_array ( $ key ) ) { return $ this -> multiRegexp ( $ key , $ value , $ bool , $ filter , $ params ) ; } if ( is_array ( $ value ) ) { return $ this -> regexps ( $ key , $ value , $ bool , $ filter , $ params ) ; } $ this -> addBool ( $ this -> makeFilteredQuery ( [ "regexp" => [ $ key => [ "value" => $ value ] ] ] , $ filter ) , $ bool , $ filter , $ params ) ; return $ this ; }
Creates a regexp query part .
56,861
public function prefix ( $ key , $ value , $ bool = "must" , $ filter = false , array $ params = [ ] ) { if ( is_array ( $ key ) ) { return $ this -> multiPrefix ( $ key , $ value , $ bool , $ filter , $ params ) ; } if ( is_array ( $ value ) ) { return $ this -> prefixs ( $ key , $ value , $ bool , $ filter , $ params ) ; } $ this -> addBool ( $ this -> makeFilteredQuery ( [ "prefix" => [ $ key => $ value ] ] , $ filter ) , $ bool , $ filter , $ params ) ; return $ this ; }
Creates a prefix query part .
56,862
public function multiPrefix ( array $ keys , $ value , $ bool = "must" , $ filter = false , array $ params = [ ] ) { $ subQuery = $ this -> orWhere ( $ bool ) ; foreach ( $ keys as $ key ) { $ subQuery -> prefix ( $ key , $ value , $ bool , true , $ params ) ; } $ subQuery -> endSubQuery ( ) ; return $ this ; }
Creates OR - joined multiple prefix queries for the list of keys
56,863
public function multiPrefixs ( array $ keys , array $ values , $ bool = "must" , $ filter = false , array $ params = [ ] ) { $ subQuery = $ this -> orWhere ( $ bool ) ; foreach ( $ keys as $ key ) { $ subQuery -> prefixs ( $ key , $ values , $ bool , true , $ params ) ; } $ subQuery -> endSubQuery ( ) ; return $ this ; }
Creates multiple prefixes queries for the list of keys
56,864
public function multiTerm ( array $ keys , $ value , $ bool = "must" , $ filter = false , array $ params = [ ] ) { $ subQuery = $ this -> orWhere ( $ bool ) ; foreach ( $ keys as $ key ) { $ subQuery -> term ( $ key , $ value , $ bool , true , $ params ) ; } $ subQuery -> endSubQuery ( ) ; return $ this ; }
Multiple OR joined term queries
56,865
public function match ( $ key , $ value , $ bool , $ filter = false , array $ params = [ ] ) { if ( is_array ( $ key ) ) { return $ this -> multiMatch ( $ key , $ value , $ bool , $ filter , $ params ) ; } if ( is_array ( $ value ) ) { return $ this -> matches ( $ key , $ value , $ bool , $ filter , $ params ) ; } $ this -> addBool ( $ this -> makeFilteredQuery ( [ "match" => [ $ key => [ "query" => $ value ] + $ params ] ] , $ filter ) , $ bool , $ filter ) ; return $ this ; }
A match query
56,866
public function matches ( $ key , array $ values , $ bool , $ filter = false , array $ params = [ ] ) { $ subQuery = $ this -> orWhere ( $ bool ) ; foreach ( $ values as $ value ) { $ subQuery -> match ( $ key , $ value , $ bool , true , $ params ) ; } $ subQuery -> endSubQuery ( ) ; return $ this ; }
Creates multiple match queries for each value in the array
56,867
public function multiMatch ( array $ keys , $ value , $ bool , $ filter = false , array $ params = [ ] ) { $ this -> addBool ( $ this -> makeFilteredQuery ( [ "multi_match" => [ "query" => $ value , "fields" => $ keys ] + $ params ] , $ filter ) , $ bool , $ filter ) ; return $ this ; }
Creates a mutli_match query
56,868
public function multiMatches ( array $ keys , array $ values , $ bool , $ filter = false , array $ params = [ ] ) { $ subQuery = $ this -> orWhere ( $ bool ) ; foreach ( $ values as $ value ) { $ subQuery -> multiMatch ( $ keys , $ value , $ bool , true , $ params ) ; } $ subQuery -> endSubQuery ( ) ; return $ this ; }
Creates multiple mutli_match queries for each value in the array
56,869
public function range ( $ key , $ operator , $ value , $ bool , $ filter , array $ params = [ ] ) { if ( is_array ( $ operator ) && ! is_array ( $ value ) || ! is_array ( $ operator ) && is_array ( $ value ) || is_array ( $ operator ) && count ( $ operator ) !== count ( $ value ) ) { throw new \ BadMethodCallException ( "Operator and value parameters should be both a scalar type or both an array with same number of elements" ) ; } if ( is_array ( $ key ) ) { return $ this -> multiRange ( $ key , $ operator , $ value , $ bool , $ filter , $ params ) ; } $ query = [ ] ; $ operators = ( array ) $ operator ; $ values = ( array ) $ value ; foreach ( $ operators as $ index => $ operator ) { $ query [ $ operator ] = $ values [ $ index ] ; } $ this -> addBool ( [ "range" => [ $ key => $ query ] ] , $ bool , $ filter , $ params ) ; return $ this ; }
Creates a range query
56,870
public function multiRange ( array $ keys , $ operator , $ value , $ bool , $ filter , array $ params = [ ] ) { $ subQuery = $ this -> orWhere ( $ bool ) ; foreach ( $ keys as $ key ) { $ subQuery -> range ( $ key , $ operator , $ value , $ bool , true , $ params ) ; } $ subQuery -> endSubQuery ( ) ; return $ this ; }
Creates multiple range queries joined by OR
56,871
public function andWhere ( $ bool = "must" , array $ params = [ ] ) { $ callback = function ( SubQueryBuilder $ subQuery ) use ( $ bool , $ params ) { return $ this -> _endChildSubQuery ( "and" , $ subQuery -> toArray ( ) , $ bool , $ params ) ; } ; return SubQueryBuilder :: make ( $ callback ) ; }
Creates an AND filter subquery
56,872
protected function _endChildSubQuery ( $ tool , array $ subQuery , $ bool , array $ params = [ ] ) { $ this -> addBool ( [ $ tool => $ subQuery ] , $ bool , true , $ params ) ; return $ this ; }
Receives the end signal from the sub query object
56,873
protected function assertInitiated ( $ key ) { $ current = & $ this -> query ; $ keys = explode ( "." , $ key ) ; foreach ( $ keys as $ element ) { if ( ! array_key_exists ( $ element , $ current ) ) { $ current [ $ element ] = [ ] ; } $ current = & $ current [ $ element ] ; } }
Checks and creates the required structure
56,874
protected function addBool ( array $ query , $ bool , $ filter = false , array $ params = [ ] ) { $ filtered = $ filter ? "filter" : "query" ; $ key = "query.filtered.{$filtered}.bool.{$bool}" ; if ( $ filter ) { $ this -> assertInitiated ( $ key ) ; } $ this -> query [ "query" ] [ "filtered" ] [ $ filtered ] [ "bool" ] [ $ bool ] [ ] = array_merge_recursive ( $ query , $ params ) ; }
Adds a new bool query part to the query array
56,875
public function saveIPMessage ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; if ( ! Permission :: check ( 'ADMIN' ) ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.PERMISSION_DENINED' , '_Permission Denied' ) ; return $ response ; } try { $ codeBankConfig = CodeBankConfig :: CurrentConfig ( ) ; $ codeBankConfig -> IPMessage = $ data -> message ; $ codeBankConfig -> write ( ) ; $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.IP_MESSAGE_CHANGE' , '_Intellectual Property message changed successfully' ) ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Saves the IP Message
56,876
public function savePreferences ( $ data ) { $ response = CodeBank_ClientAPI :: responseBase ( ) ; try { $ member = Member :: currentUser ( ) ; if ( $ member && $ member -> ID != 0 ) { $ member -> UseHeartbeat = ( $ data -> heartbeat == 1 ? true : false ) ; $ member -> write ( ) ; } else { throw new Exception ( 'Not Logged In!' ) ; } $ response [ 'status' ] = 'HELO' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.PREFERENCES_SAVED' , '_Preferences saved successfully' ) ; } catch ( Exception $ e ) { $ response [ 'status' ] = 'EROR' ; $ response [ 'message' ] = _t ( 'CodeBankAPI.SERVER_ERROR' , '_Server error has occured, please try again later' ) ; } return $ response ; }
Saves users server preferences
56,877
public function setLdap ( Zend_Ldap $ ldap ) { $ this -> _ldap = $ ldap ; $ this -> setOptions ( array ( $ ldap -> getOptions ( ) ) ) ; return $ this ; }
Set an Ldap connection
56,878
protected function _prepareOptions ( Zend_Ldap $ ldap , array $ options ) { $ adapterOptions = array ( 'group' => null , 'groupDn' => $ ldap -> getBaseDn ( ) , 'groupScope' => Zend_Ldap :: SEARCH_SCOPE_SUB , 'groupAttr' => 'cn' , 'groupFilter' => 'objectClass=groupOfUniqueNames' , 'memberAttr' => 'uniqueMember' , 'memberIsDn' => true ) ; foreach ( $ adapterOptions as $ key => $ value ) { if ( array_key_exists ( $ key , $ options ) ) { $ value = $ options [ $ key ] ; unset ( $ options [ $ key ] ) ; switch ( $ key ) { case 'groupScope' : $ value = ( int ) $ value ; if ( in_array ( $ value , array ( Zend_Ldap :: SEARCH_SCOPE_BASE , Zend_Ldap :: SEARCH_SCOPE_ONE , Zend_Ldap :: SEARCH_SCOPE_SUB ) , true ) ) { $ adapterOptions [ $ key ] = $ value ; } break ; case 'memberIsDn' : $ adapterOptions [ $ key ] = ( $ value === true || $ value === '1' || strcasecmp ( $ value , 'true' ) == 0 ) ; break ; default : $ adapterOptions [ $ key ] = trim ( $ value ) ; break ; } } } $ ldap -> setOptions ( $ options ) ; return $ adapterOptions ; }
Sets the LDAP specific options on the Zend_Ldap instance
56,879
protected function _checkGroupMembership ( Zend_Ldap $ ldap , $ canonicalName , $ dn , array $ adapterOptions ) { if ( $ adapterOptions [ 'group' ] === null ) { return true ; } if ( $ adapterOptions [ 'memberIsDn' ] === false ) { $ user = $ canonicalName ; } else { $ user = $ dn ; } require_once 'Zend/Ldap/Filter.php' ; $ groupName = Zend_Ldap_Filter :: equals ( $ adapterOptions [ 'groupAttr' ] , $ adapterOptions [ 'group' ] ) ; $ membership = Zend_Ldap_Filter :: equals ( $ adapterOptions [ 'memberAttr' ] , $ user ) ; $ group = Zend_Ldap_Filter :: andFilter ( $ groupName , $ membership ) ; $ groupFilter = $ adapterOptions [ 'groupFilter' ] ; if ( ! empty ( $ groupFilter ) ) { $ group = $ group -> addAnd ( $ groupFilter ) ; } $ result = $ ldap -> count ( $ group , $ adapterOptions [ 'groupDn' ] , $ adapterOptions [ 'groupScope' ] ) ; if ( $ result === 1 ) { return true ; } else { return 'Failed to verify group membership with ' . $ group -> toString ( ) ; } }
Checks the group membership of the bound user
56,880
private function _optionsToString ( array $ options ) { $ str = '' ; foreach ( $ options as $ key => $ val ) { if ( $ key === 'password' ) $ val = '*****' ; if ( $ str ) $ str .= ',' ; $ str .= $ key . '=' . $ val ; } return $ str ; }
Converts options to string
56,881
public static function lowerCase ( & $ value , & $ key ) { trigger_error ( __CLASS__ . '::' . __METHOD__ . '() is deprecated and will be removed in a future version' , E_USER_NOTICE ) ; return $ value = strtolower ( $ value ) ; }
Lowercase a string
56,882
protected function _buildCallback ( Zend_Server_Reflection_Function_Abstract $ reflection ) { $ callback = new Zend_Server_Method_Callback ( ) ; if ( $ reflection instanceof Zend_Server_Reflection_Method ) { $ callback -> setType ( $ reflection -> isStatic ( ) ? 'static' : 'instance' ) -> setClass ( $ reflection -> getDeclaringClass ( ) -> getName ( ) ) -> setMethod ( $ reflection -> getName ( ) ) ; } elseif ( $ reflection instanceof Zend_Server_Reflection_Function ) { $ callback -> setType ( 'function' ) -> setFunction ( $ reflection -> getName ( ) ) ; } return $ callback ; }
Build callback for method signature
56,883
protected function _buildSignature ( Zend_Server_Reflection_Function_Abstract $ reflection , $ class = null ) { $ ns = $ reflection -> getNamespace ( ) ; $ name = $ reflection -> getName ( ) ; $ method = empty ( $ ns ) ? $ name : $ ns . '.' . $ name ; if ( ! $ this -> _overwriteExistingMethods && $ this -> _table -> hasMethod ( $ method ) ) { require_once 'Zend/Server/Exception.php' ; throw new Zend_Server_Exception ( 'Duplicate method registered: ' . $ method ) ; } $ definition = new Zend_Server_Method_Definition ( ) ; $ definition -> setName ( $ method ) -> setCallback ( $ this -> _buildCallback ( $ reflection ) ) -> setMethodHelp ( $ reflection -> getDescription ( ) ) -> setInvokeArguments ( $ reflection -> getInvokeArguments ( ) ) ; foreach ( $ reflection -> getPrototypes ( ) as $ proto ) { $ prototype = new Zend_Server_Method_Prototype ( ) ; $ prototype -> setReturnType ( $ this -> _fixType ( $ proto -> getReturnType ( ) ) ) ; foreach ( $ proto -> getParameters ( ) as $ parameter ) { $ param = new Zend_Server_Method_Parameter ( array ( 'type' => $ this -> _fixType ( $ parameter -> getType ( ) ) , 'name' => $ parameter -> getName ( ) , 'optional' => $ parameter -> isOptional ( ) , ) ) ; if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ param -> setDefaultValue ( $ parameter -> getDefaultValue ( ) ) ; } $ prototype -> addParameter ( $ param ) ; } $ definition -> addPrototype ( $ prototype ) ; } if ( is_object ( $ class ) ) { $ definition -> setObject ( $ class ) ; } $ this -> _table -> addMethod ( $ definition ) ; return $ definition ; }
Build a method signature
56,884
public function it_fails_if_a_collection_doesnt_have_a_matching_event ( ) { $ events = DomainEvents :: make ( [ ] ) ; expect ( $ events ) -> shouldNotContainEvent ( new EventStub ( 3 , 2 , 1 ) ) ; $ events = DomainEvents :: make ( [ new EventStub ( 3 , 2 , 1 ) , ] ) ; expect ( $ events ) -> shouldNotContainEvent ( new EventStub ( 4 , 4 , 4 ) ) ; }
when you get time
56,885
public function canDelete ( $ member = null ) { $ parentResult = parent :: canDelete ( $ member ) ; if ( $ parentResult == false || $ this -> UserLanguage == false ) { return false ; } if ( $ this -> Folders ( ) -> count ( ) > 0 || $ this -> Snippets ( ) -> count ( ) > 0 ) { return false ; } return true ; }
Checks to see if the given member can delete this object or not
56,886
public function addMethod ( $ method , $ name = null ) { if ( is_array ( $ method ) ) { require_once 'Zend/Server/Method/Definition.php' ; $ method = new Zend_Server_Method_Definition ( $ method ) ; } elseif ( ! $ method instanceof Zend_Server_Method_Definition ) { require_once 'Zend/Server/Exception.php' ; throw new Zend_Server_Exception ( 'Invalid method provided' ) ; } if ( is_numeric ( $ name ) ) { $ name = null ; } if ( null !== $ name ) { $ method -> setName ( $ name ) ; } else { $ name = $ method -> getName ( ) ; } if ( null === $ name ) { require_once 'Zend/Server/Exception.php' ; throw new Zend_Server_Exception ( 'No method name provided' ) ; } if ( ! $ this -> _overwriteExistingMethods && array_key_exists ( $ name , $ this -> _methods ) ) { require_once 'Zend/Server/Exception.php' ; throw new Zend_Server_Exception ( sprintf ( 'Method by name of "%s" already exists' , $ name ) ) ; } $ this -> _methods [ $ name ] = $ method ; return $ this ; }
Add method to definition
56,887
public function addMethods ( array $ methods ) { foreach ( $ methods as $ key => $ method ) { $ this -> addMethod ( $ method , $ key ) ; } return $ this ; }
Add multiple methods
56,888
public function toArray ( ) { $ methods = array ( ) ; foreach ( $ this -> getMethods ( ) as $ key => $ method ) { $ methods [ $ key ] = $ method -> toArray ( ) ; } return $ methods ; }
Cast definition to an array
56,889
function encrypt ( PersonalData $ data , CryptographicDetails $ crypto ) : EncryptedPersonalData { if ( ! $ crypto -> encryption ( ) == 'libsodium' ) { throw new CryptographicDetailsNotCompatibleWithEncryption ( "{$crypto->encryption()} received, expected 'libsodium'" ) ; } $ dataString = $ data -> toString ( ) ; $ secretKey = $ crypto -> key ( 'secretKey' ) ; $ nonce = $ crypto -> key ( 'nonce' ) ; $ encrypted = sodium_crypto_secretbox ( $ dataString , $ nonce , $ secretKey ) ; return EncryptedPersonalData :: fromString ( $ encrypted ) ; }
encrypt personal data and return an encrypted form
56,890
function decrypt ( EncryptedPersonalData $ data , CryptographicDetails $ crypto ) : PersonalData { if ( ! $ crypto -> encryption ( ) == 'libsodium' ) { throw new CryptographicDetailsNotCompatibleWithEncryption ( "{$crypto->encryption()} received, expected 'libsodium'" ) ; } $ encrypted = $ data -> toString ( ) ; $ secretKey = $ crypto -> key ( 'secretKey' ) ; $ nonce = $ crypto -> key ( 'nonce' ) ; $ decrypted = sodium_crypto_secretbox_open ( $ encrypted , $ nonce , $ secretKey ) ; return PersonalData :: fromString ( $ decrypted ) ; }
decrypted encrypted personal data and return a decrypted form
56,891
public function discoverCommand ( ) { $ setup = $ this -> objectManager -> get ( BackendConfigurationManager :: class ) -> getTypoScriptSetup ( ) ; $ typoscriptService = $ this -> objectManager -> get ( TypoScriptService :: class ) ; $ config = $ typoscriptService -> convertTypoScriptArrayToPlainArray ( ( array ) $ setup [ 'plugin.' ] [ 'tx_twcomponentlibrary.' ] ) ; FluidTemplate :: addCommonStylesheets ( $ config [ 'settings' ] [ 'stylesheets' ] ) ; FluidTemplate :: addCommonHeaderScripts ( $ config [ 'settings' ] [ 'headerScripts' ] ) ; FluidTemplate :: addCommonFooterScripts ( $ config [ 'settings' ] [ 'footerScripts' ] ) ; echo json_encode ( Scanner :: discoverAll ( ) , JSON_PRETTY_PRINT ) ; }
Discover and extract all components
56,892
public function createCommand ( $ name , $ type , $ extension = null , $ vendor = null ) { $ name = GeneralUtility :: trimExplode ( '/' , $ name , true ) ; if ( ! count ( $ name ) ) { throw new CommandException ( 'Empty / invalid component name' , 1507996606 ) ; } $ type = strtolower ( $ type ) ; if ( ! in_array ( $ type , ComponentInterface :: TYPES ) ) { throw new CommandException ( sprintf ( 'Invalid component type "%s"' , $ type ) , 1507996917 ) ; } $ extension = trim ( $ extension ? : $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXT' ] [ 'extParams' ] [ 'tw_componentlibrary' ] [ 'defaultextension' ] ) ; if ( ! strlen ( $ extension ) || ! ExtensionManagementUtility :: isLoaded ( $ extension ) ) { throw new CommandException ( sprintf ( 'Invalid provider extension "%s"' , $ extension ) , 1507997408 ) ; } $ vendor = trim ( $ vendor ? : $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'EXT' ] [ 'extParams' ] [ 'tw_componentlibrary' ] [ 'defaultvendor' ] ) ; if ( ! strlen ( $ vendor ) ) { throw new CommandException ( sprintf ( 'Invalid provider extension vendor name "%s"' , $ vendor ) , 1507998569 ) ; } Kickstarter :: create ( $ name , $ type , $ extension , $ vendor ) ; }
Create a new component
56,893
public function color ( $ name , $ value = null , $ options = array ( ) ) { return $ this -> input ( 'color' , $ name , $ value , $ options ) ; }
Create a form color field .
56,894
public function date ( $ name , $ value = null , $ min = null , $ max = null , $ options = array ( ) ) { if ( ! isset ( $ min ) && ! isset ( $ max ) ) return 'The date field "' . $ name . '" must have a min, max or both.' ; if ( isset ( $ min ) ) $ options [ 'min' ] = $ min ; if ( isset ( $ max ) ) $ options [ 'max' ] = $ max ; return $ this -> input ( 'date' , $ name , $ value , $ options ) ; }
Create a form date field .
56,895
public function week ( $ name , $ value = null , $ options = array ( ) ) { return $ this -> input ( 'week' , $ name , $ value , $ options ) ; }
Create a form week field .
56,896
public function month ( $ name , $ value = null , $ options = array ( ) ) { return $ this -> input ( 'month' , $ name , $ value , $ options ) ; }
Create a form month field .
56,897
public function number ( $ name , $ value = null , $ step = null , $ options = array ( ) ) { if ( isset ( $ step ) ) $ options [ 'step' ] = $ step ; $ options = $ this -> setNumberMinMax ( $ options ) ; return $ this -> input ( 'number' , $ name , $ value , $ options ) ; }
Create a form number field .
56,898
public function range ( $ name , $ value = null , $ options = array ( ) ) { $ options = $ this -> setNumberMinMax ( $ options ) ; return $ this -> input ( 'range' , $ name , $ value , $ options ) ; }
Create a form range field .
56,899
public function search ( $ name , $ value = null , $ options = array ( ) ) { return $ this -> input ( 'search' , $ name , $ value , $ options ) ; }
Create a form search field .