idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
33,700
public function showCategoriesTable ( DatabaseManager $ database ) { $ categories = Category :: query ( ) -> leftJoin ( 'items' ) -> addSelect ( $ database -> raw ( 'COUNT(items.item_id) as item_count' ) ) -> groupBy ( 'categories.category_id' ) ; $ table = new AdminCategories ( $ categories ) ; $ table -> with ( 'parent' ) ; return view ( 'mustard::admin.categories' , [ 'table' => $ table , 'categories' => $ table -> paginate ( ) , ] ) ; }
Return the admin categories view .
33,701
public function updateCategory ( Request $ request ) { $ this -> validate ( $ request , [ 'category_id' => 'required|integer|exists:categories' , 'parent_category_id' => 'integer|exists:categories,category_id' , 'name' => 'required' , 'slug' => 'required' , ] ) ; $ category = Category :: find ( $ request -> input ( 'category_id' ) ) ; $ parent = Category :: find ( $ request -> input ( 'parent_category_id' ) ) ; if ( in_array ( $ request -> input ( 'parent_category_id' ) , $ category -> getDescendantIds ( ) ) ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'parent_category_id' => trans ( 'mustard::admin.category_parent_is_child' ) ] ) ; } $ category -> parent ( ) -> associate ( $ parent ) ; $ category -> name = $ request -> input ( 'name' ) ; $ category -> slug = $ request -> input ( 'slug' ) ; $ category -> save ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.category_updated' ) ) ; }
Update a category .
33,702
public function deleteCategory ( Request $ request ) { $ this -> validate ( $ request , [ 'category_id' => 'required|integer|exists:categories' , ] ) ; $ category = Category :: find ( $ request -> input ( 'category_id' ) ) ; if ( $ category -> items ( ) -> count ( ) ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'category_id' => trans ( 'mustard::admin.category_has_items' ) ] ) ; } $ category -> delete ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.category_deleted' ) ) ; }
Delete a category .
33,703
public function sortCategories ( Request $ request ) { $ this -> validate ( $ request , [ 'categories' => 'required|array' , ] ) ; foreach ( $ request -> input ( 'categories' ) as $ category_id => $ sort ) { $ category = Category :: find ( $ category_id ) ; $ category -> sort = $ sort ; $ category -> save ( ) ; } return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.categories_sorted' ) ) ; }
Sort categories .
33,704
public function showItemsTable ( ) { $ table = new AdminItems ( Item :: query ( ) ) ; $ table -> with ( 'seller' ) ; if ( mustard_loaded ( 'feedback' ) ) { $ table -> with ( 'seller.feedbackReceived' ) ; } return view ( 'mustard::admin.items' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; }
Return the admin items view .
33,705
public function updateItemCondition ( Request $ request ) { $ this -> validate ( $ request , [ 'item_condition_id' => 'required|integer|exists:item_conditions' , 'name' => 'required' , ] ) ; $ item_condition = ItemCondition :: find ( $ request -> input ( 'item_condition_id' ) ) ; $ item_condition -> name = $ request -> input ( 'name' ) ; $ item_condition -> save ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.item_condition_updated' ) ) ; }
Update an item condition .
33,706
public function deleteItemCondition ( Request $ request ) { $ this -> validate ( $ request , [ 'item_condition_id' => 'required|integer|exists:item_conditions' , ] ) ; $ item_condition = ItemCondition :: find ( $ request -> input ( 'item_condition_id' ) ) ; if ( $ item_condition -> items ( ) -> count ( ) ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'item_condition_id' => trans ( 'mustard::admin.item_condition_has_items' ) ] ) ; } $ item_condition -> delete ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.item_condition_deleted' ) ) ; }
Delete an item condition .
33,707
public function sortItemConditions ( Request $ request ) { $ this -> validate ( $ request , [ 'item_conditions' => 'required|array' , ] ) ; foreach ( $ request -> input ( 'item_conditions' ) as $ item_condition_id => $ sort ) { $ item_condition = ItemCondition :: find ( $ item_condition_id ) ; $ item_condition -> sort = $ sort ; $ item_condition -> save ( ) ; } return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.item_conditions_sorted' ) ) ; }
Sort item conditions .
33,708
public function createListingDuration ( Request $ request ) { $ this -> validate ( $ request , [ 'duration' => 'required|integer' , ] ) ; $ listing_duration = new ListingDuration ( ) ; $ listing_duration -> duration = $ request -> input ( 'duration' ) ; $ listing_duration -> save ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.listing_duration_created' ) ) ; }
Create a listing duration .
33,709
public function deleteListingDuration ( Request $ request ) { $ this -> validate ( $ request , [ 'listing_duration_id' => 'required|integer|exists:listing_durations' , ] ) ; $ listing_duration = ListingDuration :: find ( $ request -> input ( 'listing_duration_id' ) ) ; $ listing_duration -> delete ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.listing_duration_deleted' ) ) ; }
Delete a listing duration .
33,710
public function sortListingDurations ( Request $ request ) { $ this -> validate ( $ request , [ 'listing_durations' => 'required|array' , ] ) ; foreach ( $ request -> input ( 'listing_durations' ) as $ listing_duration_id => $ sort ) { $ listing_duration = ListingDuration :: find ( $ listing_duration_id ) ; $ listing_duration -> sort = $ sort ; $ listing_duration -> save ( ) ; } return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.listing_durations_sorted' ) ) ; }
Sort listing durations .
33,711
public function showUsersTable ( ) { $ table = new AdminUsers ( User :: query ( ) ) ; if ( mustard_loaded ( 'feedback' ) ) { $ table -> with ( 'feedbackReceived' ) ; } return view ( 'mustard::admin.users' , [ 'table' => $ table , 'users' => $ table -> paginate ( ) , ] ) ; }
Return the admin users view .
33,712
public function showSettingsTable ( ) { $ config = config ( 'mustard' ) ; array_walk ( $ config , function ( & $ value ) { if ( ! is_scalar ( $ value ) || is_bool ( $ value ) ) { $ value = var_export ( $ value , true ) ; } } ) ; $ table = new AdminSettings ( $ config ) ; return view ( 'mustard::admin.settings' , [ 'table' => $ table , 'settings' => $ table -> paginate ( ) , ] ) ; }
Return the admin settings view .
33,713
public function sendMailout ( Request $ request ) { $ this -> validate ( $ request , [ 'users' => 'required|array' , 'subject' => 'required|min:4' , 'body' => 'required|min:10' , ] ) ; $ count = 0 ; foreach ( User :: all ( ) as $ user ) { if ( in_array ( $ user -> userId , $ request -> input ( 'users' ) ) ) { $ user -> sendEmail ( $ request -> input ( 'subject' ) , 'mustard::emails.mailout' , [ 'body' => $ request -> input ( 'body' ) , 'username' => $ user -> username , ] ) ; $ count ++ ; } } return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.mailout_sent' , [ 'count' => $ count ] ) ) ; }
Send a mailout .
33,714
public static function append ( ) { if ( error_reporting ( ) !== E_ALL ) { return ; } $ value = func_get_args ( ) ; if ( count ( $ value ) < 2 ) { $ value = reset ( $ value ) ; } $ debugobj = new stdClass ( ) ; $ debugobj -> time = Timer :: benchScript ( 5 ) ; $ debugobj -> mu = memory_get_usage ( ) ; $ debugobj -> type = gettype ( $ value ) ; if ( is_array ( $ value ) || is_object ( $ value ) ) { $ debugobj -> data = @ print_r ( $ value , true ) ; } else { $ debugobj -> data = $ value ; } $ backtrace = debug_backtrace ( ) ; $ calledFrom = '' ; if ( isset ( $ backtrace [ 3 ] [ 'function' ] ) ) { $ calledFrom = $ backtrace [ 3 ] [ 'function' ] ; } $ debugobj -> backtrace = "{$backtrace[2]['file']} line {$backtrace[2]['line']} (Called from {$calledFrom}())" ; if ( self :: $ shutdown === false ) { register_shutdown_function ( array ( "Libvaloa\Debug\Debug" , 'dump' ) ) ; self :: $ shutdown = true ; } self :: $ data [ ] = $ debugobj ; }
Append debug messages to debug object .
33,715
public static function dump ( ) { if ( error_reporting ( ) !== E_ALL ) { return ; } print '<pre class="libvaloa--debug">' ; foreach ( self :: $ data as $ v ) { echo sprintf ( '<code><strong>%s</strong> <br/> Memory usage %s bytes<br/> %s&#160;[%s]&#160;%s</code><br/>' , $ v -> backtrace , $ v -> mu , $ v -> time , $ v -> type , ( in_array ( $ v -> type , array ( 'array' , 'object' ) , true ) ? '<code>' . $ v -> data . '</code>' : $ v -> data ) ) ; } print '</pre>' ; self :: $ data = array ( ) ; }
Dump debug messages at shutdown .
33,716
public static function __print ( ) { if ( error_reporting ( ) !== E_ALL ) { return ; } if ( isset ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower ( $ _SERVER [ 'HTTP_X_REQUESTED_WITH' ] ) === 'xmlhttprequest' ) { return ; if ( isset ( $ _SERVER [ 'HTTP_ACCEPT' ] ) && in_array ( 'application/json' , explode ( ',' , $ _SERVER [ 'HTTP_ACCEPT' ] ) , true ) ) { return ; } } $ a = func_get_args ( ) ; call_user_func_array ( array ( "\Libvaloa\Debug\Debug" , 'append' ) , $ a ) ; }
Prints debug message with backtrace when E_ALL error level is set .
33,717
public function append ( $ section , array $ config ) { $ config = array_merge ( [ 'config' => null , 'view' => null , 'script' => null , 'menu' => null , 'style' => null , 'form' => null , 'meta' => null , 'position' => 0 ] , $ config ) ; if ( $ html = $ this -> renderByType ( $ config ) ) { $ this -> inject ( $ section , $ html ) ; } }
Inject views into layouts
33,718
private function getCachedKeys ( ) { $ key = 'courier_cached_requests' ; if ( $ this -> cache -> isExisting ( $ key ) ) { return $ this -> cache -> get ( $ key ) ; } $ newIndex = [ ] ; $ this -> cache -> set ( $ key , $ newIndex ) ; return $ newIndex ; }
Get the index from the cache and store a new one if it does not yet exist
33,719
private function setCachePath ( ) { $ cachePath = __DIR__ . '/../../.cache' ; if ( ! is_dir ( $ cachePath ) ) { mkdir ( $ cachePath ) ; chmod ( $ cachePath , 0777 ) ; } phpFastCache :: setup ( "path" , $ cachePath ) ; phpFastCache :: setup ( "htaccess" , false ) ; }
Set the path where cache files should be stored
33,720
public function handler ( ) { $ handler = $ this -> pop ( ) ; if ( null !== $ handler ) { $ this -> push ( $ handler ) ; } return $ handler ; }
Gets the current handler without removing it from the stack .
33,721
public function executeWith ( $ callable , $ handler = null ) { $ handlers = $ this -> clear ( ) ; if ( null !== $ handler ) { $ this -> push ( $ handler ) ; } $ error = null ; try { $ result = $ callable ( ) ; } catch ( Exception $ error ) { } $ this -> restore ( $ handlers ) ; if ( null !== $ error ) { throw $ error ; } return $ result ; }
Temporarily bypass the current handler stack and execute a callable with the supplied handler .
33,722
public function addWorkflowProfile ( GroupFormEvent $ event ) { $ builder = $ event -> getBuilder ( ) ; $ group = $ builder -> getData ( ) ; $ configuration = array ( ) ; $ workflowProfiles = $ this -> workflowProfileRepository -> findAll ( ) ; foreach ( $ workflowProfiles as $ workflowProfile ) { $ configuration [ 'default' ] [ 'row' ] [ ] = $ workflowProfile -> getLabel ( $ this -> contextManager -> getBackOfficeLanguage ( ) ) ; } $ configuration [ 'default' ] [ 'column' ] [ NodeInterface :: ENTITY_TYPE ] = $ this -> translator -> trans ( 'open_orchestra_workflow_admin.profile.page' ) ; if ( $ group instanceof GroupInterface ) { $ site = $ group -> getSite ( ) ; if ( ! empty ( $ site -> getContentTypes ( ) ) ) { $ contentTypes = $ this -> contentTypeRepository -> findAllNotDeletedInLastVersion ( $ site -> getContentTypes ( ) ) ; foreach ( $ contentTypes as $ contentType ) { $ configuration [ 'default' ] [ 'column' ] [ $ contentType -> getContentTypeId ( ) ] = $ contentType -> getName ( $ this -> contextManager -> getBackOfficeLanguage ( ) ) ; } } } $ builder -> setAttribute ( 'group_render' , array_merge ( $ builder -> getAttribute ( 'group_render' ) , array ( 'profile' => array ( 'rank' => '2' , 'label' => 'open_orchestra_workflow_admin.form.profile' , ) ) ) ) ; $ builder -> setAttribute ( 'sub_group_render' , array_merge ( $ builder -> getAttribute ( 'sub_group_render' ) , array ( 'backoffice' => array ( 'rank' => '0' , 'label' => 'open_orchestra_workflow_admin.form.backoffice' , ) ) ) ) ; $ builder -> add ( 'workflow_profile_collections' , 'oo_check_list_collection' , array ( 'label' => false , 'configuration' => $ configuration , 'group_id' => 'profile' , 'sub_group_id' => 'backoffice' , 'required' => false ) ) ; $ builder -> get ( 'workflow_profile_collections' ) -> addModelTransformer ( $ this -> workflowProfileCollectionTransformer ) ; }
add workflowProfile choice to group form
33,723
public function cdn ( CdnRequest $ request , $ folder , $ file ) { $ mode = 'resize' ; $ width = null ; $ height = null ; $ path = $ folder . '/' . $ file ; if ( $ request -> has ( 'mode' ) ) { $ mode = $ request -> get ( 'mode' ) ; } if ( $ request -> has ( 'width' ) ) { $ width = $ request -> get ( 'width' ) ; } if ( $ request -> has ( 'height' ) ) { $ height = $ request -> get ( 'height' ) ; } if ( $ request -> has ( 'w' ) ) { $ width = $ request -> get ( 'w' ) ; } if ( $ request -> has ( 'h' ) ) { $ height = $ request -> get ( 'h' ) ; } return app ( PublicFolderCache :: class ) -> cache ( $ path , $ width , $ height , $ mode ) ; }
Assets CDN endpoint .
33,724
public function parse ( \ Twig_NodeInterface $ node ) { foreach ( $ node as $ subNode ) { if ( ! $ subNode instanceof \ Twig_NodeInterface ) { continue ; } $ nodeClass = get_class ( $ subNode ) ; switch ( $ nodeClass ) { case 'Twig_Node_Set' : $ this -> context [ ] = $ this -> env -> getCompiler ( ) -> compile ( $ subNode ) -> getSource ( ) ; break ; default : $ this -> parse ( $ subNode ) ; break ; } } return $ this ; }
Parses the template node recursively
33,725
public function getContext ( ) { if ( empty ( $ this -> context ) ) { return ; } array_unshift ( $ this -> context , "<?php \$context = array(); \n" ) ; $ this -> context [ ] = "return \$context;" ; $ context = implode ( null , $ this -> context ) ; $ this -> context = null ; return eval ( '?>' . $ context ) ; }
Returns the node context
33,726
public function parseResponse ( $ response ) { $ response = explode ( "\r\n\r\n" , $ response ) ; $ this -> body = array_pop ( $ response ) ; if ( empty ( $ this -> body ) ) { $ this -> body = null ; } $ this -> headers = new \ OtherCode \ Rest \ Payloads \ Headers ( array_pop ( $ response ) ) ; if ( isset ( $ this -> headers [ 'Content-Type' ] ) ) { $ content_type = explode ( ';' , $ this -> headers [ 'Content-Type' ] ) ; $ this -> content_type = $ content_type [ 0 ] ; } if ( ! isset ( $ this -> charset ) ) { $ this -> charset = substr ( $ this -> content_type , 5 ) === 'text/' ? 'iso-8859-1' : 'utf-8' ; } }
Parse the response
33,727
protected function registerAssets ( $ files ) { foreach ( $ files as $ type => $ _files ) { if ( $ type == 'script' ) { foreach ( $ _files as $ file ) { $ this -> view -> registerJsFile ( $ this -> assetUrl . $ file ) ; } } else { foreach ( $ _files as $ file ) { $ this -> view -> registerCssFile ( $ this -> assetUrl . $ file ) ; } } } }
Register asset bundle to Yii view
33,728
private function releaseAssets ( ) { $ assetDir = dirname ( __FILE__ ) . DIRECTORY_SEPARATOR . 'assets' ; $ dirs = \ Yii :: $ app -> assetManager -> publish ( $ assetDir , [ 'forceCopy' => YII_DEBUG ] ) ; return BaseUrl :: base ( true ) . $ dirs [ 1 ] . '/' ; }
Publish widget assets and return published url
33,729
public function getImgTag ( $ relativeName , $ filter ) { $ imgUrlHelper = $ this -> getView ( ) -> plugin ( 'HtImgModule\View\Helper\ImgUrl' ) ; $ this -> attributes [ 'src' ] = $ imgUrlHelper ( $ relativeName , $ filter ) ; ; $ html = '<img' . $ this -> htmlAttribs ( $ this -> getAttributes ( ) ) . $ this -> getClosingBracket ( ) ; return $ html ; }
Return valid HTML image tag
33,730
public static function create ( $ name , $ type = NULL , $ defaultValue = self :: UNDEFINED , $ modifiers = self :: MODIFIER_PROTECTED ) { if ( isset ( $ type ) ) { if ( $ type instanceof GClass ) { $ type = new ObjectType ( new GClass ( $ type -> getFQN ( ) ) ) ; } elseif ( ! ( $ type instanceof Type ) ) { $ type = Type :: create ( $ type ) ; } } return new static ( $ name , $ type , $ defaultValue , $ modifiers ) ; }
Creates a new GProperty
33,731
public function getCountries ( $ includeNoLongerUsingVAT = false ) { if ( $ includeNoLongerUsingVAT ) { return $ this -> countries ; } return array_filter ( $ this -> countries , function ( $ country ) { return $ country -> usedVATOnCurrentDate ( ) ; } ) ; }
Get the countries that used VAT at the current date . Optionally include countries that no longer use VAT .
33,732
public function getCountry ( $ countryCode ) { $ countryCode = strtoupper ( $ countryCode ) ; $ result = current ( array_filter ( $ this -> countries , function ( $ country ) use ( $ countryCode ) { return ( $ country -> getCode ( ) == $ countryCode || $ country -> getCountryCode ( ) == $ countryCode ) ; } ) ) ; return $ result != false ? $ result : null ; }
Find a country that used VAT at the current date .
33,733
public function isVATCountry ( $ countryCode ) { $ country = $ this -> getCountry ( $ countryCode ) ; return ! is_null ( $ country ) && $ country -> usedVATOnCurrentDate ( ) ; }
Check if a country used VAT at the current date .
33,734
public function getSuperReducedRate ( $ countryCode ) { $ country = $ this -> getCountry ( $ countryCode ) ; if ( ! is_null ( $ country ) ) { return $ country -> getSuperReducedRate ( ) ; } return null ; }
Get the super reduced rate for a country .
33,735
public function getReducedRates ( $ countryCode ) { $ country = $ this -> getCountry ( $ countryCode ) ; if ( ! is_null ( $ country ) ) { return $ country -> getReducedRates ( ) ; } return null ; }
Get the reduced rates for a country .
33,736
public function getStandardRate ( $ countryCode ) { $ country = $ this -> getCountry ( $ countryCode ) ; if ( ! is_null ( $ country ) ) { return $ country -> getStandardRate ( ) ; } return null ; }
Get the standard rate for a country .
33,737
public function getParkingRate ( $ countryCode ) { $ country = $ this -> getCountry ( $ countryCode ) ; if ( ! is_null ( $ country ) ) { return $ country -> getParkingRate ( ) ; } return null ; }
Get the parking rate for a country .
33,738
public function onBeforeWrite ( ) { parent :: onBeforeWrite ( ) ; $ slug = singleton ( 'SiteTree' ) -> generateURLSegment ( $ this -> Identifier ) ; $ original_slug = $ slug ; $ i = 0 ; while ( $ t = PermamailTemplate :: get ( ) -> filter ( array ( "Identifier" => "$slug" ) ) -> exclude ( array ( "ID" => $ this -> ID ) ) -> first ( ) ) { $ i ++ ; $ slug = $ original_slug . "-{$i}" ; } $ this -> Identifier = $ slug ; $ reflector = EmailReflectionTemplate :: create ( ) ; $ reflector -> process ( $ this -> Content ) ; $ vars = array ( ) ; foreach ( $ reflector -> getTopLevelVars ( ) as $ var => $ type ) { $ vars [ $ var ] = false ; } foreach ( $ reflector -> getTopLevelBlocks ( ) as $ block ) { $ vars [ $ block -> getName ( ) ] = $ block -> isLoop ( ) ; } if ( $ this -> TestVariables ( ) -> exists ( ) ) { $ this -> TestVariables ( ) -> exclude ( array ( 'Variable' => array_keys ( $ vars ) ) ) -> removeAll ( ) ; } $ currentVars = $ this -> TestVariables ( ) -> column ( 'Variable' ) ; foreach ( $ vars as $ var => $ isList ) { if ( ! in_array ( $ var , $ currentVars ) ) { $ v = PermamailTemplateVariable :: create ( array ( 'Variable' => $ var , 'PermamailTemplateID' => $ this -> ID , 'List' => $ isList ) ) ; $ v -> write ( ) ; } } }
Sanitise the identifier and populate the variables list
33,739
public function getRecords ( $ zone , $ force = false ) { if ( ! isset ( $ this -> zones [ $ zone ] ) ) { throw new \ Exception ( "Unknown zone {$zone} requested, did you call getZones() first?" ) ; } if ( ! isset ( $ this -> zonerecords [ $ zone ] ) || $ force ) { $ this -> zonerecords [ $ zone ] = $ this -> fetchRecords ( $ zone ) ; } return $ this -> zonerecords [ $ zone ] ; }
User facing function to return possibly cached records for a zone by name
33,740
public static function preloadAddresses ( $ value , $ origin = null , $ fieldValues = null ) { if ( $ value ) { if ( $ origin == 'client' ) { $ result = collect ( Client :: where ( 'id' , $ value ) -> first ( ) -> addresses -> all ( ) ) -> transform ( function ( $ item ) { return [ 'label' => $ item [ 'name' ] , 'display' => $ item [ 'name' ] , 'value' => $ item [ 'id' ] , ] ; } ) -> toArray ( ) ; } if ( $ origin == 'costCenter' ) { $ result = collect ( CostCenter :: where ( 'id' , $ value ) -> first ( ) -> addresses -> all ( ) ) -> transform ( function ( $ item ) { return [ 'label' => $ item [ 'name' ] , 'display' => $ item [ 'name' ] , 'value' => $ item [ 'id' ] , ] ; } ) -> toArray ( ) ; } return [ 'options' => $ result ] ; } else { return [ 'label' => null , 'options' => null , 'value' => null ] ; } }
cost center addresses + the client addresses .
33,741
public function getParam ( $ name ) { if ( empty ( $ name ) || ! is_string ( $ name ) ) { throw new \ InvalidArgumentException ( 'Paramater name must be not empty string' ) ; } if ( isset ( $ this -> params [ $ name ] ) || array_key_exists ( $ name , $ this -> params ) ) { return $ this -> params [ $ name ] ; } throw new ConfigurationException ( sprintf ( 'Parameter %s doesn\'t exists' , $ name ) ) ; }
Returns value gateway param
33,742
public function setFallbackHandler ( $ fallbackHandler = null ) { if ( null === $ fallbackHandler ) { $ fallbackHandler = function ( ) { return false ; } ; } $ this -> fallbackHandler = $ fallbackHandler ; }
Set an error handler to use as a fallback for errors that are not handled by Asplode .
33,743
public function install ( ) { if ( 0 === $ this -> isolator -> error_reporting ( ) ) { throw new ErrorHandlingConfigurationException ( ) ; } if ( $ this -> isInstalled ( ) ) { throw new AlreadyInstalledException ( ) ; } $ this -> stack -> push ( $ this ) ; }
Installs this error handler .
33,744
public function uninstall ( ) { $ handler = $ this -> stack -> pop ( ) ; if ( $ handler !== $ this ) { if ( null !== $ handler ) { $ this -> stack -> push ( $ handler ) ; } throw new NotInstalledException ( ) ; } }
Uninstalls this error handler .
33,745
public function handle ( $ severity , $ message , $ filename , $ lineno ) { if ( E_DEPRECATED === $ severity || E_USER_DEPRECATED === $ severity || 0 === $ this -> isolator -> error_reporting ( ) ) { $ fallbackHandler = $ this -> fallbackHandler ( ) ; return $ fallbackHandler ( $ severity , $ message , $ filename , $ lineno ) ; } throw new ErrorException ( $ message , $ severity , $ filename , $ lineno ) ; }
Handles a PHP error .
33,746
public function getRecommendedItems ( $ userId , $ itemCount = 3 ) { $ response = $ this -> sendQuery ( [ 'user' => $ userId , 'num' => intval ( $ itemCount ) ] ) ; return $ response ; }
Returns the recommendations for the given user .
33,747
public function getSimilarItems ( $ items , $ itemCount = 3 ) { if ( ! is_array ( $ items ) ) { $ items = [ $ items ] ; } $ response = $ this -> sendQuery ( [ 'items' => $ items , 'num' => intval ( $ itemCount ) ] ) ; return $ response ; }
Returns the items similar to the given item .
33,748
public function getSafeList ( $ count = null , $ maxId = null , $ sinceId = null ) { $ parameters = array ( 'count' => $ count , 'max_id' => $ maxId , 'since_id' => $ sinceId , ) ; $ parameters = array_filter ( $ parameters , function ( $ val ) { return ! is_null ( $ val ) ; } ) ; return $ this -> online -> call ( '/storage/c14/safe' , 'GET' , $ parameters ) ; }
Returns a list of links to the user s safes .
33,749
public function createSafe ( $ name , $ description ) { $ parameters = array ( 'name' => $ name , 'description' => $ description , ) ; return $ this -> online -> call ( '/storage/c14/safe' , 'POST' , $ parameters ) ; }
Creates a safe on the user s account returns its id with an HTTP code 201 .
33,750
public function updateSafe ( $ uuidSafe , $ name , $ description ) { $ parameters = array ( 'name' => $ name , 'description' => $ description , ) ; return $ this -> online -> call ( '/storage/c14/safe/' . $ uuidSafe , 'PATCH' , $ parameters ) ; }
Edits a safe on the user s account . Returns nothing with an HTTP code 204 .
33,751
public function createArchive ( $ uuidSafe , $ name , $ description , $ parity = null , $ protocols = array ( ) , $ sshKeys = array ( ) , $ days = null , $ platforms = array ( ) ) { if ( ! in_array ( $ parity , array ( self :: PARITY_STD , self :: PARITY_ENT ) ) ) { $ parity = self :: PARITY_STD ; } $ days = intval ( $ days ) ; if ( ! in_array ( $ days , array ( 2 , 5 , 7 ) ) ) { $ days = 7 ; } $ parameters = array ( 'name' => $ name , 'description' => $ description , 'parity' => $ parity , 'protocols' => $ protocols , 'ssh_keys' => $ sshKeys , 'days' => $ days , 'platforms' => $ platforms , ) ; return $ this -> online -> call ( '/storage/c14/safe/' . $ uuidSafe . '/archive' , 'POST' , $ parameters ) ; }
Creates an archive in the safe returns its id with an HTTP code 201 .
33,752
public function updateArchive ( $ uuidSafe , $ uuidArchive , $ name , $ description ) { $ parameters = array ( 'name' => $ name , 'description' => $ description , ) ; $ this -> online -> call ( '/storage/c14/safe/' . $ uuidSafe . '/archive/' . $ uuidArchive , 'PATCH' , $ parameters ) ; }
Edits an archive . Returns nothing with an HTTP code 204 .
33,753
public function getJobDetails ( $ uuidSafe , $ uuidArchive , $ uuidJob ) { return $ this -> online -> call ( '/storage/c14/safe/' . $ uuidSafe . '/archive/' . $ uuidArchive . '/job/' . $ uuidJob ) ; }
Returns information of a job .
33,754
public function enterKey ( $ uuidSafe , $ uuidArchive , $ key ) { $ parameters = array ( 'key' => $ key , ) ; $ this -> online -> call ( '/storage/c14/safe/' . $ uuidSafe . '/archive/' . $ uuidArchive . '/key' , 'POST' , $ parameters ) ; }
Sets an archive s encryption key . Returns nothing with an HTTP code 204 .
33,755
public function doUnarchive ( $ uuidSafe , $ uuidArchive , $ locationId , $ rearchive = true , $ key = '' , $ protocols = array ( ) , $ sshKeys = array ( ) ) { $ parameters = array ( 'location_id' => ( string ) $ locationId , 'rearchive' => ( bool ) $ rearchive , 'key' => $ key , 'protocols' => $ protocols , 'ssh_keys' => $ sshKeys , ) ; return $ this -> online -> call ( '/storage/c14/safe/' . $ uuidSafe . '/archive/' . $ uuidArchive . '/unarchive' , 'POST' , $ parameters ) ; }
Unarchives files into temporary storage returns true with an HTTP code 202 .
33,756
public function addReferencesToEntity ( $ entity ) { foreach ( $ this -> strategies as $ strategy ) { $ strategy -> addReferencesToEntity ( $ entity ) ; } $ this -> objectManager -> flush ( ) ; }
Update Keyword References
33,757
public function getPostalInfo ( $ type ) { if ( ! in_array ( $ type , [ PostalInfo :: TYPE_INT , PostalInfo :: TYPE_LOC ] ) ) { throw new UnexpectedValueException ( sprintf ( 'The value of the parameter \'type\' must be set to \'%s\' or \'%s\'.' , PostalInfo :: TYPE_INT , PostalInfo :: TYPE_LOC ) ) ; } $ query = sprintf ( '//epp:epp/epp:response/epp:resData/contact:infData/contact:postalInfo[@type=\'%s\']' , $ type ) ; $ node = $ this -> getFirst ( $ query ) ; if ( $ node === null ) { return null ; } return new PostalInfoHelper ( $ this , $ node ) ; }
Getting the postal - address information by type .
33,758
public function getDisclose ( ) { $ node = $ this -> getFirst ( '//epp:epp/epp:response/epp:resData/contact:infData/contact:disclose' ) ; if ( $ node === null ) { return null ; } return new Disclose ( $ this , $ node ) ; }
The contact s disclosure preferences .
33,759
protected function respond ( $ event , $ error , $ status , $ payload = [ ] ) { $ response = $ this -> events -> fire ( $ event , $ payload , true ) ; $ jsonApiError = new JsonApiError ( str_replace ( '_' , ' ' , $ error ) ) ; $ jsonApiError -> setStatusCode ( $ status ) ; return $ response ? : $ this -> response -> json ( [ 'errors' => [ $ jsonApiError ] ] , $ status ) ; }
Fire event and return the response .
33,760
public function toArray ( ) { if ( $ this -> getResponseType ( ) == 'application/json' ) { $ response = $ this -> convertJsonToArray ( $ this -> getBody ( ) ) ; } elseif ( $ this -> getResponseType ( ) == 'application/binary' ) { $ response = $ this -> convertSerializedToArray ( $ this -> getBody ( ) ) ; } else { $ response = null ; } if ( ! is_array ( $ response ) ) { $ this -> throwResponseConversionException ( ) ; } return $ response ; }
Convert the response body to an array
33,761
public function toObjects ( ) { if ( $ this -> getResponseType ( ) == 'application/json' ) { $ response = $ this -> convertJsonToObjects ( $ this -> getBody ( ) ) ; } elseif ( $ this -> getResponseType ( ) == 'application/binary' ) { $ response = $ this -> convertSerializedToObjects ( $ this -> getBody ( ) ) ; } else { $ response = null ; } if ( ! $ response ) { $ this -> throwResponseConversionException ( ) ; } return $ response ; }
Convert the response body to PHP Objects
33,762
private function convertSerializedToArray ( $ data ) { $ data = @ unserialize ( $ data ) ; if ( is_string ( $ data ) ) { return $ this -> convertJsonToArray ( $ data ) ; } if ( ( is_object ( $ data ) or is_array ( $ data ) ) and $ json = $ this -> convertToJson ( $ data ) ) { return $ this -> convertJsonToArray ( $ json ) ; } return null ; }
Convert a serialized response to an array
33,763
private function convertSerializedToObjects ( $ data ) { $ data = @ unserialize ( $ data ) ; if ( is_object ( $ data ) ) { return $ data ; } if ( is_array ( $ data ) and $ json = $ this -> convertToJson ( $ data ) ) { return $ this -> convertJsonToObjects ( $ json ) ; } return null ; }
Convert a serialized response to objects
33,764
protected function registerPlugin ( $ name ) { $ view = $ this -> getView ( ) ; MaterializePluginAsset :: register ( $ view ) ; $ id = $ this -> options [ 'id' ] ; if ( $ this -> clientOptions !== false ) { $ options = empty ( $ this -> clientOptions ) ? '' : Json :: encode ( $ this -> clientOptions ) ; $ js = "jQuery('#$id').$name($options);" ; $ view -> registerJs ( $ js ) ; } $ this -> registerClientEvents ( ) ; }
Registers a specific Materialize plugin and the related events
33,765
public function addDecoder ( DecoderInterface $ decoder ) { $ mimeTypes = $ decoder -> getMimeType ( ) ; if ( $ this -> isSupportedMimeType ( $ mimeTypes [ 0 ] ) ) { return ; } $ this -> supportedMimeTypes = array_merge ( $ this -> supportedMimeTypes , $ mimeTypes ) ; foreach ( $ mimeTypes as $ type ) { $ this -> decoders [ $ type ] = $ decoder ; } }
Add a file decoder to the FileLoader
33,766
public function addFiles ( $ files ) { if ( $ files instanceof FileBag ) { $ this -> fileBag = $ files ; return ; } if ( is_array ( $ files ) ) { $ this -> fileBag = new FileBag ( $ files ) ; return ; } throw new BadFileDataException ( 'The attempt at adding files to the file loader failed, due to the files not being a FileBag Object or an array of SplInfoObjects.' ) ; }
Add a file bag or change an array of SplFileInfo Objects to proper objects .
33,767
public function process ( $ ns = true , $ strict = true ) { return $ this -> decodedData = $ this -> decodeFileBagData ( $ this -> fileBag , $ ns , $ strict ) ; }
Process the current FileBag and return an array
33,768
public function decodeFileBagData ( FileBag $ fileBag , $ ns = true , $ strict = true ) { $ decodedData = [ ] ; $ files = $ fileBag -> getAllFileInfoObjects ( ) ; if ( empty ( $ files ) ) { throw new Exception ( "FileBag is empty. Make sure you have initialized the FileLoader and added files." ) ; } foreach ( $ files as $ file ) { list ( $ namespace , $ file ) = $ this -> getFilesNamespace ( $ file ) ; $ fileData = $ this -> decodeFile ( $ file , $ strict ) ; if ( is_array ( $ fileData ) ) { foreach ( $ fileData as $ k => $ v ) { if ( $ ns === true ) { $ decodedData [ $ namespace ] [ $ k ] = $ v ; } else { $ decodedData [ $ k ] = $ v ; } } } } if ( ! empty ( $ this -> unsupportedFiles ) ) { $ badFiles = implode ( ", " , $ this -> unsupportedFiles ) ; throw new UnsupportedFilesException ( 'The file(s) ' . $ badFiles . ' are not supported by the available decoders.' ) ; } return $ decodedData ; }
Process file bag to load into the data manager . A file bag is an array of SplFileInfo objects .
33,769
protected function checkAndAddDefaultDecoder ( $ mimeType ) { $ decoderClass = ucfirst ( $ mimeType ) . "Decoder" ; if ( file_exists ( __DIR__ . '/Decoders/' . $ decoderClass . '.php' ) && ! $ this -> isSupportedMimeType ( $ mimeType ) ) { $ nameSpace = "Michaels\\Manager\\Decoders\\" ; $ fullQualifiedClassName = $ nameSpace . $ decoderClass ; $ decoder = new $ fullQualifiedClassName ( ) ; $ this -> addDecoder ( $ decoder ) ; } }
Default decoder class factory method . Checks to make sure we have a default decoder available and if so adds it as a decoder to the file loader .
33,770
protected function decodeFile ( \ SplFileInfo $ file , $ strict = true ) { $ mimeType = $ file -> getExtension ( ) ; $ this -> checkAndAddDefaultDecoder ( $ mimeType ) ; if ( $ this -> isSupportedMimeType ( $ mimeType ) ) { if ( is_readable ( $ file -> getPathname ( ) ) ) { $ data = $ this -> getFileContents ( $ file ) ; } else { if ( $ strict ) { throw new \ Exception ( "File not found: {$file->getPathname()}" ) ; } else { return [ ] ; } } return $ this -> decoders [ $ mimeType ] -> decode ( $ data ) ; } $ this -> unsupportedFiles [ ] = $ file -> getFilename ( ) ; return false ; }
Decodes a single file using registered decoders
33,771
public function sanitizeNamespace ( $ ns ) { $ ns = str_replace ( "." , "_" , $ ns ) ; $ ns = str_replace ( " " , "_" , $ ns ) ; $ ns = str_replace ( "-" , "_" , $ ns ) ; $ ns = preg_replace ( "/[^A-Za-z0-9\.\_\- ]/" , '' , $ ns ) ; return $ ns ; }
Cleans up a file name for use as a namespace
33,772
protected function getFilesNamespace ( $ file ) { $ namespace = null ; if ( is_array ( $ file ) ) { $ namespace = $ this -> sanitizeNamespace ( $ file [ 1 ] ) ; $ file = $ file [ 0 ] ; return [ $ namespace , $ file ] ; } else { $ filename = rtrim ( $ file -> getBasename ( ) , '.' . $ file -> getExtension ( ) ) ; $ namespace = $ this -> sanitizeNamespace ( $ filename ) ; return [ $ namespace , $ file ] ; } }
Gets or creates the file s namespace
33,773
public function boot ( ) { $ configFile = realpath ( __DIR__ . '/../config/json-api.php' ) ; $ this -> mergeConfigFrom ( $ configFile , 'json-api' ) ; $ this -> publishes ( [ $ configFile => config_path ( 'json-api.php' ) , ] ) ; if ( config ( 'json-api.routes.configure' , false ) ) { if ( ! $ this -> app -> routesAreCached ( ) ) { Route :: group ( [ ] , function ( Router $ router ) { require __DIR__ . '/../routes/api.php' ; } ) ; } } }
boot with router
33,774
public function init ( ) { parent :: init ( ) ; if ( ! $ this -> keepFileName ) { $ this -> filename = $ this -> generateNewFilename ( ) ; } if ( empty ( $ this -> uploadDirectory ) ) { $ this -> uploadDirectory = Media :: getCurrentDirectory ( ) ; } }
Setup default options if user does not wanna define
33,775
private function generateNewFilename ( ) { $ time = time ( ) ; $ filename = $ this -> filename ; $ ext = end ( explode ( "." , $ filename ) ) ; do { $ filename = substr ( md5 ( $ filename . $ time ) , 0 , 8 ) . '.' . $ ext ; } while ( file_exists ( $ this -> uploadDirectory . DIRECTORY_SEPARATOR . $ filename ) ) ; return $ filename ; }
Auto generate new random file name
33,776
protected function processarTrailerArquivo ( $ linha ) { $ trailer = $ this -> createTrailer ( ) ; $ banco = new Banco ( ) ; $ banco -> setCod ( $ linha -> substr ( 5 , 3 ) -> trim ( ) ) ; $ simples = new Cobranca ( ) ; $ simples -> setQtdTitulos ( $ linha -> substr ( 18 , 8 ) -> trim ( ) ) -> setValorTotal ( $ this -> formataNumero ( $ linha -> substr ( 26 , 14 ) -> trim ( ) ) ) -> setNumAviso ( $ linha -> substr ( 40 , 8 ) -> trim ( ) ) ; $ vinculada = new Cobranca ( ) ; $ vinculada -> setQtdTitulos ( $ linha -> substr ( 58 , 8 ) -> trim ( ) ) -> setValorTotal ( $ this -> formataNumero ( $ linha -> substr ( 66 , 14 ) -> trim ( ) ) ) -> setNumAviso ( $ linha -> substr ( 80 , 8 ) -> trim ( ) ) ; $ caucionada = new Cobranca ( ) ; $ caucionada -> setQtdTitulos ( $ linha -> substr ( 98 , 8 ) -> trim ( ) ) -> setValorTotal ( $ this -> formataNumero ( $ linha -> substr ( 106 , 14 ) -> trim ( ) ) ) -> setNumAviso ( $ linha -> substr ( 120 , 8 ) -> trim ( ) ) ; $ descontada = new Cobranca ( ) ; $ descontada -> setQtdTitulos ( $ linha -> substr ( 138 , 8 ) -> trim ( ) ) -> setValorTotal ( $ this -> formataNumero ( $ linha -> substr ( 146 , 14 ) -> trim ( ) ) ) -> setNumAviso ( $ linha -> substr ( 160 , 8 ) -> trim ( ) ) ; $ vendor = new Cobranca ( ) ; $ vendor -> setQtdTitulos ( $ linha -> substr ( 218 , 8 ) -> trim ( ) ) -> setValorTotal ( $ this -> formataNumero ( $ linha -> substr ( 226 , 14 ) -> trim ( ) ) ) -> setNumAviso ( $ linha -> substr ( 240 , 8 ) -> trim ( ) ) ; $ trailer -> setBanco ( $ banco ) -> setRegistro ( $ linha -> substr ( 1 , 1 ) -> trim ( ) ) -> setRetorno ( $ linha -> substr ( 2 , 1 ) -> trim ( ) ) -> setTipoRegistro ( $ linha -> substr ( 3 , 2 ) -> trim ( ) ) -> setSimples ( $ simples ) -> setVinculada ( $ vinculada ) -> setCaucionada ( $ caucionada ) -> setDescontada ( $ descontada ) -> setVendor ( $ vendor ) -> setSequencial ( $ linha -> substr ( 395 , 6 ) -> trim ( ) ) ; return $ trailer ; }
Processa a linha trailer do arquivo .
33,777
public function applyFiltersToRepository ( array $ filters , FilterFactory $ filterFactory , ConditionAwareRepository $ repository ) { if ( empty ( $ filters ) && ( $ defaultFilter = $ filterFactory -> getDefaultFilter ( ) ) !== null ) { $ filters = [ 'default' => $ defaultFilter ] ; } foreach ( $ filters as $ filterName => $ filterValues ) { try { $ filter = $ filterFactory -> make ( $ filterName , $ filterValues ) ; } catch ( FilterFactoryNotFoundException $ e ) { continue ; } $ repository -> applyCondition ( $ filter ) ; } }
Applies all filters with their respective values to the repository . Filters which are not found in the factory are ignored
33,778
public function getWatching ( ) { $ table = new InventoryWatching ( Auth :: user ( ) -> watching ( ) ) ; return view ( 'mustard::inventory.watching' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; }
Return the inventory watching items view .
33,779
public function getSelling ( ) { $ items = Auth :: user ( ) -> items ( ) -> active ( ) ; $ table = new InventorySelling ( $ items ) ; return view ( 'mustard::inventory.selling' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; }
Return the inventory selling items view .
33,780
public function getScheduled ( ) { $ items = Auth :: user ( ) -> items ( ) -> scheduled ( ) ; $ table = new InventoryScheduled ( $ items ) ; return view ( 'mustard::inventory.scheduled' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; }
Return the inventory scheduled items view .
33,781
public function getEnded ( ) { $ items = Auth :: user ( ) -> items ( ) -> where ( 'end_date' , '<' , time ( ) ) ; $ table = new InventoryEnded ( $ items ) ; return view ( 'mustard::inventory.ended' , [ 'table' => $ table , 'items' => $ table -> paginate ( ) , ] ) ; }
Return the inventory ended items view .
33,782
public function remove ( string $ data ) : string { $ len = strlen ( $ data ) ; if ( ! $ len ) { throw new \ UnexpectedValueException ( "No padding." ) ; } $ n = ord ( $ data [ $ len - 1 ] ) ; if ( $ len < $ n || $ n > $ this -> _blocksize ) { throw new \ UnexpectedValueException ( "Invalid padding length." ) ; } $ ps = substr ( $ data , - $ n ) ; if ( $ ps !== str_repeat ( chr ( $ n ) , $ n ) ) { throw new \ UnexpectedValueException ( "Invalid padding string." ) ; } return substr ( $ data , 0 , - $ n ) ; }
Remove padding .
33,783
public static function buildDic ( StringType $ definitionFile ) { if ( ! file_exists ( $ definitionFile ( ) ) ) { throw new \ Exception ( self :: ERR_NO_DIC ) ; } return FFor :: create ( [ 'definitionFile' => $ definitionFile ] ) -> dic ( function ( ) { return PHP_MAJOR_VERSION < 7 ? new ServiceContainer ( ) : new ContainerBuilder ( ) ; } ) -> process ( function ( $ dic , $ definitionFile ) { $ fileLocator = new FileLocator ( dirname ( $ definitionFile ( ) ) ) ; $ fileLoaders = [ new XmlFileLoader ( $ dic , $ fileLocator ) , new YamlFileLoader ( $ dic , $ fileLocator ) , ] ; ( new DelegatingLoader ( new LoaderResolver ( $ fileLoaders ) ) ) -> load ( $ definitionFile ( ) ) ; self :: preCompile ( $ dic ) ; $ dic -> compile ( ) ; self :: postCompile ( $ dic ) ; } ) -> fyield ( 'dic' ) ; }
Build and return the DIC
33,784
protected static function preCompile ( ContainerInterface $ dic ) { if ( empty ( self :: $ preCompileFunction ) ) { return ; } $ func = self :: $ preCompileFunction ; $ func ( $ dic ) ; }
Do some processing on dic before compilation
33,785
protected static function postCompile ( ContainerInterface $ dic ) { if ( empty ( self :: $ postCompileFunction ) ) { return ; } $ func = self :: $ postCompileFunction ; $ func ( $ dic ) ; }
Do some processing on dic after compilation
33,786
public static function fromRecord ( $ record ) { if ( ! $ record ) { return null ; } $ className = get_called_class ( ) ; $ entity = new $ className ; foreach ( $ record as $ key => $ value ) { $ entity -> $ key = $ value ; } return $ entity ; }
Default mapping of fields
33,787
public function findFirstBy ( $ key , $ value , $ operator = '=' ) { $ query = $ this -> make ( ) ; return $ query -> where ( $ key , $ operator , $ value ) -> first ( ) ; }
returns the first model found by conditions
33,788
public function findAllBy ( $ key , $ value , $ operator = '=' ) { $ query = $ this -> make ( ) ; return $ query -> where ( $ key , $ operator , $ value ) -> get ( $ this -> getParameters ) ; }
returns all models found by conditions
33,789
public function has ( $ relation ) { $ query = $ this -> make ( ) ; return $ query -> has ( $ relation ) -> get ( $ this -> getParameters ) ; }
returns all models that have a required relation
33,790
public function getPaginated ( $ page = 1 , $ limit = 10 ) { $ query = $ this -> make ( ) ; $ collection = $ query -> forPage ( $ page , $ limit ) -> get ( ) ; return new PaginatedResult ( $ page , $ limit , $ collection -> count ( ) , $ collection ) ; }
returns paginated result
33,791
protected function makeQuery ( ) { $ query = $ this -> make ( ) ; $ this -> conditionApplier -> apply ( new ConditionTaker ( $ query ) ) ; return $ query ; }
returns a query builder
33,792
public function addDomain ( $ domain ) { if ( ! isset ( $ this -> domains [ $ domain ] ) ) { $ this -> domains [ $ domain ] = $ domain ; } return $ this ; }
Adding a domain to the list .
33,793
public function removeDomain ( $ domain ) { if ( isset ( $ this -> domains [ $ domain ] ) ) { unset ( $ this -> domains [ $ domain ] ) ; } return $ this ; }
Removing a domain from the list .
33,794
public function declareExchange ( ) { $ durable = boolval ( $ this -> flags & AMQP_DURABLE ) ; $ passive = boolval ( $ this -> flags & AMQP_PASSIVE ) ; $ auto_delete = boolval ( $ this -> flags & AMQP_AUTODELETE ) ; try { $ this -> channel -> _getChannel ( ) -> exchange_declare ( $ this -> name , $ this -> type , $ passive , $ durable , $ auto_delete ) ; } catch ( AMQPRuntimeException $ e ) { throw new AMQPConnectionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } catch ( Exception $ e ) { throw new AMQPExchangeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } return true ; }
Declare a new exchange on the broker .
33,795
public function bind ( $ exchange_name , $ routing_key = '' , array $ arguments = array ( ) ) { try { $ this -> channel -> _getChannel ( ) -> exchange_bind ( $ this -> name , $ exchange_name , $ routing_key , $ nowait = false , $ arguments ) ; } catch ( AMQPRuntimeException $ e ) { throw new AMQPConnectionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } catch ( Exception $ e ) { throw new AMQPExchangeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } return true ; }
Bind to another exchange .
33,796
public function delete ( $ exchangeName = null , $ flags = AMQP_NOPARAM ) { $ if_unused = boolval ( $ flags & AMQP_IFUNUSED ) ; if ( $ exchangeName === null ) $ exchangeName = $ this -> name ; try { $ this -> channel -> _getChannel ( ) -> exchange_delete ( $ exchangeName , $ if_unused ) ; } catch ( AMQPRuntimeException $ e ) { throw new AMQPConnectionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } catch ( Exception $ e ) { throw new AMQPExchangeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } return true ; }
Delete the exchange from the broker .
33,797
public function getArgument ( $ key ) { if ( ! isset ( $ this -> arguments [ $ key ] ) ) return false ; return $ this -> arguments [ $ key ] ; }
Get the argument associated with the given key .
33,798
public function publish ( $ message , $ routing_key = null , $ flags = AMQP_NOPARAM , array $ attributes = array ( ) ) { $ mandatory = boolval ( $ flags & AMQP_MANDATORY ) ; $ immediate = boolval ( $ flags & AMQP_IMMEDIATE ) ; if ( $ routing_key === null ) $ routing_key = '' ; if ( isset ( $ attributes [ 'headers' ] ) ) { $ attributes [ 'application_headers' ] = new AMQPTable ( $ attributes [ 'headers' ] ) ; unset ( $ attributes [ 'headers' ] ) ; } $ amqp_message = new AMQPMessage ( $ message , $ attributes ) ; try { $ this -> channel -> _getChannel ( ) -> basic_publish ( $ amqp_message , $ this -> name , $ routing_key , $ mandatory , $ immediate ) ; if ( $ this -> publisherAcks === true ) { $ this -> channel -> _getChannel ( ) -> wait_for_pending_acks_returns ( 1 ) ; } } catch ( AMQPRuntimeException $ e ) { throw new AMQPConnectionException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } catch ( Exception $ e ) { throw new AMQPExchangeException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getPrevious ( ) ) ; } return true ; }
Publish a message to an exchange .
33,799
public function setType ( $ exchange_type ) { if ( ! in_array ( $ exchange_type , array ( AMQP_EX_TYPE_DIRECT , AMQP_EX_TYPE_FANOUT , AMQP_EX_TYPE_HEADERS , AMQP_EX_TYPE_TOPIC ) ) ) return false ; $ this -> type = $ exchange_type ; return true ; }
Set the type of the exchange .