idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
10,800
protected function gatherInvokerMiddleware ( $ middleware ) { $ nameMiddleware = $ this -> config [ 'name_middleware' ] ?? [ ] ; $ middlewareGroups = $ this -> config [ 'middleware_groups' ] ?? [ ] ; return Collection :: make ( $ middleware ) -> map ( function ( $ middleware ) use ( $ nameMiddleware , $ middlewareGroup...
Gather the middleware for the invoker with resolved class names .
10,801
protected function resolveServices ( ) { $ this -> app [ 'events' ] -> listen ( ServerLaunching :: class , function ( ) { $ services = Arr :: get ( $ this -> config , 'services' ) ; if ( ! is_array ( $ services ) || empty ( $ services ) ) { return ; } foreach ( $ services as $ config ) { $ this -> resolveService ( $ co...
Resolve and register all configured services .
10,802
public function resolveService ( array $ config ) { $ middleware = $ this -> gatherInvokerMiddleware ( array_merge ( $ this -> config [ 'middleware' ] ?? [ ] , $ config [ 'middleware' ] ?? [ ] ) ) ; return ( new ServiceComponent ( $ this -> app , $ config ) ) -> setContext ( $ this -> context ) -> setDispatcher ( $ thi...
Register a service in the Homer .
10,803
protected function resolveReferences ( ) { $ references = $ this -> config [ 'references' ] ?? [ ] ; if ( ! is_array ( $ references ) || empty ( $ references ) ) { return ; } foreach ( $ references as $ config ) { $ this -> resolveReference ( $ config ) ; } }
Resolve and register all configured references .
10,804
public function resolveReference ( array $ config ) { $ config = $ this -> normalizeClientConfig ( $ config ) ; $ middleware = $ this -> gatherInvokerMiddleware ( array_merge ( $ config [ 'client' ] [ 'middleware' ] ?? [ ] , $ config [ 'middleware' ] ?? [ ] ) ) ; return ( new ReferenceComponent ( $ this -> app , $ conf...
Register a reference in the Homer .
10,805
protected function normalizeClientConfig ( array $ config ) { if ( ! isset ( $ config [ 'client' ] ) ) { $ config [ 'client' ] = [ 'url' => $ config [ 'url' ] ] ; } elseif ( is_string ( $ config [ 'client' ] ) ) { $ client = Arr :: get ( $ this -> config , 'clients.' . $ config [ 'client' ] ) ; if ( $ client == null ) ...
Normalize the client section in reference configurations .
10,806
protected function attachIcon ( Fluent $ menu = null ) { if ( ! is_null ( $ menu ) && ! is_null ( $ icon = $ this -> getAttribute ( 'icon' ) ) ) { $ menu -> icon ( $ icon ) ; } }
Attach icon to menu .
10,807
public function refresh ( ) { $ collection = $ this -> model -> query ( ) -> get ( ) ; $ this -> areaRoles = $ collection ; $ filtered = $ collection -> pluck ( 'area' ) -> unique ( ) -> filter ( function ( $ element ) { return ! is_null ( $ element ) ; } ) ; $ this -> areas = $ filtered -> toArray ( ) ; return $ this ...
Creates levels collection
10,808
public function findMatched ( $ name , $ default = null ) { if ( is_null ( $ name ) ) { return $ default ; } if ( ! in_array ( $ name , $ this -> areas ) ) { return $ default ; } return $ name ; }
Finds matched route prefix name as level name
10,809
public function getUserArea ( ) { if ( auth ( ) -> guest ( ) ) { return '' ; } $ user = auth ( ) -> user ( ) ; $ userRoles = $ user -> roles -> pluck ( 'id' ) ; $ area = null ; $ role = null ; foreach ( $ userRoles as $ userRole ) { $ filtered = $ this -> areaRoles -> where ( 'id' , $ userRole ) ; if ( $ filtered -> co...
Gets user valid level
10,810
public function disable ( DestroyListener $ listener , $ id ) { try { DB :: transaction ( function ( ) use ( $ id ) { $ model = ComponentParams :: where ( 'id' , $ id ) -> first ( ) ; $ data = $ model -> data ; $ data [ 'disabled' ] = true ; $ model -> data = $ data ; $ this -> repository -> saveEntity ( $ model ) ; } ...
Disables ui component
10,811
public function create ( FieldCreator $ listener , Route $ route ) { $ eloquent = Foundation :: make ( 'antares.customfields.model' ) ; $ form = $ this -> presenter -> form ( $ eloquent , 'create' , $ route ) ; $ this -> fireEvent ( 'form' , [ $ eloquent , $ form ] ) ; return $ listener -> showFieldCreator ( compact ( ...
creating new custom field form
10,812
public function store ( FieldCreator $ listener , array $ input ) { $ this -> attachValidator ( ) ; $ validation = $ this -> validator -> on ( 'create' ) -> with ( $ input ) ; if ( $ validation -> fails ( ) ) { if ( app ( 'request' ) -> ajax ( ) ) { return Response :: json ( $ validation -> getMessageBag ( ) -> getMess...
storing custom field in db
10,813
protected function attachValidator ( ) { return ValidatorFacade :: resolver ( function ( $ translator , $ data , $ rules , $ messages ) { return new CustomValidator ( $ translator , $ data , $ rules , $ messages ) ; } ) ; }
attach custom validation to custom field form
10,814
public function update ( FieldUpdater $ listener , $ id , array $ input ) { $ customfield = Foundation :: make ( 'antares.customfields.model' ) -> findOrFail ( $ id ) ; $ this -> attachValidator ( ) ; $ on = $ customfield -> imported ? 'imported' : 'update' ; $ validation = $ this -> validator -> on ( $ on ) -> with ( ...
updates custom field
10,815
public function destroy ( FieldRemover $ listener , $ id ) { $ model = Foundation :: make ( 'antares.customfields.model' ) -> findOrFail ( $ id ) ; try { $ this -> fireEvent ( 'deleting' , [ $ model ] ) ; DB :: transaction ( function ( ) use ( $ model ) { $ model -> delete ( ) ; } ) ; $ this -> fireEvent ( 'deleted' , ...
destroying custom field
10,816
function serialize ( $ charset_encoding = '' ) { if ( $ charset_encoding != '' ) $ this -> content_type = 'application/json; charset=' . $ charset_encoding ; else $ this -> content_type = 'application/json' ; $ this -> payload = serialize_jsonrpcresp ( $ this , $ this -> id , $ charset_encoding ) ; return $ this -> pay...
Returns json representation of the response .
10,817
protected function bootProvider ( ServiceProvider $ provider ) { parent :: bootProvider ( $ provider ) ; if ( method_exists ( $ provider , 'booted' ) ) { Event :: listen ( 'antares.extension: booted' , function ( ) use ( $ provider ) { Event :: fire ( new LoadServiceProviders ( ) ) ; $ this -> call ( [ $ provider , 'bo...
Boot the given service provider .
10,818
protected function validate ( array $ data = array ( ) ) { $ id = auth ( ) -> user ( ) -> id ; if ( empty ( $ data ) ) { return false ; } if ( ( int ) array_get ( $ data , 'secondary_user_id' ) !== $ id ) { return false ; } $ primary = array_get ( $ data , 'primary_user_id' ) ; if ( $ primary === null ) { return false ...
whether user is in preview state
10,819
public function inline ( $ source , $ attributes = [ ] , $ secure = null ) { return '<script type="text/javascript" ' . $ this -> attributes ( $ attributes ) . '>' . $ source . '</script>' . PHP_EOL ; }
Generate an inline to a JavaScript code .
10,820
public function validateNameOnCreate ( $ attribute , $ value , $ parameters ) { $ groupId = Input :: get ( 'group' ) ; $ typeId = Input :: get ( 'type' ) ; $ exists = Foundation :: make ( 'antares.customfields.model.view' ) -> query ( ) -> where ( 'group_id' , $ groupId ) -> where ( 'type_id' , $ typeId ) -> where ( 'n...
checks unique field creation
10,821
public function validateValidatorList ( $ attribute , $ value , $ parameters ) { $ validators = Input :: get ( 'validators' ) ; if ( ! is_null ( $ validators ) ) { foreach ( $ validators as $ index => $ id ) { if ( isset ( $ value [ $ id ] ) && $ value [ $ id ] == '' ) { $ this -> setCustomMessages ( [ "validator_custo...
validates validator list
10,822
public function validateMinChecked ( $ attribute , $ value , $ parameters ) { $ input = Input :: get ( $ attribute ) ; if ( ! isset ( $ parameters [ 0 ] ) OR ! is_numeric ( $ parameters [ 0 ] ) ) { return true ; } if ( count ( $ input ) < $ parameters [ 0 ] ) { $ this -> setCustomMessages ( [ $ attribute => trans ( 'an...
validates when checked checkboxes number is less than config
10,823
public function reorder ( ) { $ data = input ( 'data' ) ; $ pos = input ( 'pos' ) ; if ( is_null ( $ data ) or is_null ( $ pos ) ) { return false ; } $ unserialize = unserialize ( decrypt ( $ data ) ) ; $ modelClass = array_get ( $ unserialize , 'model' ) ; $ datatableClass = array_get ( $ unserialize , 'datatable' ) ;...
Saves colum filtering options
10,824
public function registerViewFinder ( ) { $ this -> app -> singleton ( 'view.finder' , function ( $ app ) { $ paths = $ app -> make ( 'config' ) -> get ( 'view.paths' ) ; return new FileViewFinder ( $ app -> make ( 'files' ) , $ paths ) ; } ) ; }
Register the service provider for view finder .
10,825
protected function registerTheme ( ) { $ this -> app -> singleton ( 'antares.theme' , function ( $ app ) { return new ThemeManager ( $ app ) ; } ) ; $ this -> app -> singleton ( 'antares.theme.finder' , function ( $ app ) { return new Finder ( $ app ) ; } ) ; }
Register the service provider for theme .
10,826
protected function compileViewsInPath ( $ path ) { foreach ( $ this -> laravel [ 'files' ] -> allFiles ( $ path ) as $ file ) { try { $ engine = $ this -> laravel [ 'view' ] -> getEngineFromPath ( $ file ) ; } catch ( InvalidArgumentException $ e ) { Log :: emergency ( $ e ) ; continue ; } $ this -> compileViewFile ( $...
Compile all views files in path .
10,827
public function cancel ( $ params = array ( ) ) { $ arr = array ( "id" => $ params [ "id" ] ) ; $ rawResponse = $ this -> client -> request ( 'delete' , 'api/exchange/orders' . '/' . $ arr [ 'id' ] , $ arr ) ; return $ rawResponse ; }
cancel a created order specified by order id . Optional argument amount is to refund partially .
10,828
protected function components ( ) { $ function = function ( array $ params = null ) { try { $ this -> gridStackAdapter -> scripts ( ) ; if ( ! empty ( $ params ) ) { return app ( 'ui-components' ) -> findAllByResourceAndNames ( uri ( ) , $ params ) ; } return app ( 'ui-components' ) -> findAllByResource ( uri ( ) ) ; }...
Create ui component view helper
10,829
public function setCenter ( $ location , $ title = true , $ markeroptions = array ( ) ) { if ( $ title ) { $ title = \ is_string ( $ title ) ? $ title : null ; if ( ! $ marker = $ this -> addMarker ( $ location , $ title , $ markeroptions ) ) { return false ; } $ location = $ marker [ 'loc' ] ; } elseif ( \ is_string (...
Method to set the center of the map
10,830
public function addMarker ( $ location , $ title = null , $ options = array ( ) ) { if ( \ is_string ( $ location ) ) { if ( ! $ title ) { $ title = $ location ; } $ geocode = $ this -> geocodeAddress ( $ location ) ; if ( ! $ geocode ) { return false ; } $ location = $ geocode [ 'geometry' ] [ 'location' ] ; } elseif ...
Add a marker to the map
10,831
public function extend ( Closure $ callback = null ) { ! is_null ( $ callback ) && call_user_func ( $ callback , $ this -> grid , $ this -> container -> make ( 'request' ) , $ this -> container -> make ( 'translator' ) ) ; return $ this ; }
Extend decoration .
10,832
public function handle ( FormBuilder $ formBuilder ) { $ grid = $ formBuilder -> grid ; $ fieldsets = $ grid -> fieldsets ( ) ; if ( empty ( $ fieldsets ) ) { return false ; } if ( ! isset ( $ grid -> name ) or is_null ( $ grid -> name ) ) { return false ; } $ extension = app ( 'antares.extension' ) -> getActualExtensi...
event handler on view form with customfields
10,833
protected function attributes ( FieldContract $ control ) { $ attributes = array_only ( $ control -> getAttributes ( ) , [ 'id' , 'name' , 'value' , 'label' , 'type' ] ) ; $ attributes [ 'value' ] = ( $ attributes [ 'value' ] instanceof Closure ) ? '' : $ attributes [ 'value' ] ; switch ( $ attributes [ 'type' ] ) { ca...
form attributes resolver
10,834
protected function getOptions ( $ options = null , $ default = [ ] ) { if ( empty ( $ options ) ) { return $ default ; } if ( $ options instanceof Collection ) { return $ options -> toArray ( ) ; } if ( $ options instanceof Closure ) { return $ this -> getOptions ( call_user_func ( $ options ) ) ; } if ( is_array ( $ o...
recursive field options getter
10,835
protected function setCurrentTheme ( Application $ app ) { $ memory = $ app -> make ( 'antares.memory' ) -> makeOrFallback ( ) ; $ app -> make ( 'antares.theme' ) -> setTheme ( $ memory -> get ( 'site.theme.frontend' ) ) ; $ events = $ app -> make ( 'events' ) ; $ events -> listen ( AdminStarted :: class , function ( )...
Set current theme for request .
10,836
protected function setThemeResolver ( Application $ app ) { if ( $ app -> resolved ( 'view' ) ) { $ app -> make ( 'antares.theme' ) -> resolving ( ) ; } else { $ app -> resolving ( 'view' , function ( ) use ( $ app ) { $ app -> make ( 'antares.theme' ) -> resolving ( ) ; } ) ; } }
Boot theme resolver .
10,837
protected function add ( & $ attributes , $ actions ) { $ index = 0 ; $ childs = [ ] ; foreach ( $ actions as $ name => $ callback ) { if ( ! $ callback instanceof Closure ) { continue ; } $ called = call_user_func ( $ callback , $ this -> entity ) ; if ( empty ( $ called ) or ! is_array ( $ called ) ) { continue ; } $...
Adds menu item to breadcrumb menu
10,838
protected function createMenuItem ( $ name , $ attributes ) { $ icon = array_get ( $ attributes , 'attributes.data-icon' , '' ) ; return new Fluent ( [ "icon" => starts_with ( $ icon , 'zmdi' ) ? $ icon : 'zmdi-' . $ icon , "link" => array_get ( $ attributes , 'url' ) , "title" => array_get ( $ attributes , 'title' ) ,...
Creates menu item as Fluent object
10,839
public function updateData ( array $ data ) { foreach ( $ data as $ name => $ value ) { $ this -> data [ $ name ] = $ value ; } }
Updates the settings data by the given array .
10,840
public static function getTypeByExtension ( ExtensionContract $ extension ) : string { if ( $ extension -> isRequired ( ) ) { return self :: TYPE_CORE ; } return self :: TYPE_ADDITIONAL ; }
Returns a type by the given extension .
10,841
protected function component ( ) { $ function = function ( $ params ) { if ( ( $ classname = $ this -> validate ( $ params ) ) === false ) { return '' ; } if ( ( $ object = $ this -> getInstance ( $ classname , $ params ) ) === false ) { return '' ; } $ ajax = $ this -> isAjax ( ) ; $ args = func_get_args ( ) ; if ( ( ...
Creates ui component view helper
10,842
protected function getInstance ( $ classname , $ params ) { $ components = UIComponentsRegistry :: get ( 'ui-components' ) ; if ( is_null ( $ components ) ) { return false ; } $ object = $ components -> first ( function ( $ value , $ key ) use ( $ classname ) { return $ value instanceof $ classname ; } ) ; if ( ! $ obj...
Gets ui component instance from registry
10,843
protected function validate ( $ params ) { if ( array_get ( $ params , 'data.dispatchable' ) === false ) { return false ; } if ( is_null ( $ classname = array_get ( $ params , 'data.classname' ) ) ) { return false ; } try { if ( ! class_exists ( $ classname ) ) { return false ; } } catch ( Exception $ ex ) { return fal...
Validates ui component before render
10,844
private function getCurrentContentDimension ( ) { $ current = Route :: current ( ) ; if ( is_null ( $ current ) ) { return [ ] ; } $ uri = uri ( ) ; $ dimensions = app ( 'config' ) -> get ( "antares/ui-components::dimensions" ) ; return ( isset ( $ dimensions [ $ uri ] ) ) ? $ dimensions [ $ uri ] : [ ] ; }
Gets current uri content dimension parameters
10,845
protected function contentParams ( ) { $ function = function ( $ name = 'ui-components' ) { try { $ dimension = $ this -> getCurrentContentDimension ( ) ; $ repository = app ( 'ui-components' ) ; $ config = app ( 'config' ) -> get ( 'antares/ui-components::content' ) ; $ attributes = $ repository -> findOne ( $ config ...
Gets core content params as ui component
10,846
protected function componentAttributes ( ) { $ function = function ( $ widget ) { $ classname = array_get ( $ widget [ 'attributes' ] , 'attributes.classname' ) ; if ( is_null ( $ classname ) ) { return '' ; } $ instance = null ; $ widgets = Registry :: get ( 'ui-components' ) ; if ( empty ( $ widgets ) ) { return '' ;...
Creates twig view helper to verify whether page use widgetable layout
10,847
public function componentForced ( ) { $ function = function ( $ name = null , array $ params = [ ] ) { if ( is_null ( $ name ) ) { return '' ; } $ components = UIComponentsRegistry :: get ( 'ui-components' , [ ] ) ; $ component = null ; foreach ( $ components as $ item ) { if ( $ item -> getSnakedName ( ) === $ name ) ...
Shows forced ui component
10,848
public function componentsList ( ) { $ function = function ( ) { $ widgets = app ( 'antares.widget' ) -> make ( 'menu.top.right' ) -> items ( ) ; if ( ! isset ( $ widgets [ "ui-components-selector" ] ) ) { return [ ] ; } $ childs = $ widgets [ "ui-components-selector" ] -> childs ; if ( empty ( $ childs ) ) { return [ ...
Prepares ui components list
10,849
public function make ( array $ config ) { $ driver = $ this -> getDriver ( $ config ) ; if ( isset ( $ this -> serverExtensions [ $ driver ] ) ) { $ server = call_user_func ( $ this -> serverExtensions [ $ driver ] , $ config ) ; } elseif ( method_exists ( $ this , $ method = 'create' . Str :: studly ( $ driver ) . 'Dr...
Establish a server based on the configuration .
10,850
protected function getDefaultServerSocket ( array $ config ) { $ unixSock = $ config [ 'unix_sock' ] ?? $ this -> getDefaultUnixSock ( ) ; $ serverSocket = new UnixServerSocket ( $ this -> app , [ 'unix_sock' => $ unixSock ] ) ; $ serverSocket -> setEventHandler ( new ServerEventHandler ) ; return $ serverSocket ; }
Create a default server socket instance for the server .
10,851
protected function configureServer ( $ server , array $ config ) { if ( $ handler = $ this -> parseEventHandler ( $ config ) ) { $ server -> setEventHandler ( $ handler ) ; } if ( isset ( $ config [ 'listens' ] ) && $ config [ 'listens' ] ) { $ this -> configureServerSockets ( $ server , $ config [ 'listens' ] ) ; } if...
Configure the server .
10,852
protected function configureServerSockets ( $ server , array $ serverSockets ) { foreach ( $ serverSockets as $ config ) { $ serverSocket = $ this -> createServerSocket ( $ config ) ; if ( $ handler = $ this -> parseEventHandler ( $ config ) ) { $ serverSocket -> setEventHandler ( $ handler ) ; } $ server -> listen ( $...
Configure the server sockets in the server .
10,853
protected function createServerSocket ( array $ config ) { $ protocol = $ config [ 'protocol' ] ?? 'tcp' ; if ( isset ( $ this -> serverSocketExtensions [ $ protocol ] ) ) { $ serverSocket = call_user_func ( $ this -> serverSocketExtensions [ $ protocol ] , $ this -> app , $ config ) ; if ( ! $ serverSocket instanceof ...
Create a server socket instance .
10,854
protected function configureProcesses ( $ server , array $ processes ) { foreach ( $ processes as $ config ) { $ process = $ this -> createProcess ( $ config ) ; if ( $ handler = $ this -> parseEventHandler ( $ config ) ) { $ process -> setEventHandler ( $ handler ) ; } $ server -> fork ( $ process ) ; } }
Configure the processes in the server .
10,855
public function run ( ) { if ( ! $ this -> validate ( ) ) { return false ; } return DB :: transaction ( function ( ) { $ events = $ this -> getDeferedEvents ( ) ; foreach ( $ events as $ event ) { if ( ! empty ( $ event -> value ) ) { continue ; } $ event -> value = Event :: fire ( $ event -> name ) ; $ event -> save (...
fires all defered events
10,856
public function serializer ( $ type = null ) { $ type = $ type ?? 'php' ; if ( isset ( $ this -> serializers [ $ type ] ) ) { return $ this -> serializers [ $ type ] ; } return $ this -> serializers [ $ type ] = $ this -> resolve ( $ type ) ; }
Get the serializer by type .
10,857
protected function resolveTempFileName ( UploadedFile $ file ) { $ name = $ file -> getClientOriginalName ( ) ; $ extension = File :: extension ( $ name ) ; $ subdir = sha1 ( time ( ) ) ; $ directory = storage_path ( ) . '/app/uploads/' . $ subdir ; $ filename = sha1 ( time ( ) . time ( ) ) . ".{$extension}" ; return [...
upload file temporary resolver
10,858
protected function unzip ( $ source , $ destination ) { @ mkdir ( $ destination , 0777 , true ) ; $ zip = new ZipArchive ; if ( $ zip -> open ( $ source ) === true ) { $ zip -> extractTo ( $ destination ) ; $ zip -> close ( ) ; return true ; } else { throw new \ Exception ( 'Unable to open module package file' ) ; } }
unziping module package
10,859
protected function getPackageName ( $ path ) { if ( ends_with ( $ path , '.zip' ) ) { $ path = dirname ( $ path ) ; } $ manifest = new Manifest ( new Filesystem ( ) , $ path ) ; return $ manifest -> get ( 'package' ) ; }
gets theme name by manifest
10,860
protected function uniqueMessages ( $ messageBag , $ messageBagFromCustom = null ) { if ( is_null ( $ messageBagFromCustom ) ) { return $ messageBag ; } $ messages = $ messageBagFromCustom -> getMessages ( ) ; foreach ( $ messages as $ key => $ value ) { if ( empty ( $ value ) ) { continue ; } foreach ( $ value as $ me...
unify message bugs from custom validators and from form
10,861
protected function whenValidated ( $ messageBag , $ sendHeaders ) { $ messages = empty ( $ messageBag ) ? [ ] : $ messageBag -> getMessages ( ) ; if ( $ this -> request -> ajax ( ) && $ sendHeaders ) { $ return = [ ] ; foreach ( $ messages as $ key => $ phrases ) { if ( str_contains ( $ key , '[]' ) ) { $ key = str_rep...
after form validation
10,862
protected function response ( array $ messages = [ ] ) { $ response = Response :: json ( $ messages , 200 ) ; $ response -> sendHeaders ( ) ; $ response -> sendContent ( ) ; app ( ) -> terminate ( ) ; exit ; }
send proper headers and terminate application
10,863
protected function shouldContainValueField ( $ typeId = null ) { if ( is_null ( $ typeId ) ) { return false ; } $ model = FieldType :: query ( ) -> findOrFail ( $ typeId ) ; return $ model -> name == 'select' or ( $ model -> name == 'input' and in_array ( $ model -> type , [ 'radio' , 'checkbox' ] ) ) ; }
Whether field should contain value input
10,864
public function configure ( Listener $ listener , Fluent $ extension ) { if ( ! Extension :: started ( $ extension -> get ( 'name' ) ) ) { return $ listener -> abortWhenRequirementMismatched ( ) ; } $ this -> presenter -> setCategory ( $ this -> category ) ; $ memory = Foundation :: memory ( ) ; $ activeConfig = ( arra...
View edit extension configuration page .
10,865
public function create ( Listener $ listener , $ category = null ) { $ eloquent = Foundation :: make ( 'antares.component' ) ; $ form = $ this -> presenter -> create ( $ eloquent , $ category , $ this -> validator ) ; Event :: fire ( "antares.form: extension.create" , [ $ eloquent , $ form ] ) ; Event :: fire ( new For...
create module form
10,866
public function upload ( array $ input ) { $ file = $ this -> resolveTempFileName ( $ input [ 'file' ] ) ; $ input [ 'file' ] -> directory = $ file [ 'directory' ] ; $ input [ 'file' ] -> filename = $ file [ 'filename' ] ; Validator :: resolver ( function ( $ translator , $ data , $ rules , $ messages ) { return new Cu...
upload and validate module compressed file
10,867
public function extract ( Listener $ listener , $ category = null , array $ input ) { try { $ subdir = ! is_null ( $ category ) ? $ category : 'addons' ; $ target = realpath ( app_path ( ) . "/../src/modules/{$subdir}" ) ; if ( ! is_dir ( $ target ) ) { throw new \ Exception ( 'Invalid path of module provided' ) ; } $ ...
extraction of module package
10,868
public function push ( $ params ) { foreach ( $ params as $ key => $ value ) { array_set ( $ this -> params , $ key , $ value ) ; } return $ this ; }
adds element into params container
10,869
public function to_leverage ( $ params = array ( ) ) { $ arr = array ( "amount" => $ params [ "amount" ] , "currency" => $ params [ "currency" ] ) ; $ rawResponse = $ this -> client -> request ( 'post' , 'api/exchange/transfers/to_leverage' , $ arr ) ; return $ rawResponse ; }
Transfer Balance to Leverage .
10,870
public function from_leverage ( $ params = array ( ) ) { $ arr = array ( "amount" => $ params [ "amount" ] , "currency" => $ params [ "currency" ] ) ; $ rawResponse = $ this -> client -> request ( 'post' , 'api/exchange/transfers/from_leverage' , $ arr ) ; return $ rawResponse ; }
Transfer Balance from Leverage .
10,871
protected function googlize ( ) { if ( ! $ this -> client -> getOption ( 'authurl' ) ) { $ this -> client -> setOption ( 'authurl' , 'https://accounts.google.com/o/oauth2/auth' ) ; } if ( ! $ this -> client -> getOption ( 'tokenurl' ) ) { $ this -> client -> setOption ( 'tokenurl' , 'https://accounts.google.com/o/oauth...
Method to fill in Google - specific OAuth settings
10,872
public function removeCalendar ( $ calendarID ) { if ( $ this -> isAuthenticated ( ) ) { $ jdata = $ this -> query ( 'https://www.googleapis.com/calendar/v3/users/me/calendarList/' . urlencode ( $ calendarID ) , null , null , 'delete' ) ; if ( $ jdata -> body != '' ) { throw new UnexpectedValueException ( "Unexpected d...
Method to remove a calendar from a user s calendar list
10,873
public function createCalendar ( $ title , $ options = array ( ) ) { if ( $ this -> isAuthenticated ( ) ) { $ options [ 'summary' ] = $ title ; $ url = 'https://www.googleapis.com/calendar/v3/calendars' ; $ jdata = $ this -> query ( $ url , json_encode ( $ options ) , array ( 'Content-type' => 'application/json' ) , 'p...
Method to create a Google Calendar
10,874
public function editEvent ( $ calendarID , $ eventID , $ options , $ notify = false ) { if ( $ this -> isAuthenticated ( ) ) { $ url = 'https://www.googleapis.com/calendar/v3/calendars/' ; $ url .= urlencode ( $ calendarID ) . '/events/' . urlencode ( $ eventID ) . ( $ notify ? '?sendNotifications=true' : '' ) ; $ jdat...
Method to edit a Google Calendar event
10,875
public function run ( OperationHandlerContract $ handler , array $ extensionsNames ) { if ( count ( $ extensionsNames ) === 0 ) { return $ handler -> operationInfo ( new Operation ( 'No extensions to install. Skipping composer.' ) ) ; } $ required = ( array ) config ( 'components.required' , [ ] ) ; $ modules = [ ] ; i...
Run the operation for composer .
10,876
public function publish ( Listener $ listener , array $ input ) { $ queues = $ this -> publisher -> queued ( ) ; try { $ this -> publisher -> connect ( $ input ) ; } catch ( ServerException $ e ) { Log :: emergency ( $ e ) ; $ this -> session -> forget ( 'antares.ftp' ) ; return $ listener -> publishingHasFailed ( [ 'e...
Publish process .
10,877
protected function getActiveMenuRoute ( ) { if ( is_null ( $ this -> activeMenuRoute ) ) { $ this -> activeMenuRoute = Registry :: get ( 'active_menu_route' ) ; } return $ this -> activeMenuRoute ; }
Active menu getter
10,878
public function isActive ( ) { if ( ! isset ( $ this -> attributes [ 'link' ] ) ) { return false ; } $ childs = isset ( $ this -> attributes [ 'childs' ] ) ? $ this -> attributes [ 'childs' ] : [ ] ; if ( empty ( $ childs ) ) { return $ this -> compare ( $ this -> attributes [ 'link' ] ) ; } foreach ( $ childs as $ chi...
check whether element has same request url and link attribute
10,879
protected function compare ( $ url ) { $ activeMenuRouteUrl = $ this -> getActiveMenuRoute ( ) ; if ( $ this -> url == $ url or $ url == $ activeMenuRouteUrl ) { return true ; } $ segments = $ this -> segments ; $ count = count ( $ segments ) ; if ( $ count !== count ( array_filter ( explode ( '/' , str_replace ( url (...
Whether menu item is active
10,880
public function isFirstChildActive ( ) { $ url = array_get ( $ this -> attributes , 'link' , '' ) ; if ( $ this -> getActiveMenuRoute ( ) == $ url ) { return true ; } @ list ( $ domain , $ area , $ module , $ action ) = explode ( '/' , str_replace ( 'http://' , '' , $ url ) ) ; if ( $ this -> url == $ url ) { return tr...
Whether first child is active
10,881
private function importSettings ( OperationHandlerContract $ handler , ExtensionContract $ extension ) { $ settingsPath = $ extension -> getPath ( ) . '/resources/config/settings.php' ; if ( File :: exists ( $ settingsPath ) ) { $ settings = $ this -> settingsFactory -> createFromConfig ( $ extension -> getPath ( ) . '...
Imports the default settings to the
10,882
public function edgeNGram ( $ str_phrase , $ int_min_length = 1 ) { $ arr_tokens = [ ] ; $ str_phrase = preg_replace ( '#[^a-z0-9 ]#i' , '' , $ str_phrase ) ; $ arr_words = explode ( ' ' , $ str_phrase ) ; $ arr_tokens = array_merge ( $ arr_tokens , $ arr_words ) ; foreach ( $ arr_words as $ str_word ) { $ int_letters ...
Change an input string into a list of edge N - Gram tokens for autocomplete usage
10,883
public function setTheme ( $ theme ) { if ( ! is_null ( $ this -> theme ) ) { $ this -> resolved && $ this -> resetViewPaths ( ) ; $ this -> dispatcher -> fire ( "antares.theme.unset: {$this->theme}" ) ; $ this -> dispatcher -> fire ( new ThemeUnset ( $ this -> theme ) ) ; } $ this -> theme = $ theme ; $ this -> dispat...
Set the theme this would also load the theme manifest .
10,884
public function boot ( ) { if ( $ this -> booted ) { return false ; } $ this -> booted = true ; $ themePath = $ this -> getThemePath ( ) ; $ autoload = $ this -> getThemeAutoloadFiles ( $ themePath ) ; foreach ( $ autoload as $ file ) { $ file = ltrim ( $ file , '/' ) ; $ this -> files -> requireOnce ( "{$themePath}/{$...
Boot and Load theme starter files .
10,885
public function resolving ( ) { if ( $ this -> resolved ) { return false ; } $ this -> resolved = true ; $ this -> dispatcher -> fire ( 'antares.theme.resolving' , [ $ this , $ this -> app ] ) ; $ this -> dispatcher -> fire ( new ThemeResolving ( $ this , $ this -> app ) ) ; $ this -> setViewPaths ( ) ; return true ; }
Resolving the theme .
10,886
public function getAvailableThemePaths ( ) { $ paths = [ ] ; $ themePaths = $ this -> getThemePaths ( ) ; foreach ( $ themePaths as $ path ) { $ this -> files -> isDirectory ( base_path ( $ path ) ) && $ paths [ ] = base_path ( $ path ) ; } return $ paths ; }
Get available theme paths .
10,887
protected function setViewPaths ( ) { $ viewFinder = $ this -> app -> make ( 'view.finder' ) ; $ themePaths = $ this -> getAvailableThemePaths ( ) ; if ( ! empty ( $ themePaths ) ) { $ viewFinder -> setPaths ( array_merge ( $ themePaths , $ viewFinder -> getPaths ( ) ) ) ; } }
Set theme paths to view file finder paths .
10,888
protected function resetViewPaths ( ) { $ viewFinder = $ this -> app -> make ( 'view.finder' ) ; $ paths = $ viewFinder -> getPaths ( ) ; foreach ( $ this -> getThemePaths ( ) as $ themePath ) { ( $ paths [ 0 ] === $ themePath ) && array_shift ( $ paths ) ; } $ viewFinder -> setPaths ( $ paths ) ; }
Reset theme paths to view file finder paths .
10,889
protected function registerSupportedMailer ( ) { $ this -> app -> singleton ( 'antares.support.mail' , function ( $ app ) { $ this -> registerSwiftMailer ( ) ; $ mailer = new Mailer ( $ app -> make ( 'view' ) , $ app -> make ( 'antares.swift.mailer' ) , $ app -> make ( 'events' ) ) ; if ( $ app -> bound ( 'queue' ) ) {...
Register the support mailer
10,890
protected function validateRequest ( Request $ request ) { if ( php_sapi_name ( ) === 'cli' ) { return false ; } $ route = call_user_func ( $ request -> getRouteResolver ( ) ) ; $ ignored = $ this -> container -> make ( 'config' ) -> get ( 'antares/ui-components::ignore' ) ; $ action = $ route -> getAction ( ) ; if ( i...
Validates ajax request
10,891
public function createDocument ( array $ arr_data = null ) { $ obj_doc = new Document ( $ this ) ; if ( null !== $ arr_data ) { foreach ( $ arr_data as $ str_field => $ mix_value ) { $ obj_doc -> __set ( $ str_field , $ mix_value ) ; } } return $ obj_doc ; }
Create and return a Document with this Schema
10,892
public function addAutoField ( $ str_name , $ mix_value ) { switch ( gettype ( $ mix_value ) ) { case 'integer' : case 'double' : $ this -> addNumber ( $ str_name ) ; break ; case 'object' : if ( $ mix_value instanceof \ DateTime ) { $ this -> addDate ( $ str_name ) ; } elseif ( method_exists ( $ mix_value , '__toStrin...
Determine field type automatically
10,893
public function discoverFromHtml ( $ html ) { $ links = $ this -> findLinks ( $ html ) ; if ( ! $ link = reset ( $ links ) ) { return ; } $ type = null ; switch ( $ link [ 'type' ] ) { case 'application/json+oembed' : $ type = Provider :: TYPE_JSON ; break ; case 'text/xml+oembed' : $ type = Provider :: TYPE_XML ; brea...
Discovers and API endpoint from an HTML document
10,894
public function getEndpointUrl ( $ url ) { $ components = parse_url ( $ url ) ; if ( isset ( $ components [ 'query' ] ) ) { parse_str ( $ components [ 'query' ] , $ query ) ; unset ( $ query [ 'url' ] ) ; $ components [ 'query' ] = http_build_query ( $ query ) ; } return $ this -> assembleUrl ( $ components ) ; }
Returns an endpoint URL from an URL with the url param pre - filled
10,895
public function getEventCallbacks ( $ event = null ) { if ( $ event === null ) { return $ this -> eventCallbacks ; } return $ this -> eventCallbacks [ strtolower ( $ event ) ] ?? [ ] ; }
Get all callbacks for the given event .
10,896
protected function dispatchEventToEventCallbacks ( $ event , $ arguments ) { foreach ( $ this -> getEventCallbacks ( $ event ) as $ callback ) { try { call_user_func_array ( $ callback , $ arguments ) ; } catch ( Exception $ e ) { $ this -> handleException ( $ e ) ; } catch ( Throwable $ e ) { $ this -> handleException...
Dispatch the event to the event callbacks .
10,897
protected function dispatchEventToEventHandler ( $ event , $ arguments ) { if ( $ this -> eventHandler == null || ! method_exists ( $ this -> eventHandler , $ method = "on{$event}" ) ) { return ; } try { $ this -> eventHandler -> $ method ( ... $ arguments ) ; } catch ( Exception $ e ) { $ this -> handleException ( $ e...
Dispatch the event to the event handler .
10,898
protected function handleException ( Exception $ e ) { $ handler = $ this -> app -> make ( ExceptionHandler :: class ) ; $ handler -> report ( $ e ) ; try { $ handler -> renderForConsole ( $ this -> app -> make ( OutputInterface :: class ) , $ e ) ; } catch ( Throwable $ e ) { } }
Handle the exception with the exception handler .
10,899
public function extend ( Closure $ callback ) { $ instance = $ this -> retrieve ( ) ; call_user_func ( $ callback , $ instance ) ; return $ instance ; }
Extend Messages instance from session .