idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
56,300
|
public function getTranslator ( ) { if ( $ this -> translator === null ) { $ locale = $ this -> getLocaleService ( ) -> getLocale ( ) ; $ this -> translator = new KeekoTranslator ( $ this , $ locale ) ; $ this -> translator -> addLoader ( 'json' , new KeekoJsonTranslationLoader ( $ this ) ) ; $ this -> translator -> setFallbackLocales ( [ 'en' ] ) ; } return $ this -> translator ; }
|
Returns the keeko translation service
|
56,301
|
public function getMailer ( ) { if ( $ this -> mailer === null ) { $ prefs = $ this -> getPreferenceLoader ( ) -> getSystemPreferences ( ) ; switch ( $ prefs -> getMailTransport ( ) ) { case SystemPreferences :: MAIL_TRANSPORT_SMTP : $ transport = new Swift_SmtpTransport ( $ prefs -> getSmtpServer ( ) , $ prefs -> getSmtpPort ( ) ) ; $ transport -> setUsername ( $ prefs -> getSmtpUsername ( ) ) ; $ transport -> setPassword ( $ prefs -> getSmtpPassword ( ) ) ; $ encryption = $ prefs -> getSmtpEncryption ( ) ; if ( $ encryption != SystemPreferences :: SMTP_ENCRYPTION_NONE ) { $ transport -> setEncryption ( $ encryption ) ; } break ; case SystemPreferences :: MAIL_TRANSPORT_SENDMAIL : $ transport = new Swift_SendmailTransport ( $ prefs -> getSendmail ( ) ) ; break ; case SystemPreferences :: MAIL_TRANSPORT_MAIL : default : $ transport = new Swift_MailTransport ( ) ; break ; } $ this -> mailer = new Swift_Mailer ( $ transport ) ; } return $ this -> mailer ; }
|
Returns the mailer to send emails
|
56,302
|
public function createMessage ( ) { $ prefs = $ this -> getPreferenceLoader ( ) -> getSystemPreferences ( ) ; $ message = new Swift_Message ( ) ; $ sender = $ prefs -> getPlattformEmail ( ) ; if ( ! empty ( $ sender ) ) { $ message -> setFrom ( $ prefs -> getPlattformEmail ( ) , $ prefs -> getPlattformName ( ) ) ; } return $ message ; }
|
Creates a new message which can be send with a mailer
|
56,303
|
public function deleteUserImage ( UserInterface $ user ) { $ file = $ this -> getUserImage ( $ user ) ; if ( is_readable ( $ file ) ) { unlink ( $ file ) ; } }
|
Deletes if user image exists
|
56,304
|
public function load ( $ helperName ) { $ helperFilePathUser = ROOT . DS . 'app' . DS . 'helpers' . DS . $ helperName . '.php' ; $ helperFilePathPff = ROOT_LIB . DS . 'src' . DS . 'helpers' . DS . $ helperName . '.php' ; $ found = false ; if ( file_exists ( $ helperFilePathUser ) ) { include_once ( $ helperFilePathUser ) ; $ found = true ; } if ( file_exists ( $ helperFilePathPff ) ) { include_once ( $ helperFilePathPff ) ; $ found = true ; } if ( ! ( $ found ) ) { throw new HelperException ( "Helper not found: " . $ helperName ) ; } else { return true ; } }
|
Load an helper file
|
56,305
|
public function listen ( ) { $ context = stream_context_create ( [ 'socket' => $ this -> options ] ) ; if ( $ this -> getOption ( 'SO_REUSEPORT' ) ) { stream_context_set_option ( $ context , 'socket' , 'so_reuseport' , 1 ) ; } $ flag = $ this -> isUDP ( ) ? STREAM_SERVER_BIND : STREAM_SERVER_BIND | STREAM_SERVER_LISTEN ; if ( $ this -> is_ssl ) { foreach ( $ this -> ssl as $ name => $ value ) { if ( $ value === null ) continue ; stream_context_set_option ( $ context , 'ssl' , $ name , $ value ) ; } } $ errno = $ errmsg = null ; $ this -> socket = @ stream_socket_server ( $ this -> socket_name , $ errno , $ errmsg , $ flag , $ context ) ; if ( ! $ this -> socket || $ errno ) { $ this -> socket = null ; Yii :: error ( "$this->listen $errmsg" ) ; return false ; } if ( $ this -> is_ssl ) { stream_socket_enable_crypto ( $ this -> socket , false ) ; } if ( $ this -> isUnix ( ) ) { list ( , $ sockfile ) = explode ( '://' , $ this -> socket_name , 2 ) ; $ sockfile = realpath ( $ sockfile ) ; $ this -> socket_name = $ this -> transport . '://' . $ sockfile ; chmod ( $ sockfile , 0777 ) ; } if ( function_exists ( 'socket_import_stream' ) && $ this -> transport === 'tcp' ) { $ socket = socket_import_stream ( $ this -> socket ) ; foreach ( $ this -> options as $ name => $ value ) { if ( $ value === null || ! defined ( $ name ) ) continue ; socket_set_option ( $ socket , SOL_SOCKET , constant ( $ name ) , $ value ) ; } socket_set_option ( $ socket , SOL_TCP , TCP_NODELAY , 1 ) ; } stream_set_blocking ( $ this -> socket , 0 ) ; stream_socket_enable_crypto ( $ this -> socket , false ) ; Yii :: debug ( "$this->listen listened" , 'beyod' ) ; return $ this ; }
|
create listen socket .
|
56,306
|
public function acceptUdp ( $ socket ) { $ peer = null ; $ message = stream_socket_recvfrom ( $ socket , $ this -> max_udp_packet_size , 0 , $ peer ) ; if ( ! $ peer || $ message === false || $ message === '' ) { return false ; } $ local = stream_socket_get_name ( $ socket , false ) ; $ event = new UdpMessageEvent ( [ 'message' => $ message , 'socket' => $ socket ] ) ; if ( $ this -> parser ) { $ message = call_user_func ( [ $ this -> parser , 'decode' ] , $ message , null ) ; } $ event -> local = $ local ; $ event -> peer = $ peer ; $ this -> trigger ( Server :: ON_UDP_PACKET , $ event ) ; }
|
accept udp packet
|
56,307
|
public function acceptTcp ( $ main_socket ) { $ socket = @ stream_socket_accept ( $ main_socket , 0 , $ remote_address ) ; if ( ! $ socket ) { return ; } $ connection = new Connection ( $ socket , $ this ) ; if ( $ this -> handler ) { $ this -> handler -> attach ( $ connection ) ; } $ this -> handler -> owner = $ this ; $ this -> trigger ( Server :: ON_ACCEPT , new IOEvent ( [ 'context' => $ connection ] ) ) ; $ connection -> ready ( ) ; }
|
tcp connect established event
|
56,308
|
public function setConfig ( $ data , $ value ) { if ( is_string ( $ data ) ) { $ this -> _config [ $ data ] = $ value ; } else { throw new ConfigException ( "Error while setting a config value" ) ; } }
|
Sets a configuration if the configuration already exists it OVERWRITES the old one .
|
56,309
|
public function append ( ViolationInterface $ violation , $ severity = DestinationInterface :: SEVERITY_ERROR ) { $ exceptions = array ( ) ; $ severity = $ this -> mapSeverity ( $ severity ) ; if ( empty ( $ severity ) ) { return ; } $ this -> violations [ $ severity ] [ ] = $ violation ; foreach ( $ this -> destinations as $ destination ) { try { $ destination -> append ( $ violation , $ severity ) ; } catch ( \ Exception $ exception ) { $ exceptions [ ] = $ exception ; } } if ( $ exceptions ) { throw new AppendViolationException ( 'Could not append violation ' . get_class ( $ violation ) , $ exceptions ) ; } }
|
Add a violation to the report .
|
56,310
|
public function get ( $ severity ) { $ severity = $ this -> mapSeverity ( $ severity ) ; if ( ! isset ( $ this -> violations [ $ severity ] ) ) { return array ( ) ; } return $ this -> violations [ $ severity ] ; }
|
Get violations of a certain severity .
|
56,311
|
private function mapSeverity ( $ severity ) { if ( empty ( $ severity ) ) { throw new \ InvalidArgumentException ( 'Invalid severity string' ) ; } if ( array_key_exists ( $ severity , $ this -> severityMap ) ) { return $ this -> severityMap [ $ severity ] ; } return $ severity ; }
|
Map the severity from the original value to the configured value .
|
56,312
|
private function addDestinations ( array $ destinations ) { foreach ( $ destinations as $ destination ) { if ( ! $ destination instanceof DestinationInterface ) { throw new \ InvalidArgumentException ( get_class ( $ destination ) . ' is not a valid destination' ) ; } $ this -> destinations [ ] = $ destination ; } }
|
Add the passed destinations to the report .
|
56,313
|
public static function init ( $ path , $ environment = null ) { if ( ! static :: $ instance ) static :: $ instance = new Config ( $ path , $ environment ) ; else { static :: $ instance -> path = $ path ; static :: $ instance -> environment = $ environment ; static :: $ instance -> container = array ( ) ; } return static :: $ instance ; }
|
Initialize the Config instance for a specific target path
|
56,314
|
function getClient ( ) { $ transport = $ this -> getTransport ( ) ; $ transport -> setAuth ( $ this -> username , $ this -> password ) ; return new Client ( $ transport ) ; }
|
Creates a everyman client based on the configuration parameters .
|
56,315
|
private function getTransport ( ) { switch ( $ this -> transport ) { case 'stream' : return new Transport \ Stream ( $ this -> host , $ this -> port ) ; case 'curl' : default : return new Transport \ Curl ( $ this -> host , $ this -> port ) ; } }
|
Gets the transport method .
|
56,316
|
public function import ( array $ users = array ( ) , $ realm = 'Restricted area' ) { Argument :: i ( ) -> test ( 2 , 'string' ) ; $ this -> realm = $ realm ; $ self = $ this ; return function ( Registry $ request , Registry $ response ) use ( $ users , $ self ) { $ digest = $ request -> get ( 'server' , 'PHP_AUTH_DIGEST' ) ; if ( empty ( $ digest ) ) { return $ self -> dialog ( ) ; } $ data = $ self -> digest ( $ digest ) ; if ( ! isset ( $ users [ $ data [ 'username' ] ] ) ) { return $ self -> dialog ( ) ; } $ signature = $ self -> getSignature ( $ users , $ data ) ; if ( $ data [ 'response' ] !== $ signature ) { return $ self -> dialog ( ) ; } } ; }
|
Main plugin method
|
56,317
|
public function dialog ( ) { if ( ! session_id ( ) ) { session_start ( ) ; } if ( ! isset ( $ _SESSION [ self :: UNAUTHORIZED ] ) ) { $ _SESSION [ self :: UNAUTHORIZED ] = 1 ; } else { $ _SESSION [ self :: UNAUTHORIZED ] ++ ; } if ( $ _SESSION [ self :: UNAUTHORIZED ] < 3 ) { header ( sprintf ( self :: HTTP_AUTH , $ this -> realm , uniqid ( ) , md5 ( $ this -> realm ) ) ) ; exit ; } unset ( $ _SESSION [ self :: UNAUTHORIZED ] ) ; header ( self :: UNAUTHORIZED ) ; Exception :: i ( ) -> setMessage ( self :: UNAUTHORIZED ) -> setType ( self :: ERROR_TYPE ) -> trigger ( ) ; }
|
Opens the browsers auth dialig
|
56,318
|
public function getSignature ( $ users , $ data ) { $ userArray = array ( $ data [ 'username' ] , $ this -> realm , $ users [ $ data [ 'username' ] ] ) ; $ userSignature = md5 ( implode ( ':' , $ userArray ) ) ; $ requestArray = array ( $ _SERVER [ 'REQUEST_METHOD' ] , $ data [ 'uri' ] ) ; $ requestSignature = md5 ( implode ( ':' , $ requestArray ) ) ; $ responseArray = array ( $ userSignature , $ data [ 'nonce' ] , $ data [ 'nc' ] , $ data [ 'cnonce' ] , $ data [ 'qop' ] , $ requestSignature ) ; return md5 ( implode ( ':' , $ responseArray ) ) ; }
|
Returns the response siggy
|
56,319
|
public function digest ( $ string ) { $ needed = array ( 'nonce' => 1 , 'nc' => 1 , 'cnonce' => 1 , 'qop' => 1 , 'username' => 1 , 'uri' => 1 , 'response' => 1 ) ; $ data = array ( ) ; $ keys = implode ( '|' , array_keys ( $ needed ) ) ; preg_match_all ( '@(' . $ keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@' , $ string , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ) { $ data [ $ match [ 1 ] ] = $ match [ 3 ] ? $ match [ 3 ] : $ match [ 4 ] ; unset ( $ needed [ $ match [ 1 ] ] ) ; } return $ needed ? false : $ data ; }
|
Extracts data from the siggy
|
56,320
|
public function match ( $ options , ThemeMatchingContext $ context ) { if ( is_string ( $ options ) ) { $ options = array ( 'name' => $ options ) ; } $ options = $ this -> optionsResolver -> resolve ( $ options ) ; if ( empty ( $ options ) ) { throw new \ InvalidArgumentException ( 'You must at least define one theme loading option.' ) ; } foreach ( $ options as $ key => $ option ) { try { if ( $ local = $ this -> resolutionStrategies [ $ key ] ( $ option , $ context ) ) { $ themeName = $ local ; } } catch ( InvalidThemeException $ e ) { continue ; } } if ( empty ( $ themeName ) ) { throw new InvalidThemeException ( sprintf ( 'Unavailable to determine requested theme name throught ["%s"] strategies and given context. Check your configuration.' , implode ( '", "' , array_keys ( $ options ) ) ) ) ; } try { return $ this -> synapseEngine -> enableTheme ( $ themeName ) -> getCurrentTheme ( ) ; } catch ( InvalidThemeException $ e ) { throw new InvalidThemeException ( sprintf ( 'Unavailable to activate a theme with "%s" name, guessed from given context, using ["%s"] strategies.' , $ themeName , implode ( '", "' , array_keys ( $ options ) ) ) , 0 , $ e ) ; } }
|
Try to find a template name from given options and context .
|
56,321
|
public function dispatch ( $ object ) { $ handler = $ this -> commandTranslator -> translate ( $ object ) ; return $ this -> app -> make ( $ handler ) -> handle ( $ object ) ; }
|
To dispatch command
|
56,322
|
protected function taskClearOpCache ( $ environment = ClearOpCache :: ENV_FCGI , $ host = null ) { return $ this -> task ( ClearOpCache :: class , $ environment , $ host ) ; }
|
Creates a new ClearOpCache task .
|
56,323
|
public function parseToken ( $ content , $ position , $ state , TokenList $ tokenList ) { if ( ! empty ( $ content ) ) { $ tokenList -> addToken ( $ this -> name , $ position ) -> set ( 'content' , $ content ) ; } }
|
Accept all matches
|
56,324
|
public function runMigrations ( int $ start , int $ end , array $ skip = [ ] ) { RunMigrationsUseCase :: execute ( $ start , $ end , $ skip ) ; }
|
Allows additional logic to be added before or after migration execution without altering the use case .
|
56,325
|
public function getByApplicationForEnvironment ( Application $ application , Environment $ environment , $ limit = 25 , $ page = 0 , $ filter = '' ) { $ template = ( $ filter ) ? self :: DQL_BY_APPLICATION_AND_ENV_WITH_REF_FILTER : self :: DQL_BY_APPLICATION_AND_ENV ; $ dql = sprintf ( $ template , Build :: class ) ; $ params = [ 'application' => $ application , 'environment' => $ environment , ] ; if ( $ filter ) { $ params [ 'ref' ] = $ filter ; } return $ this -> getPaginator ( $ dql , $ limit , $ page , $ params ) ; }
|
Get all builds for an application and environment paged .
|
56,326
|
private function processRequest ( ) { $ this -> request [ 'resource' ] = ( isset ( $ _GET [ 'RESTurl' ] ) && ! empty ( $ _GET [ 'RESTurl' ] ) ) ? $ _GET [ 'RESTurl' ] : 'index' ; unset ( $ _GET [ 'RESTurl' ] ) ; $ this -> request [ 'method' ] = Inflector :: lower ( $ _SERVER [ 'REQUEST_METHOD' ] ) ; $ this -> request [ 'headers' ] = $ this -> getHeaders ( ) ; $ this -> request [ 'format' ] = isset ( $ _GET [ 'format' ] ) ? trim ( $ _GET [ 'format' ] ) : null ; switch ( $ this -> request [ 'method' ] ) { case 'get' : $ this -> request [ 'params' ] = $ _GET ; break ; case 'post' : $ this -> request [ 'params' ] = array_merge ( $ _POST , $ _GET ) ; break ; case 'put' : parse_str ( fgc ( 'php://input' ) , $ this -> request [ 'params' ] ) ; break ; case 'delete' : $ this -> request [ 'params' ] = $ _GET ; break ; default : break ; } $ this -> request [ 'content-type' ] = $ this -> getResponseFormat ( $ this -> request [ 'format' ] ) ; if ( ! function_exists ( 'trim_value' ) ) { function trim_value ( & $ value ) { $ value = trim ( $ value ) ; } } array_walk_recursive ( $ this -> request , 'trim_value' ) ; }
|
Function processing raw HTTP request headers & body and populates them to class variables .
|
56,327
|
private function getController ( ) { $ expected = $ this -> request [ 'resource' ] ; foreach ( glob ( APPLICATION_PATH . '/Controllers/*.php' , GLOB_NOSORT ) as $ controller ) { $ controller = basename ( $ controller , '.php' ) ; if ( strnatcasecmp ( $ expected , $ controller ) == 0 ) { return 'Controllers_' . $ controller ; } } return null ; }
|
Function to resolve constroller from the Controllers directory based on resource name request .
|
56,328
|
private function getHeaders ( ) { if ( function_exists ( 'apache_request_headers' ) ) { return apache_request_headers ( ) ; } $ headers = array ( ) ; $ keys = preg_grep ( '{^HTTP_}i' , array_keys ( $ _SERVER ) ) ; foreach ( $ keys as $ val ) { $ key = repl ( ' ' , '-' , ucwords ( Inflector :: lower ( repl ( '_' , ' ' , substr ( $ val , 5 ) ) ) ) ) ; $ headers [ $ key ] = $ _SERVER [ $ val ] ; } return $ headers ; }
|
Function to get HTTP headers
|
56,329
|
public function getLast ( $ clear = false ) { if ( count ( $ this -> errors ) < 1 ) { return false ; } if ( $ clear ) { $ error = array_shift ( $ this -> errors ) ; return $ error ; } return $ this -> errors [ 0 ] ; }
|
Get the last error to occur and return it .
|
56,330
|
public function getAll ( $ clear = false ) { if ( $ clear ) { $ errors = $ this -> errors ; $ this -> clearAll ( ) ; return $ errors ; } return $ this -> errors ; }
|
Get all of the errors that have occured .
|
56,331
|
private function configImgSize ( ) { $ settings = Yii :: $ app -> settings ; $ settings -> set ( 'media_configuration' , 'thumbnail_size_width' , $ this -> thumbnail_size_width ) ; $ settings -> set ( 'media_configuration' , 'thumbnail_size_height' , $ this -> thumbnail_size_height ) ; $ settings -> set ( 'media_configuration' , 'medium_size_width' , $ this -> medium_size_width ) ; $ settings -> set ( 'media_configuration' , 'medium_size_height' , $ this -> medium_size_height ) ; $ settings -> set ( 'media_configuration' , 'large_size_width' , $ this -> large_size_width ) ; $ settings -> set ( 'media_configuration' , 'large_size_height' , $ this -> large_size_height ) ; }
|
Config Img size
|
56,332
|
public function getToString ( ) { $ get = $ this -> allGet ( ) ; $ formatted = array ( ) ; foreach ( $ get as $ name => $ val ) { $ formatted [ ] = "$name=$val" ; } return implode ( '&' , $ formatted ) ; }
|
Returns a string with all GET parameters as they appear in the URL .
|
56,333
|
function getFile ( $ slot_name , $ target , $ exts = NULL , $ generate_names = false ) { if ( ! $ target ) { throw new \ Exception ( "Can't move file without destination." ) ; } if ( ! array_key_exists ( $ slot_name , $ _FILES ) ) { return false ; } $ return = false ; if ( is_array ( $ _FILES [ $ slot_name ] [ 'name' ] ) ) { if ( ! is_dir ( $ target ) ) { throw new Exception ( "Target `$target' must be a directory for several files." ) ; } $ return = array ( ) ; for ( $ file_num = 0 ; $ file_num < count ( $ _FILES [ $ slot_name ] [ 'name' ] ) ; $ file_num ++ ) { $ file = array ( 'name' => $ _FILES [ $ slot_name ] [ 'name' ] [ $ file_num ] , 'type' => $ _FILES [ $ slot_name ] [ 'type' ] [ $ file_num ] , 'tmp_name' => $ _FILES [ $ slot_name ] [ 'tmp_name' ] [ $ file_num ] , 'error' => $ _FILES [ $ slot_name ] [ 'error' ] [ $ file_num ] , 'size' => $ _FILES [ $ slot_name ] [ 'size' ] [ $ file_num ] ) ; $ looptarget = '' ; if ( $ generate_names ) { $ ext = substr ( strrchr ( $ file [ 'name' ] , '.' ) , 0 ) ; $ looptarget = Utils :: uniqueFilename ( $ target , '' , $ ext ) ; } else { $ looptarget = Utils :: joinPaths ( $ target , basename ( $ file [ 'name' ] ) ) ; } try { $ return [ ] = $ this -> _getAndMoveFile ( $ file , $ looptarget , $ exts ) ; } catch ( FileUploadError $ e ) { $ return [ ] = $ e ; } } } else { if ( is_dir ( $ target ) ) { if ( $ generate_names ) { $ ext = substr ( strrchr ( $ _FILES [ $ slot_name ] [ 'name' ] , '.' ) , 0 ) ; $ target = Utils :: uniqueFilename ( $ target , '' , $ ext ) ; } else { $ target = Utils :: joinPaths ( $ target , basename ( $ _FILES [ $ slot_name ] [ 'name' ] ) ) ; } } try { $ return = $ this -> _getAndMoveFile ( $ _FILES [ $ slot_name ] , $ target , $ exts ) ; } catch ( FileUploadError $ e ) { return $ e ; } } return $ return ; }
|
Gets an uploaded file .
|
56,334
|
public function convertToPHPValue ( $ value , AbstractPlatform $ platform ) { if ( ! $ value || ! is_string ( $ value ) ) { return null ; } $ timepoint = self :: getParsingClock ( ) -> fromString ( $ value , 'Y-m-d H:i:s' ) ; if ( ! $ timepoint ) { throw ConversionException :: conversionFailedFormat ( $ value , $ this -> getName ( ) , $ platform -> getDateTimeFormatString ( ) ) ; } return $ timepoint ; }
|
Convert database value to TimePoint
|
56,335
|
public static function getSetting ( $ key , $ secondLevel = null , $ defaultValue = null ) { $ settings = self :: $ settings ; if ( is_object ( $ settings ) ) { $ settings = ( array ) $ settings ; } if ( ! array_key_exists ( $ key , $ settings ) ) { return $ defaultValue ; } if ( $ secondLevel !== null ) { if ( is_object ( $ settings [ $ key ] ) ) { $ settings [ $ key ] = ( array ) $ settings [ $ key ] ; } if ( ! array_key_exists ( $ secondLevel , $ settings [ $ key ] ) ) { return $ defaultValue ; } return $ settings [ $ key ] [ $ secondLevel ] ; } return $ settings [ $ key ] ; }
|
Get a setting value
|
56,336
|
public static function setViewer ( $ viewerClass ) { if ( ! is_subclass_of ( $ viewerClass , \ Phramework \ Viewers \ IViewer :: class , true ) ) { throw new \ Exception ( 'Class is not implementing Phramework\Viewers\IViewer' ) ; } self :: $ viewer = $ viewerClass ; }
|
Set viewer class
|
56,337
|
private static function errorView ( $ errors , $ code = 400 , $ params = null , $ method = null , $ headers = null , $ exception = null ) { if ( ! headers_sent ( ) ) { http_response_code ( $ code ) ; } self :: view ( ( object ) [ 'errors' => $ errors ] ) ; self :: $ stepCallback -> call ( StepCallback :: STEP_ERROR , $ params , $ method , $ headers , [ $ errors , $ code , $ exception ] ) ; }
|
Output an error
|
56,338
|
public static function view ( $ parameters = [ ] ) { $ args = func_get_args ( ) ; if ( self :: getMethod ( ) === self :: METHOD_HEAD ) { return ; } $ viewer = new self :: $ viewer ( ) ; $ args [ 0 ] = $ parameters ; return call_user_func_array ( [ $ viewer , 'view' ] , $ args ) ; }
|
Output the response using the selected viewer
|
56,339
|
public function getResponse ( Location $ location , $ data ) { if ( null === $ this -> responseProvider ) { throw new BadConfigurationException ( "No Response Provider set in default FormFacade" ) ; } return $ this -> responseProvider -> getResponse ( $ location , $ data ) ; }
|
Creates HTTP Response to be returned by controller
|
56,340
|
public function handle ( Eloquent $ model , array $ data , Guard $ auth ) { if ( $ auth -> check ( ) ) { return ; } if ( ! is_null ( $ id = $ this -> getAuthenticatedUser ( $ model ) ) ) { $ auth -> loginUsingId ( $ id , true ) ; } }
|
Handle user connected via social auth .
|
56,341
|
function bindWith ( iContextStream $ context ) { $ wrapperName = strtolower ( $ context -> getWrapperName ( ) ) ; $ this -> bindContexts [ $ wrapperName ] = $ context ; return $ this ; }
|
Bind Another Context Along this
|
56,342
|
function hasBind ( $ wrapperName ) { $ normalized = strtolower ( $ wrapperName ) ; return ( array_key_exists ( $ normalized , $ this -> bindContexts ) ) ? $ this -> bindContexts [ $ normalized ] : false ; }
|
Context with specific wrapper has bind?
|
56,343
|
function toContext ( ) { $ options = new Std \ Type \ StdTravers ( $ this ) ; $ options = $ options -> toArray ( function ( $ val ) { return ( $ val === null ) ; } ) ; $ params = ( isset ( $ options [ 'params' ] ) ) ? $ options [ 'params' ] : array ( ) ; unset ( $ options [ 'params' ] ) ; if ( isset ( $ options [ 'options' ] ) ) unset ( $ options [ 'options' ] ) ; $ options = array ( $ this -> getWrapperName ( ) => $ options , ) ; $ bindOptions = $ this -> _getBindContextOptions ( ) ; $ options = array_merge ( $ bindOptions , $ options ) ; $ context = stream_context_create ( $ options , $ params ) ; return $ context ; }
|
Creates and returns a stream context with any options supplied in options preset
|
56,344
|
public function stepInstall ( $ step ) { $ this -> data_step = $ step ; $ this -> data_install = $ this -> session -> get ( 'install' ) ; $ this -> data_handler = $ this -> install -> getHandler ( 'base' ) ; $ this -> controlAccessStepInstall ( ) ; $ this -> submitStepInstall ( ) ; $ this -> setData ( 'status' , $ this -> data_status ) ; $ this -> setData ( 'handler' , $ this -> data_handler ) ; $ this -> setData ( 'install' , $ this -> data_install ) ; $ this -> setData ( 'demo_handlers' , $ this -> install_model -> getDemoHandlers ( ) ) ; $ this -> setJsStepInstall ( ) ; $ this -> setCssStepInstall ( ) ; $ this -> setTitleStepInstall ( ) ; $ this -> outputStepInstall ( ) ; }
|
Displays step pages
|
56,345
|
protected function controlAccessStepInstall ( ) { if ( ! $ this -> config -> isInitialized ( ) ) { $ this -> redirect ( 'install' ) ; } if ( $ this -> data_step > count ( $ this -> data_handler [ 'steps' ] ) ) { $ this -> redirect ( 'install' ) ; } if ( isset ( $ this -> data_install [ 'data' ] [ 'step' ] ) && ( $ this -> data_step - $ this -> data_install [ 'data' ] [ 'step' ] ) != 1 ) { $ this -> data_status = false ; } }
|
Sets and validates the installation step
|
56,346
|
public function onSuiteDefine ( Suite $ suite ) { $ definition = new ReflectionFunction ( $ suite -> getDefinition ( ) ) ; $ parameters = $ definition -> getParameters ( ) ; if ( $ parameters ) { $ suite -> setDefinitionArguments ( $ this -> parameterArguments ( $ parameters ) ) ; } }
|
Handle the definition of a suite .
|
56,347
|
public function onSuiteStart ( Suite $ suite ) { foreach ( $ suite -> getTests ( ) as $ test ) { $ definition = new ReflectionFunction ( $ test -> getDefinition ( ) ) ; $ parameters = $ definition -> getParameters ( ) ; if ( $ parameters ) { $ test -> setDefinitionArguments ( $ this -> parameterArguments ( $ parameters ) ) ; } } }
|
Handle the start of a suite .
|
56,348
|
public function add ( array $ entry ) { if ( ! isset ( $ entry [ 'msgid' ] ) ) { throw new Exception ( "Invalid entry: missing msgid" ) ; } $ id = $ entry [ 'msgid' ] ; $ plural_id = isset ( $ entry [ 'msgid_plural' ] ) ? $ entry [ 'msgid_plural' ] : null ; $ context = isset ( $ entry [ 'msgctxt' ] ) ? $ entry [ 'msgctxt' ] : null ; $ flags = isset ( $ entry [ 'flags' ] ) ? $ entry [ 'flags' ] : array ( ) ; $ strings = array ( ) ; foreach ( $ entry as $ key => $ value ) { if ( substr ( $ key , 0 , 6 ) === 'msgstr' ) { if ( is_array ( $ value ) ) { $ strings = array_merge ( $ strings , $ value ) ; } else { $ strings [ ] = $ value ; } } } if ( count ( $ strings ) === 0 ) { throw new Exception ( "Invalid entry: missing msgstr" ) ; } $ this -> set [ ] = array ( 'id' => $ id , 'plural' => $ plural_id , 'context' => $ context , 'flags' => $ flags , 'strings' => $ strings ) ; }
|
Add an entry to the catalog .
|
56,349
|
public function sort ( ) { usort ( $ this -> set , function ( $ first , $ second ) { $ ids = strcmp ( $ first [ 'id' ] , $ second [ 'id' ] ) ; if ( $ ids === 0 ) { if ( $ first [ 'context' ] === null && $ second [ 'context' ] === null ) { return 0 ; } else if ( $ first [ 'context' ] === null ) { return - 1 ; } else if ( $ second [ 'context' ] === null ) { return 1 ; } else { return strcmp ( $ first [ 'context' ] , $ second [ 'context' ] ) ; } } else { return $ ids ; } } ) ; }
|
Sort the entries in lexical order .
|
56,350
|
protected function renderNumberWidget ( $ content , array $ options = [ ] ) { $ options = array_merge ( [ 'precision' => 2 , 'append' => '' , ] , $ options ) ; return $ this -> renderBlock ( 'show_widget_simple' , [ 'content' => trim ( sprintf ( '%s %s' , number_format ( $ content , $ options [ 'precision' ] , ',' , ' ' ) , $ options [ 'append' ] ) ) ] ) ; }
|
Renders the number widget .
|
56,351
|
protected function renderTextareaWidget ( $ content , array $ options = [ ] ) { $ options = array_replace ( [ 'html' => false , ] , $ options ) ; return $ this -> renderBlock ( 'show_widget_textarea' , [ 'content' => $ content , 'options' => $ options , ] ) ; }
|
Renders the textarea widget .
|
56,352
|
protected function renderEntityWidget ( $ entities , array $ options = [ ] ) { if ( ! array_key_exists ( 'field' , $ options ) ) { $ options [ 'field' ] = null ; } if ( ! array_key_exists ( 'route' , $ options ) ) { $ options [ 'route' ] = null ; } if ( ! array_key_exists ( 'route_params' , $ options ) ) { $ options [ 'route_params' ] = [ ] ; } if ( ! array_key_exists ( 'route_params_map' , $ options ) ) { $ options [ 'route_params_map' ] = [ 'id' => 'id' ] ; } if ( null !== $ entities && ! ( $ entities instanceof Collection ) ) { $ entities = new ArrayCollection ( [ $ entities ] ) ; } $ vars = [ 'route' => $ options [ 'route' ] , 'field' => $ options [ 'field' ] , 'route_params' => $ options [ 'route_params' ] , 'route_params_map' => $ options [ 'route_params_map' ] , 'entities' => $ entities ] ; return $ this -> renderBlock ( 'show_widget_entity' , $ vars ) ; }
|
Renders the entity widget .
|
56,353
|
protected function renderUrlWidget ( $ content , array $ options = [ ] ) { $ vars = [ 'target' => isset ( $ options [ 'target' ] ) ? $ options [ 'target' ] : '_blank' , 'content' => $ content ] ; return $ this -> renderBlock ( 'show_widget_url' , $ vars ) ; }
|
Renders the url widget .
|
56,354
|
protected function renderDatetimeWidget ( $ content , array $ options = [ ] ) { if ( ! array_key_exists ( 'time' , $ options ) ) { $ options [ 'time' ] = true ; } if ( ! array_key_exists ( 'date_format' , $ options ) ) { $ options [ 'date_format' ] = 'short' ; } if ( ! array_key_exists ( 'time_format' , $ options ) ) { $ options [ 'time_format' ] = $ options [ 'time' ] ? 'short' : 'none' ; } if ( ! array_key_exists ( 'locale' , $ options ) ) { $ options [ 'locale' ] = null ; } if ( ! array_key_exists ( 'timezone' , $ options ) ) { $ options [ 'timezone' ] = null ; } if ( ! array_key_exists ( 'format' , $ options ) ) { $ options [ 'format' ] = '' ; } $ vars = [ 'content' => $ content , 'options' => $ options , ] ; return $ this -> renderBlock ( 'show_widget_datetime' , $ vars ) ; }
|
Renders the datetime widget .
|
56,355
|
protected function renderTinymceWidget ( $ content , array $ options = [ ] ) { $ height = isset ( $ options [ 'height' ] ) ? intval ( $ options [ 'height' ] ) : 0 ; if ( 0 >= $ height ) { $ height = 250 ; } return $ this -> renderBlock ( 'show_widget_tinymce' , [ 'height' => $ height , 'route' => $ content ] ) ; }
|
Renders a tinymce widget .
|
56,356
|
protected function renderMediasWidget ( Collection $ medias , array $ options = [ ] ) { $ medias = array_map ( function ( $ m ) { return $ m -> getMedia ( ) ; } , $ medias -> toArray ( ) ) ; return $ this -> renderBlock ( 'show_widget_medias' , [ 'medias' => $ medias ] ) ; }
|
Renders the medias widget .
|
56,357
|
protected function renderCoordinateWidget ( Coordinate $ coordinate = null , array $ options = [ ] ) { $ map = new Map ( ) ; $ map -> setAutoZoom ( true ) ; $ map -> setMapOptions ( [ 'minZoom' => 3 , 'maxZoom' => 18 , 'disableDefaultUI' => true , ] ) ; $ map -> setStylesheetOptions ( [ 'width' => '100%' , 'height' => '320px' , ] ) ; if ( null !== $ coordinate && null !== $ coordinate -> getLatitude ( ) && null !== $ coordinate -> getLongitude ( ) ) { $ marker = new Marker ( ) ; $ marker -> setPosition ( $ coordinate ) ; $ map -> addMarker ( $ marker ) ; } return $ this -> renderBlock ( 'show_widget_coordinate' , [ 'map' => $ map ] ) ; }
|
Renders the coordinate widget .
|
56,358
|
public function register ( $ postType , $ className ) { if ( ! is_subclass_of ( $ className , 'Tev\Post\Model\AbstractPost' ) ) { throw new Exception ( "Given class '$className' is not instance of 'Tev\Post\Model\AbstractPost'" ) ; } $ this -> registeredMappings [ $ postType ] = $ className ; return $ this ; }
|
Register a new post type to class name mapping .
|
56,359
|
public function registered ( $ postType ) { if ( isset ( $ this -> registeredMappings [ $ postType ] ) ) { return $ this -> registeredMappings [ $ postType ] ; } return null ; }
|
Get the registered class name for the given post type .
|
56,360
|
public function create ( $ base = null , $ className = null ) { if ( $ base === null ) { if ( have_posts ( ) ) { the_post ( ) ; $ base = get_post ( ) ; } else { throw new Exception ( 'Please supply a post object when not within The Loop' ) ; } } $ cls = 'Tev\Post\Model\Post' ; if ( ( $ className !== null ) && is_subclass_of ( $ className , 'Tev\Post\Model\AbstractPost' ) ) { $ cls = $ className ; } elseif ( $ className = $ this -> registered ( $ base -> post_type ) ) { $ cls = $ className ; } return new $ cls ( $ base , $ this -> authorFactory , $ this -> taxonomyFactory , $ this -> fieldFactory , $ this ) ; }
|
Instantiate a post entity from a given post object .
|
56,361
|
public function current ( $ className = null ) { if ( $ p = get_post ( ) ) { return $ this -> create ( $ p , $ className ) ; } else { throw new Exception ( 'This method can only be called within The Loop' ) ; } }
|
Instantiate a post entity from the current post object .
|
56,362
|
public function slugify ( $ string , $ removeWesternEuropeanAccents = true , $ separator = '-' ) { $ slug = trim ( $ string ) ; if ( $ removeWesternEuropeanAccents ) { $ slug = htmlentities ( $ slug , ENT_NOQUOTES , 'UTF-8' ) ; $ slug = preg_replace ( '/&#?([a-zA-Z])[a-zA-Z0-9]*;/i' , '${1}' , $ slug ) ; } $ slug = iconv ( 'UTF-8' , 'ASCII//TRANSLIT' , $ slug ) ; $ slug = preg_replace ( "/[^a-zA-Z0-9\/_|+ -]/" , '' , $ slug ) ; $ slug = mb_strtolower ( trim ( $ slug , $ separator ) , 'UTF-8' ) ; $ slug = preg_replace ( "/[\/_|+ -]+/" , $ separator , $ slug ) ; return $ slug ; }
|
Generates slug from string
|
56,363
|
public static function generateKeys ( $ seed = null , $ hashKey = '' ) { if ( $ seed !== null ) { $ encrHash = Hash :: hash ( $ seed , $ hashKey , Constants :: BOX_SEEDBYTES ) ; $ signHash = Hash :: hash ( $ seed , $ hashKey , Constants :: SIGN_SEEDBYTES ) ; $ seeds = [ 'encr' => \ Sodium \ crypto_box_keypair ( $ encrHash ) , 'sign' => \ Sodium \ crypto_sign_keypair ( $ signHash ) , ] ; } else { $ seeds = [ 'encr' => \ Sodium \ crypto_box_keypair ( ) , 'sign' => \ Sodium \ crypto_sign_keypair ( ) , ] ; } return [ 'encr' => [ 'pri' => Helpers :: bin2hex ( \ Sodium \ crypto_box_secretkey ( $ seeds [ 'encr' ] ) ) , 'pub' => Helpers :: bin2hex ( \ Sodium \ crypto_box_publickey ( $ seeds [ 'encr' ] ) ) , ] , 'sign' => [ 'pri' => Helpers :: bin2hex ( \ Sodium \ crypto_sign_secretkey ( $ seeds [ 'sign' ] ) ) , 'pub' => Helpers :: bin2hex ( \ Sodium \ crypto_sign_publickey ( $ seeds [ 'sign' ] ) ) , ] , ] ; }
|
Returns a new set of keys for message encryption and signing .
|
56,364
|
public static function encrypt ( $ message , $ sender_private , $ receiver_public ) { Helpers :: isString ( $ message , 'PublicKeyEncryption' , 'encrypt' ) ; Helpers :: isString ( $ sender_private , 'PublicKeyEncryption' , 'encrypt' ) ; Helpers :: isString ( $ receiver_public , 'PublicKeyEncryption' , 'encrypt' ) ; $ messageKeyPair = \ Sodium \ crypto_box_keypair_from_secretkey_and_publickey ( Helpers :: hex2bin ( $ sender_private ) , Helpers :: hex2bin ( $ receiver_public ) ) ; $ nonce = Entropy :: generateNonce ( ) ; return base64_encode ( json_encode ( [ 'msg' => Helpers :: bin2hex ( \ Sodium \ crypto_box ( $ message , $ nonce , $ messageKeyPair ) ) , 'nonce' => Helpers :: bin2hex ( $ nonce ) , ] ) ) ; }
|
Encrypt a message using public key encryption .
|
56,365
|
public static function decrypt ( $ message , $ sender_public , $ receiver_private ) { Helpers :: isString ( $ message , 'PublicKeyEncryption' , 'decrypt' ) ; Helpers :: isString ( $ sender_public , 'PublicKeyEncryption' , 'decrypt' ) ; Helpers :: isString ( $ receiver_private , 'PublicKeyEncryption' , 'decrypt' ) ; $ messageKeyPair = \ Sodium \ crypto_box_keypair_from_secretkey_and_publickey ( Helpers :: hex2bin ( $ receiver_private ) , Helpers :: hex2bin ( $ sender_public ) ) ; $ message = base64_decode ( json_decode ( $ message , true ) ) ; $ plaintext = \ Sodium \ crypto_box_open ( Helpers :: hex2bin ( $ message [ 'msg' ] ) , Helpers :: hex2bin ( $ message [ 'nonce' ] ) , $ messageKeyPair ) ; if ( $ plaintext === false ) { throw new DecryptionException ( 'Failed to decrypt message using key' ) ; } return $ plaintext ; }
|
Decrypt a public key encrypted message .
|
56,366
|
private function loadConfig ( $ parsedConfig ) { if ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Type' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Type' ] == "smtp" ) { $ this -> transport = \ Swift_SmtpTransport :: newInstance ( ) ; if ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Host' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Host' ] != "" ) { $ this -> transport -> setHost ( $ parsedConfig [ 'moduleConf' ] [ 'Host' ] ) ; } if ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Port' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Port' ] != "" ) { $ this -> transport -> setPort ( $ parsedConfig [ 'moduleConf' ] [ 'Port' ] ) ; } if ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Username' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Username' ] != "" ) { $ this -> transport -> setUsername ( $ parsedConfig [ 'moduleConf' ] [ 'Username' ] ) ; } if ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Password' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Password' ] != "" ) { $ this -> transport -> setPassword ( $ parsedConfig [ 'moduleConf' ] [ 'Password' ] ) ; } if ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Encryption' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Encryption' ] != "" ) { $ this -> transport -> setEncryption ( $ parsedConfig [ 'moduleConf' ] [ 'Encryption' ] ) ; } } elseif ( isset ( $ parsedConfig [ 'moduleConf' ] [ 'Type' ] ) && $ parsedConfig [ 'moduleConf' ] [ 'Type' ] == "sendmail" ) { $ this -> transport = \ Swift_SendmailTransport :: newInstance ( '/usr/sbin/sendmail -bs' ) ; } else { $ this -> transport = \ Swift_MailTransport :: newInstance ( ) ; } }
|
Parse the configuration file
|
56,367
|
public function isValidFtpSettings ( ) { $ cfg = Mage :: helper ( 'radial_core' ) -> getConfigModel ( ) ; return trim ( $ cfg -> sftpUsername ) && trim ( $ cfg -> sftpLocation ) && ( ( $ cfg -> sftpAuthType === 'password' && trim ( $ cfg -> sftpPassword ) ) || ( $ cfg -> sftpAuthType === 'pub_key' && trim ( $ cfg -> sftpPrivateKey ) ) ) ; }
|
Validate sftp settings by simply checking if there s actual setting data .
|
56,368
|
public function extractNodeAttributeVal ( DOMNodeList $ nodeList , $ attributeName ) { return ( $ nodeList -> length ) ? $ nodeList -> item ( 0 ) -> getAttribute ( $ attributeName ) : null ; }
|
extract node attribute value
|
56,369
|
public function createDir ( $ dir ) { $ oldMask = umask ( 0 ) ; @ mkdir ( $ dir , self :: PERMISSION , true ) ; umask ( $ oldMask ) ; }
|
abstracting creating dir
|
56,370
|
public function moveFile ( $ source , $ destination ) { @ rename ( $ source , $ destination ) ; if ( ! $ this -> isFileExist ( $ destination ) ) { throw new EbayEnterprise_Catalog_Exception_Feed_File ( "Can not move $source to $destination" ) ; } }
|
abstracting moving a file
|
56,371
|
public function getFileTimeElapse ( $ sourceFile ) { $ date = Mage :: getModel ( 'core/date' ) ; $ timeZone = $ this -> getNewDateTimeZone ( ) ; $ startDate = $ this -> getNewDateTime ( $ date -> gmtDate ( 'Y-m-d H:i:s' , $ this -> loadFile ( $ sourceFile ) -> getCTime ( ) ) , $ timeZone ) ; $ interVal = $ startDate -> diff ( $ this -> getNewDateTime ( $ date -> gmtDate ( 'Y-m-d H:i:s' , $ this -> getTime ( ) ) , $ timeZone ) ) ; return ( ( $ interVal -> y * 365 * 24 * 60 ) + ( $ interVal -> m * 30 * 24 * 60 ) + ( $ interVal -> d * 24 * 60 ) + ( $ interVal -> h * 60 ) + $ interVal -> i ) ; }
|
getting how long ago a file has been modified or created in minutes
|
56,372
|
public function getBaseUrl ( $ type = Mage_Core_Model_Store :: URL_TYPE_LINK , $ secure = null ) { return Mage :: getBaseUrl ( $ type , $ secure ) ; }
|
abstracting getting store configuration flag
|
56,373
|
public function getDiscountId ( $ appliedRuleIds ) { $ cfg = Mage :: helper ( 'radial_core' ) -> getConfigModel ( ) ; $ ids = explode ( ',' , $ appliedRuleIds ) ; $ ruleId = ! empty ( $ ids ) ? $ ids [ 0 ] : 0 ; return sprintf ( '%.12s' , $ cfg -> storeId . '-' . $ ruleId ) ; }
|
Expect a comma delimited string of applied salesrule ids and the first rule id will be concatenated to a string of configured store id and a dash . The result string will be truncated to only 12 characters if exceeded .
|
56,374
|
public function parseBool ( $ s ) { if ( ! is_string ( $ s ) ) { return ( bool ) $ s ; } $ result = false ; switch ( strtolower ( $ s ) ) { case '1' : case 'on' : case 't' : case 'true' : case 'y' : case 'yes' : $ result = true ; break ; } return $ result ; }
|
Parse a string into a boolean .
|
56,375
|
public function extractXmlToArray ( DOMNode $ contextNode , array $ mapping , DOMXPath $ xpath ) { $ data = [ ] ; $ coreHelper = Mage :: helper ( 'radial_core' ) ; foreach ( $ mapping as $ key => $ callback ) { if ( $ callback [ 'type' ] !== 'disabled' ) { $ result = $ xpath -> query ( $ callback [ 'xpath' ] , $ contextNode ) ; if ( $ result -> length ) { $ callback [ 'parameters' ] = [ $ result ] ; $ data [ $ key ] = $ coreHelper -> invokeCallback ( $ callback ) ; } } } return $ data ; }
|
Extract data from a passed in DOMNode using an array containing mapping of how to extract the data .
|
56,376
|
public function getSdkApi ( $ service , $ operation , array $ endpointParams = [ ] , LoggerInterface $ logger = null ) { $ timeout = Mage :: getStoreConfig ( 'radial_core/payments/responsetimeout' ) ; $ config = $ this -> getConfigModel ( ) ; $ apiLogger = $ logger ? : $ this -> _logger ; $ apiConfig = new Api \ HttpConfig ( $ config -> apiKey , $ config -> apiHostname , $ config -> apiMajorVersion , $ config -> apiMinorVersion , $ config -> storeId , $ service , $ operation , $ endpointParams , $ apiLogger , $ timeout ) ; return new Api \ HttpApi ( $ apiConfig , $ apiLogger ) ; }
|
Create a new ROM SDK API object . API will be configured with core configuration and the service and operation provided .
|
56,377
|
public function invokeCallback ( array $ meta ) { if ( empty ( $ meta ) ) { return null ; } $ parameters = isset ( $ meta [ 'parameters' ] ) ? $ meta [ 'parameters' ] : [ ] ; switch ( $ meta [ 'type' ] ) { case 'model' : return call_user_func_array ( [ Mage :: getModel ( $ meta [ 'class' ] ) , $ meta [ 'method' ] ] , $ parameters ) ; case 'helper' : return call_user_func_array ( [ Mage :: helper ( $ meta [ 'class' ] ) , $ meta [ 'method' ] ] , $ parameters ) ; case 'singleton' : return call_user_func_array ( [ Mage :: getSingleton ( $ meta [ 'class' ] ) , $ meta [ 'method' ] ] , $ parameters ) ; default : return null ; } }
|
Call a class static method based on the meta data in the given array .
|
56,378
|
public function getQuoteCouponCode ( Mage_Sales_Model_Quote $ quote , Mage_SalesRule_Model_Rule $ rule ) { $ codeAppliedToQuote = $ quote -> getCouponCode ( ) ; $ codeInRule = $ rule -> getCouponCode ( ) ; return $ codeAppliedToQuote === $ codeInRule ? $ codeAppliedToQuote : $ this -> getCodeFromCouponPool ( $ rule , $ codeAppliedToQuote ) ; }
|
Get the applied coupon code on the quote for the passed in rule .
|
56,379
|
public function afterUpdate ( $ event ) { $ oldCondition = [ ] ; $ currentCondition = [ ] ; $ owner = $ this -> owner ; foreach ( ( array ) $ this -> conditionAttributes as $ attribute ) { if ( ! $ owner -> hasAttribute ( $ attribute ) ) { continue ; } $ oldCondition [ $ attribute ] = $ currentCondition [ $ attribute ] = $ owner -> getAttribute ( $ attribute ) ; if ( array_key_exists ( $ attribute , $ event -> changedAttributes ) ) { $ oldCondition [ $ attribute ] = $ event -> changedAttributes [ $ attribute ] ; } } if ( array_diff ( $ currentCondition , $ oldCondition ) != [ ] ) { $ changedModel = Yii :: createObject ( $ owner -> className ( ) ) ; $ changedModel -> setAttributes ( $ oldCondition , false ) ; $ changedModel -> recalculateSort ( ) ; $ owner -> updateAttributes ( [ $ this -> sortAttribute => $ owner -> find ( ) -> andWhere ( $ this -> getCondition ( ) ) -> count ( ) - 1 ] ) ; } }
|
After update event
|
56,380
|
public function getMaxSort ( ) { if ( $ this -> _max === null ) { $ this -> _max = $ this -> owner -> find ( ) -> andWhere ( $ this -> getCondition ( ) ) -> count ( ) - 1 ; } return $ this -> _max ; }
|
Get maximal sort index
|
56,381
|
protected function getCondition ( ) { $ condition = [ 'and' ] ; foreach ( ( array ) $ this -> conditionAttributes as $ attribute ) { if ( $ this -> owner -> hasAttribute ( $ attribute ) ) { $ condition [ ] = [ $ attribute => $ this -> owner -> $ attribute ] ; } } return $ condition ; }
|
Get WHERE condition for sort change query
|
56,382
|
public function relativeMove ( $ model , $ position ) { $ conditionAttributes = ( array ) $ this -> conditionAttributes ; $ owner = $ this -> owner ; if ( ! empty ( $ conditionAttributes ) ) { $ sameCondition = true ; foreach ( $ conditionAttributes as $ attr ) { if ( $ owner -> getAttribute ( $ attr ) != $ model -> getAttribute ( $ attr ) ) { $ sameCondition = false ; break ; } } if ( ! $ sameCondition ) { $ this -> moveToTop ( ) ; $ condition = [ ] ; foreach ( $ conditionAttributes as $ attr ) { $ condition [ $ attr ] = $ model -> getAttribute ( $ attr ) ; } $ condition [ $ this -> sortAttribute ] = $ owner -> find ( ) -> andWhere ( $ this -> getCondition ( ) ) -> count ( ) - 1 ; $ owner -> updateAttributes ( $ condition ) ; } } $ currentPos = $ owner -> getAttribute ( $ this -> sortAttribute ) ; $ destinationPos = $ model -> getAttribute ( $ this -> sortAttribute ) ; if ( $ position == 'after' ) { $ newPos = $ destinationPos > $ currentPos ? $ destinationPos - 1 : $ destinationPos ; } else { $ newPos = $ destinationPos > $ currentPos ? $ destinationPos : $ destinationPos + 1 ; } $ this -> moveToPosition ( $ newPos ) ; }
|
Move model relative other
|
56,383
|
public function setExpression ( CronExpression $ expression ) { $ this -> minute = $ expression -> getExpression ( 0 ) ; $ this -> hour = $ expression -> getExpression ( 1 ) ; $ this -> day = $ expression -> getExpression ( 2 ) ; $ this -> month = $ expression -> getExpression ( 3 ) ; $ this -> weekday = $ expression -> getExpression ( 4 ) ; $ this -> year = $ expression -> getExpression ( 5 ) ; return $ this ; }
|
set cron expression for this schedule
|
56,384
|
public static function generate ( array $ authors ) { $ newAuthors = [ ] ; foreach ( $ authors as $ author ) { $ newAuthors [ ] = ( object ) $ author ; } return $ newAuthors ; }
|
Generates a new array of authors where each item is an object .
|
56,385
|
public static function createZip ( $ destination , $ files = [ ] , $ blobs = [ ] , $ overwrite = true ) { if ( ! class_exists ( 'ZipArchive' ) ) { throw new \ Exception ( 'cannot_create_zip_archive' ) ; } if ( file_exists ( $ destination ) && ! $ overwrite ) { return false ; } $ zip = new ZipArchive ( ) ; if ( $ zip -> open ( $ destination , $ overwrite ? ZIPARCHIVE :: OVERWRITE : ZIPARCHIVE :: CREATE ) !== true ) { return false ; } foreach ( $ files as $ file ) { $ filename = $ blob [ 'filename' ] ; $ path = $ blob [ 'path' ] ; if ( ! file_exists ( $ path ) ) { throw new \ Exception ( 'file_NotFoundException' ) ; } $ zip -> addFile ( $ filename , $ path ) ; } foreach ( $ blobs as $ blob ) { $ filename = $ blob [ 'filename' ] ; $ contents = $ blob [ 'contents' ] ; $ zip -> addFromString ( $ filename , $ contents ) ; } $ zip -> close ( ) ; return file_exists ( $ destination ) ; }
|
Create a zip archive
|
56,386
|
public function isAjax ( ) { $ headers = apache_request_headers ( ) ; $ is_ajax = ( isset ( $ headers [ 'X-Requested-With' ] ) && $ headers [ 'X-Requested-With' ] == 'XMLHttpRequest' ) ; return $ is_ajax ? true : false ; }
|
To check request is ajax
|
56,387
|
public function input ( $ fieldName ) { if ( $ this -> isMethod ( 'post' ) ) { return ( isset ( $ _POST [ $ fieldName ] ) ) ? $ _POST [ $ fieldName ] : '' ; } if ( $ this -> isMethod ( 'get' ) ) { return ( isset ( $ _GET [ $ fieldName ] ) ) ? $ _GET [ $ fieldName ] : '' ; } if ( $ this -> isMethod ( 'put' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ PUT ) ; return ( isset ( $ PUT [ $ fieldName ] ) ) ? $ PUT [ $ fieldName ] : '' ; } if ( $ this -> isMethod ( 'patch' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ PATCH ) ; return ( isset ( $ PATCH [ $ fieldName ] ) ) ? $ PATCH [ $ fieldName ] : '' ; } if ( $ this -> isMethod ( 'delete' ) ) { parse_str ( file_get_contents ( "php://input" ) , $ DELETE ) ; return ( isset ( $ DELETE [ $ fieldName ] ) ) ? $ DELETE [ $ fieldName ] : '' ; } }
|
To get value from a request
|
56,388
|
public function old ( $ fieldName ) { if ( $ this -> isMethod ( 'get' ) && $ this -> session -> has ( 'planet_oldInput' ) ) { $ oldInput = $ this -> session -> get ( 'planet_oldInput' ) ; return ( $ oldInput != null ) ? $ oldInput [ $ fieldName ] : '' ; } }
|
To get old input value
|
56,389
|
public function all ( ) { if ( $ this -> isMethod ( 'POST' ) ) { return ( isset ( $ _POST ) ) ? $ _POST : [ ] ; } if ( $ this -> isMethod ( 'GET' ) ) { return ( isset ( $ _GET ) ) ? $ _GET : [ ] ; } }
|
To get all values from a request
|
56,390
|
public function get ( $ name ) { return ( $ this -> session -> has ( $ name ) ) ? $ this -> session -> get ( $ name ) : '' ; }
|
To get request data from session
|
56,391
|
public function getType ( $ value ) { if ( strpos ( $ value , '\\' ) !== false && class_exists ( $ value ) ) { return self :: TYPE_CLASS ; } else { return self :: TYPE_SCALAR ; } }
|
for the beginning keep it simple - > is a new object or just a value
|
56,392
|
private function applyDefaultSettings ( QrCode $ qrCode ) { $ qrCode -> setMargin ( 0 ) ; $ qrCode -> setEncoding ( 'UTF-8' ) ; $ qrCode -> setErrorCorrectionLevel ( new ErrorCorrectionLevel ( ErrorCorrectionLevel :: HIGH ) ) ; $ qrCode -> setRoundBlockSize ( true ) ; $ qrCode -> setValidateResult ( false ) ; $ qrCode -> setWriterOptions ( [ 'exclude_xml_declaration' => true ] ) ; }
|
Apply Default Settings
|
56,393
|
public function handle ( ) { $ subject = \ Skeleton \ Error \ Handler \ Basic :: get_subject ( $ this -> exception ) ; $ message = \ Skeleton \ Error \ Handler \ Basic :: get_html ( $ this -> exception ) ; $ headers = 'From: ' . \ Skeleton \ Error \ Config :: $ mail_errors_from . "\r\n" ; $ headers .= 'Content-Type: text/html; charset=ISO-8859-1 MIME-Version: 1.0' ; mail ( \ Skeleton \ Error \ Config :: $ mail_errors_to , $ subject , $ message , $ headers , '-f ' . \ Skeleton \ Error \ Config :: $ mail_errors_from ) ; }
|
Handle an error by sending mail
|
56,394
|
public static function not_found ( $ message = false ) { if ( ! $ message ) { $ message = "Resource not found" ; } Response :: $ status = 404 ; Response :: $ data = array ( "error" => $ message ) ; }
|
not_found function .
|
56,395
|
public static function flushFailed ( SplFileObject $ file , Exception $ previous = null ) { return new self ( sprintf ( 'The file "%s" could not be flushed.' , $ file -> getPathname ( ) ) , 0 , $ previous ) ; }
|
Creates an exception for a failed flush .
|
56,396
|
public function convertRuneMetrics ( string $ data ) : array { $ data = @ json_decode ( $ data ) ; if ( ! $ data ) { throw new DataConversionException ( "Could not decode RuneMetrics API response." ) ; } if ( isset ( $ data -> error ) ) { throw new DataConversionException ( "RuneMetrics API returned an error. User might not exist." ) ; } $ skills = [ ] ; foreach ( $ data -> skillvalues as $ skillvalue ) { $ skillId = $ skillvalue -> id + 1 ; try { $ skill = Skill :: getSkill ( $ skillId ) ; $ xp = ( int ) ( $ skillvalue -> xp / 10 ) ; $ skills [ ] = new HighScoreSkill ( $ skill , $ skillvalue -> rank ?? 0 , $ skillvalue -> level , $ xp ) ; } catch ( RuneScapeException $ exception ) { } } $ skills [ ] = new HighScoreSkill ( Skill :: getSkill ( Skill :: SKILL_TOTAL ) , $ data -> rank ? str_replace ( "," , "" , $ data -> rank ) : 0 , $ data -> totalskill , $ data -> totalxp ) ; $ activities = [ ] ; foreach ( $ data -> activities as $ activity ) { $ activities [ ] = new ActivityFeedItem ( new DateTime ( $ activity -> date ) , $ activity -> text , $ activity -> details ) ; } return [ self :: KEY_SKILL_HIGH_SCORE => new SkillHighScore ( $ skills ) , self :: KEY_ACTIVITY_FEED => new ActivityFeed ( $ activities ) , self :: KEY_REAL_NAME => $ data -> name ] ; }
|
KEY_REAL_NAME KEY_SKILL_HIGH_SCORE KEY_ACTIVITY_FEED
|
56,397
|
public function resolve ( ) { $ originFile = $ this -> file -> getPhysicalFile ( ) ; $ this -> filesystem -> mkdir ( $ relatedDestDir = sprintf ( '%s/%s' , dirname ( $ originFile -> getRealPath ( ) ) , $ this -> inflector -> slugify ( $ this -> format -> getId ( ) , '_' ) ) ) ; $ this -> formatter -> open ( $ originFile -> getRealPath ( ) ) -> crop ( new Point ( $ this -> options -> x , $ this -> options -> y ) , new Box ( $ this -> options -> width , $ this -> options -> height ) ) -> save ( $ formattedFileName = sprintf ( '%s/%s' , $ relatedDestDir , $ originFile -> getBasename ( ) ) ) ; $ file = $ this -> fileDomain -> create ( new PhysicalFile ( $ formattedFileName ) ) ; $ this -> formattedImage = $ this -> formattedImageLoader -> retrieveByFile ( $ file ) ? : new $ this -> formattedImageClass ( ) ; $ this -> formattedImage -> setFormat ( $ this -> format ) -> setFile ( $ file ) ; $ this -> assertEntityIsValid ( $ this -> formattedImage , array ( 'FormattedImage' , 'creation' ) ) ; $ this -> fireEvent ( FormattedImageEvents :: FORMATTED_IMAGE_CREATED , new FormattedImageEvent ( $ this -> formattedImage , $ this ) ) ; return $ this -> formattedImage ; }
|
FormattedImage creation method .
|
56,398
|
protected static function create ( array $ element ) { $ class = self :: getClassName ( $ element [ 'type' ] ) ; $ object = new $ class ; if ( $ object instanceof ContainerInterface ) { static :: execute ( $ object , $ element ) ; } return $ object ; }
|
Recursively creates the elements to add to the form
|
56,399
|
protected static function populateInputs ( ElementInterface $ input , array $ data ) { if ( $ input instanceof InputInterface ) { self :: addLabel ( $ input , $ data ) ; self :: addValidators ( $ input , $ data ) ; self :: setFilters ( $ input , $ data ) ; self :: addOptions ( $ input , $ data ) ; if ( isset ( $ data [ 'required' ] ) ) { $ input -> setRequired ( StaticFilter :: filter ( Boolean :: class , $ data [ 'required' ] ) ) ; } } self :: populateElement ( $ input , $ data ) ; }
|
Sets the properties and dependencies for input elements
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.