idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
3,900
public function getParentList ( ) { if ( ! $ this -> isPropertyAvailable ( 'ParentList' ) ) { $ this -> setProperty ( "ParentList" , new SPList ( $ this -> getContext ( ) , new ResourcePathEntity ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "parentlist" ) ) , false ) ; } return $ this -> getProperty ( "...
Gets the parent list that contains the list item .
3,901
public function getFolder ( ) { if ( ! $ this -> isPropertyAvailable ( 'Folder' ) ) { $ this -> setProperty ( "Folder" , new Folder ( $ this -> getContext ( ) , new ResourcePathEntity ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "Folder" ) ) , false ) ; } return $ this -> getProperty ( "Folder" ) ; }
Gets the associated Folder resource .
3,902
public function getFile ( ) { if ( ! $ this -> isPropertyAvailable ( 'File' ) ) { $ this -> setProperty ( "File" , new File ( $ this -> getContext ( ) , new ResourcePathEntity ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "File" ) ) , false ) ; } return $ this -> getProperty ( "File" ) ; }
Gets the associated File resource .
3,903
public function add ( FieldCreationInformation $ parameters ) { $ field = new Field ( $ this -> getContext ( ) ) ; $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , null , null , $ parameters ) ; $ this -> getContext ( ) -> addQuery ( $ qry , $ field ) ; $ this -> addChild ( $ field ) ; return $ field...
Creates a Field resource
3,904
public function importWebPart ( $ webPartXml ) { $ payload = new ClientValueObject ( ) ; $ payload -> setProperty ( "webPartXml" , $ webPartXml ) ; $ webPartDefinition = new WebPartDefinition ( $ this -> getContext ( ) ) ; $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "ImportWebPart" , null , $ pa...
Imports a Web Part from a string in the . dwp format
3,905
public function getByEmail ( $ emailAddress ) { $ path = new ResourcePathServiceOperation ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "getByEmail" , array ( $ emailAddress ) ) ; return new User ( $ this -> getContext ( ) , $ path ) ; }
Gets the user with the specified email address .
3,906
public function removeById ( $ id ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "removebyid" , array ( $ id ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Removes the user with the specified ID .
3,907
public function removeByLoginName ( $ loginName ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "removebyloginname" , array ( rawurlencode ( $ loginName ) ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Removes the user with the specified login name
3,908
public function breakRoleInheritance ( $ copyRoleAssignments ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "breakroleinheritance" , array ( $ copyRoleAssignments ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Creates unique role assignments for the securable object .
3,909
public function getUsers ( ) { if ( ! $ this -> isPropertyAvailable ( 'Users' ) ) { $ this -> setProperty ( "Users" , new UserCollection ( $ this -> getContext ( ) , new ResourcePathEntity ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "Users" ) ) ) ; } return $ this -> getProperty ( "Users" ) ; }
Gets a collection of user objects that represents all of the users in the group .
3,910
public function ensureFormDigest ( RequestOptions $ request ) { if ( ! isset ( $ this -> contextWebInformation ) ) { $ this -> requestFormDigest ( ) ; } $ request -> addCustomHeader ( "X-RequestDigest" , $ this -> getContextWebInformation ( ) -> FormDigestValue ) ; }
Ensure form digest value for POST request
3,911
public function requestFormDigest ( ) { $ request = new RequestOptions ( $ this -> getServiceRootUrl ( ) . "contextinfo" ) ; $ request -> Method = HttpMethod :: Post ; $ response = $ this -> executeQueryDirect ( $ request ) ; if ( ! isset ( $ this -> contextWebInformation ) ) $ this -> contextWebInformation = new Conte...
Request the SharePoint Context Info
3,912
public function getViewFields ( ) { if ( ! $ this -> isPropertyAvailable ( 'ViewFields' ) ) { $ this -> setProperty ( "ViewFields" , new ViewFieldCollection ( $ this -> getContext ( ) , new ResourcePathEntity ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "ViewFields" ) ) ) ; } return $ this -> getPropert...
Gets a value that specifies the collection of fields in the list view .
3,913
public static function createNewDiscussion ( SPList $ list , $ title ) { $ discussionPayload = array ( "Title" => $ title , "FileSystemObjectType" => 1 ) ; $ item = $ list -> addItem ( $ discussionPayload ) ; $ item -> getContext ( ) -> executeQuery ( ) ; $ item -> setProperty ( "FileLeafRef" , $ title ) ; $ item -> up...
Creates a discussion item in Discussion Board
3,914
protected function acquireSecurityToken ( $ username , $ password ) { $ data = $ this -> prepareSecurityTokenRequest ( $ username , $ password , $ this -> authorityUrl ) ; $ response = Requests :: post ( self :: $ StsUrl , null , $ data ) ; try { $ this -> processSecurityTokenResponse ( $ response ) ; } catch ( Excepti...
Acquire the service token from STS
3,915
protected function acquireSecurityTokenFromFederatedSTS ( $ username , $ password ) { $ response = Requests :: get ( str_replace ( '{username}' , $ username , self :: $ RealmUrlTemplate ) , null ) ; $ federatedStsUrl = $ this -> getFederatedAuthenticationInformation ( $ response ) ; if ( $ federatedStsUrl ) { $ message...
Acquire the service token from Federated STS
3,916
protected function getSamlAssertion ( $ response ) { $ xml = new \ DOMDocument ( ) ; $ xml -> loadXML ( $ response ) ; $ xpath = new \ DOMXPath ( $ xml ) ; if ( $ xpath -> query ( "//*[name()='saml:Assertion']" ) -> length > 0 ) { $ nodeToken = $ xpath -> query ( "//*[name()='saml:Assertion']" ) ; if ( ! empty ( $ node...
Get SAML assertion Node so it can be used within the RST2 template
3,917
protected function getFederatedAuthenticationInformation ( $ response ) { if ( $ response ) { $ xml = new \ DOMDocument ( ) ; $ xml -> loadXML ( $ response ) ; $ xpath = new \ DOMXPath ( $ xml ) ; if ( $ xpath -> query ( "//STSAuthURL" ) -> length > 0 ) { return $ xpath -> query ( "//STSAuthURL" ) -> item ( 0 ) ; } } r...
Retrieves the STS federated URL if any .
3,918
protected function processSecurityTokenResponse ( $ response ) { $ xml = new \ DOMDocument ( ) ; $ xml -> loadXML ( $ response ) ; $ xpath = new \ DOMXPath ( $ xml ) ; if ( $ xpath -> query ( "//wsse:BinarySecurityToken" ) -> length > 0 ) { $ nodeToken = $ xpath -> query ( "//wsse:BinarySecurityToken" ) -> item ( 0 ) ;...
Verify and extract security token from the HTTP response
3,919
protected function prepareSecurityTokenRequest ( $ username , $ password , $ address ) { $ fileName = __DIR__ . '/xml/SAML.xml' ; if ( ! file_exists ( $ fileName ) ) { throw new \ Exception ( "The file $fileName does not exist" ) ; } $ template = file_get_contents ( $ fileName ) ; $ template = str_replace ( '{username}...
Construct the request body to acquire security token from STS endpoint
3,920
protected function prepareRST2Request ( $ samlAssertion ) { $ fileName = __DIR__ . '/xml/RST2.xml' ; if ( ! file_exists ( $ fileName ) ) { throw new \ Exception ( "The file $fileName does not exist" ) ; } $ template = file_get_contents ( $ fileName ) ; $ xml = new \ DOMDocument ( ) ; $ xml -> loadXML ( $ template ) ; $...
Prepare the request to be sent to RST2 endpoint with the saml assertion
3,921
public function checkIn ( $ comment ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "checkIn" , array ( "comment" => $ comment , "checkintype" => 0 ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Checks the file in to a document library based on the check - in type .
3,922
public function approve ( $ comment ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "approve" , array ( "comment" => $ comment ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Approves the file submitted for content approval with the specified comment .
3,923
public function deny ( $ comment ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "deny" , array ( "comment" => $ comment ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Denies approval for a file that was submitted for content approval .
3,924
public function publish ( $ comment ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "publish" , array ( "comment" => $ comment ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Submits the file for content approval with the specified comment .
3,925
public function unpublish ( $ comment ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "unpublish" , array ( "comment" => $ comment ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Removes the file from content approval or unpublish a major version .
3,926
public function copyTo ( $ strNewUrl , $ bOverWrite ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "copyto" , array ( "strnewurl" => $ strNewUrl , "boverwrite" => $ bOverWrite ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Copies the file to the destination URL .
3,927
public function moveTo ( $ newUrl , $ flags ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "moveto" , array ( "newurl" => $ newUrl , "flags" => $ flags ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Moves the file to the specified destination URL .
3,928
public static function openBinary ( ClientRuntimeContext $ ctx , $ serverRelativeUrl ) { $ serverRelativeUrl = rawurlencode ( $ serverRelativeUrl ) ; $ url = $ ctx -> getServiceRootUrl ( ) . "web/getfilebyserverrelativeurl('$serverRelativeUrl')/\$value" ; $ options = new RequestOptions ( $ url ) ; $ data = $ ctx -> exe...
Opens the file
3,929
public function getLimitedWebPartManager ( $ scope ) { $ manager = new LimitedWebPartManager ( $ this -> getContext ( ) , new ResourcePathServiceOperation ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "getlimitedwebpartmanager" , array ( $ scope ) ) ) ; return $ manager ; }
Specifies the control set used to access modify or add Web Parts associated with this Web Part Page and view . An exception is thrown if the file is not an ASPX page .
3,930
public function getInformationRightsManagementSettings ( ) { if ( ! $ this -> isPropertyAvailable ( 'InformationRightsManagementSettings' ) ) { $ this -> setProperty ( "InformationRightsManagementSettings" , new InformationRightsManagementSettings ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "Informatio...
Returns IRM settings for given file .
3,931
public function getVersions ( ) { if ( ! $ this -> isPropertyAvailable ( 'Versions' ) ) { $ this -> setProperty ( "Versions" , new FileVersionCollection ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "Versions" ) ) ; } return $ this -> getProperty ( "Versions" ) ; }
Gets a value that returns a collection of file version objects that represent the versions of the file .
3,932
public function startUpload ( $ uploadId , $ content ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "StartUpload" , array ( 'uploadId' => $ uploadId -> toString ( ) ) , $ content ) ; $ returnValue = new ClientResult ( ) ; $ this -> getContext ( ) -> addQuery ( $ qry , $ returnValue ) ; return $...
Starts a new chunk upload session and uploads the first fragment
3,933
public function continueUpload ( $ uploadId , $ fileOffset , $ content ) { $ returnValue = new ClientResult ( ) ; $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "ContinueUpload" , array ( 'uploadId' => $ uploadId -> toString ( ) , 'fileOffset' => $ fileOffset ) , $ content ) ; $ this -> getContext ...
Continues the chunk upload session with an additional fragment
3,934
public function finishUpload ( $ uploadId , $ fileOffset , $ content ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "finishupload" , array ( 'uploadId' => $ uploadId -> toString ( ) , 'fileOffset' => $ fileOffset ) , $ content ) ; $ this -> getContext ( ) -> addQuery ( $ qry , $ this ) ; return...
Uploads the last file fragment and commits the file . The current file content is changed when this method completes .
3,935
public function executeQuery ( ) { try { $ request = $ this -> buildRequest ( ) ; if ( is_callable ( $ this -> eventsList [ "BeforeExecuteQuery" ] ) ) { call_user_func_array ( $ this -> eventsList [ "BeforeExecuteQuery" ] , array ( $ request , $ this -> getCurrentAction ( ) ) ) ; } $ responseInfo = array ( ) ; $ respon...
Submit query to OData service
3,936
private function processXmlResponse ( $ response , $ resultObject ) { $ payload = array ( ) ; $ xml = simplexml_load_string ( $ response ) ; $ xml -> registerXPathNamespace ( 'z' , '#RowsetSchema' ) ; $ rows = $ xml -> xpath ( "//z:row" ) ; foreach ( $ rows as $ row ) { $ item = null ; foreach ( $ row -> attributes ( )...
Process Xml response from SharePoint REST service
3,937
private function extractError ( $ response ) { $ error = array ( ) ; $ response = json_decode ( $ response ) ; if ( property_exists ( $ response , 'error' ) ) { if ( is_string ( $ response -> error -> message ) ) { $ message = $ response -> error -> message ; } elseif ( is_object ( $ response -> error -> message ) ) { ...
Extract error from JSON payload response
3,938
public function getByTitle ( $ title ) { return new View ( $ this -> getContext ( ) , new ResourcePathServiceOperation ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "getByTitle" , array ( rawurlencode ( $ title ) ) ) ) ; }
Get View by title
3,939
public function getById ( $ id ) { return new View ( $ this -> getContext ( ) , new ResourcePathServiceOperation ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "getById" , array ( $ id ) ) ) ; }
Get View by id
3,940
public function add ( ViewCreationInformation $ properties ) { $ view = new View ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) ) ; $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , null , null , $ properties ) ; $ this -> getContext ( ) -> addQuery ( $ qry , $ view ) ; $ this -> addChild ...
Creates a View resource
3,941
public function getById ( $ id ) { $ group = new Group ( $ this -> getContext ( ) , new ResourcePathServiceOperation ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "getById" , array ( $ id ) ) ) ; return $ group ; }
Returns a group from the collection based on the member ID of the group .
3,942
public function getByName ( $ name ) { $ group = new Group ( $ this -> getContext ( ) , new ResourcePathServiceOperation ( $ this -> getContext ( ) , $ this -> getResourcePath ( ) , "getbyname" , array ( $ name ) ) ) ; return $ group ; }
Returns a cross - site group from the collection based on the name of the group .
3,943
public function removeByLoginName ( $ groupName ) { $ qry = new InvokePostMethodQuery ( $ this -> getResourcePath ( ) , "removeByLoginName" , array ( $ groupName ) ) ; $ this -> getContext ( ) -> addQuery ( $ qry ) ; }
Removes the cross - site group with the specified name from the collection .
3,944
public function loopPengembalianAkhiran ( ) { $ this -> restorePrefix ( ) ; $ removals = $ this -> removals ; $ reversedRemovals = array_reverse ( $ removals ) ; $ currentWord = $ this -> getCurrentWord ( ) ; foreach ( $ reversedRemovals as $ removal ) { if ( ! $ this -> isSuffixRemoval ( $ removal ) ) { continue ; } i...
ECS Loop Pengembalian Akhiran
3,945
public function restorePrefix ( ) { foreach ( $ this -> removals as $ i => $ removal ) { if ( $ removal -> getAffixType ( ) == 'DP' ) { $ this -> setCurrentWord ( $ removal -> getSubject ( ) ) ; break ; } } foreach ( $ this -> removals as $ i => $ removal ) { if ( $ removal -> getAffixType ( ) == 'DP' ) { unset ( $ thi...
Restore prefix to proceed with ECS loop pengembalian akhiran
3,946
public function addWordsFromTextFile ( $ filePath , $ delimiter = "\n" ) { $ words = explode ( $ delimiter , file_get_contents ( $ filePath ) ) ; $ this -> addWords ( $ words ) ; }
Add words from a text file to the dictionary
3,947
public function remove ( $ text ) { $ words = explode ( ' ' , $ text ) ; foreach ( $ words as $ i => $ word ) { if ( $ this -> dictionary -> contains ( $ word ) ) { unset ( $ words [ $ i ] ) ; } } return implode ( ' ' , $ words ) ; }
Remove stop words .
3,948
public function stem ( $ text ) { $ normalizedText = Filter \ TextNormalizer :: normalizeText ( $ text ) ; $ words = explode ( ' ' , $ normalizedText ) ; $ stems = array ( ) ; foreach ( $ words as $ word ) { $ stems [ ] = $ this -> stemWord ( $ word ) ; } return implode ( ' ' , $ stems ) ; }
Stem a text string to its common stem form .
3,949
protected function stemWord ( $ word ) { if ( $ this -> isPlural ( $ word ) ) { return $ this -> stemPluralWord ( $ word ) ; } else { return $ this -> stemSingularWord ( $ word ) ; } }
Stem a word to its common stem form .
3,950
protected function stemSingularWord ( $ word ) { $ context = new Context ( $ word , $ this -> dictionary , $ this -> visitorProvider ) ; $ context -> execute ( ) ; return $ context -> getResult ( ) ; }
Stem a singular word to its common stem form .
3,951
public static function normalizeText ( $ text ) { $ text = strtolower ( $ text ) ; $ text = preg_replace ( '/[^a-z0-9 -]/im' , ' ' , $ text ) ; $ text = preg_replace ( '/( +)/im' , ' ' , $ text ) ; return trim ( $ text ) ; }
Removes symbols & characters other than alphabetics
3,952
public function connect ( $ configExternal ) { $ wsdl = $ configExternal -> get ( 'salesforce.wsdl' ) ; if ( empty ( $ wsdl ) ) { $ wsdl = __DIR__ . '/Wsdl/enterprise.wsdl.xml' ; } $ user = $ configExternal -> get ( 'salesforce.username' ) ; $ pass = $ configExternal -> get ( 'salesforce.password' ) ; $ token = $ confi...
Connect user into salesforce
3,953
public function getPermissionsAttribute ( $ permissions ) { if ( ! $ permissions ) { return array ( ) ; } if ( is_array ( $ permissions ) ) { return $ permissions ; } if ( ! $ _permissions = json_decode ( $ permissions , true ) ) { throw new \ InvalidArgumentException ( "Cannot JSON decode permissions [$permissions]." ...
Mutator for giving permissions .
3,954
public function validate ( ) { if ( ! $ login = $ this -> { static :: $ loginAttribute } ) { throw new LoginRequiredException ( "A login is required for a user, none given." ) ; } if ( ! $ password = $ this -> getPassword ( ) ) { throw new PasswordRequiredException ( "A password is required for user [$login], none give...
Validates the user and throws a number of Exceptions if validation fails .
3,955
public function attemptResetPassword ( $ resetCode , $ newPassword ) { if ( $ this -> checkResetPasswordCode ( $ resetCode ) ) { $ this -> password = $ newPassword ; $ this -> reset_password_code = null ; return $ this -> save ( ) ; } return false ; }
Attempts to reset a user s password by matching the reset code generated with the user s .
3,956
public function inGroup ( GroupInterface $ group ) { foreach ( $ this -> getGroups ( ) as $ _group ) { if ( $ _group -> getId ( ) == $ group -> getId ( ) ) { return true ; } } return false ; }
See if the user is in the given group .
3,957
public function getConnection ( ) { if ( $ this -> connection === null ) { $ connection = null ; switch ( $ this -> driverName ) { case 'mysql' : $ connection = '\Illuminate\Database\MySqlConnection' ; break ; case 'pgsql' : $ connection = '\Illuminate\Database\PostgresConnection' ; break ; case 'sqlsrv' : $ connection...
Returns the database connection .
3,958
public function findByUser ( UserInterface $ user , $ ipAddress = null ) { $ model = $ this -> createModel ( ) ; $ query = $ model -> where ( 'user_id' , '=' , ( $ userId = $ user -> getId ( ) ) ) ; if ( $ ipAddress ) { $ query -> where ( function ( $ query ) use ( $ ipAddress ) { $ query -> where ( 'ip_address' , '=' ...
Finds a throttler by the given Model .
3,959
public function findByUserLogin ( $ login , $ ipAddress = null ) { return $ this -> findByUser ( $ this -> userProvider -> findByLogin ( $ login ) , $ ipAddress ) ; }
Finds a throttling interface by the given user login .
3,960
public function register ( array $ credentials , $ activate = false ) { $ user = $ this -> userProvider -> create ( $ credentials ) ; if ( $ activate ) { $ user -> attemptActivation ( $ user -> getActivationCode ( ) ) ; } return $ this -> user = $ user ; }
Registers a user by giving the required credentials and an optional flag for whether to activate the user .
3,961
public function check ( ) { if ( is_null ( $ this -> user ) ) { if ( ! $ userArray = $ this -> session -> get ( ) and ! $ userArray = $ this -> cookie -> get ( ) ) { return false ; } if ( ! is_array ( $ userArray ) or count ( $ userArray ) !== 2 ) { return false ; } list ( $ id , $ persistCode ) = $ userArray ; try { $...
Check to see if the user is logged in and activated and hasn t been banned or suspended .
3,962
public function login ( UserInterface $ user , $ remember = false ) { if ( ! $ user -> isActivated ( ) ) { $ login = $ user -> getLogin ( ) ; throw new UserNotActivatedException ( "Cannot login user [$login] as they are not activated." ) ; } $ this -> user = $ user ; $ toPersist = array ( $ user -> getId ( ) , $ user -...
Logs in the given user and sets properties in the session .
3,963
public function clearLoginAttempts ( ) { if ( $ this -> getLoginAttempts ( ) == 0 or $ this -> suspended ) { return ; } $ this -> attempts = 0 ; $ this -> last_attempt_at = null ; $ this -> suspended = false ; $ this -> suspended_at = null ; $ this -> save ( ) ; }
Clear all login attempts
3,964
public function unsuspend ( ) { if ( $ this -> suspended ) { $ this -> attempts = 0 ; $ this -> last_attempt_at = null ; $ this -> suspended = false ; $ this -> suspended_at = null ; $ this -> save ( ) ; } }
Unsuspend the user .
3,965
public function isSuspended ( ) { if ( $ this -> suspended and $ this -> suspended_at ) { $ this -> removeSuspensionIfAllowed ( ) ; return ( bool ) $ this -> suspended ; } return false ; }
Check if the user is suspended .
3,966
public function unban ( ) { if ( $ this -> banned ) { $ this -> banned = false ; $ this -> banned_at = null ; $ this -> save ( ) ; } }
Unban the user .
3,967
public function removeSuspensionIfAllowed ( ) { $ suspended = new DateTime ( $ this -> suspended_at ) ; $ suspensionTime = static :: $ suspensionTime ; $ unsuspendAt = $ suspended -> modify ( "+{$suspensionTime} minutes" ) ; $ now = new DateTime ; if ( $ unsuspendAt <= $ now ) { $ this -> unsuspend ( ) ; } unset ( $ su...
Inspects to see if the user can become unsuspended or not based on the suspension time provided . If so unsuspends .
3,968
public function getRemainingSuspensionTime ( ) { if ( ! $ this -> isSuspended ( ) ) return 0 ; $ lastAttempt = clone $ this -> last_attempt_at ; $ suspensionTime = static :: $ suspensionTime ; $ clearAttemptsAt = $ lastAttempt -> modify ( "+{$suspensionTime} minutes" ) ; $ now = new Datetime ; $ timeLeft = $ clearAttem...
Get the remaining time on a suspension in minutes rounded up . Returns 0 if user is not suspended .
3,969
public function findAllInGroup ( GroupInterface $ group ) { return array_filter ( $ this -> findAll ( ) , function ( $ user ) use ( $ group ) { return $ user -> inGroup ( $ group ) ; } ) ; }
Returns all users who belong to a group .
3,970
public function delete ( ) { \ DB :: delete ( 'users_groups' ) -> where ( 'group_id' , '=' , $ this -> pk ( ) ) -> execute ( $ this -> _db ) ; return parent :: delete ( ) ; }
Delete the group .
3,971
public function unique_key_exists ( $ value , $ field ) { $ total = \ DB :: select ( array ( \ DB :: expr ( 'COUNT(*)' ) , 'total_count' ) ) -> from ( $ this -> _table_name ) -> where ( $ field , '=' , $ value ) -> where ( $ this -> _primary_key , '!=' , $ this -> pk ( ) ) -> execute ( $ this -> _db ) -> get ( 'total_c...
Tests if a unique key value exists in the database .
3,972
public function forever ( $ value ) { $ cookie = $ this -> jar -> forever ( $ this -> getKey ( ) , $ value ) ; $ this -> jar -> queue ( $ cookie ) ; }
Put a value in the Sentry cookie forever .
3,973
public function get ( ) { $ key = $ this -> getKey ( ) ; $ queued = $ this -> jar -> getQueuedCookies ( ) ; if ( isset ( $ queued [ $ key ] ) ) { return $ queued [ $ key ] ; } if ( $ this -> strategy === 'request' ) { return $ this -> request -> cookie ( $ key ) ; } else { return $ this -> jar -> get ( $ key ) ; } }
Get the Sentry cookie value .
3,974
public function forget ( ) { $ cookie = $ this -> jar -> forget ( $ this -> getKey ( ) ) ; $ this -> jar -> queue ( $ cookie ) ; }
Remove the Sentry cookie .
3,975
public function attemptActivation ( $ activationCode ) { if ( $ this -> activated ) { throw new UserAlreadyActivatedException ( 'Cannot attempt activation on an already activated user.' ) ; } if ( $ activationCode == $ this -> activation_code ) { $ this -> activation_code = null ; $ this -> activated = true ; $ this ->...
Attempts to activate the given user by checking the activate code . If the user is activated already an Exception is thrown .
3,976
public static function createSentry ( UserProviderInterface $ userProvider = null , GroupProviderInterface $ groupProvider = null , ThrottleProviderInterface $ throttleProvider = null , SessionInterface $ session = null , CookieInterface $ cookie = null , $ ipAddress = null ) { $ userProvider = $ userProvider ? : new U...
Creates a Sentry instance .
3,977
public static function setupDatabaseResolver ( PDO $ pdo , $ driverName = null , $ tablePrefix = '' ) { if ( class_exists ( 'Illuminate\Database\Eloquent\Model' ) ) { if ( is_null ( $ driverName ) ) { $ driverName = $ pdo -> getAttribute ( PDO :: ATTR_DRIVER_NAME ) ; } Eloquent :: setConnectionResolver ( new Connection...
Sets up the Eloquent Connection Resolver with the given PDO connection .
3,978
public static function guessIpAddress ( ) { foreach ( array ( 'HTTP_CLIENT_IP' , 'HTTP_X_FORWARDED_FOR' , 'HTTP_X_FORWARDED' , 'HTTP_X_CLUSTER_CLIENT_IP' , 'HTTP_FORWARDED_FOR' , 'HTTP_FORWARDED' , 'REMOTE_ADDR' ) as $ key ) { if ( array_key_exists ( $ key , $ _SERVER ) === true ) { foreach ( explode ( ',' , $ _SERVER ...
Looks through various server properties in an attempt to guess the client s IP address .
3,979
public function setCookie ( $ value , $ lifetime , $ path = null , $ domain = null , $ secure = null , $ httpOnly = null ) { if ( ! isset ( $ path ) ) $ path = $ this -> defaults [ 'path' ] ; if ( ! isset ( $ domain ) ) $ domain = $ this -> defaults [ 'domain' ] ; if ( ! isset ( $ secure ) ) $ secure = $ this -> defaul...
Actually sets the cookie .
3,980
protected function parseMigrationDefinitionData ( $ data , MigrationDefinition $ definition , $ format = 'Yaml' ) { $ status = MigrationDefinition :: STATUS_PARSED ; if ( ! is_array ( $ data ) ) { $ status = MigrationDefinition :: STATUS_INVALID ; $ message = "$format migration file '{$definition->path}' must contain a...
Parses a migration definition in the form of an array of steps
3,981
protected function getConditionsFromKey ( $ key ) { if ( is_int ( $ key ) || ctype_digit ( $ key ) ) { return array ( self :: MATCH_USERGROUP_ID => $ key ) ; } return array ( self :: MATCH_CONTENT_REMOTE_ID => $ key ) ; }
When matching by key we accept user group Id and it s remote Id only
3,982
protected function create ( $ step ) { foreach ( array ( 'object_state_group' , 'names' , 'identifier' ) as $ key ) { if ( ! isset ( $ step -> dsl [ $ key ] ) ) { throw new \ Exception ( "The '$key' key is missing in a object state creation definition" ) ; } } if ( ! count ( $ step -> dsl [ 'names' ] ) ) { throw new \ ...
Handles the create step of object state migrations .
3,983
protected function update ( $ step ) { $ stateCollection = $ this -> matchObjectStates ( 'update' , $ step ) ; if ( count ( $ stateCollection ) > 1 && array_key_exists ( 'references' , $ step -> dsl ) ) { throw new \ Exception ( "Can not execute Object State update because multiple states match, and a references sectio...
Handles the update step of object state migrations .
3,984
protected function delete ( $ step ) { $ stateCollection = $ this -> matchObjectStates ( 'delete' , $ step ) ; $ this -> setReferences ( $ stateCollection , $ step ) ; $ objectStateService = $ this -> repository -> getObjectStateService ( ) ; foreach ( $ stateCollection as $ state ) { $ objectStateService -> deleteObje...
Handles the deletion step of object state migrations .
3,985
protected function recover ( $ step ) { $ itemsCollection = $ this -> matchItems ( 'restore' , $ step ) ; if ( count ( $ itemsCollection ) > 1 && array_key_exists ( 'references' , $ step -> dsl ) ) { throw new \ Exception ( "Can not execute Trash restore because multiple items match, and a references section is specifi...
Handles the trash - restore migration action
3,986
protected function delete ( $ step ) { $ itemsCollection = $ this -> matchItems ( 'delete' , $ step ) ; $ this -> setReferences ( $ itemsCollection , $ step ) ; $ trashService = $ this -> repository -> getTrashService ( ) ; foreach ( $ itemsCollection as $ key => $ item ) { $ trashService -> deleteTrashItem ( $ item ) ...
Handles the trash - delete migration action
3,987
protected function validateConditions ( array $ conditions ) { foreach ( $ conditions as $ key => $ val ) { if ( $ this -> referenceResolver -> isReference ( $ key ) ) { return true ; } } return parent :: validateConditions ( $ conditions ) ; }
condition would be taken into account ...
3,988
protected function assignRole ( Role $ role , RoleService $ roleService , UserService $ userService , array $ assignments ) { foreach ( $ assignments as $ assign ) { switch ( $ assign [ 'type' ] ) { case 'user' : foreach ( $ assign [ 'ids' ] as $ userId ) { $ userId = $ this -> referenceResolver -> resolveReference ( $...
Assign a role to users and groups in the assignment array .
3,989
public function hashToFieldValue ( $ fieldValue , array $ context = array ( ) ) { $ altText = '' ; $ fileName = '' ; if ( $ fieldValue === null ) { return new ImageValue ( ) ; } else if ( is_string ( $ fieldValue ) ) { $ filePath = $ fieldValue ; } else { $ filePath = $ fieldValue [ 'path' ] ; if ( isset ( $ fieldValue...
Creates a value object to use as the field value when setting an image field type .
3,990
protected function getConditionsFromKey ( $ key ) { if ( is_int ( $ key ) || ctype_digit ( $ key ) ) { return array ( self :: MATCH_LOCATION_ID => $ key ) ; } return array ( self :: MATCH_LOCATION_REMOTE_ID => $ key ) ; }
When matching by key we accept location Id and remote Id only
3,991
public function getReferenceValue ( $ identifier ) { $ identifier = $ this -> getReferenceIdentifier ( $ identifier ) ; if ( ! array_key_exists ( $ identifier , $ this -> references ) ) { throw new \ Exception ( "No reference set with identifier '$identifier'" ) ; } return $ this -> references [ $ identifier ] ; }
Get a stored reference
3,992
public function addReference ( $ identifier , $ value , $ overwrite = false ) { if ( array_key_exists ( $ identifier , $ this -> references ) && ! $ overwrite ) { throw new \ Exception ( "A reference with identifier '$identifier' already exists" ) ; } $ this -> references [ $ identifier ] = $ value ; return true ; }
Add a reference to be retrieved later .
3,993
public function getMigrations ( $ limit = null , $ offset = null ) { return $ this -> storageHandler -> loadMigrations ( $ limit , $ offset ) ; }
Returns the list of all the migrations which where executed or attempted so far
3,994
public function getMigrationsByStatus ( $ status , $ limit = null , $ offset = null ) { return $ this -> storageHandler -> loadMigrationsByStatus ( $ status , $ limit , $ offset ) ; }
Returns the list of all the migrations in a given status which where executed or attempted so far
3,995
public function parseMigrationDefinition ( MigrationDefinition $ migrationDefinition ) { foreach ( $ this -> DefinitionParsers as $ definitionParser ) { if ( $ definitionParser -> supports ( $ migrationDefinition -> name ) ) { $ migrationDefinition = $ definitionParser -> parseMigrationDefinition ( $ migrationDefinitio...
Parses a migration definition return a parsed definition . If there is a parsing error the definition status will be updated accordingly
3,996
private function getLegacyMigrationDefinition ( $ version , $ bundle ) { if ( ! isset ( $ this -> activeBundles [ $ bundle ] ) ) { return false ; } $ versionsDir = $ this -> activeBundles [ $ bundle ] . '/' . $ this -> legacyMigrationsDir ; $ versionDefinitions = glob ( $ versionsDir . "/$version*" ) ; if ( ! is_array ...
Attempts to find the migration definition file . If more than one matches the 1st found is returned
3,997
protected function getDBFromFile ( $ fileName ) { $ parts = explode ( '_' , preg_replace ( '/\.sql$/' , '' , $ fileName ) ) ; return isset ( $ parts [ 1 ] ) ? $ parts [ 1 ] : null ; }
allow both aaaa_mysql_etc . sql and aaaa_mysql . sql
3,998
public function hashToFieldValue ( $ fieldValue , array $ context = array ( ) ) { if ( is_string ( $ fieldValue ) ) { $ xmlText = $ fieldValue ; } else if ( is_array ( $ fieldValue ) && isset ( $ fieldValue [ 'xml' ] ) ) { $ xmlText = $ fieldValue [ 'xml' ] ; } else { $ xmlText = $ fieldValue [ 'content' ] ; } $ resolv...
Replaces any references in an xml string to be used as the input data for an ezxmltext field .
3,999
protected function create ( $ step ) { if ( ! isset ( $ step -> dsl [ 'groups' ] ) ) { throw new \ Exception ( 'No user groups set to create user in.' ) ; } if ( ! is_array ( $ step -> dsl [ 'groups' ] ) ) { $ step -> dsl [ 'groups' ] = array ( $ step -> dsl [ 'groups' ] ) ; } $ userService = $ this -> repository -> ge...
Creates a user based on the DSL instructions .