idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
1,900
protected function rerun ( ) { $ rerunNextStep = empty ( $ this -> data [ 'rerunStep' ] ) ? 1 : intval ( $ this -> data [ 'rerunStep' ] ) + 1 ; if ( $ rerunNextStep <= $ this -> maxStepOfRerun ) { JobFabric :: getInstance ( ) -> createJob ( ( new TypedBuilder ( ) ) -> setType ( $ this -> type ) -> setData ( $ this -> data ) -> setRerunStep ( $ rerunNextStep ) -> setStart ( time ( ) + $ this -> getFibonacciDelay ( $ rerunNextStep ) ) -> setOriginal ( $ this -> _id ) ) ; } }
Rerun current job
1,901
public function queue ( $ item_id = null , $ action = null ) { if ( is_null ( $ item_id ) ) { throw new NoItemException ( "No item id was sent" ) ; } else if ( ! is_numeric ( $ item_id ) ) { throw new InvalidItemTypeException ( "The item id: $item_id is not valid it should be a number" ) ; } $ this -> actions [ ] = array ( 'action' => $ action , 'item_id' => $ item_id , 'time' => time ( ) ) ; return true ; }
All single actions are routed through this method to wrap the request in the required format for the pocket API .
1,902
public function tags_queue ( $ tag_info = array ( ) , $ action = null ) { if ( ! isset ( $ tag_info [ 'item_id' ] ) ) { throw new NoItemException ( "No item id was sent" ) ; } else if ( ! is_numeric ( $ tag_info [ 'item_id' ] ) ) { throw new InvalidItemTypeException ( "The item id: {$tag_info['item_id']} is not valid it should be a number" ) ; } if ( sizeof ( $ tag_info [ 'tags' ] ) == 0 ) { throw new NoItemException ( "No tags received" ) ; } $ base_info = array ( 'action' => $ action , 'time' => time ( ) ) ; $ tag_info = array_merge ( $ base_info , $ tag_info ) ; $ this -> actions [ ] = $ tag_info ; return true ; }
All double tag actions are routed through this method to wrap the request in the required format for the pocket API .
1,903
public function add ( $ link_info = array ( ) ) { if ( ! isset ( $ link_info [ 'url' ] ) ) { throw new NoItemException ( "The url is required when adding a link" ) ; } $ base_info = array ( 'action' => 'add' , 'time' => time ( ) ) ; $ link_info = array_merge ( $ base_info , $ link_info ) ; $ this -> actions [ ] = $ link_info ; return true ; }
Add a particular bookmark
1,904
public function showAction ( Font $ font ) { $ deleteForm = $ this -> createDeleteForm ( $ font ) ; return array ( 'entity' => $ font , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Finds and displays a Font entity .
1,905
private function createDeleteForm ( Font $ font ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'coreextra_font_delete' , array ( 'id' => $ font -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
Creates a form to delete a Font entity .
1,906
public function sendEmail ( ) { if ( ( $ this -> owner -> type != Item :: TYPE_EMAIL ) || ( ! $ config = $ this -> owner -> getEmailConfig ( ) ) ) { return true ; } $ this -> setFromConfig ( $ config ) ; return \ Yii :: $ app -> mail -> compose ( ) -> setFrom ( \ Yii :: $ app -> params [ 'adminEmail' ] ) -> setTo ( $ this -> owner -> address ) -> setSubject ( $ this -> owner -> title ) -> setHtmlBody ( $ this -> owner -> content ) -> send ( ) ? ( $ this -> owner -> status = Item :: STATUS_SUCCESS ) : ( $ this -> owner -> status = Item :: STATUS_ERROR ) ; }
prepares and sends email content
1,907
public function setFromConfig ( EmailConfig $ config ) { foreach ( [ 'title' , 'content' , 'address' ] as $ attribute ) { $ this -> owner -> $ attribute = $ this -> prepareString ( $ config -> $ attribute ) ; } }
gets data from email config EmailConfig
1,908
private function prepareString ( $ string ) { return str_replace ( array_keys ( $ this -> owner -> variables ) , array_values ( $ this -> owner -> variables ) , $ string ) ; }
prepares email content before sending
1,909
public function getJob ( $ queues , $ timeoutMs = 200 ) { $ jobs = $ this -> getJobs ( $ queues , 1 , $ timeoutMs ) ; if ( empty ( $ jobs ) ) { return null ; } return $ jobs [ 0 ] ; }
Retrieve a single job from the given queues
1,910
public function ack ( Job $ job ) { assert ( $ job -> getId ( ) != null ) ; return ( int ) $ this -> send ( [ 'ACKJOB' , $ job -> getId ( ) ] ) ; }
Acknowledge a job execution .
1,911
public function show ( $ jobId ) { $ result = $ this -> send ( [ 'SHOW' , ( string ) $ jobId ] ) ; if ( ! $ result ) { return null ; } return Job :: create ( RespUtils :: toAssoc ( $ result ) ) ; }
Return the job with the given jobId .
1,912
public static function create ( int $ statusCode , ResourceInterface $ resource = null ) : PresentationInterface { return new Presentation ( $ statusCode , $ resource ) ; }
Create the presentation
1,913
function initResponse ( ) { if ( $ this -> action [ 0 ] == '_' ) { $ this -> response = new Response \ JSONResponse ( ) ; } else { $ this -> response = new Response \ XTPLResponse ( $ this ) ; $ this -> response -> setVariable ( 'MODULE' , $ this ) ; $ this -> response -> post = $ this -> post ; $ this -> response -> get = $ this -> get ; $ this -> response -> website = Env :: getConfig ( 'website' ) ; } }
initialize default responses .
1,914
public static function encrypt ( string $ data , string $ password ) : string { $ iv = self :: generateIv ( ) ; $ key = self :: hash ( $ iv , $ password ) ; $ cyphertext = openssl_encrypt ( $ data , self :: CIPHER , $ key , OPENSSL_RAW_DATA , $ iv ) ; if ( $ cyphertext === false ) { throw new RuntimeException ( 'Encryption library: Encryption (symmetric) of content failed: ' . openssl_error_string ( ) ) ; } $ checksum = self :: hash ( $ iv . $ cyphertext , $ key ) ; $ encrypted = $ iv . $ checksum . $ cyphertext ; return $ encrypted ; }
Encrypt the given data .
1,915
public static function decrypt ( string $ data , string $ password ) : string { $ iv = self :: substr ( $ data , 0 , self :: IVSIZE ) ; $ checksum = self :: substr ( $ data , self :: IVSIZE , self :: CKSIZE ) ; $ cyphertext = self :: substr ( $ data , self :: IVSIZE + self :: CKSIZE , null ) ; $ key = self :: hash ( $ iv , $ password ) ; $ sum = self :: hash ( $ iv . $ cyphertext , $ key ) ; if ( ! hash_equals ( $ checksum , $ sum ) ) { throw new InvalidArgumentException ( 'Decryption can not proceed due to invalid cyphertext checksum.' ) ; } $ decrypted = openssl_decrypt ( $ cyphertext , self :: CIPHER , $ key , OPENSSL_RAW_DATA , $ iv ) ; if ( $ decrypted === false ) { throw new RuntimeException ( 'Encryption library: Decryption (symmetric) of content failed: ' . openssl_error_string ( ) ) ; } return $ decrypted ; }
Decrypt the given data .
1,916
private static function hash ( string $ data , string $ key ) : string { return hash_hmac ( self :: ALGO , $ data , $ key , true ) ; }
Perform a single hmac iteration . This adds an extra layer of safety because hash_hmac can return false if algo is not valid . Return type hint will throw an exception if this happens .
1,917
public function & getStorage ( $ storage_name ) : LanguageStorage { $ return = false ; if ( isset ( $ storage_name , $ this -> storage -> { $ storage_name } ) ) { $ return = $ this -> storage -> { $ storage_name } ; } return $ return ; }
Returns a reference to a specfic the language storage
1,918
public function createTextAdapter ( $ storage_name ) : TextInterface { $ adapter = new Text ( ) ; $ adapter -> setLanguage ( $ this ) ; $ adapter -> setStorageName ( $ storage_name ) ; return $ adapter ; }
Creates and return as Text object
1,919
protected function registerLockdownConfiguration ( ) { $ this -> publishes ( [ __DIR__ . $ this -> modelsConfigPath => config_path ( 'lockdown.php' ) , ] , 'config' ) ; $ this -> mergeConfigFrom ( __DIR__ . $ this -> modelsConfigPath , 'lockdown' ) ; }
Register Lockdown configuration
1,920
protected function registerCommands ( ) { $ namespace = __NAMESPACE__ . '\\Commands\\' ; $ keyPrefix = 'lockdown.commands.' ; $ commands = [ $ keyPrefix . 'assign-perm-user' => 'AssignPermissionToUser' , $ keyPrefix . 'assign-role-perm' => 'AssignPermissionToRole' , $ keyPrefix . 'assign-role-user' => 'AssignRoleToUser' , $ keyPrefix . 'create-perm' => 'CreatePermission' , $ keyPrefix . 'create-role' => 'CreateRole' , $ keyPrefix . 'delete-permission' => 'DeletePermission' , $ keyPrefix . 'delete-role' => 'DeleteRole' , $ keyPrefix . 'remove-perm-user' => 'RemovePermissionFromUser' , $ keyPrefix . 'remove-role-perm' => 'RemovePermissionFromRole' , $ keyPrefix . 'remove-role-user' => 'RemoveRoleFromUser' , $ keyPrefix . 'show-permissions' => 'ShowPermissions' , $ keyPrefix . 'show-roles' => 'ShowRoles' , ] ; foreach ( $ commands as $ key => $ class ) { $ this -> app -> bind ( $ key , function ( $ app ) use ( $ class , $ namespace ) { $ classNamespaceFull = $ namespace . $ class ; return new $ classNamespaceFull ( $ app [ 'lockdown' ] ) ; } ) ; } $ this -> commands ( array_keys ( $ commands ) ) ; }
Register Artisan commands
1,921
protected function registerUserProvider ( ) { $ this -> app [ 'lockdown.user' ] = $ this -> app -> share ( function ( $ app ) { $ userModel = config ( 'lockdown.user' ) ; return new UserProvider ( $ userModel ) ; } ) ; $ this -> app [ 'auth' ] -> provider ( 'lockdown' , function ( $ app ) { return $ app [ 'lockdown.user' ] ; } ) ; }
Register user provider
1,922
protected function registerRoleProvider ( ) { $ this -> app [ 'lockdown.role' ] = $ this -> app -> share ( function ( $ app ) { $ roleModel = config ( 'lockdown.role' ) ; return new RoleProvider ( $ roleModel ) ; } ) ; }
Register role provider
1,923
protected function registerPermissionProvider ( ) { $ this -> app [ 'lockdown.permission' ] = $ this -> app -> share ( function ( $ app ) { $ permissionModel = config ( 'lockdown.permission' ) ; return new PermissionProvider ( $ permissionModel ) ; } ) ; }
Register permission provider
1,924
protected function registerLockdownFacade ( ) { $ this -> app -> booting ( function ( ) { $ loader = AliasLoader :: getInstance ( ) ; $ loader -> alias ( 'Lockdown' , __NAMESPACE__ . '\LockdownFacade' ) ; } ) ; }
Register the Lockdown Facade
1,925
public function hasTerm ( $ taxonomy , $ term ) { return isset ( $ this -> terms [ $ taxonomy ] ) && isset ( $ this -> terms [ $ taxonomy ] [ $ term ] ) ; }
Whether the post contains the term or not .
1,926
public function getImageAttribute ( ) { if ( $ this -> thumbnail and $ this -> thumbnail -> attachment ) { return $ this -> thumbnail -> attachment -> guid ; } }
Gets the featured image if any Looks in meta the _thumbnail_id field .
1,927
public function getMainCategoryAttribute ( ) { $ mainCategory = 'Uncategorized' ; if ( ! empty ( $ this -> terms ) ) { $ taxonomies = array_values ( $ this -> terms ) ; if ( ! empty ( $ taxonomies [ 0 ] ) ) { $ terms = array_values ( $ taxonomies [ 0 ] ) ; $ mainCategory = $ terms [ 0 ] ; } } return $ mainCategory ; }
Gets the first term of the first taxonomy found .
1,928
public function getKeywordsAttribute ( ) { return collect ( $ this -> terms ) -> map ( function ( $ taxonomy ) { return collect ( $ taxonomy ) -> values ( ) ; } ) -> collapse ( ) -> toArray ( ) ; }
Gets the keywords as array .
1,929
public function cash ( $ cash = null ) { if ( $ cash !== null ) { $ this -> update ( [ 'cash' => $ cash ] ) ; } else { return $ this -> getFirstAttribute ( ) [ 'cash' ] ; } }
return or set the cash amount
1,930
public function trailStarted ( $ started = null ) { if ( $ started === null ) { return $ this -> trail_started ; } else { $ this -> trail_started = $ started ; return $ this ; } }
return or set trail started time
1,931
public function trailEndsAt ( $ endDate = null ) { if ( $ endDate === null ) { return $ this -> trail_ends_at ; } else { $ this -> trail_ends_at = $ endDate ; return $ this ; } }
return or set trail end time
1,932
public function isSubscription ( ) { $ started = $ this -> subscriptionStarted ( ) ; $ status = $ this -> status ( ) ; $ time = time ( ) ; if ( $ started !== '' && is_numeric ( $ started ) && $ status !== '' && $ status !== 'canceled' && $ time < $ this -> subscriptionEndsAt ( ) ) { return true ; } else { return false ; } }
determine our subscription is a valid subscription
1,933
public function plan ( $ plan = null ) { if ( $ plan === null ) { return $ this -> subscription_plan ; } else { $ this -> subscription_plan = $ plan ; return $ this ; } }
set or return subscription plan
1,934
public function pause ( ) { $ this -> status ( 'paused' ) ; $ started = $ this -> subscriptionStarted ( ) ; if ( ! isset ( $ this -> subscriptionPlans [ $ plan = $ this -> plan ( ) ] ) ) { $ this -> delete ( ) ; throw new BillingSubscriptionPlanException ( sprintf ( 'Your %s plan is not exists in our website' ) ) ; } $ endTime = $ this -> findTimestampOfSubscription ( $ started , $ plan ) ; $ left = $ endTime - $ started ; $ this -> subscription_paused_left = $ left ; return $ this ; }
pause the subscription
1,935
public function subscriptionEndsAt ( $ ends = null ) { if ( $ ends === null ) { return $ this -> subscription_ends_at ; } else { $ this -> subscription_ends_at = $ ends ; return $ this ; } }
return or set subscription ends time
1,936
public static function typed ( string $ type , iterable $ input = [ ] ) : PriorityQueue { $ resolver = Resolver :: typed ( $ type ) ; return new static ( $ input , $ resolver ) ; }
PriorityQueue named constructor .
1,937
public function json ( $ data , $ status = HttpMessage :: HTTP_OK , $ encodingOptions = 0 ) { $ json = json_encode ( $ data , $ encodingOptions ) ; $ this -> withStatusCode ( $ status ) -> withHeader ( 'content-type' , 'application/json' ) -> getBody ( ) -> write ( $ json ) ; return $ this ; }
Json response .
1,938
public function html ( $ data , $ status = HttpMessage :: HTTP_OK ) { $ this -> withStatusCode ( $ status ) -> withHeader ( 'content-type' , 'text/html' ) -> getBody ( ) -> write ( ( string ) $ data ) ; return $ this ; }
Html Response .
1,939
public function template ( $ path , $ data = [ ] , $ status = HttpMessage :: HTTP_OK ) { $ tempFile = $ path . '.php' ; if ( ! is_file ( $ tempFile ) ) { throw new \ RuntimeException ( 'Could not find the template file <' . $ path . '>' ) ; } ob_start ( ) ; extract ( $ data ) ; include ( $ path . '.php' ) ; $ content = ob_get_clean ( ) ; return $ this -> html ( $ content , $ status ) ; }
Render a html template .
1,940
public function isEvaluableForTypes ( string ... $ types ) : bool { if ( ! $ this -> isValid ( ) ) { return false ; } if ( is_empty ( $ types ) ) { return true ; } return Data :: make ( $ this -> value ) -> isTypeOf ( ... $ types ) ; }
Indica si este input se debe evaluar para alguno de los tipos dados
1,941
public function next ( $ value ) : self { $ this -> ensureIsNotLocked ( ) ; $ this -> value = $ value ; $ this -> locked = true ; return $ this ; }
Aplica un nuevo valor al input para que sea recogido por la siguiente regla
1,942
private function makeException ( string $ format , ... $ arguments ) : InvalidArgumentException { $ reason = sprintf ( $ format , ... $ arguments ) ; $ exception = InvalidArgumentException :: make ( $ this -> value , $ reason ) ; return $ exception ; }
Devuelve un objeto excepcion generico
1,943
public function resolve ( $ response = null ) : self { if ( $ this -> exception instanceof \ Throwable ) { throw $ this -> exception ; } if ( $ this -> mustBeResolved ( $ response ) ) { $ this -> value = $ response ; } $ this -> locked = false ; return $ this ; }
Resuelve este input aplicando la respuesta de un callback
1,944
public function doBuild ( ) { $ output = parent :: build ( ) ; if ( $ this -> form && $ this -> form -> status [ 'submitted' ] && ! $ this -> props [ 'isValid' ] ) { $ noticeName = $ this -> attribs [ 'name' ] . '_notice' ; $ this -> debug -> warn ( 'buildControl' , $ this -> form -> buildControl ) ; $ output .= $ this -> form -> buildControl -> build ( array ( 'type' => 'hidden' , 'name' => $ noticeName , 'value' => $ this -> val ( ) , ) ) ; } return $ output ; }
Build field control
1,945
public function fill ( $ object , array $ data ) { if ( ! $ object instanceof ConversionInterface ) { throw new InvalidArgumentException ( sprintf ( 'Invalid object "%s" provided; must be an instance of "%s".' , is_object ( $ object ) ? get_class ( $ object ) : gettype ( $ object ) , ConversionInterface :: CLASS ) ) ; } $ object -> fromArray ( $ data ) ; }
Fills the object with specified data .
1,946
public function extract ( $ object ) { if ( ! $ object instanceof ConversionInterface ) { throw new InvalidArgumentException ( sprintf ( 'Invalid object "%s" provided; must be an instance of "%s".' , is_object ( $ object ) ? get_class ( $ object ) : gettype ( $ object ) , ConversionInterface :: CLASS ) ) ; } return $ object -> toArray ( ) ; }
Extracts data from object .
1,947
protected function getCacheKey ( RequestInterface $ request ) : string { if ( $ this -> key === null ) { $ this -> key = $ request -> getMethod ( ) . md5 ( ( string ) $ request -> getUri ( ) ) ; } return ( string ) $ this -> key ; }
Returns the id used to cache a request .
1,948
public function hydrate ( $ value ) { if ( $ this -> nullable && $ value === null ) { return null ; } if ( $ value instanceof MongoBinData ) { return $ value -> bin ; } throw new Exception \ InvalidArgumentException ( sprintf ( 'Invalid value: must be an instance of MongoBinData, "%s" given' , is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ) ) ; }
Convert a MongoBinData to binary string
1,949
public function extract ( $ value ) { if ( $ this -> nullable && $ value === null ) { return null ; } return new MongoBinData ( $ value , $ this -> type ) ; }
Ensure the value extracted is typed as MongoBinData or null
1,950
protected function injectScript ( Response $ response ) { if ( function_exists ( 'mb_stripos' ) ) { $ posrFunction = 'mb_strripos' ; $ substrFunction = 'mb_substr' ; } else { $ posrFunction = 'strripos' ; $ substrFunction = 'substr' ; } $ content = $ response -> getContent ( ) ; $ pos = $ posrFunction ( $ content , '</body>' ) ; if ( false !== $ pos ) { $ script = "livereload.js" ; if ( $ this -> checkServerPresence ) { $ request = $ this -> httpClient -> get ( $ script ) ; try { $ checkResponse = $ this -> httpClient -> send ( $ request ) ; if ( $ checkResponse -> getStatusCode ( ) !== 200 ) { return ; } } catch ( CurlException $ e ) { if ( $ e -> getCurlHandle ( ) -> getErrorNo ( ) === 7 ) { return ; } throw $ e ; } } $ content = $ substrFunction ( $ content , 0 , $ pos ) . "\n" . '<script src="' . $ this -> httpClient -> getBaseUrl ( ) . $ script . '"></script>' . "\n" . $ substrFunction ( $ content , $ pos ) ; $ response -> setContent ( $ content ) ; } }
Injects the livereload script .
1,951
private function prepareTmpDir ( ) { $ tempDir = $ this -> file -> get ( self :: SETTING_DESTINATION_DIR ) . DIRECTORY_SEPARATOR . uniqid ( 'install-' ) ; if ( ! @ mkdir ( $ tempDir , 0700 ) ) { throw new \ RuntimeException ( 'Could not create the temporary directory' ) ; } $ this -> tempDir = $ tempDir ; }
Prepare a temporary directory .
1,952
private function moveFiles ( ) { clearstatcache ( ) ; $ destinationDir = $ this -> file -> get ( self :: SETTING_DESTINATION_DIR ) ; $ ioHandler = $ this -> getIO ( ) ; $ logging = $ ioHandler -> isVeryVerbose ( ) ; $ this -> folders = [ ] ; foreach ( Finder :: create ( ) -> in ( $ this -> tempDir ) -> ignoreDotFiles ( false ) -> ignoreVCS ( false ) as $ file ) { $ this -> moveFile ( $ file , $ destinationDir , $ logging , $ ioHandler ) ; } foreach ( array_reverse ( $ this -> folders ) as $ folder ) { if ( $ logging ) { $ ioHandler -> write ( sprintf ( 'remove directory %s' , $ folder ) ) ; } rmdir ( $ folder ) ; } }
Move the installed files to their intended destination .
1,953
private function moveFile ( SplFileInfo $ file , $ targetDir , $ logging , $ ioHandler ) { $ pathName = $ file -> getPathname ( ) ; $ destinationFile = str_replace ( $ this -> tempDir , $ targetDir , $ pathName ) ; if ( $ file -> isLink ( ) ) { $ target = $ file -> getLinkTarget ( ) ; if ( $ logging ) { $ ioHandler -> write ( sprintf ( 'link %s to %s' , $ target , $ destinationFile ) ) ; } symlink ( $ target , $ destinationFile ) ; unlink ( $ pathName ) ; return ; } if ( $ file -> isDir ( ) ) { $ permissions = substr ( decoct ( fileperms ( $ pathName ) ) , 1 ) ; $ this -> folders [ ] = $ pathName ; if ( ! is_dir ( $ destinationFile ) ) { if ( $ logging ) { $ ioHandler -> write ( sprintf ( 'mkdir %s (permissions: %s)' , $ pathName , $ permissions ) ) ; } mkdir ( $ destinationFile , octdec ( $ permissions ) , true ) ; } return ; } if ( $ file -> isFile ( ) ) { $ permissions = substr ( decoct ( fileperms ( $ pathName ) ) , 1 ) ; if ( $ logging ) { $ ioHandler -> write ( sprintf ( 'move %s to %s (permissions: %s)' , $ pathName , $ destinationFile , $ permissions ) ) ; } copy ( $ pathName , $ destinationFile ) ; chmod ( $ destinationFile , octdec ( $ permissions ) ) ; unlink ( $ pathName ) ; return ; } throw new \ RuntimeException ( sprintf ( 'Unknown file of type %s encountered for %s' , filetype ( $ pathName ) , $ pathName ) ) ; }
Move a single file or folder .
1,954
private function mayInstall ( ) { $ destinationDir = $ this -> file -> get ( self :: SETTING_DESTINATION_DIR ) . DIRECTORY_SEPARATOR ; return ! ( file_exists ( $ destinationDir . 'composer.json' ) ) ; }
Check if we may install into the destination directory .
1,955
private function databases ( ) { if ( Configuration :: read ( 'database.config.enable' ) === true ) { $ databaseConfigPath = $ this -> configDir . DS . Configuration :: read ( 'database.config.file' ) ; if ( file_exists ( $ databaseConfigPath ) ) { require $ databaseConfigPath ; return true ; } } return false ; }
Load user defined databases
1,956
private function routes ( ) { if ( Configuration :: read ( 'routing.config.enable' ) === true ) { $ routingConfigPath = $ this -> configDir . DS . Configuration :: read ( 'routing.config.file' ) ; if ( file_exists ( $ routingConfigPath ) ) { require $ routingConfigPath ; return true ; } else { throw new \ Exception ( 'Routing configuration file "' . $ routingConfigPath . '" doesn\' exist.' ) ; } } return false ; }
Load user defined routes
1,957
public function run ( ) { $ this -> routes ( ) ; Router :: resolve ( ) ; $ this -> databases ( ) ; $ this -> bootstrap ( ) ; $ bodyContent = $ this -> controller ( ) ; echo $ bodyContent ; }
Run Pabana Framework
1,958
public static function createObfuscatedString ( int $ hex_length = 16 , bool $ b_crypto_strong = false ) { if ( $ hex_length < 4 || $ hex_length > 64 ) { throw new \ Exception ( 'Utility::createObfuscatedString - Inappropriate hex length' ) ; } $ crypto_strong = false ; $ bytes = openssl_random_pseudo_bytes ( $ hex_length , $ crypto_strong ) ; if ( $ b_crypto_strong && ! $ crypto_strong ) { trigger_error ( "Utility::createObfuscatedString - Not cryptographically strong" , E_USER_NOTICE ) ; } $ hex = bin2hex ( $ bytes ) ; return $ hex ; }
Return a securely obfuscated string
1,959
public function setCells ( array $ configuration = [ ] ) { if ( is_array ( $ configuration ) ) { foreach ( $ configuration as $ cellAlias => $ cell ) { $ this -> appendCell ( $ cell , $ cellAlias ) ; } } return $ this ; }
Setting cells collection .
1,960
public function prependCell ( $ cell , $ name = null ) { $ cell = $ this -> buildCell ( $ cell ) ; if ( $ name == null && $ cell -> getName ( ) != '' ) { $ name = $ cell -> getName ( ) ; } if ( $ name == null ) { array_unshift ( $ this -> cells , $ cell ) ; } else { $ this -> cells = [ $ name => $ cell ] + $ this -> cells ; } reset ( $ this -> cells ) ; $ cell -> setName ( key ( $ this -> cells ) ) ; return $ this ; }
Add cell as first cell of collection .
1,961
public function appendCell ( $ cell , $ name = null ) { $ cell = $ this -> buildCell ( $ cell ) ; if ( $ name == null && $ cell -> getName ( ) != '' ) { $ name = $ cell -> getName ( ) ; } if ( $ name == null ) { $ this -> cells [ ] = $ cell ; } else { $ this -> cells [ $ name ] = $ cell ; } end ( $ this -> cells ) ; $ cell -> setName ( key ( $ this -> cells ) ) ; return $ this ; }
Add cell as last cell of collection .
1,962
private function buildCell ( $ cell ) { if ( is_array ( $ cell ) ) { $ cell = $ this -> getServiceLocator ( ) -> get ( 'DataGrid\Factory\Cell' ) -> get ( $ cell ) ; } elseif ( ! ( $ cell instanceof CellInterface ) ) { throw new \ RuntimeException ( 'You must provide Correct cell definition or Cell instance implementing CellInterface for data grid cells set.' ) ; } return $ cell ; }
Building cell from provided config .
1,963
public function removeCell ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> cells ) ) { throw new Exception ( 'Cell "' . $ name . '" is not set, so could not be removed' ) ; } unset ( $ this -> cells [ $ name ] ) ; return $ this ; }
Removing cell by name or offset .
1,964
public function getCells ( ) { foreach ( $ this -> cells as $ cell ) { $ cell -> setId ( $ this -> getId ( ) ) ; } return $ this -> cells ; }
Gets cells collection
1,965
public function setData ( & $ data ) { foreach ( $ this -> cells as $ cell ) { $ cell -> setData ( $ data ) ; } return $ this ; }
Sets a row data to cells set that will be used to render values .
1,966
public function getColumnsToHideIfUnavailable ( ) { $ out = [ ] ; foreach ( $ this -> getCells ( ) as $ key => $ cell ) { if ( $ cell -> getHideCellIfUnavailable ( ) ) { $ out [ ] = $ key ; } } return $ out ; }
Gets a list of columns that should be removed from rendered grid if does not contains values for any rows .
1,967
public static function set ( $ key , $ value ) { putenv ( vsprintf ( '%s=%s' , [ $ key , $ value ] ) ) ; $ _ENV [ $ key ] = $ value ; $ _SERVER [ $ key ] = $ value ; }
Set an environment variable with the provided value .
1,968
public function create ( BannerZoneInterface $ bannerZone ) { return $ this -> formFactory -> create ( 'silvestra_banner_zone' , $ bannerZone , array ( 'action' => $ this -> router -> getContext ( ) -> getPathInfo ( ) ) ) ; }
Create banner zone form .
1,969
public static function association ( $ catid , $ extension = 'com_content' ) { $ html = '' ; if ( $ associations = CategoriesHelper :: getAssociations ( $ catid , $ extension ) ) { $ associations = ArrayHelper :: toInteger ( $ associations ) ; $ db = JFactory :: getDbo ( ) ; $ query = $ db -> getQuery ( true ) -> select ( 'c.id, c.title' ) -> select ( 'l.sef as lang_sef' ) -> from ( '#__categories as c' ) -> where ( 'c.id IN (' . implode ( ',' , array_values ( $ associations ) ) . ')' ) -> join ( 'LEFT' , '#__languages as l ON c.language=l.lang_code' ) -> select ( 'l.image' ) -> select ( 'l.title as language_title' ) ; $ db -> setQuery ( $ query ) ; try { $ items = $ db -> loadObjectList ( 'id' ) ; } catch ( RuntimeException $ e ) { throw new Exception ( $ e -> getMessage ( ) , 500 , $ e ) ; } if ( $ items ) { foreach ( $ items as & $ item ) { $ text = strtoupper ( $ item -> lang_sef ) ; $ url = JRoute :: _ ( 'index.php?option=com_categories&task=category.edit&id=' . ( int ) $ item -> id . '&extension=' . $ extension ) ; $ tooltipParts = array ( JHtml :: _ ( 'image' , 'mod_languages/' . $ item -> image . '.gif' , $ item -> language_title , array ( 'title' => $ item -> language_title ) , true ) , $ item -> title ) ; $ item -> link = JHtml :: _ ( 'tooltip' , implode ( ' ' , $ tooltipParts ) , null , null , $ text , $ url , null , 'hasTooltip label label-association label-' . $ item -> lang_sef ) ; } } $ html = JLayoutHelper :: render ( 'joomla.content.associations' , $ items ) ; } return $ html ; }
Render the list of associated items
1,970
private function addProxyClasses ( ) { $ definitions = array_filter ( $ this -> container -> getDefinitions ( ) , array ( $ this -> getProxyDumper ( ) , 'isProxyCandidate' ) ) ; $ code = '' ; $ strip = '' === $ this -> docStar && method_exists ( 'Squire\Component\HttpKernel\Kernel' , 'stripComments' ) ; foreach ( $ definitions as $ definition ) { $ proxyCode = "\n" . $ this -> getProxyDumper ( ) -> getProxyCode ( $ definition ) ; if ( $ strip ) { $ proxyCode = "<?php\n" . $ proxyCode ; $ proxyCode = substr ( Kernel :: stripComments ( $ proxyCode ) , 5 ) ; } $ code .= $ proxyCode ; } return $ code ; }
Generates code for the proxies to be attached after the container class .
1,971
private function isSimpleInstance ( $ id , Definition $ definition ) { foreach ( array_merge ( array ( $ definition ) , $ this -> getInlinedDefinitions ( $ definition ) ) as $ sDefinition ) { if ( $ definition !== $ sDefinition && ! $ this -> hasReference ( $ id , $ sDefinition -> getMethodCalls ( ) ) ) { continue ; } if ( $ sDefinition -> getMethodCalls ( ) || $ sDefinition -> getProperties ( ) || $ sDefinition -> getConfigurator ( ) ) { return false ; } } return true ; }
Checks if the definition is a simple instance .
1,972
private function addFrozenConstructor ( ) { $ targetDirs = $ this -> exportTargetDirs ( ) ; $ code = <<<EOF /*{$this->docStar} * Constructor. */ public function __construct() {{$targetDirs}EOF ; if ( $ this -> container -> getParameterBag ( ) -> all ( ) ) { $ code .= "\n \$this->parameters = \$this->getDefaultParameters();\n" ; } $ code .= "\n \$this->services = array();\n" ; $ code .= $ this -> addMethodMap ( ) ; $ code .= $ this -> addAliases ( ) ; $ code .= <<<'EOF' }EOF ; return $ code ; }
Adds the constructor for a frozen container .
1,973
private function getInlinedDefinitions ( Definition $ definition ) { if ( false === $ this -> inlinedDefinitions -> contains ( $ definition ) ) { $ definitions = array_merge ( $ this -> getDefinitionsFromArguments ( $ definition -> getArguments ( ) ) , $ this -> getDefinitionsFromArguments ( $ definition -> getMethodCalls ( ) ) , $ this -> getDefinitionsFromArguments ( $ definition -> getProperties ( ) ) , $ this -> getDefinitionsFromArguments ( array ( $ definition -> getConfigurator ( ) ) ) , $ this -> getDefinitionsFromArguments ( array ( $ definition -> getFactory ( ) ) ) ) ; $ this -> inlinedDefinitions -> offsetSet ( $ definition , $ definitions ) ; return $ definitions ; } return $ this -> inlinedDefinitions -> offsetGet ( $ definition ) ; }
Returns the inline definition .
1,974
private function getDefinitionsFromArguments ( array $ arguments ) { $ definitions = array ( ) ; foreach ( $ arguments as $ argument ) { if ( is_array ( $ argument ) ) { $ definitions = array_merge ( $ definitions , $ this -> getDefinitionsFromArguments ( $ argument ) ) ; } elseif ( $ argument instanceof Definition ) { $ definitions = array_merge ( $ definitions , $ this -> getInlinedDefinitions ( $ argument ) , array ( $ argument ) ) ; } } return $ definitions ; }
Gets the definition from arguments .
1,975
public function getInstance ( ) { if ( $ this -> isSingleton ( ) && $ this -> hasInstance ( ) ) { return $ this -> instance ; } if ( $ this -> path ) { require_once $ this -> path ; } if ( $ this -> isClosure ( ) ) { $ closure = $ this -> class ; $ instance = $ closure ( $ this -> container ) ; } else { $ class = $ this -> class ; if ( $ class [ 0 ] !== '\\' ) $ class = '\\' . $ class ; $ script = sprintf ( '$instance = new %s(%s);' , $ class , $ this -> array2ArgsWithInjectDependency ( '$this->args' , $ this -> args ) ) ; eval ( $ script ) ; } if ( $ this -> isSingleton ( ) ) { $ this -> instance = $ instance ; } if ( $ this -> container && method_exists ( $ instance , 'setContainer' ) ) { $ instance -> setContainer ( $ this -> container ) ; } if ( $ this -> container ) { $ this -> container -> injectDependency ( $ instance ) ; } if ( $ this -> hasInitMethod ( ) ) { $ this -> callInitMethod ( $ instance ) ; } elseif ( $ this -> hasInitializeMethod ( $ instance ) ) { $ instance -> initialize ( ) ; } return $ instance ; }
get instance .
1,976
private function array2ArgsWithInjectDependency ( $ parent , array $ array = array ( ) ) { $ args = array ( ) ; foreach ( $ array as $ _key => $ _val ) { if ( is_string ( $ _val ) && preg_match ( '/^\$([\w_]+)$/' , $ _val , $ matches ) ) { $ args [ ] = sprintf ( '$this->container->get("%s")' , $ matches [ 1 ] ) ; } else { $ args [ ] = is_numeric ( $ _key ) ? sprintf ( '%s[%s]' , $ parent , $ _key ) : sprintf ( "%s['%s']" , $ parent , $ _key ) ; } } return join ( ', ' , $ args ) ; }
convert to arguments string .
1,977
private function callInitMethod ( $ instance ) { $ args = [ ] ; foreach ( $ this -> init_method_args as $ arg ) { if ( is_string ( $ arg ) && preg_match ( '/^\$([\w_]+)$/' , $ arg , $ matches ) ) { $ arg = $ this -> container -> get ( $ matches [ 1 ] ) ; } $ args [ ] = $ arg ; } call_user_func_array ( array ( $ instance , $ this -> init_method_name ) , $ args ) ; }
call init method
1,978
public function readHex ( int $ length ) { $ value = Reader :: high ( $ this -> bytes , 0 , $ length * 2 ) ; $ this -> skip ( $ length ) ; return $ value ; }
Read N characters of bytes in hex with high nibble .
1,979
public function Image ( ) { if ( $ this -> ActionImage ( ) ) { return $ this -> ActionImage ( ) ; } if ( $ this -> Type == 'SiteTree' ) { return $ this -> SiteTree ( ) -> ActionImage ( ) ; } }
Return image from current object if available or fall back the sitetree image .
1,980
public function getSummary ( ) { if ( $ this -> ActionSummary ) { return $ this -> obj ( 'ActionSummary' ) ; } if ( $ this -> Type == 'SiteTree' ) { return $ this -> SiteTree ( ) -> obj ( 'ActionSummary' ) ; } }
Return summary from current object if available or fall back the sitetree summary .
1,981
public function getLabel ( ) { if ( $ this -> ActionLabel ) { return $ this -> obj ( 'ActionLabel' ) ; } if ( $ this -> Type == 'SiteTree' ) { return $ this -> SiteTree ( ) -> obj ( 'ActionLabel' ) ; } }
Return label from current object if available or fall back the sitetree label .
1,982
public function toggle ( $ id , $ status ) { $ this -> App -> toggleField ( $ this -> Extensions , $ id , $ status ) ; }
Toggle action .
1,983
public function execute ( Framework $ framework , RequestAbstract $ request , Response $ response ) { $ this -> templatesManager -> addRenderer ( $ this -> htmlRenderer ) ; }
Register the html renderer on the templates manager to render the templates .
1,984
public function findAllWithCategories ( ) { $ qb = $ this -> getQueryBuilder ( ) -> select ( 'f, c' ) -> innerJoin ( 'f.categories' , 'c' ) -> innerJoin ( 'c.subcategories' , 's' ) ; $ qb -> orderBy ( 'f.order' , 'asc' ) -> addOrderBy ( 'c.id' , 'asc' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find all rows with their related categories
1,985
private function createCreateForm ( ProductOrderItem $ entity ) { $ form = $ this -> createForm ( new ProductOrderItemType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_orderitem_create' ) , 'method' => 'POST' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Create' ) ) ; return $ form ; }
Creates a form to create a ProductOrderItem entity .
1,986
public function newAction ( ) { $ entity = new ProductOrderItem ( ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new ProductOrderItem entity .
1,987
private function createEditForm ( ProductOrderItem $ entity ) { $ form = $ this -> createForm ( new ProductOrderItemType ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_orderitem_update' , array ( 'id' => $ entity -> getId ( ) ) ) , 'method' => 'PUT' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Update' ) ) ; return $ form ; }
Creates a form to edit a ProductOrderItem entity .
1,988
public function notifyListeners ( ) { foreach ( $ this -> listeners as $ listener ) { $ listenerClass = $ listener [ 'listener' ] ; $ handler = array ( $ listenerClass , 'on_' . $ this -> state ) ; if ( ! class_exists ( $ listenerClass ) ) { throw new \ Exception ( $ listenerClass . ' does not exist' ) ; } if ( $ this -> state == $ listener [ 'event' ] && is_callable ( $ handler ) ) { unset ( $ listener [ 'listener' ] ) ; $ eventListener = new $ listenerClass ( $ this -> logger , $ this -> request , $ this -> response ) ; $ eventListener -> setDatasources ( $ this -> datasourceFactory , $ this -> datasources ) ; $ eventListener -> setDatasourceKey ( $ this -> datasourceKey ) ; $ eventListener -> setEventDispatcher ( $ this -> eventDispatcher ) ; $ eventListener -> setConfig ( $ listener ) ; $ eventListener -> setCacheManager ( $ this -> cacheManager ) ; $ eventListener -> setContainer ( $ this -> container ) ; $ eventListener -> execute ( $ this -> state , $ this -> event ) ; } } }
traverses list of listeners and executes their calls
1,989
public function quote ( $ text , $ escape = true ) { return $ this -> db -> q ( ( $ escape ? $ this -> db -> escape ( $ text ) : $ text ) ) ; }
Quote and optionally escape a string to database requirements for insertion into the database .
1,990
protected function replace ( $ translation , $ replacement = [ ] ) { foreach ( $ replacement as $ key => $ value ) { $ translation = str_replace ( ':' . $ key , $ value , $ translation ) ; } return $ translation ; }
Make replacement .
1,991
protected function apiRequest ( $ url , $ params = array ( ) ) { if ( ! isset ( $ params [ 'api_key' ] ) && $ this -> hasAttribute ( 'api_key' ) ) $ params [ 'key' ] = $ this -> getAttribute ( 'api_key' ) ; $ query = http_build_query ( $ params , '&' ) ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url . '?' . $ query ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 ) ; $ output = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return $ output ; }
Make api request to specific url .
1,992
public function respond ( $ response = array ( ) , $ replaceResponse = false ) { $ this -> set ( $ response , $ replaceResponse ) ; if ( $ this -> hasResponded ( ) ) { return ; } $ this -> cleanBuffer ( ) ; if ( self :: $ code == 204 ) { $ this -> responseSent = true ; return ; } if ( ! empty ( $ this -> apiResponseCallback ) && is_callable ( $ this -> apiResponseCallback ) ) { $ callback = & $ this -> apiResponseCallback ; $ callback ( $ this -> response ) ; } if ( $ this -> responseFormat == 'JSON' ) { if ( $ this -> jsonCallbackWrap ) { echo $ this -> jsonCallbackWrap . '(' ; } echo json_encode ( $ this -> response ) ; if ( $ this -> jsonCallbackWrap ) { echo ');' ; } } else { throw new \ Exception ( 'Invalid response format: ' . $ this -> responseFormat ) ; } $ this -> responseSent = true ; }
Sending the response if it hasn t already been sent
1,993
protected function addListenersFromArray ( SharedEventManagerInterface $ manager , $ id , $ name ) { if ( ! isset ( $ this -> data [ $ id ] [ $ name ] ) || ( ! is_array ( $ this -> data [ $ id ] [ $ name ] ) && ! ( $ this -> data [ $ id ] [ $ name ] instanceof \ Traversable ) ) ) { return $ this ; } $ objectManager = $ this -> getObjectManager ( ) ; foreach ( $ this -> data [ $ id ] [ $ name ] as $ listener ) { if ( ! $ listener ) { continue ; } $ priority = 1 ; if ( is_array ( $ listener ) && isset ( $ listener [ 'listener' ] ) ) { $ priority = ( isset ( $ listener [ 'priority' ] ) ) ? ( int ) $ listener [ 'priority' ] : 1 ; $ listener = $ listener [ 'listener' ] ; } if ( is_string ( $ listener ) ) { $ listener = $ objectManager -> get ( $ listener ) ; } $ manager -> attach ( $ id , $ name , $ listener , $ priority ) ; } return $ this ; }
Add listeners from config array
1,994
public function configureEventManager ( SharedEventManagerInterface $ eventManager , $ id , $ eventName ) { $ quotedId = $ this -> xpathQuote ( $ id ) ; $ quotedEvent = $ this -> xpathQuote ( $ eventName ) ; $ objectManager = $ this -> getObjectManager ( ) ; $ this -> addListenersFromArray ( $ eventManager , $ id , $ eventName ) ; $ xpath = "./listener[@scope = $quotedId and @event = $quotedEvent and @class != '']" ; foreach ( $ this -> getXml ( ) -> xpath ( $ xpath ) as $ node ) { $ class = ( string ) $ node [ 'class' ] ; $ priority = ( string ) $ node [ 'priority' ] ; if ( ! $ objectManager -> has ( $ class ) ) { continue ; } $ params = array ( ) ; if ( isset ( $ node -> options ) ) { $ params = $ node -> options -> toPhpValue ( 'array' , $ objectManager ) ; } $ listener = $ objectManager -> newInstance ( $ class , $ params ) ; $ eventManager -> attach ( $ id , $ eventName , $ listener , ( int ) $ priority ) ; } return $ this ; }
Configure the event manager
1,995
public function display ( $ alias ) { $ items = Nav :: getMenu ( $ alias , true ) ; $ this -> set ( 'menuItems' , $ this -> _processMenuItems ( $ items , $ this -> request -> params ) ) ; }
Prepares the menu items before rendering the cell .
1,996
protected function _processMenuItems ( $ items , $ requestParams , & $ subActiveFound = false ) { foreach ( $ items as & $ item ) { if ( isset ( $ item [ 'url' ] ) && $ item [ 'url' ] [ 'plugin' ] === $ requestParams [ 'plugin' ] && $ item [ 'url' ] [ 'controller' ] === $ requestParams [ 'controller' ] ) { if ( ! empty ( $ item [ 'doNotMatchAction' ] ) ) { $ skip = false ; foreach ( $ item [ 'doNotMatchAction' ] as $ doNotMatchAction ) { if ( $ doNotMatchAction === $ requestParams [ 'action' ] ) { $ skip = true ; break ; } } if ( $ skip ) { continue ; } } if ( $ item [ 'matchAction' ] !== true ) { $ item [ 'active' ] = true ; $ subActiveFound = true ; } elseif ( $ item [ 'url' ] [ 'action' ] === $ requestParams [ 'action' ] ) { $ item [ 'active' ] = true ; $ subActiveFound = true ; } } if ( isset ( $ item [ 'children' ] ) && ! empty ( $ item [ 'children' ] ) ) { $ sub = false ; $ item [ 'children' ] = $ this -> _processMenuItems ( $ item [ 'children' ] , $ requestParams , $ sub ) ; if ( $ sub === true ) { $ item [ 'active' ] = true ; $ item [ 'open' ] = true ; $ subActiveFound = true ; } } } return $ items ; }
Process provided menu items and add classes active open depending on the provided request params .
1,997
public function setHtml ( $ html = null ) { $ html = trim ( $ html ) ; $ this -> html = 0 < strlen ( $ html ) ? $ html : null ; return $ this ; }
Sets the html .
1,998
private function commandBus ( ContainerBuilder $ container , $ user , $ isApi = false ) { $ apiPartName = $ isApi ? '_api' : '' ; $ busId = 'bengor.user.simple_bus_' . $ user . $ apiPartName . '_command_bus' ; $ middlewareTag = 'bengor_user_' . $ user . '_command_bus_middleware' ; $ handlerTag = 'bengor_user_' . $ user . $ apiPartName . '_command_bus_handler' ; $ container -> setDefinition ( $ busId , ( new Definition ( MessageBusSupportingMiddleware :: class ) ) -> addTag ( 'message_bus' , [ 'type' => 'command' , 'middleware_tag' => $ middlewareTag , ] ) -> setPublic ( false ) ) ; ( new ConfigureMiddlewares ( $ busId , $ middlewareTag ) ) -> process ( $ container ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.callable_resolver' , ( new Definition ( ServiceLocatorAwareCallableResolver :: class , [ [ new Reference ( 'service_container' ) , 'get' , ] , ] ) ) -> setPublic ( false ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.class_based_command_name_resolver' , ( new Definition ( ClassBasedNameResolver :: class ) ) -> setPublic ( false ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.command_handler_map' , ( new Definition ( CallableMap :: class , [ [ ] , $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.callable_resolver' ) , ] ) ) -> setPublic ( false ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.command_handler_resolver' , ( new Definition ( NameBasedMessageHandlerResolver :: class , [ $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.class_based_command_name_resolver' ) , $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.command_handler_map' ) , ] ) ) -> setPublic ( false ) ) ; $ container -> findDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.delegates_to_message_handler_middleware' ) -> addArgument ( $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.command_handler_resolver' ) ) -> setPublic ( false ) ; ( new RegisterHandlers ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_command_bus.command_handler_map' , $ handlerTag , 'handles' ) ) -> process ( $ container ) ; $ apiPartName = $ isApi ? '.api_' : '.' ; $ container -> setDefinition ( 'bengor_user.' . $ user . $ apiPartName . 'command_bus' , new Definition ( SimpleBusUserCommandBus :: class , [ $ container -> getDefinition ( $ busId ) , ] ) ) ; }
Registers the command bus for given user .
1,999
private function eventBus ( ContainerBuilder $ container , $ user ) { $ busId = 'bengor.user.simple_bus_' . $ user . '_event_bus' ; $ middlewareTag = 'bengor_user_' . $ user . '_event_bus_middleware' ; $ subscriberTag = 'bengor_user_' . $ user . '_event_subscriber' ; $ container -> setDefinition ( $ busId , ( new Definition ( MessageBusSupportingMiddleware :: class ) ) -> addTag ( 'message_bus' , [ 'type' => 'event' , 'middleware_tag' => $ middlewareTag , ] ) -> setPublic ( false ) ) ; ( new ConfigureMiddlewares ( $ busId , $ middlewareTag ) ) -> process ( $ container ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.callable_resolver' , ( new Definition ( ServiceLocatorAwareCallableResolver :: class , [ [ new Reference ( 'service_container' ) , 'get' , ] , ] ) ) -> setPublic ( false ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.class_based_event_name_resolver' , ( new Definition ( ClassBasedNameResolver :: class ) ) -> setPublic ( false ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.event_subscribers_collection' , ( new Definition ( CallableCollection :: class , [ [ ] , $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.callable_resolver' ) , ] ) ) -> setPublic ( false ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.event_subscribers_resolver' , ( new Definition ( NameBasedMessageSubscriberResolver :: class , [ $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.class_based_event_name_resolver' ) , $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.event_subscribers_collection' ) , ] ) ) -> setPublic ( false ) ) ; $ container -> findDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.delegates_to_message_handler_middleware' ) -> addArgument ( $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.event_subscribers_resolver' ) ) -> setPublic ( false ) ; ( new RegisterSubscribers ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.event_subscribers_collection' , $ subscriberTag , 'subscribes_to' ) ) -> process ( $ container ) ; $ container -> setDefinition ( 'bengor_user.' . $ user . '.event_bus' , new Definition ( SimpleBusUserEventBus :: class , [ $ container -> getDefinition ( $ busId ) , ] ) ) ; $ container -> setDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.aggregates_recorded_messages' , new Definition ( AggregatesRecordedMessages :: class , [ [ ] , ] ) ) -> setPublic ( false ) ; $ container -> findDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.handles_recorded_messages_middleware' ) -> setArguments ( [ $ container -> getDefinition ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.aggregates_recorded_messages' ) , $ container -> getDefinition ( $ busId ) , ] ) -> setPublic ( false ) ; ( new RegisterMessageRecorders ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.aggregates_recorded_messages' , 'event_recorder' ) ) -> process ( $ container ) ; CompilerPassUtil :: prependBeforeOptimizationPass ( $ container , new AddMiddlewareTags ( 'bengor_user.simple_bus_bridge_bundle.' . $ user . '_event_bus.handles_recorded_messages_middleware' , [ 'command' ] , 200 ) ) ; }
Registers the event bus for given user .