idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
23,000
protected function get_shortcode_atts_parser_class ( $ tag ) { $ atts_parser = $ this -> hasConfigKey ( $ tag , self :: KEY_CUSTOM_ATTS_PARSER ) ? $ this -> getConfigKey ( $ tag , self :: KEY_CUSTOM_ATTS_PARSER ) : self :: DEFAULT_SHORTCODE_ATTS_PARSER ; return $ atts_parser ; }
Get the class name of an implementation of the ShortcodeAttsParsersInterface .
23,001
protected function init_shortcode_ui ( $ tag ) { $ shortcode_ui_class = $ this -> get_shortcode_ui_class ( $ tag ) ; $ this -> shortcode_uis [ ] = $ this -> instantiate ( ShortcodeUIInterface :: class , $ shortcode_ui_class , [ 'shortcode_tag' => $ tag , 'config' => $ this -> config -> getSubConfig ( $ tag , self :: KEY_UI ) , 'dependencies' => $ this -> dependencies , ] ) ; }
Initialize the Shortcode UI for a single shortcode .
23,002
protected function get_shortcode_ui_class ( $ tag ) { $ ui_class = $ this -> hasConfigKey ( $ tag , self :: KEY_CUSTOM_UI ) ? $ this -> getConfigKey ( $ tag , self :: KEY_CUSTOM_UI ) : self :: DEFAULT_SHORTCODE_UI ; return $ ui_class ; }
Get the class name of an implementation of the ShortcodeUIInterface .
23,003
public function register ( $ context = null ) { $ this -> init_shortcodes ( ) ; $ context = $ this -> validate_context ( $ context ) ; $ context [ 'page_template' ] = $ this -> get_page_template ( ) ; array_walk ( $ this -> shortcodes , function ( ShortcodeInterface $ shortcode ) use ( $ context ) { $ shortcode -> register ( $ context ) ; } ) ; \ add_action ( 'register_shortcode_ui' , [ $ this , 'register_shortcode_ui' , ] ) ; }
Register all of the shortcode handlers .
23,004
public function register_shortcode_ui ( ) { $ template = $ this -> get_page_template ( ) ; $ context = [ 'page_template' => $ template ] ; array_walk ( $ this -> shortcode_uis , function ( ShortcodeUIInterface $ shortcode_ui ) use ( $ context ) { $ shortcode_ui -> register ( $ context ) ; } ) ; }
Register the shortcode UI handlers .
23,005
public function do_tag ( $ tag , array $ atts = [ ] , $ content = null ) { return \ BrightNucleus \ Shortcode \ do_tag ( $ tag , $ atts , $ content ) ; }
Execute a specific shortcode directly from code .
23,006
protected function instantiate ( $ interface , $ class , array $ args ) { try { if ( is_callable ( $ class ) ) { $ class = call_user_func_array ( $ class , $ args ) ; } if ( is_string ( $ class ) ) { if ( null !== $ this -> injector ) { $ class = $ this -> injector -> make ( $ class , $ args ) ; } else { $ class = $ this -> instantiateClass ( $ class , $ args ) ; } } } catch ( Exception $ exception ) { throw FailedToInstantiateObject :: fromFactory ( $ class , $ interface , $ exception ) ; } if ( ! is_subclass_of ( $ class , $ interface ) ) { throw FailedToInstantiateObject :: fromInvalidObject ( $ class , $ interface ) ; } return $ class ; }
Instantiate a new object through either a class name or a factory method .
23,007
public function parseNode ( $ query , $ node ) { if ( $ node instanceof Nodes \ KeyNode ) { return $ this -> parseKey ( $ node -> getValue ( ) ) ; } if ( $ node instanceof Nodes \ ValueNode ) { return $ this -> parseValue ( $ node -> getValue ( ) ) ; } if ( $ node instanceof Nodes \ FunctionNode ) { $ f = $ this -> getBuilder ( ) -> getFunctions ( ) -> first ( function ( $ item , $ key ) use ( $ node ) { $ class = $ item -> getNode ( ) ; return $ node instanceof $ class ; } ) ; if ( ! $ f ) { throw new \ Railken \ SQ \ Exceptions \ QuerySyntaxException ( ) ; } $ childs = new Collection ( ) ; foreach ( $ node -> getChildren ( ) as $ child ) { $ childs [ ] = $ this -> parseNode ( $ query , $ child ) ; } $ childs = $ childs -> map ( function ( $ v ) use ( $ query ) { if ( $ v instanceof \ Illuminate \ Database \ Query \ Expression ) { return $ v -> getValue ( ) ; } $ query -> addBinding ( $ v , 'where' ) ; return '?' ; } ) ; return DB :: raw ( $ f -> getName ( ) . '(' . $ childs -> implode ( ',' ) . ')' ) ; } }
Parse the node .
23,008
public function parseKey ( $ key ) { $ keys = explode ( '.' , $ key ) ; $ keys = [ implode ( "." , array_slice ( $ keys , 0 , - 1 ) ) , $ keys [ count ( $ keys ) - 1 ] ] ; $ key = ( new Collection ( $ keys ) ) -> map ( function ( $ part ) { return '`' . $ part . '`' ; } ) -> implode ( '.' ) ; return DB :: raw ( $ key ) ; }
Parse key .
23,009
private function prepareDataBits ( ) { $ n = $ this -> structureAppendN ; $ m = $ this -> structureAppendM ; $ parity = $ this -> structureAppendParity ; $ originalData = $ this -> structureAppendOriginalData ; $ dataCounter = 0 ; if ( $ this -> checkStructureAppend ( $ n , $ m ) ) { $ dataValue [ 0 ] = 3 ; $ dataBits [ 0 ] = 4 ; $ dataValue [ 1 ] = $ m - 1 ; $ dataBits [ 1 ] = 4 ; $ dataValue [ 2 ] = $ n - 1 ; $ dataBits [ 2 ] = 4 ; $ originalDataLength = strlen ( $ originalData ) ; if ( $ originalDataLength > 1 ) { $ parity = 0 ; $ i = 0 ; while ( $ i < $ originalDataLength ) { $ parity = ( $ parity ^ ord ( substr ( $ originalData , $ i , 1 ) ) ) ; $ i ++ ; } } $ dataValue [ 3 ] = $ parity ; $ dataBits [ 3 ] = 8 ; $ dataCounter = 4 ; } $ dataBits [ $ dataCounter ] = 4 ; return $ dataBits ; }
Get Data Bits Array
23,010
public function getModeName ( ) { return $ this -> isNumericData ( ) ? self :: NUMERIC_MODE : ( $ this -> isAlphaNumericData ( ) ? self :: ALPHA_NUMERIC_MODE : self :: EIGHT_BITS_MODE ) ; }
Get the encoding mode name
23,011
private function switchMode ( ) { switch ( $ this -> getModeName ( ) ) { case self :: NUMERIC_MODE : return new NumericMode ; case self :: ALPHA_NUMERIC_MODE : return new AlphanumericMode ; case self :: EIGHT_BITS_MODE : default : return new EightBitMode ; } }
Switch the Encoding mode
23,012
public function create ( ) : LoggerInterface { $ loggerType = $ this -> config [ 'type' ] ?? 'null' ; switch ( $ loggerType ) { case 'file' : return new Logger ( $ this -> config [ 'path' ] , $ this -> config [ 'level' ] ) ; case 'null' : return new NullLogger ; default : throw new \ RuntimeException ( 'Invalid logger type' ) ; } }
Creates logger depending on configuration .
23,013
public function compile ( ) { $ test = $ this -> getResource ( ) -> getOnePropertyValue ( new core_kernel_classes_Property ( PROPERTY_DELIVERYCONTENT_TEST ) ) ; if ( is_null ( $ test ) ) { throw new EmptyDeliveryException ( $ this -> getResource ( ) ) ; } return $ this -> subCompile ( $ test ) ; }
Compiles a simple delivery
23,014
protected function parseCookies ( ) { $ cookie = '' ; foreach ( $ this -> cookies as $ name => $ value ) $ cookie .= $ name . '=' . $ value . '; ' ; return rtrim ( $ cookie , ';' ) ; }
Parse the cookies into a valid HTTP Cookie header value
23,015
public function getSoapVariables ( $ requestObject , $ lowerCaseFirst = false , $ keepNullProperties = true ) { if ( ! is_object ( $ requestObject ) ) { throw new InvalidParameterException ( 'Parameter requestObject is not an object' ) ; } $ objectName = $ this -> getClassNameWithoutNamespaces ( $ requestObject ) ; if ( $ lowerCaseFirst ) { $ objectName = lcfirst ( $ objectName ) ; } $ stdClass = new \ stdClass ( ) ; $ stdClass -> $ objectName = $ requestObject ; return $ this -> objectToArray ( $ stdClass , $ keepNullProperties ) ; }
Get SOAP Request Variables
23,016
protected function logCurlMessage ( $ message , \ DateTime $ messageTimestamp ) { if ( ! $ this -> debugLogFilePath ) { throw new \ RuntimeException ( 'Debug log file path not defined.' ) ; } $ logMessage = '[' . $ messageTimestamp -> format ( 'Y-m-d H:i:s' ) . "] ----------------------------------------------------------\n" . $ message . "\n\n" ; $ logHandle = fopen ( $ this -> debugLogFilePath , 'a+' ) ; fwrite ( $ logHandle , $ logMessage ) ; fclose ( $ logHandle ) ; }
Log cURL Debug Message
23,017
public function convert ( ) { $ resource = $ file = \ tao_helpers_Http :: getUploadedFile ( 'content' ) ; $ base64Converter = new Base64ConverterModel ( $ resource ) ; $ this -> returnJson ( $ base64Converter -> convertToBase64 ( ) ) ; }
Convert uploaded resource to base 64 code
23,018
public function emulateFatal ( ) { if ( $ this -> isExternal ( ) ) { $ obj = null ; $ obj -> callOnNull ( ) ; } else { $ this -> callOnChild ( __FUNCTION__ , func_get_args ( ) ) ; } }
Will create PHP Fatal on remote thread
23,019
public function emulateExceptionOnRemoteLoop ( ) { if ( $ this -> isExternal ( ) ) { $ this -> loop -> nextTick ( function ( ) { $ this -> emulateException ( ) ; } ) ; } else { $ this -> callOnChild ( __FUNCTION__ , func_get_args ( ) ) ; } }
Will throw exception on remote thread within loop
23,020
public function emulateFatalOnRemoteLoop ( ) { if ( $ this -> isExternal ( ) ) { $ this -> loop -> nextTick ( function ( ) { $ this -> emulateFatal ( ) ; } ) ; } else { $ this -> callOnChild ( __FUNCTION__ , func_get_args ( ) ) ; } }
Will create PGP Fatal on remote thread within loop
23,021
public function getTrashed ( ) { if ( ! $ this -> modelAdmin -> hasSoftDeleting ( ) ) { return $ this -> missingMethod ( ) ; } return view ( 'flare::admin.modeladmin.trashed' , [ 'modelItems' => $ this -> modelAdmin -> onlyTrashedItems ( ) , 'totals' => $ this -> modelAdmin -> totals ( ) , ] ) ; }
Lists Trashed Model Items .
23,022
public function getAll ( ) { if ( ! $ this -> modelAdmin -> hasSoftDeleting ( ) ) { return $ this -> missingMethod ( ) ; } return view ( 'flare::admin.modeladmin.all' , [ 'modelItems' => $ this -> modelAdmin -> allItems ( ) , 'totals' => $ this -> modelAdmin -> totals ( ) , ] ) ; }
List All Model Items inc Trashed .
23,023
public function postCreate ( ModelCreateRequest $ request ) { if ( ! $ this -> modelAdmin -> hasCreating ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> create ( ) ; return redirect ( $ this -> modelAdmin -> currentUrl ( ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'The ' . $ this -> modelAdmin -> getTitle ( ) . ' was successfully created.' , 'dismissable' => false ] ] ) ; }
Receive new Model Entry Post Data validate it and return user .
23,024
public function getView ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasViewing ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> find ( $ modelitemId ) ; event ( new ModelView ( $ this -> modelAdmin ) ) ; return view ( 'flare::admin.modeladmin.view' , [ 'modelItem' => $ this -> modelAdmin -> model ] ) ; }
View a Model Entry from ModelAdmin View Page .
23,025
public function getEdit ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasEditing ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> find ( $ modelitemId ) ; return view ( 'flare::admin.modeladmin.edit' , [ 'modelItem' => $ this -> modelAdmin -> model ] ) ; }
Edit Model Entry from ModelAdmin Edit Page .
23,026
public function postEdit ( ModelEditRequest $ request , $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasEditing ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> edit ( $ modelitemId ) ; return redirect ( $ this -> modelAdmin -> currentUrl ( ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'The ' . $ this -> modelAdmin -> getTitle ( ) . ' was successfully updated.' , 'dismissable' => false ] ] ) ; }
Receive Model Entry Update Post Data validate it and return user .
23,027
public function getDelete ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasDeleting ( ) ) { return $ this -> missingMethod ( ) ; } if ( $ this -> modelAdmin -> hasSoftDeleting ( ) ) { $ this -> modelAdmin -> findWithTrashed ( $ modelitemId ) ; } else { $ this -> modelAdmin -> find ( $ modelitemId ) ; } return view ( 'flare::admin.modeladmin.delete' , [ 'modelItem' => $ this -> modelAdmin -> model ] ) ; }
Delete Model Entry from ModelAdmin Delete Page .
23,028
public function postDelete ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasDeleting ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> delete ( $ modelitemId ) ; return redirect ( $ this -> modelAdmin -> currentUrl ( ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'The ' . $ this -> modelAdmin -> getTitle ( ) . ' was successfully removed.' , 'dismissable' => false ] ] ) ; }
Receive Model Entry Delete Post Data validate it and return user .
23,029
public function getRestore ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasSoftDeleting ( ) ) { return $ this -> missingMethod ( ) ; } return view ( 'flare::admin.modeladmin.restore' , [ 'modelItem' => $ this -> modelAdmin -> model ] ) ; }
Restore a ModelItem .
23,030
public function postRestore ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasSoftDeleting ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> restore ( $ modelitemId ) ; return redirect ( $ this -> modelAdmin -> currentUrl ( ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'The ' . $ this -> modelAdmin -> getTitle ( ) . ' was successfully restored.' , 'dismissable' => false ] ] ) ; }
Process Restore ModelItem Request .
23,031
public function getClone ( $ modelitemId ) { if ( ! $ this -> modelAdmin -> hasCloning ( ) ) { return $ this -> missingMethod ( ) ; } $ this -> modelAdmin -> clone ( $ modelitemId ) ; return redirect ( $ this -> modelAdmin -> currentUrl ( ) ) -> with ( 'notifications_below_header' , [ [ 'type' => 'success' , 'icon' => 'check-circle' , 'title' => 'Success!' , 'message' => 'The ' . $ this -> modelAdmin -> getTitle ( ) . ' was successfully cloned.' , 'dismissable' => false ] ] ) ; }
Clone a Page .
23,032
public function start ( Impersonatable $ impersonater , Impersonatable $ impersonated ) { $ this -> checkImpersonation ( $ impersonater , $ impersonated ) ; try { session ( ) -> put ( $ this -> getSessionKey ( ) , $ impersonater -> getAuthIdentifier ( ) ) ; $ this -> auth ( ) -> silentLogout ( ) ; $ this -> auth ( ) -> silentLogin ( $ impersonated ) ; $ this -> events ( ) -> dispatch ( new Events \ ImpersonationStarted ( $ impersonater , $ impersonated ) ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Start the impersonation .
23,033
public function stop ( ) { try { $ impersonated = $ this -> auth ( ) -> user ( ) ; $ impersonater = $ this -> findUserById ( $ this -> getImpersonatorId ( ) ) ; $ this -> auth ( ) -> silentLogout ( ) ; $ this -> auth ( ) -> silentLogin ( $ impersonater ) ; $ this -> clear ( ) ; $ this -> events ( ) -> dispatch ( new Events \ ImpersonationStopped ( $ impersonater , $ impersonated ) ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Stop the impersonation .
23,034
private function checkImpersonation ( Impersonatable $ impersonater , Impersonatable $ impersonated ) { $ this -> mustBeEnabled ( ) ; $ this -> mustBeDifferentImpersonatable ( $ impersonater , $ impersonated ) ; $ this -> checkImpersonater ( $ impersonater ) ; $ this -> checkImpersonated ( $ impersonated ) ; }
Check the impersonation .
23,035
private function mustBeDifferentImpersonatable ( Impersonatable $ impersonater , Impersonatable $ impersonated ) { if ( $ impersonater -> getAuthIdentifier ( ) == $ impersonated -> getAuthIdentifier ( ) ) throw new Exceptions \ ImpersonationException ( 'The impersonater & impersonated with must be different.' ) ; }
Check the impersonater and the impersonated are different .
23,036
public function searchUser ( $ searchTerm , $ page = 1 , $ limit = 10 ) { $ total = $ this -> userRepository -> countNumberOfUserInSearch ( $ searchTerm ) ; $ users = $ this -> userRepository -> searchUsers ( $ searchTerm , $ page , $ limit ) ; $ results = [ ] ; foreach ( $ users as $ user ) { $ results [ ] = $ user -> listView ( ) ; } return new PageModel ( $ results , $ page , $ total , $ limit , 'users' ) ; }
Return a paginator of users
23,037
public function registerUser ( BaseUser $ user , $ source = self :: SOURCE_TYPE_WEBSITE ) { $ user -> setRoles ( [ "ROLE_USER" ] ) -> setSource ( $ source ) -> setEnabled ( true ) ; $ this -> saveUserWithPlainPassword ( $ user ) ; $ this -> dispatcher -> dispatch ( self :: REGISTER_EVENT , new UserEvent ( $ user ) ) ; return $ user ; }
Saves a new user to our database
23,038
public function saveUserForResetPassword ( BaseUser $ user ) { $ user -> setForgetPasswordToken ( null ) -> setForgetPasswordExpired ( null ) ; $ this -> saveUserWithPlainPassword ( $ user ) ; }
Makes sure the forget password token and forget password token expiration time are set to null
23,039
public function updateUserRefreshToken ( BaseUser $ user ) { if ( ! $ user -> isRefreshTokenValid ( ) ) { $ user -> setRefreshToken ( bin2hex ( random_bytes ( 90 ) ) ) ; } $ expirationDate = new \ DateTime ( ) ; $ expirationDate -> modify ( '+' . $ this -> refreshTokenTTL . ' seconds' ) ; $ user -> setRefreshTokenExpire ( $ expirationDate ) ; $ this -> save ( $ user ) ; return $ user ; }
Saves the user with an updated refresh token
23,040
public static function create ( ) { $ email = new static ( ) ; $ email -> from ( Yii :: $ app -> params [ 'mandrill' ] [ 'from_name' ] , Yii :: $ app -> params [ 'mandrill' ] [ 'from_email' ] ) ; return $ email ; }
Creates a new email model and returns it
23,041
public function from ( $ name , $ email ) { $ this -> from_email = $ email ; $ this -> from_name = $ name ; return $ this ; }
Sets the from fields
23,042
public function send ( ) { if ( ! $ this -> validate ( ) ) { return $ this -> getErrors ( ) ; } foreach ( $ this -> multipleRecipients as $ to ) { $ email_copy = clone $ this ; if ( is_array ( $ to ) ) { $ email_copy -> to_email = $ to [ 'email' ] ; $ email_copy -> to_name = $ to [ 'name' ] ; } else { $ email_copy -> to_email = $ to ; $ email_copy -> to_name = '' ; } $ email_copy -> save ( false ) ; } return true ; }
Sends the email to the email queue
23,043
public function sendEmail ( ) { $ mandrill = new Mandrill ( Yii :: $ app -> params [ 'mandrill' ] [ 'key' ] ) ; $ message = [ 'html' => $ this -> html , 'text' => $ this -> text , 'subject' => $ this -> subject , 'from_email' => $ this -> from_email , 'from_name' => $ this -> from_name , 'track_opens' => true , 'track_clicks' => true , 'auto_text' => true , 'to' => [ [ 'email' => $ this -> to_email , 'name' => $ this -> to_name ] ] , 'bcc_address' => 'mihai.petrescu@gmail.com' , ] ; $ result = $ mandrill -> messages -> send ( $ message ) ; if ( $ result [ 0 ] [ 'status' ] == 'sent' ) { $ this -> status = 'sent' ; } else { $ this -> tries ++ ; } $ this -> save ( ) ; }
Tries to send the email to mandril
23,044
public function haltQueue ( $ early = false ) { if ( $ early ) { $ this -> haltedQueueEarly = true ; } $ this -> haltedQueue = true ; return $ this ; }
Set the halt queue flag to true
23,045
public function getElasticaFields ( ) { $ db = \ DataObject :: database_fields ( get_class ( $ this -> owner ) ) ; $ fields = $ this -> owner -> searchableFields ( ) ; $ result = new \ ArrayObject ( ) ; foreach ( $ fields as $ name => $ params ) { $ type = null ; $ spec = array ( ) ; if ( array_key_exists ( $ name , $ db ) ) { $ class = $ db [ $ name ] ; if ( ( $ pos = strpos ( $ class , '(' ) ) ) { $ class = substr ( $ class , 0 , $ pos ) ; } if ( array_key_exists ( $ class , self :: $ mappings ) ) { $ spec [ 'type' ] = self :: $ mappings [ $ class ] ; } } $ result [ $ name ] = $ spec ; } $ result [ 'LastEdited' ] = array ( 'type' => 'date' ) ; $ result [ 'Created' ] = array ( 'type' => 'date' ) ; $ result [ 'ID' ] = array ( 'type' => 'integer' ) ; $ result [ 'ParentID' ] = array ( 'type' => 'integer' ) ; $ result [ 'Sort' ] = array ( 'type' => 'integer' ) ; $ result [ 'Name' ] = array ( 'type' => 'string' ) ; $ result [ 'MenuTitle' ] = array ( 'type' => 'string' ) ; $ result [ 'ShowInSearch' ] = array ( 'type' => 'integer' ) ; $ result [ 'ClassName' ] = array ( 'type' => 'string' ) ; $ result [ 'ClassNameHierarchy' ] = array ( 'type' => 'string' ) ; $ result [ 'SS_Stage' ] = array ( 'type' => 'keyword' ) ; $ result [ 'PublicView' ] = array ( 'type' => 'boolean' ) ; if ( $ this -> owner -> hasExtension ( 'Hierarchy' ) || $ this -> owner -> hasField ( 'ParentID' ) ) { $ result [ 'ParentsHierarchy' ] = array ( 'type' => 'long' , ) ; } foreach ( $ result as $ field => $ spec ) { if ( isset ( $ spec [ 'type' ] ) && ( $ spec [ 'type' ] == 'date' ) ) { $ spec [ 'format' ] = 'yyyy-MM-dd HH:mm:ss' ; $ result [ $ field ] = $ spec ; } } if ( isset ( $ result [ 'Content' ] ) && count ( $ result [ 'Content' ] ) ) { $ spec = $ result [ 'Content' ] ; $ spec [ 'store' ] = false ; $ result [ 'Content' ] = $ spec ; } $ this -> owner -> invokeWithExtensions ( 'updateElasticMappings' , $ result ) ; return $ result -> getArrayCopy ( ) ; }
Gets an array of elastic field definitions .
23,046
public function onAfterWrite ( ) { if ( \ Config :: inst ( ) -> get ( 'ElasticSearch' , 'disabled' ) || ! $ this -> owner -> autoIndex ( ) ) { return ; } $ stage = \ Versioned :: current_stage ( ) ; $ this -> service -> index ( $ this -> owner , $ stage ) ; }
Updates the record in the search index .
23,047
public function onAfterDelete ( ) { if ( \ Config :: inst ( ) -> get ( 'ElasticSearch' , 'disabled' ) ) { return ; } $ stage = \ Versioned :: current_stage ( ) ; $ this -> service -> remove ( $ this -> owner , $ stage ) ; }
Removes the record from the search index .
23,048
public function massUpdate ( UsersRequest $ request , User $ users ) { $ this -> authorize ( 'otherUpdate' , User :: class ) ; $ data = $ request -> except ( '_token' , 'updated_at' , 'image' , 'submit' ) ; $ users = $ users -> whereIn ( 'id' , $ data [ 'users' ] ) ; $ messages = [ ] ; switch ( $ data [ 'mass_action' ] ) { case 'mass_activate' : break ; case 'mass_lock' : break ; case 'mass_delete' : $ usersTemp = $ users -> get ( ) ; foreach ( $ usersTemp as $ user ) { if ( ! $ user -> delete ( ) ) { $ messages [ ] = '!mass_delete' ; } } break ; case 'mass_delete_inactive' : break ; } $ message = empty ( $ messages ) ? 'msg.complete' : 'msg.complete_but_null' ; return $ this -> makeRedirect ( true , 'admin.users.index' , $ message ) ; }
Mass update the specified resource in storage .
23,049
public function allToArray ( $ locale , $ group , $ namespace = null ) { $ args = func_get_args ( ) ; $ args [ ] = config ( 'app.locale' ) ; return $ this -> executeCallback ( static :: class , __FUNCTION__ , $ args , function ( ) use ( $ locale , $ group ) { $ array = DB :: table ( 'translations' ) -> select ( DB :: raw ( "JSON_UNQUOTE(JSON_EXTRACT(`translation`, '$." . $ locale . "')) AS translation" ) , 'key' ) -> where ( 'group' , $ group ) -> pluck ( 'translation' , 'key' ) -> all ( ) ; return $ array ; } ) ; }
Get translations to Array .
23,050
public function setInstance ( PluginInstance $ instance ) { $ this -> instance = $ instance ; $ this -> pluginInstanceId = $ instance -> getInstanceId ( ) ; }
Set the plugin instance to be wrapped
23,051
public function actionList ( $ type , $ term ) { $ tags = Tag :: find ( ) -> where ( 'type = :type AND LOWER(name) LIKE :term AND status<>"deleted"' , [ ':type' => $ type , ':term' => '%' . strtolower ( $ term ) . '%' ] ) -> all ( ) ; $ response = [ ] ; foreach ( $ tags as $ tag ) { $ response [ ] = [ "id" => $ tag -> id , "label" => $ tag -> name , "value" => $ tag -> name ] ; } Yii :: $ app -> response -> format = 'json' ; return $ response ; }
Updates the prices of a product If update is successful the browser will be redirected to the view page .
23,052
protected function setFilename ( $ filename ) { if ( false === realpath ( $ filename ) ) { throw new FileNotFoundException ( sprintf ( "The file \"%s\" was not found" , $ filename ) ) ; } $ this -> filename = realpath ( $ filename ) ; return $ this ; }
Set the filename .
23,053
public function match ( string $ uri ) : bool { if ( $ this -> uri == $ uri ) { return true ; } $ pattern = '/^' . $ this -> regex . '$/' ; return ! is_null ( $ this -> regex ) && preg_match ( $ pattern , $ uri ) ; }
Verifies if the given uri matches the route definition .
23,054
public function getArguments ( string $ uri , $ callback = null ) : array { $ values = [ ] ; $ pattern = '/^' . $ this -> regex . '$/' ; preg_match_all ( $ pattern , $ uri , $ matches ) ; $ matchCount = count ( $ matches ) ; for ( $ i = 1 ; $ i < $ matchCount ; ++ $ i ) { $ values [ ] = ( ! is_null ( $ callback ) ) ? ( new Callback ( $ callback ) ) -> execute ( $ matches [ $ i ] [ 0 ] ) : $ matches [ $ i ] [ 0 ] ; } $ arguments = [ ] ; $ i = 0 ; foreach ( $ this -> parameters as $ parameter ) { $ arguments [ $ parameter ] = $ values [ $ i ] ; ++ $ i ; } return $ arguments ; }
Retrieves all uri arguments matching the given uri .
23,055
public function getDataObjects ( $ limit = 0 , $ start = 0 ) { $ pagination = \ PaginatedList :: create ( $ this -> toArrayList ( ) ) -> setPageLength ( $ limit ) -> setPageStart ( $ start ) -> setTotalItems ( $ this -> getTotalResults ( ) ) -> setLimitItems ( false ) ; return $ pagination ; }
The paginated result set that is rendered onto the search page .
23,056
public function onAuthenticationFailure ( Request $ request , AuthenticationException $ exception ) { $ this -> dispatcher -> dispatch ( self :: API_GUARD_FAILED , new AuthFailedEvent ( $ request , $ exception ) ) ; return $ this -> removeAuthCookieFromResponse ( new Response ( 'Authentication Failed' , Response :: HTTP_FORBIDDEN ) ) ; }
4a ) This is fired when authentication fails . This can be caused by expired tokens deleted users etc
23,057
public function setClient ( ClientInterface $ client = null ) : self { if ( null === $ client ) { $ this -> client = new Client ( ) ; return $ this ; } $ this -> client = $ client ; return $ this ; }
Set the client used for the operations .
23,058
public function index ( $ record , $ stage = 'Stage' ) { if ( ! $ this -> enabled ) { return ; } $ document = $ record -> getElasticaDocument ( $ stage ) ; $ type = $ record -> getElasticaType ( ) ; $ this -> indexDocument ( $ document , $ type ) ; }
Either creates or updates a record in the index .
23,059
public function endBulkIndex ( ) { if ( ! $ this -> connected ) { return ; } $ index = $ this -> getIndex ( ) ; try { foreach ( $ this -> buffer as $ type => $ documents ) { $ index -> getType ( $ type ) -> addDocuments ( $ documents ) ; $ index -> refresh ( ) ; } } catch ( HttpException $ ex ) { $ this -> connected = false ; \ SS_Log :: log ( $ ex , \ SS_Log :: ERR ) ; } catch ( \ Elastica \ Exception \ BulkException $ be ) { \ SS_Log :: log ( $ be , \ SS_Log :: ERR ) ; throw $ be ; } $ this -> buffered = false ; $ this -> buffer = array ( ) ; }
Ends the current bulk index operation and indexes the buffered documents .
23,060
public function remove ( $ record , $ stage = 'Stage' ) { $ index = $ this -> getIndex ( ) ; $ type = $ index -> getType ( $ record -> getElasticaType ( ) ) ; try { $ type -> deleteDocument ( $ record -> getElasticaDocument ( $ stage ) ) ; } catch ( \ Exception $ ex ) { \ SS_Log :: log ( $ ex , \ SS_Log :: WARN ) ; return false ; } return true ; }
Deletes a record from the index .
23,061
public function define ( ) { $ index = $ this -> getIndex ( ) ; if ( ! $ index -> exists ( ) ) { $ index -> create ( ) ; } try { $ this -> createMappings ( $ index ) ; } catch ( \ Elastica \ Exception \ ResponseException $ ex ) { \ SS_Log :: log ( $ ex , \ SS_Log :: WARN ) ; } }
Creates the index and the type mappings .
23,062
protected function createMappings ( \ Elastica \ Index $ index ) { foreach ( $ this -> getIndexedClasses ( ) as $ class ) { $ sng = singleton ( $ class ) ; $ type = $ sng -> getElasticaType ( ) ; if ( isset ( $ this -> mappings [ $ type ] ) ) { continue ; } $ mapping = $ sng -> getElasticaMapping ( ) ; $ mapping -> setType ( $ index -> getType ( $ type ) ) ; $ mapping -> send ( ) ; } if ( $ this -> mappings ) { foreach ( $ this -> mappings as $ type => $ fields ) { $ mapping = new Mapping ( ) ; $ mapping -> setProperties ( $ fields ) ; $ mapping -> setParam ( 'date_detection' , false ) ; $ mapping -> setType ( $ index -> getType ( $ type ) ) ; $ mapping -> send ( ) ; } } }
Define all known mappings
23,063
public function refresh ( $ logFunc = null ) { $ index = $ this -> getIndex ( ) ; if ( ! $ logFunc ) { $ logFunc = function ( $ msg ) { } ; } foreach ( $ this -> getIndexedClasses ( ) as $ class ) { $ logFunc ( "Indexing items of type $class" ) ; $ this -> startBulkIndex ( ) ; foreach ( $ class :: get ( ) as $ record ) { $ logFunc ( "Indexing " . $ record -> Title ) ; $ this -> index ( $ record ) ; } if ( \ Object :: has_extension ( $ class , 'Versioned' ) ) { $ live = \ Versioned :: get_by_stage ( $ class , 'Live' ) ; foreach ( $ live as $ liveRecord ) { $ logFunc ( "Indexing Live record " . $ liveRecord -> Title ) ; $ this -> index ( $ liveRecord , 'Live' ) ; } } $ this -> endBulkIndex ( ) ; } }
Re - indexes each record in the index .
23,064
public static function formatOrNull ( $ dateTime , $ format = 'Y-m-d H:i:s' , $ null = null ) { if ( $ dateTime instanceof \ DateTime ) { return $ dateTime -> format ( $ format ) ; } elseif ( ValueHelper :: isDateTime ( $ dateTime ) ) { return static :: stringToDateTime ( $ dateTime ) -> format ( $ format ) ; } else { return $ null ; } }
Tries to format given input .
23,065
public function getDomainInfo ( $ domain ) { try { $ result = $ this -> getDomainLookupQuery ( $ domain ) -> getSingleResult ( ) ; } catch ( NoResultException $ e ) { $ result = null ; } return $ result ; }
Get the info for a single domain
23,066
private function getDomainLookupQuery ( $ domain = null ) { $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'domain.domain, primary.domain primaryDomain, language.iso639_2b languageId, site.siteId, country.iso3 countryId' ) -> from ( \ Rcm \ Entity \ Domain :: class , 'domain' , 'domain.domain' ) -> leftJoin ( 'domain.primaryDomain' , 'primary' ) -> leftJoin ( 'domain.defaultLanguage' , 'language' ) -> leftJoin ( \ Rcm \ Entity \ Site :: class , 'site' , Join :: WITH , 'site.domain = domain.domainId' ) -> leftJoin ( 'site.country' , 'country' ) ; if ( ! empty ( $ domain ) ) { $ queryBuilder -> andWhere ( 'domain.domain = :domain' ) -> setParameter ( 'domain' , $ domain ) ; } return $ queryBuilder -> getQuery ( ) ; }
Get Doctrine Query Object for Domain Lookups
23,067
public function searchForDomain ( $ domainSearchParam ) { $ domainsQueryBuilder = $ this -> createQueryBuilder ( 'domain' ) ; $ domainsQueryBuilder -> where ( 'domain.domain LIKE :domainSearchParam' ) ; $ query = $ domainsQueryBuilder -> getQuery ( ) ; $ query -> setParameter ( 'domainSearchParam' , $ domainSearchParam ) ; return $ query -> getResult ( ) ; }
Search for a domain name by query string .
23,068
public function getRedirectList ( $ siteId ) { try { $ result = $ this -> getQuery ( $ siteId ) -> getResult ( ) ; } catch ( NoResultException $ e ) { $ result = [ ] ; } return $ result ; }
Get Redirect List From DB
23,069
private function getQuery ( $ siteId , $ url = null ) { if ( empty ( $ siteId ) || ! is_numeric ( $ siteId ) ) { throw new InvalidArgumentException ( 'Invalid Site Id To Search By' ) ; } $ queryBuilder = $ this -> _em -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'r' ) -> from ( \ Rcm \ Entity \ Redirect :: class , 'r' , 'r.requestUrl' ) -> leftJoin ( 'r.site' , 'site' ) -> where ( 'r.site = :siteId' ) -> orWhere ( 'r.site is null' ) -> orderBy ( 'site.siteId' , 'DESC' ) -> setMaxResults ( 1 ) -> setParameter ( 'siteId' , $ siteId ) ; if ( ! empty ( $ url ) ) { $ queryBuilder -> andWhere ( 'r.requestUrl = :requestUrl' ) ; $ queryBuilder -> setParameter ( 'requestUrl' , $ url ) ; } return $ queryBuilder -> getQuery ( ) ; }
Get Doctrine Query
23,070
public function query ( $ name , $ parameters = [ ] ) { if ( ! isset ( $ parameters [ 'APPID' ] ) ) { $ parameters [ 'APPID' ] = $ this -> apiKey ; } if ( ! isset ( $ parameters [ 'units' ] ) ) { $ parameters [ 'units' ] = $ this -> units ; } if ( ! isset ( $ parameters [ 'lang' ] ) ) { $ parameters [ 'lang' ] = $ this -> lang ; } $ baseUrl = $ this -> apiUrl . $ name ; $ requestQueryParts = [ ] ; foreach ( $ parameters as $ key => $ value ) { $ requestQueryParts [ ] = $ key . '=' . rawurlencode ( $ value ) ; } $ baseUrl .= '?' . implode ( '&' , $ requestQueryParts ) ; $ response = $ this -> guzzleClient -> get ( $ baseUrl ) ; $ response = json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; return $ response ; }
Performs a query to the OpenWeatherMap API .
23,071
public function getForecast ( $ city , $ days = null , $ parameters = [ ] ) { if ( $ days ) { if ( ! empty ( $ parameters ) ) { $ parameters [ 'cnt' ] = $ days ; } else { $ parameters = [ 'cnt' => $ days ] ; } } return $ this -> doGenericQuery ( 'forecast/daily' , $ city , $ parameters ) ; }
Returns the forecast for a city .
23,072
public function post ( $ uri , $ callback , $ acceptedFormats = null ) { parent :: addRoute ( 'POST' , $ uri , $ callback , $ acceptedFormats ) ; }
Add a new POST route for the application . The POST method must be used to create a new entry in a collection . Rarely used on a specific resource .
23,073
public static function parseFontAwesomeIcon ( array $ args ) { $ icon = static :: newFontAwesomeIcon ( ) ; $ icon -> setName ( ArrayHelper :: get ( $ args , "name" , "home" ) ) ; $ icon -> setStyle ( ArrayHelper :: get ( $ args , "style" ) ) ; $ icon -> setAnimation ( ArrayHelper :: get ( $ args , "animation" ) ) ; $ icon -> setBordered ( ArrayHelper :: get ( $ args , "bordered" , false ) ) ; $ icon -> setFixedWidth ( ArrayHelper :: get ( $ args , "fixedWidth" , false ) ) ; $ icon -> setFont ( ArrayHelper :: get ( $ args , "font" ) ) ; $ icon -> setPull ( ArrayHelper :: get ( $ args , "pull" ) ) ; $ icon -> setSize ( ArrayHelper :: get ( $ args , "size" ) ) ; return $ icon ; }
Parses a Font Awesome icon .
23,074
public static function parseMaterialDesignIconicFontIcon ( array $ args ) { $ icon = static :: newMaterialDesignIconicFontIcon ( ) ; $ icon -> setName ( ArrayHelper :: get ( $ args , "name" , "home" ) ) ; $ icon -> setStyle ( ArrayHelper :: get ( $ args , "style" ) ) ; $ icon -> setBorder ( ArrayHelper :: get ( $ args , "border" , false ) ) ; $ icon -> setFixedWidth ( ArrayHelper :: get ( $ args , "fixedWidth" , false ) ) ; $ icon -> setFlip ( ArrayHelper :: get ( $ args , "flip" ) ) ; $ icon -> setPull ( ArrayHelper :: get ( $ args , "pull" ) ) ; $ icon -> setRotate ( ArrayHelper :: get ( $ args , "rotate" ) ) ; $ icon -> setSize ( ArrayHelper :: get ( $ args , "size" ) ) ; $ icon -> setSpin ( ArrayHelper :: get ( $ args , "spin" ) ) ; return $ icon ; }
Parses a Material Design Iconic Font icon .
23,075
public function renderInstance ( $ instanceId , $ instanceConfig ) { $ view = new ViewModel ( [ 'instanceId' => $ instanceId , 'instanceConfig' => $ instanceConfig , 'config' => $ this -> config , ] ) ; $ view -> setTemplate ( $ this -> template ) ; return $ view ; }
Reads a plugin instance from persistent storage returns a view model for it
23,076
public function postIsForThisPlugin ( ) { if ( ! $ this -> getRequest ( ) -> isPost ( ) ) { return false ; } return $ this -> getRequest ( ) -> getPost ( 'rcmPluginName' ) == $ this -> pluginName ; }
Is the post for this plugin
23,077
public function findUserByForgetPasswordToken ( $ token ) { try { $ builder = $ this -> createQueryBuilder ( 'u' ) ; return $ builder -> where ( $ builder -> expr ( ) -> eq ( 'u.forgetPasswordToken' , ':token' ) ) -> andWhere ( $ builder -> expr ( ) -> isNotNull ( 'u.forgetPasswordExpired' ) ) -> andWhere ( 'u.forgetPasswordExpired >= :today' ) -> setParameter ( 'token' , $ token ) -> setParameter ( 'today' , new \ DateTime ( ) , Type :: DATETIME ) -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ ex ) { return null ; } catch ( NonUniqueResultException $ ex ) { throw new ProgrammerException ( 'Duplicate Forget Password Token was found.' , ProgrammerException :: FORGET_PASSWORD_TOKEN_DUPLICATE_EXCEPTION_CODE ) ; } }
Returns a user with the right password token . If multiple tokens are found in the db a programmer exception is thrown with a specific code .
23,078
public function searchUsers ( $ searchString = null , $ page , $ limit ) { return $ this -> buildUserSearchQuery ( $ searchString ) -> getQuery ( ) -> setMaxResults ( $ limit ) -> setFirstResult ( $ limit * ( $ page - 1 ) ) -> getResult ( ) ; }
Gets a paginated list of users
23,079
public function countNumberOfUserInSearch ( $ searchString = null ) { $ builder = $ this -> buildUserSearchQuery ( $ searchString ) ; return $ builder -> select ( $ builder -> expr ( ) -> count ( 'u.id' ) ) -> getQuery ( ) -> getSingleScalarResult ( ) ; }
Counts the number of users in the search
23,080
public function findUserByValidRefreshToken ( $ token ) { $ user = $ this -> findOneBy ( [ 'refreshToken' => $ token ] ) ; if ( ! empty ( $ user ) && $ user -> isRefreshTokenValid ( ) ) { return $ user ; } return null ; }
Finds a user by refresh token that is not expired
23,081
public function save ( ) { event ( new BeforeSave ( $ this ) ) ; $ this -> beforeSave ( ) ; $ this -> doSave ( ) ; $ this -> afterSave ( ) ; event ( new AfterSave ( $ this ) ) ; }
Save Action .
23,082
protected function afterSave ( ) { $ this -> brokenAfterSave = false ; foreach ( \ Request :: except ( '_token' ) as $ key => $ value ) { if ( method_exists ( $ this -> model , $ key ) && is_a ( call_user_func_array ( [ $ this -> model , $ key ] , [ ] ) , 'Illuminate\Database\Eloquent\Relations\Relation' ) ) { $ this -> saveRelation ( 'afterSave' , $ key , $ value ) ; } } }
Method fired after the Save action is complete .
23,083
private function saveRelation ( $ action , $ key , $ value ) { if ( method_exists ( $ this -> model , $ key ) && is_a ( call_user_func_array ( [ $ this -> model , $ key ] , [ ] ) , 'Illuminate\Database\Eloquent\Relations\Relation' ) ) { foreach ( $ this -> { $ action . 'Relations' } as $ relationship => $ method ) { if ( is_a ( call_user_func_array ( [ $ this -> model , $ key ] , [ ] ) , 'Illuminate\Database\Eloquent\Relations\\' . $ relationship ) ) { $ this -> model -> $ key ( ) -> $ method ( $ value ) ; return ; } } } }
Method fired to Save Relations .
23,084
protected function storeCallback ( \ Closure $ callback ) { $ key = md5 ( microtime ( ) ) ; $ this -> callbacks [ $ key ] = $ callback ; return $ key ; }
Store a callback index by a generated key
23,085
protected function pushToQueue ( $ event , $ key , $ priority ) { $ end = substr ( $ event , - 2 ) ; if ( isset ( $ this -> queues [ $ event ] ) ) { if ( $ end == self :: WILDCARD ) { $ this -> wildcardSearching = true ; $ this -> queues [ $ event ] [ ] = [ 'key' => $ key , 'priority' => $ priority ] ; } else { $ this -> queues [ $ event ] -> insert ( $ key , $ priority ) ; } } else { if ( $ end == self :: WILDCARD ) { $ this -> wildcardSearching = true ; $ this -> queues [ $ event ] [ ] = [ 'key' => $ key , 'priority' => $ priority ] ; } else { $ this -> queues [ $ event ] = new PriorityQueue ; $ this -> queues [ $ event ] -> insert ( $ key , $ priority ) ; } } }
Store a callback s key and priority in a queue indexed by the event they are attached to .
23,086
public function remove ( $ name ) { if ( isset ( $ this -> queues [ $ name ] ) ) { unset ( $ this -> queues [ $ name ] ) ; } return $ this ; }
Remove event listeners from a particular index .
23,087
public function getListeners ( $ name ) { $ listenerMatched = false ; if ( isset ( $ this -> queues [ $ name ] ) ) { $ listenerMatched = true ; } if ( $ this -> wildcardSearching ) { if ( $ this -> populateQueueFromWildSearch ( $ name ) ) { $ listenerMatched = true ; } } $ listeners = [ ] ; if ( $ listenerMatched ) { foreach ( $ this -> queues [ $ name ] as $ key ) { $ listeners [ ] = $ this -> callbacks [ $ key ] ; } } return $ listeners ; }
Retrieve listeners by name
23,088
public function attach ( $ name , \ Closure $ callback , $ priority = 0 ) { $ key = $ this -> storeCallback ( $ callback ) ; if ( is_array ( $ name ) ) { foreach ( $ name as $ event ) { $ this -> pushToQueue ( $ event , $ key , $ priority ) ; } } else { $ this -> pushToQueue ( $ name , $ key , $ priority ) ; } return $ this ; }
Register a listener attached to a particular named event .
23,089
public function process ( ServerRequestInterface $ request , DelegateInterface $ delegate ) { $ contentType = $ request -> getHeaderLine ( 'Content-Type' ) ; if ( ! $ this -> match ( $ contentType ) ) { return $ delegate -> process ( $ request ) ; } $ rawBody = ( string ) $ request -> getBody ( ) ; $ parsedBody = json_decode ( $ rawBody , true ) ; if ( ! empty ( $ rawBody ) && json_last_error ( ) !== JSON_ERROR_NONE ) { $ statusCode = 400 ; $ apiMessage = new HttpStatusCodeApiMessage ( $ statusCode ) ; $ apiMessage -> setCode ( 'invalid-json' ) ; $ apiMessage -> setValue ( 'Invalid JSON' ) ; $ apiResponse = $ this -> newPsrResponseWithTranslatedMessages -> __invoke ( null , $ statusCode , $ apiMessage ) ; return $ apiResponse ; } $ request = $ request -> withAttribute ( 'rawBody' , $ rawBody ) -> withParsedBody ( $ parsedBody ) ; return $ delegate -> process ( $ request ) ; }
Adds JSON decoded request body to the request where appropriate .
23,090
public function renderContainer ( PhpRenderer $ view , $ name , $ revisionId = null ) { $ site = $ this -> getSite ( $ view ) ; $ container = $ site -> getContainer ( $ name ) ; $ pluginHtml = '' ; if ( ! empty ( $ container ) ) { if ( empty ( $ revisionId ) ) { $ revision = $ container -> getPublishedRevision ( ) ; } else { $ revision = $ container -> getRevisionById ( $ revisionId ) ; } $ pluginWrapperRows = $ revision -> getPluginWrappersByRow ( ) ; if ( ! empty ( $ pluginWrapperRows ) ) { $ pluginHtml = $ this -> getPluginRowsHtml ( $ view , $ pluginWrapperRows ) ; } $ revisionId = $ revision -> getRevisionId ( ) ; } else { $ revisionId = - 1 ; } if ( empty ( $ pluginHtml ) ) { $ pluginHtml .= '<div class="row"></div>' ; } return $ this -> getContainerWrapperHtml ( $ revisionId , $ name , $ pluginHtml , false ) ; }
Render a plugin container
23,091
protected function isDuplicateCss ( PhpRenderer $ view , $ container ) { $ headLink = $ view -> headLink ( ) ; $ containers = $ headLink -> getContainer ( ) ; foreach ( $ containers as & $ item ) { if ( ( $ item -> rel == 'stylesheet' ) && ( $ item -> href == $ container -> href ) ) { return true ; } } return false ; }
Check to see if CSS is duplicated
23,092
protected function isDuplicateScript ( PhpRenderer $ view , $ container ) { $ headScript = $ view -> headScript ( ) ; $ container = $ headScript -> getContainer ( ) ; foreach ( $ container as & $ item ) { if ( ( $ item -> source === null ) && ! empty ( $ item -> attributes [ 'src' ] ) && ! empty ( $ container -> attributes [ 'src' ] ) && ( $ container -> attributes [ 'src' ] == $ item -> attributes [ 'src' ] ) ) { return true ; } } return false ; }
Check to see if Scripts are duplicated
23,093
public function registerError ( $ level , callable $ callback ) { $ reflection = new \ ReflectionFunction ( $ callback ) ; $ parameters = $ reflection -> getParameters ( ) ; if ( count ( $ parameters ) > 4 ) { throw new \ Exception ( "Specified callback cannot have more than 4 arguments (message, file, line, context)" ) ; } $ this -> registeredErrorCallbacks [ $ level ] = $ callback ; }
Register an error level with a specific user defined callback . The specified callback can have up to 4 arguments but they are not required . First provided argument is the message second is the file path third is the line number and the fourth is an error context .
23,094
public function exceptionHandler ( \ Throwable $ error ) { $ reflection = new \ ReflectionClass ( $ error ) ; $ registeredException = $ this -> findRegisteredExceptions ( $ reflection ) ; if ( ! is_null ( $ registeredException ) ) { $ registeredException ( $ error ) ; } }
When an exception is thrown this method catches it and tries to find the best user defined callback as a response . If there is no direct callback associated it will tries to find a definition within the Exception class hierarchy . If nothing is found the default behavior is to die the script . Should not be called manually . Used as a registered PHP handler .
23,095
public function errorHandler ( $ type , ... $ args ) { if ( ! ( error_reporting ( ) & $ type ) ) { return true ; } if ( array_key_exists ( $ type , $ this -> registeredErrorCallbacks ) ) { $ callback = $ this -> registeredErrorCallbacks [ $ type ] ; $ reflection = new \ ReflectionFunction ( $ callback ) ; $ reflection -> invokeArgs ( $ args ) ; return true ; } return false ; }
When an error a notice or a warning is thrown this method catches it and tries to find the a user defined callback matching the PHP internal error type . Will validate if the raised error type is included in the error_reporting config . Should not be called manually . Used as a registered PHP handler .
23,096
protected function initialize ( Request $ request , ParamConverter $ configuration ) : void { $ this -> request = $ request ; $ this -> configuration = $ configuration ; $ this -> options = new ParameterBag ( $ configuration -> getOptions ( ) ) ; }
Set request and configuration context as class properties for easy access .
23,097
public function next ( $ fetchStyle = \ PDO :: FETCH_BOTH ) { $ row = $ this -> statement -> fetch ( $ fetchStyle ) ; $ this -> sanitizeOutput ( $ row ) ; return $ row ; }
Return the next row from the current result set obtained from the last executed query . Automatically strip slashes that would have been stored in database as escaping .
23,098
public function loadUserByUsername ( $ username ) { try { $ response = $ this -> facebookClient -> get ( '/me?fields=email' , $ username ) ; $ facebookUser = $ response -> getGraphUser ( ) ; $ email = $ facebookUser -> getEmail ( ) ; $ facebookUserId = $ facebookUser -> getId ( ) ; $ user = $ this -> userService -> findByFacebookUserId ( $ facebookUserId ) ; if ( ! empty ( $ user ) ) { return $ user ; } $ user = $ this -> userService -> findUserByEmail ( $ email ) ; if ( ! empty ( $ user ) ) { $ this -> updateUserWithFacebookId ( $ user , $ facebookUserId ) ; return $ user ; } return $ this -> registerUser ( $ email , $ facebookUserId ) ; } catch ( FacebookResponseException $ ex ) { throw new UsernameNotFoundException ( "Facebook AuthToken Did Not validate, ERROR MESSAGE " . $ ex -> getMessage ( ) , ProgrammerException :: FACEBOOK_RESPONSE_EXCEPTION_CODE ) ; } catch ( FacebookSDKException $ ex ) { throw new UsernameNotFoundException ( "Facebook SDK failed, ERROR MESSAGE " . $ ex -> getMessage ( ) , ProgrammerException :: FACEBOOK_SDK_EXCEPTION_CODE ) ; } catch ( \ Exception $ ex ) { throw new UsernameNotFoundException ( "Something unknown went wrong, ERROR MESSAGE " . $ ex -> getMessage ( ) , ProgrammerException :: FACEBOOK_PROVIDER_EXCEPTION ) ; } }
1 ) We validate the access token by fetching the user information 2 ) We search for facebook user id and if one is found we return that user 3 ) Then we search by email and if one is found we update the user to have that facebook user id 4 ) If nothing is found we register the user with facebook user id
23,099
protected function updateUserWithFacebookId ( BaseUser $ user , $ facebookUserId ) { $ user -> setFacebookUserId ( $ facebookUserId ) ; $ this -> userService -> save ( $ user ) ; }
Updates the user with their facebook id creating a link between their facebook account and user information .