idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
43,800
public function add ( $ object ) { if ( is_array ( $ object ) ) { $ this -> responses = array_merge ( $ this -> responses , $ object ) ; } else { $ implementedInterfaces = class_implements ( $ object ) ; if ( array_key_exists ( "WasabiLib\Ajax\ResponseConfiguratorInterface" , $ implementedInterfaces ) ) { $ object -> configure ( ) ; foreach ( $ object -> getResponseTypes ( ) as $ responseType ) { $ implementedInterfacesInResponseType = class_implements ( $ responseType ) ; if ( array_key_exists ( "WasabiLib\Ajax\ResponseConfiguratorInterface" , $ implementedInterfacesInResponseType ) ) { $ this -> add ( $ responseType ) ; } else { $ this -> responses [ ] = $ responseType ; } } } else if ( array_key_exists ( "WasabiLib\Ajax\ResponseTypeInterface" , $ implementedInterfaces ) ) { $ this -> responses [ ] = $ object ; } else { throw new InvalidArgumentException ( "Invalid parameter type! Given value must be an array or implements the interfaces ResponseConfiguratorInterface or ResponseTypeInterface" ) ; } } }
Adds an object which implements the interfaces ResponseTypeInterface or ResponseConfiguratorInterface or an array of objects which implement the ResponseTypeInterface .
43,801
function addElements ( $ multiPart ) { if ( ! is_array ( $ multiPart ) ) throw new \ InvalidArgumentException ( sprintf ( 'Accept array of Files; given: "%s".' , \ Poirot \ Std \ flatten ( $ multiPart ) ) ) ; foreach ( $ multiPart as $ name => $ element ) $ this -> addElement ( $ name , $ element ) ; $ this -> addElementDone ( ) ; return $ this ; }
Append Boundary Elements
43,802
function addElement ( $ fieldName , $ element , $ headers = null ) { if ( $ this -> _trailingBoundary ) throw new \ Exception ( 'Trailing Boundary Is Added.' ) ; if ( ! $ headers instanceof iHeaders ) $ headers = ( ! empty ( $ headers ) ) ? new CollectionHeader ( $ headers ) : new CollectionHeader ; if ( $ this -> _addElement ( $ fieldName , $ element , $ headers ) ) $ this -> elementsAdded [ $ fieldName ] = $ element ; return $ this ; }
Append Boundary Element
43,803
function addElementDone ( ) { $ this -> _trailingBoundary = new STemporary ( "\r\n" . "--{$this->_boundary}--" ) ; $ this -> _t__wrap_stream -> addStream ( $ this -> _trailingBoundary -> rewind ( ) ) ; }
Add Trailing Boundary And Finish Data
43,804
public static function generate ( String $ name ) : Bool { Post :: project ( $ name ) ; $ validation = Singleton :: class ( 'ZN\Validation\Data' ) ; $ validation -> rules ( 'project' , [ 'alpha' ] , 'Project Name' ) ; if ( ! $ error = $ validation -> error ( 'string' ) ) { $ source = EXTERNAL_FILES_DIR . 'DefaultProject.zip' ; $ target = PROJECTS_DIR . Post :: project ( ) ; Forge :: zipExtract ( $ source , $ target ) ; return true ; } return false ; }
Select project name
43,805
public static function isPrime ( $ val = null ) { if ( is_null ( $ val ) ) { return null ; } if ( ( $ val <= 1 ) || ( $ val > 2 && ( $ val % 2 ) === 0 ) ) { return false ; } for ( $ i = 2 ; $ i < $ val ; $ i ++ ) { if ( ( $ val % $ i ) === 0 ) { return false ; } } return true ; }
Test if an integer is a prime number
43,806
public static function isLuhn ( $ val = null ) { if ( is_null ( $ val ) ) { return null ; } $ _num = substr ( $ val , 0 , strlen ( $ val ) - 1 ) ; return ( bool ) ( intval ( $ val ) == intval ( $ _num . self :: getLuhnKey ( $ _num ) ) ) ; }
Check that the last number in a suite is its Luhn key
43,807
public function getItems ( ) { $ namespaces = $ this -> xml -> getDocNamespaces ( ) ; foreach ( $ namespaces as $ namespace => $ url ) { $ this -> xml -> registerXPathNamespace ( $ namespace , $ url ) ; } foreach ( $ this -> xml -> xpath ( $ this -> itemXpath ) as $ item ) { $ this -> items [ ] = new Item ( $ this -> itemtitleXpath ? ( string ) $ item -> xpath ( $ this -> itemtitleXpath ) [ 0 ] : NULL , $ this -> itemtorrenturlXpath ? ( string ) $ item -> xpath ( $ this -> itemtorrenturlXpath ) [ 0 ] : NULL , $ this -> itemmagnetXpath ? ( string ) $ item -> xpath ( $ this -> itemmagnetXpath ) [ 0 ] : NULL ) ; } return $ this -> items ; }
Get Items from a feed .
43,808
public static function assumeThat ( $ actual , Matcher $ matcher , $ message = '' ) : void { if ( ! $ matcher -> matches ( $ actual ) ) { throw new AssumptionViolatedException ( $ actual , $ matcher , $ message ) ; } }
Assumes that a specific value matches a specific hamcrest matcher .
43,809
public function getUserGroups ( ) { $ db = $ this -> db ; $ query = $ db -> getQuery ( true ) -> select ( 'a.*, COUNT(DISTINCT b.id) AS level' ) -> from ( $ db -> quoteName ( '#__usergroups' ) . ' AS a' ) -> join ( 'LEFT' , $ db -> quoteName ( '#__usergroups' ) . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt' ) -> group ( 'a.id, a.title, a.lft, a.rgt, a.parent_id' ) -> order ( 'a.lft ASC' ) ; return $ db -> setQuery ( $ query ) -> loadObjectList ( ) ; }
Retourne les groupes utilisateurs .
43,810
public function index ( ) { $ model = $ this -> modelFullName ; $ collection = $ model :: all ( ) ; if ( $ collection -> isEmpty ( ) ) throw new NotFoundException ( 'There Are No Resources Named "' . $ this -> getResourceName ( ) . '" Yet' ) ; return $ collection ; }
Return a listing of the resource .
43,811
public function show ( $ id ) { $ modelName = $ this -> modelFullName ; $ model = $ modelName :: find ( $ id ) ; if ( ! $ model ) throw new NotFoundException ( 'There is no Resource with id = ' . $ id . ' !' ) ; return $ model ; }
Return the specified resource .
43,812
protected function validate ( $ data , $ rules = false ) { if ( ! $ rules ) { $ modelName = $ this -> modelFullName ; $ rules = $ modelName :: $ rules ; } $ validator = \ Validator :: make ( $ data , $ rules ) ; if ( $ validator -> fails ( ) ) throw new ValidationException ( $ validator ) ; return true ; }
Validate data for resource .
43,813
public function force ( $ path , $ mode = 0777 , $ recursive = true ) { if ( $ this -> exists ( $ path ) ) { return true ; } return $ this -> makeDirectory ( $ path , $ mode , $ recursive ) ; }
Alias of makeDirectory .
43,814
public function fileName ( $ filename , $ withExt = true ) { return $ withExt ? pathinfo ( $ filename , PATHINFO_BASENAME ) : pathinfo ( $ filename , PATHINFO_FILENAME ) ; }
Get filename with or not extension .
43,815
public function saveConfig ( $ group , $ environment = '' ) { $ path = config_path ( ) ; $ items = config ( $ group , [ ] ) ; $ file = ( ! $ environment || ( $ environment == 'production' ) ) ? "{$path}/{$group}.php" : "{$path}/{$environment}/{$group}.php" ; $ code = '<?php' . "\r\n\r\n" ; $ code .= 'return ' . var_export ( $ items , true ) . ';' ; $ this -> put ( $ file , $ code ) ; }
Salvar arquivo Config .
43,816
public function select ( $ table ) { $ props = call_user_func ( array ( $ this -> model_to , 'properties' ) ) ; $ i = 0 ; $ properties = array ( ) ; foreach ( $ props as $ pk => $ pv ) { $ properties [ ] = array ( $ table . '.' . $ pk , $ table . '_c' . $ i ) ; $ i ++ ; } return $ properties ; }
Should get the properties as associative array with alias = > property the table alias is given to be included with the property
43,817
public static function includeConfigFile ( $ filename , $ application = null ) { if ( empty ( $ application ) ) { $ application = Yii :: $ app ; } $ appKey = UniApplication :: appKey ( $ application ) ; if ( ! isset ( self :: $ _configFiles [ $ appKey ] [ $ filename ] ) ) { if ( is_file ( $ filename ) ) { self :: $ _configFiles [ $ appKey ] [ $ filename ] = include ( $ filename ) ; } else { throw new InvalidConfigException ( "Config file '$filename' required" ) ; } } return self :: $ _configFiles [ $ appKey ] [ $ filename ] ; }
Get save in cache and return result of include file
43,818
public static function cleanConfigFileCache ( $ application = null ) { if ( empty ( $ application ) ) { $ application = Yii :: $ app ; } $ appKey = UniApplication :: appKey ( $ application ) ; static :: $ _configFiles [ $ appKey ] = [ ] ; }
Clean included files cache
43,819
protected function write ( $ level , $ msg ) { $ time = date ( 'Y-m-d H:i:s' , time ( ) ) ; $ msg = "[" . $ time . "][" . static :: getLevelName ( $ level ) . "] " . $ msg . PHP_EOL ; if ( $ this -> debugOutput === true ) { echo $ msg ; } if ( static :: $ silent ) { return false ; } if ( ! $ this -> isAllowed ( $ level ) ) { return false ; } $ fh = fopen ( $ this -> logFile , 'a' ) ; if ( ! fwrite ( $ fh , $ msg ) ) { throw new \ Exception ( 'Failed to write to log file at ' . $ this -> logFile ) ; } return true ; }
Writes to log file .
43,820
protected static function getLevelName ( $ value ) { $ map = array_flip ( ( new \ ReflectionClass ( self :: class ) ) -> getConstants ( ) ) ; return ( array_key_exists ( $ value , $ map ) ? $ map [ $ value ] : null ) ; }
Gets the log level name by value
43,821
public static function getLevelValue ( $ name ) { $ name = strtoupper ( $ name ) ; $ map = ( new \ ReflectionClass ( self :: class ) ) -> getConstants ( ) ; return ( isset ( $ map [ $ name ] ) ) ? $ map [ $ name ] : null ; }
Gets the log level value by name
43,822
protected function error ( $ messageKey , $ value = null ) { if ( key_exists ( self :: GLOBAL_MESSAGE_KEY , $ this -> templates ) ) $ messageKey = self :: GLOBAL_MESSAGE_KEY ; if ( ! key_exists ( $ messageKey , $ this -> templates ) ) throw new Exception \ MessageTemplateDoesNotExist ( "A message template does not exist for key $messageKey" ) ; $ this -> messages [ $ messageKey ] = $ this -> buildMessage ( $ this -> templates [ $ messageKey ] , $ value ) ; }
Adds an error message to the list of errors .
43,823
private function updateMessageTemplate ( $ template , $ key ) { if ( ! key_exists ( $ messageKey , $ this -> templates ) && $ key != self :: DEFAULT_KEY ) throw new Exception \ MessageTemplateDoesNotExist ( "A message template does not exist for key $messageKey" ) ; $ this -> templates [ $ key ] = $ template ; }
Updates the message template . This overrides existing message templates .
43,824
private function getNodeContent ( \ DOMNode $ node ) { $ type = $ node -> attributes -> getNamedItem ( 'type' ) ; if ( $ type && strtolower ( $ type -> nodeValue ) == 'xhtml' ) { $ result = '' ; foreach ( $ node -> childNodes as $ childNode ) { $ result .= $ node -> ownerDocument -> save ( $ childNode ) ; } return $ result ; } else { return $ node -> nodeValue ; } }
Enable XHTML types .
43,825
public static function getInt ( array $ array , $ key , int $ default = 0 ) : int { $ key = ( string ) $ key ; if ( $ array [ $ key ] ?? 0 ) { return ( int ) $ array [ $ key ] ; } return $ default ; }
Return INT value from array
43,826
public static function getFloat ( array $ array , $ key , float $ default = 0.0 ) : float { $ key = ( string ) $ key ; if ( $ array [ $ key ] ?? 0 ) { return ( float ) $ array [ $ key ] ; } return $ default ; }
Return FLOAT value from array
43,827
public static function getString ( array $ array , $ key , string $ default = '' ) : string { $ key = ( string ) $ key ; if ( $ array [ $ key ] ?? 0 ) { return ( string ) $ array [ $ key ] ; } return $ default ; }
Return STRING value from array
43,828
public static function getBool ( array $ array , $ key , bool $ default = false ) : bool { $ key = ( string ) $ key ; if ( $ array [ $ key ] ?? 0 ) { return ( bool ) $ array [ $ key ] ; } return $ default ; }
Return BOOL value from array
43,829
protected static function swapArgs ( & $ optional , & $ swap , $ default = null , $ swap_required = true ) { $ is_swapped = false ; if ( empty ( $ swap ) && ! empty ( $ optional ) ) { $ swap = $ optional ; $ optional = $ default ; $ is_swapped = true ; } if ( $ swap_required && ! $ swap ) { if ( is_string ( $ swap_required ) ) { $ message = "Argument '{$swap_required}' is required." ; } else { $ message = "Missing argument." ; } throw new Exceptions \ InvalidArgumentException ( $ message ) ; } return $ is_swapped ; }
Swaps two values when the second is empty and the first is not
43,830
protected static function swapCallable ( & $ optional , & $ callable , $ default = null , $ callable_required = true ) { $ is_swapped = false ; if ( is_callable ( $ optional ) ) { $ callable = $ optional ; $ optional = $ default ; $ is_swapped = true ; } if ( $ callable_required && ! $ callable ) { throw new Exceptions \ InvalidArgumentException ( "A callable object is required." ) ; } return $ is_swapped ; }
Swaps two variables when the second is a callable object
43,831
protected static function throwOnInvalidArgument ( $ arg , $ type ) { $ args = func_get_args ( ) ; $ arg = array_shift ( $ args ) ; $ arg_type = gettype ( $ arg ) ; $ found = false ; foreach ( $ args as $ type ) { if ( ( in_array ( $ type , self :: $ native_php_types ) && $ arg_type == $ type ) || $ arg instanceof $ type ) { $ found = true ; break ; } } if ( ! $ found ) { throw new Exceptions \ InvalidArgumentException ( sprintf ( "Argument must be of type %s." , Arrays :: conjunct ( $ args , "or" ) ) ) ; } return true ; }
Throws an InvalidArgumentException when the argument is not one of the given types
43,832
private function parse ( ) { $ this -> parameters = [ ] ; $ this -> pathSegments = [ ] ; $ parsedUrl = parse_url ( $ this -> returnValue ) ; foreach ( $ parsedUrl as $ key => $ value ) { if ( $ key == 'query' ) { parse_str ( $ value , $ this -> parameters ) ; } elseif ( $ key == 'path' ) { $ this -> pathSegments = ( $ value ) ? explode ( '/' , ltrim ( $ value , '/' ) ) : [ ] ; } else { $ this -> { $ key } = $ value ; } } return $ this ; }
Parses the current returnValue and fills this objects properties
43,833
public function compareTo ( $ url , $ caseSensitive = true , $ includeQuery = false , $ ignoreSpecialChars = false ) { $ urlObj = $ url instanceof Url ? $ url : self :: create ( $ url ) -> decodePath ( ) ; $ urlObj2 = clone $ this ; $ urlObj2 -> decodePath ( ) ; if ( $ ignoreSpecialChars ) { $ urlObj -> tidy ( ) ; $ urlObj2 -> tidy ( ) ; } if ( ! $ includeQuery ) { $ urlObj -> parameters = [ ] ; $ urlObj2 -> parameters = [ ] ; } return $ caseSensitive ? strcmp ( $ urlObj , $ urlObj2 ) : strcasecmp ( $ urlObj , $ urlObj2 ) ; }
Checks if this url object is equal to another .
43,834
function fromObject ( $ value ) { $ this -> clear ( ) ; $ this -> orignalValue = $ this -> returnValue = ( string ) ( method_exists ( $ value , '__toString' ) ? $ value : null ) ; return $ this -> parse ( ) ; }
Create a Url instance from an object .
43,835
function fromString ( $ value ) { $ this -> clear ( ) ; $ this -> orignalValue = $ this -> returnValue = ( string ) $ value ; return $ this -> parse ( ) ; }
Create a Url instance from a string .
43,836
function fromResource ( $ value ) { $ this -> clear ( ) ; $ this -> orignalValue = $ this -> returnValue = stream_get_contents ( $ value ) ; return $ this -> parse ( ) ; }
Create a Url instance from a resource .
43,837
protected function clear ( ) { $ this -> scheme = null ; $ this -> host = null ; $ this -> port = null ; $ this -> user = null ; $ this -> pass = null ; $ this -> pathSegments = [ ] ; $ this -> parameters = [ ] ; $ this -> fragment = null ; $ this -> orignalValue = $ this -> returnValue = '' ; return $ this -> parse ( ) ; }
Empties the values of this Url
43,838
public function offsetGet ( $ offset ) { return isset ( $ this -> pathSegments [ $ offset ] ) ? $ this -> pathSegments [ $ offset ] : null ; }
Retrieve path segment
43,839
public function current ( $ includeQuery = true ) { $ url = "" ; if ( ! $ this -> serverVars && php_sapi_name ( ) == 'cli' ) { $ url = "cli" ; } else { $ url .= $ this -> currentScheme ( ) . $ this -> currentHost ( ) ; $ port = $ this -> currentPort ( ) ; if ( ! in_array ( $ port , [ false , 80 ] ) ) { $ url .= ':' . $ port ; } $ url .= $ this -> currentPath ( ) ; if ( $ includeQuery ) { $ query = $ this -> currentQuery ( ) ; if ( $ query ) { $ url .= '?' . $ query ; } } } return static :: create ( $ url ) ; }
Get the URL of current request .
43,840
public function currentPath ( ) { $ requestURI = $ this -> serverVar ( 'REQUEST_URI' ) ; $ sciptName = $ this -> serverVar ( 'SCRIPT_NAME' ) ; return rtrim ( parse_url ( $ requestURI ? : $ sciptName , PHP_URL_PATH ) , '/' ) ; }
Get the path of the current request .
43,841
public function fetch ( $ forwardCookie = true , $ contextOptions = [ ] ) { $ cookie = $ this -> serverVar ( 'HTTP_COOKIE' ) ; if ( $ forwardCookie && $ cookie !== false ) { $ cookie = [ 'http' => [ 'header' => 'Cookie: ' . $ cookie . "\r\n" ] ] ; $ contextOptions = array_merge ( $ cookie , $ contextOptions ) ; } $ context = stream_context_create ( $ contextOptions ) ; return file_get_contents ( ( string ) $ this , false , $ context ) ; }
Make a request to the URL and retieve the result as a string
43,842
public function toString ( ) { $ result = "" ; if ( $ this -> scheme ) { $ result .= $ this -> scheme . '://' ; } if ( $ this -> user ) { $ result .= $ this -> user ; if ( $ this -> pass ) { $ result .= $ this -> user ; } $ result .= '@' ; } if ( $ this -> host ) { $ result .= $ this -> host ; } if ( $ this -> port ) { $ result .= ':' . $ this -> port ; } if ( $ this -> pathSegments ) { $ result .= '/' . implode ( '/' , $ this -> pathSegments ) ; } if ( $ this -> parameters ) { $ result .= '?' . http_build_query ( $ this -> parameters ) ; } if ( $ this -> fragment ) { $ result .= '#' . $ this -> fragment ; } return $ result ; }
Gets the current URL as a string
43,843
private function normalizeArrayForNewLines ( array $ data ) { foreach ( $ data as $ k => $ item ) { if ( is_string ( $ item ) ) { $ data [ $ k ] = str_replace ( [ "\r\n" , "\n\r" , "\r" ] , "\n" , $ item ) ; } elseif ( is_array ( $ item ) ) { $ data [ $ k ] = $ this -> normalizeArrayForNewLines ( $ item ) ; } } return $ data ; }
crutch for linux and windows
43,844
public function isUseableRaikiri ( $ class ) { $ traits = [ ] ; do { $ traits = array_merge ( $ traits , class_uses ( $ class ) ) ; } while ( $ class = get_parent_class ( $ class ) ) ; foreach ( $ traits as $ trait ) { $ traits = array_merge ( $ traits , class_uses ( $ trait ) ) ; } return in_array ( 'Samurai\\Raikiri\\DependencyInjectable' , $ traits ) ; }
useable raikiri ?
43,845
public function show ( Request $ request , Evento $ evento ) { Debugbar :: info ( $ evento ) ; return view ( 'multimedia::eventos/show' , [ 'evento' => $ evento , ] ) ; }
show the given task .
43,846
protected function deploy ( $ server , $ deployer , OutputInterface $ output ) { $ plum = $ this -> getContainer ( ) -> get ( 'madalynn.plum' ) ; $ options = $ plum -> getOptions ( $ server ) ; $ dryrun = '' ; if ( isset ( $ options [ 'dry_run' ] ) && $ options [ 'dry_run' ] ) { $ dryrun = '<comment>(dry run mode)</comment>' ; } $ output -> writeln ( sprintf ( 'Starting %s to <info>%s</info> %s' , $ deployer , $ server , $ dryrun ) ) ; $ plum -> deploy ( $ server , $ deployer , $ options ) ; $ output -> writeln ( sprintf ( 'Successfully %s to <info>%s</info>' , $ deployer , $ server ) ) ; }
Deploys the application to another server using a deployer .
43,847
public function searchAction ( ) { $ numberPage = 1 ; if ( $ this -> request -> isPost ( ) ) { $ query = Criteria :: fromInput ( $ this -> di , 'Modules\User\Models\Profiles' , $ this -> request -> getPost ( ) ) ; $ this -> persistent -> searchParams = $ query -> getParams ( ) ; } else { $ numberPage = $ this -> request -> getQuery ( "page" , "int" ) ; } $ parameters = [ ] ; if ( $ this -> persistent -> searchParams ) { $ parameters = $ this -> persistent -> searchParams ; } $ profiles = Profiles :: find ( $ parameters ) ; if ( count ( $ profiles ) == 0 ) { $ this -> flash -> notice ( "The search did not find any profiles" ) ; return $ this -> dispatcher -> forward ( [ "action" => "index" ] ) ; } $ paginator = new Paginator ( [ "data" => $ profiles , "limit" => 10 , "page" => $ numberPage ] ) ; $ this -> view -> page = $ paginator -> getPaginate ( ) ; }
Searches for profiles
43,848
public function createAction ( ) { if ( $ this -> request -> isPost ( ) ) { $ profile = new Profiles ( [ 'name' => $ this -> request -> getPost ( 'name' , 'striptags' ) , 'active' => $ this -> request -> getPost ( 'active' ) ] ) ; if ( ! $ profile -> save ( ) ) { $ this -> flash -> error ( $ profile -> getMessages ( ) ) ; } else { $ this -> flash -> success ( "Profile was created successfully" ) ; } Tag :: resetInput ( ) ; } $ this -> view -> form = new ProfilesForm ( null ) ; }
Creates a new Profile
43,849
public function editAction ( $ id ) { $ profile = Profiles :: findFirstById ( $ id ) ; if ( ! $ profile ) { $ this -> flash -> error ( "Profile was not found" ) ; return $ this -> dispatcher -> forward ( [ 'action' => 'index' ] ) ; } if ( $ this -> request -> isPost ( ) ) { $ profile -> assign ( [ 'name' => $ this -> request -> getPost ( 'name' , 'striptags' ) , 'active' => $ this -> request -> getPost ( 'active' ) ] ) ; if ( ! $ profile -> save ( ) ) { $ this -> flash -> error ( $ profile -> getMessages ( ) ) ; } else { $ this -> flash -> success ( "Profile was updated successfully" ) ; } Tag :: resetInput ( ) ; } $ this -> view -> form = new ProfilesForm ( $ profile , [ 'edit' => true ] ) ; $ this -> view -> profile = $ profile ; }
Edits an existing Profile
43,850
public function deleteAction ( $ id ) { $ profile = Profiles :: findFirstById ( $ id ) ; if ( ! $ profile ) { $ this -> flash -> error ( "Profile was not found" ) ; return $ this -> dispatcher -> forward ( [ 'action' => 'index' ] ) ; } if ( ! $ profile -> delete ( ) ) { $ this -> flash -> error ( $ profile -> getMessages ( ) ) ; } else { $ this -> flash -> success ( "Profile was deleted" ) ; } return $ this -> dispatcher -> forward ( [ 'action' => 'index' ] ) ; }
Deletes a Profile
43,851
public function restoreState ( ) { if ( $ activeCurrency = $ this -> stateService -> getByKey ( self :: ACTIVE_CURRENCY_KEY ) ) { $ this -> activeCurrency = $ activeCurrency ; } }
Uses the State service to retrieve the active currency s identifier and sets the active currency .
43,852
public function convert ( Money $ amount , IdentifierInterface $ to ) { if ( ! $ toCurrency = $ this -> getCurrency ( $ to ) ) { throw new \ InvalidArgumentException ( "Currency not supported" ) ; } $ fromCurrency = $ amount -> getCurrency ( ) ; return $ amount -> multiply ( $ toCurrency -> getValue ( ) / $ fromCurrency -> getValue ( ) ) ; }
Converts amount from one currency to another using the currency s identifier
43,853
public function getNextBuildTime ( BuildInterface $ build ) { if ( $ build -> getLastBuild ( ) -> getBuildTime ( ) == null && $ build -> getStatus ( ) !== BuildInterface :: STOPPED ) { if ( ! isset ( $ this -> _nextBuildTime ) ) { $ this -> _nextBuildTime = time ( ) ; } return $ this -> _nextBuildTime ; } else { return ; } }
Calculates the next build timestamp this is a build once scheduler .
43,854
public function getAsPreviewHTML ( ) { $ html = "" ; foreach ( $ this -> getChildren ( ) as $ child ) { $ html .= $ child -> getAsPreviewHTML ( ) ; } return $ html ; }
Iterates through the document s children to return a html version in a preview context
43,855
public function chmod ( $ path , $ mod = 0777 ) { if ( $ this -> adapter instanceof Local ) { return chmod ( $ path , $ mod ) ; } return false ; }
set the chmod to the file
43,856
public function getNodes ( ) { $ nodes = array ( ) ; foreach ( $ this -> nodes [ $ this -> options [ 'rootid' ] ] -> getDescendants ( ) as $ subnode ) { $ nodes [ ] = $ subnode ; } return $ nodes ; }
Returns a flat sorted array of all node objects in the tree .
43,857
public function getNodeById ( $ id ) { if ( empty ( $ this -> nodes [ $ id ] ) ) { throw new \ InvalidArgumentException ( "Invalid node primary key $id" ) ; } return $ this -> nodes [ $ id ] ; }
Returns a single node from the tree identified by its ID .
43,858
public function getNodeByValuePath ( $ name , array $ search ) { $ findNested = function ( array $ nodes , array $ tokens ) use ( $ name , & $ findNested ) { $ token = array_shift ( $ tokens ) ; foreach ( $ nodes as $ node ) { $ nodeName = $ node -> get ( $ name ) ; if ( $ nodeName === $ token ) { if ( count ( $ tokens ) ) { return $ findNested ( $ node -> getChildren ( ) , $ tokens ) ; } else { return $ node ; } } } return null ; } ; return $ findNested ( $ this -> getRootNodes ( ) , $ search ) ; }
Returns the first node for which a specific property s values of all ancestors and the node are equal to the values in the given argument .
43,859
private function build ( array $ data ) { $ children = array ( ) ; $ this -> nodes [ $ this -> options [ 'rootid' ] ] = $ this -> createNode ( array ( 'id' => $ this -> options [ 'rootid' ] , 'parent' => null , ) ) ; foreach ( $ data as $ row ) { $ this -> nodes [ $ row [ 'id' ] ] = $ this -> createNode ( $ row ) ; if ( empty ( $ children [ $ row [ 'parent' ] ] ) ) { $ children [ $ row [ 'parent' ] ] = array ( $ row [ 'id' ] ) ; } else { $ children [ $ row [ 'parent' ] ] [ ] = $ row [ 'id' ] ; } } foreach ( $ children as $ pid => $ childids ) { foreach ( $ childids as $ id ) { if ( $ pid == $ id ) { throw new InvalidParentException ( "Node with ID $id references its own ID as parent ID" ) ; } if ( isset ( $ this -> nodes [ $ pid ] ) ) { $ this -> nodes [ $ pid ] -> addChild ( $ this -> nodes [ $ id ] ) ; } else { throw new InvalidParentException ( "Node with ID $id points to non-existent parent with ID $pid" ) ; } } } }
Core method for creating the tree
43,860
public function setRunningEnvironment ( $ running_env ) { $ running_env = ( string ) $ running_env ; if ( empty ( $ running_env ) ) { $ this -> toss ( "InvalidArgument" , "The environment name cannot be empty." ) ; } $ previous = $ this -> running_env ; $ this -> running_env = $ running_env ; if ( ! isset ( $ this -> callbacks [ $ this -> running_env ] ) ) { $ this -> setCallback ( $ this -> running_env , $ this -> getDefaultCallback ( ) ) ; } return $ previous ; }
Sets the current runtime environment
43,861
public function handle ( $ running_env = self :: DEFAULT_ENVIRONMENT , callable $ callback = null ) { $ is_handled = false ; if ( ! $ this -> is_handling && ! $ this -> last_error ) { $ this -> swapCallable ( $ running_env , $ callback , $ this -> running_env , false ) ; $ this -> setRunningEnvironment ( $ running_env ) ; if ( $ callback ) { $ this -> setCallback ( $ callback ) ; } $ this -> prev_exception_handler = set_exception_handler ( $ this -> getUncaughtExceptionHandler ( ) ) ; $ this -> prev_error_handler = set_error_handler ( $ this -> getCoreErrorHandler ( ) ) ; register_shutdown_function ( function ( ) { if ( $ error = error_get_last ( ) ) { $ this -> handleCoreError ( $ error [ "type" ] , $ error [ "message" ] , $ error [ "file" ] , $ error [ "line" ] ) ; } } ) ; $ this -> is_handling = true ; $ is_handled = true ; } return $ is_handled ; }
Starts handling errors
43,862
public function unhandle ( ) { $ is_unhandled = false ; if ( $ this -> is_handling && ! $ this -> last_error ) { if ( $ this -> prev_exception_handler ) { set_exception_handler ( $ this -> prev_exception_handler ) ; $ this -> prev_exception_handler = null ; } if ( $ this -> prev_error_handler ) { set_error_handler ( $ this -> prev_error_handler ) ; $ this -> prev_error_handler = null ; } $ this -> is_handling = false ; $ is_unhandled = true ; } return $ is_unhandled ; }
Stop handling errors
43,863
public function setCallback ( $ env , callable $ callable = null ) { $ this -> swapCallable ( $ env , $ callable , $ this -> running_env ) ; $ this -> callbacks [ $ env ] = $ callable ; if ( empty ( $ this -> errors [ $ env ] ) ) { $ this -> setCoreErrors ( $ env , self :: getDefaultCoreErrors ( ) ) ; } if ( empty ( $ this -> exceptions [ $ env ] ) ) { $ this -> setUncaughtExceptions ( $ env , self :: $ default_exceptions ) ; } return $ this ; }
Sets the callback that will be called when an error is handled
43,864
public function getCallback ( $ env = null ) { $ env = $ env ? : $ this -> running_env ; return isset ( $ this -> callbacks [ $ env ] ) ? $ this -> callbacks [ $ env ] : null ; }
Returns the callback that will be called when an error is handled
43,865
public function defaultCallback ( $ handler ) { $ exception = $ handler -> getLastError ( ) ; if ( php_sapi_name ( ) != "cli" ) { $ message = htmlspecialchars ( $ exception -> getMessage ( ) ) ; $ trace = nl2br ( htmlspecialchars ( $ exception -> getTraceAsString ( ) ) ) ; echo "<!DOCTYPE html><html><head><title>Error</title></head><body>" , "<h1>{$message}</h1><p>{$trace}</p></body><html>" ; } else { echo $ exception -> getMessage ( ) . PHP_EOL , "-----------" . PHP_EOL , $ exception -> getTraceAsString ( ) . PHP_EOL ; } }
The default error callback
43,866
public function setCoreErrors ( $ env , $ errors = 0 ) { $ this -> swapArgs ( $ env , $ errors , $ this -> running_env , false ) ; $ this -> errors [ $ env ] = $ errors ; if ( ! $ this -> getCallback ( $ env ) ) { $ this -> setCallback ( $ env , $ this -> getDefaultCallback ( ) ) ; } return $ this ; }
Sets the core errors which will be handled
43,867
public function getCoreErrors ( $ env = null ) { $ env = $ env ? : $ this -> running_env ; return isset ( $ this -> errors [ $ env ] ) ? $ this -> errors [ $ env ] : 0 ; }
Returns the core errors which are being handled
43,868
public function removeCoreError ( $ env , $ error = 0 ) { $ this -> swapArgs ( $ env , $ error , $ this -> running_env ) ; $ is_removed = false ; if ( isset ( $ this -> errors [ $ env ] ) ) { $ orig = $ this -> errors [ $ env ] ; $ this -> errors [ $ env ] = ( $ this -> errors [ $ env ] & ~ $ error ) ; $ is_removed = $ this -> errors [ $ env ] !== $ orig ; } return $ is_removed ; }
Stops handling a core error
43,869
public function setUncaughtExceptions ( $ env , array $ exceptions = [ ] ) { $ this -> swapArgs ( $ env , $ exceptions , $ this -> running_env , false ) ; $ this -> exceptions [ $ env ] = [ ] ; if ( ! empty ( $ exceptions ) ) { foreach ( $ exceptions as $ exception ) { $ this -> exceptions [ $ env ] [ ] = Objects :: getFullName ( $ exception ) ; } if ( ! $ this -> getCallback ( $ env ) ) { $ this -> setCallback ( $ env , $ this -> getDefaultCallback ( ) ) ; } } return $ this ; }
Sets the uncaught exceptions which will be handled
43,870
public function getUncaughtExceptions ( $ env = null ) { $ env = $ env ? : $ this -> running_env ; return isset ( $ this -> exceptions [ $ env ] ) ? $ this -> exceptions [ $ env ] : [ ] ; }
Returns the types of uncaught exceptions which are being handled
43,871
public function removeUncaughtException ( $ env , $ exception = null ) { $ this -> swapArgs ( $ env , $ exception , $ this -> running_env ) ; $ is_removed = false ; if ( isset ( $ this -> exceptions [ $ env ] ) ) { $ exception = Objects :: getFullName ( $ exception ) ; $ is_removed = ( bool ) Arrays :: remove ( $ this -> exceptions [ $ env ] , $ exception ) ; } return $ is_removed ; }
Stops handling an uncaught exception
43,872
public function isHandlingCoreError ( $ env , $ error = 0 ) { $ this -> swapArgs ( $ env , $ error , $ this -> running_env ) ; return isset ( $ this -> errors [ $ env ] ) && ( ( $ this -> errors [ $ env ] & $ error ) === $ error ) ; }
Returns whether errors of the given type are being handled
43,873
public function isHandlingUncaughtException ( $ env , $ exception = null ) { $ this -> swapArgs ( $ env , $ exception , $ this -> running_env ) ; $ is_handling = false ; if ( isset ( $ this -> exceptions [ $ env ] ) ) { if ( is_object ( $ exception ) ) { $ exception = Objects :: getFullName ( $ exception ) ; } foreach ( $ this -> exceptions [ $ env ] as $ e ) { if ( is_subclass_of ( $ exception , $ e ) || $ exception == $ e ) { $ is_handling = true ; break ; } } } return $ is_handling ; }
Returns whether the given exception is being handled
43,874
public function handleCoreError ( $ type , $ message , $ file , $ line ) { $ is_handled = false ; if ( $ this -> is_handling && $ this -> isHandlingCoreError ( $ type ) ) { $ exception = new Exceptions \ PHPErrorException ( $ message , $ type , $ file , $ line ) ; $ is_handled = $ this -> triggerError ( $ exception , "Core Error" ) ; } return $ is_handled ; }
Handles core errors
43,875
public function getCoreErrorHandler ( ) { return function ( $ type , $ message , $ file , $ line ) { return $ this -> handleCoreError ( $ type , $ message , $ file , $ line ) ; } ; }
Returns the callback being used to handle core errors
43,876
protected function triggerError ( Exception $ exception , $ label ) { $ this -> unhandle ( ) ; $ this -> last_error = $ exception ; if ( $ exception instanceof Exceptions \ PHPErrorException ) { $ type = Errors :: toString ( $ exception -> getCode ( ) ) ; } else { $ code = $ exception -> getCode ( ) ; $ type = get_class ( $ exception ) ; $ type = "{$type}[{$code}]" ; } $ this -> logger -> error ( '{label} {type}: "{message}" in file {file}[{line}].' , [ "label" => $ label , "type" => $ type , "message" => $ exception -> getMessage ( ) , "file" => $ exception -> getFile ( ) , "line" => $ exception -> getLine ( ) ] ) ; try { call_user_func ( $ this -> getCallback ( ) , $ this ) ; } catch ( Exception $ e ) { } return true ; }
Calls the error callback
43,877
public function onBootstrap ( $ e ) { $ eventManager = $ e -> getApplication ( ) -> getEventManager ( ) ; $ serviceManager = $ e -> getApplication ( ) -> getServiceManager ( ) ; $ options = $ serviceManager -> get ( 'dlcdoctrine_module_options' ) ; if ( $ options -> getEnableAutoFlushFinishListener ( ) ) { $ serviceManager -> get ( 'dlcdoctrine_event_finishlistener' ) -> attach ( $ eventManager ) ; } }
Registering module - specific listeners
43,878
private function generate ( ) { $ schema = [ ] ; foreach ( $ this -> getTables ( ) as $ table ) { $ schema [ $ table ] = $ this -> getTableDefinition ( $ table ) ; } ; foreach ( array_keys ( $ schema ) as $ table ) { $ constraints = $ this -> driver -> getConstraints ( $ table ) ; foreach ( $ constraints as $ constraint ) { if ( false === empty ( $ constraint [ 'REF_TABLE' ] ) ) { $ schema [ $ table ] [ 'properties' ] [ $ constraint [ 'REF_TABLE' ] ] = $ this -> mapConstraint ( $ constraint ) ; } } } return $ schema ; }
Generate database schema definition
43,879
public function get ( $ table = null ) { $ schema = $ this -> generate ( ) ; if ( $ table !== null ) { if ( isset ( $ schema [ $ table ] ) === false ) { throw new Exception ( 'Unknown table "' . $ table . '"' ) ; } $ schema = $ schema [ $ table ] ; } return $ schema ; }
Get schema definition for database or given table
43,880
public function dispatch ( Route $ route ) { $ callback = $ route -> getCallback ( ) ; $ params = array_values ( $ route -> getData ( ) ) ; if ( $ callback instanceof Closure ) { return $ this -> container -> resolveClosure ( $ callback , $ params ) ; } $ class = $ this -> container -> make ( $ callback [ 0 ] ) ; return $ this -> container -> resolveMethod ( $ class , $ callback [ 1 ] , $ params ) ; }
Get and serve the controller
43,881
public function importJournalArticles ( $ oldJournalId , $ newJournalId , $ issueIds , $ sectionIds ) { $ articleSql = "SELECT article_id FROM articles WHERE journal_id = :journal_id" ; $ articleStatement = $ this -> dbalConnection -> prepare ( $ articleSql ) ; $ articleStatement -> bindValue ( 'journal_id' , $ oldJournalId ) ; $ articleStatement -> execute ( ) ; $ articles = $ articleStatement -> fetchAll ( ) ; $ this -> importArticles ( $ articles , $ newJournalId , $ sectionIds , $ issueIds ) ; }
Imports the articles of given Journal .
43,882
public function importCitations ( $ oldArticleId , $ article ) { $ this -> consoleOutput -> writeln ( "Reading citations..." ) ; $ citationSql = "SELECT * FROM citations WHERE assoc_id = :id" ; $ citationStatement = $ this -> dbalConnection -> prepare ( $ citationSql ) ; $ citationStatement -> bindValue ( 'id' , $ oldArticleId ) ; $ citationStatement -> execute ( ) ; $ orderCounter = 0 ; $ citations = $ citationStatement -> fetchAll ( ) ; foreach ( $ citations as $ pkpCitation ) { $ citation = new Citation ( ) ; $ citation -> setRaw ( ! empty ( $ pkpCitation [ 'raw_citation' ] ) ? $ pkpCitation [ 'raw_citation' ] : '-' ) ; $ citation -> setOrderNum ( ! empty ( $ pkpCitation [ 'seq' ] ) ? $ pkpCitation [ 'seq' ] : $ orderCounter ) ; $ article -> addCitation ( $ citation ) ; $ orderCounter ++ ; } }
Imports citations of the given article .
43,883
public function importAuthors ( $ oldArticleId , $ article ) { $ this -> consoleOutput -> writeln ( "Reading authors..." ) ; $ authorSql = "SELECT first_name, last_name, email, seq FROM authors " . "WHERE submission_id = :id ORDER BY first_name, last_name, email" ; $ authorStatement = $ this -> dbalConnection -> prepare ( $ authorSql ) ; $ authorStatement -> bindValue ( 'id' , $ oldArticleId ) ; $ authorStatement -> execute ( ) ; $ authors = $ authorStatement -> fetchAll ( ) ; foreach ( $ authors as $ pkpAuthor ) { $ author = new Author ( ) ; $ author -> setCurrentLocale ( 'en' ) ; $ author -> setFirstName ( ! empty ( $ pkpAuthor [ 'first_name' ] ) ? $ pkpAuthor [ 'first_name' ] : '-' ) ; $ author -> setLastName ( ! empty ( $ pkpAuthor [ 'last_name' ] ) ? $ pkpAuthor [ 'last_name' ] : '-' ) ; $ author -> setEmail ( ! empty ( $ pkpAuthor [ 'email' ] ) && $ pkpAuthor [ 'email' ] !== '-' ? $ pkpAuthor [ 'email' ] : 'author@example.com' ) ; $ articleAuthor = new ArticleAuthor ( ) ; $ articleAuthor -> setAuthor ( $ author ) ; $ articleAuthor -> setArticle ( $ article ) ; $ articleAuthor -> setAuthorOrder ( ! empty ( $ pkpAuthor [ 'seq' ] ) ? $ pkpAuthor [ 'seq' ] : 0 ) ; } }
Imports authors of the given article .
43,884
private function fork ( ) { $ logger = $ this -> getContainer ( ) -> get ( 'logger' ) ; if ( ! $ this -> getContainer ( ) -> get ( 'tenside.config' ) -> isForkingAvailable ( ) ) { $ logger -> warning ( 'Forking disabled by configuration, execution will block until the command has finished.' ) ; return false ; } elseif ( ! FunctionAvailabilityCheck :: isFunctionEnabled ( 'pcntl_fork' , 'pcntl' ) ) { $ logger -> warning ( 'pcntl_fork() is not available, execution will block until the command has finished.' ) ; return false ; } else { $ pid = pcntl_fork ( ) ; if ( - 1 === $ pid ) { throw new \ RuntimeException ( 'pcntl_fork() returned -1.' ) ; } elseif ( 0 !== $ pid ) { $ logger -> info ( 'Forked process ' . posix_getpid ( ) . ' to pid ' . $ pid ) ; return true ; } $ logger -> info ( 'Processing task in forked process with pid ' . posix_getpid ( ) ) ; return false ; } }
Try to fork .
43,885
function resolve_url ( $ base , $ url ) { if ( ! strlen ( $ base ) ) return $ url ; if ( ! strlen ( $ url ) ) return $ base ; if ( preg_match ( '!^[a-z]+:!i' , $ url ) ) return $ url ; $ base = parse_url ( $ base ) ; if ( $ url { 0 } == "#" ) { $ base [ 'fragment' ] = substr ( $ url , 1 ) ; return Page :: unparse_url ( $ base ) ; } unset ( $ base [ 'fragment' ] ) ; unset ( $ base [ 'query' ] ) ; if ( substr ( $ url , 0 , 2 ) == "//" ) { return Page :: unparse_url ( array ( 'scheme' => $ base [ 'scheme' ] , 'path' => $ url , ) ) ; } else if ( $ url { 0 } == "/" ) { $ base [ 'path' ] = $ url ; } else { $ path = explode ( '/' , $ base [ 'path' ] ) ; $ url_path = explode ( '/' , $ url ) ; array_pop ( $ path ) ; $ end = array_pop ( $ url_path ) ; foreach ( $ url_path as $ segment ) { if ( $ segment == '.' ) { } else if ( $ segment == '..' && $ path && $ path [ sizeof ( $ path ) - 1 ] != '..' ) { array_pop ( $ path ) ; } else { $ path [ ] = $ segment ; } } if ( $ end == '.' ) { $ path [ ] = '' ; } else if ( $ end == '..' && $ path && $ path [ sizeof ( $ path ) - 1 ] != '..' ) { $ path [ sizeof ( $ path ) - 1 ] = '' ; } else { $ path [ ] = $ end ; } $ base [ 'path' ] = join ( '/' , $ path ) ; } return Page :: unparse_url ( $ base ) ; }
Resolve a URL relative to a base path . This happens to work with POSIX filenames as well . This is based on RFC 2396 section 5 . 2 .
43,886
public function getIdentifier ( ) { $ firstOctet = $ this -> getType ( ) ; if ( Identifier :: isLongForm ( $ firstOctet ) ) { throw new LogicException ( sprintf ( 'Identifier of %s uses the long form and must therefor override "Object::getIdentifier()".' , get_class ( $ this ) ) ) ; } return chr ( $ firstOctet ) ; }
Returns all identifier octets . If an inheriting class models a tag with the long form identifier format it MUST reimplement this method to return all octets of the identifier .
43,887
public function get ( $ key ) { $ getResult = $ this -> getValue ( $ key ) ; $ unserialized = @ unserialize ( $ getResult ) ; if ( Util :: hasInternalExpireTime ( $ unserialized ) ) { $ getResult = $ unserialized [ 'v' ] ; } return $ getResult ; }
Gets the value of a key .
43,888
public function newAction ( StockTransfer $ stockTransfer ) { $ stocktransferitem = new StockTransferItem ( ) ; $ stocktransferitem -> setStockTransfer ( $ stockTransfer ) ; $ form = $ this -> createForm ( new StockTransferItemType ( ) , $ stocktransferitem ) ; return array ( 'stocktransferitem' => $ stocktransferitem , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new StockTransferItem entity .
43,889
public function createAction ( Request $ request ) { $ stocktransferitem = new StockTransferItem ( ) ; $ form = $ this -> createForm ( new StockTransferItemType ( ) , $ stocktransferitem ) ; if ( $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ stocktransferitem ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_transfers_show' , array ( 'id' => $ stocktransferitem -> getStockTransfer ( ) -> getId ( ) , ) ) ) ; } return array ( 'stocktransferitem' => $ stocktransferitem , 'form' => $ form -> createView ( ) , ) ; }
Creates a new StockTransferItem entity .
43,890
public function editAction ( StockTransferItem $ stocktransferitem ) { $ editForm = $ this -> createForm ( new StockTransferItemType ( ) , $ stocktransferitem , array ( 'action' => $ this -> generateUrl ( 'stock_transfersitem_update' , array ( 'id' => $ stocktransferitem -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; $ deleteForm = $ this -> createDeleteForm ( $ stocktransferitem -> getId ( ) , 'stock_transfersitem_delete' ) ; return array ( 'stocktransferitem' => $ stocktransferitem , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Displays a form to edit an existing StockTransferItem entity .
43,891
public function updateAction ( StockTransferItem $ stocktransferitem , Request $ request ) { $ editForm = $ this -> createForm ( new StockTransferItemType ( ) , $ stocktransferitem , array ( 'action' => $ this -> generateUrl ( 'stock_transfersitem_update' , array ( 'id' => $ stocktransferitem -> getid ( ) ) ) , 'method' => 'PUT' , ) ) ; if ( $ editForm -> handleRequest ( $ request ) -> isValid ( ) ) { $ this -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'stock_transfersitem_show' , array ( 'id' => $ stocktransferitem -> getId ( ) ) ) ) ; } $ deleteForm = $ this -> createDeleteForm ( $ stocktransferitem -> getId ( ) , 'stock_transfersitem_delete' ) ; return array ( 'stocktransferitem' => $ stocktransferitem , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Edits an existing StockTransferItem entity .
43,892
private function processNode ( array $ node ) : array { $ config = [ ] ; foreach ( $ node as $ name => $ value ) { if ( \ preg_match ( '/^num__([0-9]+)$/' , $ name , $ matches ) ) { $ name = $ matches [ 1 ] ; } if ( \ count ( $ nameEx = \ explode ( '.' , $ name ) ) > 1 ) { $ name = \ array_shift ( $ nameEx ) ; $ mergeBase = isset ( $ config [ $ name ] ) ? $ config [ $ name ] : [ ] ; $ mergeWith = $ this -> processNode ( [ \ implode ( '.' , $ nameEx ) => $ value ] ) ; $ config [ $ name ] = \ array_merge_recursive ( $ mergeBase , $ mergeWith ) ; } elseif ( \ is_array ( $ value ) ) { $ config [ $ name ] = $ this -> processNode ( $ value ) ; } else { $ config [ $ name ] = $ this -> castValue ( ( string ) $ value ) ; } } return $ config ; }
Processes INI config node
43,893
private function castValue ( string $ value ) { $ value = $ this -> normalize ( $ value ) ; if ( \ preg_match ( '/^[0-9]+$/' , $ value ) ) { $ value = ( int ) $ value ; } elseif ( \ preg_match ( '/^[0-9\.]+$/' , $ value ) ) { $ value = ( float ) $ value ; } elseif ( \ preg_match ( '/^true|false$/' , $ value ) ) { $ value = $ value === 'true' ? true : false ; } return $ value ; }
Casts value to a specified type
43,894
private function normalize ( string $ string ) : string { return \ str_replace ( $ this -> normalizeFrom , $ this -> normalizeTo , $ string ) ; }
Changes some characters from their utf - 8 to normal representation
43,895
public function hydrate ( $ document , $ data , array $ hints = array ( ) ) { $ metadata = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; if ( ! empty ( $ metadata -> lifecycleCallbacks [ Events :: preLoad ] ) ) { $ args = array ( & $ data ) ; $ metadata -> invokeLifecycleCallbacks ( Events :: preLoad , $ document , $ args ) ; } if ( $ this -> evm -> hasListeners ( Events :: preLoad ) ) { $ this -> evm -> dispatchEvent ( Events :: preLoad , new PreLoadEventArgs ( $ document , $ this -> dm , $ data ) ) ; } if ( ! empty ( $ metadata -> alsoLoadMethods ) ) { foreach ( $ metadata -> alsoLoadMethods as $ method => $ fieldNames ) { foreach ( $ fieldNames as $ fieldName ) { if ( array_key_exists ( $ fieldName , $ data ) ) { $ document -> $ method ( $ data [ $ fieldName ] ) ; continue 2 ; } } } } $ data = $ this -> getHydratorFor ( $ metadata -> name ) -> hydrate ( $ document , $ data , $ hints ) ; if ( $ document instanceof Proxy ) { $ document -> __isInitialized__ = true ; } if ( ! empty ( $ metadata -> lifecycleCallbacks [ Events :: postLoad ] ) ) { $ metadata -> invokeLifecycleCallbacks ( Events :: postLoad , $ document ) ; } if ( $ this -> evm -> hasListeners ( Events :: postLoad ) ) { $ this -> evm -> dispatchEvent ( Events :: postLoad , new LifecycleEventArgs ( $ document , $ this -> dm ) ) ; } return $ data ; }
Hydrate array of MongoDB document data into the given document object .
43,896
public function isEmailAddressPrimaryType ( $ emailID ) { if ( ! Config :: get ( 'lasallecrmlistmanagement.listmgmt_emails_in_list_primary_type_only' ) ) { return false ; } if ( $ this -> getEmailType ( $ emailID ) != 1 ) { return false ; } return true ; }
Is the email type primary AND must we accept primary type only?
43,897
public static function bit16 ( string $ data , int $ offset = 0 , $ endianness = false ) : int { if ( true === $ endianness ) { return unpack ( 'n' , $ data , $ offset ) [ 1 ] ; } if ( false === $ endianness ) { return unpack ( 'v' , $ data , $ offset ) [ 1 ] ; } if ( null === $ endianness ) { return unpack ( 'S' , $ data , $ offset ) [ 1 ] ; } }
Read an unsigned 16 bit integer .
43,898
public static function bit64 ( string $ data , int $ offset = 0 , bool $ endianness = false ) : int { if ( true === $ endianness ) { return unpack ( 'J' , $ data , $ offset ) [ 1 ] ; } if ( false === $ endianness ) { return unpack ( 'P' , $ data , $ offset ) [ 1 ] ; } if ( null === $ endianness ) { return unpack ( 'Q' , $ data , $ offset ) [ 1 ] ; } }
Read an unsigned 64 bit integer .
43,899
public function row ( & $ material , Pager & $ pager = null , $ module = NULL ) { $ tdHTML = '' ; $ input = null ; foreach ( $ this -> fields as $ field ) { foreach ( $ material -> onetomany [ '_materialfield' ] as $ materialField ) { $ isRightField = $ materialField -> FieldID == $ field -> FieldID ; $ isRightLocale = $ materialField -> locale == $ this -> locale ; $ isNotLocalizedField = $ materialField -> locale == '' ; if ( $ isRightField && ( ( $ isRightLocale ) || ( $ isNotLocalizedField ) ) ) { $ this -> headerFields [ $ field -> id ] = $ field ; if ( $ field -> Type < 9 || $ field -> Type > 10 ) { $ input = m ( 'samsoncms_input_application' ) -> createFieldByType ( $ this -> dbQuery , $ field -> Type , $ materialField ) ; } if ( $ field -> Type == 4 ) { $ input -> build ( $ field -> Value ) ; } \ samsonphp \ event \ Event :: fire ( 'samson.cms.input.table.render' , array ( $ input ) ) ; $ tdHTML .= $ this -> renderModule -> view ( 'table/tdView' ) -> set ( $ input , 'input' ) -> output ( ) ; break ; } } } return $ this -> renderModule -> view ( $ this -> row_tmpl ) -> set ( m ( 'samsoncms_input_text_application' ) -> createField ( $ this -> dbQuery , $ material , 'Url' ) , 'materialName' ) -> set ( $ material -> id , 'materialID' ) -> set ( $ material -> priority , 'priority' ) -> set ( $ material -> parent_id , 'parentID' ) -> set ( $ this -> structure -> StructureID , 'structureId' ) -> set ( $ tdHTML , 'td_view' ) -> set ( $ pager , 'pager' ) -> output ( ) ; }
Function to view table row