idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
49,300
|
public function userHasRoles ( core_kernel_classes_Resource $ user , $ roles ) { $ returnValue = ( bool ) false ; if ( empty ( $ roles ) ) { throw new InvalidArgumentException ( 'The $roles parameter must not be empty.' ) ; } $ roles = ( is_array ( $ roles ) ) ? $ roles : array ( $ roles ) ; $ searchRoles = array ( ) ; foreach ( $ roles as $ r ) { $ searchRoles [ ] = ( $ r instanceof core_kernel_classes_Resource ) ? $ r -> getUri ( ) : $ r ; } unset ( $ roles ) ; if ( common_session_SessionManager :: getSession ( ) -> getUserUri ( ) == $ user -> getUri ( ) ) { foreach ( common_session_SessionManager :: getSession ( ) -> getUserRoles ( ) as $ role ) { if ( in_array ( $ role , $ searchRoles ) ) { $ returnValue = true ; break ; } } } else { common_Logger :: w ( 'Roles of non current user (' . $ user -> getUri ( ) . ') checked, trying fallback to local ontology' ) ; $ userRoles = array_keys ( $ this -> getUserRoles ( $ user ) ) ; $ identicalRoles = array_intersect ( $ searchRoles , $ userRoles ) ; $ returnValue = ( count ( $ identicalRoles ) === count ( $ searchRoles ) ) ; } return ( bool ) $ returnValue ; }
|
Indicates if a user is granted with a set of Roles .
|
49,301
|
public function attachRole ( core_kernel_classes_Resource $ user , core_kernel_classes_Resource $ role ) { try { if ( false === $ this -> userHasRoles ( $ user , $ role ) ) { $ rolesProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_USER_ROLES ) ; $ user -> setPropertyValue ( $ rolesProperty , $ role ) ; } } catch ( common_Exception $ e ) { $ roleUri = $ role -> getUri ; $ userUri = $ user -> getUri ( ) ; $ msg = "An error occured while attaching role '${roleUri}' to user '${userUri}': " . $ e -> getMessage ( ) ; throw new core_kernel_users_Exception ( $ msg ) ; } }
|
Attach a Generis Role to a given Generis User . A UserException will be if an error occurs . If the User already has the role nothing happens .
|
49,302
|
public function unnatachRole ( core_kernel_classes_Resource $ user , core_kernel_classes_Resource $ role ) { try { if ( true === $ this -> userHasRoles ( $ user , $ role ) ) { $ rolesProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_USER_ROLES ) ; $ options = array ( 'like' => false , 'pattern' => $ role -> getUri ( ) ) ; $ user -> removePropertyValues ( $ rolesProperty , $ options ) ; } } catch ( common_Exception $ e ) { $ roleUri = $ role -> getUri ( ) ; $ userUri = $ user -> getUri ( ) ; $ msg = "An error occured while unnataching role '${roleUri}' from user '${userUri}': " . $ e -> getMessage ( ) ; } }
|
Short description of method unnatachRole
|
49,303
|
public function addRole ( $ label , $ includedRoles = null , core_kernel_classes_Class $ class = null ) { $ returnValue = null ; $ includedRoles = is_array ( $ includedRoles ) ? $ includedRoles : array ( $ includedRoles ) ; $ includedRoles = empty ( $ includedRoles [ 0 ] ) ? array ( ) : $ includedRoles ; $ classRole = ( empty ( $ class ) ) ? new core_kernel_classes_Class ( GenerisRdf :: CLASS_ROLE ) : $ class ; $ includesRoleProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_ROLE_INCLUDESROLE ) ; $ role = $ classRole -> createInstance ( $ label , "${label} Role" ) ; foreach ( $ includedRoles as $ ir ) { $ role -> setPropertyValue ( $ includesRoleProperty , $ ir ) ; } $ returnValue = $ role ; return $ returnValue ; }
|
Add a role in Generis .
|
49,304
|
public function removeRole ( core_kernel_classes_Resource $ role ) { $ returnValue = ( bool ) false ; if ( GENERIS_CACHE_USERS_ROLES == true && core_kernel_users_Cache :: areIncludedRolesInCache ( $ role ) ) { if ( $ role -> delete ( true ) == true ) { $ returnValue = core_kernel_users_Cache :: removeIncludedRoles ( $ role ) ; foreach ( $ this -> getAllRoles ( ) as $ r ) { if ( array_key_exists ( $ role -> getUri ( ) , $ this -> getIncludedRoles ( $ r ) ) ) { core_kernel_users_Cache :: removeIncludedRoles ( $ r ) ; } } } else { $ roleUri = $ role -> getUri ( ) ; $ msg = "An error occured while removing role '${roleUri}'. It could not be deleted from the cache." ; throw new core_kernel_users_Exception ( $ msg ) ; } } else { $ returnValue = $ role -> delete ( true ) ; } return ( bool ) $ returnValue ; }
|
Remove a Generis Role from the persistent memory . Any reference to the Role will be removed .
|
49,305
|
public function getIncludedRoles ( core_kernel_classes_Resource $ role ) { $ returnValue = array ( ) ; if ( GENERIS_CACHE_USERS_ROLES === true && core_kernel_users_Cache :: areIncludedRolesInCache ( $ role ) === true ) { $ returnValue = core_kernel_users_Cache :: retrieveIncludedRoles ( $ role ) ; } else { $ includesRoleProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_ROLE_INCLUDESROLE ) ; $ visitedRoles = array ( ) ; $ s = array ( ) ; array_push ( $ s , $ role ) ; while ( ! empty ( $ s ) ) { $ u = array_pop ( $ s ) ; if ( false === in_array ( $ u -> getUri ( ) , $ visitedRoles , true ) ) { $ visitedRoles [ ] = $ u -> getUri ( ) ; $ returnValue [ $ u -> getUri ( ) ] = $ u ; $ ar = $ u -> getPropertyValuesCollection ( $ includesRoleProperty ) ; foreach ( $ ar -> getIterator ( ) as $ w ) { if ( false === in_array ( $ w -> getUri ( ) , $ visitedRoles , true ) ) { array_push ( $ s , $ w ) ; } } } } unset ( $ returnValue [ $ role -> getUri ( ) ] ) ; if ( GENERIS_CACHE_USERS_ROLES === true ) { try { core_kernel_users_Cache :: cacheIncludedRoles ( $ role , $ returnValue ) ; } catch ( core_kernel_users_CacheException $ e ) { $ roleUri = $ role -> getUri ( ) ; $ msg = "Unable to retrieve included roles from cache memory for role '${roleUri}': " ; $ msg .= $ e -> getMessage ( ) ; throw new core_kernel_users_Exception ( $ msg ) ; } } } return ( array ) $ returnValue ; }
|
Get an array of the Roles included by a Generis Role .
|
49,306
|
public function includeRole ( core_kernel_classes_Resource $ role , core_kernel_classes_Resource $ roleToInclude ) { $ includesRoleProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_ROLE_INCLUDESROLE ) ; $ role -> removePropertyValues ( $ includesRoleProperty , array ( 'like' => false , 'pattern' => $ roleToInclude -> getUri ( ) ) ) ; $ role -> setPropertyValue ( $ includesRoleProperty , $ roleToInclude -> getUri ( ) ) ; core_kernel_users_Cache :: removeIncludedRoles ( $ role ) ; }
|
Make a Role include another Role .
|
49,307
|
public function unincludeRole ( core_kernel_classes_Resource $ role , core_kernel_classes_Resource $ roleToUninclude ) { $ includesRoleProperty = new core_kernel_classes_Property ( GenerisRdf :: PROPERTY_ROLE_INCLUDESROLE ) ; $ role -> removePropertyValues ( $ includesRoleProperty , array ( 'like' => false , 'pattern' => $ roleToUninclude -> getUri ( ) ) ) ; if ( GENERIS_CACHE_USERS_ROLES == true ) { core_kernel_users_Cache :: removeIncludedRoles ( $ role ) ; foreach ( $ this -> getAllRoles ( ) as $ r ) { $ includedRoles = $ this -> getIncludedRoles ( $ r ) ; if ( array_key_exists ( $ role -> getUri ( ) , $ includedRoles ) ) { core_kernel_users_Cache :: removeIncludedRoles ( $ r ) ; } } } }
|
Uninclude a Role from antother Role .
|
49,308
|
protected function getBaseDirectory ( ) { if ( ! $ this -> fileSystem ) { $ this -> fileSystem = $ this -> getServiceLocator ( ) -> get ( FileSystemService :: SERVICE_ID ) -> getDirectory ( $ this -> getFileSystemId ( ) ) ; } return $ this -> fileSystem ; }
|
Get current base directory
|
49,309
|
public function getFileSystem ( ) { if ( ! $ this -> fileSystem ) { $ this -> fileSystem = $ this -> getServiceLocator ( ) -> get ( FileSystemService :: SERVICE_ID ) -> getFileSystem ( $ this -> getFileSystemId ( ) ) ; } return $ this -> fileSystem ; }
|
Get current fileystem
|
49,310
|
static public function identifyFirstLanguage ( $ values ) { $ returnValue = '' ; if ( count ( $ values ) > 0 ) { $ previousLanguage = $ values [ 0 ] [ 'language' ] ; $ returnValue = $ previousLanguage ; foreach ( $ values as $ value ) { if ( $ value [ 'language' ] == $ previousLanguage ) { continue ; } else { $ returnValue = $ previousLanguage ; break ; } } } return $ returnValue ; }
|
Short description of method identifyFirstLanguage
|
49,311
|
static public function buildSearchPattern ( common_persistence_SqlPersistence $ persistence , $ pattern , $ like = true ) { $ returnValue = '' ; if ( $ pattern instanceof core_kernel_classes_Literal ) { $ pattern = $ pattern -> __toString ( ) ; } switch ( gettype ( $ pattern ) ) { case 'object' : if ( $ pattern instanceof core_kernel_classes_Resource ) { $ returnValue = '= ' . $ persistence -> quote ( $ pattern -> getUri ( ) ) ; } else { common_Logger :: w ( 'non ressource as search parameter: ' . get_class ( $ pattern ) , 'GENERIS' ) ; } break ; default : $ patternToken = $ pattern ; $ wildcard = mb_strpos ( $ patternToken , '*' , 0 , 'UTF-8' ) !== false ; $ object = trim ( str_replace ( '*' , '%' , $ patternToken ) ) ; if ( $ like ) { if ( ! $ wildcard && ! preg_match ( "/^%/" , $ object ) ) { $ object = "%" . $ object ; } if ( ! $ wildcard && ! preg_match ( "/%$/" , $ object ) ) { $ object = $ object . "%" ; } if ( ! $ wildcard && $ object === '%' ) { $ object = '%%' ; } $ returnValue .= 'LIKE LOWER(' . $ persistence -> quote ( $ object ) . ')' ; } else { $ returnValue .= '= ' . $ persistence -> quote ( $ patternToken ) ; } break ; } return $ returnValue ; }
|
Build a SQL search pattern on basis of a pattern and a comparison mode .
|
49,312
|
public function createIndex ( $ indexName , $ tableName , $ columns ) { $ sql = 'CREATE INDEX ' . $ indexName . ' ON ' . $ tableName . ' (' ; $ colsSql = array ( ) ; foreach ( $ columns as $ n => $ l ) { if ( ! empty ( $ l ) ) { $ colsSql [ ] = $ n . '(' . $ l . ')' ; } else { $ colsSql [ ] = $ n ; } } $ colsSql = implode ( ',' , $ colsSql ) ; $ sql .= $ colsSql . ')' ; $ this -> getDriver ( ) -> exec ( $ sql ) ; }
|
Short description of method createIndex
|
49,313
|
public function getFilePath ( ) { $ returnValue = ( string ) '' ; if ( ! empty ( $ this -> filePath ) ) { $ returnValue = $ this -> filePath ; } return ( string ) $ returnValue ; }
|
Get the path to the manifest file .
|
49,314
|
public function getName ( ) { $ returnValue = ( string ) '' ; if ( ! empty ( $ this -> name ) ) { $ returnValue = $ this -> name ; } else { $ returnValue = null ; } return ( string ) $ returnValue ; }
|
Get the name of the Extension the manifest describes .
|
49,315
|
public function getDescription ( ) { $ returnValue = ( string ) '' ; if ( ! empty ( $ this -> description ) ) { $ returnValue = $ this -> description ; } return ( string ) $ returnValue ; }
|
Get the description of the Extension the manifest describes .
|
49,316
|
public function getVersion ( ) { $ returnValue = ( string ) '' ; if ( ! empty ( $ this -> version ) ) { $ returnValue = $ this -> version ; } return ( string ) $ returnValue ; }
|
Get the version of the Extension the manifest describes .
|
49,317
|
private function setInstallModelFiles ( $ installModelFiles ) { $ this -> installModelFiles = array ( ) ; $ installModelFiles = is_array ( $ installModelFiles ) ? $ installModelFiles : array ( $ installModelFiles ) ; foreach ( $ installModelFiles as $ row ) { if ( is_string ( $ row ) ) { $ rdfpath = $ row ; } elseif ( is_array ( $ row ) && isset ( $ row [ 'file' ] ) ) { $ rdfpath = $ row [ 'file' ] ; } else { throw new common_ext_InstallationException ( 'Error in definition of model to add into the ontology for ' . $ this -> extension -> getId ( ) , 'INSTALL' ) ; } $ this -> installModelFiles [ ] = $ rdfpath ; } }
|
Sets the the RDF files to be imported during install . The array must contain paths to the files to be imported .
|
49,318
|
private function setInstallChecks ( $ installChecks ) { if ( ! is_array ( $ installChecks ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks' component must be an array." ) ; } else { foreach ( $ installChecks as $ check ) { if ( empty ( $ check [ 'type' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->type' component is mandatory." ) ; } else if ( ! is_string ( $ check [ 'type' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->type' component must be a string." ) ; } if ( empty ( $ check [ 'value' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value' component is mandatory." ) ; } else if ( ! is_array ( $ check [ 'value' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value' component must be an array." ) ; } if ( empty ( $ check [ 'value' ] [ 'id' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->id' component is mandatory." ) ; } else if ( ! is_string ( $ check [ 'value' ] [ 'id' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->id' component must be a string." ) ; } switch ( $ check [ 'type' ] ) { case 'CheckPHPRuntime' : if ( empty ( $ check [ 'value' ] [ 'min' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->min' component is mandatory for PHPRuntime checks." ) ; } break ; case 'CheckPHPExtension' : if ( empty ( $ check [ 'value' ] [ 'name' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->name' component is mandatory for PHPExtension checks." ) ; } break ; case 'CheckPHPINIValue' : if ( empty ( $ check [ 'value' ] [ 'name' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->name' component is mandatory for PHPINIValue checks." ) ; } else if ( $ check [ 'value' ] [ 'value' ] == '' ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->value' component is mandatory for PHPINIValue checks." ) ; } break ; case 'CheckFileSystemComponent' : if ( empty ( $ check [ 'value' ] [ 'location' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->location' component is mandatory for FileSystemComponent checks." ) ; } else if ( empty ( $ check [ 'value' ] [ 'rights' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->rights' component is mandatory for FileSystemComponent checks." ) ; } break ; case 'CheckCustom' : if ( empty ( $ check [ 'value' ] [ 'name' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->name' component is mandatory for Custom checks." ) ; } else if ( empty ( $ check [ 'value' ] [ 'extension' ] ) ) { throw new common_ext_MalformedManifestException ( "The 'install->checks->value->extension' component is mandatory for Custom checks." ) ; } break ; default : throw new common_ext_MalformedManifestException ( "The 'install->checks->type' component value is unknown." ) ; break ; } } } $ this -> installChecks = $ installChecks ; }
|
Set the installation checks to be performed prior installation of the described Extension .
|
49,319
|
public function getLogger ( ) { if ( $ this -> logger instanceof LoggerInterface ) { return $ this -> logger ; } if ( $ this instanceof ServiceLocatorAwareInterface ) { $ logger = $ this -> getServiceLocator ( ) -> get ( LoggerService :: SERVICE_ID ) ; } else { $ logger = ServiceManager :: getServiceManager ( ) -> get ( LoggerService :: SERVICE_ID ) ; } return ( $ logger instanceof LoggerInterface ) ? $ logger : new NullLogger ( ) ; }
|
Get the logger based on service manager
|
49,320
|
public function getExpression ( ) { $ returnValue = null ; common_Logger :: i ( 'Evaluating rule ' . $ this -> getLabel ( ) . '(' . $ this -> getUri ( ) . ')' , array ( 'Generis Rule' ) ) ; if ( empty ( $ this -> expression ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_RULE_IF ) ; $ this -> expression = new core_kernel_rules_Expression ( $ this -> getUniquePropertyValue ( $ property ) -> getUri ( ) , __METHOD__ ) ; } $ returnValue = $ this -> expression ; return $ returnValue ; }
|
Short description of method getExpression
|
49,321
|
public static function singleton ( ) { $ returnValue = null ; if ( is_null ( self :: $ instance ) ) { $ class = __CLASS__ ; self :: $ instance = new $ class ( ) ; } $ returnValue = self :: $ instance ; return $ returnValue ; }
|
Main entry point to retrieve the unique NamespaceManager instance
|
49,322
|
public function getAllNamespaces ( ) { $ returnValue = array ( ) ; if ( count ( $ this -> namespaces ) == 0 ) { $ db = core_kernel_classes_DbWrapper :: singleton ( ) ; $ query = 'SELECT modelid, modeluri FROM models' ; $ result = $ db -> query ( $ query ) ; while ( $ row = $ result -> fetch ( ) ) { $ id = $ row [ 'modelid' ] ; $ uri = $ row [ 'modeluri' ] ; $ this -> namespaces [ $ id ] = $ uri ; } } foreach ( $ this -> namespaces as $ id => $ uri ) { $ returnValue [ $ uri ] = new common_ext_Namespace ( $ id , $ uri ) ; } return ( array ) $ returnValue ; }
|
Get the list of all module s namespaces
|
49,323
|
public function getNamespace ( $ modelid ) { $ returnValue = null ; if ( count ( $ this -> namespaces ) == 0 ) { $ this -> getAllNamespaces ( ) ; } if ( is_string ( $ modelid ) ) { $ modelid = array_search ( $ modelid , $ this -> namespaces ) ; } if ( is_int ( $ modelid ) ) { if ( isset ( $ this -> namespaces [ $ modelid ] ) ) { $ returnValue = new common_ext_Namespace ( $ modelid , $ this -> namespaces [ $ modelid ] ) ; } } return $ returnValue ; }
|
Get a namesapce identified by the modelId or modelUri
|
49,324
|
public function indexOf ( common_Object $ object ) { $ returnValue = ( int ) 0 ; $ returnValue = - 1 ; foreach ( $ this -> sequence as $ index => $ _object ) { if ( $ object === $ _object ) { return $ index ; } } return ( int ) $ returnValue ; }
|
return the index of the node array at which the given node resides
|
49,325
|
public function get ( $ index ) { $ returnValue = null ; $ returnValue = isset ( $ this -> sequence [ $ index ] ) ? $ this -> sequence [ $ index ] : null ; if ( $ returnValue == null ) { throw new common_Exception ( 'index is out of range' ) ; } return $ returnValue ; }
|
Retrun the node at the given index
|
49,326
|
public function isEmpty ( ) { $ returnValue = ( bool ) false ; $ returnValue = ( count ( $ this -> sequence ) == 0 ) ; return ( bool ) $ returnValue ; }
|
Short description of method isEmpty
|
49,327
|
public function remove ( common_Object $ object ) { $ returnValue = ( bool ) false ; foreach ( $ this -> sequence as $ index => $ _node ) { if ( $ _node === $ object ) { unset ( $ this -> sequence [ $ index ] ) ; $ this -> sequence = array_values ( $ this -> sequence ) ; return true ; } } return false ; return ( bool ) $ returnValue ; }
|
Remove the node from the collection
|
49,328
|
public function getSeverityDescriptionString ( ) { $ returnValue = ( string ) '' ; switch ( $ this -> severity ) { case common_Logger :: TRACE_LEVEL : $ returnValue = "TRACE" ; break ; case common_Logger :: DEBUG_LEVEL : $ returnValue = "DEBUG" ; break ; case common_Logger :: INFO_LEVEL : $ returnValue = "INFO" ; break ; case common_Logger :: WARNING_LEVEL : $ returnValue = "WARNING" ; break ; case common_Logger :: ERROR_LEVEL : $ returnValue = "ERROR" ; break ; case common_Logger :: FATAL_LEVEL : $ returnValue = "FATAL" ; break ; default : $ returnValue = "UNKNOWN" ; } return ( string ) $ returnValue ; }
|
Short description of method getSeverityDescriptionString
|
49,329
|
public static function currentRequest ( ) { if ( php_sapi_name ( ) == 'cli' ) { throw new common_exception_Error ( 'Cannot call ' . __FUNCTION__ . ' from command line' ) ; } $ https = self :: isHttps ( ) ; $ scheme = $ https ? 'https' : 'http' ; $ port = empty ( $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ) ? $ _SERVER [ 'SERVER_PORT' ] : $ _SERVER [ 'HTTP_X_FORWARDED_PORT' ] ; $ url = $ scheme . '://' . $ _SERVER [ 'SERVER_NAME' ] . ':' . $ port . $ _SERVER [ 'REQUEST_URI' ] ; $ method = $ _SERVER [ 'REQUEST_METHOD' ] ; if ( $ _SERVER [ 'REQUEST_METHOD' ] == self :: METHOD_GET ) { $ params = $ _GET ; } else { $ params = $ _POST ; } if ( function_exists ( 'apache_request_headers' ) ) { $ headers = apache_request_headers ( ) ; } else { $ headers = array ( ) ; if ( isset ( $ _SERVER [ 'CONTENT_TYPE' ] ) ) { $ headers [ 'Content-Type' ] = $ _SERVER [ 'CONTENT_TYPE' ] ; } if ( isset ( $ _ENV [ 'CONTENT_TYPE' ] ) ) { $ headers [ 'Content-Type' ] = $ _ENV [ 'CONTENT_TYPE' ] ; } foreach ( $ _SERVER as $ key => $ value ) { if ( substr ( $ key , 0 , 5 ) == "HTTP_" ) { $ key = str_replace ( " " , "-" , ucwords ( strtolower ( str_replace ( "_" , " " , substr ( $ key , 5 ) ) ) ) ) ; $ headers [ $ key ] = $ value ; } } } return new self ( $ url , $ method , $ params , $ headers ) ; }
|
Creates an request from the current call
|
49,330
|
public static function isHttps ( ) { $ https = false ; if ( isset ( $ _SERVER [ 'HTTPS' ] ) && $ _SERVER [ 'HTTPS' ] == "on" ) { $ https = true ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] ) && $ _SERVER [ 'HTTP_X_FORWARDED_PROTO' ] == 'https' || ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_SSL' ] ) && $ _SERVER [ 'HTTP_X_FORWARDED_SSL' ] == 'on' ) { $ https = true ; } return $ https ; }
|
Detect whether we use https or http
|
49,331
|
public function getHeaderValue ( $ headerName ) { if ( is_string ( $ headerName ) && count ( $ this -> headers ) > 0 ) { $ lowCaseHeaders = array_change_key_case ( $ this -> headers , CASE_LOWER ) ; $ lowCaseHeaderName = strtolower ( $ headerName ) ; if ( isset ( $ lowCaseHeaders [ $ lowCaseHeaderName ] ) ) { return $ lowCaseHeaders [ $ lowCaseHeaderName ] ; } } return false ; }
|
Get the value of an HTTP header The lookup is case insensitive .
|
49,332
|
public function get ( $ serial ) { $ returnValue = $ this -> getPersistence ( ) -> get ( $ serial ) ; if ( $ returnValue === false && ! $ this -> has ( $ serial ) ) { $ msg = "No cache entry found for '" . $ serial . "'." ; throw new common_cache_NotFoundException ( $ msg ) ; } return $ returnValue ; }
|
gets the entry associted to the serial
|
49,333
|
public function search ( QueryBuilderInterface $ Builder ) { $ this -> serialyse ( $ Builder ) ; $ statement = $ this -> connector -> query ( $ this -> parsedQuery ) ; $ result = $ this -> statementToArray ( $ statement ) ; $ resultSetClass = $ this -> resultSetClassName ; $ resultSet = new $ resultSetClass ( $ result ) ; $ queryCount = $ this -> getSerialyser ( ) -> setCriteriaList ( $ Builder ) -> count ( true ) -> serialyse ( ) ; $ resultSet -> setParent ( $ this ) -> setCountQuery ( $ queryCount ) ; return $ resultSet ; }
|
execute Parsed Query
|
49,334
|
public function count ( QueryBuilderInterface $ Builder ) { $ this -> parsedQuery = $ this -> getSerialyser ( ) -> setCriteriaList ( $ Builder ) -> count ( true ) -> serialyse ( ) ; $ statement = $ this -> connector -> query ( $ this -> parsedQuery ) ; $ result = $ this -> statementToArray ( $ statement ) ; return ( int ) reset ( $ result ) -> cpt ; }
|
return total count result
|
49,335
|
public function install ( ) { $ this -> validateOptions ( ) ; $ this -> setupServiceManager ( $ this -> getConfigPath ( ) ) ; $ this -> installFilesystem ( ) ; return new Report ( Report :: TYPE_SUCCESS , 'Oatbox installed successfully' ) ; }
|
run the install
|
49,336
|
public function setupServiceManager ( $ configPath ) { try { $ this -> getServiceManager ( ) ; } catch ( InvalidServiceManagerException $ e ) { if ( ! \ helpers_File :: emptyDirectory ( $ configPath , true ) ) { throw new \ common_exception_Error ( 'Unable to empty ' . $ configPath . ' folder.' ) ; } $ driver = new ServiceConfigDriver ( ) ; $ configService = $ driver -> connect ( 'config' , array ( 'dir' => $ configPath , 'humanReadable' => true ) ) ; $ this -> setServiceManager ( new ServiceManager ( $ configService ) ) ; } return $ this -> getServiceManager ( ) ; }
|
Setup the service manager with configuration driver associated to config path
|
49,337
|
protected function installFilesystem ( ) { try { if ( ! ( $ this -> getServiceManager ( ) -> get ( FileSystemService :: SERVICE_ID ) instanceof FileSystemService ) ) { throw new InvalidService ( 'Your service must be a oat\oatbox\filesystem\FileSystemService' ) ; } } catch ( ServiceNotFoundException $ e ) { $ fileSystemService = new FileSystemService ( array ( FileSystemService :: OPTION_FILE_PATH => $ this -> getOption ( 'file_path' ) ) ) ; $ this -> getServiceManager ( ) -> register ( FileSystemService :: SERVICE_ID , $ fileSystemService ) ; } }
|
Install the filesystem service if not already installed
|
49,338
|
protected function validateOptions ( ) { if ( ! $ this -> hasOption ( 'root_path' ) || empty ( $ this -> getOption ( 'root_path' ) ) ) { throw new \ common_exception_MissingParameter ( 'root_path' , __CLASS__ ) ; } if ( ! $ this -> hasOption ( 'file_path' ) || empty ( $ this -> getOption ( 'file_path' ) ) ) { throw new \ common_exception_MissingParameter ( 'file_path' , __CLASS__ ) ; } }
|
Validate require option e . q . file_path & root_path
|
49,339
|
protected function getConfigPath ( ) { if ( $ this -> hasOption ( 'config_path' ) && ! empty ( $ this -> getOption ( 'config_path' ) ) ) { return $ this -> getOption ( 'config_path' ) ; } return rtrim ( $ this -> getOption ( 'root_path' ) , '/\\' ) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR ; }
|
Get the path where to install config
|
49,340
|
public static function rmWorkingCopy ( $ path , $ recursive = true ) { $ returnValue = ( bool ) false ; if ( is_file ( $ path ) ) { if ( preg_match ( '/^\//' , $ path ) ) { $ returnValue = @ unlink ( $ path ) ; } } else if ( $ recursive ) { if ( is_dir ( $ path ) ) { $ iterator = new DirectoryIterator ( $ path ) ; foreach ( $ iterator as $ fileinfo ) { if ( ! $ fileinfo -> isDot ( ) ) { self :: rmWorkingCopy ( $ fileinfo -> getPathname ( ) , true ) ; } unset ( $ fileinfo ) ; } unset ( $ iterator ) ; $ returnValue = @ rmdir ( $ path ) ; } } return ( bool ) $ returnValue ; }
|
Short description of method rmWorkingCopy
|
49,341
|
public static function cpWorkingCopy ( $ source , $ destination , $ recursive = true , $ ignoreSystemFiles = true ) { $ returnValue = ( bool ) false ; if ( file_exists ( $ source ) ) { if ( is_dir ( $ source ) && $ recursive ) { foreach ( scandir ( $ source ) as $ file ) { if ( $ file != '.' && $ file != '..' && $ file != '.svn' ) { if ( ! $ ignoreSystemFiles && $ file [ 0 ] == '.' ) { continue ; } else { self :: cpWorkingCopy ( $ source . '/' . $ file , $ destination . '/' . $ file , true , $ ignoreSystemFiles ) ; } } } } else { if ( is_dir ( dirname ( $ destination ) ) ) { $ returnValue = copy ( $ source , $ destination ) ; } else if ( $ recursive ) { if ( mkdir ( dirname ( $ destination ) , 0775 , true ) ) { $ returnValue = self :: cpWorkingCopy ( $ source , $ destination , false , $ ignoreSystemFiles ) ; } } } } return ( bool ) $ returnValue ; }
|
Short description of method cpWorkingCopy
|
49,342
|
protected function saveFile ( $ path , $ name ) { $ filename = $ this -> getUniqueFilename ( $ name ) ; $ dir = $ this -> getServiceManager ( ) -> get ( FileSystemService :: SERVICE_ID ) -> getDirectory ( Queue :: FILE_SYSTEM_ID ) ; $ filesystem = $ dir -> getFileSystem ( ) ; $ stream = fopen ( $ path , 'r+' ) ; $ filesystem -> writeStream ( $ filename , $ stream ) ; fclose ( $ stream ) ; $ file = $ dir -> getFile ( $ filename ) ; return $ this -> getFileReferenceSerializer ( ) -> serialize ( $ file ) ; }
|
Save and serialize file into task queue filesystem .
|
49,343
|
protected function getDSN ( ) { $ params = $ this -> getParams ( ) ; $ driver = str_replace ( 'pdo_' , '' , $ params [ 'driver' ] ) ; $ dbName = $ params [ 'dbname' ] ; $ dbUrl = $ params [ 'host' ] ; $ dbPort = isset ( $ params [ 'port' ] ) ? ';port=' . $ params [ 'port' ] : '' ; return $ driver . ':dbname=' . $ dbName . ';host=' . $ dbUrl . $ dbPort ; }
|
Short description of method getDSN
|
49,344
|
public function connect ( $ id , array $ params ) { $ returnValue = null ; $ this -> params = $ params ; $ driver = $ params [ 'driver' ] ; $ dbLogin = $ params [ 'user' ] ; $ dbpass = $ params [ 'password' ] ; $ connLimit = 3 ; $ counter = 0 ; while ( true ) { $ dsn = $ this -> getDSN ( ) ; $ options = array ( PDO :: ATTR_DEFAULT_FETCH_MODE => PDO :: FETCH_BOTH , PDO :: ATTR_PERSISTENT => false , PDO :: ATTR_EMULATE_PREPARES => false ) ; foreach ( $ this -> getExtraConfiguration ( ) as $ k => $ v ) { $ options [ $ k ] = $ v ; } try { $ this -> dbConnector = @ new PDO ( $ dsn , $ dbLogin , $ dbpass , $ options ) ; $ this -> afterConnect ( ) ; break ; } catch ( PDOException $ e ) { $ this -> dbConnector = null ; $ counter ++ ; if ( $ counter == $ connLimit ) { throw $ e ; } } } $ returnValue = new common_persistence_SqlPersistence ( $ params , $ this ) ; ; return $ returnValue ; }
|
Connect the SQL driver
|
49,345
|
public function prepare ( $ statement ) { $ returnValue = null ; $ this -> preparedExec = false ; $ returnValue = $ this -> getStatement ( $ statement ) ; return $ returnValue ; }
|
Creates a prepared PDOStatement .
|
49,346
|
protected function getStatement ( $ statement ) { $ key = $ this -> getStatementKey ( $ statement ) ; $ sth = null ; if ( ! empty ( $ this -> statements [ $ key ] ) ) { $ sth = $ this -> statements [ $ key ] ; } else { $ sth = $ this -> dbConnector -> prepare ( $ statement ) ; $ this -> statements [ $ key ] = $ sth ; } return $ sth ; }
|
Get a statement in the statement store regarding the provided statement . it could not be found NULL is returned .
|
49,347
|
public static function t ( $ message , $ tags = array ( ) ) { self :: singleton ( ) -> log ( self :: TRACE_LEVEL , $ message , $ tags ) ; }
|
trace logs finest - grained processes informations
|
49,348
|
public static function d ( $ message , $ tags = array ( ) ) { self :: singleton ( ) -> log ( self :: DEBUG_LEVEL , $ message , $ tags ) ; }
|
debug logs fine grained informations for debugging
|
49,349
|
public static function i ( $ message , $ tags = array ( ) ) { self :: singleton ( ) -> log ( self :: INFO_LEVEL , $ message , $ tags ) ; }
|
info logs high level system events
|
49,350
|
public static function w ( $ message , $ tags = array ( ) ) { self :: singleton ( ) -> log ( self :: WARNING_LEVEL , $ message , $ tags ) ; }
|
warning logs events that represent potential problems
|
49,351
|
public static function e ( $ message , $ tags = array ( ) ) { self :: singleton ( ) -> log ( self :: ERROR_LEVEL , $ message , self :: addTrace ( $ tags ) ) ; }
|
error logs events that allow the system to continue
|
49,352
|
public static function f ( $ message , $ tags = array ( ) ) { self :: singleton ( ) -> log ( self :: FATAL_LEVEL , $ message , self :: addTrace ( $ tags ) ) ; }
|
fatal logs very severe error events that prevent the system to continue
|
49,353
|
public function handleException ( Exception $ exception ) { $ severity = method_exists ( $ exception , 'getSeverity' ) ? $ exception -> getSeverity ( ) : self :: ERROR_LEVEL ; self :: singleton ( ) -> log ( $ severity , $ exception -> getMessage ( ) , [ self :: CONTEXT_EXCEPTION => get_class ( $ exception ) , self :: CONTEXT_ERROR_FILE => $ exception -> getFile ( ) , self :: CONTEXT_ERROR_LINE => $ exception -> getLine ( ) , self :: CONTEXT_TRACE => $ exception -> getTrace ( ) ] ) ; }
|
Short description of method handleException
|
49,354
|
public function handlePHPErrors ( $ errorNumber , $ errorString , $ errorFile = null , $ errorLine = null , $ errorContext = array ( ) ) { if ( error_reporting ( ) !== 0 ) { if ( $ errorNumber === E_STRICT ) { foreach ( $ this -> ACCEPTABLE_WARNINGS as $ pattern ) { if ( preg_match ( $ pattern , $ errorString ) > 0 ) { return false ; } } } switch ( $ errorNumber ) { case E_USER_ERROR : case E_RECOVERABLE_ERROR : $ severity = self :: FATAL_LEVEL ; break ; case E_WARNING : case E_USER_WARNING : $ severity = self :: ERROR_LEVEL ; break ; case E_NOTICE : case E_USER_NOTICE : $ severity = self :: WARNING_LEVEL ; break ; case E_DEPRECATED : case E_USER_DEPRECATED : case E_STRICT : $ severity = self :: DEBUG_LEVEL ; break ; default : self :: d ( 'Unsupported PHP error type: ' . $ errorNumber , 'common_Logger' ) ; $ severity = self :: ERROR_LEVEL ; break ; } self :: singleton ( ) -> log ( $ severity , sprintf ( 'php error(%s): %s' , $ errorNumber , $ errorString ) , [ 'PHPERROR' , self :: CONTEXT_ERROR_FILE => $ errorFile , self :: CONTEXT_ERROR_LINE => $ errorLine , self :: CONTEXT_TRACE => self :: addTrace ( ) ] ) ; } return false ; }
|
A handler for php errors should never be called manually
|
49,355
|
public function handlePHPShutdown ( ) { $ error = error_get_last ( ) ; if ( ( $ error [ 'type' ] & ( E_COMPILE_ERROR | E_ERROR | E_PARSE | E_CORE_ERROR ) ) != 0 ) { $ msg = ( isset ( $ error [ 'file' ] ) && isset ( $ error [ 'line' ] ) ) ? 'php error(' . $ error [ 'type' ] . ') in ' . $ error [ 'file' ] . '@' . $ error [ 'line' ] . ': ' . $ error [ 'message' ] : 'php error(' . $ error [ 'type' ] . '): ' . $ error [ 'message' ] ; self :: singleton ( ) -> log ( self :: FATAL_LEVEL , $ msg , array ( 'PHPERROR' ) ) ; } }
|
a workaround to catch fatal errors by handling the php shutdown should never be called manually
|
49,356
|
protected function getContext ( ) { $ trace = debug_backtrace ( ) ; $ file = isset ( $ trace [ 2 ] [ 'file' ] ) ? $ trace [ 2 ] [ 'file' ] : '' ; $ line = isset ( $ trace [ 2 ] [ 'line' ] ) ? $ trace [ 2 ] [ 'line' ] : '' ; return [ 'file' => $ file , 'line' => $ line , ] ; }
|
Returns the calling context .
|
49,357
|
private function propertiesValuestoStdClasses ( $ propertiesValues = null ) { $ returnValue = array ( ) ; foreach ( $ propertiesValues as $ uri => $ values ) { $ propStdClass = new stdClass ; $ propStdClass -> predicateUri = $ uri ; foreach ( $ values as $ value ) { $ stdValue = new stdClass ; $ stdValue -> valueType = ( get_class ( $ value ) == "core_kernel_classes_Literal" ) ? "literal" : "resource" ; $ stdValue -> value = ( get_class ( $ value ) == "core_kernel_classes_Literal" ) ? $ value -> __toString ( ) : $ value -> getUri ( ) ; $ propStdClass -> values [ ] = $ stdValue ; } $ returnValue [ ] = $ propStdClass ; } return $ returnValue ; }
|
small helper provide more convenient data structure for propertiesValues for exchange
|
49,358
|
protected function load ( $ modelId , $ file ) { $ easyRdf = new EasyRdf_Graph ( ) ; $ easyRdf -> parseFile ( $ file ) ; foreach ( $ easyRdf -> toRdfPhp ( ) as $ subject => $ propertiesValues ) { foreach ( $ propertiesValues as $ predicate => $ values ) { foreach ( $ values as $ k => $ v ) { $ triple = new core_kernel_classes_Triple ( ) ; $ triple -> modelid = $ modelId ; $ triple -> subject = $ subject ; $ triple -> predicate = $ predicate ; $ triple -> object = $ v [ 'value' ] ; $ triple -> lg = isset ( $ v [ 'lang' ] ) ? $ v [ 'lang' ] : null ; $ this -> triples [ ] = $ triple ; } } } }
|
load triples from rdf file
|
49,359
|
public function install ( ) { if ( $ this -> extension -> getId ( ) != 'generis' ) { throw new common_ext_ExtensionException ( 'Tried to install "' . $ this -> extension -> getId ( ) . '" extension using the GenerisInstaller' ) ; } $ this -> installLoadDefaultConfig ( ) ; $ model = new \ core_kernel_persistence_smoothsql_SmoothModel ( array ( \ core_kernel_persistence_smoothsql_SmoothModel :: OPTION_PERSISTENCE => 'default' , \ core_kernel_persistence_smoothsql_SmoothModel :: OPTION_READABLE_MODELS => array ( '1' ) , \ core_kernel_persistence_smoothsql_SmoothModel :: OPTION_WRITEABLE_MODELS => array ( '1' ) , \ core_kernel_persistence_smoothsql_SmoothModel :: OPTION_NEW_TRIPLE_MODEL => '1' , \ core_kernel_persistence_smoothsql_SmoothModel :: OPTION_SEARCH_SERVICE => ComplexSearchService :: SERVICE_ID , \ core_kernel_persistence_smoothsql_SmoothModel :: OPTION_CACHE_SERVICE => common_cache_Cache :: SERVICE_ID ) ) ; $ model -> setServiceLocator ( ServiceManager :: getServiceManager ( ) ) ; ModelManager :: setModel ( $ model ) ; $ this -> installOntology ( ) ; $ this -> installRegisterExt ( ) ; common_cache_FileCache :: singleton ( ) -> purge ( ) ; $ this -> log ( 'd' , 'Installing custom script for extension ' . $ this -> extension -> getId ( ) ) ; $ this -> installCustomScript ( ) ; }
|
Setup the ontology configuration
|
49,360
|
public function getStatusAsString ( ) { $ returnValue = ( string ) '' ; switch ( $ this -> getStatus ( ) ) { case self :: INVALID : $ returnValue = 'invalid' ; break ; case self :: UNKNOWN : $ returnValue = 'unknown' ; break ; case self :: VALID : $ returnValue = 'valid' ; break ; } return ( string ) $ returnValue ; }
|
Short description of method getStatusAsString
|
49,361
|
public function connect ( $ id , array $ params ) { if ( isset ( $ params [ 'connection' ] ) ) { $ connectionParams = $ params [ 'connection' ] ; } else { $ connectionParams = $ params ; $ connectionParams [ 'driver' ] = str_replace ( 'dbal_' , '' , $ connectionParams [ 'driver' ] ) ; } $ this -> persistentConnect ( $ connectionParams ) ; return new common_persistence_SqlPersistence ( $ params , $ this ) ; }
|
Connect to Dbal
|
49,362
|
public static function create ( Traversable $ from , Traversable $ to ) { $ diff = new self ( ) ; foreach ( $ to as $ triple ) { $ diff -> add ( $ triple ) ; } foreach ( $ from as $ triple ) { $ diff -> remove ( $ triple ) ; } return $ diff ; }
|
Creates a diff from a set of triples to a set of troples
|
49,363
|
public static function getMissingExtensionIds ( $ extensions ) { $ inList = array ( ) ; foreach ( $ extensions as $ ext ) { $ inList [ ] = $ ext -> getId ( ) ; } $ missing = array ( ) ; foreach ( $ extensions as $ ext ) { foreach ( $ ext -> getDependencies ( ) as $ extId => $ version ) { if ( ! in_array ( $ extId , $ inList ) && ! in_array ( $ extId , $ missing ) ) { $ missing [ ] = $ extId ; } } } return $ missing ; }
|
Based on a list of extensions we generate an array of missing extensions
|
49,364
|
public static function sortByDependencies ( $ extensions ) { $ sorted = array ( ) ; $ unsorted = array ( ) ; foreach ( $ extensions as $ ext ) { $ unsorted [ $ ext -> getId ( ) ] = array_keys ( $ ext -> getDependencies ( ) ) ; } while ( ! empty ( $ unsorted ) ) { $ before = count ( $ unsorted ) ; foreach ( array_keys ( $ unsorted ) as $ id ) { $ missing = array_diff ( $ unsorted [ $ id ] , $ sorted ) ; if ( empty ( $ missing ) ) { $ sorted [ ] = $ id ; unset ( $ unsorted [ $ id ] ) ; } } if ( count ( $ unsorted ) == $ before ) { $ notfound = array_diff ( $ missing , array_keys ( $ unsorted ) ) ; if ( ! empty ( $ notfound ) ) { throw new common_exception_Error ( 'Missing extensions ' . implode ( ',' , $ notfound ) . ' for: ' . implode ( ',' , array_keys ( $ unsorted ) ) ) ; } else { throw new common_exception_Error ( 'Cyclic extension dependencies for: ' . implode ( ',' , array_keys ( $ unsorted ) ) ) ; } } } $ returnValue = array ( ) ; foreach ( $ sorted as $ id ) { foreach ( $ extensions as $ ext ) { if ( $ ext -> getId ( ) == $ id ) { $ returnValue [ $ id ] = $ ext ; } } } return $ returnValue ; }
|
Sorts a list of extensions by dependencies starting with independent extensions
|
49,365
|
public static function isRequired ( common_ext_Extension $ extension ) { foreach ( common_ext_ExtensionsManager :: singleton ( ) -> getInstalledExtensions ( ) as $ ext ) { foreach ( $ ext -> getDependencies ( ) as $ extId => $ version ) { if ( $ extId == $ extension -> getId ( ) ) { return true ; } } } return false ; }
|
Whenever or not the extension is required by other installed extensions
|
49,366
|
public static function mustBeEnabled ( common_ext_Extension $ extension ) { foreach ( common_ext_ExtensionsManager :: singleton ( ) -> getEnabledExtensions ( ) as $ ext ) { foreach ( $ ext -> getDependencies ( ) as $ extId => $ version ) { if ( $ extId == $ extension -> getId ( ) ) { return true ; } } } return false ; }
|
Whenever or not the extension is required to be enabled by other enabled extensions
|
49,367
|
public static function checkRequiredExtensions ( common_ext_Extension $ extension ) { $ extensionManager = common_ext_ExtensionsManager :: singleton ( ) ; foreach ( $ extension -> getManifest ( ) -> getDependencies ( ) as $ requiredExt => $ requiredVersion ) { $ installedVersion = $ extensionManager -> getInstalledVersion ( $ requiredExt ) ; if ( is_null ( $ installedVersion ) ) { throw new common_ext_MissingExtensionException ( 'Extension ' . $ requiredExt . ' is needed by the extension to be installed but is missing.' , 'GENERIS' ) ; } if ( $ requiredVersion != '*' ) { $ conditions = is_array ( $ requiredVersion ) ? $ requiredVersion : [ $ requiredVersion ] ; foreach ( $ conditions as $ condition ) { $ matches = array ( ) ; preg_match ( '/[0-9\.]+/' , $ condition , $ matches , PREG_OFFSET_CAPTURE ) ; if ( count ( $ matches ) == 1 ) { $ match = current ( $ matches ) ; $ nr = $ match [ 0 ] ; $ operator = $ match [ 1 ] > 0 ? substr ( $ condition , 0 , $ match [ 1 ] ) : '=' ; if ( ! version_compare ( $ installedVersion , $ nr , $ operator ) ) { throw new common_ext_OutdatedVersionException ( 'Installed version of ' . $ requiredExt . ' ' . $ installedVersion . ' does not satisfy required ' . $ condition . ' for ' . $ extension -> getId ( ) ) ; } } else { throw new common_exception_Error ( 'Unsupported version requirement: "' . $ condition . '"' ) ; } } } } return true ; }
|
Check if extension requirements are met Always returns true but throws exception on error
|
49,368
|
public static function retrieveIncludedRoles ( core_kernel_classes_Resource $ role ) { $ returnValue = array ( ) ; try { $ serial = self :: buildIncludedRolesSerial ( $ role ) ; $ fromCache = ServiceManager :: getServiceManager ( ) -> get ( 'generis/cache' ) -> get ( $ serial ) ; foreach ( $ fromCache as $ uri ) { $ returnValue [ $ uri ] = new core_kernel_classes_Resource ( $ uri ) ; } } catch ( common_cache_Exception $ e ) { $ roleUri = $ role -> getUri ( ) ; $ msg = "Includes roles related to Role with URI '${roleUri}' is not in the Cache memory." ; throw new core_kernel_users_CacheException ( $ msg ) ; } return ( array ) $ returnValue ; }
|
Retrieve roles included in a given Generis Role from the Cache memory .
|
49,369
|
public static function cacheIncludedRoles ( core_kernel_classes_Resource $ role , $ includedRoles ) { $ toCache = array ( ) ; foreach ( $ includedRoles as $ resource ) { $ toCache [ ] = $ resource -> getUri ( ) ; } $ serial = self :: buildIncludedRolesSerial ( $ role ) ; $ cache = ServiceManager :: getServiceManager ( ) -> get ( 'generis/cache' ) ; try { $ cache -> put ( $ toCache , $ serial ) ; $ returnValue = true ; } catch ( common_Exception $ e ) { $ roleUri = $ role -> getUri ( ) ; $ msg = "An error occurred while writing included roles in the cache memory for Role '${roleUri}': " ; $ msg .= $ e -> getMessage ( ) ; throw new core_kernel_users_CacheException ( $ msg ) ; } return ( bool ) $ returnValue ; }
|
Put roles included in a Generis Role in the Cache memory .
|
49,370
|
public static function removeIncludedRoles ( core_kernel_classes_Resource $ role ) { $ serial = self :: buildIncludedRolesSerial ( $ role ) ; ServiceManager :: getServiceManager ( ) -> get ( 'generis/cache' ) -> remove ( $ serial ) ; ; return true ; }
|
Remove roles included in a Generis Role from the Cache memory .
|
49,371
|
public static function areIncludedRolesInCache ( core_kernel_classes_Resource $ role ) { $ serial = self :: buildIncludedRolesSerial ( $ role ) ; return ServiceManager :: getServiceManager ( ) -> get ( 'generis/cache' ) -> has ( $ serial ) ; }
|
Returns true if the roles included in a given Generis Role are in the memory .
|
49,372
|
public static function login ( $ userLogin , $ userPassword ) { try { $ user = self :: authenticate ( $ userLogin , $ userPassword ) ; $ loggedIn = self :: startSession ( $ user ) ; } catch ( common_user_auth_AuthFailedException $ e ) { $ loggedIn = false ; } return $ loggedIn ; }
|
Login a user using login password
|
49,373
|
public static function startSession ( common_user_User $ user ) { $ session = new common_session_DefaultSession ( $ user ) ; common_session_SessionManager :: startSession ( $ session ) ; return true ; }
|
Start a session for a provided user
|
49,374
|
public function getLogicalOperator ( ) { $ returnValue = null ; if ( empty ( $ this -> logicalOperator ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_HASLOGICALOPERATOR ) ; $ this -> logicalOperator = $ this -> getUniquePropertyValue ( $ property ) ; } $ returnValue = $ this -> logicalOperator ; return $ returnValue ; }
|
Short description of method getLogicalOperator
|
49,375
|
public function getTerminalExpression ( ) { $ returnValue = null ; $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_TERMINAL_EXPRESSION ) ; $ propertyValue = $ this -> getUniquePropertyValue ( $ property ) ; if ( $ propertyValue instanceof core_kernel_classes_Resource ) { $ returnValue = new core_kernel_rules_Term ( $ propertyValue -> getUri ( ) ) ; $ returnValue -> debug = __METHOD__ ; } else { throw new common_Exception ( 'property retrieve should be a Resource' ) ; } return $ returnValue ; }
|
Short description of method getTerminalExpression
|
49,376
|
public function getFirstExpression ( ) { $ returnValue = null ; if ( empty ( $ this -> firstExpression ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_FIRST_EXPRESSION ) ; $ this -> firstExpression = new core_kernel_rules_Expression ( $ this -> getUniquePropertyValue ( $ property ) -> getUri ( ) ) ; } $ returnValue = $ this -> firstExpression ; return $ returnValue ; }
|
Short description of method getFirstExpression
|
49,377
|
public function getSecondExpression ( ) { $ returnValue = null ; if ( empty ( $ this -> secondExpression ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_SECOND_EXPRESSION ) ; $ this -> secondExpression = new core_kernel_rules_Expression ( $ this -> getUniquePropertyValue ( $ property ) -> getUri ( ) ) ; } $ returnValue = $ this -> secondExpression ; return $ returnValue ; }
|
Short description of method getSecondExpression
|
49,378
|
public function evalEquals ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second ) { $ returnValue = ( bool ) false ; if ( $ first instanceof core_kernel_classes_Literal && $ second instanceof core_kernel_classes_Literal ) { $ returnValue = $ first -> literal == $ second -> literal ; } return ( bool ) $ returnValue ; }
|
Short description of method evalEquals
|
49,379
|
public function evalDifferent ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second ) { $ returnValue = ( bool ) false ; if ( $ first instanceof core_kernel_classes_Literal && $ second instanceof core_kernel_classes_Literal ) { $ returnValue = $ first -> literal != $ second -> literal ; } return ( bool ) $ returnValue ; }
|
Short description of method evalDifferent
|
49,380
|
public function evalInfEquals ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second ) { $ returnValue = ( bool ) false ; if ( $ first instanceof core_kernel_classes_Literal && $ second instanceof core_kernel_classes_Literal ) { $ returnValue = $ first -> literal <= $ second -> literal ; } return ( bool ) $ returnValue ; }
|
Short description of method evalInfEquals
|
49,381
|
public function evalInf ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second ) { $ returnValue = ( bool ) false ; if ( $ first instanceof core_kernel_classes_Literal && $ second instanceof core_kernel_classes_Literal ) { $ returnValue = $ first -> literal < $ second -> literal ; } return ( bool ) $ returnValue ; }
|
Short description of method evalInf
|
49,382
|
public function evalSup ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second ) { $ returnValue = ( bool ) false ; if ( $ first instanceof core_kernel_classes_Literal && $ second instanceof core_kernel_classes_Literal ) { $ returnValue = $ first -> literal > $ second -> literal ; } return ( bool ) $ returnValue ; }
|
Short description of method evalSup
|
49,383
|
public function evalSupEquals ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second ) { $ returnValue = ( bool ) false ; if ( $ first instanceof core_kernel_classes_Literal && $ second instanceof core_kernel_classes_Literal ) { $ returnValue = $ first -> literal >= $ second -> literal ; } return ( bool ) $ returnValue ; }
|
Short description of method evalSupEquals
|
49,384
|
public function operatorEval ( core_kernel_classes_Container $ firstPart , core_kernel_classes_Container $ secondPart ) { $ returnValue = ( bool ) false ; if ( $ firstPart instanceof core_kernel_classes_Resource ) { $ firstPart = new core_kernel_classes_Literal ( $ firstPart -> getUri ( ) ) ; } if ( $ secondPart instanceof core_kernel_classes_Resource ) { $ secondPart = new core_kernel_classes_Literal ( $ secondPart -> getUri ( ) ) ; } common_Logger :: d ( 'First Value : ' . $ firstPart -> literal , array ( 'Generis Expression' ) ) ; common_Logger :: d ( 'Second Value : ' . $ secondPart -> literal , array ( 'Generis Expression' ) ) ; common_Logger :: d ( 'Operator : ' . $ this -> getLogicalOperator ( ) -> getLabel ( ) , array ( 'Generis Expression' ) ) ; switch ( $ this -> getLogicalOperator ( ) -> getUri ( ) ) { case RulesRdf :: INSTANCE_EQUALS_OPERATOR_URI : { $ returnValue = $ this -> evalEquals ( $ firstPart , $ secondPart ) ; break ; } case RulesRdf :: INSTANCE_DIFFERENT_OPERATOR_URI : { $ returnValue = $ this -> evalDifferent ( $ firstPart , $ secondPart ) ; break ; } case RulesRdf :: INSTANCE_SUP_EQ_OPERATOR_URI : { $ returnValue = $ this -> evalSupEquals ( $ firstPart , $ secondPart ) ; break ; } case RulesRdf :: INSTANCE_INF_EQ_OPERATOR_URI : { $ returnValue = $ this -> evalInfEquals ( $ firstPart , $ secondPart ) ; break ; } case RulesRdf :: INSTANCE_SUP_OPERATOR_URI : { $ returnValue = $ this -> evalSup ( $ firstPart , $ secondPart ) ; break ; } case RulesRdf :: INSTANCE_INF_OPERATOR_URI : { $ returnValue = $ this -> evalInf ( $ firstPart , $ secondPart ) ; break ; } default : { var_dump ( $ this ) ; throw new common_Exception ( 'Expression ' . $ this -> getLabel ( ) . ' do not have knowm operator' ) ; } } $ logValue = $ returnValue ? ' TRUE ' : ' FALSE ' ; common_Logger :: d ( 'Expression Value : ' . $ logValue , array ( 'Generis Expression' ) ) ; return ( bool ) $ returnValue ; }
|
Short description of method operatorEval
|
49,385
|
public function getFirstOperation ( ) { $ returnValue = null ; if ( empty ( $ this -> firstOperation ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_OPERATION_FIRST_OP ) ; $ resource = $ this -> getUniquePropertyValue ( $ property ) ; $ this -> firstOperation = new core_kernel_rules_Term ( $ resource -> getUri ( ) ) ; } $ returnValue = $ this -> firstOperation ; return $ returnValue ; }
|
Short description of method getFirstOperation
|
49,386
|
public function getSecondOperation ( ) { $ returnValue = null ; if ( empty ( $ this -> secondOperation ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_OPERATION_SECOND_OP ) ; $ resource = $ this -> getUniquePropertyValue ( $ property ) ; $ this -> secondOperation = new core_kernel_rules_Term ( $ resource -> getUri ( ) ) ; } $ returnValue = $ this -> secondOperation ; return $ returnValue ; }
|
Short description of method getSecondOperation
|
49,387
|
public function getOperator ( ) { $ returnValue = null ; if ( empty ( $ this -> arithmeticOperator ) ) { $ property = new core_kernel_classes_Property ( RulesRdf :: PROPERTY_OPERATION_OPERATOR ) ; $ this -> arithmeticOperator = $ this -> getUniquePropertyValue ( $ property ) ; } $ returnValue = $ this -> arithmeticOperator ; return $ returnValue ; }
|
Short description of method getOperator
|
49,388
|
public function evaluateRecursiveOperation ( core_kernel_classes_Literal $ first , core_kernel_classes_Literal $ second , core_kernel_classes_Resource $ operator ) { switch ( $ operator -> getUri ( ) ) { case RulesRdf :: INSTANCE_OPERATOR_ADD : { $ returnValue = new core_kernel_classes_Literal ( $ first -> literal + $ second -> literal ) ; break ; } case RulesRdf :: INSTANCE_OPERATOR_MINUS : { $ returnValue = new core_kernel_classes_Literal ( $ first -> literal - $ second -> literal ) ; break ; } case RulesRdf :: INSTANCE_OPERATOR_MULTIPLY : { $ returnValue = new core_kernel_classes_Literal ( $ first -> literal * $ second -> literal ) ; break ; } case RulesRdf :: INSTANCE_OPERATOR_DIVISION : { $ returnValue = new core_kernel_classes_Literal ( $ first -> literal / $ second -> literal ) ; break ; } case RulesRdf :: INSTANCE_OPERATOR_CONCAT : { $ returnValue = new core_kernel_classes_Literal ( $ first -> literal . ' ' . $ second -> literal ) ; break ; } default : { throw new common_Exception ( 'problem evaluating operation, operator do not match with operands' ) ; } } $ returnValue -> debug = __METHOD__ ; return $ returnValue ; }
|
Short description of method evaluateRecursiveOperation
|
49,389
|
public function uninstall ( ) { common_Logger :: i ( 'Uninstalling ' . $ this -> extension -> getId ( ) , 'UNINSTALL' ) ; if ( is_null ( $ this -> extension -> getManifest ( ) -> getUninstallData ( ) ) ) { throw new common_Exception ( 'Problem uninstalling extension ' . $ this -> extension -> getId ( ) . ' : Uninstall not supported' ) ; } if ( ! common_ext_ExtensionsManager :: singleton ( ) -> isInstalled ( $ this -> extension -> getId ( ) ) ) { throw new common_Exception ( 'Problem uninstalling extension ' . $ this -> extension -> getId ( ) . ' : Not installed' ) ; } if ( helpers_ExtensionHelper :: isRequired ( $ this -> extension ) ) { throw new common_Exception ( 'Problem uninstalling extension ' . $ this -> extension -> getId ( ) . ' : Still required' ) ; } ; common_Logger :: d ( 'uninstall script for ' . $ this -> extension -> getId ( ) ) ; $ this -> uninstallScripts ( ) ; $ this -> extendedUninstall ( ) ; common_Logger :: d ( 'unregister extension ' . $ this -> extension -> getId ( ) ) ; $ this -> unregister ( ) ; $ cache = common_cache_FileCache :: singleton ( ) ; $ cache -> purge ( ) ; common_Logger :: i ( 'Uninstalled ' . $ this -> extension -> getId ( ) ) ; return true ; }
|
uninstall an extension
|
49,390
|
protected function uninstallScripts ( ) { $ data = $ this -> extension -> getManifest ( ) -> getUninstallData ( ) ; if ( ! is_null ( $ data ) && isset ( $ data [ 'php' ] ) && is_array ( $ data [ 'php' ] ) ) { foreach ( $ data [ 'php' ] as $ script ) { $ this -> runExtensionScript ( $ script ) ; } } }
|
Executes uninstall scripts specified in the Manifest
|
49,391
|
public function addAppender ( common_log_Appender $ appender ) { $ this -> appenders [ ] = $ appender ; if ( is_null ( $ this -> minLevel ) || $ this -> minLevel > $ appender -> getLogThreshold ( ) ) { $ this -> minLevel = $ appender -> getLogThreshold ( ) ; } }
|
Short description of method addAppender
|
49,392
|
public function get ( $ serviceKey ) { $ serviceId = $ this -> getServiceId ( $ serviceKey ) ; if ( ! isset ( $ this -> services [ $ serviceId ] ) ) { $ this -> services [ $ serviceId ] = $ this -> load ( $ serviceId , $ serviceKey ) ; } return $ this -> services [ $ serviceId ] ; }
|
Returns the service configured for the serviceKey or throws a ServiceNotFoundException
|
49,393
|
private function getServiceId ( $ serviceKey ) { return ( ( interface_exists ( $ serviceKey ) || class_exists ( $ serviceKey ) ) && defined ( $ serviceKey . '::SERVICE_ID' ) ) ? $ serviceKey :: SERVICE_ID : ( string ) $ serviceKey ; }
|
Extract the service id from the provided parameter
|
49,394
|
private function load ( $ serviceId , $ serviceKey ) { $ service = $ this -> getConfig ( ) -> get ( $ serviceId ) ; if ( $ service === false ) { $ service = $ this -> tryAutowiring ( $ serviceId , $ serviceKey ) ; } if ( is_object ( $ service ) && ( $ service instanceof ServiceLocatorAwareInterface ) ) { $ service -> setServiceLocator ( $ this ) ; } return $ service ; }
|
Loads the service referenced by id
|
49,395
|
private function tryAutowiring ( $ serviceId , $ serviceKey ) { if ( ! class_exists ( $ serviceKey ) || ! is_subclass_of ( $ serviceKey , ConfigurableService :: class ) ) { throw new ServiceNotFoundException ( $ serviceId ) ; } return new $ serviceKey ( ) ; }
|
Try to initialize the class without parameters
|
49,396
|
public function register ( $ serviceKey , ConfigurableService $ service ) { $ parts = explode ( '/' , $ serviceKey , 2 ) ; if ( count ( $ parts ) < 2 ) { throw new \ common_Exception ( 'Invalid servicekey ' . $ serviceKey ) ; } $ this -> propagate ( $ service ) ; $ this -> services [ $ serviceKey ] = $ service ; $ success = $ this -> getConfig ( ) -> set ( $ serviceKey , $ service ) ; if ( ! $ success ) { throw new \ common_exception_Error ( 'Unable to write ' . $ serviceKey ) ; } }
|
Registers a service overwritting a potentially already existing service . 3
|
49,397
|
public function build ( $ className , array $ options = [ ] ) { if ( is_a ( $ className , Configurable :: class , true ) ) { $ service = new $ className ( $ options ) ; $ this -> propagate ( $ service ) ; return $ service ; } throw new ServiceNotFoundException ( $ className ) ; }
|
Service or sub - service factory
|
49,398
|
private static function secondsToDuration ( $ seconds ) { $ seconds = intval ( $ seconds ) ; $ hours = floor ( $ seconds / 3600 ) ; $ minutes = floor ( ( $ seconds / 60 ) % 60 ) ; $ seconds = $ seconds % 60 ; return "${hours}h ${minutes}m {$seconds}s" ; }
|
Seconds to Duration
|
49,399
|
public function isClass ( ) { $ returnValue = ( bool ) false ; if ( count ( $ this -> getPropertyValues ( $ this -> getProperty ( OntologyRdfs :: RDFS_SUBCLASSOF ) ) ) > 0 ) { $ returnValue = true ; } else { foreach ( $ this -> getTypes ( ) as $ type ) { if ( $ type -> getUri ( ) == OntologyRdfs :: RDFS_CLASS ) { $ returnValue = true ; break ; } } } return ( bool ) $ returnValue ; }
|
returns true if the resource is a valid class ( using facts or entailment
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.