idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
2,300
protected function findModelByRouteKey ( $ key ) { return $ this -> model -> where ( $ this -> model -> getRouteKeyName ( ) , $ key ) -> first ( ) ; }
Find Eloquent model by route key .
2,301
protected function getAllRouteNames ( $ resourceName = null ) { $ resourceName = $ resourceName ?? $ this -> resourceName ; return [ 'index' => $ this -> prefix . $ this -> resourceName . '.index' , 'create' => $ this -> prefix . $ this -> resourceName . '.create' , 'store' => $ this -> prefix . $ this -> resourceName ...
Get all route names for the specified resource .
2,302
public function composeWithModel ( View $ view ) { $ key = $ this -> getModelRouteKey ( ) ; $ model = $ this -> findModelByRouteKey ( $ key ) ; $ view -> with ( 'model' , $ model ) ; }
Compose with model .
2,303
public function composeWithAllRouteNames ( View $ view ) { $ routes = $ this -> getAllRouteNames ( ) ; foreach ( $ routes as $ action => $ routeName ) { $ view -> with ( "{$action}Route" , $ routeName ) ; } }
Compose with all route names for the specified resource .
2,304
public function composeWithRequiredFields ( View $ view ) { $ requiredFields = array_keys ( $ this -> getRequiredFields ( ) ) ; $ view -> with ( 'requiredFields' , $ requiredFields ) ; }
Compose with validation required fields .
2,305
private function _checkModelProperty ( ) { if ( ! $ this -> model ) { if ( Lang :: has ( 'resource-composer.propertynotset' ) ) { $ message = trans ( 'resource-composer.propertynotset' , [ 'property' => '$model' ] ) ; } else { $ message = '$model property must be set.' ; } throw new ResourceComposerException ( $ messag...
Throw an exception if model property is not set .
2,306
public function getElement ( $ name , $ offset = null , & $ pieceOfPath = null ) { if ( StringUtils :: beginsWith ( "this." , $ name ) ) { $ name = substr ( $ name , 5 ) ; } if ( null !== $ offset ) { if ( $ offset < 0 ) { throw new BadParameterException ( "\$offset can't be negative. " . $ offset . " given" ) ; } $ la...
get the element in this element with the given name
2,307
public function make ( $ transformer ) { if ( is_string ( $ transformer ) ) { return $ this -> makeTransformerClass ( $ transformer ) ; } else if ( is_callable ( $ transformer ) ) { return $ this -> makeCallableTransformer ( $ transformer ) ; } else if ( is_object ( $ transformer ) && method_exists ( $ transformer , 't...
Build a transformer object .
2,308
public function getDefaultDataByteLength ( ) { $ default = - 1 ; $ length = $ default ; switch ( $ this -> storage_type ) { case StorageType :: NOBYTES : $ length = 0 ; break ; case StorageType :: BYTE : $ length = 1 ; break ; case StorageType :: WORD : $ length = 2 ; break ; case StorageType :: DWORD : $ length = 4 ; ...
Certain storage container types do not require a data length because it is predefined .
2,309
final public function getAllowedDataFromRequest ( array $ requestParams , $ httpMethod ) { if ( in_array ( $ httpMethod , [ 'PATCH' , 'PUT' ] ) ) { $ properties = $ this -> getModifiableProperties ( ) ; } elseif ( $ httpMethod === 'POST' ) { $ properties = $ this -> getWritableProperties ( ) ; } else { return [ ] ; } $...
Hydrates an ActiveRecord with filtered Request params
2,310
final public function getExposedProperties ( ) { if ( null === $ this -> exposedProperties ) { $ this -> exposedProperties = array_diff ( $ this -> getVisibleFields ( ) , $ this -> getHiddenFieldsAndRelations ( ) ) ; } return $ this -> exposedProperties ; }
None all or partial list of properties
2,311
final public function getExposedRelations ( ) { if ( null === $ this -> exposedRelations ) { $ this -> exposedRelations = array_diff ( $ this -> getRelationsNames ( ) , $ this -> getHiddenFieldsAndRelations ( ) ) ; } return $ this -> exposedRelations ; }
None all or partial list of relations
2,312
final public function getRelations ( ) { if ( $ this -> relationsBuilt === false ) { $ tableMap = $ this -> getTableMap ( ) ; $ this -> buildRelations ( $ tableMap ) ; $ this -> relationsBuilt = true ; } return $ this -> relations ; }
Returns names of relations
2,313
public function init ( ) { if ( count ( $ this -> buckets ) ) { foreach ( $ this -> buckets as $ alias => $ bucket ) { $ this -> _buckets [ $ alias ] = new BucketFileSystem ( $ bucket [ 'basePath' ] , $ bucket [ 'baseUrl' ] , isset ( $ bucket [ 'filePermission' ] ) ? $ bucket [ 'filePermission' ] : 0777 ) ; } } }
Initialization storage system
2,314
static public function ConvertIPv4CIDRToMask ( $ cidr ) { $ subnetMask = str_pad ( "" , $ cidr , "1" ) ; $ subnetMask = str_pad ( $ subnetMask , 32 , "0" ) ; $ subnetMask = array_map ( function ( $ x ) { return bindec ( $ x ) ; } , str_split ( $ subnetMask , 8 ) ) ; return implode ( "." , $ subnetMask ) ; }
Converts IPv4 CIDR to subnet mask format
2,315
static public function ConvertIPv4CIDRToDecimal ( $ ipAndCidr ) { list ( $ ip , $ subnetMask ) = explode ( "/" , $ ipAndCidr ) ; $ ip = static :: ConvertIPv4ToDecimal ( $ ip ) ; $ subnetMask = static :: ConvertIPv4CIDRToMask ( $ subnetMask ) ; $ subnetMask = static :: ConvertIPv4ToDecimal ( $ subnetMask ) ; return comp...
Converts IPv4 and CIDR to decimal notation
2,316
static public function IsIPv4SubnetWithinSupernet ( $ ipAndCidrSub , $ ipAndCidrSuper ) { $ ipAndCidrSubMin = static :: ConvertIPv4ToDecimal ( static :: GetIPv4NetworkAddress ( $ ipAndCidrSub ) ) ; $ ipAndCidrSubMax = static :: ConvertIPv4ToDecimal ( static :: GetIPv4BroadcastAddress ( $ ipAndCidrSub ) ) ; $ ipAndCidrS...
Checks if a given range is within a range
2,317
static public function GetIPv4NumberOfHostAddresses ( $ ipAndCidr ) { $ ipAndCidrNetwork = static :: ConvertIPv4ToDecimal ( static :: GetIPv4NetworkAddress ( $ ipAndCidr ) ) ; $ ipAndCidrBroadcast = static :: ConvertIPv4ToDecimal ( static :: GetIPv4BroadcastAddress ( $ ipAndCidr ) ) ; return $ ipAndCidrBroadcast - $ ip...
Get the number of host addresses in a given subnet
2,318
static public function IsIPv6SubnetWithinSupernet ( $ ipAndCidrSub , $ ipAndCidrSuper ) { $ ipAndCidrSubMin = static :: ConvertIPv6ToBinary ( static :: GetIPv6NetworkAddress ( $ ipAndCidrSub ) ) ; $ ipAndCidrSubMax = static :: ConvertIPv6ToBinary ( static :: GetIPv6BroadcastAddress ( $ ipAndCidrSub ) ) ; $ ipAndCidrSup...
Checks if an IPv6 subnet is within an IPv6 supernet
2,319
static public function NormalizeIPv6Address ( $ ipv6 ) { if ( strpos ( $ ipv6 , "::" ) === false && substr_count ( $ ipv6 , ":" ) !== 7 ) { throw new \ Exception ( "Invalid IPv6 address" ) ; } if ( strpos ( $ ipv6 , "::" ) !== false ) { $ padding = ":" ; $ paddingRequired = 9 - substr_count ( $ ipv6 , ":" ) ; while ( s...
Converts an IPv6 address and formats to leading 0s format
2,320
public function getRenderedTitle ( ) { $ rendered = $ this -> getRenderedContent ( ) ; if ( $ rendered instanceof Content || $ rendered instanceof MetaContent ) { return $ rendered -> title ; } return null ; }
Get rendered title
2,321
public function setRootTitle ( $ title ) { $ content = $ this -> getDependentContent ( ) ; if ( $ content ) { $ content -> title = $ title ; } return $ this ; }
Set root title
2,322
protected function getConstructParameters ( ReflectionClass $ reflectionClass , array $ data ) : array { $ constructor = $ reflectionClass -> getConstructor ( ) ; if ( $ constructor instanceof ReflectionMethod ) { foreach ( $ constructor -> getParameters ( ) as $ parameter ) { $ name = $ parameter -> getName ( ) ; $ cl...
Get construct parameters .
2,323
protected function getObjectValues ( object $ object ) : array { $ class = new ReflectionClass ( get_class ( $ object ) ) ; $ constructor = $ class -> getConstructor ( ) ; if ( $ constructor instanceof ReflectionMethod ) { foreach ( $ constructor -> getParameters ( ) as $ parameter ) { $ name = $ parameter -> getName (...
Get object values .
2,324
private function addCsrf ( ) { if ( ! $ this -> getName ( ) ) { throw new \ LogicException ( "Can't set CSRF token with form name" ) ; } $ csrfName = 'CSRF_' . $ this -> getName ( ) ; $ csrfToken = md5 ( ( string ) mt_rand ( ) ) ; self :: session ( ) -> set ( $ csrfName , $ csrfToken ) ; $ this -> addFirst ( new Hidden...
add Csrf input hidden .
2,325
protected function readContent ( $ path ) { $ str = file_get_contents ( $ path ) ; if ( is_string ( $ str ) ) { return $ str ; } else { throw new LogicException ( Message :: get ( Message :: ENV_READ_FAIL , $ path ) , Message :: ENV_READ_FAIL ) ; } }
Read from a file returns the content string
2,326
public static function getFormItemByAttributeName ( $ attributeName , $ attributeValue , $ localizedName = "" ) { $ attributeType = substr ( $ attributeName , 2 , 1 ) ; if ( $ attributeType == "s" ) { $ formItem = static :: getFormItemByAttributeType ( "shorttext" , $ attributeName , $ attributeValue , $ localizedName ...
Creates a MFormItem by a given attributeName .
2,327
public static function getDefault ( ) { if ( ( self :: $ compatibilityMode === true ) or ( func_num_args ( ) > 0 ) ) { if ( ! self :: $ _breakChain ) { self :: $ _breakChain = true ; trigger_error ( 'You are running Zend_Locale in compatibility mode... please migrate your scripts' , E_USER_NOTICE ) ; $ params = func_ge...
Return the default locale
2,328
public static function getEnvironment ( ) { if ( self :: $ _environment !== null ) { return self :: $ _environment ; } $ language = setlocale ( LC_ALL , 0 ) ; $ languages = explode ( ';' , $ language ) ; $ languagearray = array ( ) ; foreach ( $ languages as $ locale ) { if ( strpos ( $ locale , '=' ) !== false ) { $ l...
Expects the Systems standard locale
2,329
public static function getBrowser ( ) { if ( self :: $ _browser !== null ) { return self :: $ _browser ; } $ httplanguages = getenv ( 'HTTP_ACCEPT_LANGUAGE' ) ; if ( empty ( $ httplanguages ) && array_key_exists ( 'HTTP_ACCEPT_LANGUAGE' , $ _SERVER ) ) { $ httplanguages = $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ; } $ lang...
Return an array of all accepted languages of the client Expects RFC compilant Header !!
2,330
public function setLocale ( $ locale = null ) { $ locale = self :: _prepareLocale ( $ locale ) ; if ( isset ( self :: $ _localeData [ ( string ) $ locale ] ) === false ) { $ region = substr ( ( string ) $ locale , 0 , 3 ) ; if ( isset ( $ region [ 2 ] ) === true ) { if ( ( $ region [ 2 ] === '_' ) or ( $ region [ 2 ] =...
Sets a new locale
2,331
public function getRegion ( ) { $ locale = explode ( '_' , $ this -> _locale ) ; if ( isset ( $ locale [ 1 ] ) === true ) { return $ locale [ 1 ] ; } return false ; }
Returns the region part of the locale if available
2,332
public static function getHttpCharset ( ) { $ httpcharsets = getenv ( 'HTTP_ACCEPT_CHARSET' ) ; $ charsets = array ( ) ; if ( $ httpcharsets === false ) { return $ charsets ; } $ accepted = preg_split ( '/,\s*/' , $ httpcharsets ) ; foreach ( $ accepted as $ accept ) { if ( empty ( $ accept ) === true ) { continue ; } ...
Return the accepted charset of the client
2,333
public static function getTranslationList ( $ path = null , $ locale = null , $ value = null ) { $ locale = self :: findLocale ( $ locale ) ; $ result = Zend_Locale_Data :: getList ( $ locale , $ path , $ value ) ; if ( empty ( $ result ) === true ) { return false ; } return $ result ; }
Returns localized informations as array supported are several types of informations . For detailed information about the types look into the documentation
2,334
public static function getTranslation ( $ value = null , $ path = null , $ locale = null ) { $ locale = self :: findLocale ( $ locale ) ; $ result = Zend_Locale_Data :: getContent ( $ locale , $ path , $ value ) ; if ( empty ( $ result ) === true && '0' !== $ result ) { return false ; } return $ result ; }
Returns a localized information string supported are several types of informations . For detailed information about the types look into the documentation
2,335
public static function getLanguageTranslation ( $ value , $ locale = null ) { trigger_error ( "The method getLanguageTranslation is deprecated. Use getTranslation($value, 'language', $locale) instead" , E_USER_NOTICE ) ; return self :: getTranslation ( $ value , 'language' , $ locale ) ; }
Returns the localized language name
2,336
public static function getScriptTranslation ( $ value , $ locale = null ) { trigger_error ( "The method getScriptTranslation is deprecated. Use getTranslation($value, 'script', $locale) instead" , E_USER_NOTICE ) ; return self :: getTranslation ( $ value , 'script' , $ locale ) ; }
Returns the localized script name
2,337
public static function getCountryTranslation ( $ value , $ locale = null ) { trigger_error ( "The method getCountryTranslation is deprecated. Use getTranslation($value, 'country', $locale) instead" , E_USER_NOTICE ) ; return self :: getTranslation ( $ value , 'country' , $ locale ) ; }
Returns the localized country name
2,338
public static function getTerritoryTranslation ( $ value , $ locale = null ) { trigger_error ( "The method getTerritoryTranslation is deprecated. Use getTranslation($value, 'territory', $locale) instead" , E_USER_NOTICE ) ; return self :: getTranslation ( $ value , 'territory' , $ locale ) ; }
Returns the localized territory name All territories contains other countries .
2,339
public static function getQuestion ( $ locale = null ) { $ locale = self :: findLocale ( $ locale ) ; $ quest = Zend_Locale_Data :: getList ( $ locale , 'question' ) ; $ yes = explode ( ':' , $ quest [ 'yes' ] ) ; $ no = explode ( ':' , $ quest [ 'no' ] ) ; $ quest [ 'yes' ] = $ yes [ 0 ] ; $ quest [ 'yesarray' ] = $ y...
Returns an array with translated yes strings
2,340
private static function _prepareQuestionString ( $ input ) { $ regex = '' ; if ( is_array ( $ input ) === true ) { $ regex = '^' ; $ start = true ; foreach ( $ input as $ row ) { if ( $ start === false ) { $ regex .= '|' ; } $ start = false ; $ regex .= '(' ; $ one = null ; if ( strlen ( $ row ) > 2 ) { $ one = true ; ...
Internal function for preparing the returned question regex string
2,341
public static function findLocale ( $ locale = null ) { if ( $ locale === null ) { if ( Zend_Registry :: isRegistered ( 'Zend_Locale' ) ) { $ locale = Zend_Registry :: get ( 'Zend_Locale' ) ; } } if ( $ locale === null ) { $ locale = new Zend_Locale ( ) ; } if ( ! Zend_Locale :: isLocale ( $ locale , true , false ) ) {...
Finds the proper locale based on the input Checks if it exists degrades it when necessary Detects registry locale and when all fails tries to detect a automatic locale Returns the found locale as string
2,342
public static function getLocaleToTerritory ( $ territory ) { $ territory = strtoupper ( $ territory ) ; if ( array_key_exists ( $ territory , self :: $ _territoryData ) ) { return self :: $ _territoryData [ $ territory ] ; } return null ; }
Returns the expected locale for a given territory
2,343
private static function _prepareLocale ( $ locale , $ strict = false ) { if ( $ locale instanceof Zend_Locale ) { $ locale = $ locale -> toString ( ) ; } if ( is_array ( $ locale ) ) { return '' ; } if ( empty ( self :: $ _auto ) === true ) { self :: $ _browser = self :: getBrowser ( ) ; self :: $ _environment = self :...
Internal function returns a single locale on detection
2,344
public static function getOrder ( $ order = null ) { switch ( $ order ) { case self :: ENVIRONMENT : self :: $ _breakChain = true ; $ languages = self :: getEnvironment ( ) + self :: getBrowser ( ) + self :: getDefault ( ) ; break ; case self :: ZFDEFAULT : self :: $ _breakChain = true ; $ languages = self :: getDefaul...
Search the locale automatically and return all used locales ordered by quality
2,345
protected function takeChildFromDOM ( $ child ) { if ( $ child -> nodeType == XML_TEXT_NODE ) { $ this -> _text = $ child -> nodeValue ; } else { $ extensionElement = new Zend_Gdata_App_Extension_Element ( ) ; $ extensionElement -> transferFromDOM ( $ child ) ; $ this -> _extensionElements [ ] = $ extensionElement ; } ...
Given a child DOMNode tries to determine how to map the data into object instance members . If no mapping is defined Extension_Element objects are created and stored in an array .
2,346
public function transferFromDOM ( $ node ) { foreach ( $ node -> childNodes as $ child ) { $ this -> takeChildFromDOM ( $ child ) ; } foreach ( $ node -> attributes as $ attribute ) { $ this -> takeAttributeFromDOM ( $ attribute ) ; } }
Transfers each child and attribute into member variables . This is called when XML is received over the wire and the data model needs to be built to represent this XML .
2,347
public function registerNamespace ( $ prefix , $ namespaceUri , $ majorVersion = 1 , $ minorVersion = 0 ) { $ this -> _namespaces [ $ prefix ] [ $ majorVersion ] [ $ minorVersion ] = $ namespaceUri ; }
Add a namespace and prefix to the registered list
2,348
protected function initComponents ( $ componentNames ) { $ components = array ( ) ; foreach ( $ componentNames as $ name ) { $ className = sprintf ( "EventRegistration\Calculator\%sComponent" , $ name ) ; array_push ( $ components , \ Injector :: inst ( ) -> create ( $ className , $ this -> registration ) ) ; } return ...
Creates instances of components from component name strings
2,349
protected function addBinding ( $ key , $ value , $ override = false ) : void { if ( isset ( $ this -> routeBindings [ $ key ] ) && ! $ override ) { throw new \ InvalidArgumentException ( "You can't override the key: $key" ) ; } if ( $ value instanceof PrimalValued ) { $ value = $ value -> toPrimitive ( ) ; } if ( is_o...
Set a new binding .
2,350
public function getInitialValue ( ) { if ( $ this -> hasDefaultValue ) { return $ this -> defaultValue ; } return $ this -> isNullable ? null : $ this -> dataType -> getInitialValue ( ) ; }
Returns the initial value of the column .
2,351
public function getFilterCallback ( ) { if ( $ this -> filterCallback !== null ) { $ callback = $ this -> filterCallback ; } else { $ field = $ this -> field ; $ callback = function ( $ value ) use ( $ field ) { return [ $ field => $ value ] ; } ; } return $ callback ; }
Get callback that takes the value being validated and returns an array of wheres to be used with the mapper .
2,352
public final function getFactory ( ) { $ calledClass = get_called_class ( ) ; if ( empty ( self :: $ factories [ $ calledClass ] ) ) { self :: $ factories [ $ calledClass ] = $ this -> getDefaultFactory ( ) ; } return self :: $ factories [ $ calledClass ] ; }
Get the factory that supplies entities to the collection browser .
2,353
protected function getViewResponse ( Entity $ entity ) { $ response = $ this -> getHtmlResponse ( ) ; $ response -> setTemplateId ( $ this -> getViewTemplateId ( ) ) ; $ response -> setData ( $ this -> getItemName ( ) , $ entity -> getFieldsData ( ) ) ; $ response -> appendToTitle ( sprintf ( _ ( '%s %s' ) , ucfirst ( ...
Generate a response that displays an entity s data .
2,354
public function getSidebarData ( ) { if ( $ this -> _entityName === 'Veonik\Bundle\BlogBundle\Entity\Category' ) { $ join = 'JOIN posts_categories pt ON pt.category_id = t.id ' ; } else { $ join = 'JOIN posts_tags pt ON pt.tag_id = t.id ' ; } $ stmt = $ this -> _em -> getConnection ( ) -> executeQuery ( "SELECT t.id FR...
Gets sidebar data
2,355
public static function inTheInput ( array $ data , MapsProperty $ mapping , string $ key ) : UnmappableInput { return new self ( sprintf ( 'Missing the key `%s` for property `%s` in the input data: %s; ' . 'Mapper: %s' , $ key , $ mapping -> name ( ) , json_encode ( $ data ) , get_class ( $ mapping ) ) ) ; }
Notifies the client code about a missing input key .
2,356
public function getOAUTHInstance ( ) { if ( ! is_object ( $ this -> oauth ) ) { $ this -> oauth = new PHPMailerOAuthGoogle ( $ this -> oauthUserEmail , $ this -> oauthClientSecret , $ this -> oauthClientId , $ this -> oauthRefreshToken ) ; } return $ this -> oauth ; }
Get a PHPMailerOAuthGoogle instance to use .
2,357
public static function validateData ( $ engine , $ keyword , $ pageUrl , $ pageNumber , $ age , $ entries ) { if ( ! self :: validateEngine ( $ engine ) ) throw new \ Franzip \ SerpPageSerializer \ Exceptions \ InvalidArgumentException ( 'Invalid SerializableSerpPage $engine: please supply a valid non-empty string.' ) ...
Validate SerializableSerpPage constructor data .
2,358
public function supportParameter ( $ name ) { if ( in_array ( $ name , QueryModifiers ) ) { throw new \ DomainException ( "parameter $name not allowed" ) ; } $ this -> supportedParameters [ $ name ] = $ name ; asort ( $ this -> supportedParameters ) ; }
Enable support of a query parameter .
2,359
public function create ( $ class ) { $ reflectionClass = new ReflectionClass ( $ class ) ; $ reflectionMethod = $ reflectionClass -> getConstructor ( ) ; if ( ! $ reflectionMethod ) { return new $ class ; } $ params = & $ this -> fetchDepsFromSignature ( $ reflectionMethod ) ; return $ reflectionClass -> newInstanceArg...
Create an object of the given class
2,360
public function inject ( $ callable , $ overloadedDeps = array ( ) ) { $ reflection = new ReflectionFunction ( $ callable ) ; $ params = & $ this -> fetchDepsFromSignature ( $ reflection , $ overloadedDeps ) ; return call_user_func_array ( $ callable , $ params ) ; }
Executes the given callable
2,361
public function replace ( $ name , $ value ) { if ( ! isset ( $ this -> unresolvedDeps [ $ name ] ) ) { throw new Exception ( "Dependency does not exist: $name!" ) ; } if ( isset ( $ this -> resolvedDeps [ $ name ] ) ) { throw new Exception ( "Could replace resolved Dependency: $name!" ) ; } $ this -> unresolvedDeps [ ...
Replace an existing dependency
2,362
protected function parseRelationshipParams ( array $ params ) : array { if ( empty ( $ params ) ) { return [ ] ; } $ parsed = [ ] ; foreach ( $ params as $ key => $ value ) { if ( is_int ( $ key ) ) { $ parsed [ $ key ] = '' ; continue ; } if ( $ key !== 'paginate' || ( $ key === 'paginate' && ! Arr :: isAssoc ( $ valu...
Processes the parameters passed for the relationship .
2,363
private function findInArray ( array $ target , string $ key , int $ defaultIndex = 0 , $ defaultValue = null ) { if ( empty ( $ target ) ) { return $ defaultValue ; } if ( ! empty ( $ target [ $ key ] ) ) { return $ target [ $ key ] ; } elseif ( ! empty ( $ target [ $ defaultIndex ] ) ) { return $ target [ $ defaultIn...
Searches the array for a value based on a key a default index else it returns the default value .
2,364
private function _createRoute ( $ controller_name , $ action_name ) { $ route = new Router \ Route ( ) ; $ route -> setControllerName ( $ controller_name ) ; $ route -> setActionName ( $ action_name ) ; return $ route ; }
Private helper function to create a route
2,365
private function _getRoute ( $ controller_name , $ action_name ) { $ _route = $ this -> _createRoute ( $ controller_name , $ action_name ) ; foreach ( $ this -> _routes as $ route ) { if ( $ route -> getControllerName ( ) == $ _route -> getControllerName ( ) && $ route -> getActionName ( ) == $ _route -> getActionName ...
Private helper function to retrieve a route
2,366
public function allow ( $ role , $ controller_name , $ action_name ) { $ route = $ this -> _getRoute ( $ controller_name , $ action_name ) ; $ this -> _allow_list [ $ role ] [ ] = $ route ; }
Attach a route with a role in the allow list
2,367
public function deny ( $ role , $ resource , $ action ) { $ route = $ this -> _getRoute ( $ controller_name , $ action_name ) ; $ this -> _deny_list [ $ role ] [ ] = $ route ; }
Attach a route with a role in the deny list
2,368
public function isAllowed ( $ role , $ controller_name , $ action_name ) { $ _route = $ this -> _createRoute ( $ controller_name , $ action_name ) ; if ( $ this -> _default_action == "ALLOW" ) { $ list = $ this -> _deny_list ; } else if ( $ this -> _default_action == "DENY" ) { $ list = $ this -> _allow_list ; } foreac...
Check is role has the route attached
2,369
public static function parse ( $ typeName ) { $ normalize = array ( "int" => self :: INTEGER_NAME , "bool" => self :: BOOLEAN_NAME , "double" => self :: FLOAT_NAME , "real" => self :: FLOAT_NAME , "long" => self :: INTEGER_NAME ) ; if ( isset ( $ normalize [ $ typeName ] ) ) $ typeName = $ normalize [ $ typeName ] ; if...
Parses a primitive type name . Returns null if the provided type name is not a name of a primitive type .
2,370
public function setComposerManifest ( ComposerManifestParser $ composer ) { $ this -> composer_manifest = $ composer ; $ this -> setDependencies ( $ this -> composer_manifest -> getExtraEntry ( 'assets-presets' ) ) ; return $ this ; }
setters & getters
2,371
public function buildQuery ( ) { $ model = $ this -> model ; $ query = $ model :: query ( ) ; if ( is_array ( $ this -> join ) ) { foreach ( $ this -> join as $ condition ) { list ( $ joinModel , $ column , $ foreignKey ) = $ condition ; $ query -> join ( $ joinModel , $ column , $ foreignKey ) ; } } $ filter = $ this ...
Builds the model query .
2,372
public function paginate ( $ page , $ perPage , $ total ) { $ this -> response -> setHeader ( 'X-Total-Count' , $ total ) ; $ pageCount = max ( 1 , ceil ( $ total / $ perPage ) ) ; $ base = $ this -> getEndpoint ( ) ; $ requestQuery = $ this -> request -> query ( ) ; if ( isset ( $ requestQuery [ 'per_page' ] ) ) { uns...
Paginates the results from this route .
2,373
protected function parseFilterInput ( array $ input ) { if ( count ( $ input ) === 0 ) { return [ ] ; } $ allowed = [ ] ; $ model = $ this -> model ; if ( property_exists ( $ model , 'filterableProperties' ) ) { $ allowed = $ model :: $ filterableProperties ; } $ filter = [ ] ; foreach ( $ input as $ key => $ value ) {...
Builds the filter from an input array of parameters .
2,374
public function fetch ( $ what = null , $ live = false ) { if ( ! in_array ( $ what , [ 'style' , 'script' ] ) ) throw new Exception ( "{$what} not supported" ) ; $ this -> compress = ! Configure :: read ( 'debug' ) || $ live == true ; $ function = '_' . $ what ; echo $ this -> $ function ( ) ; }
Fetch either combined css or js
2,375
public function inline ( $ what = null , $ data = null , $ return = false ) { if ( ! in_array ( $ what , [ 'style' , 'script' ] ) ) throw new Exception ( "{$what} not supported" ) ; $ function = '_inline' . ucfirst ( $ what ) ; $ data = $ this -> $ function ( $ data ) ; if ( $ return ) return $ data ; echo $ data ; }
Fetch inline minified css or js
2,376
private function path ( $ file , array $ options = [ ] ) { $ base = $ this -> Url -> assetUrl ( $ file , $ options ) ; $ fullpath = preg_replace ( '/^' . preg_quote ( $ this -> request -> getAttribute ( 'webroot' ) , '/' ) . '/' , '' , urldecode ( $ base ) ) ; $ webrootPath = Configure :: read ( 'App.wwwRoot' ) . str_r...
Get full webroot path for an asset
2,377
private function filename ( $ what = null ) { if ( ! $ this -> $ what [ 'intern' ] ) return false ; $ last = 0 ; foreach ( $ this -> $ what [ 'intern' ] as $ res ) if ( file_exists ( $ res ) ) $ last = max ( $ last , filemtime ( $ res ) ) ; return "cache-{$last}-" . md5 ( serialize ( $ this -> $ what [ 'intern' ] ) ) ....
Attempt to create the filename for the selected resources
2,378
private function process ( $ what = null ) { $ output = null ; foreach ( $ this -> $ what [ 'intern' ] as $ idx => $ file ) { $ contents = file_get_contents ( $ file ) ; if ( $ what == 'css' ) $ contents = $ this -> dilemma ( $ contents , $ this -> $ what [ 'extern' ] [ $ idx ] ) ; if ( strpos ( $ file , ".min.{$what}"...
Take individual files and process them based on an algorithm
2,379
private function dilemma ( $ input = null , $ from = false ) { list ( $ plugin , $ from ) = $ this -> _View -> pluginSplit ( $ from , false ) ; $ from = Configure :: read ( 'App.cssBaseUrl' ) . $ from ; if ( isset ( $ plugin ) ) $ from = Inflector :: underscore ( $ plugin ) . '/' . $ from ; $ converter = new Converter ...
Dilemma? This function uses morph to fix and convert paths found in css
2,380
private function morph ( $ input , callable $ callback , $ ignore = '/^(data:|https?:|\\/)/' ) { $ relativeRegexes = [ '/url\(\s*(?P<quotes>["\'])?(?P<path>.+?)(?(quotes)(?P=quotes))\s*\)/ix' , '/@import\s+(?P<quotes>["\'])(?P<path>.+?)(?P=quotes)/ix' , ] ; $ matches = [ ] ; foreach ( $ relativeRegexes as $ relativeReg...
Morph The function that detects urls and morphs paths accordingly
2,381
private function _inlineStyle ( $ data = null ) { if ( is_null ( $ data ) ) return false ; $ data = $ this -> morph ( $ data , function ( $ url ) { return $ this -> Url -> build ( $ url ) ; } , '/^(data:|https?:)/' ) ; $ data = Algorithms :: css ( $ data , $ this -> _config [ 'config' ] [ 'css' ] ) ; $ hash = md5 ( $ d...
Return the compressed inline css data
2,382
private function _inlineScript ( $ data = null ) { if ( is_null ( $ data ) ) return false ; $ data = Algorithms :: js ( $ data , $ this -> _config [ 'config' ] [ 'js' ] ) ; $ hash = md5 ( $ data ) ; if ( in_array ( $ hash , $ this -> inline [ 'js' ] ) ) return false ; else $ this -> inline [ 'js' ] [ ] = $ hash ; retur...
Return the compressed inline js data
2,383
protected function _createNewContent ( $ options = array ( ) ) { extract ( $ options ) ; $ contentTable = TableRegistry :: get ( 'CmsContent' ) ; $ content = $ contentTable -> newEntity ( ) ; $ content -> parent = isset ( $ parent ) ? intval ( $ parent ) : 0 ; $ content -> name = $ this -> _randomString ( ) ; $ content...
Create new Content
2,384
public function saveMenuOrder ( ) { $ ITER = 1 ; $ contentTable = TableRegistry :: get ( 'CmsContent' ) ; if ( $ this -> request -> is ( 'post' ) ) : $ items = explode ( ',' , $ this -> request -> data [ 'order' ] ) ; foreach ( $ items as $ id ) : $ content = $ contentTable -> get ( $ id ) ; $ content -> menu_order = $...
This function is invoked in AJAX to save the ordering of the elements related
2,385
public function saveContent ( $ id = null ) { $ id = ( isset ( $ this -> request -> data [ 'id' ] ) ) ? $ this -> request -> data [ 'id' ] : $ id ; $ this -> CmsContent = TableRegistry :: get ( 'CmsContent' ) ; $ cmsContent = $ this -> CmsContent -> get ( $ id ) ; if ( $ this -> request -> is ( [ 'patch' , 'post' , 'pu...
This function is invoked in AJAX for saving data related to an object
2,386
public function saveMeta ( $ id = null ) { $ id = ( isset ( $ this -> request -> data [ 'id' ] ) ) ? $ this -> request -> data [ 'id' ] : $ id ; $ this -> CmsContentMeta = TableRegistry :: get ( 'CmsContentMeta' ) ; $ meta = $ this -> CmsContentMeta -> get ( $ id ) ; if ( $ this -> request -> is ( [ 'patch' , 'post' , ...
This function is invoked in AJAX for saving data related to an meta
2,387
public function initRouterDi ( ) { $ config = $ this -> getConfig ( ) ; if ( ! isset ( $ config [ 'router' ] ) ) { throw new Exception \ RuntimeException ( 'Cannot init DI for router. Cannot find router configuration' ) ; } $ config = $ config [ 'router' ] -> toArray ( ) ; $ router = new Router ( $ this -> diFactory ) ...
Base on router config init Di for router
2,388
public function initInvokableServices ( ) { $ config = $ this -> getConfig ( ) ; if ( ! isset ( $ config [ 'service_manager' ] ) ) { return $ this ; } $ smConfig = $ config [ 'service_manager' ] ; if ( ! isset ( $ smConfig [ 'invokables' ] ) ) { return $ this ; } $ invokables = $ smConfig [ 'invokables' ] -> toArray ( ...
Base on config service manager invokables create DI service
2,389
public function initFactoriedServices ( ) { $ config = $ this -> getConfig ( ) ; if ( ! isset ( $ config [ 'service_manager' ] ) ) { return $ this ; } $ smConfig = $ config [ 'service_manager' ] ; if ( ! isset ( $ smConfig [ 'factories' ] ) ) { return $ this ; } $ factories = $ smConfig [ 'factories' ] -> toArray ( ) ;...
Base on config service manager factories create DI services
2,390
public function createErrorHandler ( ) { $ config = $ this -> getConfig ( ) ; if ( ! isset ( $ config [ 'error_handler' ] ) ) { throw new Exception \ RuntimeException ( 'Not found error handler config' ) ; } $ errorHandlerConfig = $ config [ 'error_handler' ] -> toArray ( ) ; $ adapter = ! isset ( $ errorHandlerConfig ...
Create DI error handler
2,391
public function Base_BeforeCheckComments_Handler ( $ Sender ) { $ ActionMessage = & $ Sender -> EventArguments [ 'ActionMessage' ] ; $ Discussion = $ Sender -> EventArguments [ 'Discussion' ] ; if ( Gdn :: Session ( ) -> CheckPermission ( 'Vanilla.Discussions.Edit' , TRUE , 'Category' , $ Discussion -> PermissionCatego...
Add split action link .
2,392
public function Base_BeforeCheckDiscussions_Handler ( $ Sender ) { $ ActionMessage = & $ Sender -> EventArguments [ 'ActionMessage' ] ; if ( Gdn :: Session ( ) -> CheckPermission ( 'Vanilla.Discussions.Edit' , TRUE , 'Category' , 'any' ) ) $ ActionMessage .= ' ' . Anchor ( T ( 'Merge' ) , 'vanilla/moderation/mergediscu...
Add merge action link .
2,393
public function updateDatabaseAction ( ) { $ request = $ this -> getRequest ( ) ; if ( ! $ request instanceof ConsoleRequest ) { throw new \ Zend \ Console \ Exception \ RuntimeException ( 'You can only access this function through a console' ) ; } if ( ( bool ) $ request -> getParam ( 'help' , false ) || $ request -> ...
Will check and update the entire database structure .
2,394
protected function getHelpOutput ( ) { $ result = "\n" ; $ result .= "Copyright 2014 by Jasper van Herpt <jasper.v.herpt@gmail.com>\n" ; $ result .= "\n" ; $ result .= "Database actions:" ; $ result .= "\n" ; $ result .= "Usage:\t\tacl database [clean-install|update] [--email=] [--help|-h] [--verbose|-v]\n" ; $ result ...
Get the help output for console usage of the JaztecAcl acl database console command .
2,395
public function add ( $ alert , $ class = 'danger' , $ dismissible = true ) { $ alertDefault = array ( 'alert' => '' , 'class' => $ class , 'dismissible' => $ dismissible , ) ; if ( ! \ is_array ( $ alert ) ) { $ alert = array ( 'alert' => $ alert , ) ; } else { foreach ( array ( 'alert' , 'class' , 'dismissible' ) as ...
Add an alert
2,396
public function buildAlerts ( ) { $ str = '' ; foreach ( $ this -> alerts as $ alert ) { $ str = $ this -> build ( $ alert ) ; } return $ str ; }
Default Alert Builder
2,397
private function build ( $ alert = array ( ) ) { $ str = '' ; $ alert = \ array_merge ( array ( 'alert' => '' , 'dismissible' => true , 'class' => 'danger' , 'framework' => 'bootstrap' , ) , $ alert ) ; $ alert [ 'class' ] = 'alert-' . $ alert [ 'class' ] ; if ( $ alert [ 'framework' ] == 'bootstrap' ) { if ( $ alert [...
Build an alert
2,398
public function log ( ) { $ this -> empty = true ; $ log = array ( ) ; $ pattern = "/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\].*/" ; $ log_levels = $ this -> getLevels ( ) ; $ log_file = $ this -> path . '/' . $ this -> fileName ; if ( ! empty ( $ log_file ) && File :: exists ( $ log_file ) ) { $ this -> empty = false ; ...
Open and parse the log .
2,399
public function getImageInfo ( array $ liprop = null , $ lilimit = null , $ listart = null , $ liend = null , $ liurlwidth = null , $ liurlheight = null , $ limetadataversion = null , $ liurlparam = null , $ licontinue = null ) { $ path = '?action=query&prop=imageinfo' ; if ( isset ( $ liprop ) ) { $ path .= '&liprop='...
Method to get all image information and upload history .