idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
53,000
protected function cleanupCacheDirs ( ) { if ( ( $ benchmark = ! empty ( $ this -> options [ 'benchmark' ] ) && $ this -> options [ 'benchmark' ] === 'details' ) ) { $ time = microtime ( true ) ; } $ public_cache_dir = $ this -> cacheDir ( $ this :: DIR_PUBLIC_TYPE ) ; $ private_cache_dir = $ this -> cacheDir ( $ this :: DIR_PRIVATE_TYPE ) ; $ min_mtime = strtotime ( '-' . $ this -> cache_expiration_time ) ; foreach ( $ this -> dirRegexIteration ( $ public_cache_dir , '/\/compressor\-part\..*$/' ) as $ _dir_file ) { if ( ( $ _dir_file -> isFile ( ) || $ _dir_file -> isLink ( ) ) && $ _dir_file -> getMTime ( ) < $ min_mtime - 3600 ) { if ( $ _dir_file -> isWritable ( ) ) { unlink ( $ _dir_file -> getPathname ( ) ) ; } } } foreach ( $ this -> dirRegexIteration ( $ private_cache_dir , '/\/compressor\-parts\..*$/' ) as $ _dir_file ) { if ( ( $ _dir_file -> isFile ( ) || $ _dir_file -> isLink ( ) ) && $ _dir_file -> getMTime ( ) < $ min_mtime ) { if ( $ _dir_file -> isWritable ( ) ) { unlink ( $ _dir_file -> getPathname ( ) ) ; } } } if ( $ benchmark && ! empty ( $ time ) ) { $ this -> benchmark -> addTime ( __FUNCTION__ , $ time , 'cleaning up the public/private cache directories' ) ; } }
Cache cleanup routine .
53,001
protected function dirRegexIteration ( $ dir , $ regex ) { $ dir = ( string ) $ dir ; $ regex = ( string ) $ regex ; $ dir_iterator = new \ RecursiveDirectoryIterator ( $ dir , \ FilesystemIterator :: KEY_AS_PATHNAME | \ FilesystemIterator :: CURRENT_AS_SELF | \ FilesystemIterator :: SKIP_DOTS | \ FilesystemIterator :: UNIX_PATHS ) ; $ iterator_iterator = new \ RecursiveIteratorIterator ( $ dir_iterator , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; $ regex_iterator = new \ RegexIterator ( $ iterator_iterator , $ regex , \ RegexIterator :: MATCH , \ RegexIterator :: USE_KEY ) ; return $ regex_iterator ; }
Regex directory iterator .
53,002
protected function currentUrlSsl ( ) { if ( isset ( static :: $ static [ __FUNCTION__ ] ) ) { return static :: $ static [ __FUNCTION__ ] ; } if ( ! empty ( $ _SERVER [ 'SERVER_PORT' ] ) ) { if ( ( int ) $ _SERVER [ 'SERVER_PORT' ] === 443 ) { return static :: $ static [ __FUNCTION__ ] = true ; } } if ( ! empty ( $ _SERVER [ 'HTTPS' ] ) ) { if ( filter_var ( $ _SERVER [ 'HTTPS' ] , FILTER_VALIDATE_BOOLEAN ) ) { return static :: $ static [ __FUNCTION__ ] = true ; } } if ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) ) { if ( strcasecmp ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] , 'https' ) === 0 ) { return static :: $ static [ __FUNCTION__ ] = true ; } } return static :: $ static [ __FUNCTION__ ] = false ; }
Is the current request over SSL?
53,003
protected function isCurrentUrlUriExcluded ( ) { if ( $ this -> regex_uri_exclusions && preg_match ( $ this -> regex_uri_exclusions , $ this -> currentUrlUri ( ) ) ) { return true ; } elseif ( $ this -> built_in_regex_uri_exclusions && preg_match ( $ this -> built_in_regex_uri_exclusions , $ this -> currentUrlUri ( ) ) ) { return true ; } return false ; }
Current URI is excluded?
53,004
protected function currentUrl ( ) { if ( isset ( static :: $ static [ __FUNCTION__ ] ) ) { return static :: $ static [ __FUNCTION__ ] ; } $ url = $ this -> currentUrlScheme ( ) . '://' ; $ url .= $ this -> currentUrlHost ( ) ; $ url .= $ this -> currentUrlUri ( ) ; return static :: $ static [ __FUNCTION__ ] = $ url ; }
URL to current request .
53,005
protected function nUrlScheme ( $ scheme ) { if ( ! ( $ scheme = ( string ) $ scheme ) ) { return $ scheme ; } if ( mb_strpos ( $ scheme , ':' ) !== false ) { $ scheme = strstr ( $ scheme , ':' , true ) ; } return mb_strtolower ( $ scheme ) ; }
Normalizes a URL scheme .
53,006
protected function setUrlScheme ( $ url , $ scheme = '' ) { if ( ! ( $ url = ( string ) $ url ) ) { return $ url ; } $ scheme = ( string ) $ scheme ; if ( ! $ scheme ) { $ scheme = $ this -> currentUrlScheme ( ) ; } if ( $ scheme !== '//' ) { $ scheme = $ this -> nUrlScheme ( $ scheme ) . '://' ; } return preg_replace ( '/^(?:[a-z0-9]+\:)?\/\//ui' , $ this -> escRefs ( $ scheme ) , $ url ) ; }
Sets a particular scheme .
53,007
protected function isUrlExternal ( $ url_uri_query_fragment ) { if ( mb_strpos ( $ url_uri_query_fragment , '//' ) === false ) { return false ; } return mb_stripos ( $ url_uri_query_fragment , '//' . $ this -> currentUrlHost ( ) ) === false ; }
Checks if a given URL is local or external to the current host .
53,008
protected function resolveRelativeUrl ( $ relative_url_uri_query_fragment , $ base_url = '' ) { $ relative_url_uri_query_fragment = ( string ) $ relative_url_uri_query_fragment ; $ base_url = ( string ) $ base_url ; if ( ! $ base_url ) { $ base_url = $ this -> currentUrl ( ) ; } $ relative_parts = $ this -> mustParseUrl ( $ relative_url_uri_query_fragment , null , 0 ) ; $ relative_parts [ 'path' ] = $ this -> nUrlPathSeps ( $ relative_parts [ 'path' ] , true ) ; $ base_parts = $ parts = $ this -> mustParseUrl ( $ base_url ) ; if ( $ relative_parts [ 'host' ] ) { if ( ! $ relative_parts [ 'scheme' ] ) { $ relative_parts [ 'scheme' ] = $ base_parts [ 'scheme' ] ; } return $ this -> mustUnparseUrl ( $ relative_parts ) ; } if ( ! $ base_parts [ 'host' ] ) { throw new \ Exception ( sprintf ( 'Unable to parse (missing base host name): `%1$s`.' , $ base_url ) ) ; } if ( isset ( $ relative_parts [ 'path' ] [ 0 ] ) ) { if ( mb_strpos ( $ relative_parts [ 'path' ] , '/' ) === 0 ) { $ parts [ 'path' ] = '' ; } else { $ parts [ 'path' ] = preg_replace ( '/\/[^\/]*$/u' , '' , $ parts [ 'path' ] ) . '/' ; } for ( $ _i = 1 , $ parts [ 'path' ] = $ parts [ 'path' ] . $ relative_parts [ 'path' ] ; $ _i > 0 ; ) { $ parts [ 'path' ] = preg_replace ( [ '/\/\.\//u' , '/\/(?!\.\.)[^\/]+\/\.\.\//u' ] , '/' , $ parts [ 'path' ] , - 1 , $ _i ) ; } $ parts [ 'path' ] = str_replace ( '../' , '' , $ parts [ 'path' ] ) ; $ parts [ 'query' ] = $ relative_parts [ 'query' ] ; } elseif ( isset ( $ relative_parts [ 'query' ] [ 0 ] ) ) { $ parts [ 'query' ] = $ relative_parts [ 'query' ] ; } $ parts [ 'fragment' ] = $ relative_parts [ 'fragment' ] ; return $ this -> mustUnparseUrl ( $ parts ) ; }
Resolves a relative URL into a full URL from a base .
53,009
public function blockFencedCodeComplete ( $ block ) { $ text = print_r ( $ block , true ) ; $ matches = array ( ) ; preg_match ( '/\[class\] => language-([a-zA-Z]+)/' , $ text , $ matches ) ; if ( count ( $ matches ) > 1 && $ matches [ 1 ] === 'shell' ) { $ block [ 'element' ] [ 'text' ] [ 'text' ] = $ this -> minimalHighlighter -> highlight ( $ block [ 'element' ] [ 'text' ] [ 'text' ] ) ; } else { $ block [ 'element' ] [ 'text' ] [ 'text' ] = $ this -> highlighter -> highlight ( $ block [ 'element' ] [ 'text' ] [ 'text' ] ) ; } return $ block ; }
Use new highlighters for code blocks .
53,010
public function getAtom ( User $ user , $ key , bool $ detachFromEntityManager = true ) { if ( $ atom = $ this -> getRepository ( ) -> findOneBy ( [ 'user_id' => $ user -> getId ( ) , 'key' => $ key ] ) ) { if ( $ detachFromEntityManager ) { $ this -> getEntityManager ( ) -> detach ( $ atom ) ; } return $ atom ; } return null ; }
Get an atomic piece of user data
53,011
public function setAtom ( User $ user , $ key , $ value ) { $ conn = $ this -> getEntityManager ( ) -> getConnection ( ) ; $ stmt = $ conn -> prepare ( 'INSERT INTO users_atoms ( user_id, `key`, `value`) VALUES( ?, ?, ? ) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)' ) ; $ user_id = $ user -> getId ( ) ; $ stmt -> bindParam ( 1 , $ user_id ) ; $ stmt -> bindParam ( 2 , $ key ) ; $ stmt -> bindParam ( 3 , $ value ) ; $ stmt -> execute ( ) ; }
Set a particular atom on a user
53,012
public function search ( string $ key , string $ value ) { return $ this -> getRepository ( ) -> findBy ( [ 'key' => $ key , 'value' => $ value ] ) ; }
Key - value pair search .
53,013
public function create ( User $ user , $ username , $ password ) { $ this -> authenticationService -> create ( $ user , $ username , $ password ) ; }
Give me a user and password and I ll create authentication records for you
53,014
public function createProject ( $ projectData , $ format = 'php' , $ odm = null ) { $ data = array ( 'token' => $ this -> superToken , 'content' => 'project' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ projectData , 'projectData' , $ format ) ; if ( isset ( $ odm ) ) { $ data [ 'odm' ] = $ this -> processOdmArgument ( $ odm ) ; } $ apiToken = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ apiToken ) ; $ connection = clone $ this -> connection ; $ errorHandler = clone $ this -> errorHandler ; $ projectConstructorCallback = $ this -> projectConstructorCallback ; $ project = call_user_func ( $ projectConstructorCallback , $ apiUrl = null , $ apiToken , $ sslVerify = null , $ caCertificateFile = null , $ errorHandler , $ connection ) ; return $ project ; }
Creates a REDCap project with the specified data .
53,015
public function getProject ( $ apiToken ) { $ apiToken = $ this -> processApiTokenArgument ( $ apiToken ) ; $ connection = clone $ this -> connection ; $ errorHandler = clone $ this -> errorHandler ; $ projectConstructorCallback = $ this -> projectConstructorCallback ; $ project = call_user_func ( $ projectConstructorCallback , $ apiUrl = null , $ apiToken , $ sslVerify = null , $ caCertificateFile = null , $ errorHandler , $ connection ) ; return $ project ; }
Gets the REDCap project for the specified API token .
53,016
private function httpBuildQuery ( $ params ) { $ query = [ ] ; foreach ( $ params as $ key => $ param ) { if ( ! is_array ( $ param ) ) { continue ; } foreach ( $ param as $ subParam ) { $ query [ ] = http_build_query ( [ $ key => $ subParam ] ) ; } unset ( $ params [ $ key ] ) ; } $ query [ ] = http_build_query ( $ params ) ; $ query = implode ( '&' , $ query ) ; return $ query ; }
Create a query string
53,017
public function getInheritanceList ( ) : array { $ roleList = [ $ this ] ; $ role = $ this ; while ( $ parentRole = $ role -> getParent ( ) ) { $ roleList [ ] = $ parentRole ; $ role = $ parentRole ; } return $ roleList ; }
Return all inherited roles including the start role in this to - root traversal .
53,018
function it_can_grant_access_to_roles_by_appending_actions ( $ resourceObject , $ groupRules , $ groupActionRule ) { $ role = $ this -> getRoleWithName ( 'user' ) ; $ groupRules -> update ( Argument :: any ( ) ) -> shouldBeCalled ( ) ; $ groupActionRule -> addAction ( 'foo' ) -> shouldBeCalled ( ) ; $ this -> grantRoleAccess ( $ role , $ resourceObject , 'foo' ) ; }
Give a role access to a resource
53,019
public function exportArms ( $ format = 'php' , $ arms = [ ] ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'arm' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'arms' ] = $ this -> processArmsArgument ( $ arms ) ; $ arms = $ this -> connection -> callWithArray ( $ data ) ; $ arms = $ this -> processExportResult ( $ arms , $ format ) ; return $ arms ; }
Exports the numbers and names of the arms in the project .
53,020
public function importArms ( $ arms , $ format = 'php' , $ override = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'arm' , 'action' => 'import' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ arms , 'arms' , $ format ) ; $ data [ 'override' ] = $ this -> processOverrideArgument ( $ override ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return ( integer ) $ result ; }
Imports the specified arms into the project .
53,021
public function deleteArms ( $ arms ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'arm' , 'action' => 'delete' , 'returnFormat' => 'json' , ) ; $ data [ 'arms' ] = $ this -> processArmsArgument ( $ arms , $ required = true ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return ( integer ) $ result ; }
Deletes the specified arms from the project .
53,022
public function exportEvents ( $ format = 'php' , $ arms = [ ] ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'event' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'arms' ] = $ this -> processArmsArgument ( $ arms ) ; $ events = $ this -> connection -> callWithArray ( $ data ) ; $ events = $ this -> processExportResult ( $ events , $ format ) ; return $ events ; }
Exports information about the specified events .
53,023
public function importEvents ( $ events , $ format = 'php' , $ override = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'event' , 'action' => 'import' , 'returnFormat' => 'json' ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ events , 'arms' , $ format ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'override' ] = $ this -> processOverrideArgument ( $ override ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return ( integer ) $ result ; }
Imports the specified events into the project .
53,024
public function deleteEvents ( $ events ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'event' , 'action' => 'delete' , 'returnFormat' => 'json' , ) ; $ data [ 'events' ] = $ this -> processEventsArgument ( $ events , $ required = true ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return ( integer ) $ result ; }
Deletes the specified events from the project .
53,025
public function exportFieldNames ( $ format = 'php' , $ field = null ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'exportFieldNames' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'field' ] = $ this -> processFieldArgument ( $ field , $ required = false ) ; $ fieldNames = $ this -> connection -> callWithArray ( $ data ) ; $ fieldNames = $ this -> processExportResult ( $ fieldNames , $ format ) ; return $ fieldNames ; }
Exports the fields names for a project .
53,026
public function exportFile ( $ recordId , $ field , $ event = null , $ repeatInstance = null ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'file' , 'action' => 'export' , 'returnFormat' => 'json' ) ; $ data [ 'record' ] = $ this -> processRecordIdArgument ( $ recordId ) ; $ data [ 'field' ] = $ this -> processFieldArgument ( $ field ) ; $ data [ 'event' ] = $ this -> processEventArgument ( $ event ) ; $ data [ 'repeat_instance' ] = $ this -> processRepeatInstanceArgument ( $ repeatInstance ) ; $ file = $ this -> connection -> callWithArray ( $ data ) ; $ file = $ this -> processExportResult ( $ file , $ format = 'file' ) ; return $ file ; }
Exports the specified file .
53,027
public function deleteFile ( $ recordId , $ field , $ event = null , $ repeatInstance = null ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'file' , 'action' => 'delete' , 'returnFormat' => 'json' ) ; $ data [ 'record' ] = $ this -> processRecordIdArgument ( $ recordId ) ; $ data [ 'field' ] = $ this -> processFieldArgument ( $ field ) ; $ data [ 'event' ] = $ this -> processEventArgument ( $ event ) ; $ data [ 'repeat_instance' ] = $ this -> processRepeatInstanceArgument ( $ repeatInstance ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return $ result ; }
Deletes the specified file .
53,028
public function exportInstrumentEventMappings ( $ format = 'php' , $ arms = [ ] ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'formEventMapping' , 'format' => 'json' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'arms' ] = $ this -> processArmsArgument ( $ arms ) ; $ instrumentEventMappings = $ this -> connection -> callWithArray ( $ data ) ; $ instrumentEventMappings = $ this -> processExportResult ( $ instrumentEventMappings , $ format ) ; return $ instrumentEventMappings ; }
Gets the instrument to event mapping for the project .
53,029
public function importInstrumentEventMappings ( $ mappings , $ format = 'php' ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'formEventMapping' , 'returnFormat' => 'json' ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ mappings , 'mappings' , $ format ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return ( integer ) $ result ; }
Imports the specified instrument - event mappings into the project .
53,030
public function exportMetadata ( $ format = 'php' , $ fields = [ ] , $ forms = [ ] ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'metadata' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'forms' ] = $ this -> processFormsArgument ( $ forms ) ; $ data [ 'fields' ] = $ this -> processFieldsArgument ( $ fields ) ; $ metadata = $ this -> connection -> callWithArray ( $ data ) ; $ metadata = $ this -> processExportResult ( $ metadata , $ format ) ; return $ metadata ; }
Exports metadata about the project i . e . information about the fields in the project .
53,031
public function exportProjectXml ( $ returnMetadataOnly = false , $ recordIds = null , $ fields = null , $ events = null , $ filterLogic = null , $ exportSurveyFields = false , $ exportDataAccessGroups = false , $ exportFiles = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'project_xml' , 'returnFormat' => 'json' ) ; $ data [ 'returnMetadataOnly' ] = $ this -> processReturnMetadataOnlyArgument ( $ returnMetadataOnly ) ; $ data [ 'records' ] = $ this -> processRecordIdsArgument ( $ recordIds ) ; $ data [ 'fields' ] = $ this -> processFieldsArgument ( $ fields ) ; $ data [ 'events' ] = $ this -> processEventsArgument ( $ events ) ; $ data [ 'filterLogic' ] = $ this -> processFilterLogicArgument ( $ filterLogic ) ; $ data [ 'exportSurveyFields' ] = $ this -> processExportSurveyFieldsArgument ( $ exportSurveyFields ) ; $ data [ 'exportDataAccessGroups' ] = $ this -> processExportDataAccessGroupsArgument ( $ exportDataAccessGroups ) ; $ data [ 'exportFiles' ] = $ this -> processExportFilesArgument ( $ exportFiles ) ; $ projectXml = $ this -> connection -> callWithArray ( $ data ) ; $ projectXml = $ this -> processExportResult ( $ projectXml , $ format = 'xml' ) ; return $ projectXml ; }
Exports the specified information of project in XML format .
53,032
public function exportRecords ( $ format = 'php' , $ type = 'flat' , $ recordIds = null , $ fields = null , $ forms = null , $ events = null , $ filterLogic = null , $ rawOrLabel = 'raw' , $ rawOrLabelHeaders = 'raw' , $ exportCheckboxLabel = false , $ exportSurveyFields = false , $ exportDataAccessGroups = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'record' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'php' , 'csv' , 'json' , 'xml' , 'odm' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'type' ] = $ this -> processTypeArgument ( $ type ) ; $ data [ 'records' ] = $ this -> processRecordIdsArgument ( $ recordIds ) ; $ data [ 'fields' ] = $ this -> processFieldsArgument ( $ fields ) ; $ data [ 'forms' ] = $ this -> processFormsArgument ( $ forms ) ; $ data [ 'events' ] = $ this -> processEventsArgument ( $ events ) ; $ data [ 'rawOrLabel' ] = $ this -> processRawOrLabelArgument ( $ rawOrLabel ) ; $ data [ 'rawOrLabelHeaders' ] = $ this -> processRawOrLabelHeadersArgument ( $ rawOrLabelHeaders ) ; $ data [ 'exportCheckboxLabel' ] = $ this -> processExportCheckboxLabelArgument ( $ exportCheckboxLabel ) ; $ data [ 'exportSurveyFields' ] = $ this -> processExportSurveyFieldsArgument ( $ exportSurveyFields ) ; $ data [ 'exportDataAccessGroups' ] = $ this -> processExportDataAccessGroupsArgument ( $ exportDataAccessGroups ) ; $ data [ 'filterLogic' ] = $ this -> processFilterLogicArgument ( $ filterLogic ) ; $ records = $ this -> connection -> callWithArray ( $ data ) ; $ records = $ this -> processExportResult ( $ records , $ format ) ; return $ records ; }
Exports the specified records .
53,033
public function importRecords ( $ records , $ format = 'php' , $ type = 'flat' , $ overwriteBehavior = 'normal' , $ dateFormat = 'YMD' , $ returnContent = 'count' , $ forceAutoNumber = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'record' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'odm' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ records , 'records' , $ format ) ; $ data [ 'type' ] = $ this -> processTypeArgument ( $ type ) ; $ data [ 'overwriteBehavior' ] = $ this -> processOverwriteBehaviorArgument ( $ overwriteBehavior ) ; $ data [ 'forceAutoNumber' ] = $ this -> processForceAutoNumberArgument ( $ forceAutoNumber ) ; $ data [ 'returnContent' ] = $ this -> processReturnContentArgument ( $ returnContent , $ forceAutoNumber ) ; $ data [ 'dateFormat' ] = $ this -> processDateFormatArgument ( $ dateFormat ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; $ phpResult = json_decode ( $ result , true ) ; $ jsonError = json_last_error ( ) ; switch ( $ jsonError ) { case JSON_ERROR_NONE : $ result = $ phpResult ; if ( isset ( $ result ) && is_array ( $ result ) && array_key_exists ( 'count' , $ result ) ) { $ result = $ result [ 'count' ] ; } break ; default : $ message = 'JSON error (' . $ jsonError . ') "' . json_last_error_msg ( ) . '" while processing import return value: "' . $ result . '".' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: JSON_ERROR ) ; break ; } return $ result ; }
Imports the specified records into the project .
53,034
public function deleteRecords ( $ recordIds , $ arm = null ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'record' , 'action' => 'delete' , 'returnFormat' => 'json' ) ; $ data [ 'records' ] = $ this -> processRecordIdsArgument ( $ recordIds ) ; $ data [ 'arm' ] = $ this -> processArmArgument ( $ arm ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return $ result ; }
Deletes the specified records from the project .
53,035
public function exportRepeatingInstrumentsAndEvents ( $ format = 'php' ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'repeatingFormsEvents' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'php' , 'csv' , 'json' , 'xml' , 'odm' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return $ result ; }
Exports the repeating instruments and events .
53,036
public function exportRedcapVersion ( ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'version' ) ; $ redcapVersion = $ this -> connection -> callWithArray ( $ data ) ; $ recapVersion = $ this -> processExportResult ( $ redcapVersion , 'string' ) ; return $ redcapVersion ; }
Gets the REDCap version number of the REDCap instance being used by the project .
53,037
public function exportReports ( $ reportId , $ format = 'php' , $ rawOrLabel = 'raw' , $ rawOrLabelHeaders = 'raw' , $ exportCheckboxLabel = false ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'report' , 'returnFormat' => 'json' ) ; $ data [ 'report_id' ] = $ this -> processReportIdArgument ( $ reportId ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'rawOrLabel' ] = $ this -> processRawOrLabelArgument ( $ rawOrLabel ) ; $ data [ 'rawOrLabelHeaders' ] = $ this -> processRawOrLabelHeadersArgument ( $ rawOrLabelHeaders ) ; $ data [ 'exportCheckboxLabel' ] = $ this -> processExportCheckboxLabelArgument ( $ exportCheckboxLabel ) ; $ records = $ this -> connection -> callWithArray ( $ data ) ; $ records = $ this -> processExportResult ( $ records , $ format ) ; return $ records ; }
Exports the records produced by the specified report .
53,038
public function exportSurveyParticipants ( $ form , $ format = 'php' , $ event = null ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'participantList' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'instrument' ] = $ this -> ProcessFormArgument ( $ form , $ required = true ) ; $ data [ 'event' ] = $ this -> ProcessEventArgument ( $ event ) ; $ surveyParticipants = $ this -> connection -> callWithArray ( $ data ) ; $ surveyParticipants = $ this -> processExportResult ( $ surveyParticipants , $ format ) ; return $ surveyParticipants ; }
Exports the list of survey participants for the specified form and for longitudinal studies event .
53,039
public function exportSurveyQueueLink ( $ recordId ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'surveyQueueLink' , 'returnFormat' => 'json' ) ; $ data [ 'record' ] = $ this -> processRecordIdArgument ( $ recordId , $ required = true ) ; $ surveyQueueLink = $ this -> connection -> callWithArray ( $ data ) ; $ surveyQueueLink = $ this -> processExportResult ( $ surveyQueueLink , 'string' ) ; return $ surveyQueueLink ; }
Exports the survey queue link for the specified record ID .
53,040
public function exportSurveyReturnCode ( $ recordId , $ form , $ event = null , $ repeatInstance = null ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'surveyReturnCode' , 'returnFormat' => 'json' ) ; $ data [ 'record' ] = $ this -> processRecordIdArgument ( $ recordId , $ required = true ) ; $ data [ 'instrument' ] = $ this -> ProcessFormArgument ( $ form , $ required = true ) ; $ data [ 'event' ] = $ this -> ProcessEventArgument ( $ event ) ; $ data [ 'repeat_instance' ] = $ this -> ProcessRepeatInstanceArgument ( $ repeatInstance ) ; $ surveyReturnCode = $ this -> connection -> callWithArray ( $ data ) ; $ surveyReturnCode = $ this -> processExportResult ( $ surveyReturnCode , 'string' ) ; return $ surveyReturnCode ; }
Exports the code for returning to a survey that was not completed .
53,041
public function exportUsers ( $ format = 'php' ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'user' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ users = $ this -> connection -> callWithArray ( $ data ) ; $ users = $ this -> processExportResult ( $ users , $ format ) ; return $ users ; }
Exports the users of the project .
53,042
public function importUsers ( $ users , $ format = 'php' ) { $ data = array ( 'token' => $ this -> apiToken , 'content' => 'user' , 'returnFormat' => 'json' ) ; $ legalFormats = array ( 'csv' , 'json' , 'php' , 'xml' ) ; $ data [ 'format' ] = $ this -> processFormatArgument ( $ format , $ legalFormats ) ; $ data [ 'data' ] = $ this -> processImportDataArgument ( $ users , 'users' , $ format ) ; $ result = $ this -> connection -> callWithArray ( $ data ) ; $ this -> processNonExportResult ( $ result ) ; return ( integer ) $ result ; }
Imports the specified users into the project . This method can also be used to update user priveleges by importing a users that already exist in the project and specifying new privleges for that user in the user data that is imported .
53,043
public function getRecordIdBatches ( $ batchSize = null , $ filterLogic = null , $ recordIdFieldName = null ) { $ recordIdBatches = array ( ) ; if ( ! isset ( $ batchSize ) ) { $ message = 'The number of batches was not specified.' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: INVALID_ARGUMENT ) ; } elseif ( ! is_int ( $ batchSize ) ) { $ message = "The batch size argument has type '" . gettype ( $ batchSize ) . '", ' . 'but it should have type integer.' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: INVALID_ARGUMENT ) ; } elseif ( $ batchSize < 1 ) { $ message = 'The batch size argument is less than 1. It needs to be at least 1.' ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: INVALID_ARGUMENT ) ; } $ filterLogic = $ this -> processFilterLogicArgument ( $ filterLogic ) ; if ( ! isset ( $ recordIdFieldName ) ) { $ recordIdFieldName = $ this -> getRecordIdFieldName ( ) ; } $ records = $ this -> exportRecordsAp ( [ 'fields' => [ $ recordIdFieldName ] , 'filterLogic' => $ filterLogic ] ) ; $ recordIds = array_column ( $ records , $ recordIdFieldName ) ; $ recordIds = array_unique ( $ recordIds ) ; $ numberOfRecordIds = count ( $ recordIds ) ; $ position = 0 ; for ( $ position = 0 ; $ position < $ numberOfRecordIds ; $ position += $ batchSize ) { $ recordIdBatch = array ( ) ; $ recordIdBatch = array_slice ( $ recordIds , $ position , $ batchSize ) ; array_push ( $ recordIdBatches , $ recordIdBatch ) ; } return $ recordIdBatches ; }
Gets an array of record ID batches .
53,044
protected function processExportResult ( & $ result , $ format ) { if ( $ format == 'php' ) { $ phpResult = json_decode ( $ result , true ) ; $ jsonError = json_last_error ( ) ; switch ( $ jsonError ) { case JSON_ERROR_NONE : $ result = $ phpResult ; break ; default : $ message = "JSON error (" . $ jsonError . ") \"" . json_last_error_msg ( ) . "\" in REDCap API output." . "\nThe first 1,000 characters of output returned from REDCap are:\n" . substr ( $ result , 0 , 1000 ) ; $ code = ErrorHandlerInterface :: JSON_ERROR ; $ this -> errorHandler -> throwException ( $ message , $ code ) ; break ; } if ( array_key_exists ( 'error' , $ result ) ) { $ this -> errorHandler -> throwException ( $ result [ 'error' ] , ErrorHandlerInterface :: REDCAP_API_ERROR ) ; } } else { $ matches = array ( ) ; $ hasMatch = preg_match ( self :: JSON_RESULT_ERROR_PATTERN , $ result , $ matches ) ; if ( $ hasMatch === 1 ) { $ message = $ matches [ 1 ] ; $ this -> errorHandler -> throwException ( $ message , ErrorHandlerInterface :: REDCAP_API_ERROR ) ; } } return $ result ; }
Processes an export result from the REDCap API .
53,045
protected function processNonExportResult ( & $ result ) { $ matches = array ( ) ; $ hasMatch = preg_match ( self :: JSON_RESULT_ERROR_PATTERN , $ result , $ matches ) ; if ( $ hasMatch === 1 ) { $ message = $ matches [ 1 ] ; $ message = str_replace ( '\"' , '"' , $ message ) ; $ message = str_replace ( '\n' , "\n" , $ message ) ; $ code = ErrorHandlerInterface :: REDCAP_API_ERROR ; $ this -> errorHandler -> throwException ( $ message , $ code ) ; } }
Checks the result returned from the REDCap API for non - export methods . PHPCap is set to return errors from REDCap using JSON so the result string is checked to see if there is a JSON format error and if so and exception is thrown using the error message returned from the REDCap API .
53,046
public function getUsersWithRole ( Role $ role ) : array { $ query = $ this -> getRepository ( ) -> createQueryBuilder ( 'u' ) -> select ( 'u' ) -> where ( ':role MEMBER OF u.roles' ) -> setParameter ( 'role' , $ role ) -> getQuery ( ) ; return $ query -> getResult ( ) ?? [ ] ; }
Get users with a specific role and _not_ its hierarchical parents . In other words if you have admin which inherits from standard and you request admin you will not list standard users .
53,047
public function getResourceUserPermission ( ResourceInterface $ resource , UserInterface $ user ) { $ query = $ this -> getRepository ( ) -> createQueryBuilder ( 'r' ) -> select ( 'r' ) -> where ( 'r.resource_class = :resourceClass AND r.resource_id=:resourceId AND r.user=:user' ) -> setParameter ( 'resourceClass' , $ resource -> getClass ( ) ) -> setParameter ( 'resourceId' , $ resource -> getId ( ) ) -> setParameter ( 'user' , $ user ) -> getQuery ( ) ; return $ query -> getOneOrNullResult ( ) ; }
Get resource - type permissions from the database
53,048
public function create ( UserInterface $ user , $ resourceClass , $ resourceId , array $ actions ) : UserPermissionInterface { return new UserPermission ( $ user , $ resourceClass , $ resourceId , $ actions ) ; }
Create a user permission not persisted and return it .
53,049
public function getCallInfo ( ) { $ callInfo = curl_getinfo ( $ this -> curlHandle ) ; if ( $ errno = curl_errno ( $ this -> curlHandle ) ) { $ message = curl_error ( $ this -> curlHandle ) ; $ code = ErrorHandlerInterface :: CONNECTION_ERROR ; $ this -> errorHandler -> throwException ( $ message , $ code , $ errno ) ; } return $ callInfo ; }
Returns call information for the most recent call .
53,050
public function setCurlOption ( $ option , $ value ) { $ this -> curlOptions [ $ option ] = $ value ; $ result = curl_setopt ( $ this -> curlHandle , $ option , $ value ) ; return $ result ; }
Sets the specified cURL option to the specified value .
53,051
public function getCurlOption ( $ option ) { $ optionValue = null ; if ( array_key_exists ( $ option , $ this -> curlOptions ) ) { $ optionValue = $ this -> curlOptions [ $ option ] ; } return $ optionValue ; }
Gets the value for the specified cURL option number .
53,052
public function addTime ( $ function , $ start_time , $ task ) { if ( ! ( $ function = trim ( ( string ) $ function ) ) ) { return ; } if ( ( $ start_time = ( float ) $ start_time ) <= 0 ) { return ; } if ( ( $ end_time = ( float ) microtime ( true ) ) <= 0 ) { return ; } if ( ! ( $ task = trim ( ( string ) $ task ) ) ) { return ; } $ time = number_format ( $ end_time - $ start_time , 5 , '.' , '' ) ; $ this -> times [ $ function ] = compact ( 'function' , 'time' , 'task' ) ; }
Logs a new time entry .
53,053
public function hasHook ( $ hook ) { $ hook = ( string ) $ hook ; return $ hook && ! empty ( $ this -> hooks [ $ hook ] ) ; }
Do we have a specific hook?
53,054
public function doAction ( $ hook ) { $ hook = ( string ) $ hook ; if ( empty ( $ this -> hooks [ $ hook ] ) ) { return ; } $ hook_actions = $ this -> hooks [ $ hook ] ; $ args = func_get_args ( ) ; ksort ( $ hook_actions ) ; foreach ( $ hook_actions as $ _hook_action ) { foreach ( $ _hook_action as $ _action ) { if ( ! isset ( $ _action [ 'function' ] , $ _action [ 'accepted_args' ] ) ) { continue ; } call_user_func_array ( $ _action [ 'function' ] , array_slice ( $ args , 1 , $ _action [ 'accepted_args' ] ) ) ; } } unset ( $ _hook_action , $ _action ) ; }
Runs any callables attached to an action .
53,055
public function applyFilters ( $ hook , $ value ) { $ hook = ( string ) $ hook ; if ( empty ( $ this -> hooks [ $ hook ] ) ) { return $ value ; } $ hook_filters = $ this -> hooks [ $ hook ] ; $ args = func_get_args ( ) ; ksort ( $ hook_filters ) ; foreach ( $ hook_filters as $ _hook_filter ) { foreach ( $ _hook_filter as $ _filter ) { if ( ! isset ( $ _filter [ 'function' ] , $ _filter [ 'accepted_args' ] ) ) { continue ; } $ args [ 1 ] = $ value ; $ value = call_user_func_array ( $ _filter [ 'function' ] , array_slice ( $ args , 1 , $ _filter [ 'accepted_args' ] ) ) ; } } unset ( $ _hook_filter , $ _filter ) ; return $ value ; }
Runs any callables attached to a filter .
53,056
public static function fileToString ( $ filename ) { $ errorHandler = static :: getErrorHandler ( ) ; if ( ! file_exists ( $ filename ) ) { $ errorHandler -> throwException ( 'The input file "' . $ filename . '" could not be found.' , ErrorHandlerInterface :: INPUT_FILE_NOT_FOUND ) ; } elseif ( ! is_readable ( $ filename ) ) { $ errorHandler -> throwException ( 'The input file "' . $ filename . '" was unreadable.' , ErrorHandlerInterface :: INPUT_FILE_UNREADABLE ) ; } $ contents = file_get_contents ( $ filename ) ; if ( $ contents === false ) { $ error = error_get_last ( ) ; $ errorMessage = null ; if ( $ error != null && array_key_exists ( 'message' , $ error ) ) { $ errorMessage = $ error [ 'message' ] ; } if ( isset ( $ errorMessage ) ) { $ errorHandler -> throwException ( 'An error occurred in input file "' . $ filename . '": ' . $ errorMessage , ErrorHandlerInterface :: INPUT_FILE_ERROR ) ; } else { $ errorHandler -> throwException ( 'An error occurred in input file "' . $ filename . '"' , ErrorHandlerInterface :: INPUT_FILE_ERROR ) ; } } return $ contents ; }
Reads the contents of the specified file and returns it as a string .
53,057
public static function writeStringToFile ( $ string , $ filename , $ append = false ) { $ errorHandler = static :: getErrorHandler ( ) ; $ result = false ; if ( $ append === true ) { $ result = file_put_contents ( $ filename , $ string , FILE_APPEND ) ; } else { $ result = file_put_contents ( $ filename , $ string ) ; } if ( $ result === false ) { $ error = error_get_last ( ) ; $ errorMessage = null ; if ( $ error != null && array_key_exists ( 'message' , $ error ) ) { $ errorMessage = $ error [ 'message' ] ; } if ( isset ( $ errorMessage ) ) { $ errorHandler -> throwException ( 'An error occurred in output file "' . $ filename . '": ' . $ errorMessage , ErrorHandlerInterface :: OUTPUT_FILE_ERROR ) ; } else { $ errorHandler -> throwException ( 'An error occurred in output file "' . $ filename . '"' , ErrorHandlerInterface :: OUTPUT_FILE_ERROR ) ; } } return $ result ; }
Writes the specified string to the specified file .
53,058
public static function setErrorHandler ( $ errorHandler ) { $ currentErrorHandler = static :: getErrorHandler ( ) ; if ( ! ( $ errorHandler instanceof ErrorHandlerInterface ) ) { $ message = 'The error handler argument is not valid, because it doesn\'t implement ' . ErrorHandlerInterface :: class . '.' ; $ code = ErrorHandlerInterface :: INVALID_ARGUMENT ; $ currentErrorHandler -> throwException ( $ message , $ code ) ; } self :: $ errorHandler = $ errorHandler ; }
Sets the error handler used for methods in this class .
53,059
public function modelNotFoundException ( ModelNotFoundException $ exception ) { $ entity = $ this -> extractEntityName ( $ exception -> getModel ( ) ) ; $ ids = implode ( $ exception -> getIds ( ) , ',' ) ; $ error = [ [ 'status' => 404 , 'code' => $ this -> getCode ( 'model_not_found' ) , 'source' => [ 'pointer' => 'data/id' ] , 'title' => $ exception -> getMessage ( ) , 'detail' => __ ( 'exception::exceptions.model_not_found.title' , [ 'model' => $ entity ] ) , ] ] ; $ this -> jsonApiResponse -> setStatus ( 404 ) ; $ this -> jsonApiResponse -> setErrors ( $ error ) ; }
Set the response if Exception is ModelNotFound .
53,060
public function extractEntityName ( $ model ) { $ classNames = ( array ) explode ( '\\' , $ model ) ; $ entityName = end ( $ classNames ) ; if ( $ this -> entityHasTranslation ( $ entityName ) ) { return __ ( 'exception::exceptions.models.' . $ entityName ) ; } return $ entityName ; }
Get entitie name based on model path to mount the message .
53,061
public function entityHasTranslation ( string $ entityName ) : bool { $ hasKey = in_array ( $ entityName , $ this -> translationModelKeys ( ) ) ; if ( $ hasKey ) { return ! empty ( $ hasKey ) ; } return false ; }
Check if entity returned on ModelNotFoundException has translation on exceptions file
53,062
public function dump_node ( $ echo = true ) { $ string = $ this -> tag ; if ( count ( $ this -> attr ) > 0 ) { $ string .= '(' ; foreach ( $ this -> attr as $ k => $ v ) { $ string .= "[$k]=>\"" . $ this -> $ k . '", ' ; } $ string .= ')' ; } if ( count ( $ this -> _ ) > 0 ) { $ string .= ' $_ (' ; foreach ( $ this -> _ as $ k => $ v ) { if ( is_array ( $ v ) ) { $ string .= "[$k]=>(" ; foreach ( $ v as $ k2 => $ v2 ) { $ string .= "[$k2]=>\"" . $ v2 . '", ' ; } $ string .= ')' ; } else { $ string .= "[$k]=>\"" . $ v . '", ' ; } } $ string .= ')' ; } if ( isset ( $ this -> text ) ) { $ string .= ' text: (' . $ this -> text . ')' ; } $ string .= " HDOM_INNER_INFO: '" ; if ( isset ( $ node -> _ [ HDOM_INFO_INNER ] ) ) { $ string .= $ node -> _ [ HDOM_INFO_INNER ] . "'" ; } else { $ string .= ' NULL ' ; } $ string .= ' children: ' . count ( $ this -> children ) ; $ string .= ' nodes: ' . count ( $ this -> nodes ) ; $ string .= ' tag_start: ' . $ this -> tag_start ; $ string .= "\n" ; if ( $ echo ) { echo $ string ; return ; } else { return $ string ; } }
Debugging function to dump a single dom node with a bunch of information about it .
53,063
public function next_sibling ( ) { if ( $ this -> parent === null ) { return null ; } $ idx = 0 ; $ count = count ( $ this -> parent -> children ) ; while ( $ idx < $ count && $ this !== $ this -> parent -> children [ $ idx ] ) { ++ $ idx ; } if ( ++ $ idx >= $ count ) { return null ; } return $ this -> parent -> children [ $ idx ] ; }
returns the next sibling of node
53,064
public function getDescription ( ) { return class_basename ( $ this -> exception ) . ' line ' . $ this -> exception -> getLine ( ) . ' in ' . $ this -> exception -> getFile ( ) ; }
Mount the description with exception class line and file .
53,065
public function getCode ( $ type = 'default' ) { $ code = $ this -> exception -> getCode ( ) ; if ( empty ( $ this -> exception -> getCode ( ) ) ) { $ code = config ( $ this -> configFile . '.codes.' . $ type ) ; } return $ code ; }
Get error code . If code is empty from config file based on type .
53,066
public function jsonResponse ( Exception $ exception ) { $ this -> exception = $ exception ; $ this -> jsonApiResponse = new JsonApiResponse ; if ( $ this -> exceptionIsTreated ( ) ) { $ this -> callExceptionHandler ( ) ; } else { $ this -> setDefaultResponse ( ) ; } return response ( ) -> json ( $ this -> jsonApiResponse -> toArray ( ) , $ this -> jsonApiResponse -> getStatus ( ) ) ; }
Handle the json response . Check if exception is treated . If true call the specific handler . If false set the default response to be returned .
53,067
public function validationException ( ValidationException $ exception ) { $ this -> jsonApiResponse -> setStatus ( 422 ) ; $ this -> jsonApiResponse -> setErrors ( $ this -> jsonApiFormatErrorMessages ( $ exception ) ) ; }
Assign to response attribute the value to ValidationException .
53,068
public function notFoundHttpException ( NotFoundHttpException $ exception ) { $ statuCode = $ exception -> getStatusCode ( ) ; $ error = [ [ 'status' => $ statuCode , 'code' => $ this -> getCode ( 'not_found_http' ) , 'source' => [ 'pointer' => $ exception -> getFile ( ) . ':' . $ exception -> getLine ( ) ] , 'title' => $ this -> getDescription ( $ exception ) , 'detail' => $ this -> getNotFoundMessage ( $ exception ) , ] ] ; $ this -> jsonApiResponse -> setStatus ( $ statuCode ) ; $ this -> jsonApiResponse -> setErrors ( $ error ) ; }
Set response parameters to NotFoundHttpException .
53,069
public function getNotFoundMessage ( NotFoundHttpException $ exception ) { $ message = ! empty ( $ exception -> getMessage ( ) ) ? $ exception -> getMessage ( ) : class_basename ( $ exception ) ; if ( basename ( $ exception -> getFile ( ) ) === 'RouteCollection.php' ) { $ message = __ ( 'exception::exceptions.not_found_http.message' ) ; } return $ message ; }
Get message based on file . If file is RouteCollection return specific message .
53,070
public function addObjectToFolder ( $ repositoryId , $ objectId , $ folderId , $ allVersions = true , ExtensionDataInterface $ extension = null ) { $ url = $ this -> getObjectUrl ( $ repositoryId , $ objectId ) ; $ queryArray = [ Constants :: CONTROL_CMISACTION => Constants :: CMISACTION_ADD_OBJECT_TO_FOLDER , Constants :: PARAM_SUCCINCT => $ this -> getSuccinct ( ) ? 'true' : 'false' , Constants :: PARAM_FOLDER_ID => $ folderId , Constants :: PARAM_ALL_VERSIONS => $ allVersions ? 'true' : 'false' , ] ; $ this -> post ( $ url , $ queryArray ) ; }
Adds an existing fileable non - folder object to a folder .
53,071
public function removeObjectFromFolder ( $ repositoryId , $ objectId , $ folderId = null , ExtensionDataInterface $ extension = null ) { $ url = $ this -> getObjectUrl ( $ repositoryId , $ objectId ) ; $ queryArray = [ Constants :: CONTROL_CMISACTION => Constants :: CMISACTION_REMOVE_OBJECT_FROM_FOLDER , Constants :: PARAM_SUCCINCT => $ this -> getSuccinct ( ) ? 'true' : 'false' , Constants :: PARAM_FOLDER_ID => $ folderId , ] ; $ this -> post ( $ url , $ queryArray ) ; }
Removes an existing fileable non - folder object from a folder .
53,072
public function decode ( $ jwsString ) { $ components = explode ( '.' , $ jwsString ) ; if ( count ( $ components ) !== 3 ) { throw new MalformedSignatureException ( 'JWS string must contain 3 dot separated component.' ) ; } try { $ headers = Json :: decode ( Base64Url :: decode ( $ components [ 0 ] ) ) ; $ payload = Json :: decode ( Base64Url :: decode ( $ components [ 1 ] ) ) ; } catch ( \ InvalidArgumentException $ e ) { throw new MalformedSignatureException ( "Cannot decode signature headers and/or payload" ) ; } return [ 'headers' => $ headers , 'payload' => $ payload ] ; }
Only decodes jws string and returns headers and payload . To verify signature use verify method .
53,073
public function all ( array $ params = array ( ) ) { $ endpoint = '/admin/products.json' ; $ response = $ this -> request ( $ endpoint , 'GET' , $ params ) ; return $ this -> createCollection ( Product :: class , $ response [ 'products' ] ) ; }
Receive a lists of all Products
53,074
public function get ( $ productId , array $ fields = array ( ) ) { $ params = array ( ) ; if ( ! empty ( $ fields ) ) { $ params [ 'fields' ] = $ fields ; } $ endpoint = '/admin/products/' . $ productId . '.json' ; $ response = $ this -> request ( $ endpoint , 'GET' , $ params ) ; return $ this -> createObject ( Product :: class , $ response [ 'product' ] ) ; }
Receive a single product
53,075
public function create ( Product & $ product ) { $ data = $ product -> exportData ( ) ; $ endpoint = '/admin/products.json' ; $ response = $ this -> request ( $ endpoint , 'POST' , array ( 'product' => $ data ) ) ; $ product -> setData ( $ response [ 'product' ] ) ; }
Create a new Product
53,076
public function update ( Product & $ product ) { $ data = $ product -> exportData ( ) ; $ endpoint = '/admin/products/' . $ product -> id . '.json' ; $ response = $ this -> request ( $ endpoint , 'PUT' , array ( 'product' => $ data ) ) ; $ product -> setData ( $ response [ 'product' ] ) ; }
Modify an existing product
53,077
public function getRepositoryInfo ( $ repositoryId , ExtensionDataInterface $ extension = null ) { foreach ( $ this -> getRepositoriesInternal ( $ repositoryId ) as $ repositoryInfo ) { if ( $ repositoryInfo -> getId ( ) === $ repositoryId ) { return $ repositoryInfo ; } } throw new CmisObjectNotFoundException ( sprintf ( 'Repository "%s" not found!' , $ repositoryId ) ) ; }
Returns information about the CMIS repository the optional capabilities it supports and its access control information if applicable .
53,078
public function getTypeChildren ( $ repositoryId , $ typeId = null , $ includePropertyDefinitions = false , $ maxItems = null , $ skipCount = 0 , ExtensionDataInterface $ extension = null ) { $ url = $ this -> getRepositoryUrl ( $ repositoryId , Constants :: SELECTOR_TYPE_CHILDREN ) ; $ url -> getQuery ( ) -> modify ( [ Constants :: PARAM_PROPERTY_DEFINITIONS => $ includePropertyDefinitions ? 'true' : 'false' , Constants :: PARAM_SKIP_COUNT => $ skipCount , Constants :: PARAM_DATETIME_FORMAT => ( string ) $ this -> getDateTimeFormat ( ) ] ) ; if ( $ typeId !== null ) { $ url -> getQuery ( ) -> modify ( [ Constants :: PARAM_TYPE_ID => $ typeId ] ) ; } if ( $ maxItems !== null ) { $ url -> getQuery ( ) -> modify ( [ Constants :: PARAM_MAX_ITEMS => $ maxItems ] ) ; } $ responseData = ( array ) $ this -> readJson ( $ url ) ; return $ this -> getJsonConverter ( ) -> convertTypeChildren ( $ responseData ) ; }
Returns the list of object types defined for the repository that are children of the specified type .
53,079
public function getTypeDefinition ( $ repositoryId , $ typeId , ExtensionDataInterface $ extension = null , $ useCache = true ) { $ cache = null ; $ cacheKey = $ repositoryId . '-' . $ typeId ; if ( $ useCache === true && empty ( $ extension ) ) { $ cache = $ this -> cmisBindingsHelper -> getTypeDefinitionCache ( $ this -> getSession ( ) ) ; if ( $ cache -> contains ( $ cacheKey ) ) { return $ cache -> fetch ( $ cacheKey ) ; } } $ typeDefinition = $ this -> getTypeDefinitionInternal ( $ repositoryId , $ typeId ) ; if ( $ useCache === true && empty ( $ extension ) ) { $ cache -> save ( $ cacheKey , $ typeDefinition ) ; } return $ typeDefinition ; }
Gets the definition of the specified object type .
53,080
public function getTypeDescendants ( $ repositoryId , $ typeId = null , $ depth = null , $ includePropertyDefinitions = false , ExtensionDataInterface $ extension = null ) { $ url = $ this -> getRepositoryUrl ( $ repositoryId , Constants :: SELECTOR_TYPE_DESCENDANTS ) ; $ url -> getQuery ( ) -> modify ( [ Constants :: PARAM_PROPERTY_DEFINITIONS => $ includePropertyDefinitions ? 'true' : 'false' , Constants :: PARAM_DATETIME_FORMAT => ( string ) $ this -> getDateTimeFormat ( ) ] ) ; if ( $ typeId !== null ) { $ url -> getQuery ( ) -> modify ( [ Constants :: PARAM_TYPE_ID => $ typeId ] ) ; } if ( $ depth !== null ) { $ url -> getQuery ( ) -> modify ( [ Constants :: PARAM_DEPTH => $ depth ] ) ; } $ responseData = ( array ) $ this -> readJson ( $ url ) ; return $ this -> getJsonConverter ( ) -> convertTypeDescendants ( $ responseData ) ; }
Returns the set of descendant object type defined for the repository under the specified type .
53,081
public function updateType ( $ repositoryId , TypeDefinitionInterface $ type , ExtensionDataInterface $ extension = null ) { $ url = $ this -> getRepositoryUrl ( $ repositoryId ) ; $ url -> getQuery ( ) -> modify ( [ Constants :: CONTROL_CMISACTION => Constants :: CMISACTION_UPDATE_TYPE , Constants :: CONTROL_TYPE => json_encode ( $ this -> getJsonConverter ( ) -> convertFromTypeDefinition ( $ type ) ) ] ) ; return $ this -> getJsonConverter ( ) -> convertTypeDefinition ( $ this -> postJson ( $ url ) ) ; }
Updates a type .
53,082
public function getRenditionDocument ( OperationContextInterface $ context = null ) { $ renditionDocumentId = $ this -> getRenditionDocumentId ( ) ; if ( empty ( $ renditionDocumentId ) ) { return null ; } if ( $ context === null ) { $ context = $ this -> session -> getDefaultContext ( ) ; } $ document = $ this -> session -> getObject ( $ this -> session -> createObjectId ( $ renditionDocumentId ) , $ context ) ; return $ document instanceof DocumentInterface ? $ document : null ; }
Returns the rendition document using the provides OperationContext if the rendition is a stand - alone document .
53,083
public function getContentStream ( ) { if ( ! $ this -> objectId || ! $ this -> getStreamId ( ) ) { return null ; } return $ this -> session -> getBinding ( ) -> getObjectService ( ) -> getContentStream ( $ this -> session -> getRepositoryInfo ( ) -> getId ( ) , $ this -> objectId , $ this -> getStreamId ( ) ) ; }
Returns the content stream of the rendition .
53,084
public function getContentUrl ( ) { $ objectService = $ this -> session -> getBinding ( ) -> getObjectService ( ) ; if ( $ objectService instanceof LinkAccessInterface ) { return $ objectService -> loadRenditionContentLink ( $ this -> session -> getRepositoryInfo ( ) -> getId ( ) , $ this -> objectId , $ this -> getStreamId ( ) ) ; } return null ; }
Returns the content URL of the rendition if the binding supports content URLs .
53,085
public function createDocument ( array $ properties , ObjectIdInterface $ folderId = null , StreamInterface $ contentStream = null , VersioningState $ versioningState = null , array $ policies = [ ] , array $ addAces = [ ] , array $ removeAces = [ ] ) { if ( empty ( $ properties ) ) { throw new CmisInvalidArgumentException ( 'Properties must not be empty!' ) ; } $ objectId = $ this -> getBinding ( ) -> getObjectService ( ) -> createDocument ( $ this -> getRepositoryId ( ) , $ this -> getObjectFactory ( ) -> convertProperties ( $ properties , null , [ ] , self :: $ createAndCheckoutUpdatability ) , $ folderId === null ? null : $ folderId -> getId ( ) , $ contentStream , $ versioningState , $ this -> getObjectFactory ( ) -> convertPolicies ( $ policies ) , $ this -> getObjectFactory ( ) -> convertAces ( $ addAces ) , $ this -> getObjectFactory ( ) -> convertAces ( $ removeAces ) , null ) ; if ( $ objectId === null ) { return null ; } return $ this -> createObjectId ( $ objectId ) ; }
Creates a new document . The stream in contentStream is consumed but not closed by this method .
53,086
public function createDocumentFromSource ( ObjectIdInterface $ source , array $ properties = [ ] , ObjectIdInterface $ folderId = null , VersioningState $ versioningState = null , array $ policies = [ ] , array $ addAces = [ ] , array $ removeAces = [ ] ) { if ( ! $ source instanceof CmisObjectInterface ) { $ sourceObject = $ this -> getObject ( $ source ) ; } else { $ sourceObject = $ source ; } $ type = $ sourceObject -> getType ( ) ; $ secondaryTypes = $ sourceObject -> getSecondaryTypes ( ) ; if ( $ secondaryTypes === null ) { $ secondaryTypes = [ ] ; } if ( ! BaseTypeId :: cast ( $ type -> getBaseTypeId ( ) ) -> equals ( BaseTypeId :: CMIS_DOCUMENT ) ) { throw new CmisInvalidArgumentException ( 'Source object must be a document!' ) ; } $ objectId = $ this -> getBinding ( ) -> getObjectService ( ) -> createDocumentFromSource ( $ this -> getRepositoryId ( ) , $ source -> getId ( ) , $ this -> getObjectFactory ( ) -> convertProperties ( $ properties , $ type , $ secondaryTypes , self :: $ createAndCheckoutUpdatability ) , $ folderId === null ? null : $ folderId -> getId ( ) , $ versioningState , $ this -> getObjectFactory ( ) -> convertPolicies ( $ policies ) , $ this -> getObjectFactory ( ) -> convertAces ( $ addAces ) , $ this -> getObjectFactory ( ) -> convertAces ( $ removeAces ) , null ) ; if ( $ objectId === null ) { return null ; } return $ this -> createObjectId ( $ objectId ) ; }
Creates a new document from a source document .
53,087
public function createFolder ( array $ properties , ObjectIdInterface $ folderId , array $ policies = [ ] , array $ addAces = [ ] , array $ removeAces = [ ] ) { if ( empty ( $ properties ) ) { throw new CmisInvalidArgumentException ( 'Properties must not be empty!' ) ; } $ objectId = $ this -> getBinding ( ) -> getObjectService ( ) -> createFolder ( $ this -> getRepositoryId ( ) , $ this -> getObjectFactory ( ) -> convertProperties ( $ properties ) , $ folderId -> getId ( ) , $ this -> getObjectFactory ( ) -> convertPolicies ( $ policies ) , $ this -> getObjectFactory ( ) -> convertAces ( $ addAces ) , $ this -> getObjectFactory ( ) -> convertAces ( $ removeAces ) , null ) ; return $ this -> createObjectId ( $ objectId ) ; }
Creates a new folder .
53,088
public function createOperationContext ( $ filter = [ ] , $ includeAcls = false , $ includeAllowableActions = true , $ includePolicies = false , IncludeRelationships $ includeRelationships = null , array $ renditionFilter = [ ] , $ includePathSegments = true , $ orderBy = null , $ cacheEnabled = false , $ maxItemsPerPage = 100 ) { $ operationContext = new OperationContext ( ) ; $ operationContext -> setFilter ( $ filter ) ; $ operationContext -> setIncludeAcls ( $ includeAcls ) ; $ operationContext -> setIncludeAllowableActions ( $ includeAllowableActions ) ; $ operationContext -> setIncludePolicies ( $ includePolicies ) ; if ( $ includeRelationships !== null ) { $ operationContext -> setIncludeRelationships ( $ includeRelationships ) ; } $ operationContext -> setRenditionFilter ( $ renditionFilter ) ; $ operationContext -> setIncludePathSegments ( $ includePathSegments ) ; if ( ! empty ( $ orderBy ) ) { $ operationContext -> setOrderBy ( $ orderBy ) ; } $ operationContext -> setCacheEnabled ( $ cacheEnabled ) ; $ operationContext -> setMaxItemsPerPage ( $ maxItemsPerPage ) ; return $ operationContext ; }
Creates a new operation context object with the given properties .
53,089
public function createQueryStatement ( array $ selectPropertyIds , array $ fromTypes , $ whereClause = null , array $ orderByPropertyIds = [ ] ) { if ( empty ( $ selectPropertyIds ) ) { throw new CmisInvalidArgumentException ( 'Select property IDs must not be empty' ) ; } if ( empty ( $ fromTypes ) ) { throw new CmisInvalidArgumentException ( 'From types must not be empty' ) ; } return new QueryStatement ( $ this , null , $ selectPropertyIds , $ fromTypes , $ whereClause , $ orderByPropertyIds ) ; }
Creates a query statement for a query of one primary type joined by zero or more secondary types .
53,090
public function createRelationship ( array $ properties , array $ policies = [ ] , array $ addAces = [ ] , array $ removeAces = [ ] ) { if ( empty ( $ properties ) ) { throw new CmisInvalidArgumentException ( 'Properties must not be empty!' ) ; } $ newObjectId = $ this -> getBinding ( ) -> getObjectService ( ) -> createRelationship ( $ this -> getRepositoryId ( ) , $ this -> getObjectFactory ( ) -> convertProperties ( $ properties , null , [ ] , self :: $ createUpdatability ) , $ this -> getObjectFactory ( ) -> convertPolicies ( $ policies ) , $ this -> getObjectFactory ( ) -> convertAces ( $ addAces ) , $ this -> getObjectFactory ( ) -> convertAces ( $ removeAces ) ) ; if ( $ newObjectId === null ) { return null ; } return $ this -> createObjectId ( $ newObjectId ) ; }
Creates a new relationship between 2 objects .
53,091
public function delete ( ObjectIdInterface $ objectId , $ allVersions = true ) { $ this -> getBinding ( ) -> getObjectService ( ) -> deleteObject ( $ this -> getRepositoryId ( ) , $ objectId -> getId ( ) , $ allVersions ) ; $ this -> removeObjectFromCache ( $ objectId ) ; }
Deletes an object and if it is a document all versions in the version series .
53,092
public function getContentChanges ( $ changeLogToken , $ includeProperties , $ maxNumItems = null , OperationContextInterface $ context = null ) { if ( $ context === null ) { $ context = $ this -> getDefaultContext ( ) ; } $ objectList = $ this -> getBinding ( ) -> getDiscoveryService ( ) -> getContentChanges ( $ this -> getRepositoryInfo ( ) -> getId ( ) , $ changeLogToken , $ includeProperties , $ context -> isIncludePolicies ( ) , $ context -> isIncludeAcls ( ) , $ maxNumItems ) ; return $ this -> getObjectFactory ( ) -> convertChangeEvents ( $ changeLogToken , $ objectList ) ; }
Returns the content changes .
53,093
public function getContentStream ( ObjectIdInterface $ docId , $ streamId = null , $ offset = null , $ length = null ) { return $ this -> getBinding ( ) -> getObjectService ( ) -> getContentStream ( $ this -> getRepositoryId ( ) , $ docId -> getId ( ) , $ streamId , $ offset , $ length ) ; }
Retrieves the main content stream of a document .
53,094
public function getRelationships ( ObjectIdInterface $ objectId , $ includeSubRelationshipTypes , RelationshipDirection $ relationshipDirection , ObjectTypeInterface $ type , OperationContextInterface $ context = null ) { if ( $ context === null ) { $ context = $ this -> getDefaultContext ( ) ; } return $ this -> getBinding ( ) -> getRelationshipService ( ) -> getObjectRelationships ( $ this -> getRepositoryId ( ) , $ objectId -> getId ( ) , $ includeSubRelationshipTypes , $ relationshipDirection , $ type -> getId ( ) ) ; }
Fetches the relationships from or to an object from the repository .
53,095
public function getRootFolder ( OperationContextInterface $ context = null ) { $ rootFolderId = $ this -> getRepositoryInfo ( ) -> getRootFolderId ( ) ; $ rootFolder = $ this -> getObject ( $ this -> createObjectId ( $ rootFolderId ) , $ context === null ? $ this -> getDefaultContext ( ) : $ context ) ; if ( ! ( $ rootFolder instanceof FolderInterface ) ) { throw new CmisRuntimeException ( 'Root folder object is not a folder!' , 1423735889 ) ; } return $ rootFolder ; }
Gets the root folder of the repository with the given OperationContext .
53,096
public function getTypeChildren ( $ typeId , $ includePropertyDefinitions ) { return $ this -> getBinding ( ) -> getRepositoryService ( ) -> getTypeChildren ( $ this -> getRepositoryId ( ) , $ typeId , $ includePropertyDefinitions , 999 , 0 ) ; }
Gets the type children of a type .
53,097
public function getTypeDefinition ( $ typeId , $ useCache = true ) { $ typeDefinition = $ this -> getBinding ( ) -> getRepositoryService ( ) -> getTypeDefinition ( $ this -> getRepositoryId ( ) , $ typeId ) ; return $ this -> convertTypeDefinition ( $ typeDefinition ) ; }
Gets the definition of a type .
53,098
public function getTypeDescendants ( $ typeId , $ depth , $ includePropertyDefinitions ) { return $ this -> getBinding ( ) -> getRepositoryService ( ) -> getTypeDescendants ( $ this -> getRepositoryId ( ) , $ typeId , ( integer ) $ depth , $ includePropertyDefinitions ) ; }
Gets the type descendants of a type .
53,099
public function queryObjects ( $ typeId , $ where = null , $ searchAllVersions = false , OperationContextInterface $ context = null ) { if ( empty ( $ typeId ) ) { throw new CmisInvalidArgumentException ( 'Type id must not be empty.' ) ; } if ( $ context === null ) { $ context = $ this -> getDefaultContext ( ) ; } $ queryFilterString = $ context -> getQueryFilterString ( ) ; if ( ! empty ( $ queryFilterString ) ) { $ querySelect = $ queryFilterString ; } else { $ querySelect = '*' ; } $ whereClause = '' ; if ( ! empty ( $ where ) ) { $ whereClause = ' WHERE ' . $ where ; } $ orderBy = $ context -> getOrderBy ( ) ; if ( ! empty ( $ orderBy ) ) { $ orderBy = ' ORDER BY ' . $ orderBy ; } $ typeDefinition = $ this -> getTypeDefinition ( $ typeId ) ; $ statement = 'SELECT ' . $ querySelect . ' FROM ' . $ typeDefinition -> getQueryName ( ) . $ whereClause . $ orderBy ; $ queryStatement = new QueryStatement ( $ this , $ statement ) ; $ resultObjects = [ ] ; $ skipCount = 0 ; $ objectList = $ this -> getBinding ( ) -> getDiscoveryService ( ) -> query ( $ this -> getRepositoryInfo ( ) -> getId ( ) , $ queryStatement -> toQueryString ( ) , $ searchAllVersions , $ context -> getIncludeRelationships ( ) , $ context -> getRenditionFilterString ( ) , $ context -> isIncludeAllowableActions ( ) , $ context -> getMaxItemsPerPage ( ) , $ skipCount ) ; foreach ( $ objectList -> getObjects ( ) as $ objectData ) { $ object = $ this -> getObjectFactory ( ) -> convertObject ( $ objectData , $ context ) ; if ( $ object instanceof CmisObjectInterface ) { $ resultObjects [ ] = $ object ; } } return $ resultObjects ; }
Builds a CMIS query and returns the query results as an iterator of CmisObject objects .