idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
28,000
public function sendNormal ( $ params ) { $ params [ 'total_num' ] = 1 ; $ params [ 'client_ip' ] = ! empty ( $ params [ 'client_ip' ] ) ? $ params [ 'client_ip' ] : getenv ( 'SERVER_ADDR' ) ; return $ this -> send ( $ params , self :: TYPE_NORMAL ) ; }
Send normal LuckyMoney .
28,001
protected function parseResponse ( $ response ) { if ( $ response instanceof ResponseInterface ) { $ response = $ response -> getBody ( ) ; } return new Collection ( ( array ) XML :: parse ( $ response ) ) ; }
Parse Response XML to array .
28,002
public function onRender ( ViewInterface $ view , $ template , array $ context ) { $ this -> assertView ( $ view ) ; $ twig = $ view -> getTwig ( ) ; $ loader = $ this -> createFormulaLoader ( $ twig ) ; $ assetManager = $ this -> createAssetManager ( $ loader ) ; $ assetManager -> setLoader ( 'twig' , $ loader ) ; $ tmpl = $ twig -> loadTemplate ( $ template ) ; do { $ name = ( string ) $ tmpl ; $ resource = $ this -> createResource ( $ twig , $ name ) ; $ assetManager -> addResource ( $ resource , 'twig' ) ; } while ( $ tmpl = $ tmpl -> getParent ( $ context ) ) ; $ this -> writer -> writeManagerAssets ( $ assetManager ) ; }
Called when view renders a template .
28,003
public function truncate ( ) { foreach ( $ this -> tables as $ table ) { $ this -> db -> query ( "DELETE FROM $table" ) ; } $ this -> tables = array ( ) ; }
Truncate a table .
28,004
protected function generateKey ( $ value ) { $ hash = sha1 ( $ value ) ; $ integerHash = base_convert ( $ hash , 16 , 10 ) ; return ( int ) substr ( $ integerHash , 0 , 8 ) ; }
Generate an integer hash of a string . We ll use this method to convert a fixture s name into the primary key of it s corresponding database table record .
28,005
public function addFile ( $ file , $ local = null ) { $ this -> invokeEvent ( self :: ADD_FILE , array ( 'file' => $ file , 'local' => $ local ) ) ; }
Adds a file from the disk to the archive .
28,006
public function buildFromDirectory ( $ dir , $ regex = null ) { return $ this -> invokeEvent ( self :: BUILD_DIR , array ( 'dir' => $ dir , 'regex' => $ regex ) ) ; }
Builds the archive using the files in a directory path .
28,007
public function buildFromIterator ( Iterator $ iterator , $ base = null ) { return $ this -> invokeEvent ( self :: BUILD_ITERATOR , array ( 'iterator' => $ iterator , 'base' => $ base ) ) ; }
Builds the archive using an iterator .
28,008
public function observe ( $ id , ObserverInterface $ observer , $ priority = SubjectInterface :: FIRST_PRIORITY ) { $ this -> getSubject ( $ id ) -> registerObserver ( $ observer , $ priority ) ; }
Registers an event observer with a subject .
28,009
protected function registerDefaultSubjects ( ) { $ this -> registerSubject ( self :: ADD_DIR , new Subject \ AddDirectory ( $ this ) ) ; $ this -> registerSubject ( self :: ADD_FILE , new Subject \ AddFile ( $ this ) ) ; $ this -> registerSubject ( self :: ADD_STRING , new Subject \ AddString ( $ this ) ) ; $ this -> registerSubject ( self :: BUILD_DIR , new Subject \ BuildDirectory ( $ this ) ) ; $ this -> registerSubject ( self :: BUILD_ITERATOR , new Subject \ BuildIterator ( $ this ) ) ; $ this -> registerSubject ( self :: SET_STUB , new Subject \ SetStub ( $ this ) ) ; }
Registers the default event subjects .
28,010
private function invokeEvent ( $ id , array $ values ) { $ subject = $ this -> getSubject ( $ id ) ; $ subject -> setArguments ( new Arguments ( $ values ) ) ; return $ subject -> notifyObservers ( ) ; }
Invokes an event after setting new method argument values .
28,011
public function generate ( string $ file_path ) { $ namespace_name = $ this -> namespaceModel ( ) ; $ api = Yaml :: parseFile ( $ file_path ) ; $ namespace = new PhpNamespace ( $ namespace_name ) ; foreach ( $ api [ 'definitions' ] as $ class_name => $ class_details ) { $ class = new ClassType ( $ class_name , $ namespace ) ; $ class -> setExtends ( "$namespace_name\\" . self :: MODEL_CLASS_NAME ) ; $ class -> addComment ( "** This file was generated automatically, you might want to avoid editing it **" ) ; if ( ! empty ( $ class_details [ 'description' ] ) ) { $ class -> addComment ( "\n" . $ class_details [ 'description' ] ) ; } if ( isset ( $ class_details [ 'allOf' ] ) ) { $ parent_class_name = $ this -> typeFromRef ( $ class_details [ 'allOf' ] [ 0 ] ) ; $ class -> setExtends ( "$namespace_name\\$parent_class_name" ) ; $ properties = $ class_details [ 'allOf' ] [ 1 ] [ 'properties' ] ; } else { $ properties = $ class_details [ 'properties' ] ; } $ this -> classProperties ( $ properties , $ class ) ; $ this -> classes [ $ class_name ] = $ class ; } }
Generates classes in the classes field
28,012
public function isEndOfFile ( ) { $ handle = $ this -> getHandle ( ) ; if ( false === @ fgetc ( $ handle ) ) { return feof ( $ handle ) ; } else { fseek ( $ handle , - 1 , SEEK_CUR ) ; } return false ; }
Checks if the end of the file has been reached .
28,013
public function setupDevelopmentBuild ( ) { $ this -> io -> write ( '<info>Running component scaffolding:</info>' ) ; $ this -> doSetupDirectories ( ) ; $ this -> doCreateSymlink ( ) ; $ this -> doSetupDrush ( ) ; $ this -> doSetupDevelopmentSettings ( ) ; }
Setup development build .
28,014
public function preAutoloadDump ( Event $ event ) { $ root = $ this -> getBuildRoot ( ) ; $ autoload = $ this -> package -> getDevAutoload ( ) ; $ autoload [ 'psr-0' ] [ "Drupal\\Tests" ] = $ root . "/core/tests" ; $ autoload [ 'psr-0' ] [ "Drupal\\KernelTests" ] = $ root . "/core/tests" ; $ autoload [ 'psr-0' ] [ "Drupal\\FunctionalTests" ] = $ root . "/core/tests" ; $ autoload [ 'psr-0' ] [ "Drupal\\FunctionalJavascriptTests" ] = $ root . "/core/tests" ; $ autoload [ 'psr-4' ] [ "Drupal\\simpletest\\" ] = $ root . "/core/modules/simpletest/src" ; $ this -> package -> setDevAutoload ( $ autoload ) ; }
Pre autoload dump event handler .
28,015
protected function doSetupDirectories ( ) { $ destination = $ this -> getInstallationDirectory ( ) ; $ this -> write ( 'Prepare custom projects directory at <comment>%s</comment>' , $ this -> shortenDirectory ( $ destination ) ) ; $ this -> fs -> emptyDirectory ( $ destination ) ; $ destination = $ this -> getDefaultDirectory ( ) ; $ this -> write ( 'Make <comment>%s</comment> writable' , $ this -> shortenDirectory ( $ destination ) ) ; chmod ( $ destination , 0755 ) ; }
Setup build directories .
28,016
protected function doCreateSymlink ( ) { $ symlink = $ this -> getInstallationDirectory ( ) . '/' . $ this -> getProjectName ( ) ; $ this -> write ( 'Symlink project at <comment>%s</comment>' , $ this -> shortenDirectory ( $ symlink ) ) ; $ this -> fs -> relativeSymlink ( $ this -> getProjectDirectory ( ) , $ symlink ) ; }
Create project symlink .
28,017
protected function getBuildRoot ( ) { $ extra = $ this -> package -> getExtra ( ) ; $ paths = isset ( $ extra [ 'installer-paths' ] ) ? $ extra [ 'installer-paths' ] : [ ] ; foreach ( $ paths as $ path => $ types ) { if ( in_array ( "type:drupal-core" , $ types ) ) { return str_replace ( '/core' , '' , $ path ) ; } } throw new InstallerPathsNotFoundException ( ) ; }
Get build root name from installer paths .
28,018
protected function getInstallationDirectory ( ) { switch ( $ this -> getProjectType ( ) ) { case 'drupal-module' : return $ this -> getBuildDirectory ( ) . '/modules/custom' ; case 'drupal-theme' : return $ this -> getBuildDirectory ( ) . '/themes/custom' ; case 'drupal-drush' : return $ this -> getBuildDirectory ( ) . '/sites/all/drush' ; default : throw new NotSupportedProjectTypeException ( ) ; } }
Get project installation directory .
28,019
private function ensurePatches ( ) { $ extra = $ this -> package -> getExtra ( ) ; $ patch = realpath ( __DIR__ . '/../dist/kernel-test-base.patch' ) ; $ extra [ 'patches' ] [ 'drupal/core' ] [ 'Patch KernelTestBase' ] = $ patch ; $ this -> package -> setExtra ( $ extra ) ; }
Apply patches .
28,020
public function getClassMap ( ) { $ shopEdition = $ this -> facts -> getEdition ( ) ; $ unifiedNamespaceClassMap = null ; switch ( $ shopEdition ) { case \ OxidEsales \ UnifiedNameSpaceGenerator \ Generator :: COMMUNITY_EDITION : $ unifiedNamespaceClassMap = new CommunityEditionUnifiedNamespaceClassMap ( $ this -> facts ) ; break ; case \ OxidEsales \ UnifiedNameSpaceGenerator \ Generator :: PROFESSIONAL_EDITION : $ unifiedNamespaceClassMap = new ProfessionalEditionUnifiedNamespaceClassMap ( $ this -> facts ) ; break ; case \ OxidEsales \ UnifiedNameSpaceGenerator \ Generator :: ENTERPRISE_EDITION : $ unifiedNamespaceClassMap = new EnterpriseEditionUnifiedNamespaceClassMap ( $ this -> facts ) ; } if ( is_null ( $ unifiedNamespaceClassMap ) ) { throw new InvalidEditionException ( 'The OXID eShop edition could not be detected. Be sure to setup your OXID eShop correctly.' ) ; } $ editionSpecificUnifiedNamespaceClassMap = $ unifiedNamespaceClassMap -> getClassMap ( ) ; return $ editionSpecificUnifiedNamespaceClassMap ; }
Return an array which is mapping unified namespace class name as key to real edition namespace class name .
28,021
public function previous_level ( ) { if ( ! $ this -> previous_level ) { $ this -> previous_level = new Level ( $ this -> level -> profile , $ this -> level -> number - 1 ) ; } return $ this -> previous_level ; }
Previous level .
28,022
public function refund ( $ orderNo , $ refundNo , $ totalFee , $ refundFee = null , $ opUserId = null , $ type = self :: OUT_TRADE_NO , $ refundAccount = 'REFUND_SOURCE_UNSETTLED_FUNDS' ) { $ params = [ $ type => $ orderNo , 'out_refund_no' => $ refundNo , 'total_fee' => $ totalFee , 'refund_fee' => $ refundFee ? : $ totalFee , 'refund_fee_type' => $ this -> merchant -> fee_type , 'refund_account' => $ refundAccount , 'op_user_id' => $ opUserId ? : $ this -> merchant -> merchant_id , ] ; return $ this -> safeRequest ( self :: API_REFUND , $ params ) ; }
Make a refund request .
28,023
public function queryRefund ( $ orderNo , $ type = self :: OUT_TRADE_NO ) { $ params = [ $ type => $ orderNo , ] ; return $ this -> request ( self :: API_QUERY_REFUND , $ params ) ; }
Query refund status .
28,024
public function report ( $ api , $ timeConsuming , $ resultCode , $ returnCode , array $ other = [ ] ) { $ params = array_merge ( [ 'interface_url' => $ api , 'execute_time_' => $ timeConsuming , 'return_code' => $ returnCode , 'return_msg' => null , 'result_code' => $ resultCode , 'user_ip' => get_client_ip ( ) , 'time' => time ( ) , ] , $ other ) ; return $ this -> request ( self :: API_REPORT , $ params ) ; }
Report API status to WeChat .
28,025
public static function add ( string $ messageType , string $ message ) : void { $ _SESSION [ self :: SESSION_KEY ] [ $ messageType ] [ ] = $ message ; }
Add a flash message . Message type can be anything but preferably use one of the constants defined in this class .
28,026
public static function get ( string $ messageType ) : array { $ messages = $ _SESSION [ self :: SESSION_KEY ] [ $ messageType ] ?? [ ] ; unset ( $ _SESSION [ self :: SESSION_KEY ] [ $ messageType ] ) ; return $ messages ; }
Get all the flash messages of the given type and erase them at the same time .
28,027
private static function _tagToASN1Class ( int $ tag ) : string { if ( ! array_key_exists ( $ tag , self :: MAP_TAG_TO_CLASS ) ) { throw new \ UnexpectedValueException ( "Type " . Element :: tagToName ( $ tag ) . " is not valid DirectoryString." ) ; } return self :: MAP_TAG_TO_CLASS [ $ tag ] ; }
Get ASN . 1 class name for given DirectoryString type tag .
28,028
public static function validateInstaller ( $ installer_class ) { if ( class_exists ( $ installer_class ) ) { $ interfaces = class_implements ( $ installer_class ) ; $ installer_interface = Config :: getInternal ( 'assets-package-installer-interface' ) ; return in_array ( $ installer_interface , $ interfaces ) ; } return false ; }
Validating the installer class to use
28,029
public static function validateAutoloadGenerator ( $ generator_class ) { if ( class_exists ( $ generator_class ) ) { $ parents = class_parents ( $ generator_class ) ; $ autoload_abstract = Config :: getInternal ( 'assets-autoload-generator-abstract' ) ; return in_array ( $ autoload_abstract , $ parents ) ; } return false ; }
Validating the autoload generator class to use
28,030
public function up ( $ fixtures = array ( ) ) { $ location = $ this -> config [ 'location' ] ; if ( ! is_dir ( $ location ) ) { throw new Exceptions \ InvalidFixtureLocationException ( "Could not find fixtures folder, please make sure $location exists" , 1 ) ; } $ this -> loadFixtures ( $ fixtures ) ; }
Build fixtures .
28,031
public static function fake ( ) { static :: bootFaker ( ) ; $ params = func_get_args ( ) ; $ method = array_shift ( $ params ) ; return call_user_func_array ( array ( static :: $ faker , $ method ) , $ params ) ; }
Create fake data using Faker .
28,032
protected function loadSomeFixtures ( $ selectedFixtures ) { $ fixtures = glob ( "{$this->config['location']}/*.php" ) ; foreach ( $ fixtures as $ fixture ) { $ tableName = basename ( $ fixture , '.php' ) ; if ( in_array ( $ tableName , $ selectedFixtures ) ) { $ this -> loadFixture ( $ fixture ) ; } } }
Load a only a subset of fixtures from the fixtures folder .
28,033
public function setJobRowClass ( $ jobRowClass ) { if ( ! in_array ( 'Zend_Db_Table_Row_Abstract' , class_parents ( $ jobRowClass ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Job row class must be instance of Zend_Db_Table_Row_Abstract, given %s.' , get_class ( $ historyRowClass ) ) ) ; } $ this -> jobRowClass = $ jobRowClass ; return $ this ; }
Set cron jobs row class name
28,034
public function setHistoryRowClass ( $ historyRowClass ) { if ( ! in_array ( 'Zend_Db_Table_Row_Abstract' , class_parents ( $ historyRowClass ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'History job row class must be instance of Zend_Db_Table_Row_Abstract, given %s.' , get_class ( $ historyRowClass ) ) ) ; } $ this -> historyRowClass = $ historyRowClass ; return $ this ; }
Set cron history row class name
28,035
public function history ( $ status , JobInterface $ job , $ message = null ) { $ history = $ this -> createHistoryRowObject ( ) ; if ( ! $ history instanceof HistoryInterface ) { throw new \ InvalidArgumentException ( sprintf ( 'History must be an instance of "Extlib\Cron\Adapter\Job\HistoryInterface", "%s" given.' , get_class ( $ history ) ) ) ; } if ( ! in_array ( $ status , array ( HistoryInterface :: STATUS_OK , HistoryInterface :: STATUS_WARNING , HistoryInterface :: STATUS_ERROR ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Unknown status - "%s".' , $ status ) ) ; } $ history -> setJob ( $ job ) ; $ history -> setStatus ( $ status ) ; $ history -> setRunDate ( $ this -> date ) ; if ( null !== $ message ) { $ history -> setMessage ( $ message ) ; } $ history -> save ( ) ; return $ this ; }
Implementacja metody tworzacej wpis historii zadania
28,036
public static function allNames ( ) { static $ list ; if ( $ list === null ) { $ list = [ ] ; $ data = \ ResourceBundle :: create ( \ Locale :: getDefault ( ) , 'ICUDATA-curr' ) -> get ( 'Currencies' ) ; foreach ( $ data as $ code => $ values ) { $ list [ $ code ] = $ values [ 1 ] ; } } return $ list ; }
Returns all supported currency names include old and not used
28,037
public static function findMainCode ( $ codes ) { foreach ( static :: mainCodes ( ) as $ code ) { if ( in_array ( $ code , $ codes ) ) { return $ code ; } } return null ; }
Find main ISO 4217 currency code in a list
28,038
public static function currencySymbol ( $ code = null ) { $ localeCode = \ Locale :: getDefault ( ) ; if ( $ code !== null ) { $ localeCode .= '@currency=' . $ code ; } $ formatter = new \ NumberFormatter ( $ localeCode , \ NumberFormatter :: CURRENCY ) ; $ symbol = $ formatter -> getSymbol ( \ NumberFormatter :: CURRENCY_SYMBOL ) ; return $ symbol != $ code ? $ symbol : ( static :: countryCurrencySymbol ( substr ( $ code , 0 , 2 ) ) ? : $ symbol ) ; }
Returns currency symbol for a ISO 4217 currency code
28,039
protected static function countryCurrencyFormatter ( $ countryCode ) { $ localeCode = Locale :: countryLocaleCode ( $ countryCode ) ; return new \ NumberFormatter ( $ localeCode , \ NumberFormatter :: CURRENCY ) ; }
Returns an \ NumberFormatter object for a country
28,040
public function clear ( ) { $ currentDate = new DateTime ( ) ; foreach ( \ array_keys ( self :: $ registry ) as $ key ) { $ this -> clearExpiredKey ( $ key , $ currentDate ) ; } }
Clears all expired values from cache .
28,041
private function clearExpiredKey ( $ key , DateTime $ dateTime ) { if ( self :: $ registry [ $ key ] [ 'expires' ] < $ dateTime ) { unset ( self :: $ registry [ $ key ] ) ; } }
Clear an item if it expired .
28,042
public static function clientIP ( ) : string { if ( ! empty ( $ _SERVER [ 'HTTP_CF_CONNECTING_IP' ] ) ) { return $ _SERVER [ 'HTTP_CF_CONNECTING_IP' ] ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { return $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } elseif ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { return $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } return $ _SERVER [ 'REMOTE_ADDR' ] ; }
Returns the real client IP adress .
28,043
public static function currencies ( string $ currency = null ) : Collection { $ currency = strtoupper ( $ currency ) ; $ file = __DIR__ . "/../Assets/Currencies.json" ; $ json = json_decode ( file_get_contents ( $ file ) , true ) ; if ( $ currency ) { return Collection :: make ( $ json [ $ currency ] ) ; } return Collection :: make ( $ json ) ; }
Return all the currencies or the one specified .
28,044
public static function mostUsed ( $ data ) : string { if ( is_a ( $ data , Collection :: class ) ) { $ data = $ data -> toArray ( ) ; } $ count = array_count_values ( $ data ) ; return array_search ( max ( $ count ) , $ count ) ; }
Returns the most used value in a collection or array .
28,045
public static function gavatar ( string $ email , int $ size = 100 ) : string { $ hash = md5 ( strtolower ( trim ( $ email ) ) ) ; return "https://www.gravatar.com/avatar/{$hash}.jpg?s={$size}" ; }
Return the gavatar for the given email .
28,046
public static function secToHourFormat ( float $ seconds ) : string { $ t = round ( $ seconds ) ; return sprintf ( '%02d:%02d:%02d' , ( $ t / 3600 ) , ( $ t / 60 % 60 ) , $ t % 60 ) ; }
Returns the seconds in a hour string format .
28,047
public static function activeSegUrl ( string $ name , int $ segment = 1 , $ class = 'active' ) : string { return Request :: segment ( $ segment ) == $ name ? $ class : '' ; }
Returns if the request URL have an active segment .
28,048
public function config ( ) { $ this -> publishes ( [ __DIR__ . '/../config/laravel-forum.php' => config_path ( 'laravel-forum.php' ) , ] , 'config' ) ; $ this -> mergeConfigFrom ( __DIR__ . '/../config/laravel-forum.php' , 'laravel-forum' ) ; $ published = __DIR__ . '/../../../../config/laravel-forum.php' ; if ( file_exists ( $ published ) ) { $ this -> mergeConfigFrom ( $ published , 'laravel-forum' ) ; } }
Register the config and merge any published config .
28,049
protected function saveClassesInternal ( string $ dir , string $ namespace_name , string $ use = '' ) { if ( empty ( $ this -> classes ) ) { throw new \ Exception ( "No classes were created, try running the generate() method first" ) ; } $ dir = $ this -> checkDir ( $ dir ) ; foreach ( $ this -> classes as $ class_name => $ class ) { $ php_file = ( string ) $ class ; $ php_file = "<?php\nnamespace $namespace_name;\n$use\n$php_file" ; file_put_contents ( "{$dir}/{$class_name}.php" , $ php_file ) ; } }
Saves generated classes down as PHP files
28,050
public function all ( ) { $ multi = $ this -> client -> zoneLoadMulti ( ) ; $ zones = array_get ( $ multi , 'response.zones.objs' ) ; $ all = new Collection ( ) ; foreach ( $ zones as $ zone ) { $ name = $ zone [ 'zone_name' ] ; $ all -> put ( $ name , $ this -> get ( $ name ) ) ; } return $ all ; }
Get a collection of all the zones .
28,051
public function uploadAction ( ) { $ handle = $ this -> getRequest ( ) -> files -> get ( 'file' ) ; if ( $ handle && $ handle -> getError ( ) ) { return new JsonResponse ( array ( 'success' => false , 'err_msg' => $ this -> container -> get ( 'translator' ) -> trans ( 'file_upload_http_error' , array ( ) , 'ThraceMediaBundle' ) ) ) ; } $ imageManager = $ this -> container -> get ( 'thrace_media.imagemanager' ) ; $ options = $ this -> container -> getParameter ( 'thrace_media.plupload.options' ) ; $ extension = $ handle -> getClientOriginalExtension ( ) ; $ name = uniqid ( ) . '.' . $ extension ; if ( ! $ extension ) { return new JsonResponse ( array ( 'success' => false , 'err_msg' => sprintf ( 'Unknown Mime Type: "%s"' , $ handle -> getMimeType ( ) ) ) ) ; } $ validate = $ this -> validateImage ( $ handle ) ; if ( $ validate !== true ) { return new JsonResponse ( array ( 'success' => false , 'err_msg' => $ validate ) ) ; } $ content = $ imageManager -> normalizeImage ( $ name , file_get_contents ( $ handle -> getRealPath ( ) ) , $ options [ 'normalize_width' ] , $ options [ 'normalize_height' ] ) ; $ imageManager -> saveToTemporaryDirectory ( $ name , $ content ) ; $ imageManager -> makeImageCopyToOriginalDirectory ( $ name ) ; $ hash = $ imageManager -> checksumTemporaryFileByName ( $ name ) ; return new JsonResponse ( array ( 'success' => true , 'name' => $ name , 'hash' => $ hash ) ) ; }
This actions is responsible for validating uploading of images
28,052
public function renderAction ( ) { $ filepath = $ this -> getRequest ( ) -> get ( 'filepath' ) ; $ hash = $ this -> getRequest ( ) -> get ( 'hash' ) ; $ filter = $ this -> getRequest ( ) -> get ( 'filter' ) ; $ tag = md5 ( $ hash . $ filter ) ; $ response = new Response ( ) ; $ response -> setPublic ( ) ; $ response -> setEtag ( $ tag ) ; if ( $ response -> isNotModified ( $ this -> getRequest ( ) ) ) { return $ response ; } $ imageManager = $ this -> container -> get ( 'thrace_media.imagemanager' ) ; $ filterManager = $ this -> container -> get ( 'liip_imagine.filter.manager' ) ; try { $ image = $ imageManager -> loadPermanentImageByName ( $ filepath ) ; } catch ( FileNotFound $ e ) { throw new NotFoundHttpException ( ) ; } $ filteredImage = $ filterManager -> applyFilter ( $ image , $ filter ) ; $ content = $ filteredImage -> get ( $ imageManager -> getExtension ( $ filepath ) ) ; $ response -> setContent ( $ content ) ; $ response -> headers -> set ( 'Accept-Ranges' , 'bytes' ) ; $ response -> headers -> set ( 'Content-Length' , mb_strlen ( $ content ) ) ; $ response -> headers -> set ( 'Content-Type' , $ this -> getMimeType ( $ content ) ) ; return $ response ; }
Renders permanent image
28,053
public function renderOriginalAction ( ) { $ filepath = $ this -> getRequest ( ) -> get ( 'filepath' ) ; $ hash = $ this -> getRequest ( ) -> get ( 'hash' ) ; $ tag = md5 ( $ hash . $ filepath ) ; $ response = new Response ( ) ; $ response -> setPublic ( ) ; $ response -> setEtag ( $ tag ) ; if ( $ response -> isNotModified ( $ this -> getRequest ( ) ) ) { return $ response ; } $ imageManager = $ this -> container -> get ( 'thrace_media.imagemanager' ) ; try { $ content = $ imageManager -> loadPermanentImageByName ( $ filepath ) ; } catch ( FileNotFound $ e ) { throw new NotFoundHttpException ( ) ; } $ response -> setContent ( $ content ) ; $ response -> headers -> set ( 'Accept-Ranges' , 'bytes' ) ; $ response -> headers -> set ( 'Content-Length' , mb_strlen ( $ content ) ) ; $ response -> headers -> set ( 'Content-Type' , $ this -> getMimeType ( $ content ) ) ; return $ response ; }
Renders permanent original image
28,054
public function cropAction ( ) { $ this -> validateRequest ( ) ; $ imageManager = $ this -> container -> get ( 'thrace_media.imagemanager' ) ; $ name = $ this -> getRequest ( ) -> get ( 'name' ) ; $ options = array ( ) ; $ options [ 'x' ] = $ this -> getRequest ( ) -> get ( 'x' , false ) ; $ options [ 'y' ] = $ this -> getRequest ( ) -> get ( 'y' , false ) ; $ options [ 'w' ] = $ this -> getRequest ( ) -> get ( 'w' , false ) ; $ options [ 'h' ] = $ this -> getRequest ( ) -> get ( 'h' , false ) ; if ( ! $ imageManager -> crop ( $ name , $ options ) ) { return new JsonResponse ( array ( 'success' => false , 'err_msg' => $ this -> container -> get ( 'translator' ) -> trans ( 'error.image_crop' , array ( 'name' => $ name ) , 'ThraceMediaBundle' ) ) ) ; } $ hash = $ imageManager -> checksumTemporaryFileByName ( $ name ) ; return new JsonResponse ( array ( 'success' => true , 'name' => $ name , 'hash' => $ hash ) ) ; }
This action performs image cropping
28,055
public function rotateAction ( ) { $ this -> validateRequest ( ) ; $ imageManager = $ this -> container -> get ( 'thrace_media.imagemanager' ) ; $ name = $ this -> getRequest ( ) -> get ( 'name' ) ; $ imageManager -> rotate ( $ name ) ; $ hash = $ imageManager -> checksumTemporaryFileByName ( $ name ) ; return new JsonResponse ( array ( 'success' => true , 'name' => $ name , 'hash' => $ hash ) ) ; }
This action performs image rotation
28,056
public function resetAction ( ) { $ this -> validateRequest ( ) ; $ imageManager = $ this -> container -> get ( 'thrace_media.imagemanager' ) ; $ name = $ this -> getRequest ( ) -> get ( 'name' ) ; $ imageManager -> reset ( $ name ) ; $ hash = $ imageManager -> checksumTemporaryFileByName ( $ name ) ; return new JsonResponse ( array ( 'success' => true , 'name' => $ name , 'hash' => $ hash ) ) ; }
This action revert the image to original one
28,057
protected function validateImage ( UploadedFile $ handle ) { $ configs = $ this -> getConfigs ( ) ; $ maxSize = $ configs [ 'max_upload_size' ] ; $ extensions = $ configs [ 'extensions' ] ; $ imageConstraint = new Image ( ) ; $ imageConstraint -> minWidth = $ configs [ 'minWidth' ] ; $ imageConstraint -> minHeight = $ configs [ 'minHeight' ] ; $ imageConstraint -> maxSize = $ maxSize ; $ imageConstraint -> mimeTypes = array_map ( function ( $ item ) { return 'image/' . $ item ; } , explode ( ',' , $ extensions ) ) ; $ errors = $ this -> container -> get ( 'validator' ) -> validateValue ( $ handle , $ imageConstraint ) ; if ( count ( $ errors ) == 0 ) { return true ; } else { return $ this -> container -> get ( 'translator' ) -> trans ( $ errors [ 0 ] -> getMessageTemplate ( ) , $ errors [ 0 ] -> getMessageParameters ( ) ) ; } }
Validates image and return true on success and array of error messages on failure
28,058
protected function getConfigs ( ) { if ( ! $ configs = $ this -> container -> getParameter ( $ this -> getRequest ( ) -> get ( 'config_identifier' , 'none' ) ) ) { throw new \ InvalidArgumentException ( 'Configs does no exist!' ) ; } return $ configs ; }
Gets Image configs
28,059
public function getOriginalValue ( $ name ) { if ( ! isset ( $ this -> original [ $ name ] ) ) { throw BuilderException :: argNotDefined ( $ name ) ; } return $ this -> original [ $ name ] ; }
Returns the original value for an argument .
28,060
public function offsetGet ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> original ) ) { throw BuilderException :: argNotDefined ( $ name ) ; } if ( array_key_exists ( $ name , $ this -> override ) ) { return $ this -> override [ $ name ] ; } return $ this -> original [ $ name ] ; }
Returns the value for an argument .
28,061
public function offsetSet ( $ name , $ value ) { if ( ! array_key_exists ( $ name , $ this -> original ) ) { throw BuilderException :: argNotDefined ( $ name ) ; } $ this -> override [ $ name ] = $ value ; }
Sets the override value for an argument .
28,062
public function offsetUnset ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> original ) ) { throw BuilderException :: argNotDefined ( $ name ) ; } unset ( $ this -> override [ $ name ] ) ; }
Restores the original value of an argument .
28,063
public function execute ( ) { foreach ( $ this -> getJobs ( ) as $ key => $ job ) { try { $ this -> console ( $ job , $ key + 1 ) ; $ task = $ this -> createTask ( $ job ) ; $ return = $ task -> run ( ) ; $ this -> getAdapter ( ) -> history ( HistoryInterface :: STATUS_OK , $ job , is_string ( $ return ) ? $ return : null ) ; } catch ( \ Exception $ exc ) { $ this -> log ( $ job , $ exc ) ; } } $ this -> getAdapter ( ) -> finishProcessing ( $ this -> getJobs ( ) ) ; }
Cron execute method
28,064
public function createTask ( JobInterface $ job ) { $ className = $ job -> getTaskClassName ( ) ; $ task = new $ className ( $ this , $ job -> getParams ( ) ) ; if ( ! $ task instanceof TaskAbstract ) { throw new \ InvalidArgumentException ( 'Task must be an instance of "Extlib\Cron\Task\TaskAbstract", given "%s".' , get_class ( $ task ) ) ; } return $ task ; }
Create task class from cron job
28,065
public function setJobs ( \ ArrayObject $ jobs ) { $ this -> jobs = new \ ArrayObject ( ) ; foreach ( $ jobs as $ job ) { $ this -> addJob ( $ job ) ; } return $ this ; }
Set collections of execute cron jobs
28,066
public function addJob ( JobInterface $ job ) { $ date = $ job -> getDateLastRun ( ) ; if ( null === $ date || ( int ) $ date -> getTimestamp ( ) + ( int ) $ job -> getRunTime ( ) <= time ( ) ) { $ this -> getJobs ( ) -> append ( $ job ) ; } return $ this ; }
Add job to collection of execute cron jobs
28,067
public function log ( JobInterface $ job , \ Exception $ exc ) { if ( HistoryInterface :: STATUS_WARNING === $ exc -> getCode ( ) ) { $ this -> getAdapter ( ) -> history ( HistoryInterface :: STATUS_WARNING , $ job , $ exc -> getMessage ( ) ) ; } else { $ this -> getAdapter ( ) -> history ( HistoryInterface :: STATUS_ERROR , $ job , $ exc -> getMessage ( ) ) ; } return $ this ; }
Cron log method
28,068
public function console ( JobInterface $ job , $ number ) { echo sprintf ( '%s. Run task: %s (%s) - %s.' , $ number , $ job -> getName ( ) , $ job -> getTaskClassName ( ) , $ job -> getDateLastRun ( ) -> format ( self :: DATE_LOG_FORMAT ) ) . PHP_EOL ; return $ this ; }
Cron console log method
28,069
public function getSHA1 ( ) { try { $ array = func_get_args ( ) ; sort ( $ array , SORT_STRING ) ; return sha1 ( implode ( $ array ) ) ; } catch ( BaseException $ e ) { throw new EncryptionException ( $ e -> getMessage ( ) , EncryptionException :: ERROR_CALC_SIGNATURE ) ; } }
Get SHA1 .
28,070
private function encrypt ( $ text , $ corpId ) { try { $ key = $ this -> getAESKey ( ) ; $ random = $ this -> getRandomStr ( ) ; $ text = $ this -> encode ( $ random . pack ( 'N' , strlen ( $ text ) ) . $ text . $ corpId ) ; $ iv = substr ( $ key , 0 , 16 ) ; $ encrypted = openssl_encrypt ( $ text , 'aes-256-cbc' , $ key , OPENSSL_RAW_DATA | OPENSSL_NO_PADDING , $ iv ) ; return base64_encode ( $ encrypted ) ; } catch ( BaseException $ e ) { throw new EncryptionException ( $ e -> getMessage ( ) , EncryptionException :: ERROR_ENCRYPT_AES ) ; } }
Encrypt string .
28,071
public static function getInstance ( ) { if ( ! isset ( self :: $ config ) ) { throw new \ Tripod \ Exceptions \ ConfigException ( "Call Config::setConfig() first" ) ; } if ( ! isset ( self :: $ instance ) ) { self :: $ instance = TripodConfigFactory :: create ( self :: $ config ) ; } return self :: $ instance ; }
Since this is a singleton class use this method to create a new config instance .
28,072
protected function makeBaseClient ( $ config ) { $ parameters = $ this -> getParameters ( $ config ) ; $ client = new Client ( $ parameters ) ; $ this -> attachSubscribers ( $ client ) ; return $ client ; }
Make a guzzle client .
28,073
protected function attachSubscribers ( Client $ client ) { $ client -> getEmitter ( ) -> attach ( $ this -> getRetrySubscriber ( ) ) ; $ client -> getEmitter ( ) -> attach ( $ this -> getErrorSubscriber ( ) ) ; return $ client ; }
Attach all subscribers to the guzzle client .
28,074
protected function getRetrySubscriber ( ) { $ filter = RetrySubscriber :: createChainFilter ( [ RetrySubscriber :: createIdempotentFilter ( ) , RetrySubscriber :: createStatusFilter ( ) , ] ) ; return new RetrySubscriber ( [ 'filter' => $ filter ] ) ; }
Get the retry subscriber .
28,075
protected function makeServicesClient ( Client $ client ) { $ parameters = $ this -> getDescription ( ) ; $ description = new Description ( $ parameters ) ; return new GuzzleClient ( $ client , $ description ) ; }
Make a new guzzle services client .
28,076
public function toArray ( ) { if ( $ this -> _array ) { return $ this -> _array ; } $ root = $ this -> documentElement ; if ( $ root == 'error' ) { return array ( 0 => array ( 'id' => $ root -> getAttribute ( 'id' ) , 'code' => $ root -> getAttribute ( 'code' ) , 'auxCode' => $ root -> getAttribute ( 'auxCode' ) , 'message' => $ root -> firstChild -> nodeValue ) ) ; } $ this -> _array = $ this -> _toArray ( $ root -> childNodes ) ; return $ this -> _array ; }
Get a nested array representation of the response doc
28,077
protected function _toArray ( DOMNodeList $ nodes ) { $ array = array ( ) ; foreach ( $ nodes as $ node ) { if ( $ node -> nodeType != XML_ELEMENT_NODE ) { continue ; } if ( $ node -> hasAttributes ( ) ) { if ( $ node -> tagName == 'error' ) { $ array = array ( 'id' => $ node -> getAttribute ( 'id' ) , 'code' => $ node -> getAttribute ( 'code' ) , 'auxCode' => $ node -> getAttribute ( 'auxCode' ) , 'message' => $ node -> nodeValue ) ; } else { if ( $ node -> hasAttribute ( 'code' ) && $ node -> getAttribute ( 'code' ) ) { $ key = $ node -> getAttribute ( 'code' ) ; $ tmpArr = array ( ) ; if ( $ node -> hasAttribute ( 'id' ) ) { $ tmpArr = array ( 'id' => $ node -> getAttribute ( 'id' ) ) ; } $ tmpArr = $ tmpArr + array ( 'code' => $ key ) ; if ( $ node -> tagName == 'charge' ) { $ array [ $ key ] [ ] = $ tmpArr ; } else { $ array [ $ key ] = $ tmpArr ; } unset ( $ tmpArr ) ; } else { $ key = $ node -> getAttribute ( 'id' ) ; $ array [ $ key ] = array ( 'id' => $ node -> getAttribute ( 'id' ) ) ; } $ array [ $ key ] = $ array [ $ key ] + $ this -> _toArray ( $ node -> childNodes ) ; } } else { if ( $ node -> tagName == 'errors' ) { $ array [ $ node -> tagName ] [ ] = $ this -> _toArray ( $ node -> childNodes ) ; } else if ( $ node -> childNodes -> length > 1 ) { $ array [ $ node -> tagName ] = $ this -> _toArray ( $ node -> childNodes ) ; } else { $ array [ $ node -> tagName ] = $ node -> nodeValue ; } } } return $ array ; }
Recursive method to traverse the dom and produce an array
28,078
public function getPlanItem ( $ code = null , $ itemCode = null ) { $ items = $ this -> getPlanItems ( $ code ) ; if ( ! $ itemCode && count ( $ items ) > 1 ) { throw new CheddarGetter_Response_Exception ( "This plan contains more than one item so you need to provide the code for the item you wish to get" , CheddarGetter_Response_Exception :: USAGE_INVALID ) ; } if ( ! $ itemCode ) { return current ( $ items ) ; } return $ items [ $ itemCode ] ; }
Get an array representation of a single plan item node
28,079
public function getPromotion ( $ couponCode = null ) { if ( $ this -> getResponseType ( ) != 'promotions' ) { throw new CheddarGetter_Response_Exception ( "Can't get a promotion from a response doc that isn't of type 'promotions'" , CheddarGetter_Response_Exception :: USAGE_INVALID ) ; } if ( ! $ couponCode && $ this -> getElementsByTagName ( 'promotion' ) -> length > 1 ) { throw new CheddarGetter_Response_Exception ( "This response contains more than one promotion so you need to provide the coupon code for the promotion you wish to get" , CheddarGetter_Response_Exception :: USAGE_INVALID ) ; } if ( ! $ couponCode ) { return current ( $ this -> toArray ( ) ) ; } $ array = $ this -> toArray ( ) ; return $ array [ $ couponCode ] ; }
Get an array representation of a single promotion node
28,080
public function getCustomer ( $ code = null ) { if ( $ this -> getResponseType ( ) != 'customers' ) { throw new CheddarGetter_Response_Exception ( "Can't get a customer from a response doc that isn't of type 'customers'" , CheddarGetter_Response_Exception :: USAGE_INVALID ) ; } if ( ! $ code && $ this -> getElementsByTagName ( 'customer' ) -> length > 1 ) { throw new CheddarGetter_Response_Exception ( "This response contains more than one customer so you need to provide the code for the customer you wish to get" , CheddarGetter_Response_Exception :: USAGE_INVALID ) ; } if ( ! $ code ) { return current ( $ this -> toArray ( ) ) ; } $ array = $ this -> toArray ( ) ; return $ array [ $ code ] ; }
Get an array representation of a single customer node
28,081
public function getCustomerIsActive ( $ code = null , $ remainActiveThroughEndOfPeriod = false ) { $ subscription = $ this -> getCustomerSubscription ( $ code ) ; if ( $ subscription [ 'canceledDatetime' ] ) { if ( strtotime ( $ subscription [ 'canceledDatetime' ] ) <= time ( ) ) { if ( $ remainActiveThroughEndOfPeriod ) { $ invoice = $ this -> getCustomerInvoice ( $ code ) ; if ( strtotime ( $ invoice [ 'billingDatetime' ] ) > time ( ) ) { return true ; } } return false ; } } return true ; }
Whether or not a customer s subscription is active and in good standing
28,082
public function getCustomerIsWaitingForPayPal ( $ code = null ) { $ subscription = $ this -> getCustomerSubscription ( $ code ) ; if ( $ subscription [ 'canceledDatetime' ] && strtotime ( $ subscription [ 'canceledDatetime' ] ) <= time ( ) && $ subscription [ 'cancelType' ] == 'paypal-wait' ) { return true ; } return false ; }
Is this customer s account pending paypal preapproval confirmation?
28,083
public function getCustomerLastBilledInvoice ( $ code = null ) { $ invoices = $ this -> getCustomerInvoices ( $ code ) ; foreach ( $ invoices as $ key => $ i ) { if ( ! empty ( $ i [ 'billingDatetime' ] ) && strtotime ( $ i [ 'billingDatetime' ] ) <= time ( ) ) { return $ i ; } } return array ( ) ; }
Get an array representation of a single customer s last billed invoice
28,084
public function getCustomerInvoices ( $ code = null ) { $ invoices = array ( ) ; $ subscriptions = $ this -> getCustomerSubscriptions ( $ code ) ; foreach ( $ subscriptions as $ subscription ) { if ( isset ( $ subscription [ 'invoices' ] ) ) { foreach ( $ subscription [ 'invoices' ] as $ key => $ i ) { $ invoices [ $ key ] = $ i ; } } } return $ invoices ; }
Get an array representation of a single customer s invoices
28,085
public function getCustomerTransactions ( $ code = null ) { $ txns = array ( ) ; $ subscriptions = $ this -> getCustomerSubscriptions ( $ code ) ; foreach ( $ subscriptions as $ subscription ) { if ( isset ( $ subscription [ 'invoices' ] ) ) { foreach ( $ subscription [ 'invoices' ] as $ key => $ i ) { if ( isset ( $ i [ 'transactions' ] ) ) { foreach ( $ i [ 'transactions' ] as $ idx => $ t ) { $ txns [ $ idx ] = $ t ; } } } } } return $ txns ; }
Get an array representation of a single customer s transactions
28,086
public function getCustomerOutstandingInvoices ( $ code = null ) { $ subscription = $ this -> getCustomerSubscription ( $ code ) ; foreach ( $ subscription [ 'invoices' ] as $ key => $ i ) { if ( $ i [ 'paidTransactionId' ] || strtotime ( $ i [ 'billingDatetime' ] ) > time ( ) ) { unset ( $ subscription [ 'invoices' ] [ $ key ] ) ; } } if ( $ subscription [ 'invoices' ] ) { return $ subscription [ 'invoices' ] ; } return false ; }
Get an array representation of a single customer s outstanding invoices
28,087
public function getCustomerItemQuantity ( $ code = null , $ itemCode = null ) { $ subscription = $ this -> getCustomerSubscription ( $ code ) ; if ( ! $ itemCode && count ( $ subscription [ 'items' ] ) > 1 ) { throw new CheddarGetter_Response_Exception ( "This customer's subscription contains more than one item so you need to provide the code for the item you wish to get" , CheddarGetter_Response_Exception :: USAGE_INVALID ) ; } $ plan = $ this -> getCustomerPlan ( $ code ) ; if ( $ itemCode ) { $ item = $ plan [ 'items' ] [ $ itemCode ] ; $ itemQuantity = $ subscription [ 'items' ] [ $ itemCode ] ; } else { $ item = current ( $ plan [ 'items' ] ) ; $ itemQuantity = current ( $ subscription [ 'items' ] ) ; } return array ( 'item' => $ item , 'quantity' => $ itemQuantity ) ; }
Get an array of a customer s item quantity and quantity included
28,088
public function getCustomerItemQuantityOverage ( $ code = null , $ itemCode = null ) { $ remaining = $ this -> getCustomerItemQuantityRemaining ( $ code , $ itemCode ) ; if ( $ remaining > 0 ) { return 0 ; } return abs ( $ remaining ) ; }
Get quantity usage greater than included quantity
28,089
public function getCustomerItemQuantityOverageCost ( $ code = null , $ itemCode = null ) { $ item = $ this -> getCustomerItemQuantity ( $ code , $ itemCode ) ; $ overage = $ this -> getCustomerItemQuantityOverage ( $ code , $ itemCode ) ; if ( $ overage ) { return sprintf ( "%01.2f" , $ overage * $ item [ 'item' ] [ 'overageAmount' ] ) ; } return 0 ; }
Get current item overage cost
28,090
public function handleError ( ) { if ( $ this -> _responseType == 'error' ) { throw new CheddarGetter_Response_Exception ( $ this -> documentElement -> firstChild -> nodeValue , $ this -> documentElement -> getAttribute ( 'code' ) , $ this -> documentElement -> getAttribute ( 'id' ) , $ this -> documentElement -> getAttribute ( 'auxCode' ) ) ; } return false ; }
Handle an error if there is one
28,091
public function handleEmbeddedErrors ( ) { if ( $ this -> hasEmbeddedErrors ( ) ) { $ errors = $ this -> getEmbeddedErrors ( ) ; $ error = $ errors [ 0 ] ; throw new CheddarGetter_Response_Exception ( $ error [ 'message' ] , $ error [ 'code' ] , $ error [ 'id' ] , $ error [ 'auxCode' ] ) ; } return false ; }
Checks for embedded errors and if found throws an exception containing the first error
28,092
protected function createTwigEnvironment ( array $ options ) { if ( ! isset ( $ options [ 'path' ] ) ) { throw new \ BadMethodCallException ( "'path' option is required" ) ; } $ loader = new \ Twig_Loader_Filesystem ( ) ; $ this -> addLoaderPaths ( $ loader , $ options [ 'path' ] ) ; return new \ Twig_Environment ( $ loader , $ options ) ; }
Create a new Twig environment
28,093
protected function addLoaderPaths ( \ Twig_Loader_Filesystem $ loader , $ paths ) { foreach ( ( array ) $ paths as $ namespace => $ path ) { if ( is_int ( $ namespace ) ) { $ namespace = \ Twig_Loader_Filesystem :: MAIN_NAMESPACE ; } $ loader -> addPath ( $ path , $ namespace ) ; } }
Add paths to Twig loader
28,094
protected function assertViewVariableName ( $ name ) { if ( ! is_string ( $ name ) ) { $ type = ( is_object ( $ name ) ? get_class ( $ name ) . ' ' : '' ) . gettype ( $ name ) ; throw new \ InvalidArgumentException ( "Expected name to be a string, not a $type" ) ; } if ( ! preg_match ( '/^[a-z]\w*$/i' , $ name ) ) { throw new \ InvalidArgumentException ( "Invalid name '$name'" ) ; } }
Assert valid variable function and filter name
28,095
public function expose ( $ name , $ function = null , $ as = 'function' ) { $ this -> assertViewVariableName ( $ name ) ; if ( $ as === 'function' ) { $ function = new \ Twig_SimpleFunction ( $ name , $ function ? : $ name ) ; $ this -> getTwig ( ) -> addFunction ( $ function ) ; } elseif ( $ as === 'filter' ) { $ filter = new \ Twig_SimpleFilter ( $ name , $ function ? : $ name ) ; $ this -> getTwig ( ) -> addFilter ( $ filter ) ; } else { $ not = is_string ( $ as ) ? "'$as'" : gettype ( $ as ) ; throw new \ InvalidArgumentException ( "You can create either a 'function' or 'filter', not a $not" ) ; } return $ this ; }
Expose a function to the view .
28,096
public function addPlugin ( PluginInterface $ plugin ) { $ plugin -> onAdd ( $ this ) ; $ this -> plugins [ ] = $ plugin ; return $ this ; }
Add a plugin to the view
28,097
protected function invokePluginsOnRender ( $ template , array $ context ) { foreach ( $ this -> plugins as $ plugin ) { $ plugin -> onRender ( $ this , $ template , $ context ) ; } }
Invoke the onRender method of all plugins
28,098
private function getRequestOptions ( ) { $ options = $ this -> getGuzzleClient ( ) -> getConfig ( ) -> get ( Client :: REQUEST_OPTIONS ) ; if ( ! is_array ( $ options ) ) { $ options = array ( ) ; } return $ options ; }
Get request options
28,099
private function setRequestOptions ( array $ options ) { $ config = $ this -> getGuzzleClient ( ) -> getConfig ( ) ; $ config -> set ( Client :: REQUEST_OPTIONS , $ options ) ; $ this -> getGuzzleClient ( ) -> setConfig ( $ config ) ; }
Set request options