idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
8,300
protected function getLogger ( ) { if ( $ this -> container -> has ( 'logger' ) ) { $ logger = $ this -> container -> get ( 'logger' ) ; \ assert ( $ logger instanceof LoggerInterface ) ; return $ logger ; } return new NullLogger ( ) ; }
Proxy for the logger service of the container . If no such service is found a NullLogger is returned .
8,301
final protected function redirectToList ( ) { $ parameters = [ ] ; if ( $ filter = $ this -> admin -> getFilterParameters ( ) ) { $ parameters [ 'filter' ] = $ filter ; } return $ this -> redirect ( $ this -> admin -> generateUrl ( 'list' , $ parameters ) ) ; }
Redirects the user to the list view .
8,302
protected function isInPreviewMode ( ) { return $ this -> admin -> supportsPreviewMode ( ) && ( $ this -> isPreviewRequested ( ) || $ this -> isPreviewApproved ( ) || $ this -> isPreviewDeclined ( ) ) ; }
Returns true if the request is in the preview workflow .
8,303
protected function getAclUsers ( ) { $ aclUsers = [ ] ; $ userManagerServiceName = $ this -> container -> getParameter ( 'sonata.admin.security.acl_user_manager' ) ; if ( null !== $ userManagerServiceName && $ this -> has ( $ userManagerServiceName ) ) { $ userManager = $ this -> get ( $ userManagerServiceName ) ; if (...
Gets ACL users .
8,304
protected function getAclRoles ( ) { $ aclRoles = [ ] ; $ roleHierarchy = $ this -> container -> getParameter ( 'security.role_hierarchy.roles' ) ; $ pool = $ this -> container -> get ( 'sonata.admin.pool' ) ; foreach ( $ pool -> getAdminServiceIds ( ) as $ id ) { try { $ admin = $ pool -> getInstance ( $ id ) ; } catc...
Gets ACL roles .
8,305
protected function validateCsrfToken ( $ intention ) { $ request = $ this -> getRequest ( ) ; $ token = $ request -> request -> get ( '_sonata_csrf_token' , false ) ; if ( $ this -> container -> has ( 'security.csrf.token_manager' ) ) { $ valid = $ this -> container -> get ( 'security.csrf.token_manager' ) -> isTokenVa...
Validate CSRF token for action without form .
8,306
public function getEntity ( $ key ) { if ( \ count ( $ this -> identifier ) > 1 ) { $ entities = $ this -> getEntities ( ) ; return $ entities [ $ key ] ?? null ; } elseif ( $ this -> entities ) { return isset ( $ this -> entities [ $ key ] ) ? $ this -> entities [ $ key ] : null ; } return $ this -> modelManager -> fi...
Returns the entity for the given key .
8,307
public function getIdentifierValues ( $ entity ) { try { return $ this -> modelManager -> getIdentifierValues ( $ entity ) ; } catch ( \ Exception $ e ) { throw new InvalidArgumentException ( sprintf ( 'Unable to retrieve the identifier values for entity %s' , ClassUtils :: getClass ( $ entity ) ) , 0 , $ e ) ; } }
Returns the values of the identifier fields of an entity .
8,308
protected function load ( $ choices ) { if ( \ is_array ( $ choices ) && \ count ( $ choices ) > 0 ) { $ entities = $ choices ; } elseif ( $ this -> query ) { $ entities = $ this -> modelManager -> executeQuery ( $ this -> query ) ; } else { $ entities = $ this -> modelManager -> findBy ( $ this -> class ) ; } if ( nul...
Initializes the choices and returns them .
8,309
private function getReflProperty ( string $ property ) : ReflectionProperty { if ( ! isset ( $ this -> reflProperties [ $ property ] ) ) { $ this -> reflProperties [ $ property ] = new \ ReflectionProperty ( $ this -> class , $ property ) ; $ this -> reflProperties [ $ property ] -> setAccessible ( true ) ; } return $ ...
Returns the \ ReflectionProperty instance for a property of the underlying class .
8,310
public function renderListElement ( Environment $ environment , $ object , FieldDescriptionInterface $ fieldDescription , $ params = [ ] ) { $ template = $ this -> getTemplate ( $ fieldDescription , $ fieldDescription -> getAdmin ( ) -> getTemplate ( 'base_list_field' ) , $ environment ) ; return $ this -> render ( $ f...
render a list element from the FieldDescription .
8,311
public function renderViewElement ( Environment $ environment , FieldDescriptionInterface $ fieldDescription , $ object ) { $ template = $ this -> getTemplate ( $ fieldDescription , '@SonataAdmin/CRUD/base_show_field.html.twig' , $ environment ) ; try { $ value = $ fieldDescription -> getValue ( $ object ) ; } catch ( ...
render a view element .
8,312
public function renderViewElementCompare ( Environment $ environment , FieldDescriptionInterface $ fieldDescription , $ baseObject , $ compareObject ) { $ template = $ this -> getTemplate ( $ fieldDescription , '@SonataAdmin/CRUD/base_show_field.html.twig' , $ environment ) ; try { $ baseValue = $ fieldDescription -> g...
render a compared view element .
8,313
public function getUrlsafeIdentifier ( $ model , AdminInterface $ admin = null ) { if ( null === $ admin ) { $ admin = $ this -> pool -> getAdminByClass ( ClassUtils :: getClass ( $ model ) ) ; } return $ admin -> getUrlsafeIdentifier ( $ model ) ; }
Get the identifiers as a string that is safe to use in a url .
8,314
final public function getCanonicalizedLocaleForMoment ( array $ context ) { $ locale = strtolower ( str_replace ( '_' , '-' , $ context [ 'app' ] -> getRequest ( ) -> getLocale ( ) ) ) ; if ( ( 'en' === $ lang = substr ( $ locale , 0 , 2 ) ) && ! \ in_array ( $ locale , [ 'en-au' , 'en-ca' , 'en-gb' , 'en-ie' , 'en-nz'...
Returns a canonicalized locale for moment NPM library or null if the locale s language is en which doesn t require localization .
8,315
final public function getCanonicalizedLocaleForSelect2 ( array $ context ) { $ locale = str_replace ( '_' , '-' , $ context [ 'app' ] -> getRequest ( ) -> getLocale ( ) ) ; if ( 'en' === $ lang = substr ( $ locale , 0 , 2 ) ) { return null ; } switch ( $ locale ) { case 'pt' : $ locale = 'pt-PT' ; break ; case 'ug' : $...
Returns a canonicalized locale for select2 NPM library or null if the locale s language is en which doesn t require localization .
8,316
public function add ( $ line , $ nlBefore = 0 , $ nlAfter = 0 ) { $ output = str_repeat ( "\n" , $ nlBefore ) . $ line . str_repeat ( "\n" , $ nlAfter ) ; if ( fwrite ( $ this -> file , $ output ) === false ) { die ( "There was an error attempting to write to the report file.\n" . $ this -> fullFilePath . "\n" ) ; } }
Add a new line to the report .
8,317
public function addToSection ( $ section , $ test , $ filePath , $ lineNumber , $ codeLine ) { if ( empty ( $ section ) ) { throw new \ Exception ( __METHOD__ . ": The section can not be empty." ) ; } $ this -> sectionBuffers [ $ section ] [ $ filePath ] [ $ test ] [ ] = [ $ lineNumber , $ codeLine ] ; }
Add text to the specified section .
8,318
public function addSections ( ) { foreach ( $ this -> sectionBuffers as $ section => $ filePaths ) { $ this -> add ( '# ' . $ section , 1 , 1 ) ; foreach ( $ filePaths as $ filePath => $ tests ) { $ this -> add ( '#### ' . $ filePath , 0 , 1 ) ; foreach ( $ tests as $ test => $ lines ) { $ this -> add ( '* ' . $ test ,...
Add sections in the buffer to the output .
8,319
private function recursiveScan ( $ startFolder ) { if ( is_file ( $ startFolder ) ) { $ this -> files [ ] = $ startFolder ; return ; } $ contents = scandir ( $ startFolder ) ; foreach ( $ contents as $ content ) { if ( strpos ( $ content , '.' ) === 0 ) { continue ; } $ path = $ startFolder . DIRECTORY_SEPARATOR . $ co...
Perform a recursive scan of the given path to return files only .
8,320
public function scanNextFile ( ) { $ _file = each ( $ this -> files ) ; if ( $ _file === false ) { return false ; } $ file = $ _file [ 'value' ] ; $ lines = file ( $ file , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ; if ( $ lines === false ) { $ lines = [ ] ; } return $ lines ; }
Scan the next file in the array and provide back an array of lines .
8,321
private function printOptionsAndExit ( ) { echo "Available Options:\n" ; foreach ( $ this -> validShortOptions as $ option => $ info ) { echo "-\033[1m{$option}\033[0m\n {$info['comment']}\n {$info['description']}\n Example: {$info['example']}\n\n" ; } foreach ( $ this -> validLongOptions as $ option => $ info ) { ech...
Print out available options and exit .
8,322
private function parseOption ( $ rawOption ) { $ regex = "#^(?P<option>-[a-zA-Z]{1}|--[a-zA-Z-]{2,})(?:=(?P<value>['|\"]?.+?['|\"]?))?$#" ; if ( preg_match ( $ regex , trim ( $ rawOption ) , $ matches ) ) { if ( isset ( $ matches [ 'option' ] ) ) { $ option = ltrim ( $ matches [ 'option' ] , '-' ) ; if ( isset ( $ matc...
Parse a raw option
8,323
private function enforceOptions ( ) { foreach ( $ this -> validShortOptions as $ option => $ info ) { if ( $ info [ 'option' ] === self :: OPTION_REQUIRED && ! isset ( $ this -> options [ $ option ] ) ) { die ( "The option `{$option}` is required to be given.\n {$info['comment']}\n {$info['description']}\n Example: {$i...
Enforce usage of required options .
8,324
private function run ( ) { $ issues = [ ] ; $ totalFiles = 0 ; $ totalLines = 0 ; $ filePath = $ this -> scanner -> getCurrentFilePath ( ) ; if ( ! $ this -> options -> getOption ( 't' ) || in_array ( 'syntax' , $ this -> options -> getOption ( 't' ) , true ) ) { $ checkSyntax = true ; $ versionGood = $ this -> tests -...
Run tests generator report sections .
8,325
static public function getRealPath ( $ path ) { if ( strpos ( $ path , '~' ) === 0 ) { $ path = substr_replace ( $ path , $ _SERVER [ 'HOME' ] , 0 , 1 ) ; } $ _path = realpath ( $ path ) ; if ( ! empty ( $ path ) && $ _path !== false ) { return rtrim ( $ _path , DIRECTORY_SEPARATOR ) ; } return false ; }
Get a full real path name to a given path .
8,326
protected function getExtensionEntity ( ) { if ( ! isset ( $ this -> extensionEntity ) ) { $ processId = $ this -> getProcessId ( ) ; $ this -> extensionEntity = $ this -> getEntityManager ( ) -> getEntity ( 'Extension' , $ processId ) ; if ( ! isset ( $ this -> extensionEntity ) ) { throw new Error ( 'Extension Entity...
Get entity of this extension
8,327
public function normalizeOptions ( array $ options ) { $ options [ 'useSsl' ] = ( bool ) ( $ options [ 'useSsl' ] == 'SSL' ) ; $ options [ 'useStartTls' ] = ( bool ) ( $ options [ 'useStartTls' ] == 'TLS' ) ; $ options [ 'accountCanonicalForm' ] = $ this -> accountCanonicalFormMap [ $ options [ 'accountCanonicalForm' ]...
Normalize options to LDAP client format
8,328
public function getOption ( $ name , $ returns = null ) { if ( ! isset ( $ this -> options ) ) { $ this -> getOptions ( ) ; } if ( isset ( $ this -> options [ $ name ] ) ) { return $ this -> options [ $ name ] ; } return $ returns ; }
Get an ldap option
8,329
public function getLdapClientOptions ( ) { $ options = $ this -> getOptions ( ) ; $ zendOptions = array_diff_key ( $ options , array_flip ( $ this -> permittedEspoOptions ) ) ; return $ zendOptions ; }
Get Zend options for using Zend \ Ldap
8,330
public function jobCheckNewVersion ( $ data ) { $ config = $ this -> getConfig ( ) ; if ( ! $ config -> get ( 'adminNotifications' ) || ! $ config -> get ( 'adminNotificationsNewVersion' ) ) { return true ; } $ latestRelease = $ this -> getLatestRelease ( ) ; if ( empty ( $ latestRelease [ 'version' ] ) ) { $ config ->...
Job for checking a new version of EspoCRM
8,331
public function jobCheckNewExtensionVersion ( $ data ) { $ config = $ this -> getConfig ( ) ; if ( ! $ config -> get ( 'adminNotifications' ) || ! $ config -> get ( 'adminNotificationsNewExtensionVersion' ) ) { return true ; } $ pdo = $ this -> getEntityManager ( ) -> getPDO ( ) ; $ query = " SELECT id, name...
Job for cheking a new version of installed extensions
8,332
protected function getData ( ) { $ currentLanguage = $ this -> getLanguage ( ) ; if ( ! isset ( $ this -> data [ $ currentLanguage ] ) ) { $ this -> init ( ) ; } return $ this -> data [ $ currentLanguage ] ; }
Get data of Unifier language files
8,333
public function delete ( $ scope , $ category , $ name ) { if ( is_array ( $ name ) ) { foreach ( $ name as $ rowLabel ) { $ this -> delete ( $ scope , $ category , $ rowLabel ) ; } return ; } $ this -> deletedData [ $ scope ] [ $ category ] [ ] = $ name ; $ currentLanguage = $ this -> getLanguage ( ) ; if ( ! isset ( ...
Remove a label
8,334
private function getForeignLink ( $ parentLinkName , $ parentLinkParams , $ currentEntityDefs ) { if ( isset ( $ parentLinkParams [ 'foreign' ] ) && isset ( $ currentEntityDefs [ 'links' ] [ $ parentLinkParams [ 'foreign' ] ] ) ) { return array ( 'name' => $ parentLinkParams [ 'foreign' ] , 'params' => $ currentEntityD...
Get foreign Link
8,335
protected function getClassName ( $ name ) { $ name = Util :: normilizeClassName ( $ name ) ; $ data = $ this -> getAll ( ) ; $ name = ucfirst ( $ name ) ; if ( isset ( $ data [ $ name ] ) ) { return $ data [ $ name ] ; } return false ; }
Get class name of a job
8,336
public function isCronConfigured ( ) { $ r1From = new \ DateTime ( '-' . $ this -> checkingCronPeriod ) ; $ r1To = new \ DateTime ( '+' . $ this -> checkingCronPeriod ) ; $ r2From = new \ DateTime ( '- 1 hour' ) ; $ r2To = new \ DateTime ( ) ; $ format = \ Espo \ Core \ Utils \ DateTime :: $ systemDateTimeFormat ; $ se...
Check if crontab is configured properly
8,337
protected function loginByToken ( $ username , \ Espo \ Entities \ AuthToken $ authToken = null ) { if ( ! isset ( $ authToken ) ) { return null ; } $ userId = $ authToken -> get ( 'userId' ) ; $ user = $ this -> getEntityManager ( ) -> getEntity ( 'User' , $ userId ) ; $ tokenUsername = $ user -> get ( 'userName' ) ; ...
Login by authorization token
8,338
protected function adminLogin ( $ username , $ password ) { $ hash = $ this -> getPasswordHash ( ) -> hash ( $ password ) ; $ user = $ this -> getEntityManager ( ) -> getRepository ( 'User' ) -> findOne ( [ 'whereClause' => [ 'userName' => $ username , 'password' => $ hash , 'type' => [ 'admin' , 'super-admin' ] ] ] ) ...
Login user with administrator rights
8,339
protected function createUser ( array $ userData , $ isPortal = false ) { $ GLOBALS [ 'log' ] -> info ( 'Creating new user ...' ) ; $ data = array ( ) ; $ GLOBALS [ 'log' ] -> debug ( 'LDAP: user data: ' . print_r ( $ userData , true ) ) ; $ ldapFields = $ this -> loadFields ( 'ldap' ) ; foreach ( $ ldapFields as $ esp...
Create Espo user with data gets from LDAP server
8,340
protected function findLdapUserDnByUsername ( $ username ) { $ ldapClient = $ this -> getLdapClient ( ) ; $ options = $ this -> getUtils ( ) -> getOptions ( ) ; $ loginFilterString = '' ; if ( ! empty ( $ options [ 'userLoginFilter' ] ) ) { $ loginFilterString = $ this -> convertToFilterFormat ( $ options [ 'userLoginF...
Find LDAP user DN by his username
8,341
protected function convertToFilterFormat ( $ filter ) { $ filter = trim ( $ filter ) ; if ( substr ( $ filter , 0 , 1 ) != '(' ) { $ filter = '(' . $ filter ; } if ( substr ( $ filter , - 1 ) != ')' ) { $ filter = $ filter . ')' ; } return $ filter ; }
Check and convert filter item into LDAP format
8,342
protected function loadFields ( $ type ) { $ options = $ this -> getUtils ( ) -> getOptions ( ) ; $ typeMap = $ type . 'FieldMap' ; $ fields = array ( ) ; foreach ( $ this -> $ typeMap as $ fieldName => $ fieldValue ) { if ( isset ( $ options [ $ fieldValue ] ) ) { $ fields [ $ fieldName ] = $ options [ $ fieldValue ] ...
Load fields for a user
8,343
public function unify ( array $ paths , $ isReturnModuleNames = false ) { $ data = $ this -> loadData ( $ paths [ 'corePath' ] ) ; if ( ! empty ( $ paths [ 'modulePath' ] ) ) { $ moduleDir = strstr ( $ paths [ 'modulePath' ] , '{*}' , true ) ; $ moduleList = isset ( $ this -> metadata ) ? $ this -> getMetadata ( ) -> g...
Unite files content
8,344
protected function loadData ( $ filePath , $ returns = array ( ) ) { if ( file_exists ( $ filePath ) ) { $ content = $ this -> getFileManager ( ) -> getContents ( $ filePath ) ; $ data = Json :: getArrayData ( $ content ) ; if ( empty ( $ data ) ) { $ GLOBALS [ 'log' ] -> warning ( 'FileUnifier::unify() - Empty file or...
Load data from a file
8,345
public function addLogRecord ( $ scheduledJobId , $ status , $ runTime = null , $ targetId = null , $ targetType = null ) { if ( ! isset ( $ runTime ) ) { $ runTime = date ( 'Y-m-d H:i:s' ) ; } $ entityManager = $ this -> getEntityManager ( ) ; $ scheduledJob = $ entityManager -> getEntity ( 'ScheduledJob' , $ schedule...
Add record to ScheduledJobLogRecord about executed job
8,346
public function getFieldDefsByType ( $ fieldDef ) { if ( is_string ( $ fieldDef ) ) { $ fieldDef = array ( 'type' => $ fieldDef ) ; } if ( isset ( $ fieldDef [ 'type' ] ) ) { return $ this -> getMetadata ( ) -> get ( 'fields.' . $ fieldDef [ 'type' ] ) ; } return null ; }
Get field defenition by type in metadata fields key
8,347
public function getAdditionalFieldList ( $ fieldName , array $ fieldParams , array $ definitionList ) { if ( empty ( $ fieldParams [ 'type' ] ) || empty ( $ definitionList ) ) { return ; } $ fieldType = $ fieldParams [ 'type' ] ; $ fieldDefinition = isset ( $ definitionList [ $ fieldType ] ) ? $ definitionList [ $ fiel...
Get additional field list based on field definition in metadata fields
8,348
protected function getPhpRequiredList ( $ requiredOnly , array $ additionalData = null ) { $ requiredList = [ 'requiredPhpVersion' , 'requiredPhpLibs' , ] ; if ( ! $ requiredOnly ) { $ requiredList = array_merge ( $ requiredList , [ 'recommendedPhpLibs' , 'recommendedPhpParams' , ] ) ; } return $ this -> getRequiredLis...
Get required php params
8,349
protected function getDatabaseRequiredList ( $ requiredOnly , array $ additionalData = null ) { $ databaseTypeName = 'Mysql' ; $ databaseHelper = $ this -> getDatabaseHelper ( ) ; $ databaseParams = isset ( $ additionalData [ 'database' ] ) ? $ additionalData [ 'database' ] : null ; $ dbalConnection = $ databaseHelper ...
Get required database params
8,350
protected function checkPhpRequirements ( $ type , $ data , array $ additionalData = null ) { $ list = [ ] ; switch ( $ type ) { case 'requiredPhpVersion' : $ actualVersion = $ this -> getSystemHelper ( ) -> getPhpVersion ( ) ; $ requiredVersion = $ data ; $ acceptable = true ; if ( version_compare ( $ actualVersion , ...
Check php requirements
8,351
protected function checkDatabaseRequirements ( $ type , $ data , array $ additionalData = null ) { $ list = [ ] ; $ databaseHelper = $ this -> getDatabaseHelper ( ) ; $ databaseParams = isset ( $ additionalData [ 'database' ] ) ? $ additionalData [ 'database' ] : null ; $ pdo = $ databaseHelper -> createPdoConnection (...
Check MySQL requirements
8,352
public function process ( $ itemName , $ entityName ) { $ inputs = array ( 'itemName' => $ itemName , 'entityName' => $ entityName , ) ; $ this -> setMethods ( $ inputs ) ; $ convertedDefs = $ this -> load ( $ itemName , $ entityName ) ; $ inputs = $ this -> setArrayValue ( null , $ inputs ) ; $ this -> setMethods ( $ ...
Start process Orm converting for fields
8,353
protected function backupExistingFiles ( ) { parent :: backupExistingFiles ( ) ; $ backupPath = $ this -> getPath ( 'backupPath' ) ; $ packagePath = $ this -> getPackagePath ( ) ; return $ this -> copy ( array ( $ packagePath , self :: SCRIPTS ) , array ( $ backupPath , self :: SCRIPTS ) , true ) ; }
Copy Existing files to backup directory
8,354
protected function findExtension ( ) { $ manifest = $ this -> getManifest ( ) ; $ this -> extensionEntity = $ this -> getEntityManager ( ) -> getRepository ( 'Extension' ) -> where ( array ( 'name' => $ manifest [ 'name' ] , 'isInstalled' => true , ) ) -> findOne ( ) ; return $ this -> extensionEntity ; }
Find Extension entity
8,355
protected function storeExtension ( ) { $ entityManager = $ this -> getEntityManager ( ) ; $ extensionEntity = $ entityManager -> getEntity ( 'Extension' , $ this -> getProcessId ( ) ) ; if ( ! isset ( $ extensionEntity ) ) { $ extensionEntity = $ entityManager -> getEntity ( 'Extension' ) ; } $ manifest = $ this -> ge...
Create a record of Extension Entity
8,356
protected function compareVersion ( ) { $ manifest = $ this -> getManifest ( ) ; $ extensionEntity = $ this -> getExtensionEntity ( ) ; if ( isset ( $ extensionEntity ) ) { $ comparedVersion = version_compare ( $ manifest [ 'version' ] , $ extensionEntity -> get ( 'version' ) , '>=' ) ; if ( $ comparedVersion <= 0 ) { ...
Compare version between installed and a new extensions
8,357
protected function uninstallExtension ( ) { $ extensionEntity = $ this -> getExtensionEntity ( ) ; $ this -> executeAction ( ExtensionManager :: UNINSTALL , array ( 'id' => $ extensionEntity -> get ( 'id' ) , 'skipSystemRebuild' => true , 'skipAfterScript' => true , ) ) ; }
If extension already installed uninstall an old version
8,358
protected function deleteExtension ( ) { $ extensionEntity = $ this -> getExtensionEntity ( ) ; $ this -> executeAction ( ExtensionManager :: DELETE , array ( 'id' => $ extensionEntity -> get ( 'id' ) ) ) ; }
Delete extension package
8,359
protected function runScript ( $ type ) { $ packagePath = $ this -> getPackagePath ( ) ; $ scriptNames = $ this -> getParams ( 'scriptNames' ) ; $ scriptName = $ scriptNames [ $ type ] ; if ( ! isset ( $ scriptName ) ) { return ; } $ beforeInstallScript = Util :: concatPath ( array ( $ packagePath , self :: SCRIPTS , $...
Run scripts by type
8,360
protected function getPath ( $ name = 'packagePath' , $ isPackage = false ) { $ postfix = $ isPackage ? $ this -> packagePostfix : '' ; $ processId = $ this -> getProcessId ( ) ; $ path = Util :: concatPath ( $ this -> getParams ( $ name ) , $ processId ) ; return $ path . $ postfix ; }
Get package path
8,361
protected function getDeleteFileList ( ) { if ( ! isset ( $ this -> data [ 'deleteFileList' ] ) ) { $ deleteFileList = array ( ) ; $ deleteList = array_merge ( $ this -> getDeleteList ( 'delete' ) , $ this -> getDeleteList ( 'deleteBeforeCopy' ) , $ this -> getDeleteList ( 'vendor' ) ) ; foreach ( $ deleteList as $ key...
Get a list of files defined in manifest . json
8,362
protected function deleteFiles ( $ type = 'delete' , $ withEmptyDirs = false ) { $ deleteList = $ this -> getDeleteList ( $ type ) ; if ( ! empty ( $ deleteList ) ) { return $ this -> getFileManager ( ) -> remove ( $ deleteList , null , $ withEmptyDirs ) ; } return true ; }
Delete files defined in a manifest
8,363
protected function checkManifest ( array $ manifest ) { $ requiredFields = array ( 'name' , 'version' , ) ; foreach ( $ requiredFields as $ fieldName ) { if ( empty ( $ manifest [ $ fieldName ] ) ) { return false ; } } return true ; }
Check if the manifest is correct
8,364
protected function unzipArchive ( $ packagePath = null ) { $ packagePath = isset ( $ packagePath ) ? $ packagePath : $ this -> getPackagePath ( ) ; $ packageArchivePath = $ this -> getPackagePath ( true ) ; if ( ! file_exists ( $ packageArchivePath ) ) { throw new Error ( 'Package Archive doesn\'t exist.' ) ; } $ res =...
Unzip a package archieve
8,365
protected function deletePackageFiles ( ) { $ packagePath = $ this -> getPackagePath ( ) ; $ res = $ this -> getFileManager ( ) -> removeInDir ( $ packagePath , true ) ; return $ res ; }
Delete temporary package files
8,366
protected function deletePackageArchive ( ) { $ packageArchive = $ this -> getPackagePath ( true ) ; $ res = $ this -> getFileManager ( ) -> removeFile ( $ packageArchive ) ; return $ res ; }
Delete temporary package archive
8,367
protected function executeAction ( $ actionName , $ data ) { $ actionManager = $ this -> getActionManager ( ) ; $ currentAction = $ actionManager -> getAction ( ) ; $ actionManager -> setAction ( $ actionName ) ; $ actionManager -> run ( $ data ) ; $ actionManager -> setAction ( $ currentAction ) ; }
Execute an action . For ex . execute uninstall action in install
8,368
protected function pruneMessage ( array $ record ) { $ message = ( string ) $ record [ 'message' ] ; if ( strlen ( $ message ) > $ this -> maxErrorMessageLength ) { $ record [ 'message' ] = substr ( $ message , 0 , $ this -> maxErrorMessageLength ) . '...' ; $ record [ 'formatted' ] = $ this -> getFormatter ( ) -> form...
Cut the error message depends on maxErrorMessageLength
8,369
public function hash ( $ password , $ useMd5 = true ) { $ salt = $ this -> getSalt ( ) ; if ( $ useMd5 ) { $ password = md5 ( $ password ) ; } $ hash = crypt ( $ password , $ salt ) ; $ hash = str_replace ( $ salt , '' , $ hash ) ; return $ hash ; }
Get hash of a pawword
8,370
protected function getSalt ( ) { $ salt = $ this -> getConfig ( ) -> get ( 'passwordSalt' ) ; if ( ! isset ( $ salt ) ) { throw new Error ( 'Option "passwordSalt" does not exist in config.php' ) ; } $ salt = $ this -> normalizeSalt ( $ salt ) ; return $ salt ; }
Get a salt from config and normalize it
8,371
public function getLevelCode ( $ levelName ) { $ levelName = strtoupper ( $ levelName ) ; $ levels = $ this -> getLevels ( ) ; if ( isset ( $ levels [ $ levelName ] ) ) { return $ levels [ $ levelName ] ; } return $ levels [ $ this -> defaultLevelName ] ; }
Get Level Code
8,372
protected function mergeWithDefaults ( $ data ) { $ defaultLangFile = 'install/core/i18n/' . $ this -> defaultLanguage . '/install.json' ; $ defaultData = $ this -> getLangData ( $ defaultLangFile ) ; foreach ( $ data as $ categoryName => & $ labels ) { foreach ( $ defaultData [ $ categoryName ] as $ defaultLabelName =...
Merge current language with default one
8,373
protected function afterRetrieve ( array & $ i18n ) { $ serverType = $ this -> getSystemHelper ( ) -> getServerType ( ) ; $ serverOs = $ this -> getSystemHelper ( ) -> getOs ( ) ; $ rewriteRules = $ this -> getSystemHelper ( ) -> getRewriteRules ( ) ; if ( isset ( $ i18n [ 'options' ] [ 'modRewriteInstruction' ] [ $ se...
After retrieve actions
8,374
protected function exchangeRates ( $ baseCurrency , $ defaultCurrency , array $ currencyRates ) { $ precision = 5 ; $ defaultCurrencyRate = round ( 1 / $ currencyRates [ $ defaultCurrency ] , $ precision ) ; $ exchangedRates = array ( ) ; $ exchangedRates [ $ baseCurrency ] = $ defaultCurrencyRate ; unset ( $ currencyR...
Calculate exchange rates if defaultCurrency doesn t equals baseCurrency
8,375
public static function encode ( $ value , $ options = 0 ) { $ json = json_encode ( $ value , $ options ) ; $ error = self :: getLastError ( ) ; if ( $ json === null || ! empty ( $ error ) ) { $ GLOBALS [ 'log' ] -> error ( 'Json::encode():' . $ error . ' - ' . print_r ( $ value , true ) ) ; } return $ json ; }
JSON encode a string
8,376
public static function isJSON ( $ json ) { if ( $ json === '[]' || $ json === '{}' ) { return true ; } else if ( is_array ( $ json ) ) { return false ; } return static :: decode ( $ json ) != null ; }
Check if the string is JSON
8,377
public function getServerType ( ) { $ serverSoft = $ _SERVER [ 'SERVER_SOFTWARE' ] ; preg_match ( '/^(.*?)\//i' , $ serverSoft , $ match ) ; if ( empty ( $ match [ 1 ] ) ) { preg_match ( '/^(.*)\/?/i' , $ serverSoft , $ match ) ; } $ serverName = strtolower ( trim ( $ match [ 1 ] ) ) ; return $ serverName ; }
Get web server name
8,378
protected function sortHooks ( array $ hooks ) { foreach ( $ hooks as $ scopeName => & $ scopeHooks ) { foreach ( $ scopeHooks as $ hookName => & $ hookList ) { usort ( $ hookList , array ( $ this , 'cmpHooks' ) ) ; } } return $ hooks ; }
Sort hooks by an order
8,379
protected function getHookList ( $ scope , $ hookName ) { $ key = $ scope . '_' . $ hookName ; if ( ! isset ( $ this -> hookListHash [ $ key ] ) ) { $ hookList = array ( ) ; if ( isset ( $ this -> data [ 'Common' ] [ $ hookName ] ) ) { $ hookList = $ this -> data [ 'Common' ] [ $ hookName ] ; } if ( isset ( $ this -> d...
Get sorted hook list
8,380
protected function hookExists ( $ className , array $ hookData ) { $ class = preg_replace ( '/^.*\\\(.*)$/' , '$1' , $ className ) ; foreach ( $ hookData as $ hookData ) { if ( preg_match ( '/\\\\' . $ class . '$/' , $ hookData [ 'className' ] ) ) { return true ; } } return false ; }
Check if hook exists in the list
8,381
public function process ( ) { $ entityDefs = $ this -> getEntityDefs ( true ) ; $ ormMetadata = array ( ) ; foreach ( $ entityDefs as $ entityName => $ entityMetadata ) { if ( empty ( $ entityMetadata ) ) { $ GLOBALS [ 'log' ] -> critical ( 'Orm\Converter:process(), Entity:' . $ entityName . ' - metadata cannot be conv...
Orm metadata convertation process
8,382
protected function convertFields ( $ entityName , & $ entityMetadata ) { $ unmergedFields = array ( 'name' , ) ; $ outputMeta = array ( 'id' => array ( 'type' => Entity :: ID , 'dbType' => 'varchar' ) , 'name' => array ( 'type' => isset ( $ entityMetadata [ 'fields' ] [ 'name' ] [ 'type' ] ) ? $ entityMetadata [ 'field...
Metadata conversion from Espo format into Doctrine
8,383
protected function correctFields ( $ entityName , array $ ormMetadata ) { $ entityDefs = $ this -> getEntityDefs ( ) ; $ entityMetadata = $ ormMetadata [ $ entityName ] ; foreach ( $ entityMetadata [ 'fields' ] as $ fieldName => $ fieldParams ) { if ( empty ( $ fieldParams [ 'type' ] ) ) continue ; $ fieldType = ucfirs...
Correct fields defenitions based on \ Espo \ Custom \ Core \ Utils \ Database \ Orm \ Fields
8,384
public function unify ( $ name , $ paths , $ recursively = false ) { $ content = $ this -> unifySingle ( $ paths [ 'corePath' ] , $ name , $ recursively ) ; if ( ! empty ( $ paths [ 'modulePath' ] ) ) { $ customDir = strstr ( $ paths [ 'modulePath' ] , '{*}' , true ) ; $ moduleList = isset ( $ this -> metadata ) ? $ th...
Unite file content to the file
8,385
protected function unifyGetContents ( $ paths , $ defaults ) { $ fileContent = $ this -> getFileManager ( ) -> getContents ( $ paths ) ; if ( $ this -> useObjects ) { $ decoded = Utils \ Json :: decode ( $ fileContent ) ; } else { $ decoded = Utils \ Json :: getArrayData ( $ fileContent , null ) ; } if ( ! isset ( $ de...
Helpful method for get content from files for unite Files
8,386
public function get ( $ name , $ default = null ) { $ keys = explode ( '.' , $ name ) ; $ lastBranch = $ this -> loadConfig ( ) ; foreach ( $ keys as $ keyName ) { if ( isset ( $ lastBranch [ $ keyName ] ) && ( is_array ( $ lastBranch ) || is_object ( $ lastBranch ) ) ) { if ( is_array ( $ lastBranch ) ) { $ lastBranch...
Get an option from config
8,387
public function has ( $ name ) { $ keys = explode ( '.' , $ name ) ; $ lastBranch = $ this -> loadConfig ( ) ; foreach ( $ keys as $ keyName ) { if ( isset ( $ lastBranch [ $ keyName ] ) && ( is_array ( $ lastBranch ) || is_object ( $ lastBranch ) ) ) { if ( is_array ( $ lastBranch ) ) { $ lastBranch = $ lastBranch [ $...
Whether parameter is set
8,388
public function set ( $ name , $ value = null , $ dontMarkDirty = false ) { if ( is_object ( $ name ) ) { $ name = get_object_vars ( $ name ) ; } if ( ! is_array ( $ name ) ) { $ name = array ( $ name => $ value ) ; } foreach ( $ name as $ key => $ value ) { if ( in_array ( $ key , $ this -> associativeArrayAttributeLi...
Set an option to the config
8,389
public function remove ( $ name ) { if ( array_key_exists ( $ name , $ this -> data ) ) { unset ( $ this -> data [ $ name ] ) ; $ this -> removeData [ ] = $ name ; return true ; } return null ; }
Remove an option in config
8,390
public function updateCacheTimestamp ( $ onlyValue = false ) { $ timestamp = [ $ this -> cacheTimestamp => time ( ) ] ; if ( $ onlyValue ) { return $ timestamp ; } return $ this -> set ( $ timestamp ) ; }
Update cache timestamp
8,391
public function run ( $ data ) { $ processId = $ data [ 'id' ] ; $ GLOBALS [ 'log' ] -> debug ( 'Installation process [' . $ processId . ']: start run.' ) ; if ( empty ( $ processId ) ) { throw new Error ( 'Installation package ID was not specified.' ) ; } $ this -> setProcessId ( $ processId ) ; $ this -> initialize (...
Main installation process
8,392
protected function initRebuildActions ( $ currentSchema = null , $ metadataSchema = null ) { $ methods = array ( 'beforeRebuild' , 'afterRebuild' ) ; $ this -> getClassParser ( ) -> setAllowedMethods ( $ methods ) ; $ rebuildActions = $ this -> getClassParser ( ) -> getData ( $ this -> rebuildActionsPath ) ; $ classes ...
Init Rebuild Actions get all classes and create them
8,393
protected function executeRebuildActions ( $ action = 'beforeRebuild' ) { if ( ! isset ( $ this -> rebuildActionClasses ) ) { $ this -> initRebuildActions ( ) ; } if ( isset ( $ this -> rebuildActionClasses [ $ action ] ) ) { foreach ( $ this -> rebuildActionClasses [ $ action ] as $ rebuildActionClass ) { $ rebuildAct...
Execute actions for RebuildAction classes
8,394
protected function prepareManyMany ( $ entityName , $ relationParams , $ tables ) { $ tableName = Util :: toUnderScore ( $ relationParams [ 'relationName' ] ) ; if ( $ this -> getSchema ( ) -> hasTable ( $ tableName ) ) { $ GLOBALS [ 'log' ] -> debug ( 'DBAL: Table [' . $ tableName . '] exists.' ) ; return $ this -> ge...
Prepare a relation table for the manyMany relation
8,395
public static function toCamelCase ( $ name , $ symbol = '_' , $ capitaliseFirstChar = false ) { if ( is_array ( $ name ) ) { foreach ( $ name as & $ value ) { $ value = static :: toCamelCase ( $ value , $ symbol , $ capitaliseFirstChar ) ; } return $ name ; } $ name = lcfirst ( $ name ) ; if ( $ capitaliseFirstChar ) ...
Convert name to Camel Case format ex . camel_case to camelCase
8,396
public static function fromCamelCase ( $ name , $ symbol = '_' ) { if ( is_array ( $ name ) ) { foreach ( $ name as & $ value ) { $ value = static :: fromCamelCase ( $ value , $ symbol ) ; } return $ name ; } $ name [ 0 ] = strtolower ( $ name [ 0 ] ) ; return preg_replace_callback ( '/([A-Z])/' , function ( $ matches ...
Convert name from Camel Case format . ex . camelCase to camel - case
8,397
public static function unsetInArrayByValue ( $ needle , array $ haystack , $ reIndex = true ) { $ doReindex = false ; foreach ( $ haystack as $ key => $ value ) { if ( is_array ( $ value ) ) { $ haystack [ $ key ] = static :: unsetInArrayByValue ( $ needle , $ value ) ; } else if ( $ needle === $ value ) { unset ( $ ha...
Unset a value in array recursively
8,398
public static function concatPath ( $ folderPath , $ filePath = null ) { if ( is_array ( $ folderPath ) ) { $ fullPath = '' ; foreach ( $ folderPath as $ path ) { $ fullPath = static :: concatPath ( $ fullPath , $ path ) ; } return static :: fixPath ( $ fullPath ) ; } if ( empty ( $ filePath ) ) { return static :: fixP...
Get a full path of the file
8,399
public static function objectToArray ( $ object ) { if ( is_object ( $ object ) ) { $ object = ( array ) $ object ; } return is_array ( $ object ) ? array_map ( "static::objectToArray" , $ object ) : $ object ; }
Convert object to array format recursively