idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
22,600
public function hasRange ( ) { return ( $ this -> getOffset ( ) !== false && $ this -> getOffset ( ) >= 0 && $ this -> getNumberOfEntries ( ) !== false && $ this -> getNumberOfEntries ( ) > 0 ) ; }
Returns true if only a range of the result is requested
22,601
public static function getInstance ( ) { $ classname = get_called_class ( ) ; if ( ! isset ( self :: $ instances [ $ classname ] ) ) { self :: $ instances [ $ classname ] = new static ; } return self :: $ instances [ $ classname ] ; }
return an instance of the called class
22,602
public function addTemplatePath ( $ namespace , $ path ) { if ( ! is_string ( $ namespace ) || ! is_string ( $ path ) || empty ( $ namespace ) || empty ( $ path ) ) { throw new \ InvalidArgumentException ( 'Template namespace and path must be a not empty string' ) ; } $ this -> paths [ $ namespace ] = $ this -> normalizePath ( $ path ) ; }
Add template path
22,603
public function getTemplatePath ( $ namespace ) { if ( ! $ this -> hasTemplatePath ( $ namespace ) ) { throw new \ RuntimeException ( "Path with namespace \"" . $ namespace . "\" is not exist" ) ; } $ path = $ this -> paths [ $ namespace ] ; if ( ! is_dir ( $ path ) ) { throw new \ RuntimeException ( "Invalid template path with namespace \"" . $ namespace . "\"" ) ; } return $ path ; }
Get themplate path by namespace
22,604
public function addTemplate ( $ name , $ filename ) { if ( ! is_string ( $ name ) || ! is_string ( $ filename ) || empty ( $ name ) || empty ( $ filename ) ) { throw new \ InvalidArgumentException ( 'Template name and filename must be a not empty string' ) ; } $ this -> templateMap [ $ name ] = $ filename ; }
Add template to the map
22,605
public function getTemplate ( $ name ) { if ( ! $ this -> hasTemplate ( $ name ) ) { throw new \ RuntimeException ( "Template with name \"" . $ name . "\" is not exist" ) ; } $ filename = $ this -> templateMap [ $ name ] ; if ( ! file_exists ( $ filename ) ) { throw new \ RuntimeException ( "Invalid template filename with name \"" . $ name . "\"" ) ; } return $ filename ; }
Get template filename
22,606
public static function assertEmpty ( $ countableElement , Throwable $ exception ) : bool { static :: makeAssertion ( 0 === \ count ( $ countableElement ) , $ exception ) ; return true ; }
Asserts that the given array is empty .
22,607
public static function assertNotEmpty ( $ countableElement , Throwable $ exception ) : bool { static :: makeAssertion ( 0 !== \ count ( $ countableElement ) , $ exception ) ; return true ; }
Asserts that the given array is not empty .
22,608
public static function assertCount ( $ countableElement , int $ expected , Throwable $ exception ) : bool { static :: makeAssertion ( \ count ( $ countableElement ) === $ expected , $ exception ) ; return true ; }
Asserts that the given array contains the given number of elements .
22,609
public static function assertNotCount ( $ countableElement , int $ notExpected , Throwable $ exception ) : bool { static :: makeAssertion ( \ count ( $ countableElement ) !== $ notExpected , $ exception ) ; return true ; }
Asserts that the given array does not contain the given number of elements .
22,610
public function apply ( Builder $ builder , Repository $ repository , array $ relations = [ ] ) { $ relations = $ this -> getRelations ( $ repository , $ relations ) ; return $ builder -> with ( $ relations ) ; }
Apply eager load relations to query builder
22,611
private function getRelations ( Repository $ repository , array $ relations = [ ] ) { if ( count ( $ relations ) === 0 ) { $ relations = Input :: get ( 'with' ) ; if ( ! is_array ( $ relations ) ) { $ relations = $ this -> inputService -> decode ( 'with' ) ; } } $ result = [ ] ; $ repo_relations = $ repository -> relations ( ) ; foreach ( $ relations as $ key => $ value ) { if ( in_array ( $ key , $ repo_relations ) ) { $ result [ ] = $ key ; } elseif ( in_array ( $ value , $ repo_relations ) ) { $ result [ ] = $ value ; } } return $ result ; }
Get relation array
22,612
public function linkTo ( $ path , $ text , $ is_local_path = true ) { $ url = $ this -> _di -> getService ( "url" ) ; if ( $ is_local_path ) { $ path = $ url -> get ( $ path ) ; } $ link = "<a href='$path'>$text</a>" ; return $ link ; }
Creates an HTML anchor tag using the Url Simox service
22,613
public function associations ( ) { if ( ! $ this -> associations ) { if ( $ this -> getService ( 'rails.config' ) [ 'use_cache' ] ) { $ this -> associations = $ this -> getCachedData ( ) ; } else { $ this -> associations = $ this -> getAssociationsData ( ) ; } } return $ this -> associations ; }
Get all associations and their options .
22,614
public function callbacks ( ) { $ dependent = false ; $ autosave = false ; $ callbacks = [ 'beforeDestroy' => [ ] , 'beforeSave' => [ ] ] ; foreach ( $ this -> associations ( ) as $ data ) { switch ( $ data [ 'type' ] ) { case 'belongsTo' : case 'hasMany' : case 'hasOne' : if ( ! empty ( $ data [ 'dependent' ] ) && ! $ dependent ) { $ callbacks = [ 'beforeDestroy' => [ 'alterDependencies' ] ] ; } default : if ( ! empty ( $ data [ 'autosave' ] ) && ! $ autosave ) { $ callbacks = [ 'beforeSave' => [ 'saveDependencies' ] ] ; } break ; } if ( $ autosave && $ dependent ) { break ; } } return array_filter ( $ callbacks ) ; }
If any of the associations has a dependent option the before - destroy callback alterDependencies should be called . That method will take care of executing the proper tasks with the dependencies according to the options set . Same with the autosave option .
22,615
public function match ( $ input ) { if ( $ this -> currentState === State :: MATCH_FOUND ) { return true ; } if ( $ this -> noMatch ) { return false ; } $ advancing = true ; while ( $ advancing ) { $ hasEmpty = false ; foreach ( $ this -> states [ $ this -> currentState ] -> conditions as $ condition ) { if ( $ condition -> isTokenEmpty ( ) ) { $ this -> callCallbacks ( $ this -> currentState , $ condition -> nextState ) ; $ this -> currentState = $ condition -> nextState ; $ hasEmpty = true ; break ; } if ( $ condition -> match ( $ input ) ) { $ this -> matched [ ] = $ condition -> matched ( $ input ) ; $ this -> actualMatched [ ] = $ condition -> matched ( $ input ) ; $ this -> callCallbacks ( $ this -> currentState , $ condition -> nextState ) ; $ this -> currentState = $ condition -> nextState ; return true ; } } $ advancing = $ hasEmpty ; } $ this -> error = self :: E_NOMATCH ; $ this -> noMatch = true ; $ this -> currentState = State :: NO_MATCH ; return false ; }
Processes one input token and changes the state of the pattern accordingly . Returns true if the given input did not cause the pattern go in an unmatched state .
22,616
private function callCallbacks ( int $ initialState , int $ endState ) { if ( isset ( $ this -> callbacks [ $ initialState ] [ $ endState ] ) && is_callable ( $ this -> callbacks [ $ initialState ] [ $ endState ] ) ) { $ this -> matched = call_user_func ( $ this -> callbacks [ $ initialState ] [ $ endState ] , $ this -> matched ) ; } }
Calls callbacks for the given state number
22,617
public static function smart ( $ value , $ emptyValueIsNull = false ) { if ( is_array ( $ value ) ) { filter_var_array ( $ value , FILTER_SANITIZE_STRING ) ; } switch ( getType ( $ value ) ) { case 'double' : case 'float' : $ _filter = FILTER_SANITIZE_NUMBER_FLOAT ; break ; case 'integer' : $ _filter = FILTER_SANITIZE_NUMBER_INT ; break ; case 'string' : $ _filter = FILTER_SANITIZE_STRING ; break ; default : $ _filter = FILTER_DEFAULT ; break ; } $ _result = filter_var ( $ value , $ _filter ) ; return $ emptyValueIsNull && empty ( $ _result ) ? null : $ _result ; }
Filter chooser based on number or string . Not very smart really .
22,618
public static function get ( $ type , $ key , $ defaultValue = null , $ filter = FILTER_DEFAULT , $ filterOptions = null , $ emptyValueIsNull = false ) { if ( is_array ( $ type ) ) { $ _result = filter_var ( Option :: get ( $ type , $ key , $ defaultValue ) , $ filter , $ filterOptions ) ; return $ emptyValueIsNull && empty ( $ _result ) ? null : $ _result ; } $ _haystack = null ; switch ( $ type ) { case INPUT_REQUEST : $ _haystack = isset ( $ _REQUEST ) ? $ _REQUEST : array ( ) ; break ; case INPUT_SESSION : $ _haystack = isset ( $ _SESSION ) ? $ _SESSION : array ( ) ; break ; case INPUT_GET : $ _haystack = isset ( $ _GET ) ? $ _GET : array ( ) ; break ; case INPUT_POST : $ _haystack = isset ( $ _POST ) ? $ _POST : array ( ) ; break ; case INPUT_COOKIE : $ _haystack = isset ( $ _COOKIE ) ? $ _COOKIE : array ( ) ; break ; case INPUT_SERVER : $ _haystack = isset ( $ _SERVER ) ? $ _SERVER : array ( ) ; break ; case INPUT_ENV : $ _haystack = isset ( $ _ENV ) ? $ _ENV : array ( ) ; break ; default : throw new \ InvalidArgumentException ( 'The filter type of "' . $ type . '" is unknown or not supported.' ) ; } $ _value = empty ( $ _haystack ) ? $ defaultValue : filter_var ( Option :: get ( $ _haystack , $ key , $ defaultValue ) , $ filter , $ filterOptions ) ; return $ emptyValueIsNull && empty ( $ _value ) ? null : $ _value ; }
The master function performs all filters and gets . Gets around lack of INPUT_SESSION and INPUT_REQUEST support .
22,619
public function getRouterContainer ( ) { if ( null === $ this -> routerContainer ) { $ this -> setRouterContainer ( new RouterContainer ( ) ) ; $ this -> routerContainer -> setMapBuilder ( [ $ this -> getRouteBuilder ( ) , 'build' ] ) ; } return $ this -> routerContainer ; }
Returns route container
22,620
public function getMatcher ( ) { if ( null === $ this -> matcher ) { $ this -> setMatcher ( $ this -> getRouterContainer ( ) -> getMatcher ( ) ) ; } return $ this -> matcher ; }
Gets route matcher for this router
22,621
public function getRouteBuilder ( ) { if ( null == $ this -> routeBuilder ) { $ this -> setRouteBuilder ( new RouteBuilder ( $ this -> getRouteFile ( ) ) ) ; } return $ this -> routeBuilder ; }
Get route builder
22,622
public static function forTimePeriod ( $ time_period , Carbon $ date_time ) { $ time_period = self :: parseTimePeriod ( $ time_period ) ; switch ( $ time_period ) { case self :: HOUR : return static :: between ( $ date_time -> copy ( ) -> minute ( 0 ) -> second ( 0 ) , $ date_time -> copy ( ) -> minute ( 59 ) -> second ( 59 ) ) ; default : return static :: between ( $ date_time -> copy ( ) -> { "startOf{$time_period}" } ( ) , $ date_time -> copy ( ) -> { "endOf{$time_period}" } ( ) ) ; } }
Gets a date range for a time period .
22,623
public function spans ( $ time_period ) { $ time_period = self :: parseTimePeriod ( $ time_period ) ; if ( ! $ this -> isBounded ( ) ) { return false ; } $ end = self :: forTimePeriod ( $ time_period , $ this -> after ) -> end ( ) ; if ( ! $ end -> eq ( $ this -> after ) ) { return ; } $ start = self :: forTimePeriod ( $ time_period , $ this -> before ) -> start ( ) ; if ( ! $ start -> eq ( $ this -> before ) ) { return ; } if ( ! self :: forTimePeriod ( $ time_period , $ this -> end ( ) ) -> start ( ) -> eq ( $ this -> start ( ) ) ) { return ; } return $ this -> start ( ) ; }
Determines if a date range spans exactly one entire time period .
22,624
public function getTimeperiod ( ) { foreach ( array_keys ( self :: $ time_periods ) as $ time_period ) { if ( ! is_null ( $ this -> spans ( $ time_period ) ) ) { return $ time_period ; } } return ; }
Determines the time period that a date range spans .
22,625
public function isOpenEnded ( ) { return is_null ( $ this -> before ) || ( ! is_null ( $ this -> after ) && $ this -> before -> lte ( $ this -> after ) ) ; }
Determines if a date range has an upper bound .
22,626
public static function combine ( array $ ranges ) { $ range = new static ( ) ; foreach ( $ ranges as $ cur_range ) { $ cur_start = $ cur_range -> after ; $ cur_end = $ cur_range -> before ; if ( is_null ( $ range -> before ) || $ cur_end -> lt ( $ range -> before ) ) { $ range -> before = $ cur_end ; } if ( is_null ( $ range -> after ) || $ cur_start -> gt ( $ range -> after ) ) { $ range -> after = $ cur_start ; } } return $ range ; }
Combines a collection of date ranges into a single date range .
22,627
public function days ( ) { if ( $ this -> isOpenEnded ( ) || $ this -> isOpenStarted ( ) ) { throw new Exception ( 'The number of days within a range cannot be calculated for ranges that are open ended or open started.' ) ; } return $ this -> after -> diffInDays ( $ this -> before ) ; }
Gets the number of days that a date range spans .
22,628
public function isOpenStarted ( ) { return is_null ( $ this -> after ) || ( ! is_null ( $ this -> before ) && $ this -> before -> lte ( $ this -> after ) ) ; }
Determines if a date range has a lower bound .
22,629
protected function getDatePositionIn ( Carbon $ date_time , $ time_period ) { if ( ! array_key_exists ( $ time_period , self :: $ time_periods ) ) { throw new \ InvalidArgumentException ( 'Time period must be one of the time periods listed in the class constants' ) ; } $ start_date = self :: forTimePeriod ( $ time_period , $ date_time ) -> start ( ) ; if ( $ date_time -> copy ( ) -> eq ( $ start_date ) ) { return self :: START ; } $ end_date = self :: forTimePeriod ( $ time_period , $ date_time ) -> end ( ) ; if ( $ date_time -> copy ( ) -> eq ( $ end_date ) ) { return self :: END ; } }
Determines a dates position within a time period .
22,630
protected function offsetMonthInDate ( Carbon $ original_date , $ offset ) { $ original_month = $ original_date -> month ; if ( $ offset >= 0 && ( $ original_month + $ offset ) <= 12 ) { $ expected_month = $ original_month + $ offset ; } elseif ( $ offset >= 0 ) { $ expected_month = 0 + ( $ offset - ( 12 - $ original_month ) ) ; } elseif ( $ offset < 0 && ( $ original_month + $ offset ) >= 1 ) { $ expected_month = $ original_month + $ offset ; } elseif ( $ offset < 0 ) { $ expected_month = 12 + ( $ offset + $ original_month ) ; } return $ expected_month ; }
Offsets a month in a date by a set value ; offsets > 12 are not currently supported .
22,631
protected function refactorRolledOverDate ( Carbon $ date , Carbon $ original_date ) { return $ date -> subMonth ( ) -> endOfMonth ( ) -> setTime ( $ original_date -> hour , $ original_date -> minute , $ original_date -> second ) ; }
Adjusts a date that has rolled over back to the previous month ; setting the day to the last day of the previous month ; time values are maintained .
22,632
public static function addPath ( $ path , $ prefix = '' , $ priority = 0 ) { if ( substr ( $ path , - 1 ) !== '/' ) $ path .= '/' ; if ( $ prefix ) { $ name = $ prefix . '|' . $ path ; } else { $ name = $ path ; } self :: $ pathpriorities [ $ name ] = $ priority ; $ position = 0 ; foreach ( self :: $ paths as $ path ) { if ( self :: $ pathpriorities [ $ path ] < $ priority ) { break ; } $ position ++ ; } array_splice ( self :: $ paths , $ position , 0 , array ( $ name ) ) ; }
Add a folder to the template path .
22,633
private static function getFilenames ( $ template , $ all = false ) { $ out = array ( ) ; foreach ( self :: getPaths ( ) as $ v ) { $ split = explode ( '|' , $ v ) ; if ( count ( $ split ) === 2 ) { $ prefix = array_shift ( $ split ) ; $ folder = implode ( '|' , $ split ) ; $ templatefixed = substr ( $ template , 0 , strlen ( $ prefix ) ) ; if ( $ templatefixed == $ prefix ) { $ templaterest = substr ( $ template , strlen ( $ templatefixed ) ) ; if ( is_readable ( $ folder . $ templaterest ) ) { $ out [ ] = $ folder . $ templaterest ; if ( ! $ all ) return $ out ; } } } else { if ( is_readable ( $ v . $ template ) ) { $ out [ ] = $ v . $ template ; if ( ! $ all ) return $ out ; } } } if ( count ( $ out ) > 0 ) { return $ out ; } return false ; }
Return an array of all filenames or FALSE if none are found .
22,634
private function combine ( $ template ) { ob_start ( ) ; foreach ( self :: $ shares as $ k => $ v ) { $ { $ k } = $ v ; } foreach ( $ this -> values as $ k => $ v ) { $ { $ k } = $ v ; } if ( $ ctlbtmpltfiles = $ this -> getFilenames ( $ template , true ) ) { foreach ( $ ctlbtmpltfiles as $ ctlbtmpltfile ) { include $ ctlbtmpltfile ; } } $ val = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ val ; }
Go trough all set template directories and search for a specific template . Concat all of them .
22,635
public function filter ( ) { $ opts = func_get_args ( ) ; $ callable = array_shift ( $ opts ) ; if ( ! is_callable ( $ callable ) ) { return $ this ; } array_unshift ( $ opts , $ this ) ; return call_user_func_array ( $ callable , $ opts ) ; }
Pass current instance to a callable for manipulation and return the processed object
22,636
public function rollback ( $ unitName = "" ) { if ( empty ( $ unitName ) ) $ unitName = PersistenceConfig :: getDefaultUnit ( ) ; $ entityManager = self :: getEntityManager ( $ unitName ) ; $ entityManager -> getConnection ( ) -> rollback ( ) ; }
se realiza el rolback sobre la unidad de persistencia indicada . si no se indica ninguna se toma la default .
22,637
protected function setPath ( $ view ) { $ this -> viewModel = new ViewModel ( [ ] , $ this -> layout -> getName ( ) ) ; if ( $ view == null ) { $ view = $ this -> findView ( ) ; } $ this -> viewModel -> view = $ view ; viewResolver ( ) -> collectDetails ( $ this -> viewModel ) ; $ this -> path = $ view ; }
Get a valid view path save it .
22,638
public function value ( string $ category_key , string $ config_key ) { if ( ! ( $ category = ConfigCategory :: where ( 'key' , $ category_key ) -> first ( ) ) ) { throw new \ Exception ( "Category with name ($category_key) not found" ) ; } if ( ! ( $ config = $ category -> configs ( ) -> where ( 'key' , $ config_key ) -> first ( ) ) ) { throw new \ Exception ( "Config with name ($config_key) not found" ) ; } return $ config -> value ; }
Function for get configuration value
22,639
public function set ( string $ category_key , string $ config_key , string $ value ) { $ config = ConfigCategory :: where ( 'key' , $ category_key ) -> first ( ) -> configs ( ) -> where ( 'key' , $ config_key ) -> first ( ) ; $ config -> value = $ value ; return $ config -> save ( ) ; }
Function for set configuration value .
22,640
public function add ( string $ category_key , array $ configuration ) { $ category = ConfigCategory :: where ( 'key' , $ category_key ) -> first ( ) ; if ( ! $ category ) { throw new \ Exception ( "Category with name ($category_key) not found" ) ; } foreach ( $ configuration as $ config ) { $ this -> checkConfiguration ( $ config ) ; $ config = array_merge ( $ config , [ 'config_category_id' => $ category -> id ] ) ; Model :: create ( $ config ) ; } }
Function for add configuration to project
22,641
public function setLanguage ( $ language ) { if ( ! session_id ( ) ) { if ( $ this -> sessionManager ) { $ this -> sessionManager -> start ( ) ; } } $ _SESSION [ '_fine_I18n_language' ] = $ language ; }
Sets the language to use .
22,642
public function actionIndex ( ) { $ searchModel = Yii :: createObject ( $ this -> getModelClass ( static :: KEY_SEARCH ) ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; return $ this -> render ( $ this -> viewID , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , ] ) ; }
Lists all target models .
22,643
public function actionCreate ( ) { $ model = Yii :: createObject ( $ this -> getModelClass ( ) ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , $ this -> getFlashMsg ( 'success' ) ) ; return $ this -> redirect ( ArrayHelper :: merge ( [ 'view' ] , $ model -> getPrimaryKey ( true ) ) ) ; } else { if ( $ model -> hasErrors ( ) ) { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'error' , $ this -> getFlashMsg ( 'error' ) ) ; } return $ this -> render ( $ this -> viewID , [ 'model' => $ model , ] ) ; } }
Creates a new target model . If creation is successful the browser will be redirected to the view page .
22,644
public function actionUpdate ( ) { $ model = $ this -> findModel ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> save ( ) ) { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , $ this -> getFlashMsg ( 'success' ) ) ; return $ this -> redirect ( ArrayHelper :: merge ( [ 'view' ] , $ model -> getPrimaryKey ( true ) ) ) ; } else { if ( $ model -> hasErrors ( ) ) { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'error' , $ this -> getFlashMsg ( 'error' ) ) ; } return $ this -> render ( $ this -> viewID , [ 'model' => $ model , ] ) ; } }
Updates an existing target model . If update is successful the browser will be redirected to the view page .
22,645
public function actionDelete ( ) { if ( $ this -> findModel ( ) -> delete ( ) ) { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'success' , $ this -> getFlashMsg ( 'success' ) ) ; ; } else { \ Yii :: $ app -> getSession ( ) -> setFlash ( 'error' , $ this -> getFlashMsg ( 'error' ) ) ; } return $ this -> redirect ( [ 'index' ] ) ; }
Deletes an existing target model . If deletion is successful the browser will be redirected to the index page .
22,646
private function patchBackend ( $ bundle ) { $ b = $ this -> validateBundle ( $ bundle ) ; $ this -> patchRouting ( $ b ) ; $ this -> generateCrud ( $ b ) ; }
Add routing for backend
22,647
protected function generateCrud ( AbstractResourceBundle $ bundle ) { $ summary = array ( ) ; $ this -> generateMacrosView ( $ bundle ) ; if ( in_array ( 'index' , $ this -> configuration [ 'actions' ] ) ) { $ this -> generateIndexView ( $ bundle , $ summary ) ; } if ( in_array ( 'show' , $ this -> configuration [ 'actions' ] ) ) { $ this -> generateShowView ( $ bundle , $ summary ) ; } if ( in_array ( 'create' , $ this -> configuration [ 'actions' ] ) ) { $ this -> generateCreateView ( $ bundle , $ summary ) ; } if ( in_array ( 'update' , $ this -> configuration [ 'actions' ] ) ) { $ this -> generateUpdateView ( $ bundle , $ summary ) ; } $ this -> writeOutput ( $ summary ) ; }
Generate CRUD views
22,648
protected function generateIndexView ( AbstractResourceBundle $ bundle , & $ summary ) { $ path = $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/index.html.twig' ; if ( file_exists ( $ path ) ) { $ summary [ ] = '' ; $ summary [ ] = '<bg=red>Index view already exist.</>' ; return ; } $ this -> renderFile ( 'crud/index.html.twig.twig' , $ path , array ( 'bundle' => $ bundle -> getName ( ) , 'model' => $ this -> model , 'prefix' => $ this -> getBundlePrefix ( $ bundle ) , 'vars' => strtolower ( Inflector :: pluralize ( $ this -> model ) ) , 'actions' => array ( 'add' => strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_create' ) ) ) ) ; $ summary [ ] = '' ; $ summary [ ] = '<bg=green>Index view created.</>' ; }
Generate index view
22,649
protected function generateShowView ( AbstractResourceBundle $ bundle , & $ summary ) { $ path = $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/show.html.twig' ; $ entityClass = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getAliasNamespace ( $ this -> bundle -> getName ( ) ) . '\\' . $ this -> model ; $ identifier = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getManager ( ) -> getClassMetadata ( $ entityClass ) -> getIdentifier ( ) ; if ( file_exists ( $ path ) ) { $ summary [ ] = '' ; $ summary [ ] = '<bg=red>Show view already exist.</>' ; return ; } $ this -> renderFile ( 'crud/show.html.twig.twig' , $ path , array ( 'bundle' => $ bundle -> getName ( ) , 'model' => $ this -> model , 'identifier' => $ identifier [ 0 ] , 'prefix' => $ this -> getBundlePrefix ( $ bundle ) , 'cancel' => strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_index' ) , 'actions' => array ( 'edit' => strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_update' ) ) ) ) ; $ summary [ ] = '' ; $ summary [ ] = '<bg=green>Show view created.</>' ; }
Generate show view
22,650
protected function generateCreateView ( AbstractResourceBundle $ bundle , & $ summary ) { $ this -> generateFormView ( $ bundle ) ; $ path = $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/create.html.twig' ; if ( file_exists ( $ path ) ) { $ summary [ ] = '' ; $ summary [ ] = '<bg=red>Create view already exist.</>' ; return ; } $ this -> renderFile ( 'crud/create.html.twig.twig' , $ path , array ( 'bundle' => $ bundle -> getName ( ) , 'model' => $ this -> model , 'prefix' => $ this -> getBundlePrefix ( $ bundle ) , 'action' => strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_create' ) , 'cancel' => strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_index' ) , ) ) ; $ summary [ ] = '' ; $ summary [ ] = '<bg=green>Create view created.</>' ; }
Generate create view
22,651
protected function generateMacrosView ( AbstractResourceBundle $ bundle ) { $ path = $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/macros.html.twig' ; if ( ! file_exists ( $ path ) ) { $ entityClass = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getAliasNamespace ( $ this -> bundle -> getName ( ) ) . '\\' . $ this -> model ; $ metadata = $ this -> getEntityMetadata ( $ entityClass ) ; $ identifier = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getManager ( ) -> getClassMetadata ( $ entityClass ) -> getIdentifier ( ) ; $ actions = array ( ) ; array_map ( function ( $ key ) use ( $ bundle , & $ actions ) { if ( in_array ( $ key , array ( 'show' , 'update' ) ) ) { $ actions [ $ key ] = strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_' . $ key ) ; } } , $ this -> configuration [ 'actions' ] ) ; $ actions [ 'delete' ] = strtolower ( $ this -> getBundlePrefix ( $ bundle ) . '_' . $ this -> model . '_delete' ) ; $ this -> renderFile ( 'crud/macros.html.twig.twig' , $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/macros.html.twig' , array ( 'bundle' => $ bundle -> getName ( ) , 'model' => $ this -> model , 'prefix' => $ this -> getBundlePrefix ( $ bundle ) , 'vars' => strtolower ( Inflector :: pluralize ( $ this -> model ) ) , 'identifier' => $ identifier [ 0 ] , 'fields' => $ this -> getFieldsFromMetadata ( $ metadata [ 0 ] ) , 'actions' => $ actions ) ) ; } }
Generate macros view
22,652
protected function generateFormView ( AbstractResourceBundle $ bundle ) { $ path = $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/_form.html.twig' ; if ( ! file_exists ( $ path ) ) { $ entityClass = $ this -> getContainer ( ) -> get ( 'doctrine' ) -> getAliasNamespace ( $ this -> bundle -> getName ( ) ) . '\\' . $ this -> model ; $ metadata = $ this -> getEntityMetadata ( $ entityClass ) ; $ this -> renderFile ( 'crud/_form.html.twig.twig' , $ bundle -> getPath ( ) . '/Resources/views/' . $ this -> model . '/_form.html.twig' , array ( 'fields' => $ this -> getFieldsFromMetadata ( $ metadata [ 0 ] ) , ) ) ; } }
Generate form view
22,653
public function includeFunc ( View $ view ) { if ( $ this -> isFunc ( ) ) { Helper :: includeFile ( $ this -> getFuncFilePath ( ) , [ "view" => $ view ] , false , true ) ; } return $ this ; }
Include function file .
22,654
protected function _normalizeWritableContainer ( $ container ) { $ container = $ this -> _normalizeContainer ( $ container ) ; if ( $ container instanceof BaseContainerInterface ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Invalid container' ) , null , null , $ container ) ; } return $ container ; }
Normalizes a writable container .
22,655
public function acquireAccessToken ( ) { $ request = new Request ( self :: METADATA_AUTH_URL , 'GET' , array ( 'Metadata-Flavor' => 'Google' ) ) ; $ request -> disableGzip ( ) ; $ response = $ this -> client -> getIo ( ) -> makeRequest ( $ request ) ; if ( $ response -> getResponseHttpCode ( ) == 200 ) { $ this -> setAccessToken ( $ response -> getResponseBody ( ) ) ; $ this -> token [ 'created' ] = time ( ) ; return $ this -> getAccessToken ( ) ; } else { throw new Exception ( sprintf ( "Error fetching service account access token, message: '%s'" , $ response -> getResponseBody ( ) ) , $ response -> getResponseHttpCode ( ) ) ; } }
Acquires a new access token from the compute engine metadata server .
22,656
public final function parse ( $ param_str ) { $ params = explode ( "," , $ param_str ) ; foreach ( $ params as $ param_item ) { $ param_kv = explode ( "=" , $ param_item ) ; $ param_key = trim ( $ param_kv [ 0 ] ) ; $ param_value = trim ( $ param_kv [ 1 ] ) ; if ( '"' === substr ( $ param_key , 0 , 1 ) && '"' === substr ( $ param_key , - 1 , 1 ) ) { $ param_key = substr ( $ param_key , 1 , strlen ( $ param_key ) - 2 ) ; } if ( '"' === substr ( $ param_value , 0 , 1 ) && '"' === substr ( $ param_value , - 1 , 1 ) ) { if ( property_exists ( $ this , $ param_key ) ) { $ this -> $ param_key = substr ( $ param_value , 1 , strlen ( $ param_value ) - 2 ) ; } else { } } } }
wait for the end of the compiling and then exec this function .
22,657
public function onDispatchError ( MvcEvent $ event ) { $ exception = $ event -> getParam ( 'exception' ) ; if ( $ exception && $ exception instanceof Exception ) { $ this -> exceptionHandler ( $ exception , false ) ; } if ( $ this -> response ) { $ event -> stopPropagation ( ) ; return $ this -> response ; } }
Listen to the dispatch . error event
22,658
public function onDispatch ( MvcEvent $ event ) { if ( $ this -> response ) { $ event -> stopPropagation ( ) ; return $ this -> response ; } $ routeMatch = $ event -> getRouteMatch ( ) ; $ sm = $ event -> getApplication ( ) -> getServiceManager ( ) ; $ sm -> get ( 'Timezone' ) ; if ( $ routeMatch ) { $ locale = $ routeMatch -> getParam ( 'locale' ) ; } if ( ! $ locale ) { $ request = $ event -> getRequest ( ) ; if ( $ request instanceof HttpRequest ) { $ header = $ request -> getHeader ( 'Accept-Language' ) ; if ( $ header ) { $ availables = null ; $ controller = $ event -> getController ( ) ; if ( $ controller instanceof LocaleSelectorInterface ) { $ availables = $ controller -> getAvailableLocales ( ) ; } $ locale = $ sm -> get ( 'Locale' ) -> acceptFromHttp ( $ header -> getFieldValue ( ) , $ availables ) ; } } } if ( $ locale ) { $ sm -> get ( 'Locale' ) -> setCurrent ( $ locale ) ; } }
General dispatch listener
22,659
public function getViewWidgetViewHelper ( ) { $ config = $ this -> serviceLocator -> get ( 'Config' ) ; return View \ Helper \ ViewWidget :: factory ( $ this -> serviceLocator , empty ( $ config [ 'view_widgets' ] ) ? array ( ) : $ config [ 'view_widgets' ] ) ; }
Get viewWidget view - helper instance
22,660
public function current ( ) { if ( ! $ this -> valid ( ) ) { return null ; } $ index = $ this -> index ; $ front = $ this -> front ; $ cap = $ this -> cap ; $ offset = ( $ index + $ front ) % $ cap ; return $ this -> items [ $ offset ] ; }
Retrieves the current item
22,661
public function sendEmails ( $ listID , $ data ) { if ( ! $ this -> helpers -> isListEnabled ( $ listID ) ) { return false ; } $ emailData = [ ] ; $ emailData [ 'subject' ] = $ this -> helpers -> getListNameFromListID ( $ listID ) . ' - ' . $ data [ 'title' ] ; $ emailIDs = $ this -> helpers -> getEnabledEmailsFromList ( $ listID ) ; if ( count ( $ emailIDs ) == 0 ) { return false ; } $ data [ 'link' ] = '<a href="' ; $ data [ 'link' ] .= $ data [ 'canonical_url' ] ; $ data [ 'link' ] .= '">' ; $ data [ 'link' ] .= $ data [ 'title' ] ; $ data [ 'link' ] .= '</a>' ; foreach ( $ emailIDs as $ emailID ) { if ( ! $ this -> helpers -> isEmailAddressPrimaryType ( $ emailID -> email_id ) ) { continue ; } $ unsubscribeToken = $ this -> createUnsubscribeToken -> createUniqueToken ( ) ; $ this -> createUnsubscribeToken -> createTokenRecord ( $ listID , $ emailID -> email_id , $ unsubscribeToken ) ; $ data [ 'unsubscribe_link' ] = $ this -> createUnsubscribeToken -> unsubscribeURL ( $ unsubscribeToken ) ; $ emailData [ 'to_email' ] = $ this -> helpers -> getEmailAddressFromEmailID ( $ emailID -> email_id ) ; $ emailData [ 'to_name' ] = $ this -> helpers -> getFirstnameSurnameFromEmailID ( $ emailID -> email_id ) ; $ data [ 'to_email' ] = $ emailData [ 'to_email' ] ; $ data [ 'to_name' ] = $ emailData [ 'to_name' ] ; Mail :: queue ( 'lasallecrmlistmanagement::emails.send_email_from_list' , [ 'data' => $ data ] , function ( $ message ) use ( $ emailData ) { $ message -> from ( Config :: get ( 'lasallecmscontact.from_email' ) , Config :: get ( 'lasallecmscontact.from_name' ) ) ; $ message -> to ( $ emailData [ 'to_email' ] , $ emailData [ 'to_name' ] ) ; $ message -> subject ( $ emailData [ 'subject' ] ) ; } ) ; } return true ; }
Send emails from a list .
22,662
public function getPhotoSourceFile ( ) { $ objectManager = \ TYPO3 \ CMS \ Core \ Utility \ GeneralUtility :: makeInstance ( \ TYPO3 \ CMS \ Extbase \ Object \ ObjectManager :: class ) ; return $ objectManager -> get ( \ RGU \ Dvoconnector \ Service \ ImageService :: class ) -> getCachedFile ( $ this -> getPhotoSource ( ) ) ; }
returns the photoSource as File
22,663
public function getEntitiesAttribute ( ) { return DB :: table ( config ( 'rinvex.attributable.tables.attribute_entity' ) ) -> where ( 'attribute_id' , $ this -> getKey ( ) ) -> get ( ) -> pluck ( 'entity_type' ) -> toArray ( ) ; }
Get the entities attached to this attribute .
22,664
protected function outputLine ( $ text = '' , array $ arguments = [ ] , $ status = self :: RESET ) { $ text = $ status . $ text . static :: RESET ; return parent :: outputLine ( $ text , $ arguments ) ; }
Overwrite default outputLine to provide third parameter that will color the provided text .
22,665
private function error ( ) : void { $ code = socket_last_error ( $ this -> socket ) ; $ msg = socket_strerror ( $ code ) ; throw new \ RuntimeException ( $ msg , $ code ) ; }
Compose RuntimeException from socket error and throws it .
22,666
private function connect ( ) : void { socket_connect ( $ this -> socket , $ this -> host , $ this -> port ) or $ this -> error ( ) ; }
Connect socket to server .
22,667
private function send ( string $ data ) : void { socket_write ( $ this -> socket , $ data , strlen ( $ data ) ) or $ this -> error ( ) ; }
Send raw data to socket .
22,668
protected function sendRequest ( Request $ request ) : Response { if ( $ this -> password !== null ) { $ request -> authenticate ( $ this -> password ) ; } $ this -> send ( ( string ) $ request ) ; $ response = new Response ( $ this -> get ( ) ) ; return $ response ; }
Send SNP Request message to server .
22,669
public function notify ( NotifyRequest $ notification ) : Response { if ( $ this -> appID !== null ) { $ notification -> setApplicationIdentification ( $ this -> appID ) ; } $ response = $ this -> sendRequest ( $ notification ) ; return $ response ; }
Send SNP Notify Request message to server .
22,670
public function register ( RegisterRequest $ application ) : Response { $ response = $ this -> sendRequest ( $ application ) ; $ this -> appID = $ application -> getApplicationIdentification ( ) ; return $ response ; }
Send SNP Register Request message to server .
22,671
protected function moveFile ( ) { $ this -> getFile ( ) -> move ( $ this -> getUploadRootDir ( ) , $ this -> path ) ; $ this -> setFile ( null ) ; }
Move file to its final location
22,672
protected function loadConfig ( $ environment = null , $ configLocation = null ) { $ aggregator = new ConfigAggregator ( [ new ZendConfigProvider ( realpath ( $ configLocation . '/' ) . '/' . $ environment . '.{json,xml,ini}' ) , ] ) ; return $ aggregator -> getMergedConfig ( ) ; }
Load config and return as an array .
22,673
protected function _buildValidator ( Validator $ validator ) { $ validator -> provider ( 'googleRecaptcha' , 'Wasabi\Core\Model\Validation\GoogleRecaptchaValidationProvider' ) ; return $ validator -> notEmpty ( 'name' , __d ( 'wasabi_core' , 'Please enter your name.' ) ) -> notEmpty ( 'email' , __d ( 'wasabi_core' , 'Please enter your email address.' ) ) -> add ( 'email' , 'email' , [ 'rule' => 'email' , 'message' => __d ( 'wasabi_core' , 'Please enter a valid email address.' ) ] ) -> notEmpty ( 'subject' , __d ( 'wasabi_core' , 'Please enter a subject for your contact request.' ) ) -> notEmpty ( 'message' , __d ( 'wasabi_core' , 'Please provide a message for your contact request.' ) ) -> notEmpty ( 'g-recaptcha-response' , __d ( 'wasabi_core' , 'Please confirm you are human.' ) ) -> add ( 'g-recaptcha-response' , 'googleRecaptcha' , [ 'rule' => 'googleRecaptcha' , 'message' => __d ( 'wasabi_core' , 'Please confirm you are human.' ) , 'provider' => 'googleRecaptcha' ] ) ; }
Validation rules for the submitted fields of this form .
22,674
public static function Apci ( $ date1 , $ date2 , array $ ebpv , array $ ehp , $ x , $ y , $ s , iauASTROM & $ astrom ) { IAU :: Apcg ( $ date1 , $ date2 , $ ebpv , $ ehp , $ astrom ) ; IAU :: C2ixys ( $ x , $ y , $ s , $ astrom -> bpn ) ; }
- - - - - - - - i a u A p c i - - - - - - - -
22,675
public function stampedeProtect ( EventInterface $ event ) { $ pool = $ event -> getTarget ( ) ; $ item = $ event -> getParam ( 'item' ) ; if ( $ item instanceof CacheItemExtendedInterface ) { $ left = $ item -> getExpiration ( ) -> getTimestamp ( ) - time ( ) ; if ( $ left < $ this -> time_left && rand ( 1 , 1000 ) <= $ this -> probability ) { return $ pool -> setError ( Message :: get ( Message :: CACHE_EXT_STAMPEDE , $ item -> getKey ( ) ) , Message :: CACHE_EXT_STAMPEDE ) ; } } return true ; }
Change hit status if ...
22,676
public static function invoke ( ValidationResultFields $ validationResultFields , ValidationResultFields $ validationResultFieldsMore ) : ValidationResultFields { $ code = '' ; if ( ! $ validationResultFields -> isValid ( ) ) { $ code = $ validationResultFields -> getCode ( ) ; } if ( ! $ validationResultFieldsMore -> isValid ( ) ) { $ code = $ validationResultFieldsMore -> getCode ( ) ; } $ isValid = ( $ validationResultFields -> isValid ( ) && $ validationResultFieldsMore -> isValid ( ) ) ; $ details = array_merge ( $ validationResultFields -> getDetails ( ) , $ validationResultFieldsMore -> getDetails ( ) ) ; $ mergedFieldResults = array_merge ( $ validationResultFields -> getFieldResults ( ) , $ validationResultFieldsMore -> getFieldResults ( ) ) ; return new ValidationResultFieldsBasic ( $ isValid , $ code , $ details , $ mergedFieldResults ) ; }
Second ValidationResultFields will over - ride the first
22,677
public function getXPath ( ) { if ( ! isset ( $ this -> xpath ) ) { $ this -> xpath = new DOMXPath ( $ this ) ; if ( $ this -> documentElement -> namespaceURI <> '' ) $ this -> xpath -> registerNamespace ( 'default' , $ this -> documentElement -> namespaceURI ) ; } return $ this -> xpath ; }
Get DOMXPath for this Document
22,678
private function getNamespaces ( ) { $ this -> namespaces = array ( ) ; $ nodeList = $ this -> documentElement -> getElementsByTagName ( '*' ) ; foreach ( $ nodeList as $ node ) { if ( strlen ( $ node -> prefix ) && strlen ( $ node -> namespaceURI ) && ! in_array ( $ node -> prefix , $ this -> namespaces ) ) $ this -> namespaces [ $ node -> prefix ] = $ node -> namespaceURI ; } return $ this -> namespaces ; }
Get the list of namespaces of this Document
22,679
public function setTitle ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'title' ] = $ value ; } else { unset ( $ this -> _params [ 'title' ] ) ; } return $ this ; }
Sets the title attribute for this query .
22,680
public function setTitleExact ( $ value ) { if ( $ value != null ) { $ this -> _params [ 'title-exact' ] = $ value ; } else { unset ( $ this -> _params [ 'title-exact' ] ) ; } return $ this ; }
Sets the title - exact attribute for this query .
22,681
public function append ( ) { $ script = $ this -> parseArgs ( func_get_args ( ) ) ; if ( $ script !== false && ! in_array ( $ script , $ this -> members ) ) array_push ( $ this -> members , $ script ) ; }
Add the passed value to the end of the collection
22,682
public function prepend ( ) { $ script = $ this -> parseArgs ( func_get_args ( ) ) ; if ( $ script !== false && ! in_array ( $ script , $ this -> members ) ) array_unshift ( $ this -> members , $ script ) ; }
Add the passed value to the beginning of the collection
22,683
private function parseArgs ( array $ args ) : string { if ( ! is_array ( $ args ) ) return false ; $ components = array ( ) ; if ( count ( $ args ) == 1 && is_string ( $ args [ 0 ] ) ) { $ components [ 'src' ] = $ args [ 0 ] ; return $ this -> makeLink ( $ components ) ; } elseif ( count ( $ args ) == 1 && is_array ( $ args ) ) { $ components = $ args [ 0 ] ; return $ this -> makeLink ( $ components ) ; } elseif ( count ( $ args ) == 2 && is_string ( $ args [ 0 ] ) && is_array ( $ args [ 1 ] ) ) { $ args [ 1 ] [ 'src' ] = $ args [ 0 ] ; $ components = $ args [ 1 ] ; return $ this -> makeLink ( $ components ) ; } elseif ( count ( $ args ) == 2 && is_string ( $ args [ 0 ] ) && is_string ( $ args [ 1 ] ) ) { return '<script type="' . $ args [ 1 ] . '">' . "\n" . $ args [ 0 ] . "\n</script>\n" ; } Core :: i ( ) -> log -> warning ( 'Unable to interpret script. Not added.' ) ; return false ; }
Builds the tag based on the passed info .
22,684
public static function fatorVencimento ( $ vencimento ) { if ( ( $ vencimento === null ) || ( $ vencimento === '' ) ) { return 0 ; } $ base = Carbon :: createFromFormat ( 'd.m.Y' , '07.10.1997' ) ; if ( ! ( $ vencimento instanceof \ DateTime ) ) { $ vencimento = Carbon :: createFromTimestamp ( $ vencimento ) ; } return $ base -> diffInDays ( ) - $ vencimento -> diffInDays ( ) ; }
Retorna o fator de vencimento .
22,685
public static function dataPeloFator ( $ fator ) { $ fator = intval ( $ fator ) ; $ base = Carbon :: createFromFormat ( 'd.m.Y' , '07.10.1997' ) ; return $ base -> addDays ( $ fator ) ; }
Retorna a data pelo fator de vencimento .
22,686
public static function valorPeloFator ( $ fator , $ dec = 2 ) { $ div = pow ( 10 , $ dec ) ; $ base = intval ( round ( $ fator , 0 ) ) ; return $ base / $ div ; }
Retorna o valor pelo fator de valor .
22,687
protected static function initAttributeSet ( ) { $ className = get_called_class ( ) ; if ( ! ModelAttributes :: attributesSetFor ( $ className ) ) { ModelAttributes :: setClassAttributes ( $ className , static :: attributeSet ( ) ) ; } }
This method may be overridden to actually set the attribues .
22,688
public static function factory ( $ config = [ ] ) { $ default = [ 'url' => 'https://syrup.keboola.com/gooddata-writer' ] ; $ required = [ 'token' ] ; $ config = Collection :: fromConfig ( $ config , $ default , $ required ) ; $ config [ 'request.options' ] = [ 'headers' => [ 'X-StorageApi-Token' => $ config -> get ( 'token' ) ] , 'config' => [ 'curl' => [ CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_0 ] ] ] ; $ client = new self ( $ config -> get ( 'url' ) , $ config ) ; $ description = ServiceDescription :: factory ( __DIR__ . '/service.json' ) ; $ client -> setDescription ( $ description ) ; $ client -> setBaseUrl ( $ config -> get ( 'url' ) ) ; $ backoffPlugin = new BackoffPlugin ( new TruncatedBackoffStrategy ( 5 , new HttpBackoffStrategy ( null , new CurlBackoffStrategy ( null , new ExponentialBackoffStrategy ( ) ) ) ) ) ; $ client -> addSubscriber ( $ backoffPlugin ) ; return $ client ; }
Factory method to create a new Client
22,689
public function createWriter ( $ writerId , $ params = [ ] ) { $ job = $ this -> createWriterAsync ( $ writerId , $ params ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Create writer job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; }
Create writer and wait for finish
22,690
public function createWriterWithProjectAsync ( $ writerId , $ pid , $ username , $ password , $ params = [ ] ) { $ params [ 'writerId' ] = $ writerId ; $ params [ 'pid' ] = $ pid ; $ params [ 'username' ] = $ username ; $ params [ 'password' ] = $ password ; return $ this -> getCommand ( 'CreateWriterWithProject' , $ params ) -> execute ( ) ; }
Create writer with existing GoodData project
22,691
public function createWriterWithProject ( $ writerId , $ pid , $ username , $ password , $ params = [ ] ) { $ job = $ this -> createWriterWithProjectAsync ( $ writerId , $ pid , $ username , $ password , $ params ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Create writer job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; }
Create writer with existing GoodData project and wait for finish
22,692
public function createUserAsync ( $ writerId , $ email , $ password , $ firstName , $ lastName , $ queue = 'primary' ) { return $ this -> getCommand ( 'CreateUser' , [ 'writerId' => $ writerId , 'email' => $ email , 'password' => $ password , 'firstName' => $ firstName , 'lastName' => $ lastName , 'queue' => $ queue ] ) -> execute ( ) ; }
Create user and don t wait for end of the job
22,693
public function createUser ( $ writerId , $ email , $ password , $ firstName , $ lastName , $ queue = 'primary' ) { $ job = $ this -> createUserAsync ( $ writerId , $ email , $ password , $ firstName , $ lastName , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Create user job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } $ result = $ this -> waitForJob ( $ job [ 'url' ] ) ; if ( ! isset ( $ result [ 'result' ] [ 0 ] [ 'uid' ] ) ) { throw new ServerException ( 'Job info for create user returned unexpected result: ' . json_encode ( $ result , JSON_PRETTY_PRINT ) ) ; } return [ 'uid' => $ result [ 'result' ] [ 0 ] [ 'uid' ] ] ; }
Create user and wait for finish returns user s uid
22,694
public function createProject ( $ writerId , $ name = null , $ accessToken = null , $ queue = 'primary' ) { $ job = $ this -> createProjectAsync ( $ writerId , $ name , $ accessToken , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Create project job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } $ result = $ this -> waitForJob ( $ job [ 'url' ] ) ; if ( ! isset ( $ result [ 'result' ] [ 0 ] [ 'pid' ] ) ) { throw new ServerException ( 'Job info for create project returned unexpected result: ' . json_encode ( $ result , JSON_PRETTY_PRINT ) ) ; } return [ 'pid' => $ result [ 'result' ] [ 0 ] [ 'pid' ] ] ; }
Create project and wait for finish return project s pid
22,695
public function getProjectUsers ( $ writerId , $ pid ) { $ result = $ this -> getCommand ( 'getProjectUsers' , [ 'writerId' => $ writerId , 'pid' => $ pid ] ) -> execute ( ) ; return $ result [ 'users' ] ; }
Get list of projects users
22,696
public function addUserToProjectAsync ( $ writerId , $ pid , $ email , $ role = 'editor' , $ queue = 'primary' ) { return $ this -> getCommand ( 'AddUserToProject' , [ 'writerId' => $ writerId , 'pid' => $ pid , 'email' => $ email , 'role' => $ role , 'queue' => $ queue ] ) -> execute ( ) ; }
Add user to project
22,697
public function addUserToProject ( $ writerId , $ pid , $ email , $ role = 'editor' , $ queue = 'primary' ) { $ job = $ this -> addUserToProjectAsync ( $ writerId , $ pid , $ email , $ role , $ queue ) ; if ( ! isset ( $ job [ 'url' ] ) ) { throw new ServerException ( 'Create project job returned unexpected result: ' . json_encode ( $ job , JSON_PRETTY_PRINT ) ) ; } return $ this -> waitForJob ( $ job [ 'url' ] ) ; }
Add user to project and wait for finish
22,698
public function getSsoLink ( $ writerId , $ pid , $ email ) { $ result = $ this -> getCommand ( 'GetSSOLink' , [ 'writerId' => $ writerId , 'pid' => $ pid , 'email' => $ email ] ) -> execute ( ) ; if ( ! isset ( $ result [ 'ssoLink' ] ) ) { throw new ClientException ( 'Getting SSO link failed. ' . ( isset ( $ result [ 'error' ] ) ? $ result [ 'error' ] : '' ) ) ; } return $ result [ 'ssoLink' ] ; }
Generate SSO link for configured project and user
22,699
public function updateTable ( $ writerId , $ tableId , $ title = null , $ export = null , $ incrementalLoad = null , $ ignoreFilter = null ) { $ params = [ 'writerId' => $ writerId , 'tableId' => $ tableId ] ; if ( $ title !== null ) { $ params [ 'title' ] = $ title ; } if ( $ export !== null ) { $ params [ 'export' ] = ( bool ) $ export ; } if ( $ incrementalLoad !== null ) { $ params [ 'incrementalLoad' ] = ( bool ) $ incrementalLoad ; } if ( $ ignoreFilter !== null ) { $ params [ 'ignoreFilter' ] = ( bool ) $ ignoreFilter ; } return $ this -> getCommand ( 'UpdateTable' , $ params ) -> execute ( ) ; }
Update table configuration