idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
27,800 | public function getHttp ( ) { if ( is_null ( $ this -> http ) ) { $ this -> http = new Http ( ) ; } if ( count ( $ this -> http -> getMiddlewares ( ) ) === 0 ) { $ this -> registerHttpMiddlewares ( ) ; } return $ this -> http ; } | Return the http instance . |
27,801 | public function parseJSON ( $ method , array $ args ) { $ http = $ this -> getHttp ( ) ; $ contents = $ http -> parseJSON ( call_user_func_array ( [ $ http , $ method ] , $ args ) ) ; $ this -> checkAndThrow ( $ contents ) ; return new Collection ( $ contents ) ; } | Parse JSON from response and check error . |
27,802 | public function getCloudImageCached ( ) { $ cached = new CloudImageCached ( $ this -> Filename ) ; $ cached -> Title = $ this -> Title ; $ cached -> ParentID = $ this -> ParentID ; $ cached -> setStoreRecord ( $ this ) ; return $ cached ; } | Constructs an image record that can be used with this meta data |
27,803 | public function save ( ) { if ( self :: $ file_added ) file_put_contents ( $ this -> getFileListName ( ) , '<?php return ' . var_export ( self :: $ files [ $ this -> prefix ] , true ) . ';' ) ; self :: $ file_added = false ; } | Calling file_put_contents within a destructor will cause the file to be written in SERVER_ROOT ... |
27,804 | public function getNameAndExtension ( $ name ) { static $ extensions = array ( 'js' , 'html' , 'css' , 'txt' , 'png' , 'gif' , 'jpg' , 'jpeg' , 'eot' , 'svc' , 'woff' , 'woff2' , 'otf' , 'ttf' , 'svg' ) ; $ filename_parts = explode ( '.' , $ name ) ; $ name_parts = array ( ) ; $ filters = array ( ) ; foreach ( $ filename_parts as $ i => $ p ) { if ( $ i != 0 && in_array ( $ p , $ extensions ) ) { $ type = $ p ; break ; } if ( isset ( $ type ) ) ; else $ name_parts [ ] = $ p ; } $ name = implode ( '.' , $ name_parts ) ; if ( ! isset ( $ type ) ) $ type = $ filename_parts [ 1 ] ; return array ( $ name , $ type , $ i ) ; } | reads name and extension for a file name |
27,805 | public function getDirectory ( $ name , $ ext ) { if ( '' === $ name = '/' . trim ( $ name , '/.' ) . '/' ) return true ; $ type = $ this -> getTypeForExt ( $ ext ) ; foreach ( $ this -> paths as $ path ) { $ prefixes = isset ( $ path [ 'prefixes' ] ) ? $ path [ 'prefixes' ] : array ( ) ; $ prefix = isset ( $ prefixes [ $ type ] ) ? $ prefixes [ $ type ] . '/' : '' ; foreach ( $ path [ 'directories' ] as $ directory ) { if ( file_exists ( $ directory ) && is_dir ( $ directory ) ) return $ directory ; } } throw new Exception \ DirectoryNotFound ( $ name ) ; } | first - depth find . only returns 1 result |
27,806 | public function registerHook ( $ eventType , IEventHook $ hook ) { switch ( $ eventType ) { case IEventHook :: EVENT_SAVE_CHANGES : $ this -> getDataUpdater ( ) -> registerSaveChangesEventHook ( $ hook ) ; break ; default : throw new Exception ( "Unrecognised type $eventType whilst registering event hook" ) ; } } | Register an event hook which |
27,807 | public function getComposite ( $ operation ) { switch ( $ operation ) { case OP_VIEWS : return $ this -> getTripodViews ( ) ; case OP_TABLES : return $ this -> getTripodTables ( ) ; case OP_SEARCH : return $ this -> getSearchIndexer ( ) ; default : throw new \ Tripod \ Exceptions \ Exception ( "Undefined operation '$operation' requested" ) ; } } | Returns the composite that can perform the supported operation |
27,808 | protected function getDataUpdater ( ) { if ( ! isset ( $ this -> dataUpdater ) ) { $ readPreference = $ this -> collection -> __debugInfo ( ) [ 'readPreference' ] -> getMode ( ) ; $ opts = array ( 'defaultContext' => $ this -> defaultContext , OP_ASYNC => $ this -> async , 'stat' => $ this -> stat , 'readPreference' => $ readPreference , 'retriesToGetLock' => $ this -> retriesToGetLock , 'statsConfig' => $ this -> statsConfig ) ; $ this -> dataUpdater = new Updates ( $ this , $ opts ) ; } return $ this -> dataUpdater ; } | Returns the delegate object for saving data in Mongo |
27,809 | public function batchSyncUser ( $ mediaId , $ callback = [ ] ) { $ params = [ 'media_id' => $ mediaId , 'callback' => $ callback , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_SYNC_USER , $ params ] ) ; } | Batch sync user . |
27,810 | public function batchReplaceUser ( $ mediaId , $ callback = [ ] ) { $ params = [ 'media_id' => $ mediaId , 'callback' => $ callback , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_REPLACE_USER , $ params ] ) ; } | Batch replace user . |
27,811 | public function batchReplaceParty ( $ mediaId , $ callback = [ ] ) { $ params = [ 'media_id' => $ mediaId , 'callback' => $ callback , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_REPLACE_PARTY , $ params ] ) ; } | Batch replace party . |
27,812 | public function HashFile ( $ path , $ theme = true ) { $ path = $ theme ? $ this -> getPath ( $ path ) : $ path ; if ( file_exists ( $ path ) ) { $ hash = md5_file ( $ path ) ; return str_replace ( array ( '/' , '+' , '=' ) , '' , base64_encode ( pack ( 'H*' , $ hash ) ) ) ; } return '' ; } | Returns an md5 hash of a file |
27,813 | public function HashPath ( $ path , $ theme = true ) { $ filepath = $ this -> getPath ( $ path , $ theme ) ; $ path_parts = pathinfo ( $ filepath ) ; return sprintf ( self :: $ format , str_replace ( BASE_PATH . ( self :: $ relativeLinks ? '/' : '' ) , '' , $ path_parts [ 'dirname' ] ) , basename ( $ path , ".{$path_parts['extension']}" ) , $ this -> HashFile ( $ filepath , false ) , $ path_parts [ 'extension' ] ) ; } | Template function to return new web path to asset which includes md5 hash |
27,814 | protected function getPath ( $ path , $ theme = true ) { if ( $ theme ) { $ themes = SSViewer :: get_themes ( ) ; if ( is_array ( $ themes ) ) { $ themePath = $ themes [ 0 ] ; } else { $ themePath = 'simple' ; } $ path = '/themes/' . $ themePath . "/$path" ; } return BASE_PATH . $ path ; } | Returns the absolute path to a file based on whether or not the input is relative to the current theme |
27,815 | public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ em = $ eventArgs -> getEntityManager ( ) ; $ uow = $ em -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { if ( $ entity instanceof FileInterface ) { $ this -> populateMeta ( $ em , $ uow , $ entity ) ; $ this -> scheduledForCopyFiles [ spl_object_hash ( $ entity ) ] = $ entity ; } } foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { if ( $ entity instanceof FileInterface ) { if ( $ this -> versionEnabled ) { $ em -> lock ( $ entity , LockMode :: OPTIMISTIC , $ entity -> getCurrentVersion ( ) ) ; } if ( true === $ entity -> isScheduledForDeletion ( ) ) { $ uow -> scheduleForDelete ( $ entity ) ; continue ; } $ changeSet = $ uow -> getEntityChangeSet ( $ entity ) ; if ( isset ( $ changeSet [ 'name' ] ) ) { $ clonedEntity = clone $ entity ; $ clonedEntity -> setName ( $ changeSet [ 'name' ] [ 0 ] ) ; $ this -> scheduledForDeleteFiles [ spl_object_hash ( $ clonedEntity ) ] = $ clonedEntity ; $ this -> scheduledForCopyFiles [ spl_object_hash ( $ entity ) ] = $ entity ; $ this -> checksum ( $ entity ) ; } if ( isset ( $ changeSet [ 'name' ] ) || isset ( $ changeSet [ 'hash' ] ) ) { $ this -> populateMeta ( $ em , $ uow , $ entity ) ; } } } foreach ( $ uow -> getScheduledEntityDeletions ( ) as $ entity ) { if ( $ entity instanceof FileInterface ) { $ this -> scheduledForDeleteFiles [ spl_object_hash ( $ entity ) ] = $ entity ; } } } | Handles onFlush event and moves file to permenant directory |
27,816 | protected function checksum ( FileInterface $ entity ) { $ currentHash = $ this -> fileManager -> checksumTemporaryFileByName ( $ entity -> getName ( ) ) ; if ( $ entity -> getHash ( ) !== $ currentHash ) { throw new FileHashChangedException ( $ entity -> getName ( ) ) ; } } | Checks if file is modified by some other user |
27,817 | public static function onFailure ( \ Exception $ e , \ Resque_Job $ job ) { $ failedJob = $ job -> getInstance ( ) ; $ failedJob -> errorLog ( 'Caught exception in ' . get_called_class ( ) . ': ' . $ e -> getMessage ( ) ) ; $ failedJob -> getStat ( ) -> increment ( $ failedJob -> getStatFailureIncrementKey ( ) ) ; throw $ e ; } | Resque event when a job failures |
27,818 | protected function validateArgs ( ) { $ message = null ; foreach ( $ this -> getMandatoryArgs ( ) as $ arg ) { if ( ! isset ( $ this -> args [ $ arg ] ) ) { $ message = "Argument $arg was not present in supplied job args for job " . get_class ( $ this ) ; $ this -> errorLog ( $ message ) ; throw new \ Exception ( $ message ) ; } } if ( $ this -> configRequired ) { $ this -> ensureConfig ( ) ; } } | Validate the arguments for this job |
27,819 | protected function serializeConfig ( $ configSerializer ) { if ( $ configSerializer instanceof ITripodConfigSerializer ) { return $ configSerializer -> serialize ( ) ; } elseif ( is_array ( $ configSerializer ) ) { return $ configSerializer ; } else { throw new \ InvalidArgumentException ( '$configSerializer must an ITripodConfigSerializer or array' ) ; } } | Take a Tripod Config Serializer and return a config array |
27,820 | protected function setTripodConfig ( ) { if ( isset ( $ this -> args [ self :: TRIPOD_CONFIG_GENERATOR ] ) ) { $ config = $ this -> args [ self :: TRIPOD_CONFIG_GENERATOR ] ; } else { $ config = $ this -> args [ self :: TRIPOD_CONFIG_KEY ] ; } $ this -> tripodConfig = $ this -> deserializeConfig ( $ config ) ; } | Sets the Tripod config for the job |
27,821 | protected function getTripodConfig ( ) { if ( ! isset ( $ this -> tripodConfig ) ) { $ this -> ensureConfig ( ) ; $ this -> setConfig ( ) ; } return $ this -> tripodConfig ; } | Returns the Tripod config required by the job |
27,822 | protected function getTripodOptions ( ) { $ statsConfig = $ this -> getStatsConfig ( ) ; $ options = [ ] ; if ( ! empty ( $ statsConfig ) ) { $ options [ 'statsConfig' ] = $ statsConfig ; } return $ options ; } | Tripod options to pass between jobs |
27,823 | protected function generateConfigJobArgs ( ) { $ configInstance = $ this -> getConfigInstance ( ) ; $ args = [ ] ; if ( $ configInstance instanceof ITripodConfigSerializer ) { $ config = $ configInstance -> serialize ( ) ; } else { $ config = \ Tripod \ Config :: getConfig ( ) ; } if ( isset ( $ config [ 'class' ] ) ) { $ args [ self :: TRIPOD_CONFIG_GENERATOR ] = $ config ; } else { $ args [ self :: TRIPOD_CONFIG_KEY ] = $ config ; } return $ args ; } | Convenience method to pass config to job data |
27,824 | public function initializeContext ( Context $ context ) { if ( ! $ context instanceof GuzzleAwareContext ) { return ; } $ context -> setGuzzleClient ( $ this -> client ) ; $ context -> setGuzzleParameters ( $ this -> parameters ) ; } | Initializes provided context |
27,825 | public function take_damage ( $ amount ) { if ( $ this -> is_bound ( ) ) { $ this -> unbind ( ) ; } if ( $ this -> health ( ) ) { $ this -> health -= $ amount ; $ this -> say ( sprintf ( __ ( 'takes %1$s damage, %2$s health power left' ) , $ amount , $ this -> health ( ) ) ) ; if ( $ this -> health ( ) <= 0 ) { $ this -> position = null ; $ this -> say ( __ ( "dies" ) ) ; } } } | Take damage . |
27,826 | public function add_abilities ( $ new_abbilities ) { foreach ( $ new_abbilities as $ abbility_str ) { $ camel = '' ; $ abbility_str = str_replace ( ':' , '' , $ abbility_str ) ; foreach ( explode ( '_' , $ abbility_str ) as $ str ) { $ camel .= ucfirst ( $ str ) ; } $ class_name = 'PHPWarrior\Abilities\\' . $ camel ; $ this -> abilities [ $ abbility_str ] = new $ class_name ( $ this ) ; } return $ this ; } | Add some abilties . |
27,827 | public function perform_turn ( ) { if ( $ this -> position ) { foreach ( $ this -> abilities as $ ability ) { $ ability -> pass_turn ( ) ; } if ( $ this -> current_turn -> action && ! $ this -> is_bound ( ) ) { list ( $ name , $ args ) = $ this -> current_turn -> action ; call_user_func_array ( [ $ this -> abilities [ $ name ] , 'perform' ] , $ args ) ; } } } | Perform your turn . |
27,828 | public function sanitize ( $ input ) { foreach ( $ this -> rawRules as $ rule ) { if ( $ rule instanceof Attributes ) { $ config = [ 'remainder' => $ this -> remainder , 'recursive' => $ this -> recursive ] ; Instance :: configure ( $ rule , $ config ) ; return $ rule -> sanitize ( $ input ) ; } $ input = $ rule -> sanitize ( $ input ) ; if ( $ rule -> recursive && ( is_array ( $ input ) || is_object ( $ input ) ) ) { $ config [ 'attributes' ] = $ this ; return ( new Attributes ( $ config ) ) -> sanitize ( $ input ) ; } } return $ input ; } | Sanitize value . |
27,829 | protected function getInstanceRule ( $ name , array $ arguments ) { $ reflect = new \ ReflectionClass ( $ this -> rules [ $ name ] ) ; return $ reflect -> newInstanceArgs ( $ arguments ) ; } | Returns instance rule . |
27,830 | public static function getInstance ( AssetsInstallerInterface $ installer = null ) { if ( empty ( self :: $ _instance ) ) { if ( empty ( $ installer ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Can not instantiate autoloader generator singleton object "%s"' . ' without an "AssetsInstallerInterface" object argument!' , get_called_class ( ) ) ) ; } $ cls = get_called_class ( ) ; self :: $ _instance = new $ cls ( $ installer ) ; } return self :: $ _instance ; } | Get a singleton instance |
27,831 | public function readJsonDatabase ( ) { $ assets_file = $ this -> assets_installer -> getVendorDir ( ) . '/' . $ this -> assets_installer -> getAssetsDbFilename ( ) ; if ( file_exists ( $ assets_file ) ) { $ json = new JsonFile ( $ assets_file ) ; $ assets = $ json -> read ( ) ; return $ assets ; } return false ; } | Reads the assets database from JSON file |
27,832 | public function writeJsonDatabase ( array $ full_db ) { $ assets_file = $ this -> assets_installer -> getVendorDir ( ) . '/' . $ this -> assets_installer -> getAssetsDbFilename ( ) ; $ this -> assets_installer -> getIo ( ) -> write ( sprintf ( 'Writing assets json DB to <info>%s</info>' , str_replace ( dirname ( $ this -> assets_installer -> getVendorDir ( ) ) . '/' , '' , $ assets_file ) ) ) ; try { $ json = new JsonFile ( $ assets_file ) ; if ( $ json -> exists ( ) ) { unlink ( $ assets_file ) ; } $ json -> write ( $ full_db ) ; return $ assets_file ; } catch ( \ Exception $ e ) { if ( file_put_contents ( $ assets_file , json_encode ( $ full_db , version_compare ( PHP_VERSION , '5.4' ) > 0 ? JSON_PRETTY_PRINT : 0 ) ) ) { return $ assets_file ; } } return false ; } | Writes the assets database in a JSON file |
27,833 | public static function getRegistry ( AssetsInstallerInterface $ installer = null ) { $ _this = self :: getInstance ( $ installer ) ; return $ _this -> assets_db ; } | Get the current assets database |
27,834 | public function getFakeData ( Generator $ faker ) { if ( $ data = $ this -> getDataByFieldName ( $ faker ) ) { return $ data ; } return $ faker -> sentence ( rand ( 2 , 5 ) ) ; } | Gets a random text value . |
27,835 | public function boot ( ) { $ views = __DIR__ . '/views' ; $ this -> loadViewsFrom ( $ views , 'resource-table' ) ; $ this -> publishes ( [ $ views => base_path ( 'resources/views/vendor/msieprawski/resource-table' ) , ] ) ; $ this -> loadTranslationsFrom ( __DIR__ . '/lang' , 'resource-table' ) ; } | Bootstrap the application events |
27,836 | public function addColumn ( array $ data ) { $ columnValidation = $ this -> _validateColumn ( $ data ) ; if ( is_string ( $ this -> _validateColumn ( $ data ) ) ) { throw new CollectionException ( 'Invalid column data. ' . $ columnValidation ) ; } $ this -> _columns [ ] = $ data ; return $ this ; } | Adds column to resource table |
27,837 | public function make ( ) { if ( empty ( $ this -> _columns ) ) { throw new CollectionException ( 'At least one column is required to generate a resource table.' ) ; } $ this -> _prepareBuilder ( ) ; $ items = $ this -> _builder -> get ( ) ; return with ( new Table ( $ items , [ 'collection_generator' => $ this , 'columns' => $ this -> _columns , 'per_page' => $ this -> _perPage , 'paginate' => $ this -> _paginate , 'paginator_presenter' => $ this -> _getPaginatorPresenter ( $ items ) , 'view_name' => $ this -> _viewName , 'filter' => $ this -> _filter , 'extra' => $ this -> _extraViewData , ] ) ) -> make ( ) ; } | Returns HTML with resource table |
27,838 | public function renderFilterForm ( ) { if ( ! $ this -> _filter ) { return false ; } foreach ( $ this -> _columns as $ columnData ) { $ column = new Column ( $ columnData ) ; if ( $ column -> searchable ( ) ) { return true ; } } return false ; } | Checks if filter form should be generated |
27,839 | public function sort ( $ index , $ direction ) { if ( ! in_array ( $ direction , [ 'ASC' , 'DESC' ] ) ) { throw new CollectionException ( 'Sort direction must be ASC or DESC.' ) ; } $ this -> _sort = [ 'index' => $ index , 'dir' => $ direction ] ; return $ this ; } | Sets sort configuration |
27,840 | private function _setView ( $ name , $ custom = false ) { if ( ! is_string ( $ name ) ) { throw new CollectionException ( 'View name must be a string.' ) ; } $ this -> _viewName = ( ! $ custom ? 'resource-table::' : '' ) . $ name ; return $ this ; } | Sets view name for further rendering |
27,841 | public function resetFormUrl ( ) { $ params = Input :: get ( ) ; $ fieldsToReset = [ ] ; foreach ( $ this -> _columns as $ columnData ) { $ column = new Column ( $ columnData ) ; $ fieldsToReset [ ] = 'resource_table_' . $ column -> index ( ) ; } foreach ( $ fieldsToReset as $ fieldName ) { if ( isset ( $ params [ $ fieldName ] ) ) { unset ( $ params [ $ fieldName ] ) ; } } return Request :: url ( ) . '?' . http_build_query ( $ params ) ; } | Returns URL to reset search form |
27,842 | private function _validateColumn ( array $ data ) { if ( ! isset ( $ data [ 'label' ] ) ) { return 'Label key is required.' ; } if ( ! isset ( $ data [ 'index' ] ) ) { return 'Index key is required.' ; } if ( isset ( $ data [ 'renderer' ] ) && ( ! $ data [ 'renderer' ] instanceof \ Closure && ! is_string ( $ data [ 'renderer' ] ) ) ) { return 'Renderer must be a string or instance of Closure object.' ; } if ( isset ( $ data [ 'filter' ] ) && ! $ data [ 'filter' ] instanceof \ Closure ) { return 'Filter function must be instance of Closure object.' ; } return true ; } | Checks if provided column data is valid Returns bool if it s valid Returns string it it s not valid |
27,843 | private function _addQueryCondition ( $ builder , $ type , $ columnName , $ operator , $ value ) { switch ( $ type ) { case 'having' : $ builder -> having ( $ columnName , $ operator , $ value ) ; break ; case 'where' : default : $ builder -> where ( $ columnName , $ operator , $ value ) ; break ; } return $ builder ; } | Adds condition to the query builder |
27,844 | private function _prepareBuilder ( ) { $ builder = $ this -> _builder ; $ params = Input :: get ( ) ; if ( $ this -> renderFilterForm ( ) ) { foreach ( $ this -> _columns as $ columnData ) { $ column = new Column ( $ columnData ) ; if ( ! $ column -> searchable ( ) ) { continue ; } if ( ! isset ( $ params [ 'resource_table_' . $ column -> index ( ) ] ) ) { continue ; } $ value = $ params [ 'resource_table_' . $ column -> index ( ) ] ; if ( ! $ value || ! is_string ( $ value ) ) { continue ; } $ value = $ this -> _prepareFilterValue ( $ columnData , $ value ) ; switch ( $ column -> searchType ( ) ) { case 'select' : if ( ResourceTable :: ALL_SELECT_VALUES_KEY == $ value ) { continue ; } $ builder = $ this -> _addQueryCondition ( $ builder , $ column -> queryConditionType ( ) , $ column -> getDatabaseName ( ) , '=' , $ value ) ; break ; case 'string' : default : $ builder = $ this -> _addQueryCondition ( $ builder , $ column -> queryConditionType ( ) , $ column -> getDatabaseName ( ) , 'LIKE' , '%' . $ value . '%' ) ; break ; } } } if ( $ this -> _paginate ) { if ( isset ( $ params [ 'per_page' ] ) && is_numeric ( $ params [ 'per_page' ] ) && $ params [ 'per_page' ] > 0 ) { $ this -> _perPage = ( int ) $ params [ 'per_page' ] ; } if ( isset ( $ params [ 'page' ] ) && is_numeric ( $ params [ 'page' ] ) && $ params [ 'page' ] > 1 ) { $ this -> _page = ( int ) $ params [ 'page' ] ; } $ toSkip = ( $ this -> _page * $ this -> _perPage ) - $ this -> _perPage ; $ this -> _totalItems = $ this -> _getCountForPagination ( $ builder ) ; $ builder = $ builder -> skip ( $ toSkip ) -> take ( $ this -> _perPage ) ; } if ( $ this -> _validSort ( $ params ) ) { $ this -> sort ( $ params [ 'order_by' ] , strtoupper ( $ params [ 'order_dir' ] ) ) ; } $ sort = $ this -> getSort ( ) ; if ( $ sort [ 'index' ] && $ sort [ 'dir' ] ) { $ builder = $ builder -> orderBy ( $ sort [ 'index' ] , $ sort [ 'dir' ] ) ; } $ this -> _builder = $ builder ; } | Prepares builder object before calling get method on it |
27,845 | private function _getPaginatorPresenter ( array $ items ) { if ( ! $ this -> _paginate ) { return null ; } $ params = Input :: get ( ) ; if ( ! empty ( $ params ) ) { if ( isset ( $ params [ 'page' ] ) ) { unset ( $ params [ 'page' ] ) ; } } $ paginator = new LengthAwarePaginator ( $ items , $ this -> _totalItems , $ this -> _perPage , $ this -> _page , [ 'path' => Request :: url ( ) , ] ) ; $ paginator -> appends ( $ params ) ; return new $ this -> _paginationPresenter ( $ paginator ) ; } | Returns Paginator Presenter object if pagination is enabled |
27,846 | public function toOpenId ( $ userId , $ agentId ) { $ params = [ 'userid' => $ userId , 'agentid' => $ agentId , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_TO_OPENID , $ params ] ) ; } | Convert userid to openid . |
27,847 | public function getStatement ( $ name ) { try { $ this -> load ( ) ; } catch ( \ Exception $ e ) { throw $ e ; } return isset ( $ this -> _statements [ $ name ] ) ? $ this -> _statements [ $ name ] : null ; } | Get one preset s statement entry |
27,848 | public function getOrganizedStatements ( ) { $ organized_statements = array ( ) ; if ( empty ( $ this -> _statements ) ) { try { $ this -> load ( ) ; } catch ( \ Exception $ e ) { throw $ e ; } } $ statements = $ this -> _statements ; if ( ! empty ( $ statements [ 'require' ] ) ) { foreach ( $ statements [ 'require' ] as $ statement ) { $ data = $ statement -> getData ( ) ; foreach ( $ statement -> getData ( ) as $ type => $ stack ) { if ( ! isset ( $ statements [ $ type ] ) ) { $ statements [ $ type ] = array ( ) ; } $ statements [ $ type ] = array_merge ( $ statements [ $ type ] , $ stack ) ; } } unset ( $ statements [ 'require' ] ) ; } foreach ( $ statements as $ type => $ statement_stack ) { if ( ! isset ( $ organized_statements [ $ type ] ) ) { $ organized_statements [ $ type ] = array ( ) ; } foreach ( $ statement_stack as $ statement ) { $ organized_statements [ $ type ] [ ] = $ statement ; } } foreach ( $ organized_statements as $ type => $ stacks ) { $ organized_statements [ $ type ] = $ this -> getOrderedStatements ( $ stacks ) ; } return $ organized_statements ; } | Organize each statements item by position & requirements |
27,849 | public static function getOrderedStatements ( array $ statements ) { $ ordered = array ( ) ; foreach ( $ statements as $ index => $ statement ) { $ data = $ statement -> getData ( ) ; $ ordered [ $ index ] = isset ( $ data [ 'position' ] ) ? $ data [ 'position' ] : count ( $ ordered ) + 1 ; } array_multisort ( $ ordered , SORT_DESC , SORT_NUMERIC , $ statements ) ; return $ statements ; } | Internal function to order a statements stack |
27,850 | public function transformMaterial ( AbstractMessage $ message ) { $ type = $ message -> getType ( ) ; return [ 'msgtype' => $ type , $ type => [ 'media_id' => $ message -> get ( 'media_id' ) , ] , ] ; } | Transform material message . |
27,851 | public function transformTextCard ( AbstractMessage $ message ) { return [ 'msgtype' => 'textcard' , 'textcard' => [ 'title' => $ message -> get ( 'title' ) , 'description' => $ message -> get ( 'description' ) , 'url' => $ message -> get ( 'url' ) , 'btntxt' => $ message -> get ( 'btntxt' ) , ] , ] ; } | Transform textcard message . |
27,852 | public function getTicketCacheKey ( ) { if ( is_null ( $ this -> ticketCacheKey ) ) { return $ this -> ticketCachePrefix . $ this -> getAccessToken ( ) -> getFingerprint ( ) ; } return $ this -> ticketCacheKey ; } | Get ApiTicket token cache key . |
27,853 | public function transform ( ) { $ handle = sprintf ( 'transform%s' , ucfirst ( $ this -> msgType ) ) ; return method_exists ( $ this , $ handle ) ? $ this -> $ handle ( $ this -> message ) : [ ] ; } | Transform message . |
27,854 | public function isLocalValid ( ) { $ path = $ this -> getFullPath ( ) ; if ( ! file_exists ( $ path ) ) { return false ; } return ( getimagesize ( $ path ) !== false ) ; } | Checks if the local file is an image that can be used and not a placeholder or a corrupted file . |
27,855 | public function process ( ) { if ( $ this -> cacheOutput && $ this -> cache ) { $ contents = $ this -> input -> process ( ) ; $ key = md5 ( $ contents ) ; if ( ! ( $ output = $ this -> cache -> get ( $ key ) ) ) { $ output = $ this -> output -> process ( $ contents , $ this -> generator ) ; $ this -> cache -> set ( $ key , $ output ) ; } } else { $ output = $ this -> output -> process ( $ this -> input -> process ( ) , $ this -> generator ) ; } return $ output ; } | Processes the pdf using the input and output that have been set . |
27,856 | public function create ( $ name , $ parentId , $ order = null , $ partyId = null ) { $ params = [ 'name' => $ name , 'parentid' => $ parentId , 'order' => $ order , 'id' => $ partyId , ] ; return $ this -> parseJSON ( 'json' , [ self :: API_CREATE , $ params ] ) ; } | Create Department . |
27,857 | public function lists ( $ partyId = null ) { $ params = [ 'id' => $ partyId , ] ; return $ this -> parseJSON ( 'get' , [ self :: API_GET , $ params ] ) ; } | List all Departments . |
27,858 | public function update ( $ partyId , array $ partyInfo = [ ] ) { $ params = array_merge ( $ partyInfo , [ 'id' => $ partyId ] ) ; return $ this -> parseJSON ( 'json' , [ self :: API_UPDATE , $ params ] ) ; } | Update a Department . |
27,859 | public function editCustomer ( $ code , $ id = null , array $ data ) { $ this -> _requireIdentifier ( $ code , $ id ) ; return new CheddarGetter_Response ( $ this -> request ( '/customers/edit/' . ( ( $ id ) ? 'id/' . $ id : 'code/' . urlencode ( $ code ) ) , $ data ) ) ; } | Change customer and subscription information |
27,860 | public function voidOrRefundInvoice ( $ number , $ id = null ) { return new CheddarGetter_Response ( $ this -> request ( '/invoices/void-or-refund/' . ( ( $ id ) ? 'id/' . $ id : 'number/' . $ number ) , array ( 'bogus' => 'make this a post' ) ) ) ; } | Void or refund invoice |
27,861 | public function sendEmailReceipt ( $ number , $ id = null ) { $ this -> _requireIdentifier ( $ number , $ id ) ; return new CheddarGetter_Response ( $ this -> request ( '/invoices/send-email/' . ( ( $ id ) ? 'id/' . $ id : 'number/' . $ number ) , array ( 'bogus' => 'make this a post' ) ) ) ; } | Send an invoice receipt email |
27,862 | public function getPromotion ( $ code , $ id = null ) { $ this -> _requireIdentifier ( $ code , $ id ) ; return new CheddarGetter_Response ( $ this -> request ( '/promotions/get' . ( ( $ id ) ? '/id/' . $ id : '/code/' . urlencode ( $ code ) ) ) ) ; } | Get a single promotion |
27,863 | public function setHttpClient ( $ client ) { if ( $ client instanceof CheddarGetter_Client_AdapterInterface ) { $ this -> _httpClient = $ client ; return $ this ; } if ( $ client instanceof Zend_Http_Client ) { $ this -> _httpClient = new CheddarGetter_Client_ZendAdapter ( $ client ) ; return $ this ; } if ( is_resource ( $ client ) && get_resource_type ( $ client ) == 'curl' ) { $ this -> _httpClient = new CheddarGetter_Client_CurlAdapter ( $ client ) ; return $ this ; } throw new CheddarGetter_Client_Exception ( "httpClient can only be an instance of CheddarGetter_Client_AdapterInterface or Zend_Http_Client or a php curl resource." , CheddarGetter_Client_Exception :: USAGE_INVALID ) ; } | Set http client |
27,864 | public static function getRequestAdapter ( ) { if ( ! self :: $ _requestAdapter ) { if ( class_exists ( 'Zend_Controller_Front' , false ) ) { self :: $ _requestAdapter = new CheddarGetter_Http_ZendAdapter ( ) ; } else { self :: $ _requestAdapter = new CheddarGetter_Http_NativeAdapter ( ) ; } } return self :: $ _requestAdapter ; } | Gets the request adapter . |
27,865 | public static function getStates ( ) { return array ( self :: STATE_SENT , self :: STATE_ACCEPTED , self :: STATE_REJECTED , self :: STATE_DELIVERED , self :: STATE_FAILED , ) ; } | Gets all the states |
27,866 | public function activate ( Composer $ composer , IOInterface $ io ) { $ this -> __installer = new Dispatch ( $ io , $ composer ) ; $ composer -> getInstallationManager ( ) -> addInstaller ( $ this -> __installer ) ; } | Add the \ AssetsManager \ Composer \ Dispatch installer |
27,867 | public function onCommand ( CommandEvent $ event ) { switch ( $ event -> getCommandName ( ) ) { case 'dump-autoload' : $ _this = new DumpAutoloadEventHandler ( $ this -> __installer -> getComposer ( ) -> getPackage ( ) , $ this -> __installer -> getComposer ( ) ) ; break ; default : break ; } } | Command event dispatcher |
27,868 | public function split ( ) { return [ 'outward' => $ this -> outward ( ) , 'inward' => $ this -> inward ( ) , 'area' => $ this -> area ( ) , 'district' => $ this -> district ( ) , 'subdistrict' => $ this -> subdistrict ( ) , 'sector' => $ this -> sector ( ) , 'unit' => $ this -> unit ( ) , 'normalise' => $ this -> normalise ( ) , ] ; } | Returns an array with postcode elements |
27,869 | protected function _getIp ( ) { $ ip = null ; if ( ! empty ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { $ ip = $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } else if ( ! empty ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { $ ip = $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } else if ( ! empty ( $ _SERVER [ 'REMOTE_ADDR' ] ) ) { $ ip = $ _SERVER [ 'REMOTE_ADDR' ] ; } if ( $ this -> _isValidIpv4 ( $ ip ) ) { return $ ip ; } $ ips = explode ( ',' , $ ip , 2 ) ; $ ip = trim ( $ ips [ 0 ] ) ; if ( $ this -> _isValidIpv4 ( $ ip ) ) { return $ ip ; } return null ; } | Really get the IP |
27,870 | protected function checksum ( ImageInterface $ entity ) { $ currentHash = $ this -> imageManager -> checksumTemporaryFileByName ( $ entity -> getName ( ) ) ; if ( $ entity -> getHash ( ) !== $ currentHash ) { throw new FileHashChangedException ( $ entity -> getName ( ) ) ; } } | Checks if images is modified by some other user |
27,871 | protected function installAssets ( PackageInterface $ package ) { $ assets = $ this -> getPackageAssetsDir ( $ package ) ; if ( ! $ assets ) { return ; } $ from = $ this -> getPackageBasePath ( $ package ) . '/' . $ assets ; $ target = $ this -> getAssetsInstallPath ( $ package ) ; if ( file_exists ( $ from ) ) { $ this -> io -> write ( sprintf ( ' - Installing <info>%s</info> assets to <info>%s</info>' , $ package -> getPrettyName ( ) , str_replace ( dirname ( $ this -> assets_dir ) . '/' , '' , $ target ) ) ) ; $ this -> filesystem -> copy ( $ from , $ target ) ; Dispatch :: registerPackage ( $ package , $ target , $ this ) ; $ this -> io -> write ( '' ) ; } else { Error :: thrower ( sprintf ( 'Unable to find assets in package "%s"' , $ package -> getPrettyName ( ) ) , '\InvalidArgumentException' , __CLASS__ , __METHOD__ , __LINE__ ) ; } } | Move the assets of a package |
27,872 | protected function removeAssets ( PackageInterface $ package ) { $ assets = $ this -> getPackageAssetsDir ( $ package ) ; if ( ! $ assets ) { return ; } $ target = $ this -> getAssetsInstallPath ( $ package ) ; if ( file_exists ( $ target ) ) { $ this -> io -> write ( sprintf ( ' - Removing <info>%s</info> assets from <info>%s</info>' , $ package -> getPrettyName ( ) , str_replace ( dirname ( $ this -> assets_dir ) . '/' , '' , $ target ) ) ) ; $ this -> filesystem -> remove ( $ target ) ; Dispatch :: unregisterPackage ( $ package , $ this ) ; $ this -> io -> write ( '' ) ; } else { Error :: thrower ( sprintf ( 'Unable to find assets from package "%s"' , $ package -> getPrettyName ( ) ) , '\InvalidArgumentException' , __CLASS__ , __METHOD__ , __LINE__ ) ; } } | Remove the assets of a package |
27,873 | protected function guessConfigurator ( PackageInterface $ package ) { $ extra = $ package -> getExtra ( ) ; if ( isset ( $ extra [ 'assets-config-class' ] ) ) { Config :: load ( $ extra [ 'assets-config-class' ] , true ) ; } return $ this ; } | Create defined configuration object |
27,874 | protected function initializeAssetsDir ( ) { $ this -> filesystem -> ensureDirectoryExists ( $ this -> assets_dir ) ; $ this -> assets_dir = realpath ( $ this -> assets_dir ) ; return $ this ; } | Create the assets_dir if needed |
27,875 | protected function initializeAssetsVendorDir ( ) { $ path = $ this -> getRootPackageAssetsPath ( ) . '/' . ( $ this -> assets_vendor_dir ? str_replace ( $ this -> getRootPackageAssetsPath ( ) , '' , $ this -> assets_vendor_dir ) : '' ) ; $ this -> filesystem -> ensureDirectoryExists ( $ path ) ; $ this -> assets_vendor_dir = realpath ( $ path ) ; return $ this ; } | Create the assets_vendor_dir if needed |
27,876 | public static function guessConfigurationEntry ( PackageInterface $ package , $ config_entry ) { if ( empty ( $ config_entry ) ) { return array ( ) ; } $ extra = $ package -> getExtra ( ) ; return isset ( $ extra [ $ config_entry ] ) ? $ extra [ $ config_entry ] : Config :: get ( $ config_entry ) ; } | Search a configuration value in a package s config or the global config if so |
27,877 | 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' ) ) ) ; } $ fileManager = $ this -> container -> get ( 'thrace_media.filemanager' ) ; $ 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 -> validateFile ( $ handle ) ; if ( $ validate !== true ) { return new JsonResponse ( array ( 'success' => false , 'err_msg' => $ validate ) ) ; } $ content = file_get_contents ( $ handle -> getRealPath ( ) ) ; $ fileManager -> saveToTemporaryDirectory ( $ name , $ content ) ; $ hash = $ fileManager -> checksumTemporaryFileByName ( $ name ) ; return new JsonResponse ( array ( 'success' => true , 'name' => $ name , 'hash' => $ hash , ) ) ; } | This actions is responsible for validation uploading of files |
27,878 | public function downloadAction ( ) { $ fileManager = $ this -> container -> get ( 'thrace_media.filemanager' ) ; $ filepath = $ this -> getRequest ( ) -> get ( 'filepath' ) ; $ filename = SlugFilter :: filter ( $ this -> getRequest ( ) -> get ( 'filename' ) ) ; $ content = $ fileManager -> getPermanentFileBlobByName ( $ filepath ) ; $ response = new Response ( $ content ) ; $ response -> headers -> set ( 'Content-Length' , mb_strlen ( $ content ) ) ; $ response -> headers -> set ( 'Content-Type' , $ this -> getMimeType ( $ content ) ) ; $ response -> headers -> set ( 'Content-Disposition' , 'attachment;filename=' . $ filename ) ; $ response -> expire ( ) ; return $ response ; } | This action is responsible for downloading resourses |
27,879 | public function renderTemporaryAction ( ) { $ name = $ this -> getRequest ( ) -> get ( 'name' ) ; $ fileManager = $ this -> container -> get ( 'thrace_media.filemanager' ) ; $ content = $ fileManager -> getTemporaryFileBlobByName ( $ name ) ; $ response = new Response ( $ content ) ; $ response -> headers -> set ( 'Accept-Ranges' , 'bytes' ) ; $ response -> headers -> set ( 'Content-Length' , mb_strlen ( $ content ) ) ; $ response -> headers -> set ( 'Content-Type' , $ this -> getMimeType ( $ content ) ) ; $ response -> expire ( ) ; return $ response ; } | Renders temporary file |
27,880 | public function renderAction ( ) { $ name = $ this -> getRequest ( ) -> get ( 'name' ) ; $ hash = $ this -> getRequest ( ) -> get ( 'hash' ) ; $ response = new Response ( ) ; $ response -> setPublic ( ) ; $ response -> setEtag ( $ hash ) ; if ( $ response -> isNotModified ( $ this -> getRequest ( ) ) ) { return $ response ; } $ fileManager = $ this -> container -> get ( 'thrace_media.filemanager' ) ; $ content = $ fileManager -> getPermanentFileBlobByName ( $ name ) ; $ 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 file |
27,881 | protected function validateFile ( UploadedFile $ handle ) { $ maxSize = 200000000 ; $ extensions = 'application/jar,application/apk,application/octet-stream,application/zip' ; $ fileConstraint = new File ( ) ; $ fileConstraint -> maxSize = $ maxSize ; $ fileConstraint -> mimeTypes = explode ( ',' , $ extensions ) ; $ errors = $ this -> container -> get ( 'validator' ) -> validateValue ( $ handle , $ fileConstraint ) ; if ( count ( $ errors ) == 0 ) { return true ; } else { return $ this -> container -> get ( 'translator' ) -> trans ( $ errors [ 0 ] -> getMessageTemplate ( ) , $ errors [ 0 ] -> getMessageParameters ( ) ) ; } } | Validates file and return true on success and array of error messages on failure |
27,882 | protected function getConfigs ( ) { $ session = $ this -> container -> get ( 'session' ) ; if ( ! $ configs = $ session -> get ( $ this -> getRequest ( ) -> get ( 'thrace_media_id' , false ) ) ) { $ configs = [ 'max_upload_size' => '200000000' , 'extensions' => 'application/*' ] ; } return $ configs ; } | Gets File configs |
27,883 | public function addErrorMessage ( string $ message ) : self { if ( $ this -> throw_errors == true ) { throw new \ RuntimeException ( $ message ) ; } $ this -> errors_messages [ ] = $ message ; return $ this ; } | Adiciona uma mensagem na pilha de erros . |
27,884 | public function packerTwoUnpack ( $ data , $ revert = false ) { $ partOne = mb_substr ( $ data , 0 , 5 , "utf-8" ) ; $ partTwo = mb_substr ( $ data , 7 , null , "utf-8" ) ; return base64_decode ( $ partOne . $ partTwo ) ; } | Remove Sg para validar o base64 |
27,885 | protected function insertRelatedRecords ( $ recordName , Model $ record , $ camelKey , $ columnValue ) { $ relation = $ record -> $ camelKey ( ) ; if ( $ relation instanceof BelongsTo ) { $ this -> insertBelongsTo ( $ record , $ relation , $ columnValue ) ; return ; } if ( $ relation instanceof BelongsToMany ) { $ this -> insertBelongsToMany ( $ recordName , $ relation , $ columnValue ) ; return ; } } | Insert related records for a fixture . |
27,886 | protected function insertBelongsToMany ( $ recordName , Relation $ relation , $ columnValue ) { $ joinTable = $ relation -> getTable ( ) ; $ this -> tables [ ] = $ joinTable ; $ relatedRecords = explode ( ',' , str_replace ( ', ' , ',' , $ columnValue ) ) ; foreach ( $ relatedRecords as $ relatedRecord ) { list ( $ fields , $ values ) = $ this -> buildBelongsToManyRecord ( $ recordName , $ relation , $ relatedRecord ) ; $ placeholders = rtrim ( str_repeat ( '?, ' , count ( $ values ) ) , ', ' ) ; $ sql = "INSERT INTO $joinTable ($fields) VALUES ($placeholders)" ; $ sth = $ this -> db -> prepare ( $ sql ) ; $ sth -> execute ( $ values ) ; } } | Insert a belongsToMany foreign key relationship . |
27,887 | public function preSetData ( FormEvent $ event ) { $ entity = $ event -> getData ( ) ; if ( $ entity instanceof FileInterface && null !== $ entity -> getId ( ) ) { try { $ this -> fileManager -> copyFileToTemporaryDirectory ( $ entity ) ; } catch ( \ Gaufrette \ Exception \ FileNotFound $ e ) { $ event -> setData ( null ) ; } } } | Copy media to temporary directory |
27,888 | public function submit ( FormEvent $ event ) { $ entity = $ event -> getData ( ) ; if ( $ entity instanceof FileInterface && null === $ entity -> getId ( ) && null === $ entity -> getHash ( ) ) { $ event -> setData ( null ) ; } } | Form event - removes file if scheduled . |
27,889 | public function onComplete ( CompleteEvent $ event ) { $ json = $ event -> getResponse ( ) -> json ( ) ; if ( array_get ( $ json , 'result' ) !== 'success' || array_key_exists ( 'response' , $ json ) === false ) { throw RequestException :: create ( $ event -> getRequest ( ) , $ event -> getResponse ( ) ) ; } } | Throw a RequestException if the response is not marked as successful . |
27,890 | public function delete ( ) { $ this -> brokenOnDelete = true ; $ this -> onBeforeDelete ( ) ; if ( $ this -> brokenOnDelete ) { user_error ( "$this->class has a broken onBeforeDelete() function." . " Make sure that you call parent::onBeforeDelete()." , E_USER_ERROR ) ; } $ path = $ this -> getFullPath ( ) ; if ( file_exists ( $ path ) ) { unlink ( $ path ) ; } if ( $ this -> storeRecord ) { $ this -> storeRecord -> delete ( ) ; } $ this -> flushCache ( ) ; $ this -> onAfterDelete ( ) ; } | Simulates a delete |
27,891 | protected function createSendgridDriver ( ) { $ config = $ this -> app [ 'config' ] -> get ( 'services.sendgrid' , array ( ) ) ; $ client = new HttpClient ( Arr :: get ( $ config , 'guzzle' , [ ] ) ) ; return new SendgridTransport ( $ client , $ config [ 'api_key' ] ) ; } | Create an instance of the SendGrid Swift Transport driver . |
27,892 | public static function createTransport ( ) : TransportInterface { if ( class_exists ( HttpClientDiscovery :: class ) && class_exists ( MessageFactoryDiscovery :: class ) ) { try { return new HttpClientTransport ( HttpClientDiscovery :: find ( ) , MessageFactoryDiscovery :: find ( ) ) ; } catch ( NotFoundException $ e ) { } } if ( class_exists ( Client :: class ) ) { return new Guzzle6Transport ( ) ; } if ( extension_loaded ( 'curl' ) ) { return new CurlExtensionTransport ( ) ; } throw new RuntimeException ( 'Cannot create an HTTP transport object' ) ; } | Creates the transport based on which classes are defined . |
27,893 | public function EmbedBase64Image ( $ path ) { $ mime = $ this -> getMimeType ( $ path ) ; if ( $ mime ) { $ content = file_get_contents ( $ path ) ; if ( $ content ) { return "data:{$mime};base64," . base64_encode ( $ content ) ; } } return null ; } | Make a data URL from an image file |
27,894 | public function getMimeType ( $ path ) { $ mimeTypes = [ 'png' => 'image/png' , 'jpe' => 'image/jpeg' , 'jpeg' => 'image/jpeg' , 'jpg' => 'image/jpeg' , 'gif' => 'image/gif' , 'bmp' => 'image/bmp' , 'ico' => 'image/vnd.microsoft.icon' , 'tiff' => 'image/tiff' , 'tif' => 'image/tiff' , 'svg' => 'image/svg+xml' , 'svgz' => 'image/svg+xml' , ] ; $ ext = pathinfo ( $ path , PATHINFO_EXTENSION ) ; if ( array_key_exists ( $ ext , $ mimeTypes ) ) { return $ mimeTypes [ $ ext ] ; } return null ; } | Guess mime type based on file extension |
27,895 | public static function names ( $ codes = null , $ sort = true ) { $ list = [ ] ; $ sortList = [ ] ; $ codes = $ codes ? : static :: codes ( ) ; foreach ( $ codes as $ code ) { $ intlTimeZone = \ IntlTimeZone :: createTimeZone ( $ code ) ; $ name = static :: intlName ( $ intlTimeZone ) ; if ( '(GMT) GMT' != $ name ) { $ list [ $ code ] = $ name ; $ sortList [ $ code ] = abs ( $ intlTimeZone -> getRawOffset ( ) ) ; } } if ( $ sort ) { array_multisort ( $ sortList , $ list ) ; } return $ list ; } | Returns list of timezone names |
27,896 | protected static function intlName ( \ IntlTimeZone $ intlTimeZone ) { $ short = $ intlTimeZone -> getDisplayName ( false , \ IntlTimeZone :: DISPLAY_SHORT ) ; $ long = $ intlTimeZone -> getDisplayName ( false , \ IntlTimeZone :: DISPLAY_GENERIC_LOCATION ) ; return '(' . $ short . ') ' . $ long ; } | Generate timezone name from Intl data . |
27,897 | public function removeRecipient ( string $ recipient ) : self { $ itemPosition = array_search ( $ recipient , $ this -> recipients ) ; if ( false !== $ itemPosition ) { unset ( $ this -> recipients [ $ itemPosition ] ) ; } unset ( $ this -> recipientVariables [ $ recipient ] ) ; return $ this ; } | Removes a single recipient . |
27,898 | public function setRecipientVariables ( string $ recipient , array $ recipientVariables ) : self { $ this -> recipientVariables [ $ recipient ] = $ recipientVariables ; return $ this ; } | Sets the recipient variables for the recipient specified . |
27,899 | public function addRecipientVariable ( string $ recipient , string $ recipientVariable , string $ recipientVariableValue ) : self { if ( ! isset ( $ this -> recipientVariables [ $ recipient ] ) ) { $ this -> recipientVariables [ $ recipient ] = [ ] ; } $ this -> recipientVariables [ $ recipient ] [ $ recipientVariable ] = $ recipientVariableValue ; return $ this ; } | Adds a single recipient variable for the specified recipient . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.