idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
51,900
|
protected function copySkeleton ( $ packagePath , $ vendor , $ package , $ vendorFolderName , $ packageFolderName ) { $ this -> info ( 'Copy skeleton.' ) ; $ skeletonDirPath = $ this -> getPathFromConfig ( 'skeleton_dir_path' , $ this -> packageBaseDir . '/skeleton' ) ; foreach ( File :: allFiles ( $ skeletonDirPath , true ) as $ filePath ) { $ filePath = realpath ( $ filePath ) ; $ destFilePath = Str :: replaceFirst ( $ skeletonDirPath , $ packagePath , $ filePath ) ; $ this -> copyFileWithDirsCreating ( $ filePath , $ destFilePath ) ; } $ this -> copyStubs ( $ packagePath , $ package , $ packageFolderName ) ; $ variables = $ this -> getVariables ( $ vendor , $ package , $ vendorFolderName , $ packageFolderName ) ; $ this -> replaceTemplates ( $ packagePath , $ variables ) ; $ this -> info ( 'Skeleton was successfully copied.' ) ; }
|
Copy skeleton to package folder .
|
51,901
|
protected function copyStubs ( $ packagePath , $ package , $ packageFolderName ) { $ facadeFilePath = $ this -> packageBaseDir . '/stubs/Facade.php.tpl' ; $ mainClassFilePath = $ this -> packageBaseDir . '/stubs/MainClass.php.tpl' ; $ mainClassTestFilePath = $ this -> packageBaseDir . '/stubs/MainClassTest.php.tpl' ; $ configFilePath = $ this -> packageBaseDir . '/stubs/config.php' ; $ filePaths = [ $ facadeFilePath => "$packagePath/src/Facades/$package.php.tpl" , $ mainClassFilePath => "$packagePath/src/$package.php.tpl" , $ mainClassTestFilePath => "$packagePath/tests/{$package}Test.php.tpl" , $ configFilePath => "$packagePath/config/$packageFolderName.php" , ] ; foreach ( $ filePaths as $ filePath => $ destFilePath ) { $ this -> copyFileWithDirsCreating ( $ filePath , $ destFilePath ) ; } }
|
Copy stubs .
|
51,902
|
protected function copyFileWithDirsCreating ( $ src , $ dest ) { $ dirPathOfDestFile = dirname ( $ dest ) ; if ( ! File :: exists ( $ dirPathOfDestFile ) ) { File :: makeDirectory ( $ dirPathOfDestFile , 0755 , true ) ; } if ( ! File :: exists ( $ dest ) ) { File :: copy ( $ src , $ dest ) ; } }
|
Copy source file to destination with needed directories creating .
|
51,903
|
protected function getVariables ( $ vendor , $ package , $ vendorFolderName , $ packageFolderName ) { $ packageWords = str_replace ( '-' , ' ' , Str :: snake ( $ packageFolderName ) ) ; $ composerDescription = $ this -> askUser ( 'The composer description?' , "A $packageWords" ) ; $ composerKeywords = $ this -> getComposerKeywords ( $ packageWords ) ; $ packageHumanName = $ this -> askUser ( 'The package human name?' , Str :: title ( $ packageWords ) ) ; return [ 'vendor' => $ vendor , 'package' => $ package , 'vendorFolderName' => $ vendorFolderName , 'packageFolderName' => $ packageFolderName , 'packageHumanName' => $ packageHumanName , 'composerName' => "$vendorFolderName/$packageFolderName" , 'composerDesc' => $ composerDescription , 'composerKeywords' => $ composerKeywords , 'license' => $ this -> askUser ( 'The package licence?' , 'MIT' ) , 'phpVersion' => $ this -> askUser ( 'Php version constraint?' , '>=7.0' ) , 'aliasName' => $ packageFolderName , 'configFileName' => $ packageFolderName , 'year' => date ( 'Y' ) , 'name' => $ this -> askUser ( 'Your name?' ) , 'email' => $ this -> askUser ( 'Your email?' ) , 'githubPackageUrl' => "https://github.com/$vendorFolderName/$packageFolderName" , ] ; }
|
Get variables for substitution in templates .
|
51,904
|
protected function getPathFromConfig ( $ configName , $ default ) { $ path = config ( "laravel-package-generator.$configName" ) ; if ( empty ( $ path ) ) { $ path = $ default ; } else { $ path = base_path ( $ path ) ; } $ realPath = realpath ( $ path ) ; if ( $ realPath === false ) { throw RuntimeException :: noAccessTo ( $ path ) ; } return $ realPath ; }
|
Get path from config .
|
51,905
|
protected function getComposerKeywords ( $ packageWords ) { $ keywords = $ this -> askUser ( 'The composer keywords? (comma delimited)' , str_replace ( ' ' , ',' , $ packageWords ) ) ; $ keywords = explode ( ',' , $ keywords ) ; $ keywords = array_map ( function ( $ keyword ) { return "\"$keyword\"" ; } , $ keywords ) ; return implode ( ",\n" . str_repeat ( ' ' , 4 ) , $ keywords ) ; }
|
Get composer keywords .
|
51,906
|
protected function composerRunCommand ( $ command ) { $ this -> info ( "Run \"$command\"." ) ; $ output = [ ] ; exec ( $ command , $ output , $ returnStatusCode ) ; if ( $ returnStatusCode !== 0 ) { throw RuntimeException :: commandExecutionFailed ( $ command , $ returnStatusCode ) ; } $ this -> info ( "\"$command\" was successfully ran." ) ; }
|
Run arbitrary composer command .
|
51,907
|
public function getOwnedAreaRelationName ( ) { $ has_one = $ this -> config ( ) -> get ( 'has_one' ) ; foreach ( $ has_one as $ relationName => $ relationClass ) { if ( $ relationClass === ElementalArea :: class && $ relationName !== 'Parent' ) { return $ relationName ; } } return 'Elements' ; }
|
Retrieve a elemental area relation name which this element owns
|
51,908
|
protected function cloneRepo ( $ url , $ dest , $ branch ) { $ command = "git clone --branch=$branch $url $dest" ; $ this -> info ( "Run \"$command\"." ) ; File :: makeDirectory ( $ dest , 0755 , true ) ; $ output = [ ] ; exec ( $ command , $ output , $ returnStatusCode ) ; if ( $ returnStatusCode !== 0 ) { throw RuntimeException :: commandExecutionFailed ( $ command , $ returnStatusCode ) ; } $ this -> info ( "\"$command\" was successfully ran." ) ; }
|
Clone repo .
|
51,909
|
protected function initRepo ( $ repoPath ) { $ command = "git init $repoPath" ; $ this -> info ( "Run \"$command\"." ) ; $ output = [ ] ; exec ( $ command , $ output , $ returnStatusCode ) ; if ( $ returnStatusCode !== 0 ) { throw RuntimeException :: commandExecutionFailed ( $ command , $ returnStatusCode ) ; } $ this -> info ( "\"$command\" was successfully ran." ) ; }
|
Init git repo .
|
51,910
|
protected function createPackageFolder ( $ packagePath ) { $ this -> info ( 'Create package folder.' ) ; if ( File :: exists ( $ packagePath ) ) { $ this -> info ( 'Package folder already exists. Skipping.' ) ; return ; } if ( ! File :: makeDirectory ( $ packagePath , 0755 , true ) ) { throw new RuntimeException ( 'Cannot create package folder' ) ; } $ this -> info ( 'Package folder was successfully created.' ) ; }
|
Create package folder .
|
51,911
|
protected function removePackageFolder ( $ packagePath ) { $ this -> info ( 'Remove package folder.' ) ; if ( File :: exists ( $ packagePath ) ) { if ( ! File :: deleteDirectory ( $ packagePath ) ) { throw new RuntimeException ( 'Cannot remove package folder' ) ; } $ this -> info ( 'Package folder was successfully removed.' ) ; } else { $ this -> info ( 'Package folder does not exists. Skipping.' ) ; } }
|
Remove package folder .
|
51,912
|
public function levenshtein ( $ first , $ second ) { $ l = new \ Atomescrochus \ StringSimilarities \ Levenshtein ( ) ; return $ l -> compare ( $ first , $ second ) ; }
|
Run a basic levenshtein comparison using PHP s built - in function
|
51,913
|
protected function askUser ( $ question , $ defaultValue = '' ) { if ( $ this -> option ( 'interactive' ) ) { return $ this -> ask ( $ question , $ defaultValue ) ; } return $ defaultValue ; }
|
Ask user .
|
51,914
|
public function run ( ) { if ( empty ( $ this -> options [ 'id' ] ) ) { $ this -> options [ 'id' ] = $ this -> id ; } if ( $ this -> encodeLabel ) { $ this -> label = Html :: encode ( $ this -> label ) ; } $ perPage = ! empty ( $ _GET [ $ this -> pageSizeParam ] ) ? $ _GET [ $ this -> pageSizeParam ] : $ this -> defaultPageSize ; $ listHtml = Html :: dropDownList ( $ this -> pageSizeParam , $ perPage , $ this -> sizes , $ this -> options ) ; $ labelHtml = Html :: label ( $ this -> label , $ this -> options [ 'id' ] , $ this -> labelOptions ) ; $ output = str_replace ( [ '{list}' , '{label}' ] , [ $ listHtml , $ labelHtml ] , $ this -> template ) ; return $ output ; }
|
Runs the widget and render the output
|
51,915
|
protected function registerPackage ( $ vendor , $ package , $ relPackagePath ) { $ this -> info ( 'Register package in composer.json.' ) ; $ composerJson = $ this -> loadComposerJson ( ) ; if ( ! isset ( $ composerJson [ 'repositories' ] ) ) { Arr :: set ( $ composerJson , 'repositories' , [ ] ) ; } $ filtered = array_filter ( $ composerJson [ 'repositories' ] , function ( $ repository ) use ( $ relPackagePath ) { return $ repository [ 'type' ] === 'path' && $ repository [ 'url' ] === $ relPackagePath ; } ) ; if ( count ( $ filtered ) === 0 ) { $ this -> info ( 'Register composer repository for package.' ) ; $ composerJson [ 'repositories' ] [ ] = ( object ) [ 'type' => 'path' , 'url' => $ relPackagePath , ] ; } else { $ this -> info ( 'Composer repository for package is already registered.' ) ; } Arr :: set ( $ composerJson , "require.$vendor/$package" , 'dev-master' ) ; $ this -> saveComposerJson ( $ composerJson ) ; $ this -> info ( 'Package was successfully registered in composer.json.' ) ; }
|
Register package in composer . json .
|
51,916
|
protected function unregisterPackage ( $ vendor , $ package , $ relPackagePath ) { $ this -> info ( 'Unregister package from composer.json.' ) ; $ composerJson = $ this -> loadComposerJson ( ) ; unset ( $ composerJson [ 'require' ] [ "$vendor\\$package\\" ] ) ; $ repositories = array_filter ( $ composerJson [ 'repositories' ] , function ( $ repository ) use ( $ relPackagePath ) { return $ repository [ 'type' ] !== 'path' || $ repository [ 'url' ] !== $ relPackagePath ; } ) ; $ composerJson [ 'repositories' ] = $ repositories ; if ( count ( $ composerJson [ 'repositories' ] ) === 0 ) { unset ( $ composerJson [ 'repositories' ] ) ; } $ this -> saveComposerJson ( $ composerJson ) ; $ this -> info ( 'Package was successfully unregistered from composer.json.' ) ; }
|
Unregister package from composer . json .
|
51,917
|
protected function loadComposerJson ( ) { $ composerJsonPath = $ this -> getComposerJsonPath ( ) ; if ( ! File :: exists ( $ composerJsonPath ) ) { throw new FileNotFoundException ( 'composer.json does not exist' ) ; } $ composerJsonContent = File :: get ( $ composerJsonPath ) ; $ composerJson = json_decode ( $ composerJsonContent , true ) ; if ( ! is_array ( $ composerJson ) ) { throw new RuntimeException ( "Invalid composer.json file [$composerJsonPath]" ) ; } return $ composerJson ; }
|
Load and parse content of composer . json .
|
51,918
|
protected function getVendorAndFolderName ( $ url ) { if ( Str :: contains ( $ url , '@' ) ) { $ vendorAndPackage = explode ( ':' , $ url ) ; $ vendorAndPackage = explode ( '/' , $ vendorAndPackage [ 1 ] ) ; return [ $ vendorAndPackage [ 0 ] , Str :: replaceLast ( '.git' , '' , $ vendorAndPackage [ 1 ] ) , ] ; } $ urlParts = explode ( '/' , $ url ) ; return [ $ urlParts [ 3 ] , $ urlParts [ 4 ] ] ; }
|
Get vendor and package folder name .
|
51,919
|
public function hasMultilingualAttribute ( $ name ) { return in_array ( $ name , $ this -> attributes ) || array_key_exists ( $ name , $ this -> _multilingualAttributes ) ; }
|
Whether an attribute exists
|
51,920
|
public function getMultilingualAttributeLabel ( $ attribute ) { $ attributeLabels = $ this -> getMultilingualAttributeLabels ( ) ; return isset ( $ attributeLabels [ $ attribute ] ) ? $ attributeLabels [ $ attribute ] : $ attribute ; }
|
Return multilingual attribute label .
|
51,921
|
public function beforeAction ( $ event ) { if ( ! Yii :: $ app -> errorHandler -> exception && count ( $ this -> languages ) > 1 ) { if ( $ language = Yii :: $ app -> getRequest ( ) -> get ( 'language' ) ) { Yii :: $ app -> language = $ this -> getLanguageCode ( $ language ) ; Yii :: $ app -> session -> set ( 'language' , Yii :: $ app -> language ) ; Yii :: $ app -> response -> cookies -> add ( new \ yii \ web \ Cookie ( [ 'name' => 'language' , 'value' => Yii :: $ app -> session -> get ( 'language' ) , 'expire' => time ( ) + 31536000 ] ) ) ; } elseif ( $ language = Yii :: $ app -> session -> get ( 'language' ) ) { Yii :: $ app -> language = $ this -> getLanguageCode ( $ language ) ; } elseif ( isset ( Yii :: $ app -> request -> cookies [ 'language' ] ) ) { $ language = Yii :: $ app -> request -> cookies [ 'language' ] -> value ; Yii :: $ app -> language = $ this -> getLanguageCode ( $ language ) ; } Yii :: $ app -> formatter -> locale = Yii :: $ app -> language ; } return $ event -> isValid ; }
|
Tracks language parameter for multilingual controllers .
|
51,922
|
public function getStatus ( $ id = null ) { if ( $ this -> isSuccess ( ) ) { if ( ! $ id ) { $ result = $ this -> getResult ( ) ; return $ result [ 0 ] [ 'status' ] ; } foreach ( $ this -> getResult ( ) as $ row ) { if ( $ row [ 'id' ] == $ id ) { return $ row [ 'status' ] ; } } } return false ; }
|
Get the status of a lead . If no lead ID is given it returns the status of the first lead returned .
|
51,923
|
protected function getFilteredOptions ( array $ options ) { $ default = $ this -> getDefaultOptions ( ) ; $ options = \ array_merge ( $ default , $ options ) ; $ uses = \ array_unique ( \ array_merge ( [ 'path' , 'filename' , 'extension' , 'format' , ] , \ array_keys ( $ default ) ) ) ; $ data = Arr :: only ( $ options , $ uses ) ; return $ data ; }
|
Get filtered options .
|
51,924
|
public function generateTableName ( $ ownerTableName , $ tableNameSuffix ) { if ( preg_match ( '/{{%(\w+)}}$/' , $ ownerTableName , $ matches ) ) { $ ownerTableName = $ matches [ 1 ] ; } return '{{%' . $ ownerTableName . $ tableNameSuffix . '}}' ; }
|
Generate translation table name .
|
51,925
|
public function getTranslations ( ) { return $ this -> owner -> hasMany ( $ this -> translationClassName , [ $ this -> languageForeignKey => $ this -> _ownerPrimaryKey ] ) ; }
|
Relation to model translations
|
51,926
|
public function getTranslation ( $ language = null ) { $ language = $ language ? : $ this -> _currentLanguage ; return $ this -> owner -> hasOne ( $ this -> translationClassName , [ $ this -> languageForeignKey => $ this -> _ownerPrimaryKey ] ) -> where ( [ $ this -> languageField => $ language ] ) ; }
|
Relation to model translation
|
51,927
|
public function beforeValidate ( ) { foreach ( $ this -> attributes as $ attribute ) { $ this -> setMultilingualAttribute ( $ this -> getAttributeName ( $ attribute , $ this -> _currentLanguage ) , $ this -> getMultilingualAttribute ( $ attribute ) ) ; } }
|
Handle beforeValidate event of the owner .
|
51,928
|
public function afterFind ( ) { $ owner = $ this -> owner ; if ( $ owner -> isRelationPopulated ( 'translations' ) && $ related = $ owner -> getRelatedRecords ( ) [ 'translations' ] ) { $ translations = $ this -> indexByLanguage ( $ related ) ; foreach ( $ this -> _languageKeys as $ language ) { foreach ( $ this -> attributes as $ attribute ) { foreach ( $ translations as $ translation ) { if ( $ translation -> { $ this -> languageField } == $ language ) { $ attributeName = $ this -> localizedPrefix . $ attribute ; $ this -> setMultilingualAttribute ( $ this -> getAttributeName ( $ attribute , $ language ) , $ translation -> { $ attributeName } ) ; } } } } } else if ( $ owner -> getAttribute ( $ this -> _ownerPrimaryKey ) !== null ) { if ( ! $ owner -> isRelationPopulated ( 'translation' ) ) { $ owner -> translation ; } $ translation = $ owner -> getRelatedRecords ( ) [ 'translation' ] ; if ( $ translation ) { foreach ( $ this -> attributes as $ attribute ) { $ attribute_name = $ this -> localizedPrefix . $ attribute ; $ owner -> setMultilingualAttribute ( $ attribute , $ translation -> $ attribute_name ) ; } } } foreach ( $ this -> attributes as $ attribute ) { if ( $ owner -> hasAttribute ( $ attribute ) && $ this -> getMultilingualAttribute ( $ attribute ) ) { $ owner -> setAttribute ( $ attribute , $ this -> getMultilingualAttribute ( $ attribute ) ) ; } } }
|
Handle afterFind event of the owner .
|
51,929
|
public function afterUpdate ( ) { $ owner = $ this -> owner ; if ( $ owner -> isRelationPopulated ( 'translations' ) ) { $ translations = $ this -> indexByLanguage ( $ owner -> getRelatedRecords ( ) [ 'translations' ] ) ; $ this -> saveTranslations ( $ translations ) ; } }
|
Handle afterUpdate event of the owner .
|
51,930
|
protected function initTranslationClass ( ) { if ( ! class_exists ( $ this -> translationClassName ) ) { $ namespace = substr ( $ this -> translationClassName , 0 , strrpos ( $ this -> translationClassName , '\\' ) ) ; $ translationClassName = $ this -> getShortClassName ( $ this -> translationClassName ) ; eval ( ' namespace ' . $ namespace . '; use yii\db\ActiveRecord; class ' . $ translationClassName . ' extends ActiveRecord { public static function tableName() { return \'' . $ this -> tableName . '\'; } }' ) ; } }
|
Create dynamic translation model .
|
51,931
|
public function importLeadsCsv ( $ args ) { if ( ! is_readable ( $ args [ 'file' ] ) ) { throw new \ Exception ( 'Cannot read file: ' . $ args [ 'file' ] ) ; } if ( empty ( $ args [ 'format' ] ) ) { $ args [ 'format' ] = 'csv' ; } return $ this -> getResult ( 'importLeadsCsv' , $ args ) ; }
|
Import Leads via file upload
|
51,932
|
public function getBulkUploadStatus ( $ batchId ) { if ( empty ( $ batchId ) || ! is_int ( $ batchId ) ) { throw new \ Exception ( 'Invalid $batchId provided in ' . __METHOD__ ) ; } return $ this -> getResult ( 'getBulkUploadStatus' , array ( 'batchId' => $ batchId ) ) ; }
|
Get status of an async Import Lead file upload
|
51,933
|
public function getBulkUploadFailures ( $ batchId ) { if ( empty ( $ batchId ) || ! is_int ( $ batchId ) ) { throw new \ Exception ( 'Invalid $batchId provided in ' . __METHOD__ ) ; } return $ this -> getResult ( 'getBulkUploadFailures' , array ( 'batchId' => $ batchId ) ) ; }
|
Get failed lead results from an Import Lead file upload
|
51,934
|
public function getBulkUploadWarnings ( $ batchId ) { if ( empty ( $ batchId ) || ! is_int ( $ batchId ) ) { throw new \ Exception ( 'Invalid $batchId provided in ' . __METHOD__ ) ; } return $ this -> getResult ( 'getBulkUploadWarnings' , array ( 'batchId' => $ batchId ) ) ; }
|
Get warnings from Import Lead file upload
|
51,935
|
private function createOrUpdateLeadsCommand ( $ action , $ leads , $ lookupField , $ args , $ returnRaw = false ) { $ args [ 'input' ] = $ leads ; $ args [ 'action' ] = $ action ; if ( isset ( $ lookupField ) ) { $ args [ 'lookupField' ] = $ lookupField ; } return $ this -> getResult ( 'createOrUpdateLeads' , $ args , false , $ returnRaw ) ; }
|
Calls the CreateOrUpdateLeads command with the given action .
|
51,936
|
public function createLeads ( $ leads , $ lookupField = null , $ args = array ( ) ) { return $ this -> createOrUpdateLeadsCommand ( 'createOnly' , $ leads , $ lookupField , $ args ) ; }
|
Create the given leads .
|
51,937
|
public function createOrUpdateLeads ( $ leads , $ lookupField = null , $ args = array ( ) ) { return $ this -> createOrUpdateLeadsCommand ( 'createOrUpdate' , $ leads , $ lookupField , $ args ) ; }
|
Update the given leads or create them if they do not exist .
|
51,938
|
public function updateLeads ( $ leads , $ lookupField = null , $ args = array ( ) ) { return $ this -> createOrUpdateLeadsCommand ( 'updateOnly' , $ leads , $ lookupField , $ args ) ; }
|
Update the given leads .
|
51,939
|
public function createDuplicateLeads ( $ leads , $ lookupField = null , $ args = array ( ) ) { return $ this -> createOrUpdateLeadsCommand ( 'createDuplicate' , $ leads , $ lookupField , $ args ) ; }
|
Create duplicates of the given leads .
|
51,940
|
public function getLists ( $ ids = null , $ args = array ( ) , $ returnRaw = false ) { if ( $ ids ) { $ args [ 'id' ] = $ ids ; } return $ this -> getResult ( 'getLists' , $ args , is_array ( $ ids ) , $ returnRaw ) ; }
|
Get multiple lists .
|
51,941
|
public function getList ( $ id , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ id ; return $ this -> getResult ( 'getList' , $ args , false , $ returnRaw ) ; }
|
Get a list by ID .
|
51,942
|
public function getLeadsByFilterType ( $ filterType , $ filterValues , $ fields = array ( ) , $ nextPageToken = null , $ returnRaw = false ) { $ args [ 'filterType' ] = $ filterType ; $ args [ 'filterValues' ] = $ filterValues ; if ( $ nextPageToken ) { $ args [ 'nextPageToken' ] = $ nextPageToken ; } if ( count ( $ fields ) ) { $ args [ 'fields' ] = implode ( ',' , $ fields ) ; } return $ this -> getResult ( 'getLeadsByFilterType' , $ args , false , $ returnRaw ) ; }
|
Get multiple leads by filter type .
|
51,943
|
public function getLeadByFilterType ( $ filterType , $ filterValue , $ fields = array ( ) , $ returnRaw = false ) { $ args [ 'filterType' ] = $ filterType ; $ args [ 'filterValues' ] = $ filterValue ; if ( count ( $ fields ) ) { $ args [ 'fields' ] = implode ( ',' , $ fields ) ; } return $ this -> getResult ( 'getLeadByFilterType' , $ args , false , $ returnRaw ) ; }
|
Get a lead by filter type .
|
51,944
|
public function getLeadsByList ( $ listId , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'listId' ] = $ listId ; return $ this -> getResult ( 'getLeadsByList' , $ args , false , $ returnRaw ) ; }
|
Get multiple leads by list ID .
|
51,945
|
public function getLead ( $ id , $ fields = null , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ id ; if ( is_array ( $ fields ) ) { $ args [ 'fields' ] = implode ( ',' , $ fields ) ; } return $ this -> getResult ( 'getLead' , $ args , false , $ returnRaw ) ; }
|
Get a lead by ID .
|
51,946
|
public function isMemberOfList ( $ listId , $ id , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'listId' ] = $ listId ; $ args [ 'id' ] = $ id ; return $ this -> getResult ( 'isMemberOfList' , $ args , is_array ( $ id ) , $ returnRaw ) ; }
|
Check if a lead is a member of a list .
|
51,947
|
public function getCampaign ( $ id , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ id ; return $ this -> getResult ( 'getCampaign' , $ args , false , $ returnRaw ) ; }
|
Get a campaign by ID .
|
51,948
|
public function addLeadsToList ( $ listId , $ leads , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'listId' ] = $ listId ; $ args [ 'id' ] = ( array ) $ leads ; return $ this -> getResult ( 'addLeadsToList' , $ args , true , $ returnRaw ) ; }
|
Add one or more leads to the specified list .
|
51,949
|
public function deleteLead ( $ leads , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = ( array ) $ leads ; return $ this -> getResult ( 'deleteLead' , $ args , true , $ returnRaw ) ; }
|
Delete one or more leads
|
51,950
|
public function requestCampaign ( $ id , $ leads , $ tokens = array ( ) , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ id ; $ args [ 'input' ] = array ( 'leads' => array_map ( function ( $ id ) { return array ( 'id' => $ id ) ; } , ( array ) $ leads ) ) ; if ( ! empty ( $ tokens ) ) { $ args [ 'input' ] [ 'tokens' ] = $ tokens ; } return $ this -> getResult ( 'requestCampaign' , $ args , false , $ returnRaw ) ; }
|
Trigger a campaign for one or more leads .
|
51,951
|
public function scheduleCampaign ( $ id , \ DateTime $ runAt = NULL , $ tokens = array ( ) , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ id ; if ( ! empty ( $ runAt ) ) { $ args [ 'input' ] [ 'runAt' ] = $ runAt -> format ( 'c' ) ; } if ( ! empty ( $ tokens ) ) { $ args [ 'input' ] [ 'tokens' ] = $ tokens ; } return $ this -> getResult ( 'scheduleCampaign' , $ args , false , $ returnRaw ) ; }
|
Schedule a campaign
|
51,952
|
public function associateLead ( $ id , $ cookie = null , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ id ; if ( ! empty ( $ cookie ) ) { $ args [ 'cookie' ] = $ cookie ; } return $ this -> getResult ( 'associateLead' , $ args , false , $ returnRaw ) ; }
|
Associate a lead
|
51,953
|
public function getPagingToken ( $ sinceDatetime , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'sinceDatetime' ] = $ sinceDatetime ; return $ this -> getResult ( 'getPagingToken' , $ args , false , $ returnRaw ) ; }
|
Get the paging token required for lead activity and changes
|
51,954
|
public function getLeadChanges ( $ nextPageToken , $ fields , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'nextPageToken' ] = $ nextPageToken ; $ args [ 'fields' ] = ( array ) $ fields ; if ( count ( $ fields ) ) { $ args [ 'fields' ] = implode ( ',' , $ fields ) ; } return $ this -> getResult ( 'getLeadChanges' , $ args , true , $ returnRaw ) ; }
|
Get lead changes
|
51,955
|
public function approveEmail ( $ emailId , $ args = array ( ) , $ returnRaw = false ) { $ args [ 'id' ] = $ emailId ; return $ this -> getResult ( 'approveEmailbyId' , $ args , false , $ returnRaw ) ; }
|
Approve an email
|
51,956
|
private function getResult ( $ command , $ args , $ fixArgs = false , $ returnRaw = false ) { $ cmd = $ this -> getCommand ( $ command , $ args ) ; if ( $ fixArgs ) { $ cmd -> prepare ( ) ; $ url = preg_replace ( '/id%5B([0-9]+)%5D/' , 'id' , $ cmd -> getRequest ( ) -> getUrl ( ) ) ; $ cmd -> getRequest ( ) -> setUrl ( $ url ) ; } $ cmd -> prepare ( ) ; if ( $ returnRaw ) { return $ cmd -> getResponse ( ) -> getBody ( true ) ; } return $ cmd -> getResult ( ) ; }
|
Internal helper method to actually perform command .
|
51,957
|
public function localized ( $ language = null ) { if ( ! $ language ) { $ language = Yii :: $ app -> language ; } if ( ! isset ( $ this -> with [ 'translations' ] ) ) { $ this -> with ( [ 'translation' => function ( $ query ) use ( $ language ) { $ query -> where ( [ $ this -> languageField => $ language ] ) ; } ] ) ; } return $ this ; }
|
Scope for querying by languages .
|
51,958
|
public static function getLanguages ( $ languages , $ owner ) { if ( ! $ languages && isset ( Yii :: $ app -> params [ 'languages' ] ) ) { $ languages = Yii :: $ app -> params [ 'languages' ] ; } if ( ! is_array ( $ languages ) || empty ( $ languages ) ) { throw new InvalidConfigException ( 'Please specify array of available languages in the ' . get_class ( $ owner ) . ' or in the application parameters' ) ; } return $ languages ; }
|
Validates and returns list of languages .
|
51,959
|
public static function getLanguageRedirects ( $ languageRedirects ) { if ( ! $ languageRedirects && isset ( Yii :: $ app -> params [ 'languageRedirects' ] ) ) { $ languageRedirects = Yii :: $ app -> params [ 'languageRedirects' ] ; } return $ languageRedirects ; }
|
Validates and returns list of language redirects .
|
51,960
|
public static function getDisplayLanguages ( $ languages , $ languageRedirects ) { foreach ( $ languages as $ key => $ value ) { $ key = ( isset ( $ languageRedirects [ $ key ] ) ) ? $ languageRedirects [ $ key ] : $ key ; $ redirects [ $ key ] = $ value ; } return $ redirects ; }
|
Returns list of languages with applied language redirects .
|
51,961
|
public function languageSwitcher ( $ model , $ view = null ) { $ languages = ( $ model -> getBehavior ( 'multilingual' ) ) ? $ languages = $ model -> getBehavior ( 'multilingual' ) -> languages : [ ] ; return FormLanguageSwitcher :: widget ( [ 'languages' => $ languages , 'view' => $ view ] ) ; }
|
Renders form language switcher .
|
51,962
|
protected function updateArguments ( $ method , $ arguments , $ field ) { if ( $ method == 'widget' && isset ( $ arguments [ 1 ] [ 'options' ] [ 'id' ] ) ) { $ arguments [ 1 ] [ 'options' ] [ 'id' ] = MultilingualHelper :: getAttributeName ( $ arguments [ 1 ] [ 'options' ] [ 'id' ] , $ field -> language ) ; } if ( in_array ( $ method , [ 'textInput' , 'textarea' , 'radio' , 'checkbox' , 'fileInput' , 'hiddenInput' , 'passwordInput' ] ) && isset ( $ arguments [ 0 ] [ 'id' ] ) ) { $ arguments [ 0 ] [ 'id' ] = MultilingualHelper :: getAttributeName ( $ arguments [ 0 ] [ 'id' ] , $ field -> language ) ; } if ( in_array ( $ method , [ 'input' , 'dropDownList' , 'listBox' , 'radioList' , 'checkboxList' ] ) && isset ( $ arguments [ 1 ] [ 'id' ] ) ) { $ arguments [ 1 ] [ 'id' ] = MultilingualHelper :: getAttributeName ( $ arguments [ 1 ] [ 'id' ] , $ field -> language ) ; } return $ arguments ; }
|
Updates id for multilingual inputs with custom id .
|
51,963
|
public function getStatus ( $ id ) { if ( $ this -> isSuccess ( ) ) { foreach ( $ this -> getResult ( ) as $ row ) { if ( $ row [ 'id' ] == $ id ) { return $ row [ 'status' ] ; } } } return false ; }
|
Get the status of a lead .
|
51,964
|
function nusoap_server ( $ wsdl = false ) { parent :: nusoap_base ( ) ; global $ debug ; global $ HTTP_SERVER_VARS ; if ( isset ( $ _SERVER ) ) { $ this -> debug ( "_SERVER is defined:" ) ; $ this -> appendDebug ( $ this -> varDump ( $ _SERVER ) ) ; } elseif ( isset ( $ HTTP_SERVER_VARS ) ) { $ this -> debug ( "HTTP_SERVER_VARS is defined:" ) ; $ this -> appendDebug ( $ this -> varDump ( $ HTTP_SERVER_VARS ) ) ; } else { $ this -> debug ( "Neither _SERVER nor HTTP_SERVER_VARS is defined." ) ; } if ( isset ( $ debug ) ) { $ this -> debug ( "In nusoap_server, set debug_flag=$debug based on global flag" ) ; $ this -> debug_flag = $ debug ; } elseif ( isset ( $ _SERVER [ 'QUERY_STRING' ] ) ) { $ qs = explode ( '&' , $ _SERVER [ 'QUERY_STRING' ] ) ; foreach ( $ qs as $ v ) { if ( substr ( $ v , 0 , 6 ) == 'debug=' ) { $ this -> debug ( "In nusoap_server, set debug_flag=" . substr ( $ v , 6 ) . " based on query string #1" ) ; $ this -> debug_flag = substr ( $ v , 6 ) ; } } } elseif ( isset ( $ HTTP_SERVER_VARS [ 'QUERY_STRING' ] ) ) { $ qs = explode ( '&' , $ HTTP_SERVER_VARS [ 'QUERY_STRING' ] ) ; foreach ( $ qs as $ v ) { if ( substr ( $ v , 0 , 6 ) == 'debug=' ) { $ this -> debug ( "In nusoap_server, set debug_flag=" . substr ( $ v , 6 ) . " based on query string #2" ) ; $ this -> debug_flag = substr ( $ v , 6 ) ; } } } if ( $ wsdl ) { $ this -> debug ( "In nusoap_server, WSDL is specified" ) ; if ( is_object ( $ wsdl ) && ( get_class ( $ wsdl ) == 'wsdl' ) ) { $ this -> wsdl = $ wsdl ; $ this -> externalWSDLURL = $ this -> wsdl -> wsdl ; $ this -> debug ( 'Use existing wsdl instance from ' . $ this -> externalWSDLURL ) ; } else { $ this -> debug ( 'Create wsdl from ' . $ wsdl ) ; $ this -> wsdl = new wsdl ( $ wsdl ) ; $ this -> externalWSDLURL = $ wsdl ; } $ this -> appendDebug ( $ this -> wsdl -> getDebug ( ) ) ; $ this -> wsdl -> clearDebug ( ) ; if ( $ err = $ this -> wsdl -> getError ( ) ) { die ( 'WSDL ERROR: ' . $ err ) ; } } }
|
constructor the optional parameter is a path to a WSDL file that you d like to bind the server instance to .
|
51,965
|
function parse_request ( $ data = '' ) { $ this -> debug ( 'entering parse_request()' ) ; $ this -> parse_http_headers ( ) ; $ this -> debug ( 'got character encoding: ' . $ this -> xml_encoding ) ; if ( isset ( $ this -> headers [ 'content-encoding' ] ) && $ this -> headers [ 'content-encoding' ] != '' ) { $ this -> debug ( 'got content encoding: ' . $ this -> headers [ 'content-encoding' ] ) ; if ( $ this -> headers [ 'content-encoding' ] == 'deflate' || $ this -> headers [ 'content-encoding' ] == 'gzip' ) { if ( function_exists ( 'gzuncompress' ) ) { if ( $ this -> headers [ 'content-encoding' ] == 'deflate' && $ degzdata = @ gzuncompress ( $ data ) ) { $ data = $ degzdata ; } elseif ( $ this -> headers [ 'content-encoding' ] == 'gzip' && $ degzdata = gzinflate ( substr ( $ data , 10 ) ) ) { $ data = $ degzdata ; } else { $ this -> fault ( 'SOAP-ENV:Client' , 'Errors occurred when trying to decode the data' ) ; return ; } } else { $ this -> fault ( 'SOAP-ENV:Client' , 'This Server does not support compressed data' ) ; return ; } } } $ this -> request .= "\r\n" . $ data ; $ data = $ this -> parseRequest ( $ this -> headers , $ data ) ; $ this -> requestSOAP = $ data ; $ this -> debug ( 'leaving parse_request' ) ; }
|
parses a request
|
51,966
|
function send_response ( ) { $ this -> debug ( 'Enter send_response' ) ; if ( $ this -> fault ) { $ payload = $ this -> fault -> serialize ( ) ; $ this -> outgoing_headers [ ] = "HTTP/1.0 500 Internal Server Error" ; $ this -> outgoing_headers [ ] = "Status: 500 Internal Server Error" ; } else { $ payload = $ this -> responseSOAP ; } if ( isset ( $ this -> debug_flag ) && $ this -> debug_flag ) { $ payload .= $ this -> getDebugAsXMLComment ( ) ; } $ this -> outgoing_headers [ ] = "Server: $this->title Server v$this->version" ; preg_match ( '/\$Revisio' . 'n: ([^ ]+)/' , $ this -> revision , $ rev ) ; $ this -> outgoing_headers [ ] = "X-SOAP-Server: $this->title/$this->version (" . $ rev [ 1 ] . ")" ; $ payload = $ this -> getHTTPBody ( $ payload ) ; $ type = $ this -> getHTTPContentType ( ) ; $ charset = $ this -> getHTTPContentTypeCharset ( ) ; $ this -> outgoing_headers [ ] = "Content-Type: $type" . ( $ charset ? '; charset=' . $ charset : '' ) ; if ( strlen ( $ payload ) > 1024 && isset ( $ this -> headers ) && isset ( $ this -> headers [ 'accept-encoding' ] ) ) { if ( strstr ( $ this -> headers [ 'accept-encoding' ] , 'gzip' ) ) { if ( function_exists ( 'gzencode' ) ) { if ( isset ( $ this -> debug_flag ) && $ this -> debug_flag ) { $ payload .= "<!-- Content being gzipped ; } $ this -> outgoing_headers [ ] = "Content-Encoding: gzip" ; $ payload = gzencode ( $ payload ) ; } else { if ( isset ( $ this -> debug_flag ) && $ this -> debug_flag ) { $ payload .= "<!-- Content will not be gzipped: no gzencode ; } } } elseif ( strstr ( $ this -> headers [ 'accept-encoding' ] , 'deflate' ) ) { if ( function_exists ( 'gzdeflate' ) ) { if ( isset ( $ this -> debug_flag ) && $ this -> debug_flag ) { $ payload .= "<!-- Content being deflated ; } $ this -> outgoing_headers [ ] = "Content-Encoding: deflate" ; $ payload = gzdeflate ( $ payload ) ; } else { if ( isset ( $ this -> debug_flag ) && $ this -> debug_flag ) { $ payload .= "<!-- Content will not be deflated: no gzcompress ; } } } } $ this -> outgoing_headers [ ] = "Content-Length: " . strlen ( $ payload ) ; reset ( $ this -> outgoing_headers ) ; foreach ( $ this -> outgoing_headers as $ hdr ) { header ( $ hdr , false ) ; } print $ payload ; $ this -> response = join ( "\r\n" , $ this -> outgoing_headers ) . "\r\n\r\n" . $ payload ; }
|
sends an HTTP response
|
51,967
|
function fault ( $ faultcode , $ faultstring , $ faultactor = '' , $ faultdetail = '' ) { if ( $ faultdetail == '' && $ this -> debug_flag ) { $ faultdetail = $ this -> getDebug ( ) ; } $ this -> fault = new nusoap_fault ( $ faultcode , $ faultactor , $ faultstring , $ faultdetail ) ; $ this -> fault -> soap_defencoding = $ this -> soap_defencoding ; }
|
Specify a fault to be returned to the client . This also acts as a flag to the server that a fault has occured .
|
51,968
|
function getHTTPBody ( $ soapmsg ) { if ( count ( $ this -> responseAttachments ) > 0 ) { $ params [ 'content_type' ] = 'multipart/related; type="text/xml"' ; $ mimeMessage = new Mail_mimePart ( '' , $ params ) ; unset ( $ params ) ; $ params [ 'content_type' ] = 'text/xml' ; $ params [ 'encoding' ] = '8bit' ; $ params [ 'charset' ] = $ this -> soap_defencoding ; $ mimeMessage -> addSubpart ( $ soapmsg , $ params ) ; foreach ( $ this -> responseAttachments as $ att ) { unset ( $ params ) ; $ params [ 'content_type' ] = $ att [ 'contenttype' ] ; $ params [ 'encoding' ] = 'base64' ; $ params [ 'disposition' ] = 'attachment' ; $ params [ 'dfilename' ] = $ att [ 'filename' ] ; $ params [ 'cid' ] = $ att [ 'cid' ] ; if ( $ att [ 'data' ] == '' && $ att [ 'filename' ] <> '' ) { if ( $ fd = fopen ( $ att [ 'filename' ] , 'rb' ) ) { $ data = fread ( $ fd , filesize ( $ att [ 'filename' ] ) ) ; fclose ( $ fd ) ; } else { $ data = '' ; } $ mimeMessage -> addSubpart ( $ data , $ params ) ; } else { $ mimeMessage -> addSubpart ( $ att [ 'data' ] , $ params ) ; } } $ output = $ mimeMessage -> encode ( ) ; $ mimeHeaders = $ output [ 'headers' ] ; foreach ( $ mimeHeaders as $ k => $ v ) { $ this -> debug ( "MIME header $k: $v" ) ; if ( strtolower ( $ k ) == 'content-type' ) { $ this -> mimeContentType = str_replace ( "\r\n" , " " , $ v ) ; } } return $ output [ 'body' ] ; } return parent :: getHTTPBody ( $ soapmsg ) ; }
|
gets the HTTP body for the current response .
|
51,969
|
function getCookiesForRequest ( $ cookies , $ secure = false ) { $ cookie_str = '' ; if ( ( ! is_null ( $ cookies ) ) && ( is_array ( $ cookies ) ) ) { foreach ( $ cookies as $ cookie ) { if ( ! is_array ( $ cookie ) ) { continue ; } $ this -> debug ( "check cookie for validity: " . $ cookie [ 'name' ] . '=' . $ cookie [ 'value' ] ) ; if ( ( isset ( $ cookie [ 'expires' ] ) ) && ( ! empty ( $ cookie [ 'expires' ] ) ) ) { if ( strtotime ( $ cookie [ 'expires' ] ) <= time ( ) ) { $ this -> debug ( 'cookie has expired' ) ; continue ; } } if ( ( isset ( $ cookie [ 'domain' ] ) ) && ( ! empty ( $ cookie [ 'domain' ] ) ) ) { $ domain = preg_quote ( $ cookie [ 'domain' ] ) ; if ( ! preg_match ( "'.*$domain$'i" , $ this -> host ) ) { $ this -> debug ( 'cookie has different domain' ) ; continue ; } } if ( ( isset ( $ cookie [ 'path' ] ) ) && ( ! empty ( $ cookie [ 'path' ] ) ) ) { $ path = preg_quote ( $ cookie [ 'path' ] ) ; if ( ! preg_match ( "'^$path.*'i" , $ this -> path ) ) { $ this -> debug ( 'cookie is for a different path' ) ; continue ; } } if ( ( ! $ secure ) && ( isset ( $ cookie [ 'secure' ] ) ) && ( $ cookie [ 'secure' ] ) ) { $ this -> debug ( 'cookie is secure, transport is not' ) ; continue ; } $ cookie_str .= $ cookie [ 'name' ] . '=' . $ cookie [ 'value' ] . '; ' ; $ this -> debug ( 'add cookie to Cookie-String: ' . $ cookie [ 'name' ] . '=' . $ cookie [ 'value' ] ) ; } } return $ cookie_str ; }
|
sort out cookies for the current request
|
51,970
|
public function generate ( ) { $ returnVar = $ this -> executeCommand ( $ output ) ; if ( $ returnVar == 0 ) { $ this -> contents = $ this -> getPDFContents ( ) ; } else { throw new PDFException ( $ output ) ; } $ this -> removeTmpFiles ( ) ; return $ this ; }
|
Generates the PDF and save the PDF content for the further use
|
51,971
|
public function save ( $ fileName , AdapterInterface $ adapter , $ overwrite = false ) { $ fs = new Filesystem ( $ adapter ) ; if ( $ overwrite == true ) { $ fs -> put ( $ fileName , $ this -> get ( ) ) ; } else { $ fs -> write ( $ fileName , $ this -> get ( ) ) ; } return $ this ; }
|
Saves the pdf content to the specified location
|
51,972
|
public function removeTmpFiles ( ) { if ( file_exists ( $ this -> getHTMLPath ( ) ) ) { @ unlink ( $ this -> getHTMLPath ( ) ) ; } if ( file_exists ( $ this -> getPDFPath ( ) ) ) { @ unlink ( $ this -> getPDFPath ( ) ) ; } }
|
Remove temporary HTML and PDF files
|
51,973
|
public function executeCommand ( & $ output ) { $ descriptorspec = array ( 0 => array ( "pipe" , "r" ) , 1 => array ( "pipe" , "w" ) , 2 => array ( "pipe" , "w" ) ) ; $ process = proc_open ( $ this -> cmd . ' ' . $ this -> getParams ( ) . ' ' . $ this -> getInputSource ( ) . ' ' . $ this -> getPDFPath ( ) , $ descriptorspec , $ pipes ) ; $ output = stream_get_contents ( $ pipes [ 1 ] ) . stream_get_contents ( $ pipes [ 2 ] ) ; fclose ( $ pipes [ 0 ] ) ; fclose ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 2 ] ) ; return proc_close ( $ process ) ; }
|
Execute wkhtmltopdf command
|
51,974
|
protected function getParams ( ) { $ result = "" ; foreach ( $ this -> params as $ key => $ value ) { if ( is_numeric ( $ key ) ) { $ result .= '--' . $ value ; } else { $ result .= '--' . $ key . ' ' . '"' . $ value . '"' ; } $ result .= ' ' ; } return $ result ; }
|
Gets the parameters defined by user
|
51,975
|
protected function addParam ( $ key , $ value = null ) { if ( is_null ( $ value ) ) { $ this -> params [ ] = $ key ; } else { $ this -> params [ $ key ] = $ value ; } }
|
Adds a wkhtmltopdf parameter
|
51,976
|
protected function getInputSource ( ) { if ( ! is_null ( $ this -> path ) ) { return $ this -> path ; } file_put_contents ( $ this -> getHTMLPath ( ) , $ this -> htmlContent ) ; return $ this -> getHTMLPath ( ) ; }
|
Gets the Input source which can be an HTML file or a File path
|
51,977
|
function addSimpleType ( $ name , $ restrictionBase = '' , $ typeClass = 'simpleType' , $ phpType = 'scalar' , $ enumeration = array ( ) ) { $ this -> simpleTypes [ $ name ] = array ( 'name' => $ name , 'typeClass' => $ typeClass , 'phpType' => $ phpType , 'type' => $ restrictionBase , 'enumeration' => $ enumeration ) ; $ this -> xdebug ( "addSimpleType $name:" ) ; $ this -> appendDebug ( $ this -> varDump ( $ this -> simpleTypes [ $ name ] ) ) ; }
|
adds a simple type to the schema
|
51,978
|
public function offsetGet ( $ offset ) { $ this -> validateKeyType ( $ offset ) ; $ this -> validateKeyBounds ( $ offset ) ; return $ this -> container [ $ offset ] ; }
|
identical to at implemented for ArrayAccess
|
51,979
|
function debug ( $ string ) { if ( $ this -> debugLevel > 0 ) { $ this -> appendDebug ( $ this -> getmicrotime ( ) . ' ' . get_class ( $ this ) . ": $string\n" ) ; } }
|
adds debug data to the instance debug string with formatting
|
51,980
|
function getmicrotime ( ) { if ( function_exists ( 'gettimeofday' ) ) { $ tod = gettimeofday ( ) ; $ sec = $ tod [ 'sec' ] ; $ usec = $ tod [ 'usec' ] ; } else { $ sec = time ( ) ; $ usec = 0 ; } return strftime ( '%Y-%m-%d %H:%M:%S' , $ sec ) . '.' . sprintf ( '%06d' , $ usec ) ; }
|
returns the time in ODBC canonical form with microseconds
|
51,981
|
function releaseMutex ( $ filename ) { $ ret = flock ( $ this -> fplock [ md5 ( $ filename ) ] , LOCK_UN ) ; fclose ( $ this -> fplock [ md5 ( $ filename ) ] ) ; unset ( $ this -> fplock [ md5 ( $ filename ) ] ) ; if ( ! $ ret ) { $ this -> debug ( "Not able to release lock for $filename" ) ; } return $ ret ; }
|
releases the local mutex
|
51,982
|
function remove ( $ wsdl ) { $ filename = $ this -> createFilename ( $ wsdl ) ; if ( ! file_exists ( $ filename ) ) { $ this -> debug ( "$wsdl ($filename) not in cache to be removed" ) ; return false ; } $ this -> obtainMutex ( $ filename , "w" ) ; $ ret = unlink ( $ filename ) ; $ this -> debug ( "Removed ($ret) $wsdl ($filename) from cache" ) ; $ this -> releaseMutex ( $ filename ) ; return $ ret ; }
|
removes a wsdl instance from the cache
|
51,983
|
public function toArray ( ) { $ arr = [ ] ; foreach ( $ this as $ k => $ v ) { if ( $ v instanceof Enumerable ) { $ arr [ ] = $ v -> toArray ( ) ; } else { $ arr [ ] = $ v ; } } return $ arr ; }
|
Returns an array containing the values from this VectorLike .
|
51,984
|
function getOperationData ( $ operation ) { if ( $ this -> endpointType == 'wsdl' && is_null ( $ this -> wsdl ) ) { $ this -> loadWSDL ( ) ; if ( $ this -> getError ( ) ) return false ; } if ( isset ( $ this -> operations [ $ operation ] ) ) { return $ this -> operations [ $ operation ] ; } $ this -> debug ( "No data for operation: $operation" ) ; }
|
get available data pertaining to an operation
|
51,985
|
function setCurlOption ( $ option , $ value ) { $ this -> debug ( "setCurlOption option=$option, value=" ) ; $ this -> appendDebug ( $ this -> varDump ( $ value ) ) ; $ this -> curl_options [ $ option ] = $ value ; }
|
sets user - specified cURL options
|
51,986
|
function setHeaders ( $ headers ) { $ this -> debug ( "setHeaders headers=" ) ; $ this -> appendDebug ( $ this -> varDump ( $ headers ) ) ; $ this -> requestHeaders = $ headers ; }
|
set the SOAP headers
|
51,987
|
function getTypeDef ( $ type , $ ns ) { $ this -> debug ( "in getTypeDef: type=$type, ns=$ns" ) ; if ( ( ! $ ns ) && isset ( $ this -> namespaces [ 'tns' ] ) ) { $ ns = $ this -> namespaces [ 'tns' ] ; $ this -> debug ( "in getTypeDef: type namespace forced to $ns" ) ; } if ( ! isset ( $ this -> schemas [ $ ns ] ) ) { foreach ( $ this -> schemas as $ ns0 => $ schema0 ) { if ( strcasecmp ( $ ns , $ ns0 ) == 0 ) { $ this -> debug ( "in getTypeDef: replacing schema namespace $ns with $ns0" ) ; $ ns = $ ns0 ; break ; } } } if ( isset ( $ this -> schemas [ $ ns ] ) ) { $ this -> debug ( "in getTypeDef: have schema for namespace $ns" ) ; for ( $ i = 0 ; $ i < count ( $ this -> schemas [ $ ns ] ) ; $ i ++ ) { $ xs = & $ this -> schemas [ $ ns ] [ $ i ] ; $ t = $ xs -> getTypeDef ( $ type ) ; $ this -> appendDebug ( $ xs -> getDebug ( ) ) ; $ xs -> clearDebug ( ) ; if ( $ t ) { $ this -> debug ( "in getTypeDef: found type $type" ) ; if ( ! isset ( $ t [ 'phpType' ] ) ) { $ uqType = substr ( $ t [ 'type' ] , strrpos ( $ t [ 'type' ] , ':' ) + 1 ) ; $ ns = substr ( $ t [ 'type' ] , 0 , strrpos ( $ t [ 'type' ] , ':' ) ) ; $ etype = $ this -> getTypeDef ( $ uqType , $ ns ) ; if ( $ etype ) { $ this -> debug ( "found type for [element] $type:" ) ; $ this -> debug ( $ this -> varDump ( $ etype ) ) ; if ( isset ( $ etype [ 'phpType' ] ) ) { $ t [ 'phpType' ] = $ etype [ 'phpType' ] ; } if ( isset ( $ etype [ 'elements' ] ) ) { $ t [ 'elements' ] = $ etype [ 'elements' ] ; } if ( isset ( $ etype [ 'attrs' ] ) ) { $ t [ 'attrs' ] = $ etype [ 'attrs' ] ; } } else { $ this -> debug ( "did not find type for [element] $type" ) ; } } return $ t ; } } $ this -> debug ( "in getTypeDef: did not find type $type" ) ; } else { $ this -> debug ( "in getTypeDef: do not have schema for namespace $ns" ) ; } return false ; }
|
returns an array of information about a given type returns false if no type exists by the given name
|
51,988
|
function parametersMatchWrapped ( $ type , & $ parameters ) { $ this -> debug ( "in parametersMatchWrapped type=$type, parameters=" ) ; $ this -> appendDebug ( $ this -> varDump ( $ parameters ) ) ; if ( strpos ( $ type , ':' ) ) { $ uqType = substr ( $ type , strrpos ( $ type , ':' ) + 1 ) ; $ ns = substr ( $ type , 0 , strrpos ( $ type , ':' ) ) ; $ this -> debug ( "in parametersMatchWrapped: got a prefixed type: $uqType, $ns" ) ; if ( $ this -> getNamespaceFromPrefix ( $ ns ) ) { $ ns = $ this -> getNamespaceFromPrefix ( $ ns ) ; $ this -> debug ( "in parametersMatchWrapped: expanded prefixed type: $uqType, $ns" ) ; } } else { $ this -> debug ( "in parametersMatchWrapped: No namespace for type $type" ) ; $ ns = '' ; $ uqType = $ type ; } if ( ! $ typeDef = $ this -> getTypeDef ( $ uqType , $ ns ) ) { $ this -> debug ( "in parametersMatchWrapped: $type ($uqType) is not a supported type." ) ; return false ; } $ this -> debug ( "in parametersMatchWrapped: found typeDef=" ) ; $ this -> appendDebug ( $ this -> varDump ( $ typeDef ) ) ; if ( substr ( $ uqType , - 1 ) == '^' ) { $ uqType = substr ( $ uqType , 0 , - 1 ) ; } $ phpType = $ typeDef [ 'phpType' ] ; $ arrayType = ( isset ( $ typeDef [ 'arrayType' ] ) ? $ typeDef [ 'arrayType' ] : '' ) ; $ this -> debug ( "in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType" ) ; if ( $ phpType != 'struct' ) { $ this -> debug ( "in parametersMatchWrapped: not a struct" ) ; return false ; } if ( isset ( $ typeDef [ 'elements' ] ) && is_array ( $ typeDef [ 'elements' ] ) ) { $ elements = 0 ; $ matches = 0 ; foreach ( $ typeDef [ 'elements' ] as $ name => $ attrs ) { if ( isset ( $ parameters [ $ name ] ) ) { $ this -> debug ( "in parametersMatchWrapped: have parameter named $name" ) ; $ matches ++ ; } else { $ this -> debug ( "in parametersMatchWrapped: do not have parameter named $name" ) ; } $ elements ++ ; } $ this -> debug ( "in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names" ) ; if ( $ matches == 0 ) { return false ; } return true ; } $ this -> debug ( "in parametersMatchWrapped: no elements type $ns:$uqType" ) ; return count ( $ parameters ) == 0 ; }
|
determine whether a set of parameters are unwrapped when they are expect to be wrapped Microsoft - style .
|
51,989
|
function serializeComplexTypeAttributes ( $ typeDef , $ value , $ ns , $ uqType ) { $ this -> debug ( "serializeComplexTypeAttributes for XML Schema type $ns:$uqType" ) ; $ xml = '' ; if ( isset ( $ typeDef [ 'extensionBase' ] ) ) { $ nsx = $ this -> getPrefix ( $ typeDef [ 'extensionBase' ] ) ; $ uqTypex = $ this -> getLocalPart ( $ typeDef [ 'extensionBase' ] ) ; if ( $ this -> getNamespaceFromPrefix ( $ nsx ) ) { $ nsx = $ this -> getNamespaceFromPrefix ( $ nsx ) ; } if ( $ typeDefx = $ this -> getTypeDef ( $ uqTypex , $ nsx ) ) { $ this -> debug ( "serialize attributes for extension base $nsx:$uqTypex" ) ; $ xml .= $ this -> serializeComplexTypeAttributes ( $ typeDefx , $ value , $ nsx , $ uqTypex ) ; } else { $ this -> debug ( "extension base $nsx:$uqTypex is not a supported type" ) ; } } if ( isset ( $ typeDef [ 'attrs' ] ) && is_array ( $ typeDef [ 'attrs' ] ) ) { $ this -> debug ( "serialize attributes for XML Schema type $ns:$uqType" ) ; if ( is_array ( $ value ) ) { $ xvalue = $ value ; } elseif ( is_object ( $ value ) ) { $ xvalue = get_object_vars ( $ value ) ; } else { $ this -> debug ( "value is neither an array nor an object for XML Schema type $ns:$uqType" ) ; $ xvalue = array ( ) ; } foreach ( $ typeDef [ 'attrs' ] as $ aName => $ attrs ) { if ( isset ( $ xvalue [ '!' . $ aName ] ) ) { $ xname = '!' . $ aName ; $ this -> debug ( "value provided for attribute $aName with key $xname" ) ; } elseif ( isset ( $ xvalue [ $ aName ] ) ) { $ xname = $ aName ; $ this -> debug ( "value provided for attribute $aName with key $xname" ) ; } elseif ( isset ( $ attrs [ 'default' ] ) ) { $ xname = '!' . $ aName ; $ xvalue [ $ xname ] = $ attrs [ 'default' ] ; $ this -> debug ( 'use default value of ' . $ xvalue [ $ aName ] . ' for attribute ' . $ aName ) ; } else { $ xname = '' ; $ this -> debug ( "no value provided for attribute $aName" ) ; } if ( $ xname ) { $ xml .= " $aName=\"" . $ this -> expandEntities ( $ xvalue [ $ xname ] ) . "\"" ; } } } else { $ this -> debug ( "no attributes to serialize for XML Schema type $ns:$uqType" ) ; } return $ xml ; }
|
serializes the attributes for a complexType
|
51,990
|
function addSimpleType ( $ name , $ restrictionBase = '' , $ typeClass = 'simpleType' , $ phpType = 'scalar' , $ enumeration = array ( ) ) { $ restrictionBase = strpos ( $ restrictionBase , ':' ) ? $ this -> expandQname ( $ restrictionBase ) : $ restrictionBase ; $ typens = isset ( $ this -> namespaces [ 'types' ] ) ? $ this -> namespaces [ 'types' ] : $ this -> namespaces [ 'tns' ] ; $ this -> schemas [ $ typens ] [ 0 ] -> addSimpleType ( $ name , $ restrictionBase , $ typeClass , $ phpType , $ enumeration ) ; }
|
adds an XML Schema simple type to the WSDL types
|
51,991
|
function addElement ( $ attrs ) { $ typens = isset ( $ this -> namespaces [ 'types' ] ) ? $ this -> namespaces [ 'types' ] : $ this -> namespaces [ 'tns' ] ; $ this -> schemas [ $ typens ] [ 0 ] -> addElement ( $ attrs ) ; }
|
adds an element to the WSDL types
|
51,992
|
public function addGlobalMergeVar ( $ name , $ content ) { $ this -> globalMergeVars [ ] = array ( 'name' => $ name , 'content' => $ content , ) ; $ this -> setMerge ( true ) ; return $ this ; }
|
Set global merge variable to use for all recipients . You can override these per recipient .
|
51,993
|
public function addMergeVar ( $ recipient , $ name , $ content ) { $ this -> mergeVars [ ] = array ( 'rcpt' => $ recipient , 'vars' => array ( array ( 'name' => $ name , 'content' => $ content ) ) ) ; $ this -> setMerge ( true ) ; return $ this ; }
|
Add per - recipient merge variable which override global merge variables with the same name .
|
51,994
|
public function addMergeVars ( $ recipient , $ data ) { $ vars = array ( ) ; foreach ( $ data as $ name => $ content ) { $ vars [ ] = array ( 'name' => $ name , 'content' => $ content ) ; } $ this -> mergeVars [ ] = array ( 'rcpt' => $ recipient , 'vars' => $ vars ) ; return $ this ; }
|
Add several per - recipient merge variables which override global merge variables with the same name .
|
51,995
|
public function addMetadata ( $ data ) { if ( is_array ( $ data ) ) { foreach ( $ data as $ k => $ v ) { $ this -> metadata [ $ k ] = $ v ; } } else { $ this -> metadata [ ] = $ data ; } return $ this ; }
|
Add global metadata .
|
51,996
|
public function addRecipientMetadata ( $ recipient , $ data ) { foreach ( $ this -> recipientMetadata as $ idx => $ rcptMetadata ) { if ( isset ( $ rcptMetadata [ 'rcpt' ] ) && $ rcptMetadata [ 'rcpt' ] == $ recipient ) { if ( is_array ( $ data ) ) { foreach ( $ data as $ k => $ v ) { $ this -> recipientMetadata [ $ idx ] [ 'values' ] [ $ k ] = $ v ; } } else { $ this -> recipientMetadata [ $ idx ] [ 'values' ] [ ] = $ data ; } return $ this ; } } $ this -> recipientMetadata [ ] = array ( 'rcpt' => $ recipient , 'values' => is_array ( $ data ) ? $ data : array ( $ data ) ) ; return $ this ; }
|
Add Per - recipient metadata that will override the global values specified in the metadata parameter .
|
51,997
|
public function addAttachment ( $ type , $ name , $ data ) { $ this -> attachments [ ] = array ( 'type' => $ type , 'name' => $ name , 'content' => $ data ) ; return $ this ; }
|
Add supported attachments to add to the message
|
51,998
|
public function addImage ( $ type , $ name , $ data ) { $ this -> images [ ] = array ( 'type' => $ type , 'name' => $ name , 'content' => $ data ) ; return $ this ; }
|
Add images embedded in the message
|
51,999
|
public function getIpVersion ( $ ip ) { if ( false !== filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ) { return self :: IPv6 ; } else if ( false !== filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { return self :: IPv4 ; } return false ; }
|
Get IP verison
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.