idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
11,200
protected function withMiddleware ( $ invoker , $ interface , $ config ) { if ( empty ( $ this -> middleware ) ) { return $ invoker ; } return new MiddlewareInvoker ( $ this -> container , $ interface , $ invoker , $ this -> middleware , $ config ) ; }
Add middleware to the invoker .
11,201
function payload ( ) { if ( $ this -> Verb == 'GET' || $ this -> Verb == 'HEAD' || $ this -> Verb == 'TRACE' ) { return '' ; } else { $ params = $ this -> Parameters ; if ( $ this -> NameVar != null ) { $ params [ $ this -> NameVar ] = $ this -> Name ; } return $ this -> _payload ( $ params ) ; } }
No request body for GET requests as all params are put in the url
11,202
function getHttpAccept ( ) { if ( isset ( $ _GET [ $ this -> FormatVar ] ) ) { return $ _GET [ $ this -> FormatVar ] ; } else { if ( isset ( $ _POST [ 'http_accept' ] ) ) $ acceptList = explode ( ',' , $ _POST [ 'http_accept' ] ) ; else if ( isset ( $ _POST [ 'HTTP_ACCEPT' ] ) ) $ acceptList = explode ( ',' , $ _POST [...
Method used server - side to retrieve the accepted value from HTTP . Same logic as used by ezjscore for the call view but tries to respect weights in http Accept header
11,203
function setContentType ( $ typeAlias ) { if ( isset ( self :: $ KnownContentTypes [ $ typeAlias ] ) ) { $ this -> ContentType = self :: $ KnownContentTypes [ $ typeAlias ] ; return true ; } $ decodableType = $ this -> mimeTypeToEncodeType ( $ typeAlias ) ; if ( isset ( self :: $ KnownContentTypes [ $ decodableType ] )...
Only sets content - type header if we know how to serialize it later
11,204
protected function registerAssetSymlinker ( ) { $ this -> app -> singleton ( AssetSymlinker :: class , function ( ) { $ publicPath = sandbox_path ( 'packages/antares' ) ; return new AssetSymlinker ( new Filesystem , $ publicPath ) ; } ) ; $ this -> app -> alias ( AssetSymlinker :: class , 'asset.symlinker' ) ; }
registering asset symlinker
11,205
public function login ( User $ user ) { if ( ! $ this -> isActive ( ) ) { session ( ) -> put ( $ this -> originalUserKey , auth ( ) -> user ( ) -> id ) ; } auth ( ) -> loginUsingId ( $ user -> id ) ; session ( ) -> put ( $ this -> isActiveKey , true ) ; }
Impersonate the given user Store the currently logged in user s id in session . Log the new user in
11,206
public function logout ( ) { if ( ! $ this -> isActive ( ) ) { return false ; } auth ( ) -> logout ( ) ; $ originalUserId = session ( ) -> get ( $ this -> originalUserKey ) ; if ( $ originalUserId ) { auth ( ) -> loginUsingId ( $ originalUserId ) ; } session ( ) -> forget ( $ this -> originalUserKey ) ; session ( ) -> ...
Logout the impersonated user Log back in as the orignal user Delete the impersonation session
11,207
protected function lookForChild ( $ item , $ after ) { if ( str_contains ( $ after , '.' ) ) { $ found = [ ] ; $ this -> lookInDeep ( $ this -> items , $ after , $ item , $ found ) ; if ( ! empty ( $ found ) ) { $ this -> items [ key ( $ found ) ] -> childs = current ( $ found ) ; return $ item ; } } return false ; }
does menu item should be placed before or after child item
11,208
protected function lookInDeep ( array $ elements , $ after , $ item , & $ buffer = [ ] , & $ return = '' , $ current = null ) { $ branch = array ( ) ; foreach ( $ elements as $ key => $ element ) { $ return = strlen ( $ return ) <= 0 ? $ current : $ return . '.' . $ current ; if ( $ return . '.' . $ key == $ after ) { ...
looking for matched item in nesty array configuration
11,209
protected function buffer ( & $ buffer , $ elements , $ item , $ after , $ current ) { foreach ( $ elements as $ keyname => $ element ) { $ found = last ( explode ( '.' , $ after ) ) ; if ( $ keyname == $ found ) { $ buffer [ $ current ] [ $ keyname ] = $ element ; $ buffer [ $ current ] [ $ item -> id ] = $ item ; } e...
buffer item into container
11,210
public function add ( $ id , $ location = '#' ) { if ( $ location === '<' && count ( $ keys = array_keys ( $ this -> items ) ) > 0 ) { return $ this -> addBefore ( $ id , $ keys [ 0 ] ) ; } elseif ( preg_match ( '/^(<|>|\^):(.+)$/' , $ location , $ matches ) && count ( $ matches ) >= 3 ) { return $ this -> pickTraverse...
Add a new item by prepend or append .
11,211
public function has ( $ key ) { $ key = implode ( '.childs.' , explode ( '.' , $ key ) ) ; return ! is_null ( data_get ( $ this -> items , $ key ) ) ; }
Check whether item by id exists .
11,212
public function get ( $ key ) { $ item = $ this -> pool -> getItem ( $ key ) ; if ( $ item -> isMiss ( ) === false ) { return $ this -> serializer -> deserialize ( $ item -> get ( ) ) ; } else { return null ; } }
Gets a cache entry returning null if not in cache
11,213
protected function save ( $ key , $ value , $ isNew = false , $ brandId = false , $ flag = null ) { try { DB :: transaction ( function ( ) use ( $ key , $ value , $ isNew , $ brandId , $ flag ) { $ name = str_replace ( 'acl_antares/' , '' , $ key ) ; if ( str_contains ( $ key , 'acl_antares' ) ) { $ this -> resolver ( ...
updates module permission
11,214
public function import ( OperationHandlerContract $ handler , ExtensionContract $ extension , bool $ reload = false ) { $ name = $ extension -> getPackage ( ) -> getName ( ) ; $ filePath = $ extension -> getPath ( ) . '/acl.php' ; if ( ! File :: exists ( $ filePath ) ) { $ handler -> operationInfo ( new Operation ( 'Sk...
Import ACL of the given extension .
11,215
protected function form ( ) { return app ( 'antares.form' ) -> of ( 'security' , function ( FormGrid $ form ) { $ form -> name ( 'Security Form' ) ; $ form -> fieldset ( function ( Fieldset $ fieldset ) { $ fieldset -> control ( 'button' , 'button' ) -> attributes ( [ 'type' => 'submit' , 'class' => 'btn btn-primary' ,...
Creates form instance
11,216
public function submit ( FormResponseContract $ listener , Request $ request ) { $ response = ( array ) $ this -> dispatcher -> fire ( new SecurityFormSubmitted ( $ listener , $ request ) ) ; if ( count ( $ response ) ) { return $ response [ 0 ] ; } return null ; }
Fires an event of the security form with the given request instance .
11,217
public function save ( array $ params = [ ] ) { $ index = array_get ( $ params , 'index' ) ; $ visibility = array_get ( $ params , 'visible' ) ; $ key = array_get ( $ params , 'key' ) ; if ( is_null ( $ index ) or is_null ( $ visibility ) or is_null ( $ key ) ) { return false ; } $ request = request ( ) ; $ session = $...
Saves visibility columns definition
11,218
public function getColumns ( ) { $ session = request ( ) -> session ( ) ; $ key = $ this -> key ( ) ; if ( ! $ session -> has ( $ key ) ) { return $ this -> columns ; } $ config = $ session -> get ( $ key ) ; foreach ( $ this -> columns as $ index => $ column ) { if ( ! isset ( $ config [ $ index ] ) ) { continue ; } $...
Gets column visibility definition
11,219
protected function prepareData ( ) { $ dataProvider = $ this -> attributes [ 'dataProvider' ] ; $ urlPattern = $ this -> attributes [ 'urlPattern' ] ; $ return = new Collection ( ) ; foreach ( $ dataProvider as $ item ) { $ name = isset ( $ item -> title ) ? $ item -> title : $ item -> name ; $ url = str_replace ( '{id...
prepares data provider items
11,220
protected function scripts ( ) { $ container = $ this -> app -> make ( 'antares.asset' ) -> container ( 'antares/foundation::scripts' ) ; $ container -> inlineScript ( 'version-box' , $ this -> inline ( ) ) ; }
inline scripts used by helper
11,221
public static function parse ( string $ response ) : Response { $ responseObject = new Response ( ) ; if ( preg_match ( '/^HTTP\/([0-9]\.[0-9]) ([0-9]{3}) .*\r\n/' , $ response , $ matches ) !== 1 ) { throw new \ RuntimeException ( 'Could not parse response (error 1).' ) ; } [ $ line , $ protocolVersion , $ statusCode ...
Parses a raw response string including headers and body and returns a Response object .
11,222
public function setStatusCode ( int $ statusCode , string $ reasonPhrase = null ) : Response { if ( $ statusCode < 100 || $ statusCode > 999 ) { throw new \ InvalidArgumentException ( 'Invalid status code: ' . $ statusCode ) ; } if ( $ reasonPhrase === null ) { $ reasonPhrase = isset ( self :: $ statusCodes [ $ status...
Sets the status code of this response .
11,223
public function setCookie ( Cookie $ cookie ) : Response { $ this -> cookies [ ] = $ cookie ; $ this -> addHeader ( 'Set-Cookie' , ( string ) $ cookie ) ; return $ this ; }
Sets a cookie on this response .
11,224
public function send ( ) : bool { if ( headers_sent ( ) ) { return false ; } header ( $ this -> getStartLine ( ) ) ; foreach ( $ this -> getHeaders ( ) as $ name => $ values ) { foreach ( $ values as $ value ) { header ( $ name . ': ' . $ value , false ) ; } } echo ( string ) $ this -> body ; flush ( ) ; return true ; ...
Sends the response .
11,225
private function prepareRequestParams ( $ obj_request ) { $ obj_params = $ obj_request -> mutableParams ( ) ; $ obj_spec = $ obj_params -> mutableIndexSpec ( ) -> setName ( $ this -> str_index_name ) ; if ( null !== $ this -> str_namespace ) { $ obj_spec -> setNamespace ( $ this -> str_namespace ) ; } return $ obj_para...
Prepare the request parameters
11,226
public function put ( array $ arr_docs ) { $ obj_request = new IndexDocumentRequest ( ) ; $ obj_params = $ this -> prepareRequestParams ( $ obj_request ) ; $ obj_mapper = new Mapper ( ) ; foreach ( $ arr_docs as $ obj_doc ) { $ obj_mapper -> toGoogle ( $ obj_doc , $ obj_params -> addDocument ( ) ) ; } $ this -> execute...
Put one or more documents into the index
11,227
public function search ( Query $ obj_query ) { $ obj_request = new SearchRequest ( ) ; $ obj_params = $ this -> prepareRequestParams ( $ obj_request ) ; $ obj_params -> setQuery ( $ obj_query -> getQuery ( ) ) -> setLimit ( $ obj_query -> getLimit ( ) ) -> setOffset ( $ obj_query -> getOffset ( ) ) ; $ arr_sorts = $ ob...
Run a Search Query
11,228
public function getDocById ( $ str_id ) { $ obj_request = new ListDocumentsRequest ( ) ; $ obj_params = $ this -> prepareRequestParams ( $ obj_request ) ; $ obj_params -> setStartDocId ( $ str_id ) -> setLimit ( 1 ) ; $ this -> execute ( 'ListDocuments' , $ obj_request , new ListDocumentsResponse ( ) ) ; $ obj_response...
Return a single document by ID
11,229
public function delete ( array $ arr_ids ) { $ obj_request = new DeleteDocumentRequest ( ) ; $ obj_params = $ this -> prepareRequestParams ( $ obj_request ) ; foreach ( $ arr_ids as $ str_id ) { $ obj_params -> addDocId ( $ str_id ) ; } $ this -> execute ( 'DeleteDocument' , $ obj_request , new DeleteDocumentResponse (...
Delete one or more documents by ID
11,230
private function execute ( $ str_method , ProtocolMessage $ obj_request , ProtocolMessage $ obj_response ) { try { $ this -> obj_last_request = $ obj_request ; $ this -> obj_last_response = null ; ApiProxy :: makeSyncCall ( 'search' , $ str_method , $ obj_request , $ obj_response , 60 ) ; $ this -> obj_last_response = ...
Run a Request
11,231
private function processSearchResponse ( ) { $ obj_search_response = $ this -> obj_last_response ; $ obj_response = ( object ) [ 'status' => $ this -> describeStatusCode ( $ obj_search_response -> getStatus ( ) -> getCode ( ) ) , 'hits' => $ obj_search_response -> getMatchedCount ( ) , 'count' => $ obj_search_response ...
Process a search response
11,232
private function processListResponse ( ) { $ obj_list_response = $ this -> obj_last_response ; $ obj_response = ( object ) [ 'status' => $ this -> describeStatusCode ( $ obj_list_response -> getStatus ( ) -> getCode ( ) ) , 'count' => $ obj_list_response -> getDocumentSize ( ) , 'docs' => [ ] ] ; $ obj_mapper = new Map...
Process a document list response
11,233
public function setInvocation ( Invocation $ invocation ) { $ this -> invocation = $ invocation ; $ this -> setAttachments ( $ invocation -> getAttachments ( ) ) ; }
Set the invocation instance .
11,234
public function recover ( ) { $ validator = ValidatorFacade :: make ( [ ] , [ ] ) ; foreach ( $ this -> messages as $ key => $ value ) { foreach ( Arr :: wrap ( $ value ) as $ message ) { $ validator -> errors ( ) -> add ( $ key , $ message ) ; } } return $ validator ; }
Recover the validator from the serialization .
11,235
public function bootMenus ( ) { $ name = 'menu.top.right' ; view ( ) -> composer ( 'antares/foundation::*' , function ( ) use ( $ name ) { if ( ! Registry :: isRegistered ( 'menu.' . $ name ) ) { $ this -> app -> instance ( $ name , $ this -> app -> make ( 'antares.widget' ) -> make ( $ name ) ) ; $ selector = new Comp...
Booting top left menu
11,236
protected function setFilename ( $ filename ) { if ( is_string ( $ filename ) ) { if ( is_readable ( $ filename ) ) { $ this -> filename = $ filename ; } elseif ( file_exists ( $ filename ) ) { throw new \ InvalidArgumentException ( "File '$filename' isn't readable." ) ; } else { throw new \ InvalidArgumentException ( ...
Sets the file path of the HTML source file .
11,237
protected function registerLogFilename ( ) { $ handlers = $ this -> app -> make ( 'log' ) -> getMonolog ( ) -> getHandlers ( ) ; foreach ( $ handlers as $ handler ) { if ( ! $ handler instanceof RotatingFileHandler ) { continue ; } $ filename = ( php_sapi_name ( ) === 'cli' ) ? 'laravel-cli' : 'laravel' ; $ handler -> ...
Registers log filename
11,238
protected function registerWidgetsFinder ( ) { $ this -> app -> singleton ( 'antares.ui-components.finder' , function ( $ app ) { $ config = [ 'path.app' => $ app -> make ( 'path' ) , 'path.base' => $ app -> make ( 'path.base' ) , ] ; return new Finder ( $ app -> make ( 'files' ) , $ config ) ; } ) ; }
Register the service provider for Extension Finder .
11,239
protected function registerEvents ( ) { $ this -> app -> terminating ( function ( ) { $ this -> app -> make ( 'events' ) -> fire ( 'antares.done' ) ; $ this -> app -> make ( 'events' ) -> fire ( new AntaresDone ( ) ) ; } ) ; }
Register additional events for application .
11,240
protected function assignAreaTemplate ( ) { $ path = realpath ( __DIR__ . '/../../' ) ; $ area = area ( ) ; if ( ! is_null ( $ area ) && is_dir ( resource_path ( 'views' . DIRECTORY_SEPARATOR . $ area ) ) ) { $ this -> addViewComponent ( $ area , 'antares/foundation' , $ path . '/resources/views' ) ; } $ this -> addVie...
Assign area template based on current area
11,241
protected function runtime ( ) { $ filesystem = app ( Filesystem :: class ) ; $ files = $ filesystem -> glob ( storage_path ( 'license' ) . '/*.key' ) ; if ( ! empty ( $ files ) ) { app ( 'antares.memory' ) -> make ( 'runtime' ) -> push ( 'instance_key' , $ filesystem -> get ( $ files [ 0 ] ) ) ; } }
runtime application configuration
11,242
protected function bootWidgetsRouting ( ) { try { $ widgets = $ this -> app -> make ( 'antares.ui-components.finder' ) -> detectRoutes ( ) ; $ widgets -> each ( function ( $ widget ) { $ widget :: routes ( ) ; } ) ; return true ; } catch ( Exception $ e ) { Log :: emergency ( $ e ) ; return false ; } }
boot widgets routing
11,243
protected function bootNotificationVariables ( ) { if ( ! app ( 'antares.installed' ) ) { return ; } if ( class_exists ( VariablesService :: class ) ) { $ notification = app ( ) -> make ( VariablesService :: class ) ; $ notification -> register ( 'foundation' , new CoreVariablesProvider ( ) ) ; } }
appends notification variables
11,244
protected function getCustomfields ( ) { $ extensions = extensions ( ) ; $ return = [ ] ; event ( 'customfields.before.search' , $ return ) ; event ( new BeforeSearch ( $ return ) ) ; foreach ( $ extensions as $ name => $ extension ) { $ name = 'antares/' . str_replace ( [ 'component-' , 'module-' ] , '' , $ extension ...
Gets extensions with customfields
11,245
private function validate ( array $ config = [ ] ) { $ customfields = [ ] ; foreach ( $ config as $ classname => $ customfield ) { if ( ! class_exists ( $ classname ) ) { continue ; } array_push ( $ customfields , $ customfield ) ; } return ! empty ( $ customfields ) ; }
Whether customfield configuration is valid
11,246
public function getConfigurable ( $ group = null ) { if ( empty ( $ this -> configurable ) ) { foreach ( $ this -> customfields as $ category => $ customfield ) { foreach ( $ customfield as $ field ) { if ( ! $ field -> configurable ( ) ) { continue ; } $ this -> configurable [ strtolower ( last ( explode ( '\\' , $ ca...
Gets configurable customfields
11,247
protected function setupMiddleware ( ) { $ this -> middleware ( 'antares.auth' ) ; $ this -> middleware ( 'antares.manage' ) ; $ this -> middleware ( 'antares.csrf' ) ; $ this -> canMiddleware ( 'install' ) ; $ this -> canMiddleware ( 'uninstall' ) ; $ this -> canMiddleware ( 'activate' ) ; $ this -> canMiddleware ( 'd...
Setup controller filters .
11,248
protected function addClass ( $ cssClass , & $ attributes ) { $ class = array_get ( $ attributes , 'class' , '' ) ; if ( ! str_contains ( $ class , $ cssClass ) ) { $ class .= ' ' . $ cssClass ; } return array_set ( $ attributes , 'class' , $ class ) ; }
Add css class to link
11,249
public function getFriendlyName ( ) : string { $ extra = $ this -> getPackage ( ) -> getExtra ( ) ; $ regularName = str_replace ( [ 'component-' , 'module-' ] , '' , $ this -> getPackageName ( ) ) ; return ( string ) Arr :: get ( $ extra , 'friendly-name' , $ regularName ) ; }
Returns friendly name of the module from the composer extra attribute .
11,250
public function getController ( ) { if ( ! is_null ( self :: $ controller ) ) { return self :: $ controller ; } $ controllerParam = array_get ( $ this -> routeParams , 'controller' ) ; $ match = null ; preg_match ( "'Foundation\\\Http\\\Controllers\\\(.*?)@'si" , $ controllerParam , $ match ) ; if ( ! isset ( $ match [...
get current controller name by route
11,251
public function getControllerClass ( ) { $ controller = array_get ( $ this -> routeParams , 'controller' ) ; $ match = null ; if ( ! preg_match ( '/(.*?)(?=@|$)/' , $ controller , $ match ) ) { return ; } return $ match [ 0 ] ; }
get controller class name
11,252
public function getAction ( ) { if ( ! is_null ( self :: $ action ) ) { return self :: $ action ; } $ controllerParam = array_get ( $ this -> routeParams , 'controller' ) ; $ match = null ; if ( ! preg_match ( "/.+?(?=@)@(.*)/" , $ controllerParam , $ match ) ) { return ; } self :: $ action = strtolower ( $ match [ 1 ]...
get action name by route
11,253
public function getModule ( ) { if ( ! is_null ( self :: $ module ) ) { return self :: $ module ; } $ controllerParam = array_get ( $ this -> routeParams , 'controller' ) ; $ match = null ; preg_match ( '/(.*?)(?=@|$)/' , $ controllerParam , $ match ) ; if ( ! isset ( $ match [ 0 ] ) ) { return ; } $ reflection = new R...
get module name by route
11,254
public function shouldMakeApiResponse ( ) { $ accept = request ( ) -> header ( 'Accept' ) ; $ accepted = implode ( '.' , [ env ( 'API_STANDARDS_TREE' ) , env ( 'API_SUBTYPE' ) ] ) ; return request ( ) -> wantsJson ( ) && extension_active ( 'api' ) && str_contains ( $ accept , $ accepted ) && class_exists ( '\Antares\Mo...
does the request wants api response
11,255
protected function getQueryString ( $ query ) { $ wrapper = ( $ query instanceof AbstractQuery ) ? array ( 'query' => $ query -> toArray ( ) ) : $ query -> toArray ( ) ; return json_encode ( $ wrapper ) ; }
Useful for debugging with elastic head plugin
11,256
public static function search ( $ search_query ) { $ search_query = urlencode ( $ search_query ) ; return self :: get ( self :: BASE_URL . '/json.php?dllink=1&q=' . $ search_query ) ; }
Search for a specific query string
11,257
public static function user ( $ username ) { $ username = urlencode ( $ username ) ; return self :: get ( self :: BASE_URL . '/json.php?username=' . $ username ) ; }
Search for torrents by a specific username
11,258
private static function createCollection ( $ responseData ) { $ collection = new Collection ( ) ; foreach ( $ responseData as $ element ) { $ torrent = new Torrent ( ) ; $ torrent -> title = $ element [ 'title' ] ?? null ; $ torrent -> hash = $ element [ 'info_hash' ] ?? null ; $ torrent -> link = $ element [ 'link' ] ...
Create a new Collection of Torrent instances
11,259
public static function accept ( $ request , $ handler ) { static :: checkRequest ( $ request ) ; $ webSocketAccept = base64_encode ( sha1 ( $ request -> getWebSocketKey ( ) . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11' , true ) ) ; $ response = static :: create ( '' , self :: HTTP_SWITCHING_PROTOCOLS ) ; $ response -> heade...
Accept the handshake request and open the connection .
11,260
function payload ( ) { if ( $ this -> IsFault ) { $ payload = xmlrpc_encode ( array ( "faultCode" => $ this -> FaultCode , "faultString" => $ this -> FaultString ) ) ; return str_replace ( array ( '<fault>' , '</fault>' ) , array ( '<methodResponse><fault>' , '</fault></methodResponse>' ) , $ payload ) ; } else { $ pay...
Returns the xmlrpc payload for the response .
11,261
function decodeStream ( $ request , $ stream , $ headers = false , $ cookies = array ( ) , $ statuscode = "200" ) { $ this -> decodeStreamCommon ( $ request , $ stream , $ headers , $ cookies , $ statuscode ) ; $ results = xmlrpc_decode ( $ stream ) ; if ( $ results === null ) { $ this -> IsFault = true ; $ this -> Fau...
Decodes the XMLRPC response stream .
11,262
public function forceDelete ( $ key ) { ! is_null ( $ this -> cache ) && $ this -> cache -> forget ( $ this -> cacheKey ) ; $ model = $ this -> resolver ( ) -> where ( 'name' , $ key ) ; if ( ! is_null ( $ model ) ) { return $ model -> delete ( ) ; } return false ; }
deletes item from resolver
11,263
protected function getAssignedCustomfields ( ) { $ customfields = array_get ( app ( 'customfields' ) -> get ( ) , get_called_class ( ) , [ ] ) ; return ! is_array ( $ customfields ) ? [ $ customfields ] : $ customfields ; }
Gets assigned customfieldsa
11,264
public function customfields ( $ fieldset = null ) { $ return = [ ] ; $ customfields = $ this -> getAssignedCustomfields ( ) ; foreach ( $ customfields as $ customfield ) { if ( is_null ( $ customfield ) ) { continue ; } $ value = $ customfield -> setModel ( $ this ) -> getValue ( ) ; array_set ( $ return , $ customfie...
Gets all customfields available in model
11,265
public function export ( ) { if ( $ this -> config == null ) { throw new LogicException ( 'Context must be set before export the service.' ) ; } if ( $ this -> dispatcher == null ) { throw new LogicException ( 'Dispatcher must be set before export the service.' ) ; } $ this -> dispatcher -> exportInvoker ( $ this -> ge...
Export the interface .
11,266
public function getInvoker ( ) { if ( $ this -> invoker !== null ) { return $ this -> invoker ; } return $ this -> invoker = $ this -> createInvoker ( ) ; }
Get invoker for the interface .
11,267
protected function createInvoker ( ) { $ config = $ this -> config ; $ interface = Arr :: pull ( $ config , 'interface' ) ; $ concrete = Arr :: pull ( $ config , 'refer' , $ interface ) ; $ invoker = new ConcreteInvoker ( $ this -> context , $ interface , $ concrete , $ config ) ; return $ this -> withMiddleware ( $ in...
Create the invoker .
11,268
function decodeStream ( $ request , $ stream , $ headers = false , $ cookies = array ( ) , $ statuscode = "200" ) { $ this -> decodeStreamCommon ( $ request , $ stream , $ headers , $ cookies , $ statuscode ) ; $ this -> Value = $ stream ; }
Decodes the HTTP response stream .
11,269
protected static function decode_chunked ( $ buffer ) { $ length = 0 ; $ new = '' ; $ chunkend = strpos ( $ buffer , "\r\n" ) + 2 ; $ temp = substr ( $ buffer , 0 , $ chunkend ) ; $ chunk_size = hexdec ( trim ( $ temp ) ) ; $ chunkstart = $ chunkend ; while ( $ chunk_size > 0 ) { $ chunkend = strpos ( $ buffer , "\r\n"...
Decode a string that is encoded w . chunked transfer encoding as defined in rfc2068 par . 19 . 4 . 6 Code shamelessly stolen from nusoap library by Dietrich Ayala
11,270
function setOption ( $ option , $ value ) { if ( ! in_array ( $ option , $ this -> Options ) ) { return false ; } switch ( $ option ) { case 'timeout' : $ this -> Timeout = ( int ) $ value ; break ; case 'login' : $ this -> Login = $ value ; break ; case 'password' : $ this -> Password = $ value ; break ; case 'authTyp...
One - stop shop for setting all configuration options without having to write a hundred method calls
11,271
function setOptions ( $ optionArray ) { foreach ( $ optionArray as $ name => $ value ) { $ this -> setOption ( $ name , $ value ) ; } }
Set many options in one fell swoop
11,272
function getOption ( $ option ) { if ( ! in_array ( $ option , $ this -> Options ) ) { throw new Exception ( "Option $option not supported" ) ; } switch ( $ option ) { case 'timeout' : return $ this -> Timeout ; case 'login' : return $ this -> Login ; case 'password' : return $ this -> Password ; case 'authType' : retu...
Retrieves the current value for any option
11,273
protected function setDefaults ( ) { $ this -> attributes [ 'name' ] = $ this -> name ; $ this -> attributes [ 'classname' ] = get_called_class ( ) ; $ attributesAdapter = new AttributesAdapter ( $ this -> name ) ; $ defaults = $ attributesAdapter -> defaults ( ) ; if ( ! isset ( $ this -> attributes [ 'width' ] ) && i...
set default widget attributes
11,274
public function fill ( ) { $ params = array_merge ( $ this -> attributes , [ 'id' => $ this -> id , 'widget' => $ this -> model , 'name' => $ this -> name , 'title' => strlen ( $ this -> title ) > 0 ? $ this -> title : $ this -> name , 'description' => $ this -> description , 'editable' => $ this -> editable ( ) , 'wid...
fill widget params
11,275
public function controls ( ) { $ this -> form ( ) ; $ form = app ( 'antares.form' ) -> of ( "antares.ui-components: custom" ) ; $ fieldsets = $ form -> grid -> fieldsets ( ) ; $ controls = [ ] ; foreach ( $ fieldsets as $ fieldset ) { foreach ( $ fieldset -> controls as $ control ) { array_push ( $ controls , $ control...
getting all controls available in edition form of widget
11,276
protected function saveUploadedFile ( UploadedFile $ file , $ path ) { $ file -> move ( $ path , $ filename = $ this -> getUploadedFilename ( $ file ) ) ; return $ filename ; }
Save uploaded file into directory .
11,277
public function index ( Listener $ listener , $ category = null ) { $ presenter = $ this -> presenter -> setCategory ( $ category ) ; $ modules = $ presenter -> modules ( ) ; return $ listener -> show ( compact ( 'modules' , 'category' ) ) ; }
View modules page .
11,278
public function add ( array $ attributes = array ( ) ) { if ( ! $ this -> contains ( $ attributes ) ) { $ this -> model -> getModel ( ) -> newInstance ( $ attributes ) -> save ( ) ; $ this -> cache -> forget ( $ this -> cacheKey ) ; } return $ this ; }
add resource do resource stack
11,279
protected function contains ( array $ attributes = array ( ) ) { $ collection = $ this -> findAll ( ) ; $ filtered = $ collection -> filter ( function ( $ value , $ key ) use ( $ attributes ) { foreach ( $ attributes as $ keyname => $ attrVal ) { if ( $ value -> { $ keyname } != $ attrVal ) { return false ; } } return ...
whether resource stack contains parametrized row with component and action name
11,280
public function findOneByAttributes ( array $ attributes = array ( ) , $ columns = array ( '*' ) ) { if ( empty ( $ attributes ) ) { throw new Exception ( 'Unable to find entity' ) ; } return $ this -> model -> where ( $ attributes ) -> first ( $ columns ) ; }
find item by attributes
11,281
public function getExpression ( $ str_name ) { if ( isset ( $ this -> arr_expressions [ $ str_name ] ) ) { return $ this -> arr_expressions [ $ str_name ] ; } return null ; }
Get a specific returned expression
11,282
protected function send ( $ data ) { try { $ result = $ this -> client -> send ( $ data ) ; if ( $ result === false ) { $ errorCode = $ this -> client -> errCode ; throw new TransportException ( 'Send data failed, cause: ' . socket_strerror ( $ errorCode ) . '.' , TransportException :: CONNECTION ) ; } } catch ( Transp...
Send data .
11,283
protected function receive ( ) { try { $ data = $ this -> client -> recv ( ) ; if ( $ data === false ) { $ errorCode = $ this -> client -> errCode ; if ( $ errorCode == 11 ) { throw new TransportException ( 'Receive timeout in ' . $ this -> getTimeout ( ) . ' ms.' , TransportException :: TIMEOUT ) ; } throw new Transpo...
Receive result .
11,284
public function getBy ( $ attribute , $ value , $ columns = array ( '*' ) ) { return $ this -> model -> where ( $ attribute , '=' , $ value ) -> get ( $ columns ) ; }
gets rows by attribute
11,285
protected function hasCustomfield ( ) { $ function = function ( $ object , $ name ) { return method_exists ( $ object , 'hasCustomfield' ) ? $ object -> hasCustomfield ( $ name ) : false ; } ; return new Twig_SimpleFunction ( 'hasCustomfield' , $ function ) ; }
create widget view helper for get brand title
11,286
protected function runValidationEvents ( $ events , array $ phrases ) { is_array ( $ events ) || $ events = ( array ) $ events ; $ events = array_merge ( $ this -> getValidationEvents ( ) , $ events ) ; $ rules = new Fluent ( $ this -> getBindedRules ( ) ) ; $ phrases = new Fluent ( array_merge ( $ this -> getValidatio...
Run validation events and return the finalize rules and phrases .
11,287
public function save ( $ match = '*' ) { if ( $ this -> isAuthenticated ( ) ) { $ url = $ this -> getLink ( ) ; if ( $ match === true ) { $ match = $ this -> xml -> xpath ( './@gd:etag' ) ; $ match = $ match [ 0 ] ; } try { $ headers = array ( 'GData-Version' => 2 , 'Content-type' => 'application/atom+xml' , 'If-Match'...
Method to modify a Picasa Album
11,288
public function refresh ( ) { if ( $ this -> isAuthenticated ( ) ) { $ url = $ this -> getLink ( ) ; $ jdata = $ this -> query ( $ url , null , array ( 'GData-Version' => 2 ) ) ; $ this -> xml = $ this -> safeXml ( $ jdata -> body ) ; return $ this ; } return false ; }
Refresh Picasa Album
11,289
public function getRequired ( ) : array { $ required = [ ] ; foreach ( $ this -> required as $ component ) { $ required [ $ component ] = $ this -> getTargetBranch ( $ component ) ; } return $ required ; }
Returns an array of required components with branches .
11,290
public function getOptional ( ) : array { $ optional = [ ] ; foreach ( $ this -> optional as $ component ) { $ optional [ $ component ] = $ this -> getTargetBranch ( $ component ) ; } return $ optional ; }
Returns an array of optional components with branches .
11,291
public function getWithBranches ( array $ components ) : array { $ data = [ ] ; foreach ( $ components as $ component ) { $ data [ $ component ] = $ this -> getTargetBranch ( $ component ) ; } return $ data ; }
Returns the given components with branches .
11,292
public function getTargetBranch ( string $ component ) : string { return array_key_exists ( $ component , $ this -> branches ) ? $ this -> branches [ $ component ] : self :: $ defaultBranch ; }
Returns the target branch .
11,293
public function register ( ) { $ this -> app -> bind ( 'antares.customfields.model' , function ( ) { return new Field ( ) ; } ) ; $ this -> app -> bind ( 'antares.customfields.model.view' , function ( ) { return new FieldView ( ) ; } ) ; $ this -> app -> bind ( 'antares.customfields.model.category' , function ( ) { ret...
registering service provider
11,294
protected function bootFormEvents ( ) { $ categoriesCollection = Foundation :: make ( 'antares.customfields.model.category' ) -> select ( [ 'name' ] ) -> with ( [ 'group' => function ( $ query ) { $ query -> select ( [ 'name' ] ) ; } ] ) -> get ( ) ; $ formHandler = 'Antares\Customfields\Events\FormHandler' ; $ validat...
booting form events
11,295
protected function createInitials ( $ filename , $ fullname , $ width = null , $ height = null ) { $ width = is_null ( $ width ) ? config ( 'avatar.width' ) : $ width ; $ height = is_null ( $ height ) ? config ( 'avatar.height' ) : $ height ; $ defaultWidth = config ( 'avatar.width' ) ; $ fontSize = config ( 'avatar.fo...
create initials from string
11,296
protected function createWidgetInitials ( $ filename , $ title , $ width = null , $ height = null ) { $ avatar = AvatarFacade :: create ( $ title ) -> setDimension ( $ width , $ height ) -> setBackground ( '#02a8f3' ) -> setFontSize ( 40 ) -> setShape ( 'square' ) ; $ avatar -> save ( $ filename , 100 ) ; return $ avat...
create widget initials from string
11,297
protected function response ( $ filename ) { Image :: make ( $ filename ) -> response ( 'png' , 100 ) ; return str_replace ( [ public_path ( ) , DIRECTORY_SEPARATOR ] , [ '' , '/' ] , $ filename ) ; }
create image response
11,298
public function recover ( ) { $ instance = $ this -> values ; foreach ( get_object_vars ( $ instance ) as $ key => $ value ) { $ instance -> $ key = $ value instanceof Serialization ? $ value -> recover ( ) : $ value ; } return $ instance ; }
Recover the instance from the serialization .
11,299
public function publish ( $ package , $ source ) { $ name = trim ( str_replace ( [ 'modules' , 'components' ] , '' , $ package ) , '/' ) ; $ destination = $ this -> getDestinationPath ( $ name ) ; $ this -> makeDestination ( $ destination ) ; return app ( 'antares.asset.publisher' ) -> publishAndPropagate ( $ this -> f...
Publish files from a given path .