idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
6,700
public function get ( $ key ) { if ( $ this -> has ( $ key ) ) { return $ this -> cookies [ $ key ] ; } else { throw new RuntimeException ( sprintf ( 'Attempted to read non-existing cookie "%s"' , $ key ) ) ; } }
Retrieves a key form cookies
6,701
public function remove ( $ key ) { if ( $ this -> has ( $ key ) ) { $ this -> set ( $ key , '' , - 86400 ) ; unset ( $ this -> cookies [ $ key ] ) ; return true ; } else { return false ; } }
Removes a cookie by its associated key
6,702
public static function createRandom ( $ passes = 1 ) : self { for ( $ i = 0 ; $ i < $ passes ; $ i ++ ) { $ sensor = new self ( Random :: randomFloat ( - 0.3 , 0.3 ) , Random :: randomFloat ( - 0.2 , 2.5 ) , Random :: randomFloat ( - 0.2 , 5 ) , Random :: randomFloat ( 0.08 , 0.20 ) , Random :: randomFloat ( 0.45 , 0.6...
Create random sensor data
6,703
private function buildDigitList ( $ radix ) { if ( $ radix <= strlen ( self :: $ integerBase ) ) { return str_split ( substr ( self :: $ integerBase , 0 , $ radix ) ) ; } elseif ( $ radix === 64 ) { return str_split ( self :: $ integerBase64 ) ; } elseif ( $ radix <= 256 ) { return range ( chr ( 0 ) , chr ( $ radix - 1...
Builds the list of digits according to the radix .
6,704
private function buildArbitraryList ( $ radix ) { $ format = '#%0' . strlen ( $ radix - 1 ) . 'd' ; return array_map ( function ( $ value ) use ( $ format ) { return sprintf ( $ format , $ value ) ; } , range ( 0 , $ radix - 1 ) ) ; }
Builds the list of digits for arbitrary radix .
6,705
protected function executeQuery ( $ uri , $ type = self :: HTTP_GET , $ variables = [ ] , $ contentType = self :: CONTENT_TYPE_FORM ) : BookboonResponse { $ http = curl_init ( ) ; $ headers = $ this -> getHeaders ( ) -> getAll ( ) ; if ( $ type === self :: HTTP_POST ) { $ encodedVariables = $ this -> encodeByContentTyp...
Makes the actual query call to the remote api .
6,706
public function isValid ( $ answer ) { if ( $ this -> storage -> get ( ) == $ answer ) { return true ; } else { $ this -> error = 'Invalid answer provided' ; return false ; } }
Checks whether CAPTCHA answer is valid Should be always called after rendering
6,707
public function execute ( Request $ request , Position $ position ) { $ response = $ this -> batchExecute ( [ $ request ] , $ position ) ; return $ request -> getResponse ( current ( $ response ) ) ; }
Execute a request
6,708
protected function setEndpoint ( string $ endpoint ) { $ fullEndpoint = 'https://' . $ endpoint . '/rpc' ; if ( ! empty ( $ endpoint ) && $ fullEndpoint !== $ this -> endpoint ) { $ this -> endpoint = $ fullEndpoint ; } }
Set the endpoint to use
6,709
protected function createEnvelope ( array $ requests , Position $ position ) : RequestEnvelope { $ authInfo = null ; $ envelope = new RequestEnvelope ( ) ; $ envelope -> setStatusCode ( 2 ) ; $ envelope -> setLatitude ( $ position -> getLatitude ( ) ) ; $ envelope -> setLongitude ( $ position -> getLongitude ( ) ) ; $ ...
Create a request envelope
6,710
protected function generateLocationFixes ( Position $ position ) : array { $ amount = rand ( 3 , 5 ) ; $ fixes = [ ] ; for ( $ i = 0 ; $ i < $ amount ; $ i ++ ) { $ fixes [ ] = $ this -> generateLocationFix ( $ position ) ; } return $ fixes ; }
Generate a list of location fixes
6,711
protected function generateLocationFix ( Position $ position ) : Signature \ LocationFix { $ location = $ position -> createRandomized ( ) ; $ locationFix = new Signature \ LocationFix ( ) ; $ locationFix -> setProvider ( "network" ) ; $ locationFix -> setProviderStatus ( 3 ) ; $ locationFix -> setLocationType ( 1 ) ; ...
Generate a location fix
6,712
protected function generateSensorInfo ( ) : MessageCollection { $ list = new MessageCollection ( ) ; $ sensorData = Sensors :: createRandom ( 3 ) ; $ rawAccell = $ sensorData -> getAccelerometerData ( ) ; $ normAccell = $ sensorData -> getNormalizedAccelerometerData ( ) ; $ angle = $ sensorData -> getAngleData ( ) ; $ ...
Generate sensor information
6,713
public function getExpiration ( ) { $ dateTime = new DateTime ( ) ; return $ dateTime -> setDate ( $ this -> year , $ this -> month , $ this -> getMonthDays ( ) ) -> setTime ( 23 , 59 , 59 ) ; }
Returns expiration date
6,714
public function createInstance ( ) { $ classname = $ this -> getProjectClassname ( ) ; if ( ! class_exists ( $ classname ) ) { throw new \ Exception ( sprintf ( 'Unable to locate class %s' , $ classname ) ) ; } return new $ classname ( ) ; }
Create project type instance .
6,715
private function createBreadcrumbItems ( ) { $ itemClass = $ this -> getOption ( 'itemClass' , null ) ; $ itemActiveClass = $ this -> getOption ( 'itemActiveClass' , 'active' ) ; $ linkClass = $ this -> getOption ( 'linkClass' , null ) ; $ items = array ( ) ; foreach ( $ this -> breadcrumbBag -> getBreadcrumbs ( ) as $...
Create breadcrumb nodes
6,716
public function answerCallbackQuery ( ) : AnswerCallbackQuery { $ m = $ this -> bot -> AnswerCallbackQuery ( ) ; $ m -> setCallbackQueryId ( $ this -> query -> getId ( ) ) ; return $ m ; }
Answer the callback query .
6,717
public function isRenderable ( ) { $ intro = $ this -> getIntro ( ) ; $ result = true ; if ( $ this -> countCancel >= $ intro -> getMaxCancelLimit ( ) ) { $ result = false ; } if ( $ this -> countShow >= $ intro -> getMaxShowLimit ( ) ) { $ result = false ; } return $ result ; }
Verifica que se deba renderizar el intro de acuerdo al log
6,718
public function binDumpFile ( array $ files , array $ user_vars , $ filename , $ flags = 0 , $ context = null ) { return apc_bin_dumpfile ( $ files , $ user_vars , $ filename , $ flags , $ context ) ; }
Output a binary dump of cached files and user variables to a file
6,719
private function validUnitType ( $ unitType ) { if ( ! isset ( $ this -> unitTypes [ $ unitType ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The Unit Type "%s" is not register on Unit Converter(%s)' , $ unitType , implode ( array_keys ( $ this -> unitTypes ) , ',' ) ) ) ; } return true ; }
Valida un tipo de unidad
6,720
public function validateUnit ( $ type , $ unit , $ validUnits = null ) { return ( $ this -> findUnit ( $ type , $ unit , $ validUnits ) !== false ) ; }
Valida una unidad dada en cualquiera de sus alias
6,721
public function translateArray ( array $ array ) { $ result = array ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ key = $ this -> translate ( $ key ) ; if ( ! isset ( $ result [ $ key ] ) ) { $ result [ $ key ] = array ( ) ; } foreach ( $ value as $ index => $ inner ) { $ result [ $ ke...
Translate array values if possible
6,722
public static function create ( Error $ error ) { switch ( $ error -> code ) { case Error :: CODE_PARSE_ERROR : return new ParseErrorException ( $ error ) ; case Error :: CODE_INVALID_REQUEST : return new InvalidRequestException ( $ error ) ; case Error :: CODE_METHOD_NOT_FOUND : return new MethodNotFoundException ( $ ...
Factory method which returns a different exception based on the error code
6,723
public function load ( $ data ) { $ values = explode ( ',' , $ data ) ; if ( $ values === false ) { $ values = array ( ) ; } else { array_walk ( $ values , function ( $ value , $ key ) use ( & $ values ) { if ( empty ( $ value ) ) { unset ( $ values [ $ key ] ) ; } } ) ; } $ this -> values = $ values ; }
Loads data from a string
6,724
private function add ( $ value , $ function ) { if ( ! $ this -> exists ( $ value ) ) { $ function ( $ this -> values , $ value ) ; if ( $ this -> isLimitExceeded ( ) ) { $ this -> removeLatest ( ) ; } return true ; } else { return false ; } }
Adds a value to the stack
6,725
public function connect ( ) { foreach ( $ this -> connections as $ address => $ conn ) { if ( $ conn -> isTimedOut ( ) ) { $ conn -> close ( ) ; unset ( $ this -> connections [ $ address ] ) ; } } foreach ( $ this -> addresses as $ address ) { if ( ! isset ( $ this -> connections [ $ address ] ) ) { try { $ this -> con...
Establish a connection to all servers in the pool
6,726
public function close ( ) { foreach ( $ this -> connections as $ conn ) { $ conn -> close ( ) ; } $ this -> using = false ; $ this -> watching = array ( ) ; $ this -> ignoring = array ( ) ; }
Close all connections in the pool
6,727
protected function sendToRandomConnection ( $ command ) { $ this -> connect ( ) ; $ args = array ( ) ; if ( func_num_args ( ) > 1 ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; } $ i = $ this -> lastConnection = array_rand ( $ this -> connections ) ; return call_user_func_array ( array ( $ this -> connection...
Sends the command to a random connection in the pool
6,728
protected function sendToAllConnections ( $ command ) { $ this -> connect ( ) ; $ args = array ( ) ; if ( func_num_args ( ) > 1 ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; } $ ret = array ( ) ; foreach ( $ this -> connections as $ conn ) { $ ret [ ] = call_user_func_array ( array ( $ conn , $ command ) , ...
Sends the command to all connections in the pool
6,729
public static function doHardGetOption ( $ optionName , $ defaultValue = 0 ) { global $ wpdb ; $ optionValue = $ wpdb -> get_var ( $ wpdb -> prepare ( " SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = %s " , $ optionName ) ) ; if ( ! is_null ( $ optionValue ) ) { return $ optionValue ; } ...
Gets the option value from the wp_options database . This is a hard get as it queries the database directly to avoid any caching .
6,730
public static function wrapMany ( array $ keys ) { foreach ( $ keys as & $ key ) { $ key = self :: wrap ( $ key ) ; } return $ keys ; }
Wrap many keys
6,731
private function beautifyAuthorList ( $ authors ) { if ( $ authors === null ) { return null ; } $ authors = \ array_intersect_key ( $ authors , \ array_unique ( \ array_map ( 'strtolower' , $ authors ) ) ) ; \ usort ( $ authors , 'strcasecmp' ) ; $ mapped = [ ] ; foreach ( $ authors as $ author ) { $ mapped [ \ strtolo...
Ensure the list is case insensitively unique and that the authors are sorted .
6,732
protected function setupFinder ( ) { $ finder = new Finder ( ) ; $ finder -> in ( $ this -> config -> getIncludedPaths ( ) ) -> notPath ( '/vendor/' ) -> files ( ) ; foreach ( $ this -> config -> getExcludedPaths ( ) as $ excluded ) { $ finder -> notPath ( $ excluded ) ; } return $ finder ; }
Setup the Symfony Finder .
6,733
public function push ( CompositableInterface $ entity ) : DocumentCompositor { $ entity = clone $ entity ; $ this -> assertSupported ( $ entity ) ; $ this -> entities [ ] = $ entity ; $ this -> atomics [ '$push' ] [ ] = $ entity ; return $ this ; }
Push new entity to end of set .
6,734
public function add ( CompositableInterface $ entity ) : DocumentCompositor { $ entity = clone $ entity ; $ this -> assertSupported ( $ entity ) ; if ( ! $ this -> has ( $ entity ) ) { $ this -> entities [ ] = $ entity ; } $ this -> atomics [ '$addToSet' ] [ ] = $ entity ; return $ this ; }
Add entity to set only one instance of document must be presented .
6,735
public function pull ( CompositableInterface $ entity ) : DocumentCompositor { $ targets = $ this -> find ( $ entity , true ) ; foreach ( $ targets as $ offset => $ target ) { unset ( $ this -> entities [ $ offset ] ) ; } $ this -> atomics [ '$pull' ] [ ] = clone $ entity ; return $ this ; }
Pull mathced entities from composition .
6,736
public function findOne ( $ query ) { $ entities = $ this -> find ( $ query ) ; if ( empty ( $ entities ) ) { return null ; } return current ( $ entities ) ; }
Find document in composition based on given entity or matching query .
6,737
protected function assertSupported ( CompositableInterface $ entity ) { if ( ! is_object ( $ entity ) || ! is_a ( $ entity , $ this -> class ) ) { throw new CompositorException ( sprintf ( "Only instances of '%s' supported, '%s' given" , $ this -> class , is_object ( $ entity ) ? get_class ( $ entity ) : gettype ( $ en...
Assert that given entity supported by composition .
6,738
private function createEntities ( array $ data , bool $ filter = true ) : array { $ result = [ ] ; foreach ( $ data as $ item ) { if ( $ item instanceof CompositableInterface ) { $ this -> assertSupported ( $ item ) ; $ result [ ] = clone $ item ; } else { $ result [ ] = $ this -> odm -> make ( $ this -> class , $ item...
Instantiate every entity in composition .
6,739
private function packValues ( array $ entities ) : array { $ result = [ ] ; foreach ( $ entities as $ entity ) { $ result [ ] = $ entity -> packValue ( ) ; } return $ result ; }
Pack multiple entities into array form .
6,740
protected function prepareView ( FormView $ view , FormInterface $ form , array $ options ) { if ( isset ( $ options [ 'choice_loader' ] ) && $ options [ 'choice_loader' ] instanceof DynamicChoiceLoaderInterface ) { $ loader = $ options [ 'choice_loader' ] ; $ values = $ form -> getData ( ) instanceof ArrayCollection ?...
Prepare the view .
6,741
protected function getAjaxUrlAndRouteName ( FormInterface $ form , array $ options ) { $ ajaxUrl = $ this -> requestStack -> getMasterRequest ( ) -> getRequestUri ( ) ; $ routeName = null ; if ( $ options [ 'select2' ] [ 'ajax' ] ) { if ( null !== $ options [ 'select2' ] [ 'ajax_url' ] ) { $ ajaxUrl = $ options [ 'sele...
Gets the ajax url and route name .
6,742
protected function getChoiceLoader ( FormInterface $ form , array $ options ) { $ choiceLoader = $ form -> getConfig ( ) -> getAttribute ( 'choice_loader' ) ; if ( isset ( $ options [ 'choice_loader' ] ) ) { $ choiceLoader = $ options [ 'choice_loader' ] ; } return $ choiceLoader ; }
Get choice loader .
6,743
protected function getReplaceViewVars ( FormView $ view , array $ options , $ ajaxUrl , $ routeName ) { $ allowClear = $ options [ 'required' ] ? null : 'true' ; $ allowClear = isset ( $ options [ 'select2' ] [ 'allow_clear' ] ) ? 'true' : $ allowClear ; return [ 'select2' => $ this -> skipNullValue ( [ 'wrapper_attr' ...
Gets the new view vars for the replacement .
6,744
protected function skipNullValue ( array $ attributes ) { $ attr = [ ] ; foreach ( $ attributes as $ key => $ value ) { if ( null !== $ value ) { $ attr [ $ key ] = \ is_array ( $ value ) ? $ this -> skipNullValue ( $ value ) : $ value ; } } return $ attr ; }
Remove the key with null values .
6,745
public function setEncryption ( string $ encryption ) : SecurityTxt { if ( ! $ this -> validEncryption ( $ encryption ) ) { throw new Exception ( 'Encryption must be a well-formed URL.' ) ; } $ this -> encryption = $ encryption ; return $ this ; }
Set the encryption .
6,746
private function matchPattern ( $ pathName , $ pattern ) { if ( $ pattern [ 0 ] !== '/' ) { $ pattern = '**/' . $ pattern ; } if ( \ fnmatch ( $ pattern , $ pathName ) ) { return true ; } return false ; }
Match the passed path name against the pattern .
6,747
private function matchPatterns ( $ pathName , $ patternList ) { foreach ( $ patternList as $ pattern ) { if ( $ this -> matchPattern ( $ pathName , $ pattern ) ) { return $ pattern ; } } return false ; }
Match the passed path name against the pattern list .
6,748
public function addFromYml ( $ fileName ) { if ( ! \ is_readable ( $ fileName ) ) { throw new \ InvalidArgumentException ( 'Could not read config file: ' . $ fileName ) ; } $ config = Yaml :: parse ( \ file_get_contents ( $ fileName ) ) ; if ( isset ( $ config [ 'mapping' ] ) ) { $ this -> addAuthorMap ( $ config [ 'ma...
Retrieve the configuration file and merge it into the instance .
6,749
public function aliasAuthor ( $ alias , $ realAuthor ) { $ this -> mapping [ $ this -> arrayKey ( $ alias ) ] = trim ( $ realAuthor ) ; return $ this ; }
Add an author alias .
6,750
public function addAuthorMap ( $ mapping ) { foreach ( $ mapping as $ author => $ aliases ) { if ( \ is_array ( $ aliases ) ) { foreach ( $ aliases as $ alias ) { $ this -> aliasAuthor ( $ alias , $ author ) ; } } else { $ this -> aliasAuthor ( $ aliases , $ author ) ; } } return $ this ; }
Absorb the author mapping .
6,751
public function getRealAuthor ( $ author ) { if ( $ this -> isAuthorIgnored ( $ author ) ) { return null ; } if ( $ this -> isAlias ( $ author ) ) { $ author = $ this -> mapping [ $ this -> arrayKey ( $ author ) ] ; } if ( $ this -> isAuthorIgnored ( $ author ) ) { return null ; } return $ author ; }
Translate an author alias to the real name but return null if the author shall be ignored .
6,752
public function ignoreAuthor ( $ author ) { $ this -> ignoredAuthors [ $ this -> arrayKey ( $ author ) ] = \ trim ( $ author ) ; return $ this ; }
Ignore the given author .
6,753
public function addCopyLeft ( $ author , $ pattern ) { if ( \ is_array ( $ pattern ) ) { foreach ( $ pattern as $ singlePattern ) { $ this -> addCopyLeft ( $ author , $ singlePattern ) ; } return $ this ; } $ this -> copyLeft [ $ this -> arrayKey ( $ author ) ] [ $ this -> arrayKey ( $ pattern ) ] = $ pattern ; $ this ...
Add the the given authors to the copy - left list using the given pattern .
6,754
public function addCopyLeftAuthors ( $ authors ) { foreach ( $ authors as $ author => $ pattern ) { $ this -> addCopyLeft ( $ author , $ pattern ) ; } return $ this ; }
Add the the given authors to the copy - left list .
6,755
public function isCopyLeftAuthor ( $ author , $ pathName ) { $ key = $ this -> arrayKey ( $ author ) ; if ( ! isset ( $ this -> copyLeft [ $ key ] ) ) { return false ; } return ( bool ) $ this -> matchPatterns ( $ pathName , $ this -> copyLeft [ $ key ] ) ; }
Check if an author is listed as copy - left contributor .
6,756
public function getCopyLeftAuthors ( $ pathName ) { $ result = [ ] ; foreach ( $ this -> copyLeft as $ author => $ paths ) { if ( $ this -> matchPatterns ( $ pathName , $ paths ) ) { $ realAuthor = $ this -> getRealAuthor ( $ this -> copyLeftReal [ $ author ] ) ; $ result [ $ this -> arrayKey ( $ realAuthor ) ] = $ rea...
Obtain authors to be listed as copy - left contributor .
6,757
public function addAuthorsMetadata ( $ metadata ) { foreach ( $ metadata as $ author => $ data ) { foreach ( $ data as $ name => $ value ) { $ this -> setMetadata ( $ author , $ name , $ value ) ; } } return $ this ; }
Add authors metadata .
6,758
public function hasMetadata ( $ author , $ name ) { return isset ( $ this -> metadata [ $ this -> arrayKey ( $ author ) ] [ $ name ] ) ; }
Check if a specific author metadata is defined .
6,759
public function getMetadata ( $ author , $ name ) { $ author = $ this -> arrayKey ( $ author ) ; if ( isset ( $ this -> metadata [ $ author ] [ $ name ] ) ) { return $ this -> metadata [ $ author ] [ $ name ] ; } return null ; }
Get a specific meta data for an author .
6,760
public function setMetadata ( $ author , $ name , $ value ) { $ this -> metadata [ $ this -> arrayKey ( $ author ) ] [ $ name ] = $ value ; return $ this ; }
Set a specific meta data for an author .
6,761
public function handleClose ( ) { if ( $ this -> autoClose === true && is_resource ( $ this -> resource ) ) { fclose ( $ this -> resource ) ; } }
Handle the close of the stream object .
6,762
protected function configureSelector ( DocumentSelector $ selector , array $ aggregation ) : DocumentSelector { $ query = $ aggregation [ 2 ] ; array_walk_recursive ( $ query , function ( & $ value ) { if ( strpos ( $ value , 'self::' ) === 0 ) { $ value = $ this -> findValue ( substr ( $ value , 6 ) ) ; } } ) ; return...
Configure DocumentSelector using aggregation schema .
6,763
private function findValue ( string $ name ) { $ source = $ this -> source ; $ path = explode ( '.' , $ name ) ; foreach ( $ path as $ step ) { if ( $ source instanceof EntityInterface ) { if ( ! $ source -> hasField ( $ step ) ) { return null ; } $ source = $ source -> getField ( $ step ) ; continue ; } if ( $ source ...
Find field value using dot notation .
6,764
protected function normalizeHeaders ( array $ headers ) : array { $ returnHeaders = [ ] ; foreach ( $ headers as $ key => $ header ) { $ returnHeaders [ $ key ] = $ header [ 0 ] ?? $ header ; } return $ returnHeaders ; }
Return specific header value from string of headers .
6,765
public function updateCMSFields ( FieldList $ fields ) { $ owner = $ this -> owner ; $ fields -> removeByName ( array ( 'MD5Email' , 'NewsID' ) ) ; $ fields -> addFieldsToTab ( 'Root.Main' , array ( TextField :: create ( 'Title' , $ owner -> fieldLabel ( 'Title' ) ) , TextField :: create ( 'Name' , $ owner -> fieldLabe...
Setup the fields for the CMS .
6,766
public function execute ( ) { $ this -> label = str_replace ( array ( '#dbName#' , '#nbQueries#' , '#totalDuration#' ) , array ( $ this -> dbName , count ( $ this -> payload ) - 1 , round ( $ this -> totalDuration , 2 ) ) , $ this -> label ) ; $ this -> firephp -> fb ( array ( $ this -> label , $ this -> payload ) , \ ...
outputs the payload
6,767
public function renderFilter ( $ groupFilter , $ filterName , \ Tecnocreaciones \ Bundle \ ToolsBundle \ Model \ Search \ BaseFilter $ filter ) { if ( empty ( $ groupFilter ) ) { return "Error de filtro: " . $ filterName . " - ref: " . $ filter -> getRef ( ) ; } $ template = $ this -> twig -> loadTemplate ( $ groupFilt...
Renderiza un filtro
6,768
public function registerMiddleware ( $ middlewareInstance ) { if ( isset ( class_uses ( $ middlewareInstance ) [ 'Nf\Middleware\Pre' ] ) ) { $ key = self :: MIDDLEWARE_PRE ; } else { $ key = self :: MIDDLEWARE_POST ; } $ this -> registeredMiddlewares [ $ key ] [ ] = $ middlewareInstance ; }
registers a middleware programmatically and not through a route
6,769
public function launchAction ( ) { self :: $ obLevel = ob_get_level ( ) ; if ( php_sapi_name ( ) != 'cli' ) { ob_start ( ) ; } $ router = $ this -> _router ; $ activeRoute = $ router -> getActiveRoute ( ) ; if ( isset ( $ activeRoute [ 'contentType' ] ) ) { $ this -> _response -> setContentType ( $ activeRoute [ 'conte...
calls the actual action found from the routing system
6,770
public function postLaunchAction ( ) { $ reflected = new \ ReflectionClass ( $ this -> _controllerInstance ) ; if ( $ reflected -> hasMethod ( 'postLaunchAction' ) ) { call_user_func ( array ( $ this -> _controllerInstance , 'postLaunchAction' ) , null ) ; } }
called after action
6,771
public static function getPrimitiveTypeOf ( $ instance ) { $ phpType = gettype ( $ instance ) ; if ( isset ( self :: $ phpToJson [ $ phpType ] ) ) { return self :: $ phpToJson [ $ phpType ] ; } throw new UnsupportedTypeException ( $ phpType ) ; }
Returns the type of an instance according to JSON Schema Core 3 . 5 .
6,772
public static function isOneOf ( $ instance , array $ types ) { $ possible = self :: $ typeCompatibility [ gettype ( $ instance ) ] ; foreach ( $ types as $ type ) { if ( isset ( $ possible [ $ type ] ) ) { return true ; } } return false ; }
Returns whether an instance matches at least one of given JSON types .
6,773
public function getResponse ( $ id ) { foreach ( $ this -> _responses as $ response ) if ( $ response -> id == $ id ) return $ response ; return null ; }
Returns the specified response or null if the response is not found
6,774
public function callback ( $ request ) { $ this -> extend ( 'onBeforeCallback' ) ; $ data = $ this -> request -> postVars ( ) ; $ status = "error" ; $ order_id = 0 ; $ payment_id = 0 ; $ error_url = Controller :: join_links ( Director :: absoluteBaseURL ( ) , Payment_Controller :: config ( ) -> url_segment , 'complete'...
Retrieve and process order data from the request
6,775
public function addBox ( $ name , $ description = null ) { return $ this -> boxes [ $ name ] = new Box ( $ name , $ description ) ; }
Create a new Box
6,776
final protected function getMergedWithUniquenessOnDemand ( array $ rules , $ message ) { if ( ! is_null ( $ this -> uniqueness ) ) { $ rules [ 'Unique' ] = array ( 'value' => $ this -> uniqueness , 'message' => $ message ) ; } return $ rules ; }
Returns a rules result - set with merged Unique constraint on demand
6,777
public function add ( array $ collection ) { foreach ( $ collection as $ data ) { $ breadcrumb = new Breadcrumb ( ) ; $ breadcrumb -> setName ( $ data [ 'name' ] ) -> setLink ( isset ( $ data [ 'link' ] ) ? $ data [ 'link' ] : '#' ) ; array_push ( $ this -> collection , $ breadcrumb ) ; } return $ this ; }
Adds breadcrumb collection
6,778
public function getNames ( ) { $ result = array ( ) ; foreach ( $ this -> getBreadcrumbs ( ) as $ breadcrumb ) { array_push ( $ result , $ breadcrumb -> getName ( ) ) ; } return $ result ; }
Returns an array of all registered breadcrumb names
6,779
public function requireDefaultRecords ( ) { parent :: requireDefaultRecords ( ) ; if ( NewsHolderPage :: get ( ) -> count ( ) === 0 ) { $ page = NewsHolderPage :: create ( ) ; $ page -> Title = _t ( 'NewsHolderPage.DEFAULTPAGETITLE' , 'Newspage' ) ; $ page -> Content = '' ; $ page -> URLSegment = 'news' ; $ page -> Sor...
Create a default NewsHolderPage . This prevents error500 because of a missing page .
6,780
private function migrateAuthors ( ) { $ query = SQLSelect :: create ( ) ; $ query -> setSelect ( 'Author' ) -> setFrom ( 'News' ) -> setDistinct ( true ) ; $ authors = $ query -> execute ( ) ; foreach ( $ authors as $ author ) { if ( ! $ authorHelper = AuthorHelper :: get ( ) -> filter ( array ( 'OriginalName' => trim ...
For each author add an AuthorHelper
6,781
private function migratePages ( ) { $ existquery = "SHOW COLUMNS FROM `News` LIKE 'NewsHolderPageID';" ; $ exists = DB :: query ( $ existquery ) ; if ( $ count = $ exists -> numRecords ( ) ) { $ query = new SQLQuery ( ) ; $ query -> setSelect ( array ( 'ID' , 'NewsHolderPageID' ) ) -> setFrom ( 'News' ) ; $ newsitems =...
This is to migrate existing newsitems to the new release with the new relational method . It is forward - non - destructive . Only run if there is a column NewsHolderPageID
6,782
public function allowedActions ( $ limitToClass = null ) { $ actions = parent :: allowedActions ( $ limitToClass ) ; $ defaultMapping = $ this -> stat ( 'allowed_actions' ) ; $ siteConfig = SiteConfig :: current_site_config ( ) ; foreach ( $ defaultMapping as $ map ) { $ key = ucfirst ( $ map . 'Action' ) ; if ( $ site...
Setup the allowed actions to work with the SiteConfig settings .
6,783
public function handleAction ( $ request , $ action ) { $ handles = parent :: allowedActions ( false ) ; $ defaultMapping = $ this -> stat ( 'allowed_actions' ) ; $ handles [ 'index' ] = 'handleIndex' ; $ siteConfig = SiteConfig :: current_site_config ( ) ; foreach ( $ defaultMapping as $ key ) { $ map = ucfirst ( $ ke...
Setup the handling of the actions . This is needed for the custom URL Actions set in the SiteConfig
6,784
private function setNews ( ) { $ Params = $ this -> getURLParams ( ) ; $ segmentFilter = $ this -> setupFilter ( $ Params ) ; $ news = $ this -> Newsitems ( ) -> filter ( $ segmentFilter ) -> exclude ( array ( 'PublishFrom:GreaterThan' => SS_Datetime :: now ( ) -> format ( 'Y-m-d' ) ) ) -> first ( ) ; $ this -> current...
Set the current newsitem if available .
6,785
private function setTag ( ) { $ Params = $ this -> getURLParams ( ) ; $ tag = Tag :: get ( ) -> filter ( array ( 'URLSegment' => Convert :: raw2sql ( $ Params [ 'ID' ] ) ) ) -> first ( ) ; $ this -> current_tag = $ tag ; }
Set the current tag
6,786
private function needsRedirect ( ) { $ id = $ this -> getRequest ( ) -> param ( 'ID' ) ; $ action = $ this -> getRequest ( ) -> param ( 'Action' ) ; $ handlers = self :: $ url_handlers ; if ( array_key_exists ( $ action , $ handlers ) && $ handlers [ $ action ] === 'show' && ! $ news = $ this -> getNews ( ) ) { if ( $ ...
This feature is cleaner for redirection . Saves requests to the database if I m not mistaken .
6,787
public function MetaTitle ( ) { $ mapping = self :: $ url_handlers ; if ( $ action = $ this -> getRequest ( ) -> param ( 'Action' ) ) { switch ( $ mapping [ $ action ] ) { case 'show' : $ news = $ this -> getNews ( ) ; if ( isset ( $ news ) ) { $ this -> Title = $ news -> Title . ' - ' . $ this -> Title ; } break ; cas...
Meta! This is so Meta! I mean MetaTitle!
6,788
public function rss ( ) { $ rss = RSSFeed :: create ( $ list = $ this -> getRSSFeed ( ) , $ link = $ this -> Link ( 'rss' ) , $ title = _t ( 'News.RSSFEED' , 'News feed' ) ) ; return $ rss -> outputToBrowser ( ) ; }
I should make this configurable from SiteTree? Generate an RSS - feed .
6,789
private function setupFilter ( $ params ) { $ filter = array ( 'URLSegment' => Convert :: raw2sql ( $ params [ 'ID' ] ) , 'Live' => 1 , ) ; if ( Member :: currentUserID ( ) !== 0 && ! Permission :: checkMember ( Member :: currentUserID ( ) , array ( 'VIEW_NEWS' , 'CMS_ACCESS_NewsAdmin' ) ) ) { $ filter [ 'Live' ] = 0 ;...
Setup the filter for the getters . This keeps in mind if the user is allowed to view this item .
6,790
public function CommentForm ( ) { $ siteconfig = SiteConfig :: current_site_config ( ) ; $ params = $ this -> getURLParams ( ) ; return CommentForm :: create ( $ this , 'CommentForm' , $ siteconfig , $ params ) ; }
I m tired of writing comments!
6,791
final protected function onAuth ( ) { $ authService = $ this -> getAuthService ( ) ; $ this -> authManager -> setAuthService ( $ authService ) ; if ( $ this -> authActive === true ) { if ( $ authService -> isLoggedIn ( ) ) { $ this -> onSuccess ( ) ; } else { $ this -> onFailure ( ) ; } } if ( $ this -> hasRbacRules ( ...
Handles authorization process You should never edit this method
6,792
final protected function hasRbacRules ( ) { return $ this -> hasOption ( self :: PARAM_RBAC_KEY ) && is_array ( $ this -> getOptions ( self :: PARAM_RBAC_KEY ) ) ; }
Tells whether descendant controller has RBAC rules
6,793
public static function isRootPage ( ) { if ( is_admin ( ) ) { return false ; } $ isHome = is_home ( ) ; $ isFrontPage = is_front_page ( ) ; $ currentPageId = ( int ) get_current_web_page_id ( ) ; if ( FrontPageDisplays :: isSetToYourLatestPosts ( ) ) { return $ isHome && $ isFrontPage && ( $ currentPageId === 0 ) ; } i...
Checks if the current web page request is for the website s root page .
6,794
private function createVariadicUrl ( $ haystack , array $ args ) { $ varCount = substr_count ( $ haystack , self :: ROUTE_PARAM_VAR ) ; $ argCount = count ( $ args ) ; if ( $ varCount != $ argCount ) { $ difference = abs ( $ argCount - $ varCount ) ; for ( $ i = 0 ; $ i < $ difference ; $ i ++ ) { array_push ( $ args ,...
Creates variadic URL
6,795
protected function locale ( ) { if ( ( $ member = Member :: currentUser ( ) ) && $ member -> Locale ) { return $ member -> Locale ; } return i18n :: get_locale ( ) ; }
Get the locale of the Member or if we re not logged in or don t have a locale use the default one
6,796
public static function get ( Bookboon $ bookboon , array $ bookTypes = [ 'pdf' ] ) : BookboonResponse { $ bResponse = $ bookboon -> rawRequest ( "/frontpage" , [ 'bookType' => join ( ',' , $ bookTypes ) ] ) ; $ bResponse -> setEntityStore ( new EntityStore ( Frontpage :: getEntitiesFromArray ( $ bResponse -> getReturnA...
Get all front page books
6,797
public static function getBySlug ( Bookboon $ bookboon , string $ slug , array $ bookTypes = [ 'pdf' ] ) : BookboonResponse { $ bResponse = $ bookboon -> rawRequest ( "/frontpage/$slug" , [ 'bookType' => join ( ',' , $ bookTypes ) ] ) ; $ bResponse -> setEntityStore ( new EntityStore ( [ new static ( $ bResponse -> get...
Get specific frontpage
6,798
public function projectSetupNew ( ) { $ this -> executeCommandHook ( __FUNCTION__ , 'before' ) ; $ this -> projectInstance ( ) -> setupNewProject ( ) ; $ this -> executeCommandHook ( __FUNCTION__ , 'after' ) ; }
Setup a fresh new project .
6,799
public function projectSetupExisting ( $ opts = [ 'db-name' => null , 'db-user' => null , 'db-pass' => null , 'db-host' => null , 'db-port' => null , 'db-protocol' => null , 'no-engine' => false , 'no-browser' => false , 'restore-method' => null , 'localhost' => false , ] ) { $ this -> executeCommandHook ( __FUNCTION__...
Setup an existing project .