idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
24,700
public function put ( string $ path , $ body ) : HttpResponse { return $ this -> request ( $ path , HttpMethod :: PUT , $ body ) ; }
Executes the HttpRequest as a PUT request to the specified path with the provided body
24,701
public function post ( string $ path , $ body ) : HttpResponse { return $ this -> request ( $ path , HttpMethod :: POST , $ body ) ; }
Executes the HttpRequest as a POST request to the specified path with the provided body
24,702
public function delete ( string $ path , $ body ) : HttpResponse { return $ this -> request ( $ path , HttpMethod :: DELETE , $ body ) ; }
Executes the HttpRequest as a DELETE request to the specified path with the provided body
24,703
private function request ( string $ path , string $ method , $ body = null ) : HttpResponse { $ ch = curl_init ( ) ; $ this -> processUrl ( $ path , $ ch ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ method ) ; $ this -> processBody ( $ ch , $ body ) ; $ this -> processHeaders ( $ ch ) ; $ this -> processCookies ( $ ch ) ; return $ this -> send ( $ ch ) ; }
Constructs the HTTP request and sends it using the provided method and request body
24,704
private function send ( $ ch ) : HttpResponse { $ returnHeaders = array ( ) ; curl_setopt ( $ ch , CURLOPT_HEADERFUNCTION , function ( $ curl , $ header ) use ( & $ returnHeaders ) { if ( strpos ( $ header , ':' ) !== false ) { list ( $ name , $ value ) = explode ( ':' , $ header ) ; if ( ! array_key_exists ( $ name , $ returnHeaders ) ) { $ returnHeaders [ $ name ] = array ( ) ; } $ returnHeaders [ $ name ] [ ] = trim ( $ value ) ; } return strlen ( $ header ) ; } ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ ch , CURLOPT_HEADER , true ) ; curl_setopt ( $ ch , CURLOPT_CONNECTTIMEOUT , $ this -> timeout ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , $ this -> verifySslCertificate ) ; if ( ! empty ( $ this -> username ) ) { curl_setopt ( $ ch , CURLOPT_HTTPAUTH , CURLAUTH_BASIC ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , "$this->username:$this->password" ) ; } $ response = curl_exec ( $ ch ) ; $ requestInfo = curl_getinfo ( $ ch ) ; $ error = curl_error ( $ ch ) ; if ( ! empty ( $ error ) ) { throw new HttpRequestException ( $ error ) ; } $ httpResponse = new HttpResponse ( $ requestInfo , $ returnHeaders , $ response , $ error ) ; return $ httpResponse ; }
Sends the constructed request
24,705
protected static function construct ( ExecutionContext $ exeContext = null ) : Executor { $ executorReflection = new \ ReflectionClass ( Executor :: class ) ; $ executor = $ executorReflection -> newInstanceWithoutConstructor ( ) ; if ( $ exeContext !== null ) { $ constructor = $ executorReflection -> getConstructor ( ) ; $ constructor -> setAccessible ( true ) ; $ constructor -> invoke ( $ executor , $ exeContext ) ; } return $ executor ; }
Some crazy stuff to work around a private constructor
24,706
public function escape ( $ val ) { if ( $ this -> db === null ) $ this -> connect ( ) ; return $ this -> db -> quote ( $ val ) ; }
Escape a Value
24,707
public function add ( SourceTypeInterface $ type , $ alias ) { if ( $ alias !== $ type -> getName ( ) ) { throw new SourceTypeException ( sprintf ( 'Mapper source type %s alias is not valid!' , $ alias ) ) ; } $ this -> types [ $ alias ] = $ type ; }
Add mapper source type .
24,708
public function getType ( $ name ) { if ( isset ( $ this -> types [ $ name ] ) ) { return $ this -> types [ $ name ] ; } throw new SourceTypeException ( sprintf ( 'Mapper source type %s not found!' , $ name ) ) ; }
Get mapper source type by name .
24,709
public function Bcc ( $ RecipientEmail , $ RecipientName = '' ) { ob_start ( ) ; $ this -> PhpMailer -> AddBCC ( $ RecipientEmail , $ RecipientName ) ; ob_end_clean ( ) ; return $ this ; }
Adds to the Bcc recipient collection .
24,710
public function Cc ( $ RecipientEmail , $ RecipientName = '' ) { ob_start ( ) ; $ this -> PhpMailer -> AddCC ( $ RecipientEmail , $ RecipientName ) ; ob_end_clean ( ) ; return $ this ; }
Adds to the Cc recipient collection .
24,711
public function Clear ( ) { $ this -> PhpMailer -> ClearAllRecipients ( ) ; $ this -> PhpMailer -> Body = '' ; $ this -> PhpMailer -> AltBody = '' ; $ this -> From ( ) ; $ this -> _IsToSet = FALSE ; $ this -> MimeType ( C ( 'Garden.Email.MimeType' , 'text/plain' ) ) ; $ this -> _MasterView = 'email.master' ; $ this -> Skipped = array ( ) ; return $ this ; }
Clears out all previously specified values for this object and restores it to the state it was in when it was instantiated .
24,712
public function From ( $ SenderEmail = '' , $ SenderName = '' , $ bOverrideSender = FALSE ) { if ( $ SenderEmail == '' ) { $ SenderEmail = C ( 'Garden.Email.SupportAddress' , '' ) ; if ( ! $ SenderEmail ) { $ SenderEmail = 'noreply@' . Gdn :: Request ( ) -> Host ( ) ; } } if ( $ SenderName == '' ) $ SenderName = C ( 'Garden.Email.SupportName' , C ( 'Garden.Title' , '' ) ) ; if ( $ this -> PhpMailer -> Sender == '' || $ bOverrideSender ) $ this -> PhpMailer -> Sender = $ SenderEmail ; ob_start ( ) ; $ this -> PhpMailer -> SetFrom ( $ SenderEmail , $ SenderName , FALSE ) ; ob_end_clean ( ) ; return $ this ; }
Allows the explicit definition of the email s sender address & name . Defaults to the applications Configuration SupportEmail & SupportName settings respectively .
24,713
public function Message ( $ Message ) { if ( $ this -> PhpMailer -> ContentType == 'text/html' ) { $ TextVersion = FALSE ; if ( stristr ( $ Message , '<!-- //TEXT VERSION FOLLOWS//' ) ) { $ EmailParts = explode ( '<!-- //TEXT VERSION FOLLOWS//' , $ Message ) ; $ TextVersion = array_pop ( $ EmailParts ) ; $ Message = array_shift ( $ EmailParts ) ; $ TextVersion = trim ( strip_tags ( preg_replace ( '/<(head|title|style|script)[^>]*>.*?<\/\\1>/s' , '' , $ TextVersion ) ) ) ; $ Message = trim ( $ Message ) ; } $ this -> PhpMailer -> MsgHTML ( htmlspecialchars_decode ( $ Message , ENT_QUOTES ) ) ; if ( $ TextVersion !== FALSE && ! empty ( $ TextVersion ) ) { $ TextVersion = html_entity_decode ( $ TextVersion ) ; $ this -> PhpMailer -> AltBody = $ TextVersion ; } } else { $ this -> PhpMailer -> Body = htmlspecialchars_decode ( $ Message , ENT_QUOTES ) ; } return $ this ; }
The message to be sent .
24,714
public function To ( $ RecipientEmail , $ RecipientName = '' ) { if ( is_string ( $ RecipientEmail ) ) { if ( strpos ( $ RecipientEmail , ',' ) > 0 ) { $ RecipientEmail = explode ( ',' , $ RecipientEmail ) ; return $ this -> To ( $ RecipientEmail , $ RecipientName ) ; } if ( $ this -> PhpMailer -> SingleTo ) return $ this -> AddTo ( $ RecipientEmail , $ RecipientName ) ; if ( ! $ this -> _IsToSet ) { $ this -> _IsToSet = TRUE ; $ this -> AddTo ( $ RecipientEmail , $ RecipientName ) ; } else $ this -> Cc ( $ RecipientEmail , $ RecipientName ) ; return $ this ; } elseif ( ( is_object ( $ RecipientEmail ) && property_exists ( $ RecipientEmail , 'Email' ) ) || ( is_array ( $ RecipientEmail ) && isset ( $ RecipientEmail [ 'Email' ] ) ) ) { $ User = $ RecipientEmail ; $ RecipientName = GetValue ( 'Name' , $ User ) ; $ RecipientEmail = GetValue ( 'Email' , $ User ) ; $ UserID = GetValue ( 'UserID' , $ User , FALSE ) ; if ( $ UserID !== FALSE ) { if ( ! Gdn :: UserModel ( ) -> CheckPermission ( $ UserID , 'Garden.Email.View' ) ) { $ this -> Skipped [ ] = $ User ; return $ this ; } } return $ this -> To ( $ RecipientEmail , $ RecipientName ) ; } elseif ( $ RecipientEmail instanceof Gdn_DataSet ) { foreach ( $ RecipientEmail -> ResultObject ( ) as $ Object ) $ this -> To ( $ Object ) ; return $ this ; } elseif ( is_array ( $ RecipientEmail ) ) { $ Count = count ( $ RecipientEmail ) ; if ( ! is_array ( $ RecipientName ) ) $ RecipientName = array_fill ( 0 , $ Count , '' ) ; if ( $ Count == count ( $ RecipientName ) ) { $ RecipientEmail = array_combine ( $ RecipientEmail , $ RecipientName ) ; foreach ( $ RecipientEmail as $ Email => $ Name ) $ this -> To ( $ Email , $ Name ) ; } else trigger_error ( ErrorMessage ( 'Size of arrays do not match' , 'Email' , 'To' ) , E_USER_ERROR ) ; return $ this ; } trigger_error ( ErrorMessage ( 'Incorrect first parameter (' . GetType ( $ RecipientEmail ) . ') passed to function.' , 'Email' , 'To' ) , E_USER_ERROR ) ; }
Adds to the To recipient collection .
24,715
public function execute ( string $ event ) { foreach ( $ this -> members as $ member ) { if ( $ member -> getEvent ( ) === $ event ) { $ member -> execute ( ) ; } } }
Loop through and execute each member of the collection
24,716
public function loadAll ( $ prefix = '' ) { foreach ( $ this -> _files as $ section => $ file ) { if ( strlen ( $ prefix ) == 0 || $ prefix == $ section || ( strlen ( $ section ) > strlen ( $ prefix ) && substr ( $ section , 0 , strlen ( $ prefix ) ) == $ prefix ) || ( strlen ( $ section ) < strlen ( $ prefix ) && substr ( $ prefix , 0 , strlen ( $ section ) ) == $ section ) ) { $ this -> _loadFile ( $ file ) ; unset ( $ this -> _files [ $ section ] ) ; } } }
Load all locale files
24,717
public function execute ( Framework $ framework , WebRequest $ request , Response $ response ) { if ( $ request -> hasSession ( ) ) { $ profileMenuEntry = new \ Zepi \ Web \ General \ Entity \ MenuEntry ( 'profile' , $ this -> translate ( 'Profile' , '\\Zepi\\Web\\AccessControl' ) , 'profile' , 'mdi-person' ) ; $ this -> getMenuManager ( ) -> addMenuEntry ( 'menu-right' , $ profileMenuEntry , 90 ) ; $ userSettingsSubMenuEntry = new \ Zepi \ Web \ General \ Entity \ HiddenMenuEntry ( $ this -> translate ( 'User settings' , '\\Zepi\\Web\\AccessControl' ) ) ; $ profileMenuEntry -> addChild ( $ userSettingsSubMenuEntry ) ; $ changePasswordSubMenuEntry = new \ Zepi \ Web \ General \ Entity \ HiddenMenuEntry ( $ this -> translate ( 'Change password' , '\\Zepi\\Web\\AccessControl' ) , 'profile/change-password' , 'mdi-vpn-key' ) ; $ userSettingsSubMenuEntry -> addChild ( $ changePasswordSubMenuEntry ) ; $ menuEntry = new \ Zepi \ Web \ General \ Entity \ MenuEntry ( 'logout' , $ this -> translate ( 'Logout' , '\\Zepi\\Web\\AccessControl' ) , 'logout' , 'glyphicon-log-out' ) ; $ this -> getMenuManager ( ) -> addMenuEntry ( 'menu-right' , $ menuEntry , 100 ) ; } else { if ( $ this -> getSetting ( 'accesscontrol.allowRegistration' ) ) { $ menuEntry = new \ Zepi \ Web \ General \ Entity \ MenuEntry ( 'registration' , $ this -> translate ( 'Registration' , '\\Pmx\\Autopilot\\AccessControl' ) , '/register/' , 'mdi-account-circle' ) ; $ this -> getMenuManager ( ) -> addMenuEntry ( 'menu-right' , $ menuEntry ) ; } $ menuEntry = new \ Zepi \ Web \ General \ Entity \ MenuEntry ( 'login' , $ this -> translate ( 'Login' , '\\Zepi\\Web\\AccessControl' ) , 'login' , 'glyphicon-log-in' ) ; $ this -> getMenuManager ( ) -> addMenuEntry ( 'menu-right' , $ menuEntry , 100 ) ; } }
Registers the menu entries which are only accessable if the user is logged in or not logged in in example login or logout menu entry .
24,718
protected function retrieve ( $ url ) { if ( $ this -> curlWrapper -> error ) { throw new StarcraftConnectionLayerException ( $ this -> curlWrapper -> error_message , $ this -> curlWrapper -> error_code ) ; } }
Method that allows for easy retrieval of data from a URL and triggers a certain type of exception when something goes wrong .
24,719
public static function groupByPropertiesNames ( GroupData $ groupData ) { self :: $ data = $ groupData -> getData ( ) ; self :: $ groupProperties = $ groupData -> getGroupProperties ( ) ; self :: $ groupCriteriaHigherLevel = $ groupData -> getGroupCriteriaHigherLevel ( ) ; self :: $ quantityPropertyName = $ groupData -> getQuantityPropertyName ( ) ; self :: $ groupResultType = $ groupData -> getGroupResultType ( ) ; if ( ! is_null ( $ groupData -> getMostFrequentQuantity ( ) ) ) { self :: $ mostFrequentQuantity = $ groupData -> getMostFrequentQuantity ( ) ; } self :: prepareKeeper ( ) ; self :: removeRedundantProperties ( ) ; foreach ( self :: $ data as $ basicKey => $ item ) { if ( ! ( $ item instanceof \ StdClass ) ) { throw new GroupException ( "Can't group. Not StdClass in \$item" ) ; } self :: group ( $ basicKey , $ item ) ; } switch ( self :: $ groupResultType ) : case ( GroupConsts :: RESULT_GROUP_SORT_DATA ) : $ result = self :: getMostFrequentValuesForGrouped ( self :: $ groupKeeper ) ; break ; case ( GroupConsts :: RESULT_GROUP_STRING ) : $ result = self :: $ groupKeeper ; break ; endswitch ; return $ result ; }
Allow to group data with same properties by properties names .
24,720
protected function writeToFile ( array $ translations ) : void { $ excel = app ( 'excel' ) ; $ filename = config ( 'netcore.module-translate.translations_file' ) ; $ excel -> create ( $ filename , function ( LaravelExcelWriter $ writer ) use ( $ translations ) { $ writer -> setTitle ( 'Translations' ) ; $ writer -> sheet ( 'Translations' , function ( LaravelExcelWorksheet $ sheet ) use ( $ translations ) { $ sheet -> fromArray ( $ translations , '' , 'A1' ) ; $ sheet -> row ( 1 , function ( $ row ) { $ row -> setFontWeight ( 'bold' ) ; } ) ; } ) ; } ) -> store ( 'xlsx' , resource_path ( 'seed_translations' ) ) ; }
Write translations to the file .
24,721
protected function makeRows ( $ group , $ key , $ value ) : array { $ rows = [ ] ; if ( is_array ( $ value ) ) { foreach ( $ value as $ subKey => $ subValue ) { $ rows [ ] = [ 'key' => $ group . '.' . $ key . '.' . $ subKey , 'value' => $ subValue , ] ; } } else { $ rows [ ] = [ 'key' => $ group . '.' . $ key , 'value' => $ value , ] ; } return $ rows ; }
Create translations from array .
24,722
protected function getPaths ( ) : array { $ paths = [ base_path ( 'app' ) , base_path ( 'modules' ) , base_path ( 'resources' ) , base_path ( 'routes' ) , ] ; foreach ( $ paths as $ i => $ path ) { if ( ! File :: isDirectory ( $ path ) ) { unset ( $ paths [ $ i ] ) ; } } return $ paths ; }
Get paths in which to search for translations .
24,723
protected function storeEntity ( ) { $ request = $ this -> getRequest ( ) ; $ id = $ request -> getParameter ( 'id' ) ; $ entity = NULL ; try { $ entity = $ this -> getFactory ( ) -> findEntity ( $ id ) ; } catch ( NotFoundException $ exception ) { $ className = $ this -> getFactory ( ) -> getEntitiesClassName ( ) ; $ entity = new $ className ( array ( 'id' => $ id , ) ) ; } $ dataFromRequest = $ this -> getEntityDataFromRequest ( ) ; if ( $ this -> nullsIgnoredOnStore ) { $ dataFromRequest = array_filter ( $ dataFromRequest , function ( $ value ) { return ! is_null ( $ value ) ; } ) ; } $ entity -> update ( $ dataFromRequest ) ; $ entity -> store ( ) ; return $ entity ; }
Updates the entity with the new data in the request and stores it .
24,724
public function getEntityData ( ) { $ entity = null ; try { $ entity = $ this -> getEntity ( $ this -> getRequest ( ) -> getParameter ( 'id' ) ) ; } catch ( NotFoundException $ exception ) { $ entity = $ this -> getEntityClass ( ) -> newInstanceArgs ( $ this -> getEntityDataFromRequest ( ) ) ; } return $ entity -> getFieldsData ( ) ; }
Gets the current entity s data so that it can be set into the request .
24,725
protected function getBatchActionConfirmationResponse ( $ actionId , array $ selectedIds ) { $ response = null ; if ( empty ( $ selectedIds ) ) { $ response = $ this -> getIndexRedirectionResponse ( ) ; } else { $ response = $ this -> getHtmlResponse ( ) ; $ collectionName = $ this -> getCollectionName ( ) ; $ response -> setTemplateId ( sprintf ( '%s/%s' , $ collectionName , $ actionId ) ) ; $ response -> setData ( $ collectionName , $ selectedIds ) ; } return $ response ; }
Returns a response which displays a confirmation page for a batch process .
24,726
protected function getBatchActionResponse ( $ actionFunction , array $ selectedIds ) { $ response = $ this -> getIndexRedirectionResponse ( ) ; $ successfullyUsedIds = array ( ) ; foreach ( $ selectedIds as $ id ) { try { call_user_func ( $ actionFunction , $ id ) ; $ successfullyUsedIds [ ] = $ id ; } catch ( NotFoundException $ exception ) { $ response -> addErrorMessage ( sprintf ( _ ( '%s %s was not found.' ) , _ ( $ this -> getItemName ( ) ) , $ id ) ) ; } } $ response -> addNotice ( sprintf ( _ ( '%d %s were affected.' ) , count ( $ successfullyUsedIds ) , _ ( $ this -> getCollectionName ( ) ) ) ) ; return $ response ; }
Issue a response to a batch action request .
24,727
private function getIndexRedirectionResponse ( ) { $ response = new Redirection ( $ this -> getRequest ( ) ) ; $ url = sprintf ( '/%s/' , $ this -> getCollectionName ( ) ) ; $ view = $ this -> getRequest ( ) -> getParameter ( 'view' ) ; if ( ! empty ( $ view ) ) { $ url .= '?view=' . $ view ; } $ response -> setNextUrl ( $ url ) ; return $ response ; }
Gets a redirection to the collection s index page honouring the current view .
24,728
protected function getEditionResponse ( Entity $ entity = null ) { $ response = $ this -> getHtmlResponse ( ) ; $ response -> setTemplateId ( sprintf ( '%s/edit' , $ this -> getCollectionName ( ) ) ) ; if ( $ entity ) { $ response -> setData ( $ this -> getItemName ( ) , $ entity -> getFieldsData ( ) ) ; } return $ response ; }
Return a response that shows an edition page .
24,729
private function getUpdatedEntityResponse ( ) { $ response = $ this -> getEditionResponse ( ) ; try { $ this -> storeEntity ( ) ; $ response -> addNotice ( sprintf ( _ ( '%s correctly stored.' ) , ucfirst ( $ this -> getItemName ( ) ) ) ) ; } catch ( ValidatorException $ exception ) { $ response -> addErrorMessage ( array ( 'validation' => $ exception -> getValidationStatus ( ) , ) ) ; } catch ( \ Exception $ exception ) { $ response -> addErrorMessage ( $ exception -> getMessage ( ) ) ; } $ response -> setData ( $ this -> getItemName ( ) , $ this -> getEntityData ( ) ) ; return $ response ; }
Updates an entity with the data in the request and emits a response to attest for that .
24,730
protected function getSelectedIds ( ) { $ ids = array ( ) ; foreach ( $ _REQUEST as $ parameter => $ value ) { $ matches = array ( ) ; preg_match ( '/select_(.*)/' , $ parameter , $ matches ) ; if ( $ matches ) { $ ids [ ] = $ matches [ 1 ] ; } } return $ ids ; }
Find the IDs of the selected elements in a list .
24,731
public function setServiceContainer ( $ value = \ null ) : ContainerMediatorInterface { if ( \ null === $ value ) { $ value = new Container ( ) ; } if ( ! $ value instanceof Container ) { $ mess = \ sprintf ( 'Must be an instance of Pimple Container but given %s' , \ gettype ( $ value ) ) ; throw new \ InvalidArgumentException ( $ mess ) ; } $ this -> serviceContainer = $ value ; return $ this ; }
This is used to bring in the service container that will be used .
24,732
public function listResources ( ) { $ list = [ ] ; $ path = $ this -> getPath ( ) . "resources" ; if ( file_exists ( $ path ) ) { $ scan = @ scandir ( $ path ) ; if ( ! $ scan ) { throw new ReadException ( "Cannot ready resources directory for the '" . get_class ( $ this ) . "' module" ) ; } $ path .= DIRECTORY_SEPARATOR ; foreach ( $ scan as $ file ) { if ( $ file [ 0 ] !== "." && preg_match ( '/\.json$/' , $ file ) ) { $ list [ ] = new Resource ( $ path . $ file ) ; } } } return new Collection ( $ list ) ; }
Get all module resources
24,733
public function listAction ( Request $ request ) { $ type = $ request -> request -> get ( 'tasks' , 'involved' ) ; $ sort = $ request -> request -> get ( 'sort' , 'createdAt' ) ; $ dir = $ request -> request -> get ( 'dir' , 'DESC' ) ; $ limit = $ request -> request -> get ( 'limit' , 20 ) ; $ start = $ request -> request -> get ( 'start' , 0 ) ; $ status = [ ] ; foreach ( $ request -> request -> all ( ) as $ key => $ value ) { if ( substr ( $ key , 0 , 7 ) === 'status_' ) { $ status [ ] = substr ( $ key , 7 ) ; } } $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; if ( ! count ( $ status ) ) { $ status [ ] = current ( array_keys ( $ taskManager -> getStates ( ) ) ) ; } $ userId = $ this -> getUser ( ) -> getId ( ) ; switch ( $ type ) { case 'tasks' : $ tasks = $ taskManager -> findByCreatedByAndStatus ( $ userId , $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByCreatedByAndStatus ( $ userId , $ status ) ; break ; case 'todos' : $ tasks = $ taskManager -> findByAssignedToAndStatus ( $ userId , $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByAssignedToAndStatus ( $ userId , $ status ) ; break ; case 'involved' : $ tasks = $ taskManager -> findByInvolvementAndStatus ( $ userId , $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByInvolvementAndStatus ( $ userId , $ status ) ; break ; case 'all' : default : $ tasks = $ taskManager -> findByStatus ( $ status , [ $ sort => $ dir ] , $ limit , $ start ) ; $ total = $ taskManager -> countByStatus ( $ status ) ; break ; } $ data = [ ] ; foreach ( $ tasks as $ task ) { $ data [ ] = $ this -> serializeTask ( $ task ) ; } return new JsonResponse ( [ 'tasks' => $ data , 'total' => $ total , ] ) ; }
List tasks .
24,734
public function typesAction ( Request $ request ) { $ component = $ request -> request -> get ( 'component' ) ; $ taskTypes = $ this -> get ( 'phlexible_task.types' ) ; $ types = [ ] ; foreach ( $ taskTypes -> all ( ) as $ type ) { if ( $ component && $ type -> getComponent ( ) !== $ component ) { continue ; } $ types [ ] = [ 'id' => $ type -> getName ( ) , 'name' => $ type -> getName ( ) , ] ; } return new JsonResponse ( [ 'types' => $ types ] ) ; }
List types .
24,735
public function statusAction ( Request $ request ) { $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ states = $ taskManager -> getStates ( ) ; return new JsonResponse ( [ 'states' => $ states ] ) ; }
List status .
24,736
public function recipientsAction ( Request $ request ) { $ taskType = $ request -> get ( 'type' ) ; $ types = $ this -> get ( 'phlexible_task.types' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ authorizationChecker = $ this -> get ( 'security.authorization_checker' ) ; $ type = $ types -> get ( $ taskType ) ; $ users = [ ] ; foreach ( $ userManager -> findAll ( ) as $ user ) { if ( ! $ authorizationChecker -> isGranted ( 'ROLE_TASKS' ) ) { continue ; } if ( $ type -> getRole ( ) && ! $ authorizationChecker -> isGranted ( $ type -> getRole ( ) ) ) { continue ; } $ users [ $ user -> getDisplayName ( ) ] = [ 'uid' => $ user -> getId ( ) , 'username' => $ user -> getDisplayName ( ) , ] ; } ksort ( $ users ) ; $ users = array_values ( $ users ) ; return new JsonResponse ( [ 'users' => $ users ] ) ; }
List recipients .
24,737
public function createTaskAction ( Request $ request ) { $ typeName = $ request -> get ( 'type' ) ; $ assignedUserId = $ request -> get ( 'recipient' ) ; $ description = $ request -> get ( 'description' ) ; $ payload = $ request -> get ( 'payload' ) ; if ( $ payload ) { $ payload = json_decode ( $ payload , true ) ; } $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ types = $ this -> get ( 'phlexible_task.types' ) ; $ type = $ types -> get ( $ typeName ) ; $ assignedUser = $ userManager -> find ( $ assignedUserId ) ; $ task = $ taskManager -> createTask ( $ type , $ this -> getUser ( ) , $ assignedUser , $ payload , $ description ) ; return new ResultResponse ( true , 'Task created.' ) ; }
Create task .
24,738
public function commentAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ comment = $ request -> get ( 'comment' ) ; if ( $ comment ) { $ comment = urldecode ( $ comment ) ; } $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ task = $ taskManager -> find ( $ id ) ; $ taskManager -> updateTask ( $ task , $ this -> getUser ( ) , null , null , $ comment ) ; return new ResultResponse ( true , 'Task comment created.' , array ( 'task' => $ this -> serializeTask ( $ task ) ) ) ; }
Create task comment .
24,739
public function transitionAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ assignedUserId = $ request -> get ( 'recipient' ) ; $ name = $ request -> get ( 'name' ) ; $ comment = $ request -> get ( 'comment' ) ; if ( $ comment ) { $ comment = urldecode ( $ comment ) ; } $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ assignUser = null ; if ( $ assignedUserId ) { $ assignUser = $ userManager -> find ( $ assignedUserId ) ; } $ task = $ taskManager -> find ( $ id ) ; $ taskManager -> updateTask ( $ task , $ this -> getUser ( ) , $ name , $ assignUser , $ comment ) ; return new ResultResponse ( true , 'Task transition created.' , array ( 'task' => $ this -> serializeTask ( $ task ) ) ) ; }
Create task transition .
24,740
public function viewAction ( Request $ request ) { $ id = $ request -> get ( 'id' ) ; $ taskManager = $ this -> get ( 'phlexible_task.task_manager' ) ; $ types = $ this -> get ( 'phlexible_task.types' ) ; $ userManager = $ this -> get ( 'phlexible_user.user_manager' ) ; $ task = $ taskManager -> find ( $ id ) ; $ createUser = $ userManager -> find ( $ task -> getCreateUserId ( ) ) ; $ assignedUser = $ userManager -> find ( $ task -> getAssignedUserId ( ) ) ; $ transitions = [ ] ; foreach ( $ task -> getTransitions ( ) as $ transition ) { $ transitionUser = $ userManager -> find ( $ transition -> getCreateUserId ( ) ) ; $ history [ ] = [ 'create_date' => $ transition -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'name' => $ transitionUser -> getDisplayName ( ) , 'status' => $ transition -> getNewState ( ) , 'latest' => 1 , ] ; } $ transitions = array_reverse ( $ transitions ) ; $ comments = [ ] ; foreach ( $ task -> getComments ( ) as $ comment ) { $ commentUser = $ userManager -> find ( $ comment -> getCreateUserId ( ) ) ; $ history [ ] = [ 'create_date' => $ comment -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'name' => $ commentUser -> getDisplayName ( ) , 'status' => $ comment -> getCurrentState ( ) , 'comment' => $ comment -> getComment ( ) , 'latest' => 1 , ] ; } $ type = $ types -> get ( $ task -> getType ( ) ) ; $ data = [ 'id' => $ task -> getId ( ) , 'type' => $ task -> getType ( ) , 'title' => $ type -> getTitle ( $ task ) , 'text' => $ type -> getText ( $ task ) , 'component' => $ type -> getComponent ( ) , 'created' => $ task -> getCreateUserId ( ) === $ this -> getUser ( ) -> getId ( ) ? 1 : 0 , 'assigned' => $ task -> getAssignedUserId ( ) === $ this -> getUser ( ) -> getId ( ) ? 1 : 0 , 'assigned_user' => $ assignedUser -> getDisplayName ( ) , 'assigned_uid' => $ task -> getAssignedUserId ( ) , 'create_user' => $ createUser -> getDisplayName ( ) , 'create_uid' => $ task -> getCreateUserId ( ) , 'create_date' => $ task -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'latest_status' => $ task -> getFiniteState ( ) , 'latest_comment' => '' , 'latest_user' => '' , 'latest_uid' => '' , 'latest_date' => '' , 'transitions' => $ transitions , 'comments' => $ comments , ] ; return new JsonResponse ( $ data ) ; }
View task .
24,741
private function _getCacheInfo ( ) { $ request = Agl :: getRequest ( ) ; $ module = $ request -> getModule ( ) ; $ view = $ request -> getView ( ) ; $ action = $ request -> getAction ( ) ; $ cacheInfo = array ( ) ; $ cacheConfig = Agl :: app ( ) -> getConfig ( 'core-layout/modules/' . $ module . '#' . $ view . '#action#' . $ action . '/' . ConfigInterface :: CONFIG_CACHE_NAME ) ; if ( $ cacheConfig === NULL ) { $ cacheConfig = Agl :: app ( ) -> getConfig ( 'core-layout/modules/' . $ module . '#' . $ view . '/' . ConfigInterface :: CONFIG_CACHE_NAME ) ; } if ( $ cacheConfig === NULL ) { $ cacheConfig = Agl :: app ( ) -> getConfig ( 'core-layout/modules/' . $ module . '/' . ConfigInterface :: CONFIG_CACHE_NAME ) ; } if ( $ cacheConfig === NULL ) { $ cacheConfig = Agl :: app ( ) -> getConfig ( 'core-layout/modules/' . ConfigInterface :: CONFIG_CACHE_NAME ) ; } if ( is_array ( $ cacheConfig ) ) { $ configCacheTtlName = ConfigInterface :: CONFIG_CACHE_TTL_NAME ; $ configCacheTypeName = ConfigInterface :: CONFIG_CACHE_TYPE_NAME ; $ cacheInfo [ $ configCacheTtlName ] = ( isset ( $ cacheConfig [ $ configCacheTtlName ] ) and ctype_digit ( $ cacheConfig [ $ configCacheTtlName ] ) ) ? ( int ) $ cacheConfig [ $ configCacheTtlName ] : 0 ; $ type = ( isset ( $ cacheConfig [ $ configCacheTypeName ] ) ) ? $ cacheConfig [ $ configCacheTypeName ] : ConfigInterface :: CONFIG_CACHE_TYPE_STATIC ; $ cacheInfo [ CacheInterface :: CACHE_KEY ] = ViewInterface :: CACHE_FILE_PREFIX . $ module . CacheInterface :: CACHE_KEY_SEPARATOR . $ view . CacheInterface :: CACHE_KEY_SEPARATOR . $ action ; if ( Agl :: isModuleLoaded ( Agl :: AGL_MORE_POOL . '/locale/locale' ) ) { $ cacheInfo [ CacheInterface :: CACHE_KEY ] .= CacheInterface :: CACHE_KEY_SEPARATOR . Agl :: getSingleton ( Agl :: AGL_MORE_POOL . '/locale' ) -> getLanguage ( ) ; } if ( $ type == ConfigInterface :: CONFIG_CACHE_TYPE_DYNAMIC ) { $ cacheInfo [ CacheInterface :: CACHE_KEY ] .= CacheInterface :: CACHE_KEY_SEPARATOR . StringData :: rewrite ( $ request -> getReq ( ) ) ; if ( Request :: isAjax ( ) ) { $ cacheInfo [ CacheInterface :: CACHE_KEY ] .= CacheInterface :: CACHE_KEY_SEPARATOR . ConfigInterface :: CONFIG_CACHE_KEY_AJAX ; } } } return $ cacheInfo ; }
Return a TTL and a cache key composed of the module the view the actions and of the locale code and the request string if required .
24,742
protected function _getView ( ) { if ( $ viewInstance = Registry :: get ( 'view' ) ) { return $ viewInstance ; } $ request = Agl :: getRequest ( ) ; $ module = $ request -> getModule ( ) ; $ view = $ request -> getView ( ) ; $ viewPath = APP_PATH . Agl :: APP_PHP_DIR . ViewInterface :: APP_PHP_DIR . DS . $ module . DS . $ view . Agl :: PHP_EXT ; if ( file_exists ( $ viewPath ) ) { $ className = $ module . ucfirst ( $ view ) . ViewInterface :: APP_VIEW_SUFFIX ; $ viewInstance = Agl :: getInstance ( $ className ) ; } else { $ viewInstance = new View ( ) ; } $ viewInstance -> setFile ( $ module . DS . $ view ) ; Registry :: set ( 'view' , $ viewInstance ) ; return $ viewInstance ; }
Create and return the current view instance .
24,743
protected function _renderView ( ) { $ isCacheEnabled = Agl :: app ( ) -> isCacheEnabled ( ) ; if ( $ isCacheEnabled ) { $ cacheInfo = $ this -> _getCacheInfo ( ) ; if ( ! empty ( $ cacheInfo ) and $ cacheInstance = Agl :: getCache ( ) and $ cacheInstance -> has ( $ cacheInfo [ CacheInterface :: CACHE_KEY ] ) ) { return $ cacheInstance -> get ( $ cacheInfo [ CacheInterface :: CACHE_KEY ] ) ; } } $ viewModel = $ this -> _getView ( ) ; $ content = $ viewModel -> startBuffer ( ) -> render ( ) ; if ( $ isCacheEnabled and ! empty ( $ cacheInfo ) ) { $ cacheInstance -> set ( $ cacheInfo [ CacheInterface :: CACHE_KEY ] , $ content , $ cacheInfo [ ConfigInterface :: CONFIG_CACHE_TTL_NAME ] ) ; } return $ content ; }
Render the view page .
24,744
public function addColumn ( $ name , $ type , $ length = null ) { $ column = new MDatabaseTableColumn ( $ name , $ type , $ length ) ; array_push ( $ this -> columns , $ column ) ; }
Adds a new column to the actual database representation .
24,745
public function validate ( ) { if ( $ this instanceof Cache \ CacheableValidatableInterface && $ this -> isValidationCacheEnabled ( ) && $ this -> lastValidationResult instanceof ValidationResultSet ) { return $ this -> lastValidationResult ; } $ validationResultSet = $ this -> validateValue ( $ this -> getValue ( ) ) ; if ( $ this instanceof Cache \ CacheableValidatableInterface && $ this -> isValidationCacheEnabled ( ) ) { $ this -> lastValidationResult = $ validationResultSet ; } return $ validationResultSet ; }
Validates this against all given Validators
24,746
protected function getEntity ( Rule $ rule ) { if ( $ rule instanceof RuleSet ) { foreach ( $ rule -> getChildren ( ) as $ child ) { return $ child -> getEntity ( ) ; } throw new \ Exception ( sprintf ( 'The rule %s and non of its children have an entity' , get_class ( $ rule ) ) ) ; } return $ rule -> getEntity ( ) ; }
Get the entity from the passed rule
24,747
public function setQueryParams ( $ id , $ params = [ ] ) { $ requestQuery = $ this -> request -> query -> get ( 'query_id' ) ; if ( isset ( $ requestQuery [ $ id ] ) ) { $ paramsQuery = $ requestQuery [ $ id ] ; } elseif ( isset ( $ params [ 'query' ] ) ) { $ paramsQuery = $ params [ 'query' ] ; } else { $ paramsQuery = [ ] ; } $ query = array_merge ( [ 'limit' => null , 'offset' => null , 'orderby' => null , 'order' => null ] , $ paramsQuery ) ; if ( $ query [ 'offset' ] !== null && $ query [ 'offset' ] >= $ this -> paramDefaults [ 'offset' ] ) { $ this -> qb -> setFirstResult ( $ query [ 'offset' ] ) ; } if ( $ query [ 'limit' ] !== null && $ query [ 'limit' ] >= $ this -> paramDefaults [ 'limit' ] ) { $ this -> qb -> setMaxResults ( $ query [ 'limit' ] ) ; } if ( in_array ( $ query [ 'orderby' ] , $ this -> paramDefaults [ 'orderby' ] ) ) { $ order = in_array ( strtoupper ( $ query [ 'order' ] ) , $ this -> paramDefaults [ 'order' ] ) ? $ query [ 'order' ] : $ this -> paramDefaults [ 'order' ] [ 0 ] ; $ this -> qb -> orderBy ( 'a.' . Inflector :: camelize ( $ query [ 'orderby' ] ) , strtoupper ( $ order ) ) ; } }
Update query builder to include additional parameters
24,748
public static function getCommandDescription ( WebDriver_Command $ command ) { $ commandDescriptionList = [ "Command: {$command->getCommandName()}" , "Method: {$command->getMethod()}" , "URL: {$command->getUrl()}" ] ; $ paramList = $ command -> getParameters ( ) ; if ( ! empty ( $ paramList ) ) { $ commandDescriptionList = array_merge ( $ commandDescriptionList , [ "Parameters:" , var_export ( $ paramList , true ) ] ) ; } return implode ( "\n" , $ commandDescriptionList ) ; }
Returns webdriver command description .
24,749
public static function factory ( WebDriver_Command $ command , array $ infoList = [ ] , $ rawResponse = null ) { $ httpStatusCode = isset ( $ infoList [ 'http_code' ] ) ? $ infoList [ 'http_code' ] : 0 ; switch ( $ httpStatusCode ) { case WebDriver_Http :: CLIENT_ERROR_NOT_FOUND : case WebDriver_Http :: SERVER_ERROR_NOT_IMPLEMENTED : case WebDriver_Http :: CLIENT_ERROR_METHOD_NOT_ALLOWED : case WebDriver_Http :: CLIENT_ERROR_BAD_REQUEST : return WebDriver_Exception_InvalidRequest :: factory ( $ command , $ infoList , $ rawResponse ) ; case WebDriver_Http :: SERVER_ERROR_INTERNAL : $ decodedJsonList = json_decode ( $ rawResponse , true ) ; $ messageList = [ "Internal Server Error" ] ; if ( $ decodedJsonList === null ) { $ messageList [ ] = "Cant decode response JSON:" ; $ messageList [ ] = json_last_error_msg ( ) ; $ messageList [ ] = $ rawResponse ; $ exception = new WebDriver_Exception_Protocol ( implode ( "\n" , $ messageList ) ) ; $ exception -> httpStatusCode = $ httpStatusCode ; return $ exception ; } $ exception = WebDriver_Exception_FailedCommand :: factory ( $ command , $ infoList , $ rawResponse , $ decodedJsonList ) ; $ exception -> httpStatusCode = $ httpStatusCode ; return $ exception ; default : $ messageList = [ "Unknown error: {$httpStatusCode}" , $ rawResponse , static :: getCommandDescription ( $ command ) ] ; $ exception = new WebDriver_Exception_Protocol ( implode ( "\n" , $ messageList ) ) ; $ exception -> httpStatusCode = $ httpStatusCode ; return $ exception ; } }
Factory for protocol errors .
24,750
public function formatActionResponseProperty ( ResponseProperty $ responseProperty ) { $ info = [ 'name' => $ responseProperty -> getName ( ) , 'type' => $ responseProperty -> getType ( ) , 'description' => $ responseProperty -> getDescription ( ) ] ; if ( $ responseProperty -> isObject ( ) || $ responseProperty -> isCollection ( ) ) { foreach ( $ responseProperty -> getChild ( ) as $ resProperty ) { $ info [ 'properties' ] [ $ resProperty -> getName ( ) ] = $ this -> formatActionResponseProperty ( $ resProperty ) ; } } return $ info ; }
Format action response property
24,751
public static function restore_stock ( $ order ) { $ order = wc_get_order ( $ order ) ; if ( ! $ order || 'yes' !== get_option ( 'woocommerce_manage_stock' ) || ! apply_filters ( 'woocommerce_can_reduce_order_stock' , true , $ order ) || 1 > count ( $ order -> get_items ( ) ) ) { return false ; } $ restored = false ; foreach ( $ order -> get_items ( 'line_item' ) as $ item ) { $ qty = $ item -> get_quantity ( ) ; $ product = $ item -> get_product ( ) ; if ( ! $ qty || ! $ product || ! $ product -> managing_stock ( ) ) { continue ; } $ name = $ product -> get_formatted_name ( ) ; $ current_stock = $ product -> get_stock_quantity ( ) ; $ new_stock = wc_update_product_stock ( $ product , $ qty , 'increase' ) ; if ( ! $ new_stock ) { continue ; } $ order -> add_order_note ( sprintf ( __ ( '%1$s stock increased from %2$d to %3$d.' , 'hametwoo' ) , $ name , $ current_stock , $ new_stock ) ) ; $ restored = true ; } return $ restored ; }
Restore stock .
24,752
public function create ( $ data , $ flush = self :: FLUSH ) { if ( $ flush === self :: FLUSH ) { $ this -> flushModel ( ) ; } if ( is_callable ( $ data ) ) { $ model = $ this -> model ; call_user_func ( $ data , $ model ) ; $ model -> push ( ) ; } else { $ model = $ this -> model -> create ( $ data ) ; } return $ model ; }
Persist a new set of data
24,753
public function updateModel ( array $ data , Model $ model ) { $ model = $ model -> fill ( $ data ) ; return $ model -> isDirty ( ) && $ model -> update ( $ data ) ; }
Update a model passed in . Returns a boolean indicating whether the model has been modified or not .
24,754
public function newModel ( $ override = null ) { $ model = $ this -> model ( ) ; if ( $ override ) $ model = $ override ; $ class = '\\' . ltrim ( $ model , '\\' ) ; return $ this -> app -> make ( $ class ) ; }
Make a new model and attach it to the repository
24,755
public static function createObject ( $ type , $ defaultClass , $ instanceOf = false , $ param = [ ] ) { if ( is_string ( $ type ) ) { $ type = [ 'class' => $ type ] ; } if ( is_array ( $ type ) && ! isset ( $ type [ 'class' ] ) && ! empty ( $ defaultClass ) ) { $ type [ 'class' ] = $ defaultClass ; } if ( ! is_object ( $ type ) ) { $ type = Yii :: createObject ( $ type , $ param ) ; } if ( $ instanceOf === true ) { $ instanceOf = $ defaultClass ; } if ( $ instanceOf && ! $ type instanceof $ instanceOf ) { throw new InvalidArgumentException ( get_class ( $ type ) . " not instance of $instanceOf" ) ; } return $ type ; }
Create object with set default class and check parent class .
24,756
public function Initialize ( ) { $ this -> Head = new HeadModule ( $ this ) ; $ this -> Head -> AddTag ( 'meta' , array ( 'name' => 'robots' , 'content' => 'noindex' ) ) ; $ this -> AddJsFile ( 'jquery.js' ) ; $ this -> AddJsFile ( 'jquery.livequery.js' ) ; $ this -> AddJsFile ( 'jquery.form.js' ) ; $ this -> AddJsFile ( 'jquery.popup.js' ) ; $ this -> AddJsFile ( 'jquery.gardenhandleajaxform.js' ) ; $ this -> AddJsFile ( 'global.js' ) ; $ this -> AddCssFile ( 'style.css' ) ; parent :: Initialize ( ) ; Gdn_Theme :: Section ( 'Entry' ) ; }
Include JS and CSS used by all methods .
24,757
protected function CheckOverride ( $ Type , $ Target , $ TransientKey = NULL ) { if ( ! $ this -> Request -> Get ( 'override' , TRUE ) ) return ; $ Provider = Gdn_AuthenticationProviderModel :: GetDefault ( ) ; if ( ! $ Provider ) return ; $ this -> EventArguments [ 'Target' ] = $ Target ; $ this -> EventArguments [ 'DefaultProvider' ] = & $ Provider ; $ this -> EventArguments [ 'TransientKey' ] = $ TransientKey ; $ this -> FireEvent ( "Override{$Type}" ) ; $ Url = $ Provider [ $ Type . 'Url' ] ; if ( $ Url ) { switch ( $ Type ) { case 'Register' : case 'SignIn' : $ Target = '/sso?target=' . urlencode ( $ Target ) ; break ; case 'SignOut' : $ Cookie = C ( 'Garden.Cookie.Name' ) ; if ( strpos ( $ Url , '?' ) === FALSE ) $ Url .= '?vfcookie=' . urlencode ( $ Cookie ) ; else $ Url .= '&vfcookie=' . urlencode ( $ Cookie ) ; $ SignedOut = ! Gdn :: Session ( ) -> IsValid ( ) ; if ( ! $ SignedOut && ( Gdn :: Session ( ) -> ValidateTransientKey ( $ TransientKey ) || $ this -> Form -> IsPostBack ( ) ) ) { Gdn :: Session ( ) -> End ( ) ; $ SignedOut = TRUE ; } $ SignoutType = C ( 'Garden.SSO.Signout' ) ; switch ( $ SignoutType ) { case 'redirect-only' : break ; case 'post-only' : $ this -> SetData ( 'Method' , 'POST' ) ; break ; case 'post' : if ( ! $ SignedOut ) return ; $ this -> SetData ( 'Method' , 'POST' ) ; break ; case 'none' : return ; case 'redirect' : default : if ( ! $ SignedOut ) return ; break ; } break ; default : throw new Exception ( "Unknown entry type $Type." ) ; } $ Url = str_ireplace ( '{target}' , rawurlencode ( Url ( $ Target , TRUE ) ) , $ Url ) ; if ( $ this -> DeliveryType ( ) == DELIVERY_TYPE_ALL && strcasecmp ( $ this -> Data ( 'Method' ) , 'POST' ) != 0 ) Redirect ( $ Url , 302 ) ; else { $ this -> SetData ( 'Url' , $ Url ) ; $ this -> Render ( 'Redirect' , 'Utility' ) ; die ( ) ; } } }
Check the default provider to see if it overrides one of the entry methods and then redirect .
24,758
protected function _SetRedirect ( $ CheckPopup = FALSE ) { $ Url = Url ( $ this -> RedirectTo ( ) , TRUE ) ; $ this -> RedirectUrl = $ Url ; $ this -> MasterView = 'popup' ; $ this -> View = 'redirect' ; if ( $ this -> _RealDeliveryType != DELIVERY_TYPE_ALL && $ this -> DeliveryType ( ) != DELIVERY_TYPE_ALL ) { $ this -> DeliveryMethod ( DELIVERY_METHOD_JSON ) ; $ this -> SetHeader ( 'Content-Type' , 'application/json' ) ; } elseif ( $ CheckPopup ) { $ this -> AddDefinition ( 'CheckPopup' , $ CheckPopup ) ; } else { Redirect ( Url ( $ this -> RedirectUrl ) ) ; } }
After sign in send them along .
24,759
public function SignOut ( $ TransientKey = "" ) { $ this -> CheckOverride ( 'SignOut' , $ this -> Target ( ) , $ TransientKey ) ; if ( Gdn :: Session ( ) -> ValidateTransientKey ( $ TransientKey ) || $ this -> Form -> IsPostBack ( ) ) { $ User = Gdn :: Session ( ) -> User ; $ this -> EventArguments [ 'SignoutUser' ] = $ User ; $ this -> FireEvent ( "BeforeSignOut" ) ; Gdn :: Session ( ) -> End ( ) ; $ this -> SetData ( 'SignedOut' , TRUE ) ; $ this -> EventArguments [ 'SignoutUser' ] = $ User ; $ this -> FireEvent ( "SignOut" ) ; $ this -> _SetRedirect ( ) ; } elseif ( ! Gdn :: Session ( ) -> IsValid ( ) ) $ this -> _SetRedirect ( ) ; $ this -> SetData ( 'Target' , $ this -> Target ( ) ) ; $ this -> Leaving = FALSE ; $ this -> Render ( ) ; }
Good afternoon good evening and goodnight .
24,760
public function Register ( $ InvitationCode = '' ) { if ( ! $ this -> Request -> IsPostBack ( ) ) $ this -> CheckOverride ( 'Register' , $ this -> Target ( ) ) ; $ this -> FireEvent ( "Register" ) ; $ this -> Form -> SetModel ( $ this -> UserModel ) ; $ this -> GenderOptions = array ( 'u' => T ( 'Unspecified' ) , 'm' => T ( 'Male' ) , 'f' => T ( 'Female' ) ) ; $ this -> AddJsFile ( 'entry.js' ) ; $ this -> Form -> AddHidden ( 'ClientHour' , date ( 'Y-m-d H:00' ) ) ; $ this -> Form -> AddHidden ( 'Target' , $ this -> Target ( ) ) ; $ this -> SetData ( 'NoEmail' , UserModel :: NoEmail ( ) ) ; $ RegistrationMethod = $ this -> _RegistrationView ( ) ; $ this -> View = $ RegistrationMethod ; $ this -> $ RegistrationMethod ( $ InvitationCode ) ; }
Calls the appropriate registration method based on the configuration setting .
24,761
private function RegisterApproval ( ) { Gdn :: UserModel ( ) -> AddPasswordStrength ( $ this ) ; if ( $ this -> Form -> IsPostBack ( ) ) { $ this -> UserModel -> DefineSchema ( ) ; $ this -> UserModel -> Validation -> ApplyRule ( 'Name' , 'Username' , $ this -> UsernameError ) ; $ this -> UserModel -> Validation -> ApplyRule ( 'TermsOfService' , 'Required' , T ( 'You must agree to the terms of service.' ) ) ; $ this -> UserModel -> Validation -> ApplyRule ( 'Password' , 'Required' ) ; $ this -> UserModel -> Validation -> ApplyRule ( 'Password' , 'Strength' ) ; $ this -> UserModel -> Validation -> ApplyRule ( 'Password' , 'Match' ) ; $ this -> UserModel -> Validation -> ApplyRule ( 'DiscoveryText' , 'Required' , 'Tell us why you want to join!' ) ; $ this -> FireEvent ( 'RegisterValidation' ) ; try { $ Values = $ this -> Form -> FormValues ( ) ; unset ( $ Values [ 'Roles' ] ) ; $ AuthUserID = $ this -> UserModel -> Register ( $ Values ) ; if ( ! $ AuthUserID ) { $ this -> Form -> SetValidationResults ( $ this -> UserModel -> ValidationResults ( ) ) ; } else { Gdn :: Session ( ) -> Start ( $ AuthUserID ) ; if ( $ this -> Form -> GetFormValue ( 'RememberMe' ) ) Gdn :: Authenticator ( ) -> SetIdentity ( $ AuthUserID , TRUE ) ; $ Label = T ( 'NewApplicantEmail' , 'New applicant:' ) ; $ Story = Anchor ( Gdn_Format :: Text ( $ Label . ' ' . $ Values [ 'Name' ] ) , ExternalUrl ( 'dashboard/user/applicants' ) ) ; $ this -> EventArguments [ 'AuthUserID' ] = $ AuthUserID ; $ this -> EventArguments [ 'Story' ] = & $ Story ; $ this -> FireEvent ( 'RegistrationPending' ) ; $ this -> View = "RegisterThanks" ; $ Data = Gdn :: Database ( ) -> SQL ( ) -> GetWhere ( 'UserMeta' , array ( 'Name' => 'Preferences.Email.Applicant' ) ) -> ResultArray ( ) ; $ ActivityModel = new ActivityModel ( ) ; foreach ( $ Data as $ Row ) { $ ActivityModel -> Add ( $ AuthUserID , 'Applicant' , $ Story , $ Row [ 'UserID' ] , '' , '/dashboard/user/applicants' , 'Only' ) ; } } } catch ( Exception $ Ex ) { $ this -> Form -> AddError ( $ Ex ) ; } } $ this -> Render ( ) ; }
Registration that requires approval .
24,762
public function PasswordRequest ( ) { Gdn :: Locale ( ) -> SetTranslation ( 'Email' , T ( UserModel :: SigninLabelCode ( ) ) ) ; if ( $ this -> Form -> IsPostBack ( ) === TRUE ) { $ this -> Form -> ValidateRule ( 'Email' , 'ValidateRequired' ) ; if ( $ this -> Form -> ErrorCount ( ) == 0 ) { try { $ Email = $ this -> Form -> GetFormValue ( 'Email' ) ; if ( ! $ this -> UserModel -> PasswordRequest ( $ Email ) ) { $ this -> Form -> SetValidationResults ( $ this -> UserModel -> ValidationResults ( ) ) ; } } catch ( Exception $ ex ) { $ this -> Form -> AddError ( $ ex -> getMessage ( ) ) ; } if ( $ this -> Form -> ErrorCount ( ) == 0 ) { $ this -> Form -> AddError ( 'Success!' ) ; $ this -> View = 'passwordrequestsent' ; } } else { if ( $ this -> Form -> ErrorCount ( ) == 0 ) $ this -> Form -> AddError ( "Couldn't find an account associated with that email/username." ) ; } } $ this -> Render ( ) ; }
Request password reset .
24,763
public function PasswordReset ( $ UserID = '' , $ PasswordResetKey = '' ) { if ( ! is_numeric ( $ UserID ) || $ PasswordResetKey == '' || $ this -> UserModel -> GetAttribute ( $ UserID , 'PasswordResetKey' , '' ) != $ PasswordResetKey ) $ this -> Form -> AddError ( 'Failed to authenticate your password reset request. Try using the reset request form again.' ) ; if ( $ this -> Form -> ErrorCount ( ) == 0 ) { $ User = $ this -> UserModel -> GetID ( $ UserID , DATASET_TYPE_ARRAY ) ; if ( $ User ) { $ User = ArrayTranslate ( $ User , array ( 'UserID' , 'Name' , 'Email' ) ) ; $ this -> SetData ( 'User' , $ User ) ; } } if ( $ this -> Form -> ErrorCount ( ) == 0 && $ this -> Form -> IsPostBack ( ) === TRUE ) { $ Password = $ this -> Form -> GetFormValue ( 'Password' , '' ) ; $ Confirm = $ this -> Form -> GetFormValue ( 'Confirm' , '' ) ; if ( $ Password == '' ) $ this -> Form -> AddError ( 'Your new password is invalid' ) ; else if ( $ Password != $ Confirm ) $ this -> Form -> AddError ( 'Your passwords did not match.' ) ; if ( $ this -> Form -> ErrorCount ( ) == 0 ) { $ User = $ this -> UserModel -> PasswordReset ( $ UserID , $ Password ) ; Gdn :: Session ( ) -> Start ( $ User -> UserID , TRUE ) ; Redirect ( '/' ) ; } } $ this -> Render ( ) ; }
Do password reset .
24,764
public function EmailConfirm ( $ UserID , $ EmailKey = '' ) { $ User = $ this -> UserModel -> GetID ( $ UserID ) ; if ( ! $ User ) throw NotFoundException ( 'User' ) ; $ EmailConfirmed = $ this -> UserModel -> ConfirmEmail ( $ User , $ EmailKey ) ; $ this -> Form -> SetValidationResults ( $ this -> UserModel -> ValidationResults ( ) ) ; if ( $ EmailConfirmed ) { $ UserID = GetValue ( 'UserID' , $ User ) ; Gdn :: Session ( ) -> Start ( $ UserID ) ; } $ this -> SetData ( 'EmailConfirmed' , $ EmailConfirmed ) ; $ this -> SetData ( 'Email' , $ User -> Email ) ; $ this -> Render ( ) ; }
Confirm email address is valid via sent code .
24,765
public function EmailConfirmRequest ( $ UserID = '' ) { if ( $ UserID && ! Gdn :: Session ( ) -> CheckPermission ( 'Garden.Users.Edit' ) ) $ UserID = '' ; try { $ this -> UserModel -> SendEmailConfirmationEmail ( $ UserID ) ; } catch ( Exception $ Ex ) { } $ this -> Form -> SetValidationResults ( $ this -> UserModel -> ValidationResults ( ) ) ; $ this -> Render ( ) ; }
Send email confirmation message to user .
24,766
public function Target ( $ Target = FALSE ) { if ( $ Target === FALSE ) { $ Target = $ this -> Form -> GetFormValue ( 'Target' , FALSE ) ; if ( ! $ Target ) $ Target = $ this -> Request -> Get ( 'Target' , '/' ) ; } if ( ! preg_match ( '`(^https?://)`' , $ Target ) ) { $ Target = '/' . ltrim ( $ Target , '/' ) ; if ( preg_match ( '`^/entry/signin`i' , $ Target ) ) $ Target = '/' ; } else { $ MyHostname = parse_url ( Gdn :: Request ( ) -> Domain ( ) , PHP_URL_HOST ) ; $ TargetHostname = parse_url ( $ Target , PHP_URL_HOST ) ; $ TrustedDomains = C ( 'Garden.TrustedDomains' , TRUE ) ; if ( is_array ( $ TrustedDomains ) ) { $ TrustedDomains [ ] = $ MyHostname ; $ Sender -> EventArguments [ 'TrustedDomains' ] = & $ TrustedDomains ; $ this -> FireEvent ( 'BeforeTargetReturn' ) ; } if ( $ TrustedDomains === TRUE ) { return $ Target ; } elseif ( count ( $ TrustedDomains ) == 0 ) { if ( $ MyHostname != $ TargetHostname ) $ Target = '' ; } else { $ Match = FALSE ; foreach ( $ TrustedDomains as $ TrustedDomain ) { if ( StringEndsWith ( $ TargetHostname , $ TrustedDomain , TRUE ) ) $ Match = TRUE ; } if ( ! $ Match ) $ Target = '' ; } } return $ Target ; }
Set where to go after signin .
24,767
public function getHTML ( $ showLabel = true ) { return parent :: getHTML ( false ) . Templates :: getTemplate ( $ this -> getTemplateLocation ( ) ) -> render ( array ( 'id' => $ this -> getId ( ) , 'showLabel' => $ showLabel || $ this -> overrideShowLabel , 'label' => $ this -> label , 'resolution' => $ this -> resolution , 'displaySize' => $ this -> displaySize ) ) ; }
Gets the HTML markup of the component
24,768
public function getLanguage ( ) { if ( ! $ this -> selectedLanguage ) { $ language = false ; if ( isset ( $ _SESSION [ 'language' ] ) && $ this -> isValidLanguage ( $ _SESSION [ 'language' ] ) ) { $ language = $ _SESSION [ 'language' ] ; } $ requestLanguage = $ this -> getRequest ( ) -> get ( 'language' ) ; if ( $ requestLanguage && $ this -> isValidLanguage ( $ requestLanguage ) ) { $ language = $ requestLanguage ; } if ( $ language ) { $ this -> setLanguage ( $ language ) ; } else { $ this -> setLanguage ( $ this -> getDefaultLanguage ( ) ) ; } } return $ this -> selectedLanguage ; }
Checks SESSION GET and Nip_Request and selects requested language If language not requested falls back to default
24,769
public function setLanguage ( $ language ) { $ this -> setLocale ( $ language ) ; $ code = $ this -> getLanguageCode ( $ language ) ; putenv ( 'LC_ALL=' . $ code ) ; setlocale ( LC_ALL , $ code ) ; setlocale ( LC_NUMERIC , 'en_US' ) ; return $ this ; }
Selects a language to be used when translating
24,770
public function getDefaultLanguage ( ) { if ( ! $ this -> defaultLanguage ) { $ language = substr ( setlocale ( LC_ALL , 0 ) , 0 , 2 ) ; $ languages = $ this -> getLanguages ( ) ; $ languageDefault = reset ( $ languages ) ; $ language = $ this -> isValidLanguage ( $ language ) ? $ language : $ languageDefault ; $ this -> setDefaultLanguage ( $ language ) ; } return $ this -> defaultLanguage ; }
gets the default language to be used when translating
24,771
public function findUserById ( $ id ) { if ( $ id instanceof UserInterface ) { return $ id ; } $ result = $ this -> userProvider -> findById ( $ id ) ; if ( $ result ) { return $ result ; } $ exceptionMessage = "A user with the ID '%(id)s' cannot be found." ; throw new UserNotFound ( isprintf ( $ exceptionMessage , compact ( 'id' ) ) ) ; }
Find a user by their ID
24,772
public function findUserByLogin ( $ login ) { if ( $ login instanceof UserInterface ) { return $ login ; } $ result = $ this -> userProvider -> findByLogin ( $ login ) ; if ( $ result ) { return $ result ; } $ exceptionMessage = "A user with the login '%(login)s' cannot be found." ; throw new UserNotFound ( isprintf ( $ exceptionMessage , compact ( 'login' ) ) ) ; }
Find a user by their login
24,773
public function giveRolePermission ( $ role , $ permission , $ level = 'allow' ) { $ this -> checkPermissionLevel ( $ level ) ; $ role = $ this -> findRoleByKey ( $ role ) ; $ permission = $ this -> findPermissionByKey ( $ permission ) ; return $ role -> give ( $ permission , $ level ) ; }
Give a role a permission
24,774
public function removeRolePermission ( $ role , $ permission ) { $ role = $ this -> findRoleByKey ( $ role ) ; $ permission = $ this -> findPermissionByKey ( $ permission ) ; return $ role -> remove ( $ permission ) ; }
Remove a permission from a role
24,775
public function giveUserPermission ( $ user , $ permission , $ level = 'allow' ) { $ this -> checkPermissionLevel ( $ level ) ; $ user = $ this -> findUserById ( $ user ) ; $ permission = $ this -> findPermissionByKey ( $ permission ) ; return $ user -> give ( $ permission , $ level ) ; }
Give a user a permission
24,776
public function removeUserPermission ( $ user , $ permission ) { $ permissions = $ this -> findPermissionByKey ( $ permission ) ; $ user = $ this -> findUserById ( $ user ) ; return $ user -> remove ( $ permission ) ; }
Remove a permission from a user
24,777
public function giveUserRole ( $ user , $ role ) { $ user = $ this -> findUserById ( $ user ) ; $ role = $ this -> findRoleByKey ( $ role ) ; if ( $ user -> is ( $ role -> key ) ) { return true ; } return $ user -> join ( $ role ) ; }
Give a user a role
24,778
public function removeUserRole ( $ user , $ role ) { $ user = $ this -> findUserById ( $ user ) ; $ role = $ this -> findRoleByKey ( $ role ) ; if ( $ user -> not ( $ role -> key ) ) { return true ; } return $ user -> leave ( $ role ) ; }
Remove a role from a user
24,779
public function createPermission ( $ name , $ key = null , $ description = null ) { $ key = snake_case ( isset ( $ key ) ? $ key : $ name ) ; $ description = isset ( $ description ) ? $ description : $ name ; $ values = compact ( 'name' , 'key' , 'description' ) ; return $ this -> permissionProvider -> create ( $ values ) ; }
Create a permission
24,780
public function has ( $ id , $ permission , $ all = true ) { if ( ! $ user = $ this -> findUserById ( $ id ) ) { return false ; } return $ user -> has ( $ permission , $ all ) ; }
Does the user have a permission?
24,781
public function hasnt ( $ id , $ permission , $ all = true ) { return false === $ this -> has ( $ id , $ permission , $ all ) ; }
Does the user not have a permission
24,782
public function is ( $ id , $ role , $ all = true ) { if ( ! $ user = $ this -> findUserById ( $ id ) ) { return false ; } return $ user -> is ( $ role , $ all ) ; }
Is the user part of a role?
24,783
public function not ( $ id , $ role , $ all = true ) { return false === $ this -> is ( $ id , $ role , $ all ) ; }
Is the user not part of a role?
24,784
private function checktime ( int $ hour , int $ minute , int $ second ) { if ( $ hour < 0 || $ hour > 23 ) { return false ; } elseif ( $ minute < 0 || $ minute > 59 ) { return false ; } elseif ( $ second < 0 || $ second > 59 ) { return false ; } return true ; }
Checks whether the passed time is a valid time .
24,785
public static function join ( Array $ pieces , $ glue ) { $ s = NULL ; foreach ( $ pieces as $ key => $ piece ) { if ( is_array ( $ piece ) ) $ piece = 'Array' ; $ s .= sprintf ( $ glue , $ piece , $ key ) ; } return $ s ; }
Joins an array to string
24,786
public static function remove ( Array & $ array , $ item , $ searchStrict = TRUE ) { if ( ( $ key = array_search ( $ item , $ array , $ searchStrict ) ) !== FALSE ) { array_splice ( $ array , $ key , 1 ) ; } return $ array ; }
Remove an element from an array
24,787
public static function filterKeys ( Array $ array , Closure $ filter ) { $ filtered = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( $ filter ( $ key , $ value ) ) { $ filtered [ $ key ] = $ value ; } } return $ filtered ; }
Filters the keys and values from an array
24,788
public static function indexBy ( Array $ array , $ property ) { $ ret = array ( ) ; if ( count ( $ array ) > 0 ) { $ index = Util :: castGetterFromSample ( $ property , current ( $ array ) ) ; foreach ( $ array as $ item ) { $ ret [ $ index ( $ item ) ] = $ item ; } } return $ ret ; }
Returns an array with the index constructred from objects in the collection
24,789
public function getAttributeDataFromTabs ( array $ limit = [ ] ) { $ api_root_data = json_decode ( $ this -> nt8RestService -> get ( '/' ) ) ; $ attrib_data = $ api_root_data -> constants -> attributes ; if ( count ( $ limit ) > 0 ) { $ attrib_data = array_filter ( $ attrib_data , function ( $ value ) use ( $ limit ) { $ attr_code = $ value -> code ? : '' ; if ( in_array ( $ attr_code , $ limit ) ) { return TRUE ; } return FALSE ; } ) ; } return $ attrib_data ; }
Fetches data for the specified attributes from Tabs .
24,790
public function createAttributesFromTabs ( array $ attrib_data = [ ] ) { $ updatedAttrs = "" ; $ save_status = FALSE ; foreach ( $ attrib_data as $ attr_key => $ attribute ) { $ attr_array = [ 'field_attribute_code' => [ 'value' => $ attribute -> code ] , 'field_attribute_brand' => [ 'value' => $ attribute -> brand ] , 'field_attribute_labl' => [ 'value' => $ attribute -> label ] , 'field_attribute_group' => [ 'value' => $ attribute -> group ] , 'field_attribute_type' => [ 'value' => $ attribute -> type ] , ] ; $ attr_array [ 'vid' ] = $ this :: ATTRIBUTE_VOCAB_ID ; $ attr_array [ 'name' ] = $ attribute -> label ; $ term = Term :: create ( $ attr_array ) ; $ terms = self :: loadTermsByNames ( $ this :: ATTRIBUTE_VOCAB_ID , [ $ attr_array [ 'name' ] ] , function ( & $ term ) use ( $ attr_array , & $ save_status ) { $ term -> get ( 'field_attribute_code' ) -> setValue ( $ attr_array [ 'field_attribute_code' ] ) ; $ term -> get ( 'field_attribute_brand' ) -> setValue ( $ attr_array [ 'field_attribute_brand' ] ) ; $ term -> get ( 'field_attribute_labl' ) -> setValue ( $ attr_array [ 'field_attribute_labl' ] ) ; $ term -> get ( 'field_attribute_group' ) -> setValue ( $ attr_array [ 'field_attribute_group' ] ) ; $ term -> get ( 'field_attribute_type' ) -> setValue ( $ attr_array [ 'field_attribute_type' ] ) ; $ save_status = $ term -> save ( ) ; } ) ; if ( is_null ( $ terms ) ) { $ save_status = $ term -> save ( ) ; } if ( $ save_status ) { $ updatedAttrs .= $ attr_array [ 'field_attribute_code' ] [ 'value' ] . ", " ; } } return $ updatedAttrs ; }
Populates the cottage_attributes taxonomy with data from TABS .
24,791
public function loadNodesFromProprefs ( array $ proprefs ) { $ loadedNodes = [ ] ; foreach ( $ proprefs as $ propref ) { $ nodes = $ this -> loadNodesFromPropref ( $ propref ) ? : [ ] ; if ( count ( $ nodes ) > 0 ) { foreach ( $ nodes as $ node ) { $ loadedNodes [ $ propref ] [ ] = $ node ; } } } return $ loadedNodes ; }
Load node objects from an array of property references .
24,792
public function loadNodesFromPropref ( string $ propref , bool $ load = TRUE ) { $ nodeQuery = $ this -> entityQuery -> get ( 'node' ) ; $ nodeStorage = $ this -> entityTypeManager -> getStorage ( 'node' ) ; $ nids = $ nodeQuery -> condition ( 'field_cottage_reference_code.value' , $ propref , '=' ) -> execute ( ) ; if ( ! $ load ) { return $ nids ; } $ nodes = $ nodeStorage -> loadMultiple ( $ nids ) ; if ( count ( $ nodes ) === 0 ) { \ Drupal :: logger ( 'NT8PropertyService' ) -> notice ( "Could not load a node for this propref: @propref" , [ '@propref' => print_r ( $ propref , TRUE ) ] ) ; $ nodes = NULL ; } return $ nodes ; }
Loads property nodes which have the same propref as the one provided .
24,793
public function updateNodeInstancesFromData ( \ stdClass $ data ) { $ updatedProperties = [ ] ; $ nids = self :: loadNodesFromPropref ( $ data -> propertyRef , FALSE ) ; $ updatedValues = self :: generateUpdateArray ( $ data , FALSE ) ; if ( count ( $ nids ) > 0 ) { $ nodes = $ this -> entityTypeManager -> getStorage ( 'node' ) -> loadMultiple ( $ nids ) ; foreach ( $ nodes as $ node ) { $ updated = $ this -> updateNodeInstanceFromData ( $ updatedValues , $ node ) ; if ( $ updated ) { $ updatedProperties [ ] = $ data -> propertyRef ; $ node -> save ( ) ; } } } return $ updatedProperties ; }
Updates all matching nodes with data provided by the TABS api .
24,794
public static function getNodeFieldValue ( EntityInterface $ node , string $ fieldName , int $ index = - 1 , string $ keyname = 'value' ) { $ field_instance = static :: getNodeField ( $ node , $ fieldName ) ; $ field_instance_value = $ field_instance -> getValue ( ) ; if ( $ index > - 1 ) { $ field_instance_value = $ field_instance_value [ $ index ] [ $ keyname ] ; } return $ field_instance_value ; }
Retrieves a field value from a specified node .
24,795
public static function getTidFromTermName ( $ term_name , $ vocab_name ) { $ tid = - 1 ; if ( $ terms = taxonomy_term_load_multiple_by_name ( $ term_name , $ vocab_name ) ) { $ term = reset ( $ terms ) ; $ tid = $ term -> id ( ) ; } return $ tid ; }
Retrieves a TID for a given term name . Rturns - 1 if term couldn t be found .
24,796
public function updateNodeInstanceFromData ( array $ updatedValues , EntityInterface & $ nodeInstance ) { $ updated = FALSE ; foreach ( $ updatedValues as $ updatedValueKey => $ updatedValue ) { $ currentNodeField = static :: getNodeFieldValue ( $ nodeInstance , $ updatedValueKey ) ; $ length_of_update_fields = count ( $ updatedValue ) ; $ updateIndex = 0 ; foreach ( $ currentNodeField as $ index => $ nodeFieldValue ) { $ comparisonUpdate = $ updatedValue ; if ( $ length_of_update_fields > 1 ) { $ comparisonUpdate = $ updatedValue [ $ updateIndex ++ ] ?? $ updatedValue ; } $ nestedComparison = $ comparisonUpdate [ 0 ] ?? NULL ; if ( $ nestedComparison && is_array ( $ nestedComparison ) ) { $ comparisonUpdate = $ nestedComparison ; } sort ( $ comparisonUpdate ) ; sort ( $ nodeFieldValue ) ; $ difference = ( $ comparisonUpdate == $ nodeFieldValue ) ; if ( $ difference == 0 ) { $ fieldRef = static :: getNodeField ( $ nodeInstance , $ updatedValueKey ) ; $ fieldRef -> setValue ( $ updatedValue ) ; $ updated = TRUE ; } } } return $ updated ; }
Updates an EntityInterface from a provided array of updated values .
24,797
public function createNodeInstanceFromPropref ( string $ propRef = "" ) { $ data = $ this -> getPropertyFromApi ( $ propRef ) ; $ created_node = NULL ; if ( $ data && $ data instanceof \ stdClass ) { $ created_node = $ this -> createNodeInstanceFromData ( $ data , TRUE ) ; } return $ created_node ; }
Creates a property node populated with data returned from the API .
24,798
function setClient ( $ clientName , MongoDB \ Client $ clientMongo ) { if ( $ this -> hasClient ( $ clientName ) ) throw new \ Exception ( sprintf ( 'Client with name (%s) already exists and cant be replaced.' , $ clientName ) ) ; $ this -> clients [ $ clientName ] = $ clientMongo ; return $ this ; }
Add Client Connection
24,799
function getClient ( $ clientName ) { if ( ! isset ( $ this -> clients [ $ clientName ] ) ) $ this -> clients [ $ clientName ] = $ this -> _attainClient ( $ clientName ) ; return $ this -> clients [ $ clientName ] ; }
Attain Client By Name