idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
15,200
protected function populatePreviousData ( Form $ form ) { $ prepops = EventAttendee :: config ( ) -> prepopulated_fields ; if ( ! $ prepops ) { return ; } $ latestattendee = $ this -> registration -> Attendees ( ) -> sort ( "LastEdited" , "DESC" ) -> first ( ) ; if ( $ latestattendee ) { $ form -> loadDataFrom ( $ latestattendee , Form :: MERGE_DEFAULT , $ prepops ) ; } }
poplate given form with specfific data from last attednee
15,201
public function edit ( $ request ) { $ attendee = $ this -> registration -> Attendees ( ) -> byID ( $ request -> param ( 'ID' ) ) ; if ( ! $ attendee ) { return $ this -> httpError ( 404 , "Attendee not found" ) ; } $ form = $ this -> AttendeeForm ( ) ; $ ticket = $ attendee -> Ticket ( ) ; if ( ! $ ticket -> exists ( ) ) { $ form -> setAllowedTickets ( $ this -> registration -> Event ( ) -> getAvailableTickets ( ) ) ; } if ( ! $ form -> hasSessionData ( ) ) { $ form -> loadDataFrom ( $ attendee ) ; } $ form -> getValidator ( ) -> addRequiredField ( "ID" ) ; $ this -> extend ( "onEdit" , $ form , $ attendee , $ this -> registration ) ; return array ( 'Title' => $ attendee -> Ticket ( ) -> Title , 'Form' => $ form ) ; }
Edit action renders the attendee form populated with existing details .
15,202
public function save ( $ data , $ form ) { $ attendeeid = $ form -> Fields ( ) -> fieldByName ( "ID" ) -> dataValue ( ) ; $ attendee = $ this -> registration -> Attendees ( ) -> byID ( ( int ) $ attendeeid ) ; if ( $ attendee && $ attendee -> TicketID && $ attendee -> TicketID != $ data [ 'TicketID' ] ) { $ form -> sessionMessage ( 'You cannot change the ticket' , 'bad' ) ; return $ this -> redirectBack ( ) ; } if ( ! $ attendee ) { $ attendee = $ this -> createAttendee ( ) ; } $ form -> saveInto ( $ attendee ) ; $ attendee -> write ( ) ; $ this -> registration -> calculateTotal ( ) ; $ this -> registration -> write ( ) ; $ this -> extend ( "onSave" , $ attendee , $ this -> registration ) ; return $ this -> redirect ( $ this -> NextURL ) ; }
Save new and edited attendees
15,203
protected function createAttendee ( ) { $ attendee = EventAttendee :: create ( ) ; $ attendee -> RegistrationID = $ this -> registration -> ID ; return $ attendee ; }
Helper for creating new attendee on registration .
15,204
public static function convertGDRessourceToImagick ( $ imgRessource , $ png = false ) { ob_start ( ) ; if ( $ png ) { imagepng ( $ imgRessource , null , 0 ) ; } else { imagejpeg ( $ imgRessource , null , 100 ) ; } $ blob = ob_get_clean ( ) ; $ image = new \ Imagick ( ) ; $ image -> readImageBlob ( $ blob ) ; return $ image ; }
Convertit une ressource image GD en objet Imagick
15,205
public static function convertImagickToGDRessource ( \ Imagick $ imagick , $ png = false ) { $ imagick -> setImageFormat ( 'png' ) ; $ data = $ imagick -> getimageblob ( ) ; $ im = imagecreatefromstring ( $ data ) ; if ( $ png ) { imagealphablending ( $ im , true ) ; imagesavealpha ( $ im , true ) ; } return $ im ; }
Convertir un objet Imagick en ressource image GD
15,206
public static function setEvents ( $ pEvents = NULL ) { if ( $ pEvents === NULL ) { $ pEvents = Agl :: app ( ) -> getConfig ( 'main/events' ) ; } if ( is_array ( $ pEvents ) ) { self :: $ _events = $ pEvents ; } else { self :: $ _events = array ( ) ; } return self :: $ _events ; }
Register events . Get events from the configuration by default .
15,207
public function findElementtypeByUniqueId ( $ uniqueId ) { foreach ( $ this -> elementtypeManager -> findAll ( ) as $ elementtype ) { if ( $ elementtype -> getUniqueId ( ) === $ uniqueId ) { return $ elementtype ; } } return null ; }
Find element type by unique id .
15,208
public function findElementtypeByType ( $ type ) { $ elementtypes = [ ] ; foreach ( $ this -> elementtypeManager -> findAll ( ) as $ elementtype ) { if ( $ elementtype -> getType ( ) === $ type ) { $ elementtypes [ ] = $ elementtype ; } } return $ elementtypes ; }
Find element type by type .
15,209
public function createElementtype ( $ type , $ uniqueId , $ name , $ icon , ElementtypeStructure $ elementtypeStructure = null , array $ mappings = null , $ user , $ flush = true ) { if ( ! $ icon ) { $ icons = [ Elementtype :: TYPE_FULL => 'artikel_list.gif' , Elementtype :: TYPE_STRUCTURE => 'nav_haupt.gif' , Elementtype :: TYPE_LAYOUTAREA => '_fallback.gif' , Elementtype :: TYPE_LAYOUTCONTAINER => '_fallback.gif' , Elementtype :: TYPE_PART => 'teaser_hellblau_list.gif' , Elementtype :: TYPE_REFERENCE => '_fallback.gif' , ] ; $ icon = $ icons [ $ type ] ; } $ elementtype = new Elementtype ( ) ; $ elementtype -> setUniqueId ( $ uniqueId ) -> setType ( $ type ) -> setTitle ( 'de' , $ name ) -> setTitle ( 'en' , $ name ) -> setIcon ( $ icon ) -> setRevision ( 1 ) -> setStructure ( $ elementtypeStructure ) -> setMappings ( $ mappings ) -> setCreateUser ( $ user ) -> setCreatedAt ( new \ DateTime ( ) ) -> setModifyUser ( $ elementtype -> getCreateUser ( ) ) -> setModifiedAt ( $ elementtype -> getCreatedAt ( ) ) ; $ this -> elementtypeManager -> updateElementtype ( $ elementtype ) ; return $ elementtype ; }
Create a new empty Element Type .
15,210
public function duplicateElementtype ( Elementtype $ sourceElementtype , $ user ) { $ elementtype = clone $ sourceElementtype ; $ uniqId = uniqid ( ) ; foreach ( $ elementtype -> getTitles ( ) as $ language => $ title ) { $ elementtype -> setTitle ( $ language , $ title . ' - copy - ' . $ uniqId ) ; } $ elementtypeStructure = new ElementtypeStructure ( ) ; $ elementtype -> setId ( null ) -> setUniqueId ( $ elementtype -> getUniqueId ( ) . '-' . $ uniqId ) -> setRevision ( 1 ) -> setStructure ( $ elementtypeStructure ) -> setCreatedAt ( new \ DateTime ( ) ) -> setCreateUser ( $ user ) ; $ rii = new \ RecursiveIteratorIterator ( $ sourceElementtype -> getStructure ( ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; $ dsIdMap = [ ] ; foreach ( $ rii as $ sourceNode ) { if ( $ sourceNode -> isReferenced ( ) ) { continue ; } $ node = clone $ sourceNode ; $ dsIdMap [ $ sourceNode -> getDsId ( ) ] = $ dsId = UuidUtil :: generate ( ) ; $ parentDsId = null ; if ( ! $ sourceNode -> isRoot ( ) ) { $ parentDsId = $ dsIdMap [ $ sourceNode -> getParentNode ( ) -> getDsId ( ) ] ; } $ node -> setDsId ( $ dsId ) -> setParentDsId ( $ parentDsId ) ; $ elementtypeStructure -> addNode ( $ node ) ; } $ mappings = $ elementtype -> getMappings ( ) ; foreach ( $ mappings as $ mappingIndex => $ mapping ) { foreach ( $ mapping [ 'fields' ] as $ mappingFieldIndex => $ mapingField ) { if ( isset ( $ dsIdMap [ $ mapingField [ 'dsId' ] ] ) ) { $ mappings [ $ mappingIndex ] [ 'fields' ] [ $ mappingFieldIndex ] [ 'dsId' ] = $ dsIdMap [ $ mapingField [ 'dsId' ] ] ; } } } $ elementtype -> setMappings ( $ mappings ) ; $ this -> elementtypeManager -> updateElementtype ( $ elementtype ) ; return $ elementtype ; }
Duplicate an elementtype .
15,211
public function parseIntelligent ( $ value ) { $ functions = [ "parseNumeric" , "parseBoolean" , "parseString" ] ; foreach ( $ functions as $ function ) { try { return call_user_func ( [ $ this , $ function ] , $ value ) ; } catch ( ParseException $ e ) { } } $ exportValue = var_export ( $ value , true ) ; throw new ParseException ( "'$exportValue' could not be parsed by any parser" ) ; }
Gets a raw value land tries to parse it in several ways . When it found a function that can parse the given value it will return immediately instead of trying to parse it with one of the possible functions left .
15,212
public function parseNumeric ( $ value ) { if ( is_numeric ( $ value ) ) { return $ value + 0 ; } $ exportValue = var_export ( $ value , true ) ; throw new ParseException ( "'$exportValue' could not be parsed as a number" ) ; }
Make this numeric element a number of the correct type .
15,213
public function parseString ( $ value ) { if ( is_string ( $ value ) ) { return $ value ; } $ exportValue = var_export ( $ value , true ) ; throw new ParseException ( "'$exportValue' can not be parsed as a string" ) ; }
Tests if the given value is of type string
15,214
public function getResultObject ( array $ result_array ) { $ result_object = array ( ) ; foreach ( $ result_array as $ key => $ value ) { $ result_object [ ] = ( object ) $ value ; } return ( object ) $ result_object ; }
This method sets the resultset in object format
15,215
public function getClient ( ) { if ( $ this -> client ) { return $ this -> client ; } $ this -> client = new Client ( self :: BASE_URL ) ; return $ this -> client ; }
Get the client used to query Pocket .
15,216
public function findRelatedIssuesByRepository ( RepositoryInterface $ repository , $ shortName , $ numericId ) { $ repositoryIds = [ ] ; foreach ( $ repository -> getProjects ( ) as $ project ) { $ repositoryIds [ ] = $ project -> getId ( ) ; } $ queryBuilder = $ this -> repository -> createQueryBuilder ( 'i' ) -> leftJoin ( 'i.project' , 'p' ) ; $ this -> addCriteria ( $ queryBuilder , [ 'in' => [ 'i.project' => $ repositoryIds ] , 'p.shortName' => $ shortName , 'i.numericId' => $ numericId , ] ) ; return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Finds related issues of repository short name and numeric id given .
15,217
public function tick ( $ class , array $ params = array ( ) , $ usernameid = NULL , $ decrement = false ) { if ( empty ( $ class ) ) : return false ; endif ; $ handler = new File ( ) ; $ file = date ( "Y-m-d" ) . ".log" ; $ folder = PATH_LOGS . DS . $ class . DS ; if ( ! $ handler -> isFile ( $ folder . $ file ) ) { if ( ! $ handler -> create ( $ folder . $ file , "a+" ) ) { throw new Exception ( "Could not create the log file {$file}" ) ; return false ; } } unset ( $ params [ "file" ] ) ; $ tick = array_merge ( array ( "time" => time ( ) , "inc" => ( ! $ decrement ) ? "+1" : "-1" ) , $ params ) ; $ line = json_encode ( $ tick ) ; if ( ! $ handler -> write ( $ folder . $ file , PHP_EOL . $ line , "a+" ) ) { throw new Exception ( "Could not write out to the stats file {$file}" ) ; return false ; } return true ; }
Ticks a user performed action
15,218
protected function identity ( ) { if ( null === $ this -> identity ) { $ authenticationService = $ this -> getServiceLocator ( ) -> get ( 'Zend\Authentication\AuthenticationService' ) ; if ( ! $ authenticationService -> hasIdentity ( ) ) { throw new \ Exception ( 'No identity loaded' ) ; } $ this -> identity = $ authenticationService -> getIdentity ( ) ; } return $ this -> identity ; }
Get the current identity
15,219
protected function save ( $ successMessage , $ failureMessage ) { try { $ this -> getEntityManager ( ) -> flush ( ) ; $ this -> addMessage ( $ successMessage , FlashMessenger :: NAMESPACE_SUCCESS ) ; return true ; } catch ( \ Exception $ e ) { $ this -> addMessage ( $ failureMessage , FlashMessenger :: NAMESPACE_ERROR ) ; if ( $ e instanceof \ Doctrine \ DBAL \ DBALException ) { $ previous = $ e -> getPrevious ( ) ; if ( $ previous instanceof \ Doctrine \ DBAL \ Driver \ Mysqli \ MysqliException ) { switch ( $ previous -> getCode ( ) ) { case 1062 : $ this -> addMessage ( 'You are using details that already exist.' , 'error' ) ; return false ; } } } throw new \ Exception ( 'You are seeing this because this error needs to be properly handled.' , 0 , $ e ) ; return false ; } }
Flush the entityManager and handle errors
15,220
public function createAction ( Request $ request ) { $ entity = new Collection ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_collection_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Creates a new Collection entity .
15,221
private function createCreateForm ( Collection $ entity ) { $ form = $ this -> createForm ( $ this -> get ( 'amulen.classification.form.collection' ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_collection_create' ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Create' ) ) ; return $ form ; }
Creates a form to create a Collection entity .
15,222
public function newAction ( ) { $ entity = new Collection ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new Collection entity .
15,223
public function addInterceptors ( array $ interceptors ) { foreach ( $ interceptors as $ interceptor ) { if ( $ interceptor instanceof HandlerInterceptor ) { array_push ( $ this -> interceptors , $ interceptor ) ; } } }
Add a list of HandlerInterceptor instances to the end of this chain
15,224
public function applyPreHandle ( ServletRequestInterface $ request , ServletResponseInterface $ response ) { $ interceptors = $ this -> getInterceptors ( ) ; if ( ! empty ( $ interceptors ) ) { for ( $ i = 0 ; $ i < count ( $ interceptors ) ; $ i ++ ) { $ interceptor = $ interceptors [ $ i ] ; if ( ! $ interceptor -> preHandle ( $ request , $ response , $ this -> handler ) ) { $ this -> triggerAfterCompletion ( $ request , $ response , null ) ; return false ; } $ this -> interceptorIndex = $ i ; } } return true ; }
Apply preHandle methods of registered interceptors
15,225
public function applyPostHandle ( ServletRequestInterface $ request , ServletResponseInterface $ response , ModelAndView $ model ) { $ interceptors = $ this -> getInterceptors ( ) ; if ( ! empty ( $ interceptors ) ) { for ( $ i = $ this -> interceptorIndex ; $ i >= 0 ; $ i -- ) { $ interceptor = $ interceptors [ $ i ] ; $ interceptor -> postHandle ( $ request , $ response , $ this -> handler , $ model ) ; } } }
Applies postHandle methods of registered interceptors
15,226
public function triggerAfterCompletion ( ServletRequestInterface $ request , ServletResponseInterface $ response , \ Exception $ ex ) { $ interceptors = $ this -> getInterceptors ( ) ; if ( ! empty ( $ interceptors ) ) { for ( $ i = $ this -> interceptorIndex ; $ i >= 0 ; $ i -- ) { $ interceptor = $ interceptors [ $ i ] ; try { $ interceptor -> afterCompletion ( $ request , $ response , $ this -> handler ) ; } catch ( \ Exception $ exc ) { } } } }
Applies afterCompletion methods of registered interceptors
15,227
public function getConnectionString ( ) { $ connection_string = array ( ) ; $ type = $ this -> getType ( ) ; array_push ( $ connection_string , $ type ) ; if ( $ type == self :: SQLite ) { $ filename = 'db.sqlite' ; if ( isset ( $ this -> properties [ 'filename' ] ) ) $ filename = $ this -> properties [ 'filename' ] ; array_push ( $ connection_string , ":$filename" ) ; } else { array_push ( $ connection_string , ':host=' ) ; array_push ( $ connection_string , ( isset ( $ this -> properties [ 'host' ] ) ) ? $ this -> properties [ 'host' ] : 'localhost' ) ; array_push ( $ connection_string , ';dbname=' ) ; array_push ( $ connection_string , ( isset ( $ this -> properties [ 'name' ] ) ) ? $ this -> properties [ 'name' ] : null ) ; } array_push ( $ connection_string , ';charset=' ) ; array_push ( $ connection_string , $ this -> getCharset ( ) ) ; return implode ( $ connection_string ) ; }
ritorna la stringa di connessione per interfaccia pdo
15,228
public function execute ( ) { $ query = $ this -> factory -> builder ( $ this -> insert ) -> process ( ) ; $ result = $ this -> pdo -> query ( $ query ) ; if ( ! $ result ) { throw new \ Exception ( 'An error is while the insertion occurred! (query: "' . $ query . '")' ) ; } return $ this -> pdo -> lastInsertId ( ) ; }
Execute the query and insert the expected entries in the database .
15,229
public function columns ( array $ columns ) { $ columnsArray = array ( ) ; foreach ( $ columns as $ column ) { $ columnsArray [ ] = $ this -> factory -> references ( 'Column' , $ column ) ; } $ this -> insert -> columns ( $ columnsArray ) ; return $ this ; }
Set columns to the query in which should insert new entries . Afterwards the value method should call to set the values .
15,230
public function values ( array $ values ) { $ valuesArray = array ( ) ; foreach ( $ values as $ value ) { $ valuesArray [ ] = $ this -> factory -> references ( 'Value' , $ value ) ; } $ this -> insert -> values ( $ valuesArray ) ; return $ this ; }
Set values to the query . The method can execute multiple times . The passed array require the same amount of elements otherwise an exception will thrown .
15,231
protected function renderTemplate ( ConfigGroup $ group = null ) { $ adminPool = $ this -> container -> get ( 'sonata.admin.pool' ) ; return $ this -> render ( 'VinceTAdminConfigurationBundle:Configuration:index.html.twig' , array ( 'configuration_menu' => $ this -> createMenu ( ) , 'group' => $ group , 'form' => $ this -> createConfigGroupForm ( $ group ) -> createView ( ) , 'admin_section' => $ adminPool -> getAdminByAdminCode ( 'admin.configuration.admin.configsection' ) , 'admin_group' => $ adminPool -> getAdminByAdminCode ( 'admin.configuration.admin.configgroup' ) , 'admin_value' => $ adminPool -> getAdminByAdminCode ( 'admin.configuration.admin.configvalue' ) , 'admin_type' => $ adminPool -> getAdminByAdminCode ( 'admin.configuration.admin.configtype' ) , ) ) ; }
Render the main template
15,232
protected function createConfigGroupForm ( ConfigGroup $ group = null ) { $ formBuilder = $ this -> createFormBuilder ( ) ; if ( $ group ) { $ values = $ this -> container -> get ( 'admin.configuration.configvalue_manager' ) -> getRepository ( ) -> findByConfigGroupId ( $ group -> getId ( ) ) ; foreach ( $ values as $ configValue ) { $ sub = $ this -> container -> get ( 'form.factory' ) -> createNamedBuilder ( str_replace ( ':' , ' ' , $ configValue -> getPath ( ) ) , 'admin_configuration_configvalue_' . $ configValue -> getConfigType ( ) -> getFormType ( ) , $ configValue ) ; $ formBuilder -> add ( $ sub ) ; } } return $ formBuilder -> getForm ( ) ; }
Create the form for all values in group
15,233
private function generateRolesAndPermissions ( ) { if ( empty ( $ this -> aclData ) ) { $ this -> error ( 'empty roles and permissions in "generateRolesAndPermissions" method' ) ; return ; } foreach ( $ this -> aclData as $ acl ) { $ this -> createPermissions ( $ acl [ 'acl' ] ) ; $ this -> createRoles ( $ acl [ 'acl' ] ) ; } $ this -> createRolesPermissions ( $ this -> aclData ) ; }
Create roles permissions and roles_permissions
15,234
private function createRolesPermissions ( array $ aclData ) { $ allRolesActions = $ this -> extractAllActions ( $ aclData ) ; $ uncheckedActionsOutput = [ ] ; foreach ( $ this -> rolesList as $ roleRecord ) { $ roleRecord -> load ( 'permissions' ) ; $ currentRolePermissions = $ roleRecord -> permissions -> pluck ( 'action' ) -> toArray ( ) ; if ( count ( $ currentRolePermissions ) ) { $ uncheckedActions = array_diff ( $ allRolesActions [ $ roleRecord -> slug ] , $ currentRolePermissions ) ; if ( ! empty ( $ uncheckedActions ) ) { $ uncheckedActionsOutput [ ] = [ $ roleRecord -> name , implode ( "\n" , $ uncheckedActions ) ] ; } continue ; } $ permissions = Permissions :: whereIn ( 'action' , $ allRolesActions [ $ roleRecord -> slug ] ) -> get ( ) ; $ roleRecord -> permissions ( ) -> sync ( $ permissions -> pluck ( 'id' ) ) ; } if ( $ uncheckedActionsOutput ) { $ this -> table ( [ 'Role' , 'Unchecked actions' ] , $ uncheckedActionsOutput ) ; } }
Creating roles permissions
15,235
public function addResource ( ResourceInterface $ resource ) { if ( ! $ this -> trackResources ) { return $ this ; } $ this -> resources [ ] = $ resource ; return $ this ; }
Adds a resource for this configuration .
15,236
public function addClassResource ( \ ReflectionClass $ class ) { if ( ! $ this -> trackResources ) { return $ this ; } do { if ( is_file ( $ class -> getFileName ( ) ) ) { $ this -> addResource ( new FileResource ( $ class -> getFileName ( ) ) ) ; } } while ( $ class = $ class -> getParentClass ( ) ) ; return $ this ; }
Adds the given class hierarchy as resources .
15,237
public function resolveServices ( $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ value [ $ k ] = $ this -> resolveServices ( $ v ) ; } } elseif ( $ value instanceof Reference ) { $ value = $ this -> get ( ( string ) $ value , $ value -> getInvalidBehavior ( ) ) ; } elseif ( $ value instanceof Definition ) { $ value = $ this -> createService ( $ value , null ) ; } elseif ( $ value instanceof Expression ) { $ value = $ this -> getExpressionLanguage ( ) -> evaluate ( $ value , array ( 'container' => $ this ) ) ; } return $ value ; }
Replaces service references by the real service instance and evaluates expressions .
15,238
protected function runJob ( ) { if ( isset ( $ this -> callbackChildren [ $ this -> uid ] ) ) { $ callback = $ this -> callbackChildren [ $ this -> uid ] ; $ result = $ callback -> call ( $ this -> callbackParamChildren [ $ this -> uid ] ) ; } else if ( $ this -> callback ) { $ result = $ this -> callback -> call ( $ this -> callbackParam ) ; } else { $ result = null ; } if ( $ this -> getShareResult ( ) ) { $ this -> getStorage ( ) -> write ( $ this -> uid , $ result ) ; } posix_kill ( $ this -> pid , 9 ) ; }
Run the fork job
15,239
public function doTheJob ( $ callback , $ params = array ( ) ) { if ( ! $ callback instanceof CallbackHandler ) { $ callback = new CallbackHandler ( $ callback ) ; } if ( ! is_array ( $ params ) ) { $ params = array ( $ params ) ; } $ this -> callback = $ callback ; $ this -> callbackParam = $ params ; return $ this ; }
Set default jobs
15,240
public function doTheJobChild ( $ num , $ callback , $ params = array ( ) ) { if ( ! $ callback instanceof CallbackHandler ) { $ callback = new CallbackHandler ( $ callback ) ; } if ( ! is_array ( $ params ) ) { $ params = array ( $ params ) ; } $ this -> callbackChildren [ $ num ] = $ callback ; $ this -> callbackParamChildren [ $ num ] = $ params ; return $ this ; }
Set cild jobs
15,241
public function handler ( $ signal ) { switch ( $ signal ) { case SIGALRM : $ this -> isStopped = true ; $ this -> closeChildren ( ) ; break ; case SIGINT : case SIGKILL : $ this -> broadcast ( $ signal ) ; exit ; default : break ; } }
ISignal handler .
15,242
public function getSharedResults ( ) { if ( ! $ this -> shareResult ) { return false ; } if ( ! $ this -> isStarted ) { return false ; } if ( ! $ this -> isFinished ) { trigger_error ( 'children process was not interrupted' , E_USER_NOTICE ) ; return false ; } $ resultsContainer = $ this -> getDefaultResultsContainer ( ) ; $ results = new $ resultsContainer ( ) ; foreach ( $ this -> handlers as $ uid => $ handler ) { $ resultContainer = $ this -> getDefaultResultContainer ( ) ; $ result = new $ resultContainer ( ) ; $ result -> setUid ( $ uid ) ; $ result -> setPid ( $ handler ) ; $ result -> setResult ( $ this -> getStorage ( ) -> read ( $ uid ) ) ; $ results -> addResult ( $ uid , $ result ) ; } return $ results ; }
Close all children
15,243
public function setShareResult ( $ b ) { if ( $ this -> isStarted ) { throw new Exception \ RuntimeException ( 'Invalid timeout value' ) ; } $ this -> shareResult = $ b ; return $ this ; }
Set flag to share result
15,244
public function addProvider ( $ provider ) { if ( is_string ( $ provider ) ) { $ provider = new $ provider ( $ this ) ; } if ( in_array ( $ provider , $ this -> providers ) ) { return ; } $ this -> providers [ ] = $ provider ; $ this -> registerEvents ( $ provider ) ; $ this -> registerProvides ( $ provider ) ; $ this -> registerProvider ( $ provider ) ; }
Add a service provider to the application .
15,245
public function registerProvidersFor ( $ binding ) { foreach ( $ this -> provides ( $ binding ) as $ provider ) { $ this -> registerProvider ( $ provider , true , $ binding ) ; } }
Register the service providers for a specific binding
15,246
protected function registerEvents ( ServiceProvider $ provider ) { if ( ! isset ( $ this -> event ) ) return ; foreach ( $ provider -> when ( ) as $ event ) { $ this -> event -> listen ( $ event , function ( ) use ( $ provider ) { $ this -> registerProvider ( $ provider , true ) ; } ) ; } }
Register the events that register the specified provider
15,247
protected function registerProvides ( ServiceProvider $ provider ) { foreach ( $ provider -> provides ( ) as $ binding ) { $ this -> provides [ $ binding ] [ ] = $ provider ; } }
Remember the bindings that the specified service provider provides
15,248
public function refreshToken ( AccessToken $ accessToken ) { $ refreshToken = $ accessToken -> getRefreshToken ( ) ; $ scope = $ accessToken -> getScope ( ) ; if ( empty ( $ refreshToken ) ) { throw new RuntimeException ( 'No refresh token was set' ) ; } $ data = array ( 'grant_type' => 'refresh_token' , 'refresh_token' => $ refreshToken , ) ; if ( ! empty ( $ scope ) ) { $ data [ 'scope' ] = $ scope ; } $ header = array ( ) ; if ( $ this -> type == self :: AUTH_BASIC ) { $ header [ 'Authorization' ] = 'Basic ' . base64_encode ( $ this -> clientId . ':' . $ this -> clientSecret ) ; } if ( $ this -> type == self :: AUTH_POST ) { $ data [ 'client_id' ] = $ this -> clientId ; $ data [ 'client_secret' ] = $ this -> clientSecret ; } $ request = new PostRequest ( $ this -> url , $ header , $ data ) ; $ response = $ this -> httpClient -> request ( $ request ) ; $ data = Json \ Parser :: decode ( $ response -> getBody ( ) ) ; if ( $ response -> getStatusCode ( ) == 200 ) { return $ this -> newToken ( $ data ) ; } else { throw new RuntimeException ( 'Could not refresh access token' ) ; } }
Tries to refresh an access token if an refresh token is available . Returns the new received access token or throws an excepion
15,249
protected static function _setPhpInit ( ) { $ init = Module :: merge ( ptc_path ( 'root' ) . '/app/config/init.php' ) ; foreach ( $ init as $ k => $ v ) { if ( is_array ( $ v ) ) { foreach ( $ v as $ key => $ val ) { ini_set ( $ k . '.' . $ key , $ val ) ; } } else { ini_set ( $ k , $ v ) ; } } static :: option ( 'init' , $ init ) ; }
Php configuration at runtime
15,250
protected static function _setDebug ( ) { $ debug = Module :: merge ( ptc_path ( 'root' ) . '/app/config/debug.php' ) ; if ( file_exists ( ptc_path ( 'root' ) . '/app/config/debug_ajax.php' ) ) { if ( ! empty ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) && ( 'xmlhttprequest' === strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) || 'ajax' === strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) ) ) { $ debug_ajax = require_once ( ptc_path ( 'root' ) . '/app/config/debug_ajax.php' ) ; $ debug = array_merge ( $ debug , $ debug_ajax ) ; } } static :: option ( 'debug' , $ debug ) ; require_once ( ptc_path ( 'root' ) . '/vendor/phptoolcase/phptoolcase/PtcDebug.php' ) ; if ( ! is_null ( ptc_array_get ( static :: $ _config , 'debug.replace_error_handler' , null ) ) ) { $ die_on_error = ( ptc_array_get ( static :: $ _config , 'debug.die_on_error' ) ) ? true : false ; Debug :: setErrorHandler ( $ die_on_error ) ; ptc_array_set ( static :: $ _config , 'debug.replace_error_handler' , false , true ) ; } if ( ptc_array_get ( static :: $ _config , 'debug.start' ) ) { $ exclude = ptc_array_get ( static :: $ _config , 'debug.exclude_categories' ) ; if ( is_string ( $ exclude ) && array_key_exists ( $ exclude , static :: $ _debugLevels ) ) { ptc_array_set ( static :: $ _config , 'debug.exclude_categories' , static :: $ _debugLevels [ $ exclude ] , true ) ; } if ( isset ( $ _GET [ 'debug_level' ] ) ) { ptc_array_set ( static :: $ _config , 'debug.exclude_categories' , static :: $ _debugLevels [ $ _GET [ 'debug_level' ] ] , true ) ; } Debug :: load ( static :: $ _config [ 'debug' ] ) ; } }
Set debug at runtime
15,251
protected static function _setAppConfig ( ) { static :: option ( 'paths' , Module :: merge ( ptc_path ( 'root' ) . '/app/config/paths.php' ) ) ; ptc_add_path ( ptc_array_get ( static :: $ _config , 'paths' ) ) ; static :: option ( 'app' , Module :: merge ( ptc_path ( 'root' ) . '/app/config/app.php' ) ) ; HandyMan :: addAlias ( ptc_array_get ( static :: $ _config , 'app.aliases' ) ) ; if ( $ locale = ptc_array_get ( static :: $ _config , 'app.locale' ) ) { setlocale ( LC_ALL , $ locale . 'UTF-8' ) ; } if ( $ timezone = ptc_array_get ( static :: $ _config , 'app.timezone' ) ) { date_default_timezone_set ( $ timezone ) ; } ptc_add_file ( ptc_array_get ( static :: $ _config , 'app.files' ) ) ; ptc_add_dir ( ptc_array_get ( static :: $ _config , 'app.directories' ) ) ; ptc_add_dir ( ptc_array_get ( static :: $ _config , 'app.namespaces' ) ) ; if ( $ sep = ptc_array_get ( static :: $ _config , 'app.separators' ) ) { HandyMan :: addSeparators ( $ sep ) ; } if ( $ conv = ptc_array_get ( static :: $ _config , 'app.conventions' ) ) { HandyMan :: addConventions ( $ conv ) ; } static :: option ( 'db' , Module :: merge ( ptc_path ( 'root' ) . '/app/config/db.php' ) ) ; if ( $ db = ptc_array_get ( static :: $ _config , 'db' ) ) { $ loop = ( static :: option ( 'app.test_env' ) ) ? $ db [ 'develop' ] : $ db [ 'prod' ] ; foreach ( $ loop as $ k => $ v ) { if ( ptc_array_get ( $ v , 'user' ) ) { DB :: add ( $ v , $ k ) ; } } } static :: option ( 'auth' , Module :: merge ( ptc_path ( 'root' ) . '/app/config/auth.php' ) ) ; }
Application bootstrap configuration
15,252
protected static function _setCustomConfigFiles ( ) { $ files = array ( '..' , '.' , 'app.php' , 'db.php' , 'debug.php' , 'init.php' , 'modules.php' , 'paths.php' , 'auth.php' , 'debug_ajax.php' ) ; $ scanned_directory = array_diff ( scandir ( ptc_path ( 'root' ) . '/app/config' ) , $ files ) ; if ( ! empty ( $ scanned_directory ) ) { foreach ( $ scanned_directory as $ file ) { $ option_name = str_replace ( '.php' , '' , $ file ) ; $ options = Module :: merge ( ptc_path ( 'root' ) . '/app/config/' . $ file ) ; if ( ptc_array_get ( $ options , '_load' ) ) { $ options = call_user_func ( ptc_array_get ( $ options , '_load' ) , $ options ) ; } static :: option ( $ option_name , $ options ) ; } } static :: _loadModulesConfig ( ) ; }
Load custom config files
15,253
protected static function _loadModulesConfig ( ) { $ config = array ( '..' , '.' ) ; foreach ( static :: options ( ) as $ key => $ val ) { $ config [ ] = $ key . '.php' ; } foreach ( Module :: all ( ) as $ k => $ module ) { $ scanned_directory = array_diff ( scandir ( ptc_path ( 'root' ) . '/modules/' . $ k . '/config' ) , $ config ) ; if ( ! empty ( $ scanned_directory ) ) { foreach ( $ scanned_directory as $ file ) { $ option_name = str_replace ( '.php' , '' , $ file ) ; $ options = require ( ptc_path ( 'root' ) . '/modules/' . $ k . '/config/' . $ file ) ; if ( ptc_array_get ( $ options , '_load' ) ) { $ options = call_user_func ( ptc_array_get ( $ options , '_load' ) , $ options ) ; } static :: option ( $ option_name , $ options ) ; } } } }
Load module config files that are not in root config
15,254
public function createDelegatorWithName ( ServiceLocatorInterface $ serviceLocator , $ name , $ requestedName , $ callback ) { $ oauth2Server = $ callback ( ) ; if ( is_callable ( $ oauth2Server ) ) { $ oauth2ServerFactory = $ oauth2Server ; $ oauth2Server = $ oauth2ServerFactory ( ) ; } $ moduleOptions = $ serviceLocator -> get ( ModuleOptions :: class ) ; $ thirdPartyProviders = $ moduleOptions -> getThirdPartyProviders ( ) ; if ( $ moduleOptions -> isThirdPartyGrantTypeEnabled ( ) && ! empty ( $ thirdPartyProviders ) ) { $ thirdPartyGrant = $ serviceLocator -> get ( ThirdPartyGrantType :: class ) ; $ oauth2Server -> addGrantType ( $ thirdPartyGrant ) ; } return isset ( $ oauth2ServerFactory ) ? $ oauth2ServerFactory : $ oauth2Server ; }
A factory that creates delegates of a given service
15,255
public function initStructureNodeParentsRelatedByStructureNodeId ( $ overrideExisting = true ) { if ( null !== $ this -> collStructureNodeParentsRelatedByStructureNodeId && ! $ overrideExisting ) { return ; } $ this -> collStructureNodeParentsRelatedByStructureNodeId = new ObjectCollection ( ) ; $ this -> collStructureNodeParentsRelatedByStructureNodeId -> setModel ( '\gossi\trixionary\model\StructureNodeParent' ) ; }
Initializes the collStructureNodeParentsRelatedByStructureNodeId collection .
15,256
public function initStructureNodeParentsRelatedByParentId ( $ overrideExisting = true ) { if ( null !== $ this -> collStructureNodeParentsRelatedByParentId && ! $ overrideExisting ) { return ; } $ this -> collStructureNodeParentsRelatedByParentId = new ObjectCollection ( ) ; $ this -> collStructureNodeParentsRelatedByParentId -> setModel ( '\gossi\trixionary\model\StructureNodeParent' ) ; }
Initializes the collStructureNodeParentsRelatedByParentId collection .
15,257
public function getKstruktur ( ConnectionInterface $ con = null ) { if ( $ this -> singleKstruktur === null && ! $ this -> isNew ( ) ) { $ this -> singleKstruktur = ChildKstrukturQuery :: create ( ) -> findPk ( $ this -> getPrimaryKey ( ) , $ con ) ; } return $ this -> singleKstruktur ; }
Gets a single ChildKstruktur object which is related to this object by a one - to - one relationship .
15,258
public function setKstruktur ( ChildKstruktur $ v = null ) { $ this -> singleKstruktur = $ v ; if ( $ v !== null && $ v -> getStructureNode ( null , false ) === null ) { $ v -> setStructureNode ( $ this ) ; } return $ this ; }
Sets a single ChildKstruktur object as related to this object by a one - to - one relationship .
15,259
public function getFunctionPhase ( ConnectionInterface $ con = null ) { if ( $ this -> singleFunctionPhase === null && ! $ this -> isNew ( ) ) { $ this -> singleFunctionPhase = ChildFunctionPhaseQuery :: create ( ) -> findPk ( $ this -> getPrimaryKey ( ) , $ con ) ; } return $ this -> singleFunctionPhase ; }
Gets a single ChildFunctionPhase object which is related to this object by a one - to - one relationship .
15,260
public function setFunctionPhase ( ChildFunctionPhase $ v = null ) { $ this -> singleFunctionPhase = $ v ; if ( $ v !== null && $ v -> getStructureNode ( null , false ) === null ) { $ v -> setStructureNode ( $ this ) ; } return $ this ; }
Sets a single ChildFunctionPhase object as related to this object by a one - to - one relationship .
15,261
public function initStructureNodesRelatedByParentId ( ) { $ this -> collStructureNodesRelatedByParentId = new ObjectCollection ( ) ; $ this -> collStructureNodesRelatedByParentIdPartial = true ; $ this -> collStructureNodesRelatedByParentId -> setModel ( '\gossi\trixionary\model\StructureNode' ) ; }
Initializes the collStructureNodesRelatedByParentId crossRef collection .
15,262
public function removeStructureNodeRelatedByParentId ( ChildStructureNode $ structureNodeRelatedByParentId ) { if ( $ this -> getStructureNodesRelatedByParentId ( ) -> contains ( $ structureNodeRelatedByParentId ) ) { $ structureNodeParent = new ChildStructureNodeParent ( ) ; $ structureNodeParent -> setStructureNodeRelatedByParentId ( $ structureNodeRelatedByParentId ) ; if ( $ structureNodeRelatedByParentId -> isStructureNodeRelatedByStructureNodeIdsLoaded ( ) ) { $ structureNodeRelatedByParentId -> getStructureNodeRelatedByStructureNodeIds ( ) -> removeObject ( $ this ) ; } $ structureNodeParent -> setStructureNodeRelatedByStructureNodeId ( $ this ) ; $ this -> removeStructureNodeParentRelatedByStructureNodeId ( clone $ structureNodeParent ) ; $ structureNodeParent -> clear ( ) ; $ this -> collStructureNodesRelatedByParentId -> remove ( $ this -> collStructureNodesRelatedByParentId -> search ( $ structureNodeRelatedByParentId ) ) ; if ( null === $ this -> structureNodesRelatedByParentIdScheduledForDeletion ) { $ this -> structureNodesRelatedByParentIdScheduledForDeletion = clone $ this -> collStructureNodesRelatedByParentId ; $ this -> structureNodesRelatedByParentIdScheduledForDeletion -> clear ( ) ; } $ this -> structureNodesRelatedByParentIdScheduledForDeletion -> push ( $ structureNodeRelatedByParentId ) ; } return $ this ; }
Remove structureNodeRelatedByParentId of this object through the kk_trixionary_structure_node_parent cross reference table .
15,263
public function initStructureNodesRelatedByStructureNodeId ( ) { $ this -> collStructureNodesRelatedByStructureNodeId = new ObjectCollection ( ) ; $ this -> collStructureNodesRelatedByStructureNodeIdPartial = true ; $ this -> collStructureNodesRelatedByStructureNodeId -> setModel ( '\gossi\trixionary\model\StructureNode' ) ; }
Initializes the collStructureNodesRelatedByStructureNodeId crossRef collection .
15,264
public function removeStructureNodeRelatedByStructureNodeId ( ChildStructureNode $ structureNodeRelatedByStructureNodeId ) { if ( $ this -> getStructureNodesRelatedByStructureNodeId ( ) -> contains ( $ structureNodeRelatedByStructureNodeId ) ) { $ structureNodeParent = new ChildStructureNodeParent ( ) ; $ structureNodeParent -> setStructureNodeRelatedByStructureNodeId ( $ structureNodeRelatedByStructureNodeId ) ; if ( $ structureNodeRelatedByStructureNodeId -> isStructureNodeRelatedByParentIdsLoaded ( ) ) { $ structureNodeRelatedByStructureNodeId -> getStructureNodeRelatedByParentIds ( ) -> removeObject ( $ this ) ; } $ structureNodeParent -> setStructureNodeRelatedByParentId ( $ this ) ; $ this -> removeStructureNodeParentRelatedByParentId ( clone $ structureNodeParent ) ; $ structureNodeParent -> clear ( ) ; $ this -> collStructureNodesRelatedByStructureNodeId -> remove ( $ this -> collStructureNodesRelatedByStructureNodeId -> search ( $ structureNodeRelatedByStructureNodeId ) ) ; if ( null === $ this -> structureNodesRelatedByStructureNodeIdScheduledForDeletion ) { $ this -> structureNodesRelatedByStructureNodeIdScheduledForDeletion = clone $ this -> collStructureNodesRelatedByStructureNodeId ; $ this -> structureNodesRelatedByStructureNodeIdScheduledForDeletion -> clear ( ) ; } $ this -> structureNodesRelatedByStructureNodeIdScheduledForDeletion -> push ( $ structureNodeRelatedByStructureNodeId ) ; } return $ this ; }
Remove structureNodeRelatedByStructureNodeId of this object through the kk_trixionary_structure_node_parent cross reference table .
15,265
public function getChildObject ( ) { if ( ! $ this -> hasChildObject ( ) ) { return null ; } $ childObjectClass = $ this -> getDescendantClass ( ) ; $ childObject = PropelQuery :: from ( $ childObjectClass ) -> findPk ( $ this -> getPrimaryKey ( ) ) ; return $ childObject -> hasChildObject ( ) ? $ childObject -> getChildObject ( ) : $ childObject ; }
Get the child object of this object
15,266
public function initController ( \ OWeb \ types \ Controller $ controller = null ) { if ( $ this -> controller == null ) return ; Events :: getInstance ( ) -> sendEvent ( 'Init_Prepare@OWeb\manage\Controller' , $ this -> controller ) ; $ this -> controller -> initController ( ) ; Events :: getInstance ( ) -> sendEvent ( 'Init_Done@OWeb\manage\Controller' , $ this -> controller ) ; Events :: getInstance ( ) -> sendEvent ( 'ActionDist_Prepare@OWeb\manage\Controller' , $ this -> controller ) ; $ source [ ] = \ OWeb \ OWeb :: getInstance ( ) -> get_get ( ) ; $ source [ ] = \ OWeb \ OWeb :: getInstance ( ) -> get_post ( ) ; foreach ( $ source as $ get ) { if ( isset ( $ get [ 'action' ] ) ) $ this -> controller -> doAction ( $ get [ 'action' ] ) ; $ i = 1 ; while ( isset ( $ get [ 'action_' . $ i ] ) ) { $ this -> controller -> doAction ( $ get [ 'action_' . $ i ] ) ; $ i ++ ; } } Events :: getInstance ( ) -> sendEvent ( 'ActionDist_Done@OWeb\manage\Controller' , $ this -> controller ) ; }
Will initialize the Controller and will do the Actions to which the Controller has register
15,267
public function loadController ( $ name ) { if ( $ this -> controller != null ) { throw new \ OWeb \ manage \ exceptions \ Controller ( "A Controller was already loaded" ) ; } else { try { $ controller = new $ name ( true ) ; $ this -> controller = $ controller ; if ( ! ( $ controller instanceof \ OWeb \ types \ Controller ) ) throw new \ OWeb \ manage \ exceptions \ Controller ( "A Controller needs to be an instance of \\OWeb\\Types\\Controller" ) ; \ OWeb \ manage \ Events :: getInstance ( ) -> sendEvent ( 'loaded@OWeb\manage\Controller' , $ this -> controller ) ; } catch ( \ Exception $ ex ) { throw new \ OWeb \ manage \ exceptions \ Controller ( "The Controller couldn't be loaded due to Errors" , 0 , $ ex ) ; } } return $ this -> controller ; }
Will load the Controller as main controller . Will automaticlly set up the initialisation sequence for the Controller . The Controller will be initialized once OWeb has finished initialisation .
15,268
public function display ( ) { if ( $ this -> controller != null ) { try { $ this -> controller -> display ( ) ; } catch ( \ Exception $ ex ) { throw new \ OWeb \ manage \ exceptions \ Controller ( "The Controller couldn't be shown due to Errors" , 0 , $ ex ) ; } } else { throw new \ OWeb \ manage \ exceptions \ Controller ( "A Controller wasn't loaded to be shown" ) ; } }
Will start the display sequence of the controller . First will prepare controller for display . Then it will ask the controller to display it s View .
15,269
public function generateRandomKey ( int $ length = 32 ) : string { if ( $ length < 1 ) { throw new \ RuntimeException ( 'First parameter ($length) must be greater than 0' ) ; } if ( \ function_exists ( 'random_bytes' ) ) { return \ random_bytes ( $ length ) ; } throw new \ RuntimeException ( 'Function random_bytes not found' ) ; }
Generates specified number of random bytes . Note that output may not be ASCII .
15,270
public static function verifyFormatting ( $ p_address ) { if ( strstr ( $ p_address , "@" ) == false ) { return false ; } else { list ( $ user , $ domain ) = explode ( '@' , $ p_address ) ; if ( strstr ( $ domain , '.' ) == false ) { return false ; } else { return true ; } } }
Verify email global format
15,271
public static function make ( $ string ) { $ key1 = config ( 'security.key1' ) ; $ key2 = config ( 'security.key2' ) ; return sha1 ( md5 ( $ string . 'youssef' . $ key1 ) ) . md5 ( sha1 ( $ string . 'Vinala' . $ key2 ) ) ; }
A function to create a hash string based on another string .
15,272
public static function create ( $ lenght ) { $ characters = 'abcdefghijk01234lmnopq56789rstuxyvwz' ; $ charLenght = strlen ( $ characters ) ; $ string = '' ; for ( $ i = 0 ; $ i < $ lenght ; $ i ++ ) { $ index = mt_rand ( 0 , $ charLenght - 1 ) ; $ string .= $ characters [ $ index ] ; } return $ string ; }
Create a hash string .
15,273
public function link_provider ( array $ data ) { if ( ! is_numeric ( $ data [ 'expires' ] ) ) { if ( $ date = \ DateTime :: createFromFormat ( \ DateTime :: ISO8601 , $ data [ 'expires' ] ) ) { $ data [ 'expires' ] = $ date -> getTimestamp ( ) ; } elseif ( $ date = \ DateTime :: createFromFormat ( 'Y-m-d H:i:s' , $ data [ 'expires' ] ) ) { $ data [ 'expires' ] = $ date -> getTimestamp ( ) ; } else { $ data [ 'expires' ] = time ( ) ; } } \ DB :: delete ( $ this -> config [ 'table' ] ) -> where ( 'uid' , '=' , $ data [ 'uid' ] ) -> where ( 'provider' , '=' , $ data [ 'provider' ] ) -> execute ( static :: $ db_connection ) ; list ( $ insert_id , $ rows_affected ) = \ DB :: insert ( $ this -> config [ 'table' ] ) -> set ( $ data ) -> execute ( static :: $ db_connection ) ; return $ rows_affected ? $ insert_id : false ; }
create a remote entry for this login
15,274
public function get ( $ key , $ default = null ) { return is_array ( $ this -> response ) ? \ Arr :: get ( $ this -> response , $ key , $ default ) : $ default ; }
Get a response value
15,275
protected function callback ( ) { $ this -> response = \ Input :: get ( 'opauth' , false ) and $ this -> response = unserialize ( base64_decode ( $ this -> response ) ) ; if ( ! $ this -> response ) { throw new \ OpauthException ( 'no valid response received in the callback' ) ; } if ( array_key_exists ( 'error' , $ this -> response ) ) { throw new \ OpauthException ( 'Authentication error: the callback returned an error auth response' ) ; } if ( $ this -> get ( 'auth' ) === null or $ this -> get ( 'timestamp' ) === null or $ this -> get ( 'signature' ) === null or $ this -> get ( 'auth.provider' ) === null or $ this -> get ( 'auth.uid' ) === null ) { throw new \ OpauthException ( 'Invalid auth response: Missing key auth response components' ) ; } elseif ( ! $ this -> opauth -> validate ( sha1 ( print_r ( $ this -> get ( 'auth' ) , true ) ) , $ this -> get ( 'timestamp' ) , $ this -> get ( 'signature' ) , $ reason ) ) { throw new \ OpauthException ( 'Invalid auth response: ' . $ reason ) ; } }
fetch the callback response
15,276
protected function create_user ( array $ user ) { $ user_id = \ Auth :: create_user ( isset ( $ user [ 'nickname' ] ) ? $ user [ 'nickname' ] : null , isset ( $ user [ 'password' ] ) ? $ user [ 'password' ] : \ Str :: random ( ) , isset ( $ user [ 'email' ] ) ? $ user [ 'email' ] : null , \ Config :: get ( 'opauth.default_group' , - 1 ) , array ( 'fullname' => isset ( $ user [ 'name' ] ) ? $ user [ 'name' ] : ( isset ( $ user [ 'full_name' ] ) ? $ user [ 'full_name' ] : ( isset ( $ user [ 'first_name' ] , $ user [ 'last_name' ] ) ? $ user [ 'first_name' ] . ' ' . $ user [ 'last_name' ] : null ) ) , ) ) ; return $ user_id ? : false ; }
use Auth to create a new user in case we ve received enough information to do so
15,277
public function addChild ( Node $ child ) { array_push ( $ this -> children , $ child ) ; $ child -> setParent ( $ this ) ; }
Adds a child to this node s content . A child may be a TextNode or another ElementNode ... or anything else that may extend the abstract Node class .
15,278
public function removeChild ( Node $ child ) { foreach ( $ this -> children as $ key => $ value ) { if ( $ value == $ child ) unset ( $ this -> children [ $ key ] ) ; } }
Removes a child from this node s contnet .
15,279
public function closestParentOfType ( $ str ) { $ str = strtolower ( $ str ) ; $ currentEl = $ this ; while ( strtolower ( $ currentEl -> getTagName ( ) ) != $ str && $ currentEl -> hasParent ( ) ) $ currentEl = $ currentEl -> getParent ( ) ; if ( strtolower ( $ currentEl -> getTagName ( ) ) != $ str ) return null ; else return $ currentEl ; }
Traverses the parse tree upwards going from parent to parent until it finds a parent who has the given tag name . Returns the parent with the matching tag name if it exists otherwise returns null .
15,280
protected function importCSV ( $ config , $ fn = NULL ) { $ fileName = $ config [ 'fileName' ] ; $ file = fopen ( $ fileName , "r" ) ; while ( ! feof ( $ file ) ) { $ record = fgetcsv ( $ file , 0 , $ config [ 'delimiter' ] ) ; if ( isset ( $ record [ 0 ] ) ) { $ attributes = $ this -> parseAttributeMap ( $ config [ 'attributeMap' ] , $ record ) ; isset ( $ fn ) ? $ fn ( $ attributes , $ config ) : NULL ; var_dump ( $ attributes ) ; $ model = new $ config [ 'saveModel' ] ( ) ; $ model -> setAttributes ( $ attributes ) ; $ model -> save ( ) ; } else { break ; } } }
Import a CSV file
15,281
private function session ( ) { if ( $ this -> session === null ) { $ this -> session = DI :: getInstance ( ) -> get ( 'session' ) ; } return $ this -> session ; }
Get the session .
15,282
public static function skills ( $ qty = 1 , $ max = 0 ) { if ( $ max > 0 ) { $ qty = self :: numberBetween ( $ qty , $ max ) ; } return self :: randomElements ( self :: $ skills , $ qty ) ; }
Generate fake skills from a list .
15,283
public function AddMatchSql ( $ Sql , $ Columns , $ LikeRelavenceColumn = '' ) { if ( $ this -> _SearchMode == 'like' ) { if ( $ LikeRelavenceColumn ) $ Sql -> Select ( $ LikeRelavenceColumn , '' , 'Relavence' ) ; else $ Sql -> Select ( 1 , '' , 'Relavence' ) ; $ Sql -> BeginWhereGroup ( ) ; $ ColumnsArray = explode ( ',' , $ Columns ) ; $ First = TRUE ; foreach ( $ ColumnsArray as $ Column ) { $ Column = trim ( $ Column ) ; $ Param = $ this -> Parameter ( ) ; if ( $ First ) { $ Sql -> Where ( "$Column like $Param" , NULL , FALSE , FALSE ) ; $ First = FALSE ; } else { $ Sql -> OrWhere ( "$Column like $Param" , NULL , FALSE , FALSE ) ; } } $ Sql -> EndWhereGroup ( ) ; } else { $ Boolean = $ this -> _SearchMode == 'boolean' ? ' in boolean mode' : '' ; $ Param = $ this -> Parameter ( ) ; $ Sql -> Select ( $ Columns , "match(%s) against($Param{$Boolean})" , 'Relavence' ) ; $ Param = $ this -> Parameter ( ) ; $ Sql -> Where ( "match($Columns) against ($Param{$Boolean})" , NULL , FALSE , FALSE ) ; } }
Add the sql to perform a search .
15,284
public function addRoute ( string $ name , array $ methods , string $ pattern , array $ middlewares , array $ handler , string $ group = null ) { $ this -> routes [ $ name ] = [ 'methods' => $ methods , 'pattern' => $ pattern , 'middlewares' => $ middlewares , 'handler' => $ handler , 'group' => $ group ] ; }
Add route to collection .
15,285
public function addGroup ( string $ name , string $ prefix = '' , array $ middlewares = [ ] ) { $ this -> groups [ $ name ] = [ $ prefix , $ middlewares ] ; }
Add group for routes to collection .
15,286
public function generateRoutesData ( RouteParser $ routeParser , DataGenerator $ dataGenerator ) { $ routes = [ ] ; foreach ( $ this -> routes as $ name => $ route ) { if ( $ route [ 'group' ] ) { if ( ! isset ( $ this -> groups [ $ route [ 'group' ] ] ) ) { throw new \ LogicException ( sprintf ( 'The route group "%s" is not found' , $ route [ 'group' ] ) ) ; } $ pattern = $ this -> groups [ $ route [ 'group' ] ] [ 0 ] . $ route [ 'pattern' ] ; $ middlewares = array_merge ( $ this -> groups [ $ route [ 'group' ] ] [ 1 ] , $ route [ 'middlewares' ] ) ; } else { $ pattern = $ route [ 'pattern' ] ; $ middlewares = $ route [ 'middlewares' ] ; } $ routeDatas = $ routeParser -> parse ( $ pattern ) ; $ this -> addToDataGenerator ( $ route [ 'methods' ] , $ routeDatas , $ name , $ dataGenerator ) ; $ routes [ $ name ] = [ 'datas' => $ routeDatas , 'methods' => $ route [ 'methods' ] , 'pattern' => $ pattern , 'middlewares' => $ middlewares , 'handler' => $ route [ 'handler' ] , 'group' => $ route [ 'group' ] ] ; } return [ 'routes' => $ routes , 'dispatch_data' => $ dataGenerator -> getData ( ) ] ; }
Generate routes data for FastRouter
15,287
protected function addToDataGenerator ( array $ methods , array $ routeDatas , string $ routeName , DataGenerator $ dataGenerator ) : DataGenerator { foreach ( $ methods as $ method ) { foreach ( $ routeDatas as $ routeData ) { $ dataGenerator -> addRoute ( $ method , $ routeData , $ routeName ) ; } } return $ dataGenerator ; }
Set route data to DataGenerator
15,288
public function parse ( $ data ) { $ frames = array ( ) ; while ( $ data != '' ) { $ data = $ this -> currentFrame -> parse ( $ data ) ; if ( $ data != '' ) { $ frames [ ] = $ this -> currentFrame ; $ this -> currentFrame = new Net_Notifier_WebSocket_Frame ( ) ; } } $ state = $ this -> currentFrame -> getState ( ) ; if ( $ state === Net_Notifier_WebSocket_Frame :: STATE_DONE ) { $ frames [ ] = $ this -> currentFrame ; $ this -> currentFrame = new Net_Notifier_WebSocket_Frame ( ) ; } return $ frames ; }
Parses WebSocket frames out of a raw data stream
15,289
protected function formatByIntlMoneyFormatter ( $ valueToFormat = 0.0 , $ decimalsCount = NULL , $ currency = NULL ) { $ formatter = $ this -> getIntlNumberFormatter ( $ this -> langAndLocale , \ NumberFormatter :: CURRENCY , NULL , ( $ decimalsCount !== NULL ? [ \ NumberFormatter :: FRACTION_DIGITS => $ decimalsCount ] : [ ] ) ) ; if ( $ currency === NULL ) { if ( $ this -> defaultCurrency !== NULL ) { $ currency = $ this -> defaultCurrency ; } else { $ currency = \ numfmt_get_symbol ( $ formatter , \ NumberFormatter :: INTL_CURRENCY_SYMBOL ) ; if ( mb_strlen ( $ currency ) !== 3 ) { if ( $ this -> encodingConversion === NULL ) { $ this -> setUpSystemLocaleAndEncodings ( ) ; $ this -> setUpLocaleConventions ( ) ; } $ currency = $ this -> localeConventions -> int_curr_symbol ; } } } return \ numfmt_format_currency ( $ formatter , $ valueToFormat , $ currency ) ; }
Format money by Intl extension formatter . If no international three chars currency symbol is provided there is used currency symbol from localized Intl formatter instance .
15,290
public function offsetSet ( $ key , $ value ) { if ( $ key !== null ) { $ this -> data [ $ key ] = $ value ; } else { $ this -> data [ ] = $ value ; } return $ this ; }
Sets the value ArrayAccess implementation
15,291
public function equals ( UrlInterface $ url ) : bool { return $ this -> getScheme ( ) -> equals ( $ url -> getScheme ( ) ) && $ this -> getHost ( ) -> equals ( $ url -> getHost ( ) ) && $ this -> getPort ( ) === $ url -> getPort ( ) && $ this -> getPath ( ) -> equals ( $ url -> getPath ( ) ) && $ this -> getQueryString ( ) === $ url -> getQueryString ( ) && $ this -> getFragment ( ) === $ url -> getFragment ( ) ; }
Returns true if the url equals other url false otherwise .
15,292
public function getHostAndPort ( ) : string { if ( $ this -> myPort !== $ this -> myScheme -> getDefaultPort ( ) ) { return $ this -> myHost . ':' . $ this -> myPort ; } return $ this -> myHost -> __toString ( ) ; }
Returns the host and port of the url as a string .
15,293
public function withFragment ( ? string $ fragment = null ) : UrlInterface { if ( ! self :: myValidateFragment ( $ fragment , $ error ) ) { throw new UrlInvalidArgumentException ( $ error ) ; } return new self ( $ this -> myScheme , $ this -> myHost , $ this -> myPort , $ this -> myPath , $ this -> myQueryString , $ fragment ) ; }
Returns a copy of the Url instance with the specified fragment .
15,294
public function withHost ( HostInterface $ host ) : UrlInterface { return new self ( $ this -> myScheme , $ host , $ this -> myPort , $ this -> myPath , $ this -> myQueryString , $ this -> myFragment ) ; }
Returns a copy of the Url instance with the specified host .
15,295
public function withPort ( int $ port ) : UrlInterface { if ( ! self :: myValidatePort ( $ port , $ error ) ) { throw new UrlInvalidArgumentException ( $ error ) ; } return new self ( $ this -> myScheme , $ this -> myHost , $ port , $ this -> myPath , $ this -> myQueryString , $ this -> myFragment ) ; }
Returns a copy of the Url instance with the specified port .
15,296
public function withPath ( UrlPathInterface $ path ) : UrlInterface { return new self ( $ this -> myScheme , $ this -> myHost , $ this -> myPort , $ this -> myPath -> withUrlPath ( $ path ) , $ this -> myQueryString , $ this -> myFragment ) ; }
Returns a copy of the Url instance with the specified path .
15,297
public function withQueryString ( ? string $ queryString = null ) : UrlInterface { if ( ! self :: myValidateQueryString ( $ queryString , $ error ) ) { throw new UrlInvalidArgumentException ( $ error ) ; } return new self ( $ this -> myScheme , $ this -> myHost , $ this -> myPort , $ this -> myPath , $ queryString , $ this -> myFragment ) ; }
Returns a copy of the Url instance with the specified query string .
15,298
public function withScheme ( SchemeInterface $ scheme , bool $ keepDefaultPort = true ) : UrlInterface { return new self ( $ scheme , $ this -> myHost , ( $ keepDefaultPort && $ this -> myPort === $ this -> myScheme -> getDefaultPort ( ) ? $ scheme -> getDefaultPort ( ) : $ this -> myPort ) , $ this -> myPath , $ this -> myQueryString , $ this -> myFragment ) ; }
Returns a copy of the Url instance with the specified scheme .
15,299
public static function fromParts ( SchemeInterface $ scheme , HostInterface $ host , ? int $ port = null , UrlPathInterface $ urlPath = null , ? string $ queryString = null , ? string $ fragment = null ) { if ( $ port === null ) { $ port = $ scheme -> getDefaultPort ( ) ; } if ( $ urlPath === null ) { $ urlPath = UrlPath :: parse ( '/' ) ; } if ( ! self :: myValidateParts ( $ port , $ urlPath , $ queryString , $ fragment , $ error ) ) { throw new UrlInvalidArgumentException ( $ error ) ; } return new self ( $ scheme , $ host , $ port , $ urlPath , $ queryString , $ fragment ) ; }
Creates a url from url parts .