idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
8,800
private function dotGet ( string $ name ) { $ data = $ this -> data ; $ path = ( ! empty ( $ this -> prefix ) ? $ this -> prefix . '.' : '' ) . $ name ; if ( empty ( $ path ) ) { return $ data ; } $ path = explode ( '.' , rtrim ( $ path , '.' ) ) ; foreach ( $ path as $ step ) { if ( ! is_array ( $ data ) || ! array_ke...
Get element using dot notation .
8,801
public function validateFile ( Entity \ File $ file , $ sourceFilePath = null ) { $ this -> validate ( $ file , self :: TYPE_FILE , $ sourceFilePath ) ; }
Calls shared validation method
8,802
public function belongsTo ( NodeInterface $ node ) { parent :: belongsTo ( $ node ) ; $ rep = $ this -> sourceRepository ; if ( ! ( $ rep instanceof RepositoryInterface ) ) { throw new Exception \ WrongInstance ( $ rep , 'RepositoryInterface' ) ; } $ nestedSetRepository = $ rep -> getNestedSetRepository ( ) ; $ this ->...
Pass the doctrine entity the nested set node belongs to
8,803
public function free ( EntityNodeInterface $ entity ) { $ this -> repository -> free ( $ entity ) ; $ this -> repository = null ; }
Prepare object to be processed by garbage collector by removing it s instance from the Doctrine Repository Array Helper object
8,804
public function getCommandLine ( ) { if ( \ Yii :: $ app === null || ! $ this -> getIsConsoleRequest ( ) ) { return null ; } $ params = [ ] ; if ( isset ( $ _SERVER [ 'argv' ] ) ) { $ params = $ _SERVER [ 'argv' ] ; } return implode ( ' ' , $ params ) ; }
Returns the command line .
8,805
public function getIsConsoleRequest ( ) { if ( $ this -> _isConsoleRequest === null && \ Yii :: $ app !== null ) { if ( \ Yii :: $ app -> getRequest ( ) instanceof ConsoleRequest ) { $ this -> _isConsoleRequest = true ; } elseif ( \ Yii :: $ app -> getRequest ( ) instanceof WebRequest ) { $ this -> _isConsoleRequest = ...
Returns whether the current request is a console request .
8,806
public function getSessionId ( ) { if ( \ Yii :: $ app !== null && \ Yii :: $ app -> has ( 'session' , true ) && \ Yii :: $ app -> getSession ( ) !== null && \ Yii :: $ app -> getSession ( ) -> getIsActive ( ) ) { return \ Yii :: $ app -> getSession ( ) -> getId ( ) ; } else { return null ; } }
Returns the session ID .
8,807
public function getStackTrace ( ) { if ( ! isset ( $ this -> message [ 4 ] ) || empty ( $ this -> message [ 4 ] ) ) { return null ; } $ traces = array_map ( function ( $ trace ) { return "in {$trace['file']}:{$trace['line']}" ; } , $ this -> message [ 4 ] ) ; return implode ( "\n" , $ traces ) ; }
Returns the additional stack trace as a string .
8,808
public function getText ( ) { $ text = $ this -> message [ 0 ] ; if ( ! is_string ( $ text ) ) { if ( $ text instanceof \ Throwable || $ text instanceof \ Exception ) { $ text = ( string ) $ text ; } else { $ text = VarDumper :: export ( $ text ) ; } } return $ text ; }
Returns the message text .
8,809
public function getUrl ( ) { if ( \ Yii :: $ app === null || $ this -> getIsConsoleRequest ( ) ) { return null ; } return \ Yii :: $ app -> getRequest ( ) -> getAbsoluteUrl ( ) ; }
Returns the current absolute URL .
8,810
public function getUserId ( ) { if ( \ Yii :: $ app !== null && \ Yii :: $ app -> has ( 'user' , true ) && \ Yii :: $ app -> getUser ( ) !== null ) { $ user = \ Yii :: $ app -> getUser ( ) -> getIdentity ( false ) ; if ( $ user !== null ) { return $ user -> getId ( ) ; } } return null ; }
Returns the user identity ID .
8,811
private function getPointer ( ) { if ( ! isset ( $ this -> pointer ) ) { $ this -> pointer = fopen ( $ this -> source , 'r' ) ; if ( ! defined ( 'HHVM_VERSION' ) ) { stream_set_chunk_size ( $ this -> pointer , 32 ) ; stream_set_read_buffer ( $ this -> pointer , 32 ) ; } } return $ this -> pointer ; }
Returns the pointer to the random source .
8,812
public function translate ( $ params , & $ smarty ) { $ vars = array ( ) ; foreach ( $ params as $ name => $ value ) { if ( ! in_array ( $ name , $ this -> protectedParams ) ) { $ vars [ "%$name" ] = $ value ; } } $ str = $ this -> translator -> trans ( $ this -> getParam ( $ params , 'l' ) , $ vars , $ this -> getPara...
Process translate function
8,813
public function setSQL ( $ sql , array $ args = [ ] ) { $ this -> sql = $ sql ; $ this -> args = $ args ; $ this -> message = $ this -> getMessage ( ) ; if ( strlen ( $ sql ) > 2048 ) return $ this ; $ msg = '<br/>' . "\n" . 'SQL: ' . $ sql ; if ( count ( $ args ) > 0 ) { $ msg .= ' (' . implode ( ', ' , $ args ) . ')'...
Set SQL .
8,814
public static function renderHtmlTag ( array $ attributes , $ htmlTag , $ shortEndTag ) { $ output = '<' . $ htmlTag ; foreach ( $ attributes as $ attr => $ value ) { if ( static :: isValidValue ( $ value ) ) { $ output .= ' ' . $ attr . '="' . $ value . '"' ; } } $ output .= $ shortEndTag ? ' />' : '></' . $ htmlTag ....
Render the HTML tag .
8,815
public function replaceParameters ( $ data ) { if ( is_string ( $ data ) ) { return $ this -> replaceParametersScalar ( $ data ) ; } $ obj = $ this ; array_walk_recursive ( $ data , function ( & $ value ) use ( $ obj ) { if ( is_string ( $ value ) ) { $ value = $ obj -> replaceParametersScalar ( $ value ) ; } } ) ; ret...
Replaces %param . name% - > param . value in a given array
8,816
public function replaceParametersScalar ( $ data ) { $ count = preg_match_all ( '/%[a-z\\._]+%/i' , $ data , $ matches ) ; if ( ! $ count ) { return $ data ; } $ replacements = array ( ) ; foreach ( $ matches as $ expression ) { $ parameter = trim ( $ expression [ 0 ] , '%' ) ; $ replacements [ $ expression [ 0 ] ] = $...
Replaces %param . name% - > param . value in a given string
8,817
public function getParameter ( $ name ) { $ chunks = explode ( '.' , $ name ) ; $ name = $ chunks [ 0 ] . ( isset ( $ chunks [ 1 ] ) ? '.' . $ chunks [ 1 ] : '' ) ; if ( ! isset ( $ this -> parameters [ $ name ] ) ) { throw new ReferenceException ( sprintf ( 'Parameter "%s" is not defined in the container' , $ name ) )...
Gets parameter by name
8,818
public function canAccept ( self $ arguments ) : bool { if ( $ this -> values === null ) { return true ; } if ( $ this -> equal ( $ arguments ) ) { return true ; } $ values = $ arguments -> getValues ( ) ; if ( $ values === null ) { return false ; } if ( count ( $ this -> values ) !== count ( $ values ) ) { return fals...
Check if the specified arguments are acceptable as a match for the expected arguments .
8,819
public function run ( $ action , $ request = null ) { $ this -> action = $ action ; $ this -> defaultView = $ action ; if ( $ request === null ) $ request = new Request ; $ this -> request = $ request ; $ this -> response = new Response ; $ this -> response -> setRequest ( $ this -> request ) ; $ result = null ; foreac...
Run the action .
8,820
public function url ( $ action , $ params = [ ] ) { if ( is_array ( $ action ) ) return $ this -> resolver -> url ( $ action , $ params ) ; else return $ this -> resolver -> url ( [ get_called_class ( ) , $ action ] , $ params ) ; }
Return the url for a given action .
8,821
public function set ( $ name , $ value ) { \ Asgard \ Common \ ArrayUtils :: set ( $ this -> parameters , $ name , $ value ) ; return $ this ; }
Set parameter .
8,822
public function call ( Entity $ entity , $ name , array $ arguments ) { if ( isset ( $ this -> calls [ $ name ] ) ) { array_unshift ( $ arguments , $ entity ) ; return call_user_func_array ( $ this -> calls [ $ name ] , $ arguments ) ; } else { foreach ( $ this -> callsCatchAll as $ behavior ) { $ processed = false ; $...
Handle a custom call .
8,823
public function callStatic ( $ name , array $ arguments ) { if ( isset ( $ this -> statics [ $ name ] ) ) return call_user_func_array ( $ this -> statics [ $ name ] , $ arguments ) ; else { foreach ( $ this -> staticsCatchAll as $ behavior ) { $ processed = false ; $ res = call_user_func_array ( [ $ behavior , 'staticC...
Handle a custom static call .
8,824
public function loadBehaviors ( $ behaviors ) { if ( $ this -> generalHookManager !== null ) $ this -> generalHookManager -> trigger ( 'Asgard.Entity.LoadBehaviors' , [ $ this , & $ behaviors ] ) ; foreach ( $ behaviors as $ behavior ) $ this -> loadBehavior ( $ behavior ) ; }
Load the bahaviors .
8,825
public function loadBehavior ( $ behavior ) { if ( ! is_object ( $ behavior ) ) return ; if ( ! $ behavior instanceof \ Asgard \ Entity \ Behavior ) throw new \ Exception ( $ this -> entityClass . ' has an invalid behavior object.' ) ; $ behavior -> setDefinition ( $ this ) ; $ behavior -> load ( $ this ) ; $ reflectio...
Load a behavior .
8,826
public function set ( $ name , $ value ) { \ Asgard \ Common \ ArrayUtils :: set ( $ this -> metas , $ name , $ value ) ; return $ this ; }
Set a meta data .
8,827
public function processPreSet ( $ entity , $ name , & $ value , $ locale = null , $ hook = true , $ silentException = false ) { if ( $ hook ) $ this -> trigger ( 'set' , [ $ entity , $ name , & $ value , $ locale ] ) ; if ( $ this -> hasProperty ( $ name ) ) { if ( $ this -> property ( $ name ) -> get ( 'hooks.set' ) )...
Process values before entity set .
8,828
public function processPreAdd ( $ entity , $ name , & $ value , $ locale = null , $ hook = true , $ silentException = false ) { if ( $ hook ) $ this -> trigger ( 'set' , [ $ entity , $ name , & $ value , $ locale ] ) ; if ( ! $ this -> hasProperty ( $ name ) ) return ; if ( $ this -> property ( $ name ) -> get ( 'hooks...
Process values before adding to a ManyCollection .
8,829
public function make ( array $ attrs = null , $ locale = null ) { $ entityClass = $ this -> entityClass ; $ entity = new $ entityClass ( $ attrs , $ locale , $ this ) ; return $ entity ; }
Make a new entity .
8,830
protected function getRealAssetName ( $ assetName ) { $ prefix = 0 === strpos ( $ assetName , '?' ) ? '?' : '' ; $ assetName = ltrim ( $ assetName , '?' ) ; if ( null !== $ this -> replacementManager && $ this -> replacementManager -> hasReplacement ( $ assetName ) ) { $ assetName = $ this -> replacementManager -> getR...
Get the real asset name .
8,831
public function requeue ( $ delay , $ backoff = false ) { $ this -> isResponded = true ; $ this -> delegate -> onRequeue ( $ this , $ delay , $ backoff ) ; }
Requeue sends a REQ command to the nsqd which sent this message using the supplied delay .
8,832
static function makeOptions ( array $ options , $ indent = '' ) { $ o = mapAndFilter ( $ options , function ( $ v , $ k ) use ( $ indent ) { if ( is_object ( $ v ) ) { if ( $ v instanceof \ RawText ) return "$k: $v" ; if ( method_exists ( $ v , 'toArray' ) ) $ v = $ v -> toArray ( ) ; else $ v = ( array ) $ v ; } retur...
Generates a javascript representation of the provided options stripping the ones that are null or empty strings .
8,833
public static function hasPosts ( $ tagID , $ postTypeSlug = '' ) { $ postTypeSlug ( $ postTypeSlug ? $ postTypeSlug : PostType :: getSlug ( ) ) ; $ queryObject = DB :: table ( tagsRelationTable ( $ postTypeSlug ) ) -> where ( 'tagID' , $ tagID ) ; if ( $ queryObject -> count ( ) > 0 ) { return true ; } return false ; ...
Check if there is any post related to a tag .
8,834
public function featuredImageURL ( $ width = null , $ height = null , $ defaultFeaturedImageURL = '' ) { if ( $ this -> hasFeaturedImage ( ) ) { if ( ! $ width && ! $ height ) { return url ( $ this -> featuredImage -> url ) ; } else { return $ this -> featuredImage -> thumb ( $ width , $ height , $ this -> featuredImag...
Get URL of a tag s featured image .
8,835
protected function parseSupraLinkStart ( LinkReferencedElement $ link ) { $ tag = new HtmlTagStart ( 'a' ) ; $ title = ReferencedElementUtils :: getLinkReferencedElementTitle ( $ link , $ this -> container -> getDoctrine ( ) -> getManager ( ) , $ this -> container -> getLocaleManager ( ) -> getCurrentLocale ( ) ) ; $ u...
Parse supra . link return beginning part of referenced link element .
8,836
protected function parseSupraImage ( ImageReferencedElement $ imageData ) { $ imageId = $ imageData -> getImageId ( ) ; $ fileStorage = $ this -> container [ 'cms.file_storage' ] ; $ image = $ fileStorage -> findImage ( $ imageId ) ; if ( $ image === null ) { return null ; } $ sizeName = $ imageData -> getSizeName ( ) ...
Parse supra . image
8,837
final public function filterWithRepository ( Collection $ collection , Repository $ repository , WhereExpressionCollector $ sqlStatement , & $ params ) { $ speciatedFilter = $ repository -> getRepositorySpecificFilter ( $ this ) ; if ( $ speciatedFilter ) { $ filtered = $ speciatedFilter -> doFilterWithRepository ( $ c...
Returns A string containing information needed for a repository to use a filter directly .
8,838
public function noty ( $ type , $ message , $ key = "" ) { array_push ( $ this -> notyMessages , [ 'key' => $ key , 'type' => $ type , 'message' => $ message , ] ) ; return ; }
Noty messages . retrun nory messages array structure .
8,839
public static function findBySlug ( $ slug , $ postTypeSlug = '' ) { $ postTypeSlug = ( $ postTypeSlug ? $ postTypeSlug : PostType :: getSlug ( ) ) ; $ postObj = ( new Post ( ) ) -> setTable ( $ postTypeSlug ) ; $ post = $ postObj -> where ( 'slug_' . App :: getLocale ( ) , $ slug ) -> with ( $ postObj -> getDefaultRel...
Find a post by slug .
8,840
public static function findByID ( $ postID , $ postTypeSlug = '' ) { $ postTypeSlug = ( $ postTypeSlug ? $ postTypeSlug : PostType :: getSlug ( ) ) ; $ postObj = ( new Post ( ) ) -> setTable ( $ postTypeSlug ) ; $ post = $ postObj -> where ( 'postID' , $ postID ) -> with ( $ postObj -> getDefaultRelations ( getPostType...
Find a post by ID .
8,841
private static function handleObjectOrArrayValues ( $ formData , $ translatable , $ languages = [ ] ) { if ( $ formData [ 'type' ] [ 'inputType' ] == 'db' ) { $ tmpArr = [ ] ; $ primaryKey = "" ; if ( $ formData [ 'dbTable' ] [ 'belongsTo' ] == 'User' ) { $ primaryKey = "userID" ; } else if ( $ formData [ 'dbTable' ] [...
Handles post type field values .
8,842
public static function insertCategories ( $ selectedCategories , $ postID , $ postTypeSlug ) { if ( count ( $ selectedCategories ) ) { $ categoriesIDs = [ ] ; $ newCategoryRelation = [ ] ; foreach ( $ selectedCategories as $ selectedCategory ) { $ newCategoryRelation [ ] = [ 'categoryID' => $ selectedCategory [ 'catego...
Insert Post Categories .
8,843
public static function insertTags ( $ selectedTags , $ postID , $ postType ) { if ( count ( $ selectedTags ) ) { $ tagsIDs = [ ] ; $ newTagsRelations = [ ] ; foreach ( $ selectedTags as $ langSlug => $ selectedTagForLanguage ) { if ( $ selectedTagForLanguage ) { foreach ( $ selectedTagForLanguage as $ selectedTag ) { i...
Insert Post tags .
8,844
public static function insertMedia ( $ mediaFiles , $ postID , $ postTypeSlug , $ languages , $ notTranslatableFiles , $ filesToBeIgnored = [ ] ) { $ imagesArr = array ( ) ; foreach ( $ mediaFiles as $ fileKey => $ files ) { if ( $ fileKey == 'featuredImage' || $ fileKey == 'featuredVideo' || in_array ( $ fileKey , $ f...
Insert Post media files .
8,845
public static function getAdvancedSearchFields ( $ postType ) { $ postTypeFields = json_decode ( DB :: table ( 'post_type' ) -> where ( "slug" , $ postType ) -> first ( ) -> fields ) ; $ advancedSearchFields = array ( ) ; foreach ( $ postTypeFields as $ fieldArray ) { if ( $ fieldArray -> type -> inputType == "image" |...
Setup advanced search fields to be used in Posts advanced search .
8,846
public static function getCustomTemplate ( $ baseTemplateName , $ postType ) { if ( strstr ( $ postType , '_' ) ) { $ explodePostTypeName = explode ( '_' , $ postType ) ; $ postType = $ explodePostTypeName [ 1 ] ; } $ postTypeFileName = $ baseTemplateName . ucfirst ( $ postType ) . ".vue" ; if ( file_exists ( $ _SERVER...
Get a custom vuejs template for a particular default function .
8,847
public function featuredImageURL ( $ width = null , $ height = null , $ defaultFeaturedImageURL = '' , array $ options = [ ] ) { $ imageURL = null ; if ( $ this -> hasFeaturedImage ( ) ) { if ( ! $ width && ! $ height ) { $ imageURL = url ( $ this -> featuredImage -> url ) . "?" . strtotime ( $ this -> updated_at ) ; }...
Get URL of post s featured image .
8,848
public function printTags ( $ customView = '' , $ ulClass = "" ) { if ( $ this -> hasTags ( ) ) { $ tags = "tags" ; return new HtmlString ( view ( ) -> make ( ( $ customView ? $ customView : "vendor.tags.default" ) , [ 'tagsList' => $ this -> $ tags , 'ulClass' => $ ulClass , 'postTypeSlug' => $ this -> getTable ( ) ] ...
Render Tags of a post .
8,849
public function hasTags ( ) { $ tags = "tags" ; $ postType = getPostType ( $ this -> getTable ( ) ) ; return ( $ postType -> hasTags && isset ( $ this -> $ tags ) && ! $ this -> $ tags -> isEmpty ( ) ) ; }
Check if a post has tags .
8,850
public function hasCategory ( ) { $ postType = getPostType ( $ this -> getTable ( ) ) ; return ( $ postType -> hasCategories && isset ( $ this -> categories ) && ! $ this -> categories -> isEmpty ( ) ) ; }
Check if a post has a primary category .
8,851
public function content ( ) { ob_start ( ) ; print $ this -> beforeContentEvents ( ) ; print $ this -> content ; print $ this -> afterContentEvents ( ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ content ; }
Handle post s content .
8,852
public static function isInMenuLinks ( $ postID , $ postType ) { $ isInMenulinks = MenuLink :: where ( 'belongsToID' , $ postID ) -> where ( 'belongsTo' , $ postType ) -> count ( ) ; if ( $ isInMenulinks ) { return true ; } return false ; }
Check if post is being used as menu link .
8,853
public static function updateMenulink ( $ post ) { if ( self :: isInMenuLinks ( $ post -> postID , $ post -> getTable ( ) ) ) { $ menuLinks = MenuLink :: where ( 'belongsToID' , $ post -> postID ) -> where ( 'belongsTo' , $ post -> getTable ( ) ) -> get ( ) ; foreach ( $ menuLinks as $ menuLink ) { $ menuLink -> params...
Update post parameters in MenuLink .
8,854
public static function getDefaultPostRoutes ( $ postType ) { $ baseRouteName = str_replace ( '_' , '.' , $ postType -> slug ) ; return [ 'defaultRoute' => $ baseRouteName . '.single' , 'list' => [ $ baseRouteName . '.single' => $ postType -> name . ' single Post' , ] ] ; }
Get Default routes for post types that do not have their own Controller .
8,855
public static function getDefaultPostTypeRoutes ( $ postType ) { $ baseRouteName = str_replace ( '_' , '.' , $ postType -> slug ) ; return [ 'defaultRoute' => $ baseRouteName . '.index' , 'list' => [ $ baseRouteName . '.index' => $ postType -> name . ' Index' ] ] ; }
Get default routes for a post type .
8,856
public function trigger ( $ name , array $ args = [ ] , $ cb = null , & $ chain = null ) { if ( ! $ this -> getHookManager ( ) ) return ; return $ this -> getHookManager ( ) -> trigger ( $ name , $ args , $ cb , $ chain ) ; }
Trigger a hook .
8,857
public function preHook ( $ hookName , $ cb ) { $ args = [ $ hookName , $ cb ] ; return call_user_func_array ( [ $ this -> getHookManager ( ) , 'preHook' ] , $ args ) ; }
Set a pre hook .
8,858
public function postHook ( $ hookName , $ cb ) { $ args = [ $ hookName , $ cb ] ; return call_user_func_array ( [ $ this -> getHookManager ( ) , 'postHook' ] , $ args ) ; }
Set an post hook .
8,859
public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ this -> pages = new ArrayCollection ( ) ; $ this -> manager = $ eventArgs -> getEntityManager ( ) ; $ uow = $ this -> manager -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityUpdates ( ) as $ entity ) { $ this -> handleEntity ( $ entity ) ; } forea...
Flush event handler .
8,860
private function handleEntity ( $ entity ) { if ( null !== $ page = $ this -> findRelatedPage ( $ entity ) ) { if ( null === $ page -> getId ( ) ) { return ; } if ( ! $ this -> pages -> contains ( $ page ) ) { $ this -> pages -> add ( $ page ) ; } } }
Handles the entity .
8,861
private function findRelatedPage ( $ entity ) { if ( $ entity instanceof Cms \ PageTranslationInterface ) { return $ entity -> getTranslatable ( ) ; } if ( $ entity instanceof Cms \ SeoTranslationInterface && null !== $ entity -> getId ( ) ) { return $ this -> manager -> createQuery ( "SELECT p FROM {$this->pageClass} ...
Finds the related page .
8,862
public static function getDriver ( string $ connectionString ) { $ connection = [ 'orig' => $ connectionString , 'type' => null , 'user' => null , 'pass' => null , 'host' => null , 'port' => null , 'name' => null , 'opts' => [ ] ] ; $ aliases = [ 'mysqli' => 'mysql' , 'pg' => 'postgre' , 'oci' => 'oracle' , 'firebird' ...
Create a driver instance from a connection string
8,863
public function one ( string $ sql , $ par = null , bool $ opti = true ) { return $ this -> get ( $ sql , $ par , null , false , $ opti ) -> value ( ) ; }
Run a SELECT query and get a single row
8,864
public function all ( string $ sql , $ par = null , string $ key = null , bool $ skip = false , bool $ opti = true ) : array { return $ this -> get ( $ sql , $ par , $ key , $ skip , $ opti ) -> toArray ( ) ; }
Run a SELECT query and get an array
8,865
public function getSchema ( $ asPlainArray = true ) { return ! $ asPlainArray ? $ this -> tables : array_map ( function ( $ table ) { return [ 'name' => $ table -> getName ( ) , 'pkey' => $ table -> getPrimaryKey ( ) , 'comment' => $ table -> getComment ( ) , 'columns' => array_map ( function ( $ column ) { return [ 'n...
Get the full schema as an array that you can serialize and store
8,866
public function table ( $ table , bool $ mapped = false ) { return $ mapped ? new TableQueryMapped ( $ this , $ this -> definition ( $ table ) ) : new TableQuery ( $ this , $ this -> definition ( $ table ) ) ; }
Initialize a table query
8,867
public static function get_last_name ( $ source ) { $ name = explode ( ' ' , self :: parse_source_path ( 'info.name' , $ source ) ) ; array_shift ( $ name ) ; return join ( ' ' , $ name ) ; }
Take all but the first part of the name
8,868
public static function get_google_locale ( $ source ) { $ locale = self :: parse_source_path ( 'raw.locale' , $ source ) ; if ( ! $ locale ) { return self :: get_smart_locale ( ) ; } return str_replace ( '-' , '_' , $ locale ) ; }
Google responds near perfectly for locales if populated . Fallback otherwise .
8,869
public static function get_smart_locale ( $ language = null ) { require_once FRAMEWORK_PATH . '/thirdparty/Zend/Locale.php' ; $ locale = Zend_Locale :: getBrowser ( ) ; if ( ! $ locale ) { if ( $ language ) { return i18n :: get_locale_from_lang ( $ language ) ; } else { return i18n :: get_locale ( ) ; } } $ locale = ar...
Try very hard to get a locale for this user . Helps for i18n etc .
8,870
public static function parse_source_path ( $ path , $ source ) { $ fragments = explode ( '.' , $ path ) ; $ currentFrame = $ source ; foreach ( $ fragments as $ fragment ) { if ( ! isset ( $ currentFrame [ $ fragment ] ) ) { return null ; } $ currentFrame = $ currentFrame [ $ fragment ] ; } return $ currentFrame ; }
Dot notation parser . Looks for an index or fails gracefully if not found .
8,871
public static function camelToUnderdash ( $ s ) { $ s = preg_replace ( '#(.)(?=[A-Z])#' , '$1_' , $ s ) ; $ s = strtolower ( $ s ) ; $ s = rawurlencode ( $ s ) ; return $ s ; }
camelCase - > underdash_separated .
8,872
public static function underdashToCamel ( $ s ) { $ s = strtolower ( $ s ) ; $ s = preg_replace ( '#_(?=[a-z])#' , ' ' , $ s ) ; $ s = substr ( ucwords ( 'x' . $ s ) , 1 ) ; $ s = str_replace ( ' ' , '' , $ s ) ; return $ s ; }
underdash_separated - > camelCase
8,873
public static function resolve ( Uri $ baseUri , Uri $ targetUri ) { if ( ! $ baseUri -> isAbsolute ( ) ) { throw new InvalidArgumentException ( 'Base uri must be absolute' ) ; } if ( $ targetUri -> isAbsolute ( ) ) { $ path = $ targetUri -> getPath ( ) ; if ( ! empty ( $ path ) ) { return $ targetUri -> withPath ( $ p...
Resolves a base uri against a target uri
8,874
public static function percentEncode ( $ value , $ preventDoubleEncode = true ) { $ len = strlen ( $ value ) ; $ val = '' ; for ( $ i = 0 ; $ i < $ len ; $ i ++ ) { $ j = ord ( $ value [ $ i ] ) ; if ( $ j <= 0xFF ) { if ( $ preventDoubleEncode ) { if ( $ j == 0x25 && $ i < $ len - 2 ) { $ hex = strtoupper ( substr ( $...
Percent encodes a value
8,875
public static function getByName ( $ belongsTo , $ name , $ defaultURL = '' ) { $ singlePermalink = Permalink :: where ( 'belongsTo' , $ belongsTo ) -> where ( "name" , $ name ) -> first ( ) ; if ( $ singlePermalink && $ singlePermalink -> custom_url ) { return $ singlePermalink -> custom_url ; } if ( ! $ singlePermali...
Get a permalink by name .
8,876
public static function removeIndex ( string $ list , $ index , string $ separator ) : string { $ items = self :: explode ( $ separator , $ list ) ; if ( isset ( $ items [ $ index ] ) ) { unset ( $ items [ $ index ] ) ; } return implode ( $ separator , $ items ) ; }
Remove index .
8,877
public static function drop ( $ name ) { if ( ! isset ( self :: $ _config [ $ name ] ) ) { return false ; } unset ( self :: $ _config [ $ name ] , self :: $ _engines [ $ name ] , self :: $ _logs [ $ name ] ) ; return true ; }
Drops a cache engine . Deletes the cache configuration information If the deleted configuration is the last configuration using an certain engine the Engine instance is also unset .
8,878
public static function clearGroup ( $ group , $ config = 'default' ) { if ( ! self :: isInitialized ( $ config ) ) { return false ; } $ start = microtime ( true ) ; $ success = self :: $ _engines [ $ config ] -> clearGroup ( $ group ) ; self :: __logActivity ( $ config , 'clearGroup' , '' , $ success , $ start ) ; self...
Delete all keys from the cache belonging to the same group .
8,879
public static function settings ( $ name = 'default' ) { if ( ! empty ( self :: $ _engines [ $ name ] ) ) { return self :: $ _engines [ $ name ] -> settings ( ) ; } return array ( ) ; }
Return the settings for the named cache engine .
8,880
private static function __logActivity ( $ config , $ type , $ key , $ success , $ startTime ) { $ queryTime = round ( ( microtime ( true ) - $ startTime ) * 1000 , 2 ) ; self :: $ _logs [ $ config ] [ ] = array ( 'type' => $ type , 'key' => $ key , 'success' => $ success , 'time' => $ queryTime ) ; self :: $ _queriesTi...
Log a cache activity
8,881
public function getVariable ( $ which ) { if ( isset ( $ this -> data [ $ which ] ) ) { return $ this -> data [ $ which ] ; } elseif ( isset ( $ this -> config [ "data" ] ) ) { return $ this -> config [ "data" ] [ $ which ] ; } return null ; }
Get a value of a variable which will be exposed to the template files during render .
8,882
protected function getTimezoneRegions ( ) { return [ 'UTC' => DateTimeZone :: UTC , 'Africa' => DateTimeZone :: AFRICA , 'America' => DateTimeZone :: AMERICA , 'Antarctica' => DateTimeZone :: ANTARCTICA , 'Asia' => DateTimeZone :: ASIA , 'Atlantic' => DateTimeZone :: ATLANTIC , 'Australia' => DateTimeZone :: AUSTRALIA ...
Gets a list of timezone regions .
8,883
protected function getTimezoneLocations ( $ region ) { $ locations = [ ] ; foreach ( DateTimeZone :: listIdentifiers ( $ region ) as $ timezone ) { $ locations [ ] = substr ( $ timezone , strpos ( $ timezone , '/' ) + 1 ) ; } return $ locations ; }
Gets a list of available locations in the supplied region .
8,884
public function deleteAction ( ) { $ this -> checkLock ( ) ; $ this -> isPostRequest ( ) ; $ folder = $ this -> getPageLocalization ( ) -> getMaster ( ) ; if ( $ folder -> hasChildren ( ) ) { throw new CmsException ( null , 'Cannot remove non-empty folder.' ) ; } $ this -> getEntityManager ( ) -> remove ( $ folder ) ; ...
Folder delete action .
8,885
public function saveAction ( ) { $ this -> isPostRequest ( ) ; $ this -> checkLock ( ) ; $ localization = $ this -> getPageLocalization ( ) ; if ( ! $ localization instanceof GroupLocalization ) { throw new \ UnexpectedValueException ( sprintf ( 'Expecting instanceof GroupLocalization, [%s] received.' , get_class ( $ l...
Settings save action handler . Initiated when group title is changed via Sitemap .
8,886
public function flushToContext ( ResponseContext $ mainContext ) { foreach ( $ this -> getAllValues ( ) as $ key => $ value ) { $ mainContext -> setValue ( $ key , $ value ) ; } foreach ( $ this -> layoutSnippetResponses as $ key => $ responses ) { foreach ( $ responses as $ snippet ) { $ mainContext -> addToLayoutSnip...
Flushes all data to another response context
8,887
public function getNext ( ) { if ( ! $ this -> valid ( ) ) { throw new \ OutOfBoundsException ( 'End of iterator reached.' ) ; } $ value = $ this -> get ( $ this -> key ( ) ) ; $ this -> next ( ) ; return $ value ; }
Loads next value in scalar value input and advances the iterator pointer .
8,888
public function apply ( ) { if ( $ this -> config -> hasKey ( self :: REMOVE ) ) { $ removeConfig = $ this -> config -> getSubConfig ( self :: REMOVE ) ; $ this -> remove ( $ removeConfig -> getArrayCopy ( ) ) ; } if ( $ this -> config -> hasKey ( self :: ADD ) ) { $ addConfig = $ this -> config -> getSubConfig ( self ...
Apply theme support items .
8,889
protected function add ( array $ items ) { array_walk ( $ items , function ( $ value , string $ key ) { add_theme_support ( $ key , $ value ) ; } ) ; }
Add theme support for given keys and values .
8,890
public function getCheckboxes ( array $ options = [ ] ) { if ( isset ( $ options [ 'choices' ] ) ) $ choices = $ options [ 'choices' ] ; else $ choices = $ this -> getChoices ( ) ; $ checkboxes = [ ] ; foreach ( $ choices as $ k => $ v ) { $ checkbox_options = $ options ; $ checkbox_options [ 'value' ] = $ k ; $ checkb...
Return checkboxes .
8,891
public function getCheckbox ( $ name , array $ options = [ ] ) { $ choices = $ this -> getChoices ( ) ; $ default = $ this -> value ; $ value = isset ( $ options [ 'value' ] ) ? $ options [ 'value' ] : null ; if ( $ value === null ) { foreach ( $ choices as $ k => $ v ) { if ( $ v == $ name ) { $ value = $ k ; break ; ...
Return a checkbox widget .
8,892
public function href ( $ routeName = '' , $ customAttributes = [ ] ) { if ( ! $ routeName ) { $ routeName = 'category.posts' ; } $ getRoute = Route :: getRoutes ( ) -> getByName ( $ routeName ) ; if ( $ getRoute ) { $ routeParams = Route :: getRoutes ( ) -> getByName ( $ routeName ) -> parameterNames ( ) ; if ( $ this ...
Generate a custom URL to a category .
8,893
public function scopeVisible ( $ query , $ languageSlug = '' ) { if ( ! $ languageSlug ) { $ languageSlug = App :: getLocale ( ) ; } return $ query -> where ( 'isVisible->' . $ languageSlug , true ) ; }
Scope a query to only include visible categories .
8,894
public function getRadios ( array $ options = [ ] ) { if ( isset ( $ options [ 'choices' ] ) ) $ choices = $ options [ 'choices' ] ; else $ choices = $ this -> getChoices ( ) ; $ radios = [ ] ; foreach ( $ choices as $ k => $ v ) { $ radio_options = $ options ; $ radio_options [ 'value' ] = $ k ; $ radio_options [ 'wid...
Return radios widgets .
8,895
public function GetMashupTokensPage ( string $ tag , int $ lastKnownScanTicks = 0 , int $ pageSize = 50 ) { $ tokens = $ this -> ExecuteCall ( "GetMashupTokensPage" , ( object ) [ "tag" => $ tag , "lastKnownScanTicks" => $ lastKnownScanTicks , "pageSize" => $ pageSize ] , GnResponseType :: ListGnMashupToken ) ; return ...
Get a page of user - scanned QR - tokens from the oldest already read toward the newer ones .
8,896
public function getAccessToken ( ) { if ( is_string ( $ this -> access_token ) && $ this -> isValidToken ( ) ) { $ this -> accessToken = $ this -> token_type . ' ' . $ this -> access_token ; return $ this -> accessToken ; } return false ; }
Return the access token if it is valid
8,897
public function getRefreshToken ( ) { if ( is_string ( $ this -> refresh_token ) && $ this -> isValidToken ( ) ) { $ this -> refreshToken = $ this -> token_type . ' ' . $ this -> refresh_token ; return $ this -> refreshToken ; } return false ; }
Return the Refresh Token if available and valid
8,898
public function set ( $ key , $ value = null ) { $ this -> setAcquisitionTime ( ) ; if ( is_null ( $ value ) && is_array ( $ key ) ) { foreach ( $ key as $ attribute => $ value ) { $ this -> setValue ( $ attribute , $ value ) ; } } else { $ this -> setValue ( $ key , $ value ) ; } }
Set one or an array of attributes for the class
8,899
private function setValue ( $ key , $ value ) { $ this -> $ key = $ value ; if ( $ key == 'expires_in' ) $ this -> setExpiration ( $ value ) ; }
Set a single attribute value