idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
34,200
public function details ( $ log , array $ levels , $ entries , $ level = null ) { $ this -> breadcrumb -> onSystem ( ) ; $ dataTable = $ this -> errorLogDetailsTable -> html ( ) ; return $ this -> view ( 'details' , compact ( 'dataTable' , 'log' , 'levels' , 'entries' , 'level' ) ) ; }
presenter for details action
34,201
public function index ( $ id = null ) { if ( $ this -> authProviderService -> getEnabledDrivers ( ) -> isEmpty ( ) ) { return $ this -> redirectWithMessage ( handles ( 'antares/foundation::account' ) , trans ( 'antares/api::response.no_active_api_providers' ) , 'error' ) ; } $ this -> breadcrumb -> onUserConfig ( ) ; $ model = ApiUsers :: query ( ) -> firstOrCreate ( [ 'user_id' => user ( $ id ) -> id ] ) ; $ form = $ this -> getForm ( $ model ) ; event ( "antares.form: user.api" , [ $ model , $ form ] ) ; return view ( 'antares/api::admin.user.index' , compact ( 'form' ) ) ; }
User api configuration
34,202
public function update ( $ id ) { $ model = ApiUsers :: query ( ) -> findOrFail ( $ id ) ; $ form = $ this -> getForm ( $ model ) ; $ url = url ( ) -> previous ( ) ; if ( ! $ form -> isValid ( ) ) { return $ this -> redirectWithErrors ( $ url , $ form -> getMessageBag ( ) ) ; } $ model -> enabled = input ( 'api' , 'off' ) === 'on' ; if ( ! is_null ( $ whitelist = input ( 'whitelist' ) ) ) { $ model -> whitelist = $ whitelist ; } if ( ! $ model -> save ( ) ) { return $ this -> redirectWithMessage ( $ url , trans ( 'antares/api::response.user_config_not_saved' ) , 'error' ) ; } return $ this -> redirectWithMessage ( $ url , trans ( 'antares/api::response.user_config_saved' ) ) ; }
Updates user api configuration
34,203
public function reset ( ) { $ provider = input ( 'provider' ) ; $ driver = $ this -> authProviderService -> getDriver ( $ provider ) ; $ driver -> reset ( ) ; return $ this -> redirectWithMessage ( url ( ) -> previous ( ) , trans ( 'antares/api::response.user_config_token_reseted' , [ 'name' => $ driver -> getLegend ( ) ] ) ) ; }
Resets provider token
34,204
protected function setResponseError ( $ error , int $ statusCode = 500 ) : void { if ( $ error instanceof \ Exception ) { $ error = $ error -> getMessage ( ) ; } $ this -> response [ 'message' ] = ( string ) $ error ; $ this -> response [ 'status' ] = $ statusCode ; }
Linkmobility always formats their errors like this so we mimic this
34,205
public function accumulate ( $ v ) { $ this -> last_value = null ; $ key = $ v -> value [ 0 ] ; if ( ! isset ( $ this -> stream [ $ v -> stream ] [ $ key ] ) ) { $ this -> stream [ $ v -> stream ] [ $ key ] = 0 ; } $ this -> stream [ $ v -> stream ] [ $ key ] += 1 ; if ( isset ( $ this -> stream [ $ v -> stream ^ 1 ] [ $ key ] ) ) { $ this -> last_value = $ v -> value ; } }
Take a muxed tuple and treat the first value as the join key .
34,206
public function map ( $ class , $ presenter = null ) { if ( is_array ( $ class ) ) { foreach ( $ class as $ model => $ present ) { $ this -> mappings -> put ( $ model , $ present ) ; } } else { $ this -> mappings -> put ( $ class , $ presenter ) ; } }
Add another presenter mapping .
34,207
public function sendSuccess ( ) { $ message = trans ( 'Report has been send.' ) ; app ( 'antares.messages' ) -> add ( 'success' , $ message ) ; if ( app ( 'request' ) -> ajax ( ) ) { return new JsonResponse ( [ 'message' => $ message ] , 200 ) ; } return redirect ( handles ( 'antares::/' ) ) ; }
when delete error log completed successfully
34,208
public function publicKey ( User $ user , $ reset = false ) { $ model = ApiPublicPrivate :: query ( ) -> firstOrNew ( [ 'user_id' => $ user -> id ] ) ; if ( ! $ model -> exists or $ reset ) { $ model -> public_key = hash ( 'sha256' , openssl_random_pseudo_bytes ( 32 ) ) ; $ model -> save ( ) ; } return $ model -> public_key ; }
User private key getter
34,209
public function getProjects ( $ debuggingEnabled = false ) { $ dataService = $ this -> getDataService ( ) ; $ projects = $ dataService -> getProjects ( ) ; if ( is_array ( $ projects ) === false ) { $ message = 'No projects found on "%s"!' ; $ message = sprintf ( $ message , $ dataService -> getHost ( ) ) ; throw new \ RuntimeException ( $ message , 1363894633 ) ; } $ transformerFactory = $ this -> getTransformerFactory ( ) ; $ projectTransformer = $ transformerFactory -> getTransformer ( 'Project' , $ debuggingEnabled ) ; $ transformedProjects = [ ] ; foreach ( $ projects as $ name => $ project ) { if ( array_key_exists ( '_name' , $ project ) ) { $ exceptionMessage = 'Key "_name" already exists. Maybe we can get rid of the $name var?' ; $ exceptionMessage .= 'Please search for this exception and read the comments.' ; throw new \ RuntimeException ( $ exceptionMessage , 1420132548 ) ; } $ project [ '_name' ] = $ name ; $ projectTransformer -> setData ( $ project ) ; $ transformedProjects [ $ name ] = $ projectTransformer -> transform ( ) ; } return $ transformedProjects ; }
Returns all projects by Gerrit API . The returned projects are already transformed to a unique format .
34,210
public function report ( Exception $ e ) { try { if ( class_exists ( '\Nodes\Bugsnag\ServiceProvider' ) ) { if ( \ Nodes \ Bugsnag \ ServiceProvider :: VERSION == '1.0' ) { if ( $ e instanceof NodesException && $ e -> getReport ( ) ) { app ( 'nodes.bugsnag' ) -> notifyException ( $ e , $ e -> getMeta ( ) , $ e -> getSeverity ( ) ) ; } elseif ( ! $ e instanceof NodesException ) { app ( 'nodes.bugsnag' ) -> notifyException ( $ e , null , 'error' ) ; } } elseif ( \ Nodes \ Bugsnag \ ServiceProvider :: VERSION == '2.0' ) { if ( $ e instanceof NodesException && $ e -> getReport ( ) ) { app ( 'nodes.bugsnag' ) -> notifyException ( $ e , function ( \ Bugsnag \ Report $ report ) use ( $ e ) { $ report -> setMetaData ( $ e -> getMeta ( ) , true ) ; $ report -> setSeverity ( $ e -> getSeverity ( ) ) ; } ) ; } elseif ( ! $ e instanceof NodesException ) { app ( 'nodes.bugsnag' ) -> notifyException ( $ e , function ( \ Bugsnag \ Report $ report ) { $ report -> setSeverity ( 'error' ) ; } ) ; } } } } catch ( \ Throwable $ e ) { } Log :: error ( $ e ) ; }
Report and log an exception .
34,211
public function clearToken ( $ service ) { $ tokens = Session :: get ( $ this -> sessionVariableName ) ; if ( array_key_exists ( $ service , $ tokens ) ) { unset ( $ tokens [ $ service ] ) ; } Session :: set ( $ this -> sessionVariableName , $ tokens ) ; return $ this ; }
Delete the user s token . Aka log out .
34,212
protected function registerActions ( Server $ server ) { $ server -> registerAction ( 'get.category' , 'FluxBB\Actions\ViewCategory' ) ; $ server -> registerAction ( 'get.conversation' , 'FluxBB\Actions\GetConversation' ) ; $ server -> registerAction ( 'get.post' , 'FluxBB\Actions\GetPost' ) ; $ server -> registerAction ( 'create.user' , 'FluxBB\Actions\CreateUser' ) ; $ server -> registerAction ( 'login.user' , 'FluxBB\Actions\Login' ) ; $ server -> registerAction ( 'logout.user' , 'FluxBB\Actions\Logout' ) ; $ server -> registerAction ( 'edit.post' , 'FluxBB\Actions\EditPost' ) ; $ server -> registerAction ( 'reply.topic' , 'FluxBB\Actions\Reply' ) ; $ server -> registerAction ( 'subscribe.topic' , 'FluxBB\Actions\SubscribeTopic' ) ; $ server -> registerAction ( 'unsubscribe.topic' , 'FluxBB\Actions\UnsubscribeTopic' ) ; $ server -> registerAction ( 'create.topic' , 'FluxBB\Actions\NewTopic' ) ; $ server -> registerAction ( 'set.settings' , 'FluxBB\Actions\SetSettings' ) ; $ server -> registerAction ( 'get.settings' , 'FluxBB\Actions\GetSettings' ) ; }
Register the actions with the server .
34,213
protected function registerValidators ( RequestValidator $ validator ) { $ validator -> registerValidator ( 'post_edit_handler' , 'FluxBB\Validation\PostValidator' ) ; $ validator -> registerValidator ( 'reply_handler' , 'FluxBB\Validation\PostValidator' ) ; $ validator -> registerValidator ( 'new_topic_handler' , 'FluxBB\Validation\PostValidator' ) ; $ validator -> registerValidator ( 'admin.options.set' , 'FluxBB\Validation\OptionsValidator' ) ; $ validator -> registerValidator ( 'handle_registration' , 'FluxBB\Validation\UserValidator' ) ; }
Register all validators with the request validator .
34,214
public function onEditDevice ( $ id ) { $ this -> onDevicesList ( ) ; Breadcrumbs :: register ( 'device-edit' , function ( $ breadcrumbs ) use ( $ id ) { $ breadcrumbs -> parent ( 'devices-list' ) ; $ breadcrumbs -> push ( 'Device edit #' . $ id , handles ( 'antares::logger/devices/' . $ id . '/edit' ) ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'device-edit' ) ) ; }
shows breadcrumbs on device edit ;
34,215
public function onActivity ( $ type = null ) { Breadcrumbs :: register ( 'logger-activity' , function ( $ breadcrumbs ) { $ breadcrumbs -> push ( 'Activity Log' , handles ( 'antares::logger/activity/index' ) ) ; } ) ; if ( ! is_null ( $ type ) ) { Breadcrumbs :: register ( 'logger-activity-' . $ type , function ( $ breadcrumbs ) use ( $ type ) { $ breadcrumbs -> push ( ucfirst ( $ type ) . ' Log' , handles ( 'antares::logger/activity/' . $ type ) ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'logger-activity-' . $ type ) ) ; } else { view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'logger-activity' ) ) ; } }
breadcrumbs when list of activity
34,216
public function onActivityDetails ( Model $ model ) { $ this -> onActivity ( ) ; Breadcrumbs :: register ( 'logger-activity-details' , function ( $ breadcrumbs ) use ( $ model ) { $ breadcrumbs -> parent ( 'logger-activity' ) ; $ breadcrumbs -> push ( 'Show Activity Log #' . $ model -> id , handles ( 'antares::logger/activity/show/' . $ model -> id ) ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'logger-activity-details' ) ) ; }
breadcrumbs when shows activity details
34,217
public function onRequestDetails ( ) { Breadcrumbs :: register ( 'logger-request' , function ( $ breadcrumbs ) { $ breadcrumbs -> push ( 'Request Log' , handles ( 'antares::logger/request/index' ) , [ 'force_link' => true ] ) ; } ) ; $ date = Request :: route ( ) -> parameter ( 'date' ) ; Breadcrumbs :: register ( 'logger-request-' . $ date , function ( $ breadcrumbs ) use ( $ date ) { $ breadcrumbs -> parent ( 'logger-request' ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'logger-request-' . $ date ) ) ; }
Breadcrummbs when shows request log details
34,218
public function onReportsHistory ( ) { $ this -> onSystemInformations ( ) ; Breadcrumbs :: register ( 'logger-reports-history' , function ( $ breadcrumbs ) { $ breadcrumbs -> parent ( 'logger-system-informations' ) ; $ breadcrumbs -> push ( 'Reports history' , handles ( 'antares::logger/history' ) ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'logger-reports-history' ) ) ; }
breadcrummbs when shows reports history
34,219
public function onPreviewHtmlReport ( Model $ model ) { $ this -> onReportsHistory ( ) ; Breadcrumbs :: register ( 'logger-reports-preview-' . $ model -> id , function ( $ breadcrumbs ) use ( $ model ) { $ breadcrumbs -> parent ( 'logger-reports-history' ) ; $ breadcrumbs -> push ( 'Preview report ' . $ model -> name , handles ( 'antares::logger/view/' . $ model -> id ) ) ; } ) ; view ( ) -> share ( 'breadcrumbs' , Breadcrumbs :: render ( 'logger-reports-preview-' . $ model -> id ) ) ; }
breadcrummbs when shows preview html report
34,220
public function execute ( $ debug = false ) { if ( count ( $ this -> requests ) === 0 ) { return false ; } $ curl = curl_init ( ) ; if ( ! $ curl ) { return false ; } $ query = "api_key={$this->key}&api_action=batch&api_requestArray=" . json_encode ( $ this -> requests ) ; $ this -> requests = [ ] ; if ( $ debug ) { return $ query ; } curl_setopt ( $ curl , CURLOPT_URL , 'https://api.linode.com/' ) ; curl_setopt ( $ curl , CURLOPT_POST , true ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , $ query ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1_2 ) ; $ result = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; $ json = json_decode ( $ result , true ) ; if ( ! $ json ) { throw new \ RuntimeException ( 'Empty response' ) ; } return $ json ; }
Performs a call for currently batched requests .
34,221
protected function createSortTransformFunction ( ) { $ propertyMap = $ this -> propertyMap ; $ propertyExtractor = $ this -> getPropertyExtractor ( ) ; $ valueChecker = $ this -> getValueChecker ( ) ; return function ( $ a , $ b ) use ( $ propertyMap , $ propertyExtractor , $ valueChecker ) { foreach ( $ propertyMap as $ property ) { $ valueA = $ propertyExtractor ( $ a , $ property [ 'accessor' ] ) ; $ valueB = $ propertyExtractor ( $ b , $ property [ 'accessor' ] ) ; $ cmp = $ property [ 'comparator' ] ; $ valueChecker ( $ valueA , $ valueB , $ cmp ) ; $ result = $ cmp -> compare ( $ valueA , $ valueB ) ; if ( $ result != 0 ) { return $ result * $ property [ 'direction' ] ; } } return 0 ; } ; }
Create a callback used in usort
34,222
public function create ( $ DatacenterID , $ PlanID , $ PaymentTerm = null ) { return $ this -> call ( 'linode.create' , [ 'DatacenterID' => $ DatacenterID , 'PlanID' => $ PlanID , 'PaymentTerm' => $ PaymentTerm , ] ) ; }
Creates a Linode and assigns you full privileges . There is a 250 - linodes - per - hour limiter .
34,223
public function duplicate ( $ LinodeID , $ DatacenterID , $ PlanID , $ PaymentTerm = null ) { return $ this -> call ( 'linode.clone' , [ 'LinodeID' => $ LinodeID , 'DatacenterID' => $ DatacenterID , 'PlanID' => $ PlanID , 'PaymentTerm' => $ PaymentTerm , ] ) ; }
Creates a new Linode assigns you full privileges and then clones the specified LinodeID to the new Linode . There is a limit of 5 active clone operations per source Linode . It is recommended that the source Linode be powered down during the clone .
34,224
public function update ( $ LinodeID , $ Label = null , $ lpm_displayGroup = null , $ Alert_cpu_enabled = null , $ Alert_cpu_threshold = null , $ Alert_diskio_enabled = null , $ Alert_diskio_threshold = null , $ Alert_bwin_enabled = null , $ Alert_bwin_threshold = null , $ Alert_bwout_enabled = null , $ Alert_bwout_threshold = null , $ Alert_bwquota_enabled = null , $ Alert_bwquota_threshold = null , $ backupWindow = null , $ backupWeeklyDay = null , $ watchdog = null , $ ms_ssh_disabled = null , $ ms_ssh_user = null , $ ms_ssh_ip = null , $ ms_ssh_port = null ) { return $ this -> call ( 'linode.update' , [ 'LinodeID' => $ LinodeID , 'Label' => $ Label , 'lpm_displayGroup' => $ lpm_displayGroup , 'Alert_cpu_enabled' => $ Alert_cpu_enabled , 'Alert_cpu_threshold' => $ Alert_cpu_threshold , 'Alert_diskio_enabled' => $ Alert_diskio_enabled , 'Alert_diskio_threshold' => $ Alert_diskio_threshold , 'Alert_bwin_enabled' => $ Alert_bwin_enabled , 'Alert_bwin_threshold' => $ Alert_bwin_threshold , 'Alert_bwout_enabled' => $ Alert_bwout_enabled , 'Alert_bwout_threshold' => $ Alert_bwout_threshold , 'Alert_bwquota_enabled' => $ Alert_bwquota_enabled , 'Alert_bwquota_threshold' => $ Alert_bwquota_threshold , 'backupWindow' => $ backupWindow , 'backupWeeklyDay' => $ backupWeeklyDay , 'watchdog' => $ watchdog , 'ms_ssh_disabled' => $ ms_ssh_disabled , 'ms_ssh_user' => $ ms_ssh_user , 'ms_ssh_ip' => $ ms_ssh_ip , 'ms_ssh_port' => $ ms_ssh_port , ] ) ; }
Updates a Linode s properties .
34,225
protected static function decodeToUtf8 ( $ str ) { $ str = preg_replace_callback ( "/\\\\x([0-9ABCDEF]{1,2})/" , function ( $ matches ) { return chr ( hexdec ( $ matches [ 1 ] ) ) ; } , $ str ) ; $ encoding = mb_detect_encoding ( $ str , 'ASCII, UCS2, UTF8' ) ; if ( $ encoding == 'ASCII' ) { $ result = mb_convert_encoding ( $ str , 'UTF-8' , 'ASCII' ) ; } else { if ( substr_count ( $ str , chr ( 0 ) ) > 0 ) { $ result = mb_convert_encoding ( $ str , 'UTF-8' , 'UCS2' ) ; } else { $ result = $ str ; } } return $ result ; }
Decodes id - card information to utf8
34,226
public function get ( $ key = null , $ default = null ) { if ( empty ( $ key ) ) { return $ this -> settings ; } $ ts = microtime ( true ) ; if ( $ ts !== array_get ( $ this -> settings , $ key , $ ts ) ) { return array_get ( $ this -> settings , $ key ) ; } if ( ! is_null ( $ this -> fallback ) and $ this -> fallback -> fallbackHas ( $ key ) ) { return $ this -> fallback -> fallbackGet ( $ key , $ default ) ; } return $ default ; }
Get a value and return it
34,227
public function set ( $ key , $ value ) { array_set ( $ this -> settings , $ key , $ value ) ; $ this -> save ( $ this -> path , $ this -> filename ) ; $ this -> load ( $ this -> path , $ this -> filename ) ; }
Store the passed value in to the json file
34,228
public function has ( $ searchKey ) { $ default = microtime ( true ) ; if ( $ default == array_get ( $ this -> settings , $ searchKey , $ default ) and ! is_null ( $ this -> fallback ) ) { return $ this -> fallback -> fallbackHas ( $ searchKey ) ; } return $ default !== array_get ( $ this -> settings , $ searchKey , $ default ) ; }
Check to see if the value exists
34,229
public function clear ( ) { $ this -> settings = array ( ) ; $ this -> save ( $ this -> path , $ this -> filename ) ; $ this -> load ( $ this -> path , $ this -> filename ) ; }
Clears the JSON Config file
34,230
public function setArray ( array $ data ) { foreach ( $ data as $ key => $ value ) { array_set ( $ this -> settings , $ key , $ value ) ; } $ this -> save ( $ this -> path , $ this -> filename ) ; $ this -> load ( $ this -> path , $ this -> filename ) ; }
This will mass assign data to the Setting
34,231
protected function doTransform ( Matrix $ mA , $ extra = null ) { if ( $ mA -> is ( 'empty' ) ) { return new Matrix ( array ( ) ) ; } $ this -> assertParameterIsArray ( $ extra , 'Second operand is not an array' ) ; if ( empty ( $ extra ) ) { throw new MatrixException ( 'Second operand does not contain row indicator' ) ; } $ row = intval ( $ extra [ 0 ] ) ; $ availableRows = $ mA -> rows ( ) ; if ( $ row < 1 || $ row > $ availableRows ) { throw new MatrixException ( 'Row indicator out of bounds' ) ; } $ numRows = ( isset ( $ extra [ 1 ] ) ? intval ( $ extra [ 1 ] ) : 1 ) ; if ( $ numRows < 1 || ( $ numRows + $ row - 1 ) > $ availableRows ) { throw new MatrixException ( 'Numrows out of bounds' ) ; } $ this -> assertMatrixIsComplete ( $ mA ) ; return $ this -> doTransformation ( $ mA , $ row , $ numRows ) ; }
Take a row slice from the matrix
34,232
protected function getName ( $ classname , $ function = null ) { $ name = str_replace ( 'Controller' , '' , last ( explode ( '\\' , $ classname ) ) ) ; return strtoupper ( ! is_null ( $ function ) ? $ name . '_' . $ function : $ name ) ; }
Creates name of log entity
34,233
public function keep ( $ priority = null ) { if ( ! $ this -> validate ( ) ) { return ; } $ insert = array_merge ( $ this -> prepare ( ) , $ this -> getObjectParams ( $ priority ) ) ; $ logs = new Logs ( $ insert ) ; $ logs -> save ( ) ; $ segments = request ( ) -> segments ( ) ; if ( end ( $ segments ) == 'login' ) { try { $ location = $ this -> app -> make ( 'geoip' ) -> getLocation ( ) ; } catch ( Exception $ ex ) { $ location = 'not reached' ; } $ this -> loginDeviceAdapter -> validate ( array_merge ( $ insert , [ 'log_id' => $ logs -> id , 'location' => $ location ] ) ) ; } return true ; }
insert customized log data
34,234
protected function getObjectParams ( $ priority , array $ params = [ ] ) { if ( ! empty ( $ params ) ) { $ object = array_get ( $ params , 'object' ) ; $ name = array_get ( $ params , 'name' ) ; } elseif ( ! is_null ( $ this -> owner ) ) { $ object = $ this -> owner ; $ name = $ this -> getName ( $ owner ) ; } else { $ backtrace = debug_backtrace ( DEBUG_BACKTRACE_PROVIDE_OBJECT , 3 ) [ 2 ] ; $ object = array_get ( $ backtrace , 'object' ) ; $ name = $ this -> getName ( get_class ( $ object ) , array_get ( $ backtrace , 'function' ) ) ; } if ( ! is_object ( $ object ) or is_null ( $ name ) ) { throw new Exception ( 'Unable to resolve logger object params' ) ; } return [ 'type_id' => $ this -> logTypeId ( $ object ) , 'owner_type' => get_class ( $ object ) , 'old_value' => $ this -> old , 'priority_id' => $ this -> logPrioriotyId ( $ priority ) , 'name' => $ name ] ; }
Gets object params
34,235
public function traverse ( ) { if ( self :: $ ignoreAjax or ! $ this -> validate ( ) ) { return ; } $ request = app ( 'antares.request' ) ; $ module = $ request -> getModule ( ) ; $ controller = $ request -> getController ( ) ; $ action = $ request -> getAction ( ) ; $ insert = [ 'type_id' => $ this -> getLogTypeByName ( $ module ) , 'owner_type' => $ request -> getControllerClass ( ) , 'priority_id' => $ this -> logPrioriotyId ( 'low' ) , 'name' => strtoupper ( implode ( '_' , [ $ module , $ controller , $ action ] ) ) , 'type' => 'viewed' ] ; return Logs :: insert ( array_merge ( $ this -> prepare ( ) , $ insert ) ) ; }
traverse all user actions
34,236
protected function prepare ( ) { return [ 'route' => str_replace ( app ( 'url' ) -> to ( '/' ) , '' , Request :: url ( ) ) , 'ip_address' => GeoIPFacade :: getClientIP ( ) , 'user_agent' => isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ? $ _SERVER [ 'HTTP_USER_AGENT' ] : 'No UserAgent' , 'created_at' => new DateTime ( ) , 'updated_at' => new DateTime ( ) , 'type' => 'dispatched' , 'user_id' => auth ( ) -> guest ( ) ? null : auth ( ) -> user ( ) -> id , 'brand_id' => brand_id ( ) , 'additional_params' => $ this -> additionalParams , 'related_data' => $ this -> relatedData ] ; }
prepare insert log data
34,237
public function logPrioriotyId ( $ priority = 'medium' ) { $ logPriority = LogPriorities :: where ( 'name' , $ priority ) -> first ( ) ; if ( is_null ( $ logPriority ) ) { $ logPriority = new LogPriorities ( [ 'name' => $ priority ] ) ; $ logPriority -> save ( ) ; } return $ logPriority -> id ; }
get instance of log priority
34,238
public function logTypeId ( $ object ) { $ reflection = new ReflectionClass ( $ object ) ; $ filename = $ reflection -> getFileName ( ) ; $ match = null ; if ( ! preg_match ( "'src(.*?)src'si" , $ filename , $ match ) ) { throw new Exception ( 'Unable to resolve current module name.' ) ; } if ( ! isset ( $ match [ 1 ] ) ) { throw new Exception ( 'Unable to resolve current module namespace.' ) ; } $ reserved = [ 'components' , 'modules' ] ; $ name = ( str_contains ( $ match [ 1 ] , 'core' ) ) ? 'core' : trim ( str_replace ( $ reserved , '' , $ match [ 1 ] ) , DIRECTORY_SEPARATOR ) ; return $ this -> getLogTypeByName ( $ name ) ; }
get instance of log type
34,239
protected function getLogTypeByName ( $ name ) { $ type = LogTypes :: where ( 'name' , $ name ) -> first ( ) ; if ( is_null ( $ type ) ) { $ type = new LogTypes ( [ 'name' => $ name ] ) ; $ type -> save ( ) ; } return $ type -> id ; }
get log type by name
34,240
public function getAdapter ( ) { $ className = $ this -> app -> make ( 'config' ) -> get ( 'antares/logger::adapter.default.model' ) ; return $ this -> app -> make ( $ className ) ; }
get default notification sender adapter
34,241
public function created ( Model $ model ) { $ langs = app ( 'languages' ) -> langs ( ) ; DB :: beginTransaction ( ) ; try { foreach ( $ langs as $ lang ) { $ this -> saveTranslatedMessage ( $ model , $ lang ) ; } } catch ( Exception $ ex ) { DB :: rollback ( ) ; throw $ ex ; } DB :: commit ( ) ; return true ; }
Runs after new log has been saved
34,242
protected function saveTranslatedMessage ( Model $ model , $ lang ) { if ( ! $ model -> translation -> isEmpty ( ) ) { return false ; } $ message = $ model -> translated ( $ lang -> code ) ; return $ model -> translation ( ) -> getModel ( ) -> newInstance ( [ 'log_id' => $ model -> id , 'lang_id' => array_get ( $ lang , 'id' ) , 'raw' => strip_tags ( $ message ) , 'text' => $ message ] ) -> save ( ) ; }
Saves translated message
34,243
protected function returnOriginalMatrixType ( Matrix $ original , Matrix $ result ) { $ oClass = get_class ( $ original ) ; if ( $ oClass == 'Chippyash\Matrix\Matrix' ) { return $ result ; } return new $ oClass ( $ result -> toArray ( ) ) ; }
Required so that upstream matrices can use the transformations and be returned in a matrix type they understand
34,244
private function extractDateTimeFormat ( $ source , $ defaultValue = null ) { $ dateTimeFormat = $ defaultValue ; if ( preg_match ( '/DateTime<(?<type>[a-zA-Z0-9\,\.\s\-\:\/\\\]+)>/' , $ source , $ matches ) ) { $ dateTimeFormat = $ matches [ 'type' ] ; if ( defined ( '\DateTime::' . $ dateTimeFormat ) ) { $ dateTimeFormat = constant ( '\DateTime::' . $ dateTimeFormat ) ; } } return $ dateTimeFormat ; }
Extracts specified date time format from given source If source does not contain any format - returns default value
34,245
public static function getUniqueColumnElements ( array $ array , $ elementKey = null ) { if ( is_null ( $ elementKey ) ) { return array_unique ( $ array ) ; } $ uniqueElements = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && isset ( $ value [ $ elementKey ] ) ) { $ value = $ value [ $ elementKey ] ; } elseif ( is_object ( $ value ) && property_exists ( $ value , $ elementKey ) ) { $ value = $ value -> { $ elementKey } ; } else { continue ; } if ( ! in_array ( $ value , $ uniqueElements , true ) ) { $ uniqueElements [ ] = $ value ; } } return $ uniqueElements ; }
Get unique array or column elements
34,246
public static function getValue ( $ array , $ key , $ default = null ) { if ( ! isset ( $ array ) ) { return $ default ; } if ( $ key instanceof \ Closure ) { return $ key ( $ array , $ default ) ; } if ( is_array ( $ key ) ) { $ lastKey = array_pop ( $ key ) ; foreach ( $ key as $ keyPart ) { $ array = static :: getValue ( $ array , $ keyPart ) ; } $ key = $ lastKey ; } if ( is_array ( $ array ) && array_key_exists ( $ key , $ array ) ) { return $ array [ $ key ] ; } if ( ( $ pos = strrpos ( $ key , '.' ) ) !== false ) { $ array = static :: getValue ( $ array , substr ( $ key , 0 , $ pos ) , $ default ) ; $ key = substr ( $ key , $ pos + 1 ) ; } if ( is_object ( $ array ) && property_exists ( $ array , $ key ) ) { return $ array -> { $ key } ; } elseif ( is_array ( $ array ) ) { return array_key_exists ( $ key , $ array ) ? $ array [ $ key ] : $ default ; } else { return $ default ; } }
Gets value from array or object Copied from Yii2 framework
34,247
public function send ( ) { try { return $ this -> sendData ( $ this -> getData ( ) ) ; } catch ( GoCardlessProException $ e ) { if ( $ e -> getMessage ( ) == 'Rate limit exceeded' ) { sleep ( $ this -> sleepTimeout ) ; try { return $ this -> sendData ( $ this -> getData ( ) ) ; } catch ( GoCardlessProException $ f ) { $ e = $ f ; } } $ response = new ErrorResponse ( $ this , $ e ) ; return $ response ; } catch ( \ Exception $ e ) { $ response = new ErrorResponse ( $ this , $ e ) ; return $ response ; } }
Set the correct configuration sending
34,248
public static function create ( \ SoapClient $ client , \ Exception $ exception ) { $ exception = new static ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; if ( ! empty ( $ xml = $ client -> __getLastRequest ( ) ) ) { $ exception -> request = static :: formatXml ( $ xml ) ; } if ( ! empty ( $ xml = $ client -> __getLastResponse ( ) ) ) { $ exception -> response = static :: formatXml ( $ xml ) ; } return $ exception ; }
Creates a new client exception .
34,249
public static function formatXml ( string $ xml ) : string { if ( empty ( $ xml ) ) { return '' ; } $ doc = new \ DOMDocument ( ) ; $ doc -> preserveWhiteSpace = false ; $ doc -> formatOutput = true ; $ doc -> loadXML ( $ xml ) ; return $ doc -> saveXML ( ) ; }
Pretty print the given XML .
34,250
private function addTranslations ( Writer $ writer ) { foreach ( $ this -> translations as $ translation ) { $ writer -> write ( [ [ 'name' => 'xhtml:link' , 'attributes' => [ 'rel' => 'alternate' , 'hreflang' => $ translation [ 'hreflang' ] , 'href' => $ translation [ 'href' ] ] , 'value' => null ] ] ) ; } }
Used for serialization .
34,251
public function addTranslation ( $ locale , $ url ) { $ this -> validateUrl ( $ url ) ; $ this -> translations [ ] = [ 'hreflang' => $ locale , 'href' => $ url ] ; return $ this ; }
It adds a translation
34,252
public function setPriority ( $ priority ) { if ( ! ( is_float ( $ priority ) && $ priority >= 0 && $ priority <= 1 ) ) { throw new Exception ( 'Priority must be >=0.0 and <=1.0' ) ; } $ this -> priority = number_format ( $ priority , 1 ) ; return $ this ; }
It sets priority .
34,253
public function call ( string $ method , RequestInterface $ request ) { try { $ parameters = $ request -> toArray ( ) ; return $ this -> __soapCall ( $ method , [ 'parameters' => $ parameters ] ) ; } catch ( \ Exception $ exception ) { if ( $ this -> debug ) { throw ClientException :: create ( $ this , $ exception ) ; } throw new ClientException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; } }
Call the web service method .
34,254
public static function bootOptionallyBoundToApplication ( ) { static :: addGlobalScope ( 'in-application' , function ( Builder $ builder ) { $ builder -> where ( function ( $ sq ) { $ sq -> whereNull ( 'application_id' ) -> orWhere ( 'application_id' , '=' , '' ) ; if ( $ application = app ( 'soda' ) -> getApplication ( ) ) { $ sq -> orWhere ( 'application_id' , '=' , $ application -> getKey ( ) ) ; } } ) ; } ) ; }
Adds application_id global scope filter to model .
34,255
public function delete ( Listener $ listener , $ id ) { try { $ model = LogsLoginDevices :: query ( ) -> findOrFail ( $ id ) ; if ( $ model -> delete ( ) ) { return $ listener -> deviceDeletedSuccessfully ( ) ; } } catch ( Exception $ ex ) { Log :: emergency ( $ ex ) ; return $ listener -> deviceDeletionFailed ( ) ; } }
on delete device
34,256
public function edit ( $ id ) { $ this -> breadcrumb -> onEditDevice ( $ id ) ; $ model = app ( LogsLoginDevices :: class ) -> findOrFail ( $ id ) ; $ form = new DeviceForm ( $ model ) ; return view ( 'antares/logger::admin.devices.edit' , compact ( 'form' ) ) ; }
on edit device name
34,257
public function update ( Listener $ listener , $ id ) { $ model = LogsLoginDevices :: query ( ) -> findOrFail ( $ id ) ; $ form = new DeviceForm ( $ model ) ; if ( ! $ form -> isValid ( ) ) { return $ listener -> deviceUpdateFailedValidation ( ) ; } $ model -> name = Input :: get ( 'name' ) ; if ( ! $ model -> save ( ) ) { return $ listener -> deviceUpdateFailed ( ) ; } return $ listener -> deviceUpdateSuccess ( ) ; }
on update device name
34,258
private function getPhalconLoggerLevel ( $ level ) { $ levelMap = [ LogLevel :: INFO => PhalconLogLevel :: INFO , LogLevel :: DEBUG => PhalconLogLevel :: DEBUG , LogLevel :: ALERT => PhalconLogLevel :: ALERT , LogLevel :: CRITICAL => PhalconLogLevel :: CRITICAL , LogLevel :: EMERGENCY => PhalconLogLevel :: EMERGENCY , LogLevel :: ERROR => PhalconLogLevel :: ERROR , LogLevel :: NOTICE => PhalconLogLevel :: NOTICE , LogLevel :: WARNING => PhalconLogLevel :: WARNING ] ; return ArrayUtils :: getValue ( $ levelMap , $ level , PhalconLogLevel :: INFO ) ; }
Get Phalcon Log Level from PSR Log level
34,259
public function transform ( $ data ) { if ( $ data instanceof FormBuilder ) { $ response = $ data -> getRawResponse ( ) ; foreach ( $ response [ 'fieldsets' ] as $ fieldset ) { $ this -> transformFieldset ( $ fieldset ) ; } return [ 'form' => [ 'name' => array_get ( $ response , 'name' ) , 'rules' => array_get ( $ response , 'rules' , [ ] ) , 'fieldsets' => $ this -> fieldsets , ] , ] ; } return parent :: transform ( $ data ) ; }
Transform FormBuilder data and return as array .
34,260
protected function transformFieldset ( Fieldset $ fieldset ) { $ controls = [ ] ; foreach ( $ fieldset -> controls ( ) as $ control ) { $ type = $ control -> get ( 'type' ) ; if ( ! in_array ( $ type , self :: $ protectedTypes ) ) { $ controls [ ] = $ this -> transformControlField ( $ control ) ; } } $ this -> fieldsets [ ] = [ 'name' => $ fieldset -> getName ( ) , 'controls' => $ controls , ] ; }
Transform a Fieldset object and compute a results array .
34,261
protected function transformControlField ( $ control ) { $ attributes = $ control -> getAttributes ( ) ; foreach ( self :: $ unusedFieldAttrs as $ attr ) { if ( isset ( $ attributes [ $ attr ] ) ) { unset ( $ attributes [ $ attr ] ) ; } } return $ attributes ; }
Returns an array of a field without unused field attributes .
34,262
public function registerMatcher ( $ matcher ) { if ( ! in_array ( $ matcher , $ this -> matchers ) && is_a ( $ matcher , MatcherInterface :: class , true ) ) { $ this -> matchers [ ] = $ matcher ; } return $ this ; }
Registers a new matcher .
34,263
public function match ( Request $ request ) { foreach ( $ this -> matchers as $ matcher ) { $ matcherInstance = app ( $ matcher ) ; if ( $ matcherInstance -> matches ( $ request -> getPathInfo ( ) ) ) { return $ matcherInstance -> render ( $ request ) ; } } return $ this -> handlePageNotFound ( ) ; }
Loads a page by it s slug .
34,264
public function loadFrom ( Repository $ config , $ configPath ) { foreach ( $ this -> filesIn ( $ configPath ) as $ group => $ configFile ) { $ config -> set ( $ group , require $ configFile ) ; } }
Load the config files from the given path and store the values in the repository .
34,265
protected function filesIn ( $ configPath ) { $ files = [ ] ; foreach ( Finder :: create ( ) -> files ( ) -> name ( '*.php' ) -> in ( $ configPath ) as $ file ) { $ group = basename ( $ file -> getRealPath ( ) , '.php' ) ; $ files [ $ group ] = $ file -> getRealPath ( ) ; } return $ files ; }
Get all files in the given directory .
34,266
public function actionCreate ( ) { $ model = new WarehouseVoucherItems ( ) ; if ( $ model -> loadAll ( request ( ) -> post ( ) ) && $ model -> saveAll ( ) ) { return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } else { return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; } }
Creates a new WarehouseVoucherItems model . If creation is successful the browser will be redirected to the view page .
34,267
public static function getConfigurationByConfigFile ( $ configFile ) { if ( file_exists ( $ configFile ) === false ) { $ message = 'Configuration file "%s" not found or accessible.' ; $ message = sprintf ( $ message , $ configFile ) ; throw new \ RuntimeException ( $ message , 1415381521 ) ; } $ config = Yaml :: parse ( $ configFile ) ; $ configuration = new Configuration ( $ config ) ; return $ configuration ; }
Creates a configuration based on a YAML configuration file .
34,268
public static function getConfigurationByConfigFileAndCommandOptionsAndArguments ( $ configFile , InputExtendedInterface $ input ) { if ( $ input -> isOptionSet ( 'config-file' ) === true ) { $ configuration = self :: getConfigurationByConfigFile ( $ configFile ) ; } else { $ configuration = new Configuration ( ) ; } $ configuration = self :: mergeCommandOptionsIntoConfiguration ( $ configuration , $ input ) ; $ configuration = self :: mergeCommandArgumentsIntoConfiguration ( $ configuration , $ input ) ; return $ configuration ; }
Creates a configuration based on a YAML configuration file command line options and command line arguments . The command line options will be merged into the configuration . The command line arguments will be merged into the configuration as well .
34,269
protected static function mergeCommandOptionsIntoConfiguration ( Configuration $ config , InputExtendedInterface $ input ) { $ configurationMapping = [ 'database-host' => 'Database.Host' , 'database-user' => 'Database.Username' , 'database-pass' => 'Database.Password' , 'database-port' => 'Database.Port' , 'database-name' => 'Database.Name' , 'ssh-key' => 'SSH.KeyFile' , ] ; foreach ( $ configurationMapping as $ optionName => $ configName ) { if ( $ input -> isOptionSet ( $ optionName ) === true ) { $ config -> setConfigurationValue ( $ configName , $ input -> getOption ( $ optionName ) ) ; } elseif ( ! $ config -> getConfigurationValue ( $ configName ) ) { $ config -> setConfigurationValue ( $ configName , null ) ; } } return $ config ; }
Merges the command line options into a existing configuration .
34,270
protected static function mergeCommandArgumentsIntoConfiguration ( Configuration $ config , InputExtendedInterface $ input ) { if ( $ input -> hasArgument ( 'instances' ) === false ) { return $ config ; } $ argumentInstances = $ input -> getArgument ( 'instances' ) ; if ( count ( $ argumentInstances ) === 0 ) { return $ config ; } $ config -> setConfigurationValue ( 'Gerrit.Gerrie' , $ argumentInstances ) ; return $ config ; }
Merges the command line arguments into a existing configuration .
34,271
protected function renderRemoveButton ( $ options = [ ] ) { $ options = array_replace_recursive ( [ 'class' => 'btn btn-box-tool' , 'data-widget' => 'remove' , ] , $ options ) ; return Html :: button ( FA :: i ( 'times' ) , $ options ) ; }
Renders the remove button
34,272
protected function renderCollapseButton ( $ options = [ ] , $ collapsed = false ) { $ options = array_replace_recursive ( [ 'class' => 'btn btn-box-tool' , 'data-widget' => 'collapse' , ] , $ options ) ; return Html :: button ( $ collapsed ? FA :: i ( 'plus' ) : FA :: i ( 'minus' ) , $ options ) ; }
Renders the collapse button
34,273
protected function renderRefreshButton ( ) { $ options = [ 'class' => 'btn btn-box-tool' , 'data-widget' => 'reload-list' , 'data-toggle' => 'tooltip' , 'title' => Yii :: t ( 'adminlte' , 'Refresh' ) , ] ; return Html :: button ( FA :: i ( FA :: _REFRESH ) , $ options ) ; }
Renders the refresh list button
34,274
protected function renderGobackButton ( ) { $ options = [ 'class' => 'btn' , 'data-widget' => 'goback' , 'data-toggle' => 'tooltip' , 'title' => Yii :: t ( 'adminlte' , 'Go back' ) , ] ; return Html :: button ( FA :: i ( FA :: _ARROW_LEFT ) , $ options ) ; }
Renders the go back button
34,275
protected function renderSearchButton ( ) { $ view = $ this -> getView ( ) ; $ defaultOptions = [ 'title' => Yii :: t ( 'adminlte' , 'Search' ) , 'url' => 'search' , 'params' => [ 'referer' => $ this -> boxUrl ] , 'searchLabel' => Yii :: t ( 'adminlte' , 'Search' ) , 'closeLabel' => Yii :: t ( 'adminlte' , 'Close' ) . '(Esc)' , 'resetLabel' => Yii :: t ( 'adminlte' , 'Reset' ) , 'size' => 'size-wide' , ] ; $ options = array_replace_recursive ( $ defaultOptions , $ this -> searchOptions ) ; $ searchDialogId = $ this -> options [ 'id' ] . '-search-dialog' ; $ params = "var boxUrl=$('#{$this->options['id']}').attr('data-box-url');" . "boxUrl=wn.url.deleteQueryString(boxUrl, 'page');" . "boxUrl=wn.url.deleteQueryString(boxUrl, 'per-page');" . "boxUrl=wn.url.deleteQueryString(boxUrl, '_toggle');" . "var boxParams=((pos=boxUrl.indexOf('?')) !== -1)?boxUrl.substring(pos+1):'';" ; $ bdAjaxOpts = Json :: encode ( [ 'type' => 'get' , 'url' => Url :: toRoute ( array_merge ( ( array ) ArrayHelper :: remove ( $ options , 'url' ) , ArrayHelper :: remove ( $ options , 'params' ) ) ) , 'data' => new JsExpression ( 'boxParams' ) , 'timeout' => "4000" , 'dataType' => "HTML" , 'success' => new JsExpression ( "function(data){addToDialog(data, dialog, '{$searchDialogId}');}" ) , 'error' => new JsExpression ( "function(XMLHttpRequest, textStatus, errorThrown){errorResponse(XMLHttpRequest, errorThrown);}" ) , ] ) ; $ opts = Json :: encode ( [ 'title' => ArrayHelper :: remove ( $ options , 'title' ) , 'size' => ArrayHelper :: remove ( $ options , 'size' ) , 'message' => new JsExpression ( "function(dialog){{$params}$.ajax($bdAjaxOpts);}" ) , 'buttons' => [ [ 'id' => 'submit' , 'label' => ArrayHelper :: remove ( $ options , 'searchLabel' ) , 'cssClass' => 'btn-success' , 'action' => new JsExpression ( 'function(){$("#search_div").trigger("submit");}' ) , ] , [ 'id' => 'reset' , 'label' => ArrayHelper :: remove ( $ options , 'resetLabel' ) , 'action' => new JsExpression ( 'function(){$("#search_div").trigger("reset");}' ) , ] , [ 'id' => 'close' , 'label' => ArrayHelper :: remove ( $ options , 'closeLabel' ) , 'action' => new JsExpression ( 'function(dialogRef){dialogRef.close();}' ) , ] , ] , ] ) ; $ widgetSearchOpts = 'wnSearchOpts_' . hash ( 'crc32' , $ opts ) ; $ view -> registerJs ( "var {$widgetSearchOpts}={$opts}" , View :: POS_HEAD ) ; $ widgetSearch = 'wnSearchWidget_' . hash ( 'crc32' , "#{$this->options['id']} [data-widget=search]" ) ; $ opts = Json :: encode ( [ 'boxId' => $ this -> options [ 'id' ] , 'dialogId' => $ searchDialogId , 'widgetSearch' => new JsExpression ( "{$widgetSearch}" ) , ] ) ; $ view -> registerJs ( "var {$widgetSearch}=new BootstrapDialog({$widgetSearchOpts});\nwnSearchWidget({$opts});" ) ; GridSearchAsset :: register ( $ view ) ; return Html :: button ( FA :: i ( FA :: _SEARCH ) , [ 'class' => 'btn btn-box-tool' , 'data-widget' => 'search' , 'data-toggle' => 'tooltip' , 'title' => $ defaultOptions [ 'title' ] , ] ) ; }
Renders the search button
34,276
public static function taggify ( $ tag ) { $ filters = config ( 'lecturize.tags.filters' , [ ] ) ; $ tag = trim ( str_replace ( array_keys ( $ filters ) , array_values ( $ filters ) , $ tag ) ) ; $ patterns = config ( 'lecturize.tags.patterns' , [ '/\(([^)]+)\)/' => '' ] ) ; $ tag = trim ( preg_replace ( array_keys ( $ patterns ) , array_values ( $ patterns ) , $ tag ) ) ; if ( config ( 'lecturize.tags.camel_case' , false ) ) { $ tag = camel_case ( $ tag ) ; $ tag = ucfirst ( $ tag ) ; } $ tag = trim ( $ tag ) ; return $ tag ; }
Taggify a given string
34,277
public function getSerializer ( ) : Serializer { if ( $ this -> serializer ) { return $ this -> serializer ; } return $ this -> serializer = new Serializer ( [ new ModelNormalizer ( ) ] , [ new JsonEncoder ( ) ] ) ; }
Returns the serializer
34,278
public function call ( string $ method , RequestInterface $ request , $ responseClass ) { $ serializer = $ this -> getSerializer ( ) ; $ req = $ res = null ; try { $ req = $ serializer -> normalize ( $ request , 'json' ) ; $ res = $ this -> request ( 'POST' , $ method , [ 'json' => $ req , ] ) ; $ parts = $ this -> parseResponse ( $ res -> getBody ( ) -> getContents ( ) ) ; $ response = null ; foreach ( $ parts as $ part ) { if ( $ part [ 'headers' ] [ 'Content-ID' ] === '<jsonInfos>' ) { $ response = $ this -> serializer -> deserialize ( $ part [ 'body' ] , $ responseClass , 'json' ) ; } elseif ( $ response ) { $ response -> addAttachment ( new Attachment ( trim ( $ part [ 'headers' ] [ 'Content-ID' ] , '<>' ) , $ part [ 'body' ] ) ) ; } } return $ response -> setSuccess ( true ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ exception ) { $ response = new $ responseClass ; if ( null !== $ res = $ exception -> getResponse ( ) ) { $ data = json_decode ( $ res -> getBody ( ) -> getContents ( ) , true ) ; if ( isset ( $ data [ 'messages' ] ) && ! empty ( $ data [ 'messages' ] ) ) { foreach ( $ data [ 'messages' ] as $ m ) { $ response -> addMessage ( new Message ( intval ( $ m [ 'id' ] ) , $ m [ 'type' ] , $ m [ 'messageContent' ] ) ) ; } } return $ response ; } throw $ exception ; } catch ( \ Exception $ exception ) { $ exception = new ClientException ( 'REST call failed' , 0 , $ exception ) ; if ( $ this -> debug && $ req ) { $ exception -> request = $ req ; } if ( $ this -> debug && $ res ) { $ exception -> response = $ res ; } throw $ exception ; } }
Call the web service .
34,279
public function system ( ) { $ linfo = new Linfo ( config ( 'antares/logger::analyzer.system' ) ) ; $ linfo -> scan ( ) ; $ output = new SystemInfo ( $ linfo ) ; $ info = $ output -> output ( ) ; return $ this -> presenter -> system ( $ info ) ; }
read system environment
34,280
public function modules ( ) { $ predefinedDirectories = [ 'core' , 'components' ] ; $ return = [ ] ; foreach ( $ predefinedDirectories as $ predefinedDirectory ) { $ directoryPath = base_path ( "src/{$predefinedDirectory}" ) ; $ directories = $ this -> filesystem -> directories ( $ directoryPath ) ; foreach ( $ directories as $ directory ) { $ size = 0 ; $ files = $ this -> filesystem -> allFiles ( $ directory ) ; foreach ( $ files as $ file ) { $ size += $ file -> getSize ( ) ; } $ return [ $ predefinedDirectory ] [ ] = [ 'directory' => $ predefinedDirectory . DIRECTORY_SEPARATOR . last ( explode ( DIRECTORY_SEPARATOR , $ directory ) ) , 'files_count' => count ( $ files ) , 'size' => $ this -> humanFileSize ( $ size , 'MB' ) , ] ; } } return $ this -> presenter -> modules ( $ return ) ; }
read modules list
34,281
public function version ( ) { $ adapter = app ( 'antares.version' ) -> getAdapter ( ) ; $ data = [ 'version' => $ adapter -> getActualVersion ( ) ] ; if ( $ adapter -> isNewer ( ) ) { $ data [ 'messages' ] [ ] = [ 'warning' , sprintf ( 'New System version available. We strongly recommend upgrade to version %s' , $ adapter -> getVersion ( ) ) ] ; } return $ this -> presenter -> version ( $ data ) ; }
get system version
34,282
public function components ( ) { $ ignore = [ 'addons/playground' , 'components/tickets' , 'domains/dns' ] ; $ extensions = app ( 'antares.memory' ) -> make ( 'component' ) ; $ active = array_except ( $ extensions -> get ( 'extensions.active' ) , $ ignore ) ; $ available = array_except ( $ extensions -> get ( 'extensions.available' ) , $ ignore ) ; $ inactive = array_flip ( array_diff ( array_keys ( $ available ) , array_keys ( $ active ) ) ) ; $ data = [ 'components' => $ available , 'inactive' => $ inactive ] ; return $ this -> presenter -> components ( $ data ) ; }
report installed components
34,283
protected function prepareArguments ( $ cpt , array $ args ) { $ defaults = $ this -> getConfigKey ( static :: DEFAULTS ) ; return ( new ArgumentCollection ( array_replace_recursive ( $ defaults , $ this -> getConfigKey ( $ cpt ) , $ args ) ) ) -> prepareLabels ( ) ; }
Prepare the arguments and return a Collection of arguments .
34,284
public function publishHtml ( Eloquent $ model ) { $ this -> breadcrumb -> onPreviewHtmlReport ( $ model ) ; return $ this -> view ( 'html' , [ 'model' => $ model ] ) ; }
publish html report
34,285
public function createFromImage ( $ LinodeID , $ ImageID , $ Label = null , $ size = null , $ rootPass = null , $ rootSSHKey = null ) { return $ this -> call ( 'linode.disk.createfromimage' , [ 'LinodeID' => $ LinodeID , 'ImageID' => $ ImageID , 'Label' => $ Label , 'size' => $ size , 'rootPass' => $ rootPass , 'rootSSHKey' => $ rootSSHKey , ] ) ; }
Creates a new disk from a previously imagized disk .
34,286
public function imagize ( $ LinodeID , $ DiskID , $ Label = null , $ Description = null ) { return $ this -> call ( 'linode.disk.imagize' , [ 'LinodeID' => $ LinodeID , 'DiskID' => $ DiskID , 'Label' => $ Label , 'Description' => $ Description , ] ) ; }
Creates a gold - master image for future deployments .
34,287
public static function validateOptions ( array $ config ) { if ( ! isset ( $ config [ 'expected' ] ) ) { throw new \ InvalidArgumentException ( 'expected is required' ) ; } if ( ! is_callable ( $ config [ 'expected' ] ) ) { throw new \ InvalidArgumentException ( 'expected must be callable' ) ; } if ( ! isset ( $ config [ 'hash' ] ) ) { throw new \ InvalidArgumentException ( 'hash is required' ) ; } if ( ! ( $ config [ 'hash' ] ) instanceof HashInterface ) { throw new \ InvalidArgumentException ( 'hash must be an instance of ' . __NAMESPACE__ . '\\HashInterface' ) ; } }
Validates the options provided to an integrity plugin .
34,288
public function getView ( $ design , $ view , $ key = null , $ params = array ( ) ) { $ query = $ this -> processViewParameters ( $ params ) ; $ url = '_design/' . $ design . '/_view/' . $ view . '?' . implode ( '&' , $ query ) ; if ( is_array ( $ key ) ) { $ rtn = $ this -> getViewByPost ( $ url , $ key ) ; } else { if ( ! is_null ( $ key ) ) { if ( is_string ( $ key ) ) { $ key = '"' . $ key . '"' ; } if ( is_bool ( $ key ) ) { $ key = $ key ? 'true' : 'false' ; } $ url .= '&key=' . $ key ; } $ rtn = $ this -> getViewByGet ( $ url ) ; } return $ rtn ; }
Get the results of a CouchDb view as an array of arrays or Chill Document objects .
34,289
public function getAllDocuments ( ) { $ response = $ this -> getViewByGet ( '_all_docs' ) ; return $ this -> asDocs ? $ this -> toDocuments ( $ response ) : $ response ; }
Get all documents in the database .
34,290
public function get ( $ documentId , $ cache = true ) { $ rtn = $ this -> getCache ( $ documentId ) ; if ( ! $ cache || ! $ rtn ) { list ( $ status , $ doc ) = $ this -> sendRequest ( urlencode ( $ documentId ) ) ; if ( $ status == 200 ) { $ rtn = $ this -> setCache ( $ documentId , $ doc ) ; } else { $ rtn = null ; } } return $ this -> asDocs ? $ this -> toDocument ( $ rtn ) : $ rtn ; }
Get document by ID optionally pull from cache if previously queried .
34,291
public function put ( $ documentId , array $ doc ) { $ context = array ( 'http' => array ( ) ) ; $ context [ 'http' ] [ 'method' ] = 'PUT' ; $ context [ 'http' ] [ 'header' ] = 'Content-Type: application/json' ; $ context [ 'http' ] [ 'content' ] = json_encode ( $ doc ) ; $ rev = isset ( $ doc [ '_rev' ] ) ? '?rev=' . $ doc [ '_rev' ] : '' ; list ( $ status , $ response ) = $ this -> sendRequest ( urlencode ( $ documentId ) . $ rev , $ context ) ; if ( $ status == 409 ) { throw new Exception \ Conflict ( 'PUT /' . $ documentId . ' failed.' ) ; } elseif ( $ status != 201 ) { throw new Exception \ Response ( 'PUT /' . $ documentId . ' - Unknown response status.' ) ; } if ( isset ( $ response [ 'id' ] ) ) { return array ( '_id' => $ response [ 'id' ] , '_rev' => $ response [ 'rev' ] ) ; } else { return $ response ; } }
Update or create a document by ID . CouchDb recommends using PUT rather than POST where possible to avoid proxy issues .
34,292
public function post ( array $ doc ) { $ context = array ( 'http' => array ( ) ) ; $ context [ 'http' ] [ 'method' ] = 'POST' ; $ context [ 'http' ] [ 'header' ] = 'Content-Type: application/json' ; $ context [ 'http' ] [ 'content' ] = json_encode ( $ doc ) ; list ( $ status , $ response ) = $ this -> sendRequest ( '' , $ context ) ; if ( $ status != 201 ) { throw new Exception \ Response ( 'POST - Unknown response status.' ) ; } if ( isset ( $ response [ 'id' ] ) ) { return array ( '_id' => $ response [ 'id' ] , '_rev' => $ response [ 'rev' ] ) ; } else { return $ response ; } }
Create a new document by POST . CouchDb recommends using PUT rather than POST where possible to avoid proxy issues .
34,293
public function delete ( $ documentId , $ rev ) { $ context = array ( 'http' => array ( ) ) ; $ context [ 'http' ] [ 'method' ] = 'DELETE' ; list ( $ status , $ response ) = $ this -> sendRequest ( $ documentId . '?rev=' . $ rev , $ context ) ; unset ( $ response ) ; if ( $ status != 200 ) { throw new Exception \ Response ( 'DELETE - Unknown response status.' ) ; } if ( $ this -> getCache ( $ documentId ) ) { unset ( $ this -> cache [ $ documentId ] ) ; } return true ; }
Delete document by ID .
34,294
protected function getCache ( $ documentId ) { if ( isset ( $ this -> cache [ $ documentId ] ) ) { return $ this -> cache [ $ documentId ] ; } return null ; }
Get a document from this class internal cache .
34,295
protected function setCache ( $ documentId , $ value ) { $ this -> cache [ $ documentId ] = $ value ; return $ this -> cache [ $ documentId ] ; }
Put a document into this class internal cache .
34,296
protected function toDocuments ( array $ docs = array ( ) ) { if ( isset ( $ docs [ 'rows' ] ) ) { $ rtn = array ( ) ; foreach ( $ docs [ 'rows' ] as $ row ) { $ rtn [ ] = $ this -> toDocument ( $ row [ 'value' ] ) ; } return $ rtn ; } else { return array ( ) ; } }
Convert many CouchDb documents to Chill Document objects .
34,297
protected function fillableFromArray ( array $ attributes ) { if ( ! empty ( $ attributes ) && property_exists ( $ this , 'defaults' ) ) { $ attributes = array_diff_assoc ( $ attributes , $ this -> defaults ) ; } return parent :: fillableFromArray ( $ attributes ) ; }
Get the fillable attributes of a given array . Don t store the defaults .
34,298
public function getGateway ( $ id ) : GatewayInterface { $ gateway = $ this -> _gateways [ $ id ] ?? null ; if ( $ gateway === null ) { throw new InvalidArgumentException ( "Gateway: `$id` not exist!" ) ; } elseif ( ! $ gateway instanceof GatewayInterface ) { if ( is_string ( $ gateway ) ) { $ gateway = [ 'class' => $ gateway ] ; } if ( is_array ( $ gateway ) ) { $ gateway = ArrayHelper :: merge ( $ this -> gatewayConfig , $ gateway ) ; } $ gateway = $ this -> _gateways [ $ id ] = Yii :: createObject ( $ gateway ) ; } return $ gateway ; }
Get gateway by id given .
34,299
protected function redirect ( $ action , $ params = array ( ) , $ status = 302 ) { return Redirect :: to ( $ this -> url ( $ action , $ params ) , $ status ) ; }
Helper function to redirect to another action in the controller .