idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
2,500
public function offset ( $ offset = null ) { if ( is_null ( $ offset ) ) return $ this -> discard ( 'query.offset' ) ; return $ this -> merge ( [ 'query.offset' => intval ( $ offset ) ] ) ; }
Sets rows offset
2,501
public function attrs ( $ attrs ) { if ( is_array ( $ attrs ) && ! empty ( $ attrs ) ) return $ this -> merge ( [ 'query.attrs' => $ attrs ] ) ; else return $ this -> merge ( [ 'query.attrs' => func_get_args ( ) ] ) ; }
Sets the attributes to fetch
2,502
public function findByPk ( $ pk ) { $ this -> mapper -> connect ( ) ; $ query = $ this -> mapper -> newQuery ( ) -> from ( $ this -> entityProfile -> getEntityTable ( ) ) -> select ( $ this -> getSelectColumns ( ) ) -> where ( Column :: __callstatic ( $ this -> entityProfile -> getPrimaryKey ( true ) ) -> eq ( $ pk ) ) ; list ( $ sql , $ args ) = $ query -> build ( ) ; return $ this -> mapper -> merge ( $ this -> clean ( [ 'map.type' => $ this -> buildExpression ( $ this -> entityProfile ) ] ) ) -> execute ( $ sql , $ args ) ; }
Obtains an entity by primary key
2,503
public function find ( SQLPredicate $ condition = null ) { $ this -> mapper -> connect ( ) ; $ table = $ this -> entityProfile -> getEntityTable ( ) ; $ query = $ this -> mapper -> newQuery ( $ this -> entityProfile ) -> from ( $ table , Schema :: DEFAULT_ALIAS ) -> select ( $ this -> getSelectColumns ( ) ) ; $ args = func_get_args ( ) ; if ( empty ( $ args ) && $ this -> hasOption ( 'query.filter' ) ) $ query -> where ( $ this -> getFilter ( ) ) ; elseif ( isset ( $ condition ) ) $ query -> where ( new Filter ( $ args ) ) ; if ( $ this -> hasOption ( 'query.orderBy' ) ) $ query -> orderBy ( $ this -> getOrderBy ( ) ) ; if ( $ this -> hasOption ( 'query.limit' ) ) $ query -> limit ( $ this -> getOption ( 'query.limit' ) ) ; if ( $ this -> hasOption ( 'query.offset' ) ) $ query -> offset ( $ this -> getOption ( 'query.offset' ) ) ; if ( $ this -> hasOption ( 'query.distinct' ) && $ this -> getOption ( 'query.distinct' ) ) $ query -> distinct ( ) ; list ( $ sql , $ args ) = $ query -> build ( ) ; return $ this -> mapper -> merge ( $ this -> clean ( [ 'map.type' => $ this -> getListMappingExpression ( ) ] ) ) -> execute ( $ sql , $ args ) ; }
Finds a list of entities by a given criteria
2,504
public function delete ( $ entity ) { if ( is_null ( $ entity ) ) return ; $ this -> mapper -> connect ( ) ; $ this -> mapper -> beginTransaction ( ) ; $ pk = $ this -> getPropertyValue ( $ this -> entityProfile , $ entity , $ this -> entityProfile -> getPrimaryKey ( ) ) ; foreach ( $ this -> entityProfile -> getReferences ( ) as $ assoc ) $ this -> entityProfile -> getAssociation ( $ assoc ) -> delete ( $ this -> mapper , $ pk ) ; $ query = $ this -> mapper -> newQuery ( ) -> deleteFrom ( $ this -> entityProfile -> getEntityTable ( ) ) -> where ( Column :: __callstatic ( $ this -> entityProfile -> getPrimaryKey ( true ) ) -> eq ( $ pk ) ) ; $ result = $ query -> exec ( ) ; $ this -> mapper -> commit ( ) ; return $ result ; }
Removes given entity from database
2,505
public function deleteWhere ( SQLPredicate $ condition = null , $ cascade = false ) { $ this -> mapper -> connect ( ) ; $ this -> mapper -> beginTransaction ( ) ; if ( $ cascade ) { $ list = $ this -> find ( $ condition ) ; foreach ( $ list as $ entity ) $ this -> delete ( $ entity ) ; $ result = true ; } else { $ query = $ this -> mapper -> newQuery ( $ this -> entityProfile ) -> deleteFrom ( $ this -> entityProfile -> getEntityTable ( ) ) -> where ( $ condition ) ; $ result = $ query -> exec ( ) ; } $ this -> mapper -> commit ( ) ; return $ result ; }
Removes a set of entities by a given condition
2,506
public function truncate ( ) { $ this -> mapper -> connect ( ) ; $ this -> mapper -> beginTransaction ( ) ; $ query = $ this -> mapper -> newQuery ( ) -> deleteFrom ( $ this -> entityProfile -> getEntityTable ( ) ) ; $ result = $ query -> exec ( ) ; $ this -> mapper -> commit ( ) ; return $ result ; }
Truncates a table
2,507
protected function sqlFunction ( SQLFunction $ function ) { $ this -> mapper -> connect ( ) ; $ query = $ this -> mapper -> newQuery ( $ this -> entityProfile ) -> from ( $ this -> entityProfile -> getEntityTable ( ) , Schema :: DEFAULT_ALIAS ) -> select ( $ function -> getFunctionInstance ( ) ) ; if ( $ this -> hasOption ( 'query.filter' ) ) $ query -> where ( $ this -> getFilter ( ) ) ; list ( $ sql , $ args ) = $ query -> build ( ) ; return $ this -> mapper -> merge ( $ this -> clean ( [ 'map.type' => $ function -> getDefaultType ( ) ] ) ) -> execute ( $ sql , $ args ) ; }
Invokes an aggregate function
2,508
public function install ( PackageWrapper $ package , $ isDev ) { $ args = [ 'install' ] ; if ( ! $ isDev ) { $ args [ ] = '--production' ; } $ this -> execute ( 'npm' , $ args , $ this -> io , $ package -> getPath ( ) ) ; }
Run this installer for the package
2,509
private function validateRegex ( ) : bool { $ isValid = \ preg_match ( $ this -> options [ 'pattern' ] , $ this -> value ) ? true : false ; if ( ! $ isValid ) { $ this -> setError ( self :: VALIDATOR_ERROR_REGEX_PATTERN_NOT_MATCH ) ; } return $ isValid ; }
Checks whether string is valid against regex pattern
2,510
public function findBy ( array $ criteria , array $ order = null , $ limit = null , $ offset = null ) { return $ this -> getRepository ( ) -> findBy ( $ criteria , $ order , $ limit , $ offset ) ; }
Returns entities according to criteria .
2,511
private static function preprocessJsonPayload ( $ payload ) { $ requests = [ ] ; $ is_batch = false ; if ( is_array ( $ payload ) ) { $ is_batch = true ; foreach ( $ payload as $ request ) $ requests [ ] = self :: preprocessJsonRequest ( $ request ) ; } else { $ requests [ ] = self :: preprocessJsonRequest ( $ payload ) ; } return array ( $ is_batch , $ requests ) ; }
Preprocess json payload
2,512
private static function preprocessJsonRequest ( $ request ) { if ( ! is_object ( $ request ) || ! property_exists ( $ request , 'jsonrpc' ) || ! property_exists ( $ request , 'method' ) || $ request -> jsonrpc != '2.0' || empty ( $ request -> method ) ) { return array ( 'ERROR_CODE' => - 32600 , 'ERROR_MESSAGE' => 'Invalid Request' , 'ID' => ! isset ( $ request [ 'id' ] ) ? null : $ request [ 'id' ] ) ; } return array ( 'METHOD' => $ request -> method , 'PARAMETERS' => property_exists ( $ request , 'params' ) ? $ request -> params : [ ] , 'ID' => property_exists ( $ request , 'id' ) ? $ request -> id : null ) ; }
Preprocess a single json request
2,513
private function runSingleRequest ( $ request_method , $ parameters ) { try { $ registered_method = $ this -> checkRequestSustainability ( $ request_method ) ; $ selected_signature = $ this -> checkRequestConsistence ( $ registered_method , $ parameters ) ; if ( is_array ( $ parameters ) ) $ parameters = self :: matchParameters ( $ parameters , $ registered_method , $ selected_signature ) ; $ this -> parameters -> setParameters ( $ parameters ) ; $ callback = $ registered_method -> getCallback ( ) ; $ attributes = $ registered_method -> getArguments ( ) ; array_unshift ( $ attributes , $ this -> parameters ) ; } catch ( RpcException $ re ) { throw $ re ; } set_error_handler ( function ( $ severity , $ message , $ file , $ line ) { $ this -> logger -> error ( $ message , array ( "FILE" => $ file , "LINE" => $ line ) ) ; throw new RpcException ( 'Internal error' , - 32603 ) ; } ) ; try { $ return = call_user_func_array ( $ callback , $ attributes ) ; } catch ( RpcException $ re ) { restore_error_handler ( ) ; throw $ re ; } catch ( Exception $ e ) { restore_error_handler ( ) ; $ this -> logger -> error ( $ e -> getMessage ( ) , array ( "FILE" => $ e -> getFile ( ) , "LINE" => $ e -> getLine ( ) ) ) ; throw new RpcException ( 'Internal error' , - 32603 ) ; } restore_error_handler ( ) ; return $ return ; }
Exec a single request
2,514
private static function packJsonError ( $ code , $ message , $ id ) { if ( ! is_null ( $ id ) ) { return array ( 'jsonrpc' => '2.0' , 'error' => array ( 'code' => $ code , 'message' => $ message ) , 'id' => $ id ) ; } else { return null ; } }
Pack a json error response
2,515
private static function checkSignatureMatch ( $ provided , $ requested ) { if ( is_object ( $ provided ) ) { foreach ( $ provided as $ parameter => $ value ) { if ( ! isset ( $ requested [ $ parameter ] ) || ! Validator :: validate ( $ value , $ requested [ $ parameter ] ) ) return false ; } } else { $ provided_parameters_count = count ( $ provided ) ; $ requested_parameters_count = count ( $ requested ) ; if ( $ provided_parameters_count != $ requested_parameters_count ) return false ; $ index = 0 ; foreach ( $ requested as $ parameter => $ type ) { if ( ! Validator :: validate ( $ provided [ $ index ] , $ type ) ) return false ; $ index += 1 ; } } return true ; }
Check if call match a signature
2,516
public function write ( $ content = '' ) { if ( $ this -> rotate ( ) ) { if ( empty ( $ this -> file_mtime ) && file_exists ( $ this -> file_path ) ) { $ this -> file_mtime = filemtime ( $ this -> file_path ) ; } $ f = @ fopen ( $ this -> file_path , "ab" ) ; if ( $ f ) { fputs ( $ f , str_replace ( '<' , '&lt;' , $ content ) ) ; fclose ( $ f ) ; $ this -> file_mtime = filemtime ( $ this -> file_path ) ; return true ; } else { throw new \ RuntimeException ( sprintf ( 'Can not write in file "%s"!' , $ this -> file_path ) ) ; } } else { throw new \ RuntimeException ( sprintf ( 'Can not write and/or rotate file "%s"!' , $ this -> file_path ) ) ; } }
Write a string in the file
2,517
public function rotate ( $ force = false ) { $ rotator = $ this -> options [ 'backup_time' ] ; if ( true === $ force || $ this -> mustRotate ( ) ) { $ dir = dirname ( $ this -> file_path ) ; $ old_file = $ this -> getFilename ( basename ( $ this -> file_path ) , $ rotator ) ; if ( file_exists ( $ dir . '/' . $ old_file ) ) { @ unlink ( $ dir . '/' . $ old_file ) ; } if ( false !== strpos ( $ this -> flag , $ this -> options [ 'filename_iterator_tag' ] ) ) { while ( $ rotator -- > 0 ) { $ original_file = $ this -> getFilename ( basename ( $ this -> file_path ) , $ rotator ) ; if ( file_exists ( $ dir . '/' . $ original_file ) ) { $ target_file = $ this -> getFilename ( basename ( $ this -> file_path ) , ( $ rotator + 1 ) ) ; $ ok = @ rename ( $ dir . '/' . $ original_file , $ dir . '/' . $ target_file ) ; } } } else { $ target_file = $ this -> getFilename ( basename ( $ this -> file_path ) , 1 ) ; $ ok = @ rename ( $ this -> file_path , $ dir . '/' . $ target_file ) ; } return $ ok ; } return true ; }
Rotate file if so
2,518
public function mustRotate ( ) { if ( ! file_exists ( $ this -> file_path ) ) return false ; if ( $ this -> flag & self :: ROTATE_FILESIZE ) { $ s = @ filesize ( $ this -> file_path ) ; return ( bool ) ( @ is_readable ( $ this -> file_path ) && $ s > $ this -> options [ 'max_filesize' ] * 1024 ) ; } else { if ( empty ( $ this -> file_mtime ) ) { $ this -> file_mtime = filemtime ( $ this -> file_path ) ; } $ now = date ( 'ymdHis' , ( time ( ) - $ this -> options [ 'period_duration' ] ) ) ; return ( bool ) ( @ is_readable ( $ this -> file_path ) && date ( 'ymdHis' , $ this -> file_mtime ) <= $ now ) ; } }
Does the current file need to be rotated
2,519
public function getFilename ( $ file_name , $ rotation_index = 0 ) { if ( $ rotation_index === 0 ) return $ file_name ; $ rotation_date = date ( $ this -> options [ 'date_format' ] , time ( ) - ( $ this -> options [ 'period_duration' ] * $ rotation_index ) ) ; return strtr ( sprintf ( $ this -> options [ 'filename_mask' ] , $ file_name ) , array ( $ this -> options [ 'filename_date_tag' ] => $ rotation_date , $ this -> options [ 'filename_iterator_tag' ] => $ rotation_index , ) ) ; }
Get the name of a file to rotate
2,520
public static function lockTheme ( $ theme_name ) { update_option ( 'template' , $ theme_name ) ; update_option ( 'stylesheet' , $ theme_name ) ; update_option ( 'current_theme' , $ theme_name ) ; add_action ( 'admin_init' , function ( ) { global $ submenu ; unset ( $ submenu [ self :: MENU_THEMES ] [ 5 ] ) ; $ submenu [ self :: MENU_THEMES ] [ 6 ] [ 2 ] = "customize.php?return=" . urlencode ( get_admin_url ( ) ) ; } ) ; }
Sets the theme to the provided theme name and removes the theme selection screen
2,521
public function run ( $ id ) { $ model = $ this -> getModel ( $ id ) ; $ model -> setScenario ( $ this -> scenario ) ; if ( $ model -> load ( Yii :: $ app -> getRequest ( ) -> post ( ) ) ) { if ( Yii :: $ app -> getRequest ( ) -> isAjax ) { Yii :: $ app -> getResponse ( ) -> format = Response :: FORMAT_JSON ; return ActiveForm :: validate ( $ model ) ; } if ( $ model -> save ( ) ) { $ this -> addSuccessFlash ( ) ; return $ this -> redirect ( $ model ) ; } else { $ this -> addErrorFlash ( ) ; } } return $ this -> controller -> render ( $ this -> view , [ $ this -> nameVariableModel => $ model , ] ) ; }
Updates existing record .
2,522
protected function getAllowedAclFields ( Model $ model , $ scenario ) { $ privilege = [ 'set' , 'set_on_' . $ scenario ] ; $ acl = app ( AclContract :: class ) ; $ modelClass = get_class ( $ model ) ; $ cacheKey = sha1 ( json_encode ( $ privilege ) . $ acl -> getContextId ( ) . $ modelClass ) ; if ( ! isset ( $ this -> fieldAclCache [ $ cacheKey ] ) ) { $ this -> fieldAclCache [ $ cacheKey ] = [ ] ; $ this -> fieldAclCache [ $ cacheKey ] [ ] = 'meta' ; foreach ( $ model -> getFields ( ) as $ fieldName ) { if ( $ acl -> isAllowedField ( $ modelClass , $ fieldName , $ privilege ) ) { $ this -> fieldAclCache [ $ cacheKey ] [ ] = $ fieldName ; } } foreach ( $ model -> metaFields ( ) as $ fieldName ) { $ metaFieldName = 'meta.' . $ fieldName ; if ( $ acl -> isAllowedField ( $ modelClass , $ metaFieldName , $ privilege ) ) { $ this -> fieldAclCache [ $ cacheKey ] [ ] = $ metaFieldName ; } } } return $ this -> fieldAclCache [ $ cacheKey ] ; }
Get and cache the field rules
2,523
protected function getStep ( $ step ) { $ store = $ this -> getStore ( ) ; $ formSrv = $ this -> getServiceLocator ( ) -> get ( 'Form' ) ; if ( $ step == $ this -> startStep ) { $ form = $ formSrv -> get ( 'Grid\Paragraph\CreateWizard\Start' ) ; $ model = new StartStep ( array ( 'textDomain' => 'paragraph' , ) ) ; } else { $ store [ 'type' ] = $ step ; $ form = new Form ; $ create = $ formSrv -> get ( 'Grid\Paragraph\Meta\Create' ) ; $ model = new WizardStep ( array ( 'textDomain' => 'paragraph' , ) , array ( 'finish' => true , 'next' => 'finish' , ) ) ; if ( $ create -> has ( $ step ) ) { foreach ( $ create -> get ( $ step ) as $ element ) { $ form -> add ( $ element ) ; } } else { $ edit = $ formSrv -> get ( 'Grid\Paragraph\Meta\Edit' ) ; if ( $ edit -> has ( $ step ) ) { foreach ( $ edit -> get ( $ step ) as $ element ) { $ form -> add ( $ element ) ; } } else { $ model -> setOption ( 'skip' , true ) ; } } } return $ model -> setStepForm ( $ form ) ; }
Get step model
2,524
public function index ( ) { $ this -> getListingService ( ) -> setOrder ( $ this -> getOrder ( ) ) -> setPagination ( $ this -> getPagination ( ) ) -> getFilters ( ) -> add ( $ this -> getSearchFilter ( ) ) ; $ this -> set ( [ $ this -> getEntityNamePlural ( ) => $ this -> getListingService ( ) -> getList ( ) , 'pagination' => $ this -> getListingService ( ) -> getPagination ( ) ] ) ; }
Handle the request to display a list of entities
2,525
protected function getPagination ( ) { if ( null == $ this -> pagination ) { $ this -> pagination = new Pagination ( [ 'rowsPerPage' => $ this -> rowsPerPage , 'request' => $ this -> getRequest ( ) ] ) ; } return $ this -> pagination ; }
Get pagination for roes per page property
2,526
protected function getListingService ( ) { if ( null == $ this -> listingService ) { $ this -> listingService = new EntityListingService ( $ this -> getEntityClassName ( ) ) ; } return $ this -> listingService ; }
Get the entity listing service
2,527
protected function getSearchFilter ( ) { $ pattern = $ this -> getRequest ( ) -> getQuery ( 'pattern' , null ) ; $ pattern = StaticFilter :: filter ( 'text' , $ pattern ) ; $ this -> set ( 'pattern' , $ pattern ) ; return new SearchFilter ( [ 'pattern' => $ pattern ] ) ; }
Get search filter
2,528
protected function getSearchFields ( ) { if ( null == $ this -> searchFields ) { $ field = $ this -> getEntityDescriptor ( ) -> getDisplayFiled ( ) ; $ this -> searchFields = [ $ this -> getEntityDescriptor ( ) -> getTableName ( ) . '.' . $ field -> getField ( ) ] ; } return $ this -> searchFields ; }
Get the fields list to use on search filter
2,529
protected function getOrder ( ) { $ repo = $ this -> getRepository ( ) ; $ table = $ repo -> getEntityDescriptor ( ) -> getTableName ( ) ; $ pmk = $ repo -> getEntityDescriptor ( ) -> getPrimaryKey ( ) -> getField ( ) ; return "{$table}.{$pmk} DESC" ; }
Returns the query order by clause
2,530
public function shopIsAvailable ( ) { $ open = false ; $ setting = $ this -> shopSettingsRepository -> findOneBy ( [ 'name' => \ Amulen \ ShopBundle \ Entity \ ShopSetting :: SHOP_AVAILABLE ] ) ; if ( $ setting ) { $ strValue = $ setting -> getValue ( ) ; $ value = strtolower ( trim ( $ strValue ) ) ; if ( $ value == 'yes' || $ value == 'si' || $ value == 'on' || $ value == 'true' ) { $ open = true ; } } return $ open ; }
Get the shop status .
2,531
public function getSetting ( $ settingName ) { $ value = null ; $ setting = $ this -> shopSettingsRepository -> findOneBy ( [ 'name' => $ settingName ] ) ; if ( $ setting ) { $ value = $ setting -> getValue ( ) ; } return $ value ; }
Get s setting value .
2,532
public function equals ( $ role ) { return $ role -> getRole ( ) -> id == $ this -> role -> id && $ role -> getRole ( ) -> name == $ this -> role -> name ; }
checks if given role object is equal to current one
2,533
public function addPermissions ( $ permissions ) { foreach ( $ permissions as $ permission ) { $ per = new permission ( $ permission ) ; $ this -> role -> sharedPermissionList [ ] = $ per -> get ( ) ; } R :: store ( $ this -> role ) ; }
add permissions to role
2,534
public function addPermission ( $ permission ) { $ per = new permission ( $ permission ) ; $ this -> role -> sharedPermissionList [ ] = $ per -> get ( ) ; R :: store ( $ this -> role ) ; }
add a permission to role
2,535
public function getPermissions ( ) { $ permissions = [ ] ; foreach ( $ this -> role -> sharedPermissionList as $ permission ) { $ permissions [ ] = $ permission -> name ; } return $ permissions ; }
return all permission assigned to this role
2,536
public function hasPermission ( $ permissionName ) { foreach ( $ this -> role -> sharedPermissionList as $ permission ) { if ( $ permission -> name == $ permissionName ) { return true ; } } return false ; }
check if a role has a permission
2,537
public function addHost ( Host $ host ) { $ host_name = $ host -> getHostName ( ) ; if ( $ this -> offsetExists ( $ host_name ) ) throw new \ InvalidArgumentException ( "Duplicate host {$host_name}" ) ; foreach ( $ this -> hosts as $ h ) { if ( $ h -> isWww ( ) && ( "www." . $ h -> getHostName ( ) ) === $ host_name ) throw new \ InvalidArgumentException ( "Duplicate host {$host_name}" ) ; if ( $ h -> inAlias ( $ host_name ) || $ h -> inRedirect ( $ host_name ) ) $ h -> removeAlias ( $ host_name ) ; } foreach ( $ host -> getAliases ( ) as $ alias ) $ this -> throwAlias ( $ alias , $ host_name ) ; foreach ( $ host -> getRedirect ( ) as $ redirect ) $ this -> throwAlias ( $ redirect , $ host_name ) ; $ host -> addInvoker ( function ( $ type , $ value ) use ( $ host_name ) { switch ( $ type ) { case "alias" : case "redirect" : $ this -> throwAlias ( $ value , $ host_name ) ; break ; } } ) ; return $ this ; }
Add new host item
2,538
public function getHost ( string $ host ) { $ host = Host :: filter ( $ host ) ; return $ this -> offsetExists ( $ host ) ? $ this -> hosts [ $ host ] : null ; }
Get host item
2,539
public function hasHost ( string $ host ) : bool { $ host = Host :: filter ( $ host ) ; return $ this -> offsetExists ( $ host ) ; }
Check host exists
2,540
public function removeHost ( string $ host ) { $ host = Host :: filter ( $ host ) ; if ( $ this -> offsetExists ( $ host ) ) unset ( $ this -> hosts [ $ host ] ) ; return $ this ; }
Remove host item
2,541
public static function asort ( array & $ array , int $ sort_flags = SORT_REGULAR ) : void { self :: decorateOriginalArray ( $ array ) ; uasort ( $ array , function ( $ a , $ b ) use ( $ sort_flags ) { if ( $ a [ 1 ] == $ b [ 1 ] ) return $ a [ 0 ] - $ b [ 0 ] ; $ arr = [ - 1 => $ a [ 1 ] , 1 => $ b [ 1 ] ] ; asort ( $ arr , $ sort_flags ) ; reset ( $ arr ) ; return key ( $ arr ) ; } ) ; self :: undecorateSortedArray ( $ array ) ; }
Sort an array and maintain index association
2,542
public static function uasort ( array & $ array , callable $ value_compare_func ) : void { self :: decorateOriginalArray ( $ array ) ; uasort ( $ array , function ( $ a , $ b ) use ( $ value_compare_func ) { $ result = call_user_func ( $ value_compare_func , $ a [ 1 ] , $ b [ 1 ] ) ; if ( $ result == 0 ) return $ a [ 0 ] - $ b [ 0 ] ; return $ result ; } ) ; self :: undecorateSortedArray ( $ array ) ; }
Sort an array with a user - defined comparison function and maintain index association
2,543
protected function createConfigFolder ( $ folderName ) { $ folder = $ this -> getBaseConfigFolder ( ) . $ folderName ; if ( ! is_dir ( $ folder ) ) { $ this -> logger -> info ( "Creating folder config/{$folderName}" ) ; mkdir ( $ folder ) ; } return $ folder ; }
Create the given folder inside the base config folder .
2,544
protected function initAllConfigs ( ) { if ( $ this -> isInitialized ) { return ; } $ this -> logger -> info ( 'Checking and initializing config files' ) ; foreach ( $ this -> getEnvironments ( ) as $ environment ) { $ this -> initConfig ( $ environment ) ; } $ this -> isInitialized = true ; }
Refresh config files for all environments .
2,545
protected function stripBaseConfigFolderFromPath ( $ path ) { if ( 0 !== strpos ( $ path , $ this -> getBaseConfigFolder ( ) ) ) { throw new ConfigManipulatorException ( 'Cannot strip base path from given path: ' . $ path ) ; } return substr ( $ path , strlen ( $ this -> getBaseConfigFolder ( ) ) ) ; }
Make the given path relative to the base config folder by stripping the folder name if it matches .
2,546
public function checkCanCreateModuleConfig ( $ module , $ environment = '' , $ allowOverwriteEmpty = true ) { $ targetFile = $ this -> getModuleFile ( $ module , $ environment ) ; if ( file_exists ( $ targetFile ) ) { $ content = Yaml :: parse ( file_get_contents ( $ targetFile ) ) ; if ( null !== $ content || ! $ allowOverwriteEmpty ) { return false ; } } return true ; }
Check if the config for the given module name and environment can safely be created .
2,547
public function addParameter ( $ name , $ defaultValue , $ addComment = null ) { $ this -> logger -> info ( "Setting parameter $name in parameters.yml" ) ; $ this -> getYamlManipulator ( ) -> addParameterToFile ( $ this -> getBaseConfigFolder ( ) . 'parameters.yml' , $ name , $ defaultValue , false ) ; $ this -> getYamlManipulator ( ) -> addParameterToFile ( $ this -> getBaseConfigFolder ( ) . 'parameters.yml.dist' , $ name , $ defaultValue , true , $ addComment ) ; }
Add a parameter to parameters . yml and parameters . yml . dist .
2,548
public static function endsWith ( $ string , $ end ) { $ l = strlen ( $ end ) ; if ( $ l == 0 ) { return true ; } return substr ( $ string , - $ l ) === $ end ; }
Whether a string end with another string .
2,549
public function listAction ( ) { $ filterManager = $ this -> get ( 'phlexible_message.filter_manager' ) ; $ filters = [ ] ; foreach ( $ filterManager -> findBy ( [ 'userId' => $ this -> getUser ( ) -> getId ( ) ] ) as $ filter ) { $ criteria = [ ] ; foreach ( $ filter -> getCriteria ( ) as $ groupIndex => $ group ) { foreach ( $ group as $ criterium ) { $ criteria [ ] = [ 'criteria' => $ criterium -> getType ( ) , 'value' => $ criterium -> getValue ( ) , 'group' => $ groupIndex + 1 , ] ; } } $ filters [ ] = [ 'id' => $ filter -> getId ( ) , 'title' => $ filter -> getTitle ( ) , 'criteria' => $ criteria , ] ; } return new JsonResponse ( $ filters ) ; }
List filters .
2,550
public function updateAction ( Request $ request , $ id ) { $ title = $ request -> get ( 'title' ) ; $ rawCriteria = json_decode ( $ request -> get ( 'criteria' ) , true ) ; $ filterManager = $ this -> get ( 'phlexible_message.filter_manager' ) ; $ filter = $ filterManager -> find ( $ id ) ; $ filter -> setTitle ( $ title ) ; $ criteria = new Criteria ( ) ; $ criteria -> setMode ( Criteria :: MODE_OR ) ; foreach ( $ rawCriteria as $ group ) { $ criteriaGroup = new Criteria ( ) ; $ criteriaGroup -> setMode ( Criteria :: MODE_AND ) ; foreach ( $ group as $ row ) { if ( ! strlen ( $ row [ 'value' ] ) ) { continue ; } $ criterium = new Criterium ( $ row [ 'key' ] , $ row [ 'value' ] ) ; $ criteriaGroup -> add ( $ criterium ) ; } if ( $ criteriaGroup -> count ( ) ) { $ criteria -> addCriteria ( $ criteriaGroup ) ; } } $ filter -> setCriteria ( $ criteria ) ; $ filterManager -> updateFilter ( $ filter ) ; return new ResultResponse ( true , 'Filter updated' ) ; }
Updates a Filter .
2,551
public function deleteAction ( $ id ) { $ filterManager = $ this -> get ( 'phlexible_message.filter_manager' ) ; $ filter = $ filterManager -> find ( $ id ) ; $ filterManager -> deleteFilter ( $ filter ) ; return new ResultResponse ( true , 'Filter "' . $ filter -> getTitle ( ) . '" deleted.' ) ; }
Delete filter .
2,552
public function previewAction ( Request $ request ) { $ rawCriteria = json_decode ( $ request -> get ( 'filters' ) , true ) ; $ messageManager = $ this -> get ( 'phlexible_message.message_manager' ) ; $ criteria = new Criteria ( ) ; $ criteria -> setMode ( Criteria :: MODE_OR ) ; foreach ( $ rawCriteria as $ group ) { $ criteriaGroup = new Criteria ( ) ; $ criteriaGroup -> setMode ( Criteria :: MODE_AND ) ; foreach ( $ group as $ row ) { if ( ! strlen ( $ row [ 'value' ] ) ) { continue ; } $ criterium = new Criterium ( $ row [ 'key' ] , $ row [ 'value' ] ) ; $ criteriaGroup -> add ( $ criterium ) ; } if ( $ criteriaGroup -> count ( ) ) { $ criteria -> addCriteria ( $ criteriaGroup ) ; } } if ( ! $ criteria -> count ( ) ) { return new JsonResponse ( [ 'total' => 0 , 'messages' => [ ] , ] ) ; } $ messages = $ messageManager -> findByCriteria ( $ criteria , [ 'createdAt' => 'DESC' ] , 20 ) ; $ count = $ messageManager -> countByCriteria ( $ criteria ) ; $ priorityList = $ messageManager -> getPriorityNames ( ) ; $ typeList = $ messageManager -> getTypeNames ( ) ; $ data = [ ] ; foreach ( $ messages as $ message ) { $ data [ ] = [ 'subject' => $ message -> getSubject ( ) , 'body' => nl2br ( $ message -> getBody ( ) ) , 'priority' => $ priorityList [ $ message -> getPriority ( ) ] , 'type' => $ typeList [ $ message -> getType ( ) ] , 'channel' => $ message -> getChannel ( ) , 'role' => $ message -> getRole ( ) , 'created_at' => $ message -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'user' => $ message -> getUser ( ) , ] ; } return new JsonResponse ( [ 'total' => $ count , 'messages' => $ data , ] ) ; }
Preview messages .
2,553
public function getErrors ( ) { $ errors = $ this -> handlerRegistry -> getHandler ( $ this -> key ) -> getErrors ( ) -> getErrors ( ) ; return new Response ( $ errors ) ; }
Get all errors
2,554
protected function connect ( ) { $ this -> _socket = @ stream_socket_client ( $ this -> hostname . ':' . $ this -> port , $ errorNumber , $ errorDescription , $ this -> timeout ? $ this -> timeout : ini_get ( "default_socket_timeout" ) ) ; if ( $ this -> _socket ) { if ( $ this -> password !== null ) $ this -> executeCommand ( 'AUTH' , array ( $ this -> password ) ) ; $ this -> executeCommand ( 'SELECT' , array ( $ this -> database ) ) ; } else throw new CException ( 'Failed to connect to redis: ' . $ errorDescription , ( int ) $ errorNumber ) ; }
Establishes a connection to the redis server . It does nothing if the connection has already been established .
2,555
public static function SingleImage ( $ name , $ title = null , SS_List $ dataList = null ) { $ field = UploadField :: create ( $ name , $ title , $ dataList ) -> setAllowedFileCategories ( 'image' ) -> setConfig ( 'allowedMaxFileNumber' , 1 ) ; return $ field ; }
Return a new UploadField instance preconfiguger to only allow one image
2,556
public function get ( $ uri , $ extraHeaders = array ( ) ) { $ requestData = $ this -> prepareRequest ( 'GET' , $ uri , $ extraHeaders ) ; return $ this -> performHttpRequest ( $ requestData [ 'method' ] , $ requestData [ 'url' ] , $ requestData [ 'headers' ] ) ; }
GET a URI using client object .
2,557
public function post ( $ data , $ uri = null , $ remainingRedirects = null , $ contentType = null , $ extraHeaders = null ) { $ requestData = $ this -> prepareRequest ( 'POST' , $ uri , $ extraHeaders , $ data , $ contentType ) ; return $ this -> performHttpRequest ( $ requestData [ 'method' ] , $ requestData [ 'url' ] , $ requestData [ 'headers' ] , $ requestData [ 'data' ] , $ requestData [ 'contentType' ] ) ; }
POST data with client object
2,558
public function delete ( $ data , $ remainingRedirects = null ) { if ( is_string ( $ data ) ) { $ requestData = $ this -> prepareRequest ( 'DELETE' , $ data ) ; } else { $ headers = array ( ) ; $ requestData = $ this -> prepareRequest ( 'DELETE' , null , $ headers , $ data ) ; } return $ this -> performHttpRequest ( $ requestData [ 'method' ] , $ requestData [ 'url' ] , $ requestData [ 'headers' ] , '' , $ requestData [ 'contentType' ] , $ remainingRedirects ) ; }
DELETE entry with client object
2,559
public function insertEntry ( $ data , $ uri , $ className = 'Zend_Gdata_App_Entry' , $ extraHeaders = array ( ) ) { if ( ! class_exists ( $ className , false ) ) { require_once 'Zend/Loader.php' ; @ Zend_Loader :: loadClass ( $ className ) ; } $ response = $ this -> post ( $ data , $ uri , null , null , $ extraHeaders ) ; $ returnEntry = new $ className ( $ response -> getBody ( ) ) ; $ returnEntry -> setHttpClient ( self :: getstaticHttpClient ( ) ) ; $ etag = $ response -> getHeader ( 'ETag' ) ; if ( $ etag !== null ) { $ returnEntry -> setEtag ( $ etag ) ; } return $ returnEntry ; }
Inserts an entry to a given URI and returns the response as a fully formed Entry .
2,560
public function updateEntry ( $ data , $ uri = null , $ className = null , $ extraHeaders = array ( ) ) { if ( $ className === null && $ data instanceof Zend_Gdata_App_Entry ) { $ className = get_class ( $ data ) ; } elseif ( $ className === null ) { $ className = 'Zend_Gdata_App_Entry' ; } if ( ! class_exists ( $ className , false ) ) { require_once 'Zend/Loader.php' ; @ Zend_Loader :: loadClass ( $ className ) ; } $ response = $ this -> put ( $ data , $ uri , null , null , $ extraHeaders ) ; $ returnEntry = new $ className ( $ response -> getBody ( ) ) ; $ returnEntry -> setHttpClient ( self :: getstaticHttpClient ( ) ) ; $ etag = $ response -> getHeader ( 'ETag' ) ; if ( $ etag !== null ) { $ returnEntry -> setEtag ( $ etag ) ; } return $ returnEntry ; }
Update an entry
2,561
public function retrieveAllEntriesForFeed ( $ feed ) { $ feedClass = get_class ( $ feed ) ; $ reflectionObj = new ReflectionClass ( $ feedClass ) ; $ result = $ reflectionObj -> newInstance ( ) ; do { foreach ( $ feed as $ entry ) { $ result -> addEntry ( $ entry ) ; } $ next = $ feed -> getLink ( 'next' ) ; if ( $ next !== null ) { $ feed = $ this -> getFeed ( $ next -> href , $ feedClass ) ; } else { $ feed = null ; } } while ( $ feed != null ) ; return $ result ; }
Retrieve all entries for a feed iterating through pages as necessary . Be aware that calling this function on a large dataset will take a significant amount of time to complete . In some cases this may cause execution to timeout without proper precautions in place .
2,562
public function getNextFeed ( $ feed , $ className = null ) { $ nextLink = $ feed -> getNextLink ( ) ; if ( ! $ nextLink ) { return null ; } $ nextLinkHref = $ nextLink -> getHref ( ) ; if ( $ className === null ) { $ className = get_class ( $ feed ) ; } return $ this -> getFeed ( $ nextLinkHref , $ className ) ; }
Retrieve next set of results based on a given feed .
2,563
public function getPreviousFeed ( $ feed , $ className = null ) { $ previousLink = $ feed -> getPreviousLink ( ) ; if ( ! $ previousLink ) { return null ; } $ previousLinkHref = $ previousLink -> getHref ( ) ; if ( $ className === null ) { $ className = get_class ( $ feed ) ; } return $ this -> getFeed ( $ previousLinkHref , $ className ) ; }
Retrieve previous set of results based on a given feed .
2,564
public function generateIfMatchHeaderData ( $ data , $ allowWeek ) { $ result = '' ; if ( $ this -> _majorProtocolVersion >= 2 && $ data instanceof Zend_Gdata_App_Entry ) { $ etag = $ data -> getEtag ( ) ; if ( ( $ etag !== null ) && ( $ allowWeek || substr ( $ etag , 0 , 2 ) != 'W/' ) ) { $ result = $ data -> getEtag ( ) ; } } return $ result ; }
Returns the data for an If - Match header based on the current Etag property . If Etags are not supported by the server or cannot be extracted from the data then null will be returned .
2,565
protected function generateToken ( $ object ) { $ token = get_class ( $ object ) ; if ( $ pos = strrpos ( $ token , "\\" ) ) { $ token = strtolower ( substr ( $ token , $ pos + 1 ) ) ; } if ( isset ( $ this -> tokens [ $ token ] ) ) { $ i = 1 ; $ tmp = $ token . $ i ; while ( isset ( $ this -> tokens [ $ tmp ] ) ) { $ i ++ ; } $ token = $ tmp ; } $ this -> tokens [ $ token ] = true ; return $ token ; }
Generate a unique token .
2,566
public function isForceInitialization ( $ flag = null ) { if ( $ flag === null ) { return $ this -> forceInit ; } $ this -> forceInit = $ flag ; return $ this ; }
Gets or sets flag
2,567
public function url ( $ url = null , $ full = false ) { if ( CakePlugin :: loaded ( 'I18n' ) ) { $ url = Common :: url ( $ url ) ; if ( is_array ( $ url ) && ! array_key_exists ( 'lang' , $ url ) ) { $ url [ 'lang' ] = Configure :: read ( 'Config.language' ) ; } } return parent :: url ( $ url , $ full ) ; }
Url helper function
2,568
public function save ( AbstractEntity $ entity ) { if ( empty ( $ entity -> getId ( ) ) ) { $ this -> getEntityManager ( ) -> persist ( $ entity ) ; } $ this -> getEntityManager ( ) -> flush ( $ entity ) ; }
Persists and saves an entity to the database .
2,569
public function remove ( AbstractEntity $ entity ) { $ this -> getEntityManager ( ) -> remove ( $ entity ) ; $ this -> getEntityManager ( ) -> flush ( ) ; }
Removes an entity from the database .
2,570
public static function getClassProfile ( $ classname ) { if ( ! array_key_exists ( $ classname , self :: $ profiles ) ) self :: $ profiles [ $ classname ] = new ClassProfile ( $ classname ) ; return self :: $ profiles [ $ classname ] ; }
Obtains a ClassProfile instance for the given classname
2,571
public function stream_open ( string $ url , string $ mode , int $ options , ? string & $ openedPath ) : bool { $ partition = self :: getPartition ( $ url ) ; $ path = self :: getRelativePath ( $ url ) ; $ this -> filePointer = $ partition -> fileOpen ( $ path , $ mode , $ options ) ; $ result = ( bool ) $ this -> filePointer ; if ( $ result && ( $ options & STREAM_USE_PATH ) ) { $ openedPath = $ path ; } return $ result ; }
Opens file or URL . This method is called immediately after the wrapper is initialized .
2,572
public function stream_metadata ( string $ url , int $ option , $ value ) : bool { $ partition = self :: getPartition ( $ url ) ; $ path = self :: getRelativePath ( $ url ) ; switch ( $ option ) { case STREAM_META_TOUCH : $ result = $ partition -> touch ( $ path , $ value [ 1 ] ?? null , $ value [ 2 ] ?? null ) ? true : false ; break ; default : $ result = false ; } return $ result ; }
Change stream metadata .
2,573
public static function register ( string $ protocol , string $ root = null , int $ flags = 0 ) : bool { $ wrappers = stream_get_wrappers ( ) ; if ( in_array ( $ protocol , $ wrappers ) ) { throw new Exception ( "Protocol '$protocol' has been already registered" ) ; } $ wrapper = stream_wrapper_register ( $ protocol , get_called_class ( ) , $ flags ) ; if ( $ wrapper ) { if ( null !== $ root ) { $ content = Entity :: newInstance ( $ root ) ; } else { $ content = null ; } $ partition = new Partition ( $ content ) ; self :: $ partitions [ $ protocol ] = $ partition ; } return $ wrapper ; }
Register stream wrapper .
2,574
public static function commit ( string $ protocol ) : bool { if ( isset ( self :: $ partitions [ $ protocol ] ) ) { self :: $ partitions [ $ protocol ] -> commit ( ) ; $ result = true ; } else { $ result = false ; } return $ result ; }
Commit all changes to real FS .
2,575
public static function unregister ( string $ protocol ) : bool { unset ( self :: $ partitions [ $ protocol ] ) ; $ wrappers = stream_get_wrappers ( ) ; if ( ! in_array ( $ protocol , $ wrappers ) ) { throw new Exception ( "Protocol '$protocol' has not been registered yet" ) ; } return stream_wrapper_unregister ( $ protocol ) ; }
Unregister stream wrapper .
2,576
private static function getPartition ( string $ url ) : ? Partition { $ urlParts = explode ( '://' , $ url ) ; $ protocol = array_shift ( $ urlParts ) ; return self :: $ partitions [ $ protocol ] ?? null ; }
Get partition by file url .
2,577
public function getCustomDate ( $ language , $ fallbackLanguage = null ) { $ date = $ this -> getMappedField ( 'date' , $ language , $ fallbackLanguage ) ; return $ date ; }
Return custom date .
2,578
public function getMappedField ( $ field , $ language , $ fallbackLanguage = null ) { if ( $ this -> mappedFields -> containsKey ( $ language ) ) { $ mappedField = $ this -> mappedFields -> get ( $ language ) ; } elseif ( $ this -> mappedFields -> containsKey ( $ fallbackLanguage ) ) { $ mappedField = $ this -> mappedFields -> get ( $ fallbackLanguage ) ; } else { foreach ( $ this -> mappedFields as $ testMappedField ) { if ( $ testMappedField -> getLanguage ( ) === $ language ) { $ mappedField = $ testMappedField ; break ; } } if ( ! isset ( $ mappedField ) ) { foreach ( $ this -> mappedFields as $ testMappedField ) { if ( $ testMappedField -> getLanguage ( ) === $ fallbackLanguage ) { $ mappedField = $ testMappedField ; break ; } } } if ( ! isset ( $ mappedField ) ) { return null ; } } if ( $ field === 'page' ) { if ( $ mappedField -> getPage ( ) ) { return $ mappedField -> getPage ( ) ; } else { $ field = 'backend' ; } } if ( $ field === 'navigation' ) { if ( $ mappedField -> getNavigation ( ) ) { return $ mappedField -> getNavigation ( ) ; } else { $ field = 'backend' ; } } if ( $ field === 'backend' ) { return $ mappedField -> getBackend ( ) ; } if ( $ field === 'date' && $ mappedField -> getDate ( ) ) { return $ mappedField -> getDate ( ) ; } if ( $ field === 'forward' && $ mappedField -> getForward ( ) ) { return json_decode ( $ mappedField -> getForward ( ) , true ) ; } if ( $ field === 'custom1' && $ mappedField -> getCustom1 ( ) ) { return $ mappedField -> getCustom1 ( ) ; } elseif ( $ field === 'custom2' && $ mappedField -> getCustom2 ( ) ) { return $ mappedField -> getCustom2 ( ) ; } elseif ( $ field === 'custom3' && $ mappedField -> getCustom3 ( ) ) { return $ mappedField -> getCustom3 ( ) ; } elseif ( $ field === 'custom4' && $ mappedField -> getCustom4 ( ) ) { return $ mappedField -> getCustom4 ( ) ; } elseif ( $ field === 'custom5' && $ mappedField -> getCustom5 ( ) ) { return $ mappedField -> getCustom5 ( ) ; } return null ; }
Return mapped field .
2,579
public function singleAnnouncementAction ( ) { $ this -> checkStaticTemplateIsIncluded ( ) ; $ this -> checkSettings ( ) ; $ this -> slotExtendedAssignMultiple ( [ self :: VIEW_VARIABLE_ASSOCIATION_ID => $ this -> settings [ self :: SETTINGS_ASSOCIATION_ID ] , self :: VIEW_VARIABLE_ANNOUNCEMENT_ID => $ this -> settings [ self :: SETTINGS_ANNOUNCEMENT_ID ] ] , __CLASS__ , __FUNCTION__ ) ; return $ this -> view -> render ( ) ; }
single announcement action .
2,580
protected function normalizeDirArray ( ) { if ( ! isset ( $ this -> dir [ 'iterate' ] ) ) { $ this -> dir [ 'iterate' ] = self :: DEFAULT_ITERATE ; } if ( ! isset ( $ this -> dir [ 'path' ] ) ) { $ this -> dir [ 'path' ] = self :: DEFAULT_PATH ; } if ( ! isset ( $ this -> dir [ 'recursive' ] ) ) { $ this -> dir [ 'recursive' ] = self :: DEFAULT_RECURSIVE ; } }
Makes sure dir array has default properties at least
2,581
public function getArgsMethod ( & $ class , $ method ) { $ params = [ ] ; $ method = new \ ReflectionMethod ( $ class , $ method ) ; $ parameters = $ method -> getParameters ( ) ; foreach ( $ parameters as $ parameter ) { $ object = $ parameter -> getClass ( ) ; if ( $ object != null ) { if ( array_key_exists ( $ object -> name , $ this -> _alias ) ) { $ name = $ this -> _alias [ $ object -> name ] ; array_push ( $ params , self :: $ name ( ) ) ; } else if ( preg_match ( '#(Controller\\\Request\\\)#isU' , $ object -> name ) ) { array_push ( $ params , Form :: instance ( ) -> get ( $ object ) ) ; } else if ( preg_match ( '#(Orm\\\Entity\\\)#isU' , $ object -> name ) ) { array_push ( $ params , Orm :: instance ( ) -> get ( $ object ) ) ; } else { array_push ( $ params , null ) ; } } else { if ( isset ( $ _GET [ $ parameter -> getName ( ) ] ) ) { array_push ( $ params , $ _GET [ $ parameter -> getName ( ) ] ) ; } else if ( isset ( $ _POST [ $ parameter -> getName ( ) ] ) ) { array_push ( $ params , $ _POST [ $ parameter -> getName ( ) ] ) ; } else { if ( ! $ parameter -> isOptional ( ) ) { array_push ( $ params , null ) ; } } } } return $ params ; }
Initialization of the application
2,582
public final function setContentLength ( $ length ) { if ( ! is_numeric ( $ length ) ) { throw new ehough_shortstop_api_exception_InvalidArgumentException ( "Content-Length must be an integer ($length)" ) ; } $ length = intval ( $ length ) ; if ( $ length < 0 ) { throw new ehough_shortstop_api_exception_InvalidArgumentException ( "Content-Length cannot be negative ($length)" ) ; } $ this -> _contentLength = $ length ; }
Sets the content length of the entity .
2,583
protected static function bootLaravel ( Event $ event ) { $ dir = dirname ( $ event -> getComposer ( ) -> getConfig ( ) -> get ( 'vendor-dir' ) ) ; require $ dir . '/bootstrap/autoload.php' ; self :: $ app = require_once $ dir . '/bootstrap/app.php' ; self :: $ kernel = $ app -> make ( \ Illuminate \ Contracts \ Console \ Kernel :: class ) ; self :: $ kernel -> bootstrap ( ) ; self :: instantiateConsoleInteraction ( $ event ) ; }
Boots Laravel so we can use all its features .
2,584
protected static function instantiateConsoleInteraction ( Event $ event ) { $ consoleIO = $ event -> getIO ( ) ; self :: $ consoleInteraction = new ConsoleInteraction ( new Input ( $ consoleIO ) , new Output ( $ consoleIO ) ) ; }
Gets the console interaction object So we can use all the command line features of composer .
2,585
public function addInEdge ( DocumentGraphEdge $ edge ) : void { $ this -> inEdges [ $ edge -> getSource ( ) -> className ] = $ edge ; }
Adds an in edge to this node .
2,586
public function addOutEdge ( DocumentGraphEdge $ edge ) : void { $ this -> outEdges [ $ edge -> getDestination ( ) -> className ] = $ edge ; }
Adds an out edge from this node .
2,587
private function filterParent ( $ parent , MenuItemCollection $ items ) { $ filteredItems = new MenuItemCollection ( ) ; foreach ( $ items -> getItems ( ) as $ name => $ item ) { if ( $ parent === $ item -> getParent ( ) ) { $ subItems = $ this -> filterParent ( $ name , $ items ) ; if ( count ( $ subItems ) ) { $ item -> setItems ( $ subItems ) ; } $ filteredItems -> set ( $ name , $ item ) ; $ items -> remove ( $ name ) ; } } return $ filteredItems ; }
Filter handlers by parent name .
2,588
public function actionShow ( $ id , $ slug ) { $ model = $ this -> model -> node ( $ id ) ; if ( empty ( $ model ) || ! $ model -> is_visible || $ model -> slug != $ slug ) { throw new NotFoundHttpException ( Yii :: t ( $ this -> tcModule , 'Content not found' ) ) ; } return $ this -> actionView ( $ id , true , null , true , false , true ) ; }
Render content as a web page
2,589
public function getDefaultParams ( $ model , $ langCode ) { $ fmt = new Formatter ; $ params = [ 'title' => $ model -> i18n [ $ langCode ] -> title , 'slug' => $ model -> slug , 'path' => $ model :: getNodePath ( $ model ) , 'owner' => $ fmt -> asUsername ( $ model -> owner_id ) , 'created' => $ model -> create_time , 'updated' => $ model -> update_time , ] ; return $ params ; }
Get default substitution params .
2,590
public function setCacheDir ( $ dir ) { if ( ! is_dir ( $ dir ) ) { $ this -> createDir ( $ dir ) ; } if ( ! is_writable ( $ dir ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The cache directory "%s" is not writable.' , $ dir ) ) ; } $ this -> cacheDir = $ dir ; return $ this ; }
Sets the cache directory .
2,591
public function setMetadataDirs ( array $ dirs ) { foreach ( $ dirs as $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The directory "%s" does not exist.' , $ dir ) ) ; } } $ this -> metadataDirs = $ dirs ; return $ this ; }
Sets metadata directories .
2,592
public function setSchemaDirs ( array $ dirs ) { foreach ( $ dirs as $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The directory "%s" does not exist.' , $ dir ) ) ; } } $ this -> schemaDirs = $ dirs ; return $ this ; }
Sets the schema directories .
2,593
public function addSchemaDir ( $ dir ) { if ( ! is_dir ( $ dir ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The directory "%s" does not exist.' , $ dir ) ) ; } if ( in_array ( $ dir , $ this -> schemaDirs ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The directory "%s" is already configured.' , $ dir ) ) ; } return $ this ; }
Adds a schema directory .
2,594
public function build ( ) { $ annotationReader = $ this -> annotationReader ; if ( null === $ annotationReader ) { $ annotationReader = new AnnotationReader ( ) ; if ( null !== $ this -> cacheDir ) { $ this -> createDir ( $ this -> cacheDir . '/annotations' ) ; $ annotationReader = new FileCacheReader ( $ annotationReader , $ this -> cacheDir . '/annotations' , $ this -> debug ) ; } } $ metadataDriver = $ this -> driverFactory -> createDriver ( $ this -> metadataDirs , $ annotationReader ) ; $ metadataFactory = new MetadataFactory ( $ metadataDriver ) ; $ metadataFactory -> setIncludeInterfaces ( $ this -> includeInterfaceMetadata ) ; if ( null !== $ this -> cacheDir ) { $ this -> createDir ( $ this -> cacheDir . '/metadata' ) ; $ metadataFactory -> setCache ( new FileCache ( $ this -> cacheDir . '/metadata' ) ) ; } $ schemaRegistry = new SchemaRegistry ( $ this -> schemaDirs ) ; return new Manager ( $ metadataFactory , $ schemaRegistry ) ; }
Builds and return a Manager instance .
2,595
function getParentClass ( ) { return FALSE !== $ this -> parentClass ? $ this -> parentClass : $ this -> parentClass = $ this -> buildParentClass ( ) ; }
Gets the parent class or NULL if it does not have one .
2,596
public function getRoles ( ) { $ roles = [ "ROLE_USER" ] ; $ dbRoles = EQM :: query ( new Role ( ) ) -> innerJoin ( 'roles_users ru' , 'Role.id = ru.role_id' ) -> where ( 'ru.user_id = :userId' , [ 'userId' => $ this -> getId ( ) ] ) -> all ( ) ; foreach ( $ dbRoles as $ role ) { $ roles [ ] = $ role -> getRole ( ) ; } return $ roles ; }
Returns the roles granted to the user .
2,597
public function setOsobaFizyczna ( \ KCH \ PCC3 \ Deklaracja \ Podmiot1AnonymousType \ OsobaFizycznaAnonymousType $ osobaFizyczna ) { $ this -> osobaFizyczna = $ osobaFizyczna ; return $ this ; }
Sets a new osobaFizyczna
2,598
public function execute ( ) { $ this -> cleanHistory ( ) ; $ this -> log ( ) ; $ this -> instanceManager -> update ( $ this -> instance ) ; }
Execute all steps for current instance - Clean history - Add log - Save current instance state
2,599
protected function cleanHistory ( ) { $ createdAt = new \ DateTime ( ) ; $ logs = $ this -> instance -> getLogs ( ) ; foreach ( $ logs as $ log ) { if ( ( $ createdAt -> getTimestamp ( ) - $ log -> getCreatedAt ( ) -> getTimestamp ( ) ) > $ this -> expiredTimestamp ) { $ this -> instance -> removeLog ( $ log ) ; } } }
Clean instance history . Delete expired logs