idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
4,900
public function extractJson ( ) { foreach ( $ this -> getRows ( ) as & $ row ) { foreach ( $ this -> getJsonFields ( ) as $ field ) { if ( isset ( $ row [ $ field ] ) ) { $ data = json_decode ( $ row [ $ field ] , JSON_OBJECT_AS_ARRAY ) ; foreach ( ( array ) $ data as $ k => $ v ) { $ row [ sprintf ( '_%s__%s' , $ field , $ k ) ] = $ v ; } } } } return $ this ; }
Extract json data
4,901
public static function isEven ( $ value , $ scale = null ) { if ( ! static :: is ( $ value ) ) { throw new \ InvalidArgumentException ( "The \$value parameter must be of type float (or string representing a big float)." ) ; } return static :: equals ( static :: mod ( $ value , 2.0 , $ scale ) , 0.0 , $ scale ) ; }
Tests if the given value is even .
4,902
public static function isOdd ( $ value , $ scale = null ) { if ( ! static :: is ( $ value ) ) { throw new \ InvalidArgumentException ( "The \$value parameter must be of type float (or string representing a big float)." ) ; } return static :: equals ( static :: abs ( static :: mod ( $ value , 2.0 , $ scale ) ) , 1.0 , $ scale ) ; }
Tests if the given value is odd .
4,903
public static function inRange ( $ value , $ lower , $ upper , $ lowerExclusive = false , $ upperExclusive = false ) { if ( ! static :: is ( $ value ) || ! static :: is ( $ lower ) || ! static :: is ( $ upper ) ) { throw new \ InvalidArgumentException ( "The \$value, \$lower and \$upper parameters must be of type float" . " (or string representing a big float)." ) ; } $ lowerLimit = min ( $ lower , $ upper ) ; if ( ! ( ( $ lowerExclusive ) ? $ lowerLimit < $ value : $ lowerLimit <= $ value ) ) { return false ; } $ upperLimit = max ( $ lower , $ upper ) ; if ( ! ( ( $ upperExclusive ) ? $ upperLimit > $ value : $ upperLimit >= $ value ) ) { return false ; } return true ; }
Tests if an integer is in a range .
4,904
public static function abs ( $ float ) { if ( ! static :: is ( $ float ) ) { throw new \ InvalidArgumentException ( "The \$float parameter must be of type float (or string representing a big float)." ) ; } if ( Float :: is ( $ float ) ) { return Float :: abs ( $ float ) ; } else { return Str :: replace ( $ float , '-' , '' ) ; } }
Gets the absolute value of the given float .
4,905
public static function viewData ( $ data , $ links = null , $ meta = null , $ included = null ) { $ viewParameters = new \ stdClass ( ) ; if ( $ links ) { $ viewParameters -> links = $ links ; } $ viewParameters -> data = $ data ; if ( $ included !== null ) { $ viewParameters -> included = $ included ; } if ( $ meta ) { $ viewParameters -> meta = $ meta ; } \ Phramework \ Phramework :: view ( $ viewParameters ) ; unset ( $ viewParameters ) ; return true ; }
View JSONAPI data
4,906
protected static function getRequestInclude ( $ parameters , $ modelClass = null ) { if ( ! is_object ( $ parameters ) && is_array ( $ parameters ) ) { $ parameters = ( object ) $ parameters ; } $ include = [ ] ; if ( $ modelClass !== null ) { foreach ( $ modelClass :: getRelationships ( ) as $ relationshipKey => $ relationship ) { if ( ( $ relationship -> flags & Relationship :: FLAG_INCLUDE_BY_DEFAULT ) != 0 ) { $ include [ ] = $ include ; } } } if ( ! isset ( $ parameters -> include ) || empty ( $ parameters -> include ) ) { return $ include ; } foreach ( explode ( ',' , $ parameters -> include ) as $ i ) { $ include [ ] = trim ( $ i ) ; } return array_unique ( $ include ) ; }
Extract included related resources from parameters
4,907
protected static function getRequestData ( $ parameters ) { if ( ! is_object ( $ parameters ) && is_array ( $ parameters ) ) { $ parameters = ( object ) $ parameters ; } Request :: requireParameters ( $ parameters , [ 'data' ] ) ; return $ parameters -> data ; }
Get request primary data
4,908
protected static function getRequestRelationships ( $ parameters ) { if ( ! is_object ( $ parameters ) && is_array ( $ parameters ) ) { $ parameters = ( object ) $ parameters ; } Request :: requireParameters ( $ parameters , [ 'data' ] ) ; if ( isset ( $ parameters -> data -> relationships ) ) { return ( object ) $ parameters -> data -> relationships ; } else { return new \ stdClass ( ) ; } }
Get request relationships if any attributes .
4,909
private function startsWith ( $ string , $ prefix ) { return $ prefix === "" || strrpos ( $ string , $ prefix , - strlen ( $ string ) ) !== FALSE ; }
Check if a string starts with a prefix
4,910
private function endswith ( $ string , $ suffix ) { $ strlen = strlen ( $ string ) ; $ testlen = strlen ( $ suffix ) ; if ( $ testlen > $ strlen ) { return false ; } return substr_compare ( $ string , $ suffix , - $ testlen ) === 0 ; }
Check if a string ends with a suffix
4,911
public static function render ( Query \ Delete $ query ) { return Compiler :: withDb ( $ query -> getDb ( ) , function ( ) use ( $ query ) { return Compiler :: expression ( array ( 'DELETE' , $ query -> getType ( ) , Aliased :: combine ( $ query -> getTable ( ) ) , Compiler :: word ( 'FROM' , Aliased :: combine ( $ query -> getFrom ( ) ) ) , Join :: combine ( $ query -> getJoin ( ) ) , Compiler :: word ( 'WHERE' , Condition :: combine ( $ query -> getWhere ( ) ) ) , Compiler :: word ( 'ORDER BY' , Direction :: combine ( $ query -> getOrder ( ) ) ) , Compiler :: word ( 'LIMIT' , $ query -> getLimit ( ) ) , ) ) ; } ) ; }
Render a Delete object
4,912
private function getReturn ( $ method , $ default ) { if ( isset ( $ this -> returns [ $ method ] ) && ! empty ( $ this -> returns [ $ method ] ) ) { return array_shift ( $ this -> returns [ $ method ] ) ; } return $ default ; }
Dequeue a value for a specific method invocation
4,913
public function getConfigTreeBuilder ( ) { $ builder = new TreeBuilder ( ) ; $ rootNode = $ builder -> root ( 'best_it_ct_order_export' ) ; $ rootNode -> children ( ) -> arrayNode ( 'commercetools_client' ) -> isRequired ( ) -> children ( ) -> scalarNode ( 'id' ) -> cannotBeEmpty ( ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'secret' ) -> cannotBeEmpty ( ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'project' ) -> cannotBeEmpty ( ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'scope' ) -> cannotBeEmpty ( ) -> isRequired ( ) -> end ( ) -> end ( ) -> end ( ) -> scalarNode ( 'filesystem' ) -> info ( 'Please provide the service id for your flysystem file system.' ) -> isRequired ( ) -> end ( ) -> scalarNode ( 'logger' ) -> info ( 'Please provide the service id for your logging service.' ) -> defaultValue ( 'logger' ) -> end ( ) -> arrayNode ( 'orders' ) -> children ( ) -> booleanNode ( 'with_pagination' ) -> defaultValue ( true ) -> info ( 'Should we use a paginated list of orders (or is the result list changing by "itself")?' ) -> end ( ) -> arrayNode ( 'default_where' ) -> info ( 'Add where clauses for orders: ' . 'https://dev.commercetools.com/http-api-projects-orders.html#query-orders' ) -> prototype ( 'scalar' ) -> end ( ) -> end ( ) -> scalarNode ( 'file_template' ) -> info ( 'Which template is used for the export of a single order?' ) -> defaultValue ( 'detail.xml.twig' ) -> end ( ) -> scalarNode ( 'name_scheme' ) -> defaultValue ( 'order_{{id}}_{{YmdHis}}.xml' ) -> info ( 'Provide an order field name or a format string for the date function enclosed ' . 'with {{ and }}.' ) -> end ( ) -> end ( ) -> end ( ) ; return $ builder ; }
Parses the config .
4,914
private function isCacheable ( RequestHandleInterface $ handle ) { if ( null === $ this -> cache ) { return false ; } if ( $ handle -> getMethod ( ) != self :: GET ) { return false ; } return true ; }
Returns true if handle is possible to be cached
4,915
public function onGet ( string $ path , $ target ) : ConfigurableRoute { return $ this -> addRoute ( new Route ( $ path , $ target , 'GET' ) ) ; }
reply with given class or callable for GET request on given path
4,916
public function passThroughOnGet ( string $ path = '/[a-zA-Z0-9-_]+.html$' , $ target = HtmlFilePassThrough :: class ) : ConfigurableRoute { return $ this -> onGet ( $ path , $ target ) ; }
reply with HTML file stored in pages path
4,917
public function apiIndexOnGet ( string $ path ) : ConfigurableRoute { return $ this -> onGet ( $ path , new Index ( $ this -> routes , $ this -> mimeTypes ) ) ; }
reply with API index overview
4,918
public function redirectOnGet ( string $ path , $ target , int $ statusCode = 302 ) : ConfigurableRoute { return $ this -> onGet ( $ path , new Redirect ( $ target , $ statusCode ) ) ; }
reply with a redirect
4,919
public function onHead ( string $ path , $ target ) : ConfigurableRoute { return $ this -> addRoute ( new Route ( $ path , $ target , 'HEAD' ) ) ; }
reply with given class or callable for HEAD request on given path
4,920
public function onPost ( string $ path , $ target ) : ConfigurableRoute { return $ this -> addRoute ( new Route ( $ path , $ target , 'POST' ) ) ; }
reply with given class or callable for POST request on given path
4,921
public function onPut ( string $ path , $ target ) : ConfigurableRoute { return $ this -> addRoute ( new Route ( $ path , $ target , 'PUT' ) ) ; }
reply with given class or callable for PUT request on given path
4,922
public function onDelete ( string $ path , $ target ) : ConfigurableRoute { return $ this -> addRoute ( new Route ( $ path , $ target , 'DELETE' ) ) ; }
reply with given class or callable for DELETE request on given path
4,923
public function findResource ( $ uri , string $ requestMethod = null ) : UriResource { $ calledUri = CalledUri :: castFrom ( $ uri , $ requestMethod ) ; $ matchingRoutes = $ this -> routes -> match ( $ calledUri ) ; if ( $ matchingRoutes -> hasExactMatch ( ) ) { return $ this -> handleMatchingRoute ( $ calledUri , $ matchingRoutes -> exactMatch ( ) ) ; } if ( $ matchingRoutes -> exist ( ) ) { return $ this -> handleNonMethodMatchingRoutes ( $ calledUri , $ matchingRoutes ) ; } return new NotFound ( $ this -> injector , $ calledUri , $ this -> collectInterceptors ( $ calledUri ) , $ this -> supportedMimeTypes ( ) ) ; }
returns resource which is applicable for given request
4,924
private function handleMatchingRoute ( CalledUri $ calledUri , Route $ route ) : UriResource { if ( $ route -> requiresAuth ( ) ) { return new ProtectedResource ( $ route -> authConstraint ( ) , $ this -> resolveResource ( $ calledUri , $ route ) , $ this -> injector ) ; } return $ this -> resolveResource ( $ calledUri , $ route ) ; }
creates a processable route for given route
4,925
private function resolveResource ( CalledUri $ calledUri , Route $ route ) : ResolvingResource { return new ResolvingResource ( $ this -> injector , $ calledUri , $ this -> collectInterceptors ( $ calledUri , $ route ) , $ this -> supportedMimeTypes ( $ route ) , $ route ) ; }
creates matching route
4,926
private function handleNonMethodMatchingRoutes ( CalledUri $ calledUri , MatchingRoutes $ matchingRoutes ) : UriResource { if ( $ calledUri -> methodEquals ( 'OPTIONS' ) ) { return new ResourceOptions ( $ this -> injector , $ calledUri , $ this -> collectInterceptors ( $ calledUri ) , $ this -> supportedMimeTypes ( ) , $ matchingRoutes ) ; } return new MethodNotAllowed ( $ this -> injector , $ calledUri , $ this -> collectInterceptors ( $ calledUri ) , $ this -> supportedMimeTypes ( ) , $ matchingRoutes -> allowedMethods ( ) ) ; }
creates a processable route when a route can be found regardless of request method
4,927
public function preInterceptOnGet ( $ preInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> preIntercept ( $ preInterceptor , $ path , 'GET' ) ; }
pre intercept with given class or callable on all GET requests
4,928
public function preInterceptOnHead ( $ preInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> preIntercept ( $ preInterceptor , $ path , 'HEAD' ) ; }
pre intercept with given class or callable on all HEAD requests
4,929
public function preInterceptOnPost ( $ preInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> preIntercept ( $ preInterceptor , $ path , 'POST' ) ; }
pre intercept with given class or callable on all POST requests
4,930
public function preInterceptOnPut ( $ preInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> preIntercept ( $ preInterceptor , $ path , 'PUT' ) ; }
pre intercept with given class or callable on all PUT requests
4,931
public function preInterceptOnDelete ( $ preInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> preIntercept ( $ preInterceptor , $ path , 'DELETE' ) ; }
pre intercept with given class or callable on all DELETE requests
4,932
public function preIntercept ( $ preInterceptor , string $ path = null , string $ requestMethod = null ) : RoutingConfigurator { if ( ! is_callable ( $ preInterceptor ) && ! ( $ preInterceptor instanceof PreInterceptor ) && ! class_exists ( ( string ) $ preInterceptor ) ) { throw new \ InvalidArgumentException ( 'Given pre interceptor must be a callable, an instance of ' . PreInterceptor :: class . ' or a class name of an existing pre interceptor class' ) ; } $ this -> preInterceptors [ ] = [ 'interceptor' => $ preInterceptor , 'requestMethod' => $ requestMethod , 'path' => $ path ] ; return $ this ; }
pre intercept with given class or callable on all requests
4,933
public function postInterceptOnGet ( $ postInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> postIntercept ( $ postInterceptor , $ path , 'GET' ) ; }
post intercept with given class or callable on all GET requests
4,934
public function postInterceptOnHead ( $ postInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> postIntercept ( $ postInterceptor , $ path , 'HEAD' ) ; }
post intercept with given class or callable on all HEAD requests
4,935
public function postInterceptOnPost ( $ postInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> postIntercept ( $ postInterceptor , $ path , 'POST' ) ; }
post intercept with given class or callable on all POST requests
4,936
public function postInterceptOnPut ( $ postInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> postIntercept ( $ postInterceptor , $ path , 'PUT' ) ; }
post intercept with given class or callable on all PUT requests
4,937
public function postInterceptOnDelete ( $ postInterceptor , string $ path = null ) : RoutingConfigurator { return $ this -> postIntercept ( $ postInterceptor , $ path , 'DELETE' ) ; }
post intercept with given class or callable on all DELETE requests
4,938
public function postIntercept ( $ postInterceptor , string $ path = null , string $ requestMethod = null ) : RoutingConfigurator { if ( ! is_callable ( $ postInterceptor ) && ! ( $ postInterceptor instanceof PostInterceptor ) && ! class_exists ( ( string ) $ postInterceptor ) ) { throw new \ InvalidArgumentException ( 'Given pre interceptor must be a callable, an instance of ' . PostInterceptor :: class . ' or a class name of an existing post interceptor class' ) ; } $ this -> postInterceptors [ ] = [ 'interceptor' => $ postInterceptor , 'requestMethod' => $ requestMethod , 'path' => $ path ] ; return $ this ; }
post intercept with given class or callable on all requests
4,939
private function getPreInterceptors ( CalledUri $ calledUri , Route $ route = null ) : array { $ global = $ this -> getApplicable ( $ calledUri , $ this -> preInterceptors ) ; if ( null === $ route ) { return $ global ; } return array_merge ( $ global , $ route -> preInterceptors ( ) ) ; }
returns list of applicable pre interceptors for this request
4,940
private function getPostInterceptors ( CalledUri $ calledUri , Route $ route = null ) : array { $ global = $ this -> getApplicable ( $ calledUri , $ this -> postInterceptors ) ; if ( null === $ route ) { return $ global ; } return array_merge ( $ route -> postInterceptors ( ) , $ global ) ; }
returns list of applicable post interceptors for this request
4,941
private function getApplicable ( CalledUri $ calledUri , array $ interceptors ) : array { $ applicable = [ ] ; foreach ( $ interceptors as $ interceptor ) { if ( $ calledUri -> satisfies ( $ interceptor [ 'requestMethod' ] , $ interceptor [ 'path' ] ) ) { $ applicable [ ] = $ interceptor [ 'interceptor' ] ; } } return $ applicable ; }
calculates which interceptors are applicable for given request method
4,942
public function setDefaultMimeTypeClass ( string $ mimeType , $ mimeTypeClass ) : RoutingConfigurator { SupportedMimeTypes :: setDefaultMimeTypeClass ( $ mimeType , $ mimeTypeClass ) ; return $ this ; }
sets a default mime type class for given mime type but doesn t mark the mime type as supported for all routes
4,943
public function supportsMimeType ( string $ mimeType , $ mimeTypeClass = null ) : RoutingConfigurator { if ( null === $ mimeTypeClass && ! SupportedMimeTypes :: provideDefaultClassFor ( $ mimeType ) ) { throw new \ InvalidArgumentException ( 'No default class known for mime type ' . $ mimeType . ', please provide a class' ) ; } $ this -> mimeTypes [ ] = $ mimeType ; if ( null !== $ mimeTypeClass ) { $ this -> mimeTypeClasses [ $ mimeType ] = $ mimeTypeClass ; } return $ this ; }
add a supported mime type
4,944
private function supportedMimeTypes ( Route $ route = null ) : SupportedMimeTypes { if ( $ this -> disableContentNegotation ) { return SupportedMimeTypes :: createWithDisabledContentNegotation ( ) ; } if ( null !== $ route ) { return $ route -> supportedMimeTypes ( $ this -> mimeTypes , $ this -> mimeTypeClasses ) ; } return new SupportedMimeTypes ( $ this -> mimeTypes , $ this -> mimeTypeClasses ) ; }
retrieves list of supported mime types
4,945
public function getJSData ( ) { return [ 'name' => $ this -> name , 'title' => $ this -> title , 'description' => $ this -> description , 'column' => $ this -> column , 'extraColumn' => $ this -> extraColumn , 'columnFormat' => $ this -> columnFormat , 'addForm' => $ this -> addForm , 'editForm' => $ this -> editForm , 'inputType' => $ this -> inputType , 'actions' => $ this -> actions , 'deleteOption' => $ this -> deleteOption , 'editOption' => $ this -> editOption , 'addOption' => $ this -> addOption , 'orderOption' => $ this -> orderOption , 'exportOption' => $ this -> exportOption , 'microEditOption' => $ this -> microEditOption , 'modelDefaults' => $ this -> modelDefaults , 'selectOptions' => $ this -> selectOptions , 'filters' => $ this -> filters , 'richFilters' => $ this -> richFilters , 'showFilters' => $ this -> showFilters , 'trans' => $ this -> trans , 'moduleInPopup' => $ this -> moduleInPopup , 'customActions' => $ this -> customActions , 'panelView' => $ this -> panelView , 'orderParameters' => $ this -> orderParameters , 'checkboxColumn' => $ this -> checkboxColumn , 'defaultSortAttr' => $ this -> defaultSortAttr , 'defaultSortOrder' => $ this -> defaultSortOrder , 'interfaceTrans' => $ this -> getInterfaceTrans ( ) , 'thumbnailColumns' => $ this -> getThumbnailColumns ( ) , 'dateTimePickerOptions' => $ this -> getDateTimePickerOptions ( ) , 'config' => [ 'routePrefix' => config ( 'crude.routePrefix' ) , 'numRowsOptions' => config ( 'crude.numRowsOptions' ) , 'iconClassName' => config ( 'crude.iconClassName' ) , 'refreshAll' => config ( 'crude.refreshAll' ) , 'mapCenter' => config ( 'crude.mapCenter' ) , 'sortAttr' => $ this -> getOrderAttribute ( ) , ] , ] ; }
Prepare data for JS list config model
4,946
protected function configureRoutes ( RouteCollection $ collection ) { parent :: configureRoutes ( $ collection ) ; $ collection -> add ( 'duplicate' , $ this -> getRouterIdParameter ( ) . '/duplicate' ) ; $ collection -> add ( 'generateEntityCode' ) ; if ( $ collection -> get ( 'batch' ) ) { $ collection -> get ( 'batch' ) -> setMethods ( [ 'POST' ] ) ; } }
Configure routes for list actions .
4,947
private static function arrayDepth ( $ array , $ level = 0 ) { if ( ! $ array ) { return $ level ; } if ( ! is_array ( $ array ) ) { return $ level ; } ++ $ level ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ level = $ level < self :: arrayDepth ( $ value , $ level ) ? self :: arrayDepth ( $ value , $ level ) : $ level ; } } return $ level ; }
Returns the level of depth of an array .
4,948
public function bundleExists ( $ bundle ) { $ kernelBundles = $ this -> getConfigurationPool ( ) -> getContainer ( ) -> getParameter ( 'kernel.bundles' ) ; if ( array_key_exists ( $ bundle , $ kernelBundles ) ) { return true ; } if ( in_array ( $ bundle , $ kernelBundles ) ) { return true ; } return false ; }
Checks if a Bundle is installed .
4,949
public function renameFormTab ( $ tabName , $ newTabName , $ keepOrder = true ) { $ tabs = $ this -> getFormTabs ( ) ; if ( ! $ tabs ) { return ; } if ( ! isset ( $ tabs [ $ tabName ] ) ) { throw new \ Exception ( sprintf ( 'Tab %s does not exist.' , $ tabName ) ) ; } if ( isset ( $ tabs [ $ newTabName ] ) ) { return ; } if ( $ keepOrder ) { $ keys = array_keys ( $ tabs ) ; $ keys [ array_search ( $ tabName , $ keys ) ] = $ newTabName ; $ tabs = array_combine ( $ keys , $ tabs ) ; } else { $ tabs [ $ newTabName ] = $ tabs [ $ tabName ] ; unset ( $ tabs [ $ tabName ] ) ; } $ this -> setFormTabs ( $ tabs ) ; }
Rename a form tab after form fields have been configured .
4,950
public function renameShowTab ( $ tabName , $ newTabName , $ keepOrder = true ) { $ tabs = $ this -> getShowTabs ( ) ; if ( ! $ tabs ) { return ; } if ( ! isset ( $ tabs [ $ tabName ] ) ) { throw new \ Exception ( sprintf ( 'Tab %s does not exist.' , $ tabName ) ) ; } if ( isset ( $ tabs [ $ newTabName ] ) ) { return ; } if ( $ keepOrder ) { $ keys = array_keys ( $ tabs ) ; $ keys [ array_search ( $ tabName , $ keys ) ] = $ newTabName ; $ tabs = array_combine ( $ keys , $ tabs ) ; } else { $ tabs [ $ newTabName ] = $ tabs [ $ tabName ] ; unset ( $ tabs [ $ tabName ] ) ; } $ this -> setShowTabs ( $ tabs ) ; }
Rename a show tab after show fields have been configured .
4,951
public function removeTab ( $ tabNames , $ mapper ) { $ currentTabs = $ this -> getFormTabs ( ) ; foreach ( $ currentTabs as $ k => $ item ) { if ( is_array ( $ tabNames ) && in_array ( $ item [ 'name' ] , $ tabNames ) || ! is_array ( $ tabNames ) && $ item [ 'name' ] === $ tabNames ) { foreach ( $ item [ 'groups' ] as $ groupName ) { $ this -> removeAllFieldsFromFormGroup ( $ groupName , $ mapper ) ; } unset ( $ currentTabs [ $ k ] ) ; } } $ this -> setFormTabs ( $ currentTabs ) ; }
Removes tab in current form Mapper .
4,952
public function removeAllFieldsFromFormGroup ( $ groupName , $ mapper ) { $ formGroups = $ this -> getFormGroups ( ) ; foreach ( $ formGroups as $ name => $ formGroup ) { if ( $ name === $ groupName ) { foreach ( $ formGroups [ $ name ] [ 'fields' ] as $ key => $ field ) { $ mapper -> remove ( $ key ) ; } } } }
Removes all fields from form groups and remove them from mapper .
4,953
public static function create ( $ body ) { if ( 0 !== strpos ( $ body , static :: START_TOKEN ) ) { throw new InvalidArgumentException ( "Unexpected response body." ) ; } if ( static :: END_TOKEN !== substr ( $ body , - strlen ( static :: END_TOKEN ) ) ) { throw new InvalidArgumentException ( "Unexpected response body." ) ; } $ body = substr ( $ body , strlen ( static :: START_TOKEN ) , - strlen ( static :: END_TOKEN ) ) ; $ parts = explode ( '|' , trim ( $ body , '|' ) ) ; if ( empty ( $ parts ) ) { throw new InvalidArgumentException ( "Unexpected response body." ) ; } $ response = new static ( ) ; for ( $ i = 0 ; $ i < count ( $ parts ) ; $ i ++ ) { list ( $ key , $ value ) = explode ( ':' , $ parts [ $ i ] , 2 ) ; if ( $ key === Config :: RESULT ) { if ( 0 < strpos ( $ value , ':' ) ) { list ( $ code , $ field ) = explode ( ':' , $ value , 2 ) ; } else { $ code = $ value ; $ field = 'unknown' ; } $ response -> set ( Config :: RESULT , $ code ) ; $ response -> set ( Config :: FIELD , $ field ) ; } else { $ response -> set ( $ key , $ value ) ; } } return $ response ; }
Creates a response from the given http response body .
4,954
public static function render ( SQL \ Join $ join ) { $ condition = $ join -> getCondition ( ) ; $ table = $ join -> getTable ( ) ; return Compiler :: expression ( array ( $ join -> getType ( ) , 'JOIN' , $ table instanceof SQL \ Aliased ? Aliased :: render ( $ table ) : $ table , is_array ( $ condition ) ? self :: renderArrayCondition ( $ condition ) : $ condition , ) ) ; }
Render a Join object
4,955
public function template ( $ template , $ data = Array ( ) ) { \ Template :: with ( $ template , $ data ) ; \ View :: serve ( ) ; }
A template to add to the view and return .
4,956
public function getAuthorizeUrl ( $ request_token , $ callback_uri = NULL , $ state = NULL ) { if ( empty ( $ callback_uri ) && isset ( $ request_token [ 'callback_uri' ] ) ) { $ callback_uri = $ request_token [ 'callback_uri' ] ; } if ( empty ( $ state ) ) { $ state = md5 ( mt_rand ( ) ) ; } $ params = array ( ) ; if ( $ this -> getConfig ( ) -> get ( 'offline_access' ) ) { $ params += $ this -> getOfflineAccessParams ( ) ; } $ query = array ( 'response_type' => 'code' , 'client_id' => $ this -> getConfig ( 'consumer_key' ) , 'redirect_uri' => $ callback_uri , 'scope' => implode ( $ this -> getConfig ( 'scope_delimiter' ) , $ this -> getScope ( ) ) , 'state' => $ state , ) + $ params ; $ url = Url :: factory ( $ this -> getConfig ( 'base_url' ) ) ; $ url -> addPath ( $ this -> getConfig ( 'authorize_path' ) ) ; $ url -> setQuery ( $ query ) ; return ( string ) $ url ; }
Return a redirect url .
4,957
protected function normalizeAccessToken ( $ access_token ) { if ( ! isset ( $ access_token [ 'token_type' ] ) ) { $ access_token [ 'token_type' ] = 'Bearer' ; } if ( ! isset ( $ access_token [ 'expires_at' ] ) && isset ( $ access_token [ 'expires_in' ] ) ) { $ access_token [ 'expires_at' ] = $ access_token [ 'expires_in' ] + $ access_token [ 'request_time' ] ; } return $ access_token ; }
Normalize access token
4,958
public static function getRelationshipData ( $ relationshipKey , $ id , Fields $ fields = null , $ primaryDataParameters = [ ] , $ relationshipParameters = [ ] ) { if ( ! static :: relationshipExists ( $ relationshipKey ) ) { throw new \ Phramework \ Exceptions \ ServerException ( sprintf ( '"%s" is not a valid relationship key' , $ relationshipKey ) ) ; } $ relationship = static :: getRelationship ( $ relationshipKey ) ; switch ( $ relationship -> type ) { case \ Phramework \ JSONAPI \ Relationship :: TYPE_TO_ONE : $ resource = $ callMethod = static :: getById ( $ id , $ fields , ... $ primaryDataParameters ) ; if ( ! $ resource ) { return null ; } return ( isset ( $ resource -> relationships -> { $ relationshipKey } -> data ) ? $ resource -> relationships -> { $ relationshipKey } -> data : null ) ; case \ Phramework \ JSONAPI \ Relationship :: TYPE_TO_MANY : default : if ( ! isset ( $ relationship -> callbacks -> { Phramework :: METHOD_GET } ) ) { return [ ] ; } $ callMethod = $ relationship -> callbacks -> { Phramework :: METHOD_GET } ; if ( ! is_callable ( $ callMethod ) ) { throw new \ Phramework \ Exceptions \ ServerException ( $ callMethod [ 0 ] . '::' . $ callMethod [ 1 ] . ' is not implemented' ) ; } return call_user_func ( $ callMethod , $ id , $ fields , ... $ relationshipParameters ) ; } }
Get records from a relationship link
4,959
public static function getIncludedData ( $ primaryData , $ include = [ ] , Fields $ fields = null , $ additionalResourceParameters = [ ] ) { $ tempRelationshipIds = new \ stdClass ( ) ; foreach ( $ include as $ relationshipKey ) { if ( ! static :: relationshipExists ( $ relationshipKey ) ) { throw new RequestException ( sprintf ( 'Relationship "%s" not found' , $ relationshipKey ) ) ; } $ tempRelationshipIds -> { $ relationshipKey } = [ ] ; } if ( empty ( $ include ) || empty ( $ primaryData ) ) { return [ ] ; } if ( ! is_array ( $ primaryData ) ) { $ primaryData = [ $ primaryData ] ; } foreach ( $ primaryData as $ resource ) { if ( empty ( $ resource -> relationships ) ) { continue ; } foreach ( $ include as $ relationshipKey ) { if ( ! isset ( $ resource -> relationships -> { $ relationshipKey } ) ) { continue ; } if ( ! isset ( $ resource -> relationships -> { $ relationshipKey } -> data ) ) { continue ; } $ relationshipData = $ resource -> relationships -> { $ relationshipKey } -> data ; if ( ! $ relationshipData || empty ( $ relationshipData ) ) { continue ; } if ( ! is_array ( $ relationshipData ) ) { $ relationshipData = [ $ relationshipData ] ; } foreach ( $ relationshipData as $ primaryKeyAndType ) { $ tempRelationshipIds -> { $ relationshipKey } [ ] = $ primaryKeyAndType -> id ; } } } $ included = [ ] ; foreach ( $ include as $ relationshipKey ) { $ relationship = static :: getRelationship ( $ relationshipKey ) ; $ relationshipModelClass = $ relationship -> modelClass ; $ ids = array_unique ( $ tempRelationshipIds -> { $ relationshipKey } ) ; $ additionalArgument = ( isset ( $ additionalResourceParameters [ $ relationshipKey ] ) ? $ additionalResourceParameters [ $ relationshipKey ] : [ ] ) ; $ resources = $ relationshipModelClass :: getById ( $ ids , $ fields , ... $ additionalArgument ) ; foreach ( $ resources as $ key => $ resource ) { if ( $ resource === null ) { continue ; } $ included [ ] = $ resource ; } } return $ included ; }
Get jsonapi s included object selected by include argument using id s of relationship s data from resources in primary data object
4,960
private function deviceRepository ( $ persistenceStorage , $ userAgentHandlerChain ) { $ devicePatcher = new WURFL_Xml_DevicePatcher ( ) ; $ deviceRepositoryBuilder = new WURFL_DeviceRepositoryBuilder ( $ persistenceStorage , $ userAgentHandlerChain , $ devicePatcher ) ; return $ deviceRepositoryBuilder -> build ( $ this -> wurflConfig -> wurflFile , $ this -> wurflConfig -> wurflPatches , $ this -> wurflConfig -> capabilityFilter ) ; }
Returns a WURFL device repository
4,961
public static function commentTable ( $ table , $ comment , $ connection = null ) { if ( is_null ( $ connection ) ) { $ connection = DB :: connection ( ) ; } if ( $ connection -> getDriverName ( ) === 'sqlite' ) { return ; } $ connection -> statement ( sprintf ( 'ALTER TABLE `%s` COMMENT = "%s"' , $ table , addslashes ( $ comment ) ) ) ; }
Add a comment at the level of a table .
4,962
public static function describeTable ( $ table , $ connection = null ) { if ( is_null ( $ connection ) ) { $ connection = DB :: connection ( ) ; } if ( $ connection -> getDriverName ( ) === 'sqlite' ) { $ result = $ connection -> select ( sprintf ( 'PRAGMA table_info(%s)' , $ table ) ) ; $ column_key = 'name' ; } else { $ result = $ connection -> select ( sprintf ( 'SELECT COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = \'%s\' and TABLE_SCHEMA = \'%s\'' , $ table , $ connection -> getDatabaseName ( ) ) ) ; $ column_key = 'COLUMN_NAME' ; } return array_map ( function ( $ item ) use ( $ column_key ) { return $ item -> $ column_key ; } , $ result ) ; }
Describe a table s columns .
4,963
protected function isFixtureAlreadyLoaded ( $ fixtureObject ) { if ( ! $ this -> loadedFixtures ) { $ this -> loadedFixtures = [ ] ; $ loadedFixtures = $ this -> em -> getRepository ( 'OkvpnFixtureBundle:DataFixture' ) -> findAll ( ) ; foreach ( $ loadedFixtures as $ fixture ) { $ this -> loadedFixtures [ $ fixture -> getClassName ( ) ] = $ fixture -> getVersion ( ) ? : '0.0' ; } } $ alreadyLoaded = false ; if ( isset ( $ this -> loadedFixtures [ get_class ( $ fixtureObject ) ] ) ) { $ alreadyLoaded = true ; $ loadedVersion = $ this -> loadedFixtures [ get_class ( $ fixtureObject ) ] ; if ( $ fixtureObject instanceof VersionedFixtureInterface && version_compare ( $ loadedVersion , $ fixtureObject -> getVersion ( ) ) == - 1 ) { if ( $ fixtureObject instanceof LoadedFixtureVersionAwareInterface ) { $ fixtureObject -> setLoadedVersion ( $ loadedVersion ) ; } $ alreadyLoaded = false ; } } return $ alreadyLoaded ; }
Determines whether the given data fixture is already loaded or not
4,964
public function setMinute ( $ minute ) { if ( ! in_array ( $ minute , range ( 0 , 59 ) ) ) { throw new InvalidArgumentException ( 'Minute must be between 0 and 59' ) ; } $ this -> minute = $ minute ; return $ this ; }
Sets minutes in repetition
4,965
public function doPostRequest ( $ uri , $ data = null ) { return $ this -> doRequest ( Request :: POST , $ uri , $ data ) ; }
Create POST request to CORAL backend
4,966
public function saveModifiedFiles ( $ installPath ) { DebugPrinter :: log ( 'Saving modified items' ) ; $ tmpRoot = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR ; $ installPath = trim ( $ installPath , '\\/' ) . DIRECTORY_SEPARATOR ; $ fsm = new Filesystem ; DebugPrinter :: log ( 'Items to search: %s' , implode ( ', ' , $ this -> modifiableFiles ) ) ; foreach ( $ this -> modifiableFiles as $ file ) { $ source = $ installPath . $ file ; $ target = $ tmpRoot . md5 ( $ source ) ; if ( ! $ fsm -> exists ( $ source ) ) { DebugPrinter :: log ( 'Item `%s` is missing, skipping it' , $ source ) ; continue ; } $ args = array ( $ source , $ target , ) ; DebugPrinter :: log ( 'Saving `%s` to `%s`' , $ args ) ; if ( is_dir ( $ source ) ) { $ fsm -> mirror ( $ source , $ target ) ; } else { $ fsm -> copy ( $ source , $ target ) ; } } DebugPrinter :: log ( 'Finished saving modified items' ) ; }
Saves config files during install .
4,967
public function restoreModifiedFiles ( $ installPath ) { DebugPrinter :: log ( 'Restoring modified items' ) ; $ tmpRoot = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR ; $ installPath = trim ( $ installPath , '\\/' ) . DIRECTORY_SEPARATOR ; $ fsm = new Filesystem ; DebugPrinter :: log ( 'Items to search: %s' , implode ( ', ' , $ this -> modifiableFiles ) ) ; foreach ( $ this -> modifiableFiles as $ file ) { $ target = $ installPath . $ file ; $ source = $ tmpRoot . md5 ( $ target ) ; if ( ! $ fsm -> exists ( $ source ) ) { DebugPrinter :: log ( 'Item `%s` is missing, skipping it' , $ source ) ; continue ; } $ args = array ( $ source , $ target , ) ; DebugPrinter :: log ( 'Restoring `%s` to `%s`' , $ args ) ; if ( $ fsm -> exists ( $ target ) ) { $ fsm -> remove ( $ target ) ; } $ fsm -> rename ( $ source , $ target , true ) ; } DebugPrinter :: log ( 'Finished restoring modified items' ) ; }
Restores previously saved config files .
4,968
protected function setPermissions ( $ installPath , $ basePerms = 0644 ) { $ fsm = new Filesystem ; foreach ( $ this -> chmodNodes as $ fsNode ) { $ path = $ installPath . DIRECTORY_SEPARATOR . $ fsNode ; $ isFile = is_file ( $ path ) ; $ isDir = is_dir ( $ path ) ; if ( ! $ isFile && ! $ isDir ) { DebugPrinter :: log ( 'Filesystem node %s not found' , $ path ) ; continue ; } $ perms = $ basePerms ; if ( $ isDir ) { $ perms |= 0111 ; } $ args = array ( $ path , decoct ( $ perms ) , ) ; DebugPrinter :: log ( 'Chmodding `%s` to `%s`' , $ args ) ; $ fsm -> chmod ( $ path , $ perms ) ; } }
Sets Opencart folder permissions as required in manual .
4,969
public function rotateInstalledFiles ( $ installPath ) { $ fsm = new Filesystem ; $ tempDir = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . uniqid ( 'oci-' ) ; DebugPrinter :: log ( 'Rotating files using `%s` dir' , $ tempDir ) ; $ dirs = glob ( $ installPath . DIRECTORY_SEPARATOR . '*' , GLOB_ONLYDIR ) ; foreach ( $ dirs as $ key => $ dir ) { if ( $ dir [ 0 ] === '.' ) { unset ( $ dirs [ $ key ] ) ; } } if ( sizeof ( $ dirs ) === 1 ) { $ subDirectory = $ tempDir . DIRECTORY_SEPARATOR . dirname ( reset ( $ dirs ) ) ; $ fsm -> rename ( $ installPath , $ tempDir ) ; $ fsm -> rename ( $ subDirectory , $ installPath ) ; $ fsm -> remove ( $ tempDir ) ; } }
Moves installed files out of upload dir .
4,970
public function copyConfigFiles ( $ installPath ) { $ filesystem = new Filesystem ; $ configFiles = array ( '/config' , '/admin/config' , ) ; foreach ( $ configFiles as $ configFile ) { $ source = $ installPath . $ configFile . '-dist.php' ; $ target = $ installPath . $ configFile . '.php' ; if ( $ filesystem -> exists ( $ source ) ) { $ filesystem -> copy ( $ source , $ target ) ; } else { DebugPrinter :: log ( 'File `%s` doesn\'t exist, though i am sure it should' , $ source ) ; } } }
Copies configuration files from their dists as specified by installation notes .
4,971
public function decodeJson ( $ assoc = false ) { $ result = json_decode ( $ this -> body , $ assoc ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { throw new PipelinerHttpException ( $ this , "Error while parsing returned JSON" ) ; } return $ result ; }
Decodes the response s body into an object .
4,972
protected function appendRelatedModelsToModelData ( array $ model ) { $ relationships = array_merge ( array_get ( $ model , 'relationships.normal' ) , array_get ( $ model , 'relationships.reverse' ) ) ; $ model [ 'related_models' ] = [ ] ; foreach ( $ relationships as $ name => $ relationship ) { $ relatedModelId = $ relationship [ 'model' ] ; if ( isset ( $ model [ 'related_models' ] [ $ relatedModelId ] ) ) continue ; $ model [ 'related_models' ] [ $ relatedModelId ] = $ this -> data [ 'models' ] [ $ relatedModelId ] ; } return $ model ; }
Append related model data for related models
4,973
protected function makeTranslatedDataFromModelData ( array $ model ) { $ sluggable = ( $ model [ 'sluggable' ] && array_get ( $ model , 'sluggable_setup.translated' ) ) ; return [ 'module' => $ model [ 'module' ] , 'name' => $ model [ 'name' ] . config ( 'pxlcms.generator.models.translation_model_postfix' ) , 'table' => ! empty ( $ model [ 'table' ] ) ? $ model [ 'table' ] . snake_case ( config ( 'pxlcms.tables.translation_postfix' , '_ml' ) ) : null , 'cached' => $ model [ 'cached' ] , 'is_translated' => false , 'is_translation' => true , 'is_listified' => false , 'order_by' => [ ] , 'normal_fillable' => $ model [ 'translated_attributes' ] , 'translated_fillable' => [ ] , 'hidden' => [ ] , 'casts' => [ ] , 'dates' => [ ] , 'defaults' => [ ] , 'normal_attributes' => [ ] , 'translated_attributes' => [ ] , 'timestamps' => null , 'categories_module' => null , 'relations_config' => [ ] , 'relationships' => [ 'normal' => [ ] , 'reverse' => [ ] , 'image' => [ ] , 'file' => [ ] , 'checkbox' => [ ] , ] , 'sluggable' => $ sluggable , 'sluggable_setup' => $ sluggable ? $ model [ 'sluggable_setup' ] : [ ] , 'scope_active' => false , 'scope_position' => false , ] ; }
Make model data array for translation model
4,974
public function get ( ) { return array_key_exists ( $ this -> subject -> getName ( ) , $ this -> matches ) ? $ this -> matches [ $ this -> subject -> getName ( ) ] -> get ( ) : $ this -> surrogate -> get ( ) ; }
Provides the value the instance of the mapped subject is mapped to or throws a runtime exception if the instance has not been mapped to anything .
4,975
static function factory ( Plugin $ plugin , $ type ) { $ plugin -> validator -> extend ( 'can_edit' , function ( $ attribute , $ value , $ parameters , $ validator ) { if ( empty ( $ value ) ) { return false ; } $ current_user = wp_get_current_user ( ) ; if ( empty ( $ current_user ) ) { return false ; } if ( $ attribute === 'user_id' ) { $ target_user = get_user_by ( 'ID' , $ value ) ; } else { $ target_user = get_user_by ( $ attribute , $ value ) ; } if ( $ current_user -> ID === $ target_user -> ID ) { return true ; } else if ( $ current_user -> can ( 'administrator' ) ) { return true ; } else { return false ; } } ) ; if ( empty ( $ type ) ) { throw new \ Exception ( "Missing required argument: type" ) ; } $ type = urldecode ( $ type ) ; if ( class_exists ( $ type ) ) { $ implements = class_implements ( $ type ) ; if ( ! isset ( $ implements [ 'FatPanda\Illuminate\WordPress\Concerns\ProfileSectionContract' ] ) ) { throw new \ Exception ( "Profile Section type {$type} does not implement ProfileSectionContract" ) ; } $ section = new $ type ( ) ; $ section -> setPlugin ( $ plugin ) ; return $ section ; } else { return new SimpleProfileSection ( $ type ) ; } }
Create a profile section of the given type and associate it with the given Plugin
4,976
public function usePermissionRelatedByParentIdQuery ( $ relationAlias = null , $ joinType = Criteria :: LEFT_JOIN ) { return $ this -> joinPermissionRelatedByParentId ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'PermissionRelatedByParentId' , '\Alchemy\Component\Cerberus\Model\PermissionQuery' ) ; }
Use the PermissionRelatedByParentId relation Permission object
4,977
public function usePermissionRelatedByIdQuery ( $ relationAlias = null , $ joinType = Criteria :: LEFT_JOIN ) { return $ this -> joinPermissionRelatedById ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'PermissionRelatedById' , '\Alchemy\Component\Cerberus\Model\PermissionQuery' ) ; }
Use the PermissionRelatedById relation Permission object
4,978
public function filterByRolePermission ( $ rolePermission , $ comparison = null ) { if ( $ rolePermission instanceof \ Alchemy \ Component \ Cerberus \ Model \ RolePermission ) { return $ this -> addUsingAlias ( PermissionTableMap :: COL_ID , $ rolePermission -> getPermissionId ( ) , $ comparison ) ; } elseif ( $ rolePermission instanceof ObjectCollection ) { return $ this -> useRolePermissionQuery ( ) -> filterByPrimaryKeys ( $ rolePermission -> getPrimaryKeys ( ) ) -> endUse ( ) ; } else { throw new PropelException ( 'filterByRolePermission() only accepts arguments of type \Alchemy\Component\Cerberus\Model\RolePermission or Collection' ) ; } }
Filter the query by a related \ Alchemy \ Component \ Cerberus \ Model \ RolePermission object
4,979
public function filterByRole ( $ role , $ comparison = Criteria :: EQUAL ) { return $ this -> useRolePermissionQuery ( ) -> filterByRole ( $ role , $ comparison ) -> endUse ( ) ; }
Filter the query by a related Role object using the role_permission table as cross reference
4,980
public function setStatusCode ( int $ statusCode , string $ reasonPhrase = null ) : Response { $ this -> status -> setCode ( $ statusCode , $ reasonPhrase ) ; return $ this ; }
sets the status code to be send
4,981
public function addHeader ( string $ name , string $ value ) : Response { $ this -> headers -> add ( $ name , $ value ) ; return $ this ; }
add a header to the response
4,982
public function containsHeader ( string $ name , string $ value = null ) : bool { if ( $ this -> headers -> contain ( $ name ) ) { if ( null !== $ value ) { return $ value === $ this -> headers [ $ name ] ; } return true ; } return false ; }
check if response contains a certain header
4,983
public function addCookie ( Cookie $ cookie ) : Response { $ this -> cookies [ $ cookie -> name ( ) ] = $ cookie ; return $ this ; }
add a cookie to the response
4,984
public function removeCookie ( string $ name ) : Response { $ this -> addCookie ( Cookie :: create ( $ name , 'remove' ) -> expiringAt ( time ( ) - 86400 ) ) ; return $ this ; }
removes cookie with given name
4,985
public function containsCookie ( string $ name , string $ value = null ) : bool { if ( isset ( $ this -> cookies [ $ name ] ) ) { if ( null !== $ value ) { return $ this -> cookies [ $ name ] -> value ( ) === $ value ; } return true ; } return false ; }
checks if response contains a certain cookie
4,986
public function methodNotAllowed ( string $ requestMethod , array $ allowedMethods ) : Error { $ this -> status -> methodNotAllowed ( $ allowedMethods ) ; return Error :: methodNotAllowed ( $ requestMethod , $ allowedMethods ) ; }
creates a 405 Method Not Allowed message
4,987
private function sendHead ( ) : Response { $ this -> header ( $ this -> status -> line ( $ this -> version , $ this -> sapi ) ) ; foreach ( $ this -> headers as $ name => $ value ) { $ this -> header ( $ name . ': ' . $ value ) ; } foreach ( $ this -> cookies as $ cookie ) { $ cookie -> send ( ) ; } $ this -> header ( 'Content-type: ' . $ this -> mimeType ) ; if ( ! $ this -> headers -> contain ( 'X-Request-ID' ) ) { $ this -> header ( 'X-Request-ID: ' . $ this -> request -> id ( ) ) ; } return $ this ; }
sends head only
4,988
public function selectremote ( Panel \ Action \ SelectRemote $ action ) { $ element = $ action -> getElement ( ) ; $ element -> addAttribute ( 'id' , $ element -> getName ( ) ) ; $ element -> addClass ( 'select2-remote input-callback' ) ; $ element -> addAttribute ( 'data-css' , 'form-control input-large input-sm' ) ; $ element -> addAttribute ( 'data-remote' , $ element -> getUrl ( ) ) ; $ element -> addAttribute ( 'data-length' , $ element -> getLength ( ) ) ; $ element -> addAttribute ( 'data-action' , $ action -> getUrl ( ) ) ; $ element -> addAttribute ( 'data-method' , 'post' ) ; $ element -> addAttribute ( 'placeholder' , $ element -> getLabel ( ) ) ; $ html = html ( 'input' , $ element -> getAttributes ( ) ) ; return $ html ; }
Render a Select 2
4,989
public static function listSubscriptions ( $ user , $ page = 1 , $ per_page = 20 , $ order_by = self :: ORDERBY_CREATED_AT , $ order_dir = self :: ORDERDIR_ASC , $ include_finished = false , $ hash_type = false , $ hash = false ) { if ( $ page < 1 ) { throw new DataSift_Exception_InvalidData ( "The specified page number is invalid" ) ; } if ( $ per_page < 1 ) { throw new DataSift_Exception_InvalidData ( "The specified per_page value is invalid" ) ; } $ params = array ( 'page' => $ page , 'per_page' => $ per_page , 'order_by' => $ order_by , 'order_dir' => $ order_dir , ) ; if ( $ hash_type !== false && $ hash !== false ) { $ params [ $ hash_type ] = $ hash ; } if ( $ include_finished ) { $ params [ 'include_finished' ] = '1' ; } $ res = $ user -> post ( 'push/get' , $ params ) ; $ retval = array ( 'count' => $ res [ 'count' ] , 'subscriptions' => array ( ) ) ; foreach ( $ res [ 'subscriptions' ] as $ sub ) { $ retval [ 'subscriptions' ] [ ] = new self ( $ user , $ sub ) ; } return $ retval ; }
Get a page of push subscriptions in the given user s account where each page contains up to per_page items . Results will be ordered according to the supplied ordering parameters .
4,990
public static function listByPlaybackId ( $ user , $ playback_id , $ page = 1 , $ per_page = 20 , $ order_by = self :: ORDERBY_CREATED_AT , $ order_dir = self :: ORDERDIR_ASC , $ include_finished = false , $ hash_type = false , $ hash = false ) { return self :: listSubscriptions ( $ user , $ page , $ per_page , $ order_by , $ order_dir , $ include_finished , 'playback_id' , $ playback_id ) ; }
Get a page of push subscriptions to the given stream playback_id where each page contains up to per_page items . Results will be ordered according to the supplied ordering parameters .
4,991
protected function init ( $ data ) { if ( ! isset ( $ data [ 'id' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No id found' ) ; } $ this -> _id = $ data [ 'id' ] ; if ( ! isset ( $ data [ 'name' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No name found' ) ; } $ this -> _name = $ data [ 'name' ] ; if ( ! isset ( $ data [ 'created_at' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No created_at found' ) ; } $ this -> _created_at = $ data [ 'created_at' ] ; if ( ! isset ( $ data [ 'status' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No status found' ) ; } $ this -> _status = $ data [ 'status' ] ; if ( ! isset ( $ data [ 'hash_type' ] , $ data ) ) { throw new DataSift_Exception_InvalidData ( 'No hash_type found' ) ; } $ this -> _hash_type = $ data [ 'hash_type' ] ; if ( ! isset ( $ data [ 'hash' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No hash found' ) ; } $ this -> _hash = $ data [ 'hash' ] ; if ( ! isset ( $ data [ 'last_request' ] ) ) { $ this -> _last_request = 0 ; } else { $ this -> _last_request = $ data [ 'last_request' ] ; } if ( ! isset ( $ data [ 'last_success' ] ) ) { $ this -> _last_success = 0 ; } else { $ this -> _last_success = $ data [ 'last_success' ] ; } if ( ! isset ( $ data [ 'output_type' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No output_type found' ) ; } $ this -> _output_type = $ data [ 'output_type' ] ; if ( ! isset ( $ data [ 'output_params' ] ) ) { throw new DataSift_Exception_InvalidData ( 'No output_params found' ) ; } $ this -> _output_params = $ this -> parseOutputParams ( $ data [ 'output_params' ] ) ; }
Extract data from an array .
4,992
protected function parseOutputParams ( $ params , $ prefix = '' ) { $ retval = array ( ) ; foreach ( $ params as $ key => $ val ) { if ( is_array ( $ val ) ) { $ retval = array_merge ( $ retval , $ this -> parseOutputParams ( $ val , $ prefix . $ key . '.' ) ) ; } else { $ retval [ $ prefix . $ key ] = $ val ; } } return $ retval ; }
Recursive method to parse the output_params as received from the API into the flattened dot - notation used by the client libraries .
4,993
public function setOutputParam ( $ key , $ val ) { if ( $ this -> isDeleted ( ) ) { throw new DataSift_Exception_InvalidData ( 'Cannot modify a deleted subscription' ) ; } parent :: setOutputParam ( $ key , $ val ) ; }
Set an output parameter . Checks to see if the subscription has been deleted and if not calls the base class to set the parameter .
4,994
public function save ( ) { $ params = array ( 'id' => $ this -> getId ( ) , 'name' => $ this -> getName ( ) ) ; foreach ( $ this -> _output_params as $ key => $ val ) { $ params [ DataSift_Push_Definition :: OUTPUT_PARAMS_PREFIX . $ key ] = $ val ; } $ this -> init ( $ this -> _user -> post ( 'push/update' , $ params ) ) ; }
Save changes to the name and output_parameters of this subscription .
4,995
public function delete ( ) { $ this -> _user -> post ( 'push/delete' , array ( 'id' => $ this -> getId ( ) ) ) ; $ this -> _status = self :: STATUS_DELETED ; }
Delete this subscription .
4,996
public function pull ( $ size = 20971520 , $ cursor = false ) { if ( strtolower ( $ this -> _output_type ) != 'pull' ) { throw new DataSift_Exception_InvalidData ( "Output type is not pull" ) ; } $ params = array ( 'id' => $ this -> getId ( ) , 'size' => $ size ) ; if ( $ cursor !== false ) { $ params [ 'cursor' ] = $ cursor ; } return $ this -> _user -> get ( 'pull' , $ params ) ; }
Pull data from this subscription .
4,997
public function getLog ( $ page = 1 , $ per_page = 20 , $ order_by = self :: ORDERBY_REQUEST_TIME , $ order_dir = self :: ORDERDIR_DESC ) { return self :: getLogs ( $ this -> _user , $ page , $ per_page , $ order_by , $ order_dir , $ this -> getId ( ) ) ; }
Get a page of the log for this subscription order as specified .
4,998
public function rewind ( ) { if ( ! $ this -> rewindable && ! $ this -> firstCross ) { throw new \ Exception ( 'Unable to traverse not rewindable iterator multiple time' ) ; } $ this -> firstCross = false ; $ this -> position = 0 ; }
Rewinds the Iterator to the first element .
4,999
public function count ( ) { if ( ! isset ( $ this -> count ) ) { $ this -> count = $ this -> repository -> count ( $ this -> query ) ; } return $ this -> count ; }
Count number of document from collection